Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

27464 строки
1.1 MiB

  1. var __create = Object.create;
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __require = /* @__PURE__ */ ((x2) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x2, {
  7. get: (a2, b2) => (typeof require < "u" ? require : a2)[b2]
  8. }) : x2)(function(x2) {
  9. if (typeof require < "u") return require.apply(this, arguments);
  10. throw Error('Dynamic require of "' + x2 + '" is not supported');
  11. });
  12. var __esm = (fn, res) => function() {
  13. return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
  14. };
  15. var __commonJS = (cb, mod) => function() {
  16. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  17. };
  18. var __export = (target, all) => {
  19. for (var name in all)
  20. __defProp(target, name, { get: all[name], enumerable: !0 });
  21. }, __copyProps = (to, from, except, desc) => {
  22. if (from && typeof from == "object" || typeof from == "function")
  23. for (let key of __getOwnPropNames(from))
  24. !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  25. return to;
  26. };
  27. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  28. // If the importer is in node compatibility mode or this is not an ESM
  29. // file that has been converted to a CommonJS file using a Babel-
  30. // compatible transform (i.e. "__esModule" has not been set), then set
  31. // "default" to the CommonJS "module.exports" for node compatibility.
  32. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
  33. mod
  34. )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
  35. // global-externals:react
  36. var react_exports = {};
  37. __export(react_exports, {
  38. Children: () => Children,
  39. Component: () => Component,
  40. Fragment: () => Fragment,
  41. Profiler: () => Profiler,
  42. PureComponent: () => PureComponent,
  43. StrictMode: () => StrictMode,
  44. Suspense: () => Suspense,
  45. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: () => __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
  46. act: () => act,
  47. cloneElement: () => cloneElement,
  48. createContext: () => createContext,
  49. createElement: () => createElement,
  50. createFactory: () => createFactory,
  51. createRef: () => createRef,
  52. default: () => react_default,
  53. forwardRef: () => forwardRef,
  54. isValidElement: () => isValidElement,
  55. lazy: () => lazy,
  56. memo: () => memo,
  57. startTransition: () => startTransition,
  58. unstable_act: () => unstable_act,
  59. useCallback: () => useCallback,
  60. useContext: () => useContext,
  61. useDebugValue: () => useDebugValue,
  62. useDeferredValue: () => useDeferredValue,
  63. useEffect: () => useEffect,
  64. useId: () => useId,
  65. useImperativeHandle: () => useImperativeHandle,
  66. useInsertionEffect: () => useInsertionEffect,
  67. useLayoutEffect: () => useLayoutEffect,
  68. useMemo: () => useMemo,
  69. useReducer: () => useReducer,
  70. useRef: () => useRef,
  71. useState: () => useState,
  72. useSyncExternalStore: () => useSyncExternalStore,
  73. useTransition: () => useTransition,
  74. version: () => version
  75. });
  76. var react_default, Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, act, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, unstable_act, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version, init_react = __esm({
  77. "global-externals:react"() {
  78. react_default = __REACT__, { Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, act, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, unstable_act, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version } = __REACT__;
  79. }
  80. });
  81. // ../../node_modules/prop-types/lib/ReactPropTypesSecret.js
  82. var require_ReactPropTypesSecret = __commonJS({
  83. "../../node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
  84. "use strict";
  85. var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
  86. module.exports = ReactPropTypesSecret;
  87. }
  88. });
  89. // ../../node_modules/prop-types/factoryWithThrowingShims.js
  90. var require_factoryWithThrowingShims = __commonJS({
  91. "../../node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
  92. "use strict";
  93. var ReactPropTypesSecret = require_ReactPropTypesSecret();
  94. function emptyFunction() {
  95. }
  96. function emptyFunctionWithReset() {
  97. }
  98. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  99. module.exports = function() {
  100. function shim(props, propName, componentName, location2, propFullName, secret) {
  101. if (secret !== ReactPropTypesSecret) {
  102. var err = new Error(
  103. "Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
  104. );
  105. throw err.name = "Invariant Violation", err;
  106. }
  107. }
  108. shim.isRequired = shim;
  109. function getShim() {
  110. return shim;
  111. }
  112. var ReactPropTypes = {
  113. array: shim,
  114. bigint: shim,
  115. bool: shim,
  116. func: shim,
  117. number: shim,
  118. object: shim,
  119. string: shim,
  120. symbol: shim,
  121. any: shim,
  122. arrayOf: getShim,
  123. element: shim,
  124. elementType: shim,
  125. instanceOf: getShim,
  126. node: shim,
  127. objectOf: getShim,
  128. oneOf: getShim,
  129. oneOfType: getShim,
  130. shape: getShim,
  131. exact: getShim,
  132. checkPropTypes: emptyFunctionWithReset,
  133. resetWarningCache: emptyFunction
  134. };
  135. return ReactPropTypes.PropTypes = ReactPropTypes, ReactPropTypes;
  136. };
  137. }
  138. });
  139. // ../../node_modules/prop-types/index.js
  140. var require_prop_types = __commonJS({
  141. "../../node_modules/prop-types/index.js"(exports, module) {
  142. module.exports = require_factoryWithThrowingShims()();
  143. var ReactIs, throwOnDirectAccess;
  144. }
  145. });
  146. // ../../node_modules/react-fast-compare/index.js
  147. var require_react_fast_compare = __commonJS({
  148. "../../node_modules/react-fast-compare/index.js"(exports, module) {
  149. var hasElementType = typeof Element < "u", hasMap = typeof Map == "function", hasSet = typeof Set == "function", hasArrayBuffer = typeof ArrayBuffer == "function" && !!ArrayBuffer.isView;
  150. function equal3(a2, b2) {
  151. if (a2 === b2) return !0;
  152. if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
  153. if (a2.constructor !== b2.constructor) return !1;
  154. var length, i2, keys;
  155. if (Array.isArray(a2)) {
  156. if (length = a2.length, length != b2.length) return !1;
  157. for (i2 = length; i2-- !== 0; )
  158. if (!equal3(a2[i2], b2[i2])) return !1;
  159. return !0;
  160. }
  161. var it;
  162. if (hasMap && a2 instanceof Map && b2 instanceof Map) {
  163. if (a2.size !== b2.size) return !1;
  164. for (it = a2.entries(); !(i2 = it.next()).done; )
  165. if (!b2.has(i2.value[0])) return !1;
  166. for (it = a2.entries(); !(i2 = it.next()).done; )
  167. if (!equal3(i2.value[1], b2.get(i2.value[0]))) return !1;
  168. return !0;
  169. }
  170. if (hasSet && a2 instanceof Set && b2 instanceof Set) {
  171. if (a2.size !== b2.size) return !1;
  172. for (it = a2.entries(); !(i2 = it.next()).done; )
  173. if (!b2.has(i2.value[0])) return !1;
  174. return !0;
  175. }
  176. if (hasArrayBuffer && ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
  177. if (length = a2.length, length != b2.length) return !1;
  178. for (i2 = length; i2-- !== 0; )
  179. if (a2[i2] !== b2[i2]) return !1;
  180. return !0;
  181. }
  182. if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
  183. if (a2.valueOf !== Object.prototype.valueOf && typeof a2.valueOf == "function" && typeof b2.valueOf == "function") return a2.valueOf() === b2.valueOf();
  184. if (a2.toString !== Object.prototype.toString && typeof a2.toString == "function" && typeof b2.toString == "function") return a2.toString() === b2.toString();
  185. if (keys = Object.keys(a2), length = keys.length, length !== Object.keys(b2).length) return !1;
  186. for (i2 = length; i2-- !== 0; )
  187. if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return !1;
  188. if (hasElementType && a2 instanceof Element) return !1;
  189. for (i2 = length; i2-- !== 0; )
  190. if (!((keys[i2] === "_owner" || keys[i2] === "__v" || keys[i2] === "__o") && a2.$$typeof) && !equal3(a2[keys[i2]], b2[keys[i2]]))
  191. return !1;
  192. return !0;
  193. }
  194. return a2 !== a2 && b2 !== b2;
  195. }
  196. module.exports = function(a2, b2) {
  197. try {
  198. return equal3(a2, b2);
  199. } catch (error) {
  200. if ((error.message || "").match(/stack|recursion/i))
  201. return console.warn("react-fast-compare cannot handle circular refs"), !1;
  202. throw error;
  203. }
  204. };
  205. }
  206. });
  207. // ../../node_modules/invariant/browser.js
  208. var require_browser = __commonJS({
  209. "../../node_modules/invariant/browser.js"(exports, module) {
  210. "use strict";
  211. var invariant = function(condition, format, a2, b2, c2, d2, e2, f2) {
  212. if (!condition) {
  213. var error;
  214. if (format === void 0)
  215. error = new Error(
  216. "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
  217. );
  218. else {
  219. var args = [a2, b2, c2, d2, e2, f2], argIndex = 0;
  220. error = new Error(
  221. format.replace(/%s/g, function() {
  222. return args[argIndex++];
  223. })
  224. ), error.name = "Invariant Violation";
  225. }
  226. throw error.framesToPop = 1, error;
  227. }
  228. };
  229. module.exports = invariant;
  230. }
  231. });
  232. // ../../node_modules/shallowequal/index.js
  233. var require_shallowequal = __commonJS({
  234. "../../node_modules/shallowequal/index.js"(exports, module) {
  235. module.exports = function(objA, objB, compare, compareContext) {
  236. var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
  237. if (ret !== void 0)
  238. return !!ret;
  239. if (objA === objB)
  240. return !0;
  241. if (typeof objA != "object" || !objA || typeof objB != "object" || !objB)
  242. return !1;
  243. var keysA = Object.keys(objA), keysB = Object.keys(objB);
  244. if (keysA.length !== keysB.length)
  245. return !1;
  246. for (var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB), idx = 0; idx < keysA.length; idx++) {
  247. var key = keysA[idx];
  248. if (!bHasOwnProperty(key))
  249. return !1;
  250. var valueA = objA[key], valueB = objB[key];
  251. if (ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0, ret === !1 || ret === void 0 && valueA !== valueB)
  252. return !1;
  253. }
  254. return !0;
  255. };
  256. }
  257. });
  258. // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
  259. var require_use_sync_external_store_shim_production = __commonJS({
  260. "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js"(exports) {
  261. "use strict";
  262. var React = (init_react(), __toCommonJS(react_exports));
  263. function is4(x2, y2) {
  264. return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
  265. }
  266. var objectIs = typeof Object.is == "function" ? Object.is : is4, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect2 = React.useLayoutEffect, useDebugValue2 = React.useDebugValue;
  267. function useSyncExternalStore$2(subscribe, getSnapshot) {
  268. var value = getSnapshot(), _useState = useState2({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
  269. return useLayoutEffect2(
  270. function() {
  271. inst.value = value, inst.getSnapshot = getSnapshot, checkIfSnapshotChanged(inst) && forceUpdate({ inst });
  272. },
  273. [subscribe, value, getSnapshot]
  274. ), useEffect2(
  275. function() {
  276. return checkIfSnapshotChanged(inst) && forceUpdate({ inst }), subscribe(function() {
  277. checkIfSnapshotChanged(inst) && forceUpdate({ inst });
  278. });
  279. },
  280. [subscribe]
  281. ), useDebugValue2(value), value;
  282. }
  283. function checkIfSnapshotChanged(inst) {
  284. var latestGetSnapshot = inst.getSnapshot;
  285. inst = inst.value;
  286. try {
  287. var nextValue = latestGetSnapshot();
  288. return !objectIs(inst, nextValue);
  289. } catch {
  290. return !0;
  291. }
  292. }
  293. function useSyncExternalStore$1(subscribe, getSnapshot) {
  294. return getSnapshot();
  295. }
  296. var shim = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? useSyncExternalStore$1 : useSyncExternalStore$2;
  297. exports.useSyncExternalStore = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim;
  298. }
  299. });
  300. // ../../node_modules/use-sync-external-store/shim/index.js
  301. var require_shim = __commonJS({
  302. "../../node_modules/use-sync-external-store/shim/index.js"(exports, module) {
  303. "use strict";
  304. module.exports = require_use_sync_external_store_shim_production();
  305. }
  306. });
  307. // ../../node_modules/memoizerific/memoizerific.js
  308. var require_memoizerific = __commonJS({
  309. "../../node_modules/memoizerific/memoizerific.js"(exports, module) {
  310. (function(f2) {
  311. if (typeof exports == "object" && typeof module < "u")
  312. module.exports = f2();
  313. else if (typeof define == "function" && define.amd)
  314. define([], f2);
  315. else {
  316. var g2;
  317. typeof window < "u" ? g2 = window : typeof global < "u" ? g2 = global : typeof self < "u" ? g2 = self : g2 = this, g2.memoizerific = f2();
  318. }
  319. })(function() {
  320. var define2, module2, exports2;
  321. return (function e2(t2, n3, r4) {
  322. function s2(o4, u2) {
  323. if (!n3[o4]) {
  324. if (!t2[o4]) {
  325. var a2 = typeof __require == "function" && __require;
  326. if (!u2 && a2) return a2(o4, !0);
  327. if (i2) return i2(o4, !0);
  328. var f2 = new Error("Cannot find module '" + o4 + "'");
  329. throw f2.code = "MODULE_NOT_FOUND", f2;
  330. }
  331. var l3 = n3[o4] = { exports: {} };
  332. t2[o4][0].call(l3.exports, function(e3) {
  333. var n4 = t2[o4][1][e3];
  334. return s2(n4 || e3);
  335. }, l3, l3.exports, e2, t2, n3, r4);
  336. }
  337. return n3[o4].exports;
  338. }
  339. for (var i2 = typeof __require == "function" && __require, o3 = 0; o3 < r4.length; o3++) s2(r4[o3]);
  340. return s2;
  341. })({ 1: [function(_dereq_, module3, exports3) {
  342. module3.exports = function(forceSimilar) {
  343. if (typeof Map != "function" || forceSimilar) {
  344. var Similar = _dereq_("./similar");
  345. return new Similar();
  346. } else
  347. return /* @__PURE__ */ new Map();
  348. };
  349. }, { "./similar": 2 }], 2: [function(_dereq_, module3, exports3) {
  350. function Similar() {
  351. return this.list = [], this.lastItem = void 0, this.size = 0, this;
  352. }
  353. Similar.prototype.get = function(key) {
  354. var index;
  355. if (this.lastItem && this.isEqual(this.lastItem.key, key))
  356. return this.lastItem.val;
  357. if (index = this.indexOf(key), index >= 0)
  358. return this.lastItem = this.list[index], this.list[index].val;
  359. }, Similar.prototype.set = function(key, val) {
  360. var index;
  361. return this.lastItem && this.isEqual(this.lastItem.key, key) ? (this.lastItem.val = val, this) : (index = this.indexOf(key), index >= 0 ? (this.lastItem = this.list[index], this.list[index].val = val, this) : (this.lastItem = { key, val }, this.list.push(this.lastItem), this.size++, this));
  362. }, Similar.prototype.delete = function(key) {
  363. var index;
  364. if (this.lastItem && this.isEqual(this.lastItem.key, key) && (this.lastItem = void 0), index = this.indexOf(key), index >= 0)
  365. return this.size--, this.list.splice(index, 1)[0];
  366. }, Similar.prototype.has = function(key) {
  367. var index;
  368. return this.lastItem && this.isEqual(this.lastItem.key, key) ? !0 : (index = this.indexOf(key), index >= 0 ? (this.lastItem = this.list[index], !0) : !1);
  369. }, Similar.prototype.forEach = function(callback, thisArg) {
  370. var i2;
  371. for (i2 = 0; i2 < this.size; i2++)
  372. callback.call(thisArg || this, this.list[i2].val, this.list[i2].key, this);
  373. }, Similar.prototype.indexOf = function(key) {
  374. var i2;
  375. for (i2 = 0; i2 < this.size; i2++)
  376. if (this.isEqual(this.list[i2].key, key))
  377. return i2;
  378. return -1;
  379. }, Similar.prototype.isEqual = function(val1, val2) {
  380. return val1 === val2 || val1 !== val1 && val2 !== val2;
  381. }, module3.exports = Similar;
  382. }, {}], 3: [function(_dereq_, module3, exports3) {
  383. var MapOrSimilar = _dereq_("map-or-similar");
  384. module3.exports = function(limit) {
  385. var cache = new MapOrSimilar(!1), lru = [];
  386. return function(fn) {
  387. var memoizerific3 = function() {
  388. var currentCache = cache, newMap, fnResult, argsLengthMinusOne = arguments.length - 1, lruPath = Array(argsLengthMinusOne + 1), isMemoized = !0, i2;
  389. if ((memoizerific3.numArgs || memoizerific3.numArgs === 0) && memoizerific3.numArgs !== argsLengthMinusOne + 1)
  390. throw new Error("Memoizerific functions should always be called with the same number of arguments");
  391. for (i2 = 0; i2 < argsLengthMinusOne; i2++) {
  392. if (lruPath[i2] = {
  393. cacheItem: currentCache,
  394. arg: arguments[i2]
  395. }, currentCache.has(arguments[i2])) {
  396. currentCache = currentCache.get(arguments[i2]);
  397. continue;
  398. }
  399. isMemoized = !1, newMap = new MapOrSimilar(!1), currentCache.set(arguments[i2], newMap), currentCache = newMap;
  400. }
  401. return isMemoized && (currentCache.has(arguments[argsLengthMinusOne]) ? fnResult = currentCache.get(arguments[argsLengthMinusOne]) : isMemoized = !1), isMemoized || (fnResult = fn.apply(null, arguments), currentCache.set(arguments[argsLengthMinusOne], fnResult)), limit > 0 && (lruPath[argsLengthMinusOne] = {
  402. cacheItem: currentCache,
  403. arg: arguments[argsLengthMinusOne]
  404. }, isMemoized ? moveToMostRecentLru(lru, lruPath) : lru.push(lruPath), lru.length > limit && removeCachedResult(lru.shift())), memoizerific3.wasMemoized = isMemoized, memoizerific3.numArgs = argsLengthMinusOne + 1, fnResult;
  405. };
  406. return memoizerific3.limit = limit, memoizerific3.wasMemoized = !1, memoizerific3.cache = cache, memoizerific3.lru = lru, memoizerific3;
  407. };
  408. };
  409. function moveToMostRecentLru(lru, lruPath) {
  410. var lruLen = lru.length, lruPathLen = lruPath.length, isMatch, i2, ii;
  411. for (i2 = 0; i2 < lruLen; i2++) {
  412. for (isMatch = !0, ii = 0; ii < lruPathLen; ii++)
  413. if (!isEqual2(lru[i2][ii].arg, lruPath[ii].arg)) {
  414. isMatch = !1;
  415. break;
  416. }
  417. if (isMatch)
  418. break;
  419. }
  420. lru.push(lru.splice(i2, 1)[0]);
  421. }
  422. function removeCachedResult(removedLru) {
  423. var removedLruLen = removedLru.length, currentLru = removedLru[removedLruLen - 1], tmp, i2;
  424. for (currentLru.cacheItem.delete(currentLru.arg), i2 = removedLruLen - 2; i2 >= 0 && (currentLru = removedLru[i2], tmp = currentLru.cacheItem.get(currentLru.arg), !tmp || !tmp.size); i2--)
  425. currentLru.cacheItem.delete(currentLru.arg);
  426. }
  427. function isEqual2(val1, val2) {
  428. return val1 === val2 || val1 !== val1 && val2 !== val2;
  429. }
  430. }, { "map-or-similar": 1 }] }, {}, [3])(3);
  431. });
  432. }
  433. });
  434. // ../../node_modules/picocolors/picocolors.browser.js
  435. var require_picocolors_browser = __commonJS({
  436. "../../node_modules/picocolors/picocolors.browser.js"(exports, module) {
  437. var x2 = String, create4 = function() {
  438. return { isColorSupported: !1, reset: x2, bold: x2, dim: x2, italic: x2, underline: x2, inverse: x2, hidden: x2, strikethrough: x2, black: x2, red: x2, green: x2, yellow: x2, blue: x2, magenta: x2, cyan: x2, white: x2, gray: x2, bgBlack: x2, bgRed: x2, bgGreen: x2, bgYellow: x2, bgBlue: x2, bgMagenta: x2, bgCyan: x2, bgWhite: x2, blackBright: x2, redBright: x2, greenBright: x2, yellowBright: x2, blueBright: x2, magentaBright: x2, cyanBright: x2, whiteBright: x2, bgBlackBright: x2, bgRedBright: x2, bgGreenBright: x2, bgYellowBright: x2, bgBlueBright: x2, bgMagentaBright: x2, bgCyanBright: x2, bgWhiteBright: x2 };
  439. };
  440. module.exports = create4();
  441. module.exports.createColors = create4;
  442. }
  443. });
  444. // ../../node_modules/scroll/index.js
  445. var require_scroll = __commonJS({
  446. "../../node_modules/scroll/index.js"(exports, module) {
  447. var E_NOSCROLL = new Error("Element already at target scroll position"), E_CANCELLED = new Error("Scroll cancelled"), min = Math.min, ms = Date.now;
  448. module.exports = {
  449. left: make("scrollLeft"),
  450. top: make("scrollTop")
  451. };
  452. function make(prop) {
  453. return function(el, to, opts, cb) {
  454. opts = opts || {}, typeof opts == "function" && (cb = opts, opts = {}), typeof cb != "function" && (cb = noop5);
  455. var start = ms(), from = el[prop], ease = opts.ease || inOutSine, duration = isNaN(opts.duration) ? 350 : +opts.duration, cancelled = !1;
  456. return from === to ? cb(E_NOSCROLL, el[prop]) : requestAnimationFrame(animate), cancel;
  457. function cancel() {
  458. cancelled = !0;
  459. }
  460. function animate(timestamp) {
  461. if (cancelled) return cb(E_CANCELLED, el[prop]);
  462. var now = ms(), time = min(1, (now - start) / duration), eased = ease(time);
  463. el[prop] = eased * (to - from) + from, time < 1 ? requestAnimationFrame(animate) : requestAnimationFrame(function() {
  464. cb(null, el[prop]);
  465. });
  466. }
  467. };
  468. }
  469. function inOutSine(n3) {
  470. return 0.5 * (1 - Math.cos(Math.PI * n3));
  471. }
  472. function noop5() {
  473. }
  474. }
  475. });
  476. // ../../node_modules/scrollparent/scrollparent.js
  477. var require_scrollparent = __commonJS({
  478. "../../node_modules/scrollparent/scrollparent.js"(exports, module) {
  479. (function(root2, factory) {
  480. typeof define == "function" && define.amd ? define([], factory) : typeof module == "object" && module.exports ? module.exports = factory() : root2.Scrollparent = factory();
  481. })(exports, function() {
  482. function isScrolling(node) {
  483. var overflow = getComputedStyle(node, null).getPropertyValue("overflow");
  484. return overflow.indexOf("scroll") > -1 || overflow.indexOf("auto") > -1;
  485. }
  486. function scrollParent2(node) {
  487. if (node instanceof HTMLElement || node instanceof SVGElement) {
  488. for (var current = node.parentNode; current.parentNode; ) {
  489. if (isScrolling(current))
  490. return current;
  491. current = current.parentNode;
  492. }
  493. return document.scrollingElement || document.documentElement;
  494. }
  495. }
  496. return scrollParent2;
  497. });
  498. }
  499. });
  500. // ../../node_modules/react-innertext/index.js
  501. var require_react_innertext = __commonJS({
  502. "../../node_modules/react-innertext/index.js"(exports, module) {
  503. "use strict";
  504. var hasProps = function(jsx2) {
  505. return Object.prototype.hasOwnProperty.call(jsx2, "props");
  506. }, reduceJsxToString = function(previous, current) {
  507. return previous + innerText2(current);
  508. }, innerText2 = function(jsx2) {
  509. return jsx2 === null || typeof jsx2 == "boolean" || typeof jsx2 > "u" ? "" : typeof jsx2 == "number" ? jsx2.toString() : typeof jsx2 == "string" ? jsx2 : Array.isArray(jsx2) ? jsx2.reduce(reduceJsxToString, "") : hasProps(jsx2) && Object.prototype.hasOwnProperty.call(jsx2.props, "children") ? innerText2(jsx2.props.children) : "";
  510. };
  511. innerText2.default = innerText2;
  512. module.exports = innerText2;
  513. }
  514. });
  515. // ../../node_modules/deepmerge/dist/cjs.js
  516. var require_cjs = __commonJS({
  517. "../../node_modules/deepmerge/dist/cjs.js"(exports, module) {
  518. "use strict";
  519. var isMergeableObject = function(value) {
  520. return isNonNullObject(value) && !isSpecial(value);
  521. };
  522. function isNonNullObject(value) {
  523. return !!value && typeof value == "object";
  524. }
  525. function isSpecial(value) {
  526. var stringValue = Object.prototype.toString.call(value);
  527. return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
  528. }
  529. var canUseSymbol = typeof Symbol == "function" && Symbol.for, REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
  530. function isReactElement(value) {
  531. return value.$$typeof === REACT_ELEMENT_TYPE;
  532. }
  533. function emptyTarget(val) {
  534. return Array.isArray(val) ? [] : {};
  535. }
  536. function cloneUnlessOtherwiseSpecified(value, options2) {
  537. return options2.clone !== !1 && options2.isMergeableObject(value) ? deepmerge4(emptyTarget(value), value, options2) : value;
  538. }
  539. function defaultArrayMerge(target, source, options2) {
  540. return target.concat(source).map(function(element) {
  541. return cloneUnlessOtherwiseSpecified(element, options2);
  542. });
  543. }
  544. function getMergeFunction(key, options2) {
  545. if (!options2.customMerge)
  546. return deepmerge4;
  547. var customMerge = options2.customMerge(key);
  548. return typeof customMerge == "function" ? customMerge : deepmerge4;
  549. }
  550. function getEnumerableOwnPropertySymbols(target) {
  551. return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
  552. return Object.propertyIsEnumerable.call(target, symbol);
  553. }) : [];
  554. }
  555. function getKeys(target) {
  556. return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
  557. }
  558. function propertyIsOnObject(object, property) {
  559. try {
  560. return property in object;
  561. } catch {
  562. return !1;
  563. }
  564. }
  565. function propertyIsUnsafe(target, key) {
  566. return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
  567. }
  568. function mergeObject(target, source, options2) {
  569. var destination = {};
  570. return options2.isMergeableObject(target) && getKeys(target).forEach(function(key) {
  571. destination[key] = cloneUnlessOtherwiseSpecified(target[key], options2);
  572. }), getKeys(source).forEach(function(key) {
  573. propertyIsUnsafe(target, key) || (propertyIsOnObject(target, key) && options2.isMergeableObject(source[key]) ? destination[key] = getMergeFunction(key, options2)(target[key], source[key], options2) : destination[key] = cloneUnlessOtherwiseSpecified(source[key], options2));
  574. }), destination;
  575. }
  576. function deepmerge4(target, source, options2) {
  577. options2 = options2 || {}, options2.arrayMerge = options2.arrayMerge || defaultArrayMerge, options2.isMergeableObject = options2.isMergeableObject || isMergeableObject, options2.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
  578. var sourceIsArray = Array.isArray(source), targetIsArray = Array.isArray(target), sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
  579. return sourceAndTargetTypesMatch ? sourceIsArray ? options2.arrayMerge(target, source, options2) : mergeObject(target, source, options2) : cloneUnlessOtherwiseSpecified(source, options2);
  580. }
  581. deepmerge4.all = function(array, options2) {
  582. if (!Array.isArray(array))
  583. throw new Error("first argument should be an array");
  584. return array.reduce(function(prev, next) {
  585. return deepmerge4(prev, next, options2);
  586. }, {});
  587. };
  588. var deepmerge_1 = deepmerge4;
  589. module.exports = deepmerge_1;
  590. }
  591. });
  592. // ../../node_modules/downshift/node_modules/react-is/cjs/react-is.production.min.js
  593. var require_react_is_production_min = __commonJS({
  594. "../../node_modules/downshift/node_modules/react-is/cjs/react-is.production.min.js"(exports) {
  595. "use strict";
  596. var b2 = Symbol.for("react.element"), c2 = Symbol.for("react.portal"), d2 = Symbol.for("react.fragment"), e2 = Symbol.for("react.strict_mode"), f2 = Symbol.for("react.profiler"), g2 = Symbol.for("react.provider"), h2 = Symbol.for("react.context"), k2 = Symbol.for("react.server_context"), l3 = Symbol.for("react.forward_ref"), m2 = Symbol.for("react.suspense"), n3 = Symbol.for("react.suspense_list"), p2 = Symbol.for("react.memo"), q2 = Symbol.for("react.lazy"), t2 = Symbol.for("react.offscreen"), u2;
  597. u2 = Symbol.for("react.module.reference");
  598. function v2(a2) {
  599. if (typeof a2 == "object" && a2 !== null) {
  600. var r4 = a2.$$typeof;
  601. switch (r4) {
  602. case b2:
  603. switch (a2 = a2.type, a2) {
  604. case d2:
  605. case f2:
  606. case e2:
  607. case m2:
  608. case n3:
  609. return a2;
  610. default:
  611. switch (a2 = a2 && a2.$$typeof, a2) {
  612. case k2:
  613. case h2:
  614. case l3:
  615. case q2:
  616. case p2:
  617. case g2:
  618. return a2;
  619. default:
  620. return r4;
  621. }
  622. }
  623. case c2:
  624. return r4;
  625. }
  626. }
  627. }
  628. exports.ContextConsumer = h2;
  629. exports.ContextProvider = g2;
  630. exports.Element = b2;
  631. exports.ForwardRef = l3;
  632. exports.Fragment = d2;
  633. exports.Lazy = q2;
  634. exports.Memo = p2;
  635. exports.Portal = c2;
  636. exports.Profiler = f2;
  637. exports.StrictMode = e2;
  638. exports.Suspense = m2;
  639. exports.SuspenseList = n3;
  640. exports.isAsyncMode = function() {
  641. return !1;
  642. };
  643. exports.isConcurrentMode = function() {
  644. return !1;
  645. };
  646. exports.isContextConsumer = function(a2) {
  647. return v2(a2) === h2;
  648. };
  649. exports.isContextProvider = function(a2) {
  650. return v2(a2) === g2;
  651. };
  652. exports.isElement = function(a2) {
  653. return typeof a2 == "object" && a2 !== null && a2.$$typeof === b2;
  654. };
  655. exports.isForwardRef = function(a2) {
  656. return v2(a2) === l3;
  657. };
  658. exports.isFragment = function(a2) {
  659. return v2(a2) === d2;
  660. };
  661. exports.isLazy = function(a2) {
  662. return v2(a2) === q2;
  663. };
  664. exports.isMemo = function(a2) {
  665. return v2(a2) === p2;
  666. };
  667. exports.isPortal = function(a2) {
  668. return v2(a2) === c2;
  669. };
  670. exports.isProfiler = function(a2) {
  671. return v2(a2) === f2;
  672. };
  673. exports.isStrictMode = function(a2) {
  674. return v2(a2) === e2;
  675. };
  676. exports.isSuspense = function(a2) {
  677. return v2(a2) === m2;
  678. };
  679. exports.isSuspenseList = function(a2) {
  680. return v2(a2) === n3;
  681. };
  682. exports.isValidElementType = function(a2) {
  683. return typeof a2 == "string" || typeof a2 == "function" || a2 === d2 || a2 === f2 || a2 === e2 || a2 === m2 || a2 === n3 || a2 === t2 || typeof a2 == "object" && a2 !== null && (a2.$$typeof === q2 || a2.$$typeof === p2 || a2.$$typeof === g2 || a2.$$typeof === h2 || a2.$$typeof === l3 || a2.$$typeof === u2 || a2.getModuleId !== void 0);
  684. };
  685. exports.typeOf = v2;
  686. }
  687. });
  688. // ../../node_modules/downshift/node_modules/react-is/index.js
  689. var require_react_is = __commonJS({
  690. "../../node_modules/downshift/node_modules/react-is/index.js"(exports, module) {
  691. "use strict";
  692. module.exports = require_react_is_production_min();
  693. }
  694. });
  695. // ../../node_modules/fuse.js/dist/fuse.js
  696. var require_fuse = __commonJS({
  697. "../../node_modules/fuse.js/dist/fuse.js"(exports, module) {
  698. (function(e2, t2) {
  699. typeof exports == "object" && typeof module == "object" ? module.exports = t2() : typeof define == "function" && define.amd ? define("Fuse", [], t2) : typeof exports == "object" ? exports.Fuse = t2() : e2.Fuse = t2();
  700. })(exports, function() {
  701. return (function(e2) {
  702. var t2 = {};
  703. function r4(n3) {
  704. if (t2[n3]) return t2[n3].exports;
  705. var o3 = t2[n3] = { i: n3, l: !1, exports: {} };
  706. return e2[n3].call(o3.exports, o3, o3.exports, r4), o3.l = !0, o3.exports;
  707. }
  708. return r4.m = e2, r4.c = t2, r4.d = function(e3, t3, n3) {
  709. r4.o(e3, t3) || Object.defineProperty(e3, t3, { enumerable: !0, get: n3 });
  710. }, r4.r = function(e3) {
  711. typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e3, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e3, "__esModule", { value: !0 });
  712. }, r4.t = function(e3, t3) {
  713. if (1 & t3 && (e3 = r4(e3)), 8 & t3 || 4 & t3 && typeof e3 == "object" && e3 && e3.__esModule) return e3;
  714. var n3 = /* @__PURE__ */ Object.create(null);
  715. if (r4.r(n3), Object.defineProperty(n3, "default", { enumerable: !0, value: e3 }), 2 & t3 && typeof e3 != "string") for (var o3 in e3) r4.d(n3, o3, function(t4) {
  716. return e3[t4];
  717. }.bind(null, o3));
  718. return n3;
  719. }, r4.n = function(e3) {
  720. var t3 = e3 && e3.__esModule ? function() {
  721. return e3.default;
  722. } : function() {
  723. return e3;
  724. };
  725. return r4.d(t3, "a", t3), t3;
  726. }, r4.o = function(e3, t3) {
  727. return Object.prototype.hasOwnProperty.call(e3, t3);
  728. }, r4.p = "", r4(r4.s = 0);
  729. })([function(e2, t2, r4) {
  730. function n3(e3) {
  731. return (n3 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e4) {
  732. return typeof e4;
  733. } : function(e4) {
  734. return e4 && typeof Symbol == "function" && e4.constructor === Symbol && e4 !== Symbol.prototype ? "symbol" : typeof e4;
  735. })(e3);
  736. }
  737. function o3(e3, t3) {
  738. for (var r5 = 0; r5 < t3.length; r5++) {
  739. var n4 = t3[r5];
  740. n4.enumerable = n4.enumerable || !1, n4.configurable = !0, "value" in n4 && (n4.writable = !0), Object.defineProperty(e3, n4.key, n4);
  741. }
  742. }
  743. var i2 = r4(1), a2 = r4(7), s2 = a2.get, c2 = (a2.deepValue, a2.isArray), h2 = (function() {
  744. function e3(t4, r6) {
  745. var n4 = r6.location, o4 = n4 === void 0 ? 0 : n4, i3 = r6.distance, a4 = i3 === void 0 ? 100 : i3, c3 = r6.threshold, h3 = c3 === void 0 ? 0.6 : c3, l3 = r6.maxPatternLength, u2 = l3 === void 0 ? 32 : l3, f2 = r6.caseSensitive, v2 = f2 !== void 0 && f2, p2 = r6.tokenSeparator, d2 = p2 === void 0 ? / +/g : p2, g2 = r6.findAllMatches, y2 = g2 !== void 0 && g2, m2 = r6.minMatchCharLength, k2 = m2 === void 0 ? 1 : m2, b2 = r6.id, S2 = b2 === void 0 ? null : b2, x2 = r6.keys, M2 = x2 === void 0 ? [] : x2, _2 = r6.shouldSort, w2 = _2 === void 0 || _2, L3 = r6.getFn, A3 = L3 === void 0 ? s2 : L3, O2 = r6.sortFn, C2 = O2 === void 0 ? function(e4, t5) {
  746. return e4.score - t5.score;
  747. } : O2, j2 = r6.tokenize, P3 = j2 !== void 0 && j2, I2 = r6.matchAllTokens, F2 = I2 !== void 0 && I2, T3 = r6.includeMatches, N2 = T3 !== void 0 && T3, z2 = r6.includeScore, E2 = z2 !== void 0 && z2, W2 = r6.verbose, K2 = W2 !== void 0 && W2;
  748. (function(e4, t5) {
  749. if (!(e4 instanceof t5)) throw new TypeError("Cannot call a class as a function");
  750. })(this, e3), this.options = { location: o4, distance: a4, threshold: h3, maxPatternLength: u2, isCaseSensitive: v2, tokenSeparator: d2, findAllMatches: y2, minMatchCharLength: k2, id: S2, keys: M2, includeMatches: N2, includeScore: E2, shouldSort: w2, getFn: A3, sortFn: C2, verbose: K2, tokenize: P3, matchAllTokens: F2 }, this.setCollection(t4), this._processKeys(M2);
  751. }
  752. var t3, r5, a3;
  753. return t3 = e3, (r5 = [{ key: "setCollection", value: function(e4) {
  754. return this.list = e4, e4;
  755. } }, { key: "_processKeys", value: function(e4) {
  756. if (this._keyWeights = {}, this._keyNames = [], e4.length && typeof e4[0] == "string") for (var t4 = 0, r6 = e4.length; t4 < r6; t4 += 1) {
  757. var n4 = e4[t4];
  758. this._keyWeights[n4] = 1, this._keyNames.push(n4);
  759. }
  760. else {
  761. for (var o4 = null, i3 = null, a4 = 0, s3 = 0, c3 = e4.length; s3 < c3; s3 += 1) {
  762. var h3 = e4[s3];
  763. if (!h3.hasOwnProperty("name")) throw new Error('Missing "name" property in key object');
  764. var l3 = h3.name;
  765. if (this._keyNames.push(l3), !h3.hasOwnProperty("weight")) throw new Error('Missing "weight" property in key object');
  766. var u2 = h3.weight;
  767. if (u2 < 0 || u2 > 1) throw new Error('"weight" property in key must bein the range of [0, 1)');
  768. i3 = i3 == null ? u2 : Math.max(i3, u2), o4 = o4 == null ? u2 : Math.min(o4, u2), this._keyWeights[l3] = u2, a4 += u2;
  769. }
  770. if (a4 > 1) throw new Error("Total of weights cannot exceed 1");
  771. }
  772. } }, { key: "search", value: function(e4) {
  773. var t4 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { limit: !1 };
  774. this._log(`---------
  775. Search pattern: "`.concat(e4, '"'));
  776. var r6 = this._prepareSearchers(e4), n4 = r6.tokenSearchers, o4 = r6.fullSearcher, i3 = this._search(n4, o4);
  777. return this._computeScore(i3), this.options.shouldSort && this._sort(i3), t4.limit && typeof t4.limit == "number" && (i3 = i3.slice(0, t4.limit)), this._format(i3);
  778. } }, { key: "_prepareSearchers", value: function() {
  779. var e4 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", t4 = [];
  780. if (this.options.tokenize) for (var r6 = e4.split(this.options.tokenSeparator), n4 = 0, o4 = r6.length; n4 < o4; n4 += 1) t4.push(new i2(r6[n4], this.options));
  781. return { tokenSearchers: t4, fullSearcher: new i2(e4, this.options) };
  782. } }, { key: "_search", value: function() {
  783. var e4 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t4 = arguments.length > 1 ? arguments[1] : void 0, r6 = this.list, n4 = {}, o4 = [];
  784. if (typeof r6[0] == "string") {
  785. for (var i3 = 0, a4 = r6.length; i3 < a4; i3 += 1) this._analyze({ key: "", value: r6[i3], record: i3, index: i3 }, { resultMap: n4, results: o4, tokenSearchers: e4, fullSearcher: t4 });
  786. return o4;
  787. }
  788. for (var s3 = 0, c3 = r6.length; s3 < c3; s3 += 1) for (var h3 = r6[s3], l3 = 0, u2 = this._keyNames.length; l3 < u2; l3 += 1) {
  789. var f2 = this._keyNames[l3];
  790. this._analyze({ key: f2, value: this.options.getFn(h3, f2), record: h3, index: s3 }, { resultMap: n4, results: o4, tokenSearchers: e4, fullSearcher: t4 });
  791. }
  792. return o4;
  793. } }, { key: "_analyze", value: function(e4, t4) {
  794. var r6 = this, n4 = e4.key, o4 = e4.arrayIndex, i3 = o4 === void 0 ? -1 : o4, a4 = e4.value, s3 = e4.record, h3 = e4.index, l3 = t4.tokenSearchers, u2 = l3 === void 0 ? [] : l3, f2 = t4.fullSearcher, v2 = t4.resultMap, p2 = v2 === void 0 ? {} : v2, d2 = t4.results, g2 = d2 === void 0 ? [] : d2;
  795. (function e5(t5, o5, i4, a5) {
  796. if (o5 != null) {
  797. if (typeof o5 == "string") {
  798. var s4 = !1, h4 = -1, l4 = 0;
  799. r6._log(`
  800. Key: `.concat(n4 === "" ? "--" : n4));
  801. var v3 = f2.search(o5);
  802. if (r6._log('Full text: "'.concat(o5, '", score: ').concat(v3.score)), r6.options.tokenize) {
  803. for (var d3 = o5.split(r6.options.tokenSeparator), y2 = d3.length, m2 = [], k2 = 0, b2 = u2.length; k2 < b2; k2 += 1) {
  804. var S2 = u2[k2];
  805. r6._log(`
  806. Pattern: "`.concat(S2.pattern, '"'));
  807. for (var x2 = !1, M2 = 0; M2 < y2; M2 += 1) {
  808. var _2 = d3[M2], w2 = S2.search(_2), L3 = {};
  809. w2.isMatch ? (L3[_2] = w2.score, s4 = !0, x2 = !0, m2.push(w2.score)) : (L3[_2] = 1, r6.options.matchAllTokens || m2.push(1)), r6._log('Token: "'.concat(_2, '", score: ').concat(L3[_2]));
  810. }
  811. x2 && (l4 += 1);
  812. }
  813. h4 = m2[0];
  814. for (var A3 = m2.length, O2 = 1; O2 < A3; O2 += 1) h4 += m2[O2];
  815. h4 /= A3, r6._log("Token score average:", h4);
  816. }
  817. var C2 = v3.score;
  818. h4 > -1 && (C2 = (C2 + h4) / 2), r6._log("Score average:", C2);
  819. var j2 = !r6.options.tokenize || !r6.options.matchAllTokens || l4 >= u2.length;
  820. if (r6._log(`
  821. Check Matches: `.concat(j2)), (s4 || v3.isMatch) && j2) {
  822. var P3 = { key: n4, arrayIndex: t5, value: o5, score: C2 };
  823. r6.options.includeMatches && (P3.matchedIndices = v3.matchedIndices);
  824. var I2 = p2[a5];
  825. I2 ? I2.output.push(P3) : (p2[a5] = { item: i4, output: [P3] }, g2.push(p2[a5]));
  826. }
  827. } else if (c2(o5)) for (var F2 = 0, T3 = o5.length; F2 < T3; F2 += 1) e5(F2, o5[F2], i4, a5);
  828. }
  829. })(i3, a4, s3, h3);
  830. } }, { key: "_computeScore", value: function(e4) {
  831. this._log(`
  832. Computing score:
  833. `);
  834. for (var t4 = this._keyWeights, r6 = !!Object.keys(t4).length, n4 = 0, o4 = e4.length; n4 < o4; n4 += 1) {
  835. for (var i3 = e4[n4], a4 = i3.output, s3 = a4.length, c3 = 1, h3 = 0; h3 < s3; h3 += 1) {
  836. var l3 = a4[h3], u2 = l3.key, f2 = r6 ? t4[u2] : 1, v2 = l3.score === 0 && t4 && t4[u2] > 0 ? Number.EPSILON : l3.score;
  837. c3 *= Math.pow(v2, f2);
  838. }
  839. i3.score = c3, this._log(i3);
  840. }
  841. } }, { key: "_sort", value: function(e4) {
  842. this._log(`
  843. Sorting....`), e4.sort(this.options.sortFn);
  844. } }, { key: "_format", value: function(e4) {
  845. var t4 = [];
  846. if (this.options.verbose) {
  847. var r6 = [];
  848. this._log(`
  849. Output:
  850. `, JSON.stringify(e4, function(e5, t5) {
  851. if (n3(t5) === "object" && t5 !== null) {
  852. if (r6.indexOf(t5) !== -1) return;
  853. r6.push(t5);
  854. }
  855. return t5;
  856. }, 2)), r6 = null;
  857. }
  858. var o4 = [];
  859. this.options.includeMatches && o4.push(function(e5, t5) {
  860. var r7 = e5.output;
  861. t5.matches = [];
  862. for (var n4 = 0, o5 = r7.length; n4 < o5; n4 += 1) {
  863. var i4 = r7[n4];
  864. if (i4.matchedIndices.length !== 0) {
  865. var a5 = { indices: i4.matchedIndices, value: i4.value };
  866. i4.key && (a5.key = i4.key), i4.hasOwnProperty("arrayIndex") && i4.arrayIndex > -1 && (a5.arrayIndex = i4.arrayIndex), t5.matches.push(a5);
  867. }
  868. }
  869. }), this.options.includeScore && o4.push(function(e5, t5) {
  870. t5.score = e5.score;
  871. });
  872. for (var i3 = 0, a4 = e4.length; i3 < a4; i3 += 1) {
  873. var s3 = e4[i3];
  874. if (this.options.id && (s3.item = this.options.getFn(s3.item, this.options.id)[0]), o4.length) {
  875. for (var c3 = { item: s3.item }, h3 = 0, l3 = o4.length; h3 < l3; h3 += 1) o4[h3](s3, c3);
  876. t4.push(c3);
  877. } else t4.push(s3.item);
  878. }
  879. return t4;
  880. } }, { key: "_log", value: function() {
  881. var e4;
  882. this.options.verbose && (e4 = console).log.apply(e4, arguments);
  883. } }]) && o3(t3.prototype, r5), a3 && o3(t3, a3), e3;
  884. })();
  885. e2.exports = h2;
  886. }, function(e2, t2, r4) {
  887. function n3(e3, t3) {
  888. for (var r5 = 0; r5 < t3.length; r5++) {
  889. var n4 = t3[r5];
  890. n4.enumerable = n4.enumerable || !1, n4.configurable = !0, "value" in n4 && (n4.writable = !0), Object.defineProperty(e3, n4.key, n4);
  891. }
  892. }
  893. var o3 = r4(2), i2 = r4(3), a2 = r4(6), s2 = (function() {
  894. function e3(t4, r6) {
  895. var n4 = r6.location, o4 = n4 === void 0 ? 0 : n4, i3 = r6.distance, s4 = i3 === void 0 ? 100 : i3, c2 = r6.threshold, h2 = c2 === void 0 ? 0.6 : c2, l3 = r6.maxPatternLength, u2 = l3 === void 0 ? 32 : l3, f2 = r6.isCaseSensitive, v2 = f2 !== void 0 && f2, p2 = r6.tokenSeparator, d2 = p2 === void 0 ? / +/g : p2, g2 = r6.findAllMatches, y2 = g2 !== void 0 && g2, m2 = r6.minMatchCharLength, k2 = m2 === void 0 ? 1 : m2, b2 = r6.includeMatches, S2 = b2 !== void 0 && b2;
  896. (function(e4, t5) {
  897. if (!(e4 instanceof t5)) throw new TypeError("Cannot call a class as a function");
  898. })(this, e3), this.options = { location: o4, distance: s4, threshold: h2, maxPatternLength: u2, isCaseSensitive: v2, tokenSeparator: d2, findAllMatches: y2, includeMatches: S2, minMatchCharLength: k2 }, this.pattern = v2 ? t4 : t4.toLowerCase(), this.pattern.length <= u2 && (this.patternAlphabet = a2(this.pattern));
  899. }
  900. var t3, r5, s3;
  901. return t3 = e3, (r5 = [{ key: "search", value: function(e4) {
  902. var t4 = this.options, r6 = t4.isCaseSensitive, n4 = t4.includeMatches;
  903. if (r6 || (e4 = e4.toLowerCase()), this.pattern === e4) {
  904. var a3 = { isMatch: !0, score: 0 };
  905. return n4 && (a3.matchedIndices = [[0, e4.length - 1]]), a3;
  906. }
  907. var s4 = this.options, c2 = s4.maxPatternLength, h2 = s4.tokenSeparator;
  908. if (this.pattern.length > c2) return o3(e4, this.pattern, h2);
  909. var l3 = this.options, u2 = l3.location, f2 = l3.distance, v2 = l3.threshold, p2 = l3.findAllMatches, d2 = l3.minMatchCharLength;
  910. return i2(e4, this.pattern, this.patternAlphabet, { location: u2, distance: f2, threshold: v2, findAllMatches: p2, minMatchCharLength: d2, includeMatches: n4 });
  911. } }]) && n3(t3.prototype, r5), s3 && n3(t3, s3), e3;
  912. })();
  913. e2.exports = s2;
  914. }, function(e2, t2) {
  915. var r4 = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;
  916. e2.exports = function(e3, t3) {
  917. var n3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : / +/g, o3 = new RegExp(t3.replace(r4, "\\$&").replace(n3, "|")), i2 = e3.match(o3), a2 = !!i2, s2 = [];
  918. if (a2) for (var c2 = 0, h2 = i2.length; c2 < h2; c2 += 1) {
  919. var l3 = i2[c2];
  920. s2.push([e3.indexOf(l3), l3.length - 1]);
  921. }
  922. return { score: a2 ? 0.5 : 1, isMatch: a2, matchedIndices: s2 };
  923. };
  924. }, function(e2, t2, r4) {
  925. var n3 = r4(4), o3 = r4(5);
  926. e2.exports = function(e3, t3, r5, i2) {
  927. for (var a2 = i2.location, s2 = a2 === void 0 ? 0 : a2, c2 = i2.distance, h2 = c2 === void 0 ? 100 : c2, l3 = i2.threshold, u2 = l3 === void 0 ? 0.6 : l3, f2 = i2.findAllMatches, v2 = f2 !== void 0 && f2, p2 = i2.minMatchCharLength, d2 = p2 === void 0 ? 1 : p2, g2 = i2.includeMatches, y2 = g2 !== void 0 && g2, m2 = s2, k2 = e3.length, b2 = u2, S2 = e3.indexOf(t3, m2), x2 = t3.length, M2 = [], _2 = 0; _2 < k2; _2 += 1) M2[_2] = 0;
  928. if (S2 !== -1) {
  929. var w2 = n3(t3, { errors: 0, currentLocation: S2, expectedLocation: m2, distance: h2 });
  930. if (b2 = Math.min(w2, b2), (S2 = e3.lastIndexOf(t3, m2 + x2)) !== -1) {
  931. var L3 = n3(t3, { errors: 0, currentLocation: S2, expectedLocation: m2, distance: h2 });
  932. b2 = Math.min(L3, b2);
  933. }
  934. }
  935. S2 = -1;
  936. for (var A3 = [], O2 = 1, C2 = x2 + k2, j2 = 1 << (x2 <= 31 ? x2 - 1 : 30), P3 = 0; P3 < x2; P3 += 1) {
  937. for (var I2 = 0, F2 = C2; I2 < F2; )
  938. n3(t3, { errors: P3, currentLocation: m2 + F2, expectedLocation: m2, distance: h2 }) <= b2 ? I2 = F2 : C2 = F2, F2 = Math.floor((C2 - I2) / 2 + I2);
  939. C2 = F2;
  940. var T3 = Math.max(1, m2 - F2 + 1), N2 = v2 ? k2 : Math.min(m2 + F2, k2) + x2, z2 = Array(N2 + 2);
  941. z2[N2 + 1] = (1 << P3) - 1;
  942. for (var E2 = N2; E2 >= T3; E2 -= 1) {
  943. var W2 = E2 - 1, K2 = r5[e3.charAt(W2)];
  944. if (K2 && (M2[W2] = 1), z2[E2] = (z2[E2 + 1] << 1 | 1) & K2, P3 !== 0 && (z2[E2] |= (A3[E2 + 1] | A3[E2]) << 1 | 1 | A3[E2 + 1]), z2[E2] & j2 && (O2 = n3(t3, { errors: P3, currentLocation: W2, expectedLocation: m2, distance: h2 })) <= b2) {
  945. if (b2 = O2, (S2 = W2) <= m2) break;
  946. T3 = Math.max(1, 2 * m2 - S2);
  947. }
  948. }
  949. if (n3(t3, { errors: P3 + 1, currentLocation: m2, expectedLocation: m2, distance: h2 }) > b2) break;
  950. A3 = z2;
  951. }
  952. var $ = { isMatch: S2 >= 0, score: O2 === 0 ? 1e-3 : O2 };
  953. return y2 && ($.matchedIndices = o3(M2, d2)), $;
  954. };
  955. }, function(e2, t2) {
  956. e2.exports = function(e3, t3) {
  957. var r4 = t3.errors, n3 = r4 === void 0 ? 0 : r4, o3 = t3.currentLocation, i2 = o3 === void 0 ? 0 : o3, a2 = t3.expectedLocation, s2 = a2 === void 0 ? 0 : a2, c2 = t3.distance, h2 = c2 === void 0 ? 100 : c2, l3 = n3 / e3.length, u2 = Math.abs(s2 - i2);
  958. return h2 ? l3 + u2 / h2 : u2 ? 1 : l3;
  959. };
  960. }, function(e2, t2) {
  961. e2.exports = function() {
  962. for (var e3 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1, r4 = [], n3 = -1, o3 = -1, i2 = 0, a2 = e3.length; i2 < a2; i2 += 1) {
  963. var s2 = e3[i2];
  964. s2 && n3 === -1 ? n3 = i2 : s2 || n3 === -1 || ((o3 = i2 - 1) - n3 + 1 >= t3 && r4.push([n3, o3]), n3 = -1);
  965. }
  966. return e3[i2 - 1] && i2 - n3 >= t3 && r4.push([n3, i2 - 1]), r4;
  967. };
  968. }, function(e2, t2) {
  969. e2.exports = function(e3) {
  970. for (var t3 = {}, r4 = e3.length, n3 = 0; n3 < r4; n3 += 1) t3[e3.charAt(n3)] = 0;
  971. for (var o3 = 0; o3 < r4; o3 += 1) t3[e3.charAt(o3)] |= 1 << r4 - o3 - 1;
  972. return t3;
  973. };
  974. }, function(e2, t2) {
  975. var r4 = function(e3) {
  976. return Array.isArray ? Array.isArray(e3) : Object.prototype.toString.call(e3) === "[object Array]";
  977. }, n3 = function(e3) {
  978. return e3 == null ? "" : (function(e4) {
  979. if (typeof e4 == "string") return e4;
  980. var t3 = e4 + "";
  981. return t3 == "0" && 1 / e4 == -1 / 0 ? "-0" : t3;
  982. })(e3);
  983. }, o3 = function(e3) {
  984. return typeof e3 == "string";
  985. }, i2 = function(e3) {
  986. return typeof e3 == "number";
  987. };
  988. e2.exports = { get: function(e3, t3) {
  989. var a2 = [];
  990. return (function e4(t4, s2) {
  991. if (s2) {
  992. var c2 = s2.indexOf("."), h2 = s2, l3 = null;
  993. c2 !== -1 && (h2 = s2.slice(0, c2), l3 = s2.slice(c2 + 1));
  994. var u2 = t4[h2];
  995. if (u2 != null) if (l3 || !o3(u2) && !i2(u2)) if (r4(u2)) for (var f2 = 0, v2 = u2.length; f2 < v2; f2 += 1) e4(u2[f2], l3);
  996. else l3 && e4(u2, l3);
  997. else a2.push(n3(u2));
  998. } else a2.push(t4);
  999. })(e3, t3), a2;
  1000. }, isArray: r4, isString: o3, isNum: i2, toString: n3 };
  1001. }]);
  1002. });
  1003. }
  1004. });
  1005. // ../../node_modules/store2/dist/store2.js
  1006. var require_store2 = __commonJS({
  1007. "../../node_modules/store2/dist/store2.js"(exports, module) {
  1008. (function(window2, define2) {
  1009. var _2 = {
  1010. version: "2.14.4",
  1011. areas: {},
  1012. apis: {},
  1013. nsdelim: ".",
  1014. // utilities
  1015. inherit: function(api, o3) {
  1016. for (var p2 in api)
  1017. o3.hasOwnProperty(p2) || Object.defineProperty(o3, p2, Object.getOwnPropertyDescriptor(api, p2));
  1018. return o3;
  1019. },
  1020. stringify: function(d2, fn) {
  1021. return d2 === void 0 || typeof d2 == "function" ? d2 + "" : JSON.stringify(d2, fn || _2.replace);
  1022. },
  1023. parse: function(s2, fn) {
  1024. try {
  1025. return JSON.parse(s2, fn || _2.revive);
  1026. } catch {
  1027. return s2;
  1028. }
  1029. },
  1030. // extension hooks
  1031. fn: function(name, fn) {
  1032. _2.storeAPI[name] = fn;
  1033. for (var api in _2.apis)
  1034. _2.apis[api][name] = fn;
  1035. },
  1036. get: function(area, key) {
  1037. return area.getItem(key);
  1038. },
  1039. set: function(area, key, string) {
  1040. area.setItem(key, string);
  1041. },
  1042. remove: function(area, key) {
  1043. area.removeItem(key);
  1044. },
  1045. key: function(area, i2) {
  1046. return area.key(i2);
  1047. },
  1048. length: function(area) {
  1049. return area.length;
  1050. },
  1051. clear: function(area) {
  1052. area.clear();
  1053. },
  1054. // core functions
  1055. Store: function(id, area, namespace) {
  1056. var store3 = _2.inherit(_2.storeAPI, function(key, data, overwrite) {
  1057. return arguments.length === 0 ? store3.getAll() : typeof data == "function" ? store3.transact(key, data, overwrite) : data !== void 0 ? store3.set(key, data, overwrite) : typeof key == "string" || typeof key == "number" ? store3.get(key) : typeof key == "function" ? store3.each(key) : key ? store3.setAll(key, data) : store3.clear();
  1058. });
  1059. store3._id = id;
  1060. try {
  1061. var testKey = "__store2_test";
  1062. area.setItem(testKey, "ok"), store3._area = area, area.removeItem(testKey);
  1063. } catch {
  1064. store3._area = _2.storage("fake");
  1065. }
  1066. return store3._ns = namespace || "", _2.areas[id] || (_2.areas[id] = store3._area), _2.apis[store3._ns + store3._id] || (_2.apis[store3._ns + store3._id] = store3), store3;
  1067. },
  1068. storeAPI: {
  1069. // admin functions
  1070. area: function(id, area) {
  1071. var store3 = this[id];
  1072. return (!store3 || !store3.area) && (store3 = _2.Store(id, area, this._ns), this[id] || (this[id] = store3)), store3;
  1073. },
  1074. namespace: function(namespace, singleArea, delim) {
  1075. if (delim = delim || this._delim || _2.nsdelim, !namespace)
  1076. return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
  1077. var ns = namespace, store3 = this[ns];
  1078. if ((!store3 || !store3.namespace) && (store3 = _2.Store(this._id, this._area, this._ns + ns + delim), store3._delim = delim, this[ns] || (this[ns] = store3), !singleArea))
  1079. for (var name in _2.areas)
  1080. store3.area(name, _2.areas[name]);
  1081. return store3;
  1082. },
  1083. isFake: function(force) {
  1084. return force ? (this._real = this._area, this._area = _2.storage("fake")) : force === !1 && (this._area = this._real || this._area), this._area.name === "fake";
  1085. },
  1086. toString: function() {
  1087. return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
  1088. },
  1089. // storage functions
  1090. has: function(key) {
  1091. return this._area.has ? this._area.has(this._in(key)) : this._in(key) in this._area;
  1092. },
  1093. size: function() {
  1094. return this.keys().length;
  1095. },
  1096. each: function(fn, fill) {
  1097. for (var i2 = 0, m2 = _2.length(this._area); i2 < m2; i2++) {
  1098. var key = this._out(_2.key(this._area, i2));
  1099. if (key !== void 0 && fn.call(this, key, this.get(key), fill) === !1)
  1100. break;
  1101. m2 > _2.length(this._area) && (m2--, i2--);
  1102. }
  1103. return fill || this;
  1104. },
  1105. keys: function(fillList) {
  1106. return this.each(function(k2, v2, list) {
  1107. list.push(k2);
  1108. }, fillList || []);
  1109. },
  1110. get: function(key, alt) {
  1111. var s2 = _2.get(this._area, this._in(key)), fn;
  1112. return typeof alt == "function" && (fn = alt, alt = null), s2 !== null ? _2.parse(s2, fn) : alt ?? s2;
  1113. },
  1114. getAll: function(fillObj) {
  1115. return this.each(function(k2, v2, all) {
  1116. all[k2] = v2;
  1117. }, fillObj || {});
  1118. },
  1119. transact: function(key, fn, alt) {
  1120. var val = this.get(key, alt), ret = fn(val);
  1121. return this.set(key, ret === void 0 ? val : ret), this;
  1122. },
  1123. set: function(key, data, overwrite) {
  1124. var d2 = this.get(key), replacer;
  1125. return d2 != null && overwrite === !1 ? data : (typeof overwrite == "function" && (replacer = overwrite, overwrite = void 0), _2.set(this._area, this._in(key), _2.stringify(data, replacer), overwrite) || d2);
  1126. },
  1127. setAll: function(data, overwrite) {
  1128. var changed, val;
  1129. for (var key in data)
  1130. val = data[key], this.set(key, val, overwrite) !== val && (changed = !0);
  1131. return changed;
  1132. },
  1133. add: function(key, data, replacer) {
  1134. var d2 = this.get(key);
  1135. if (d2 instanceof Array)
  1136. data = d2.concat(data);
  1137. else if (d2 !== null) {
  1138. var type = typeof d2;
  1139. if (type === typeof data && type === "object") {
  1140. for (var k2 in data)
  1141. d2[k2] = data[k2];
  1142. data = d2;
  1143. } else
  1144. data = d2 + data;
  1145. }
  1146. return _2.set(this._area, this._in(key), _2.stringify(data, replacer)), data;
  1147. },
  1148. remove: function(key, alt) {
  1149. var d2 = this.get(key, alt);
  1150. return _2.remove(this._area, this._in(key)), d2;
  1151. },
  1152. clear: function() {
  1153. return this._ns ? this.each(function(k2) {
  1154. _2.remove(this._area, this._in(k2));
  1155. }, 1) : _2.clear(this._area), this;
  1156. },
  1157. clearAll: function() {
  1158. var area = this._area;
  1159. for (var id in _2.areas)
  1160. _2.areas.hasOwnProperty(id) && (this._area = _2.areas[id], this.clear());
  1161. return this._area = area, this;
  1162. },
  1163. // internal use functions
  1164. _in: function(k2) {
  1165. return typeof k2 != "string" && (k2 = _2.stringify(k2)), this._ns ? this._ns + k2 : k2;
  1166. },
  1167. _out: function(k2) {
  1168. return this._ns ? k2 && k2.indexOf(this._ns) === 0 ? k2.substring(this._ns.length) : void 0 : (
  1169. // so each() knows to skip it
  1170. k2
  1171. );
  1172. }
  1173. },
  1174. // end _.storeAPI
  1175. storage: function(name) {
  1176. return _2.inherit(_2.storageAPI, { items: {}, name });
  1177. },
  1178. storageAPI: {
  1179. length: 0,
  1180. has: function(k2) {
  1181. return this.items.hasOwnProperty(k2);
  1182. },
  1183. key: function(i2) {
  1184. var c2 = 0;
  1185. for (var k2 in this.items)
  1186. if (this.has(k2) && i2 === c2++)
  1187. return k2;
  1188. },
  1189. setItem: function(k2, v2) {
  1190. this.has(k2) || this.length++, this.items[k2] = v2;
  1191. },
  1192. removeItem: function(k2) {
  1193. this.has(k2) && (delete this.items[k2], this.length--);
  1194. },
  1195. getItem: function(k2) {
  1196. return this.has(k2) ? this.items[k2] : null;
  1197. },
  1198. clear: function() {
  1199. for (var k2 in this.items)
  1200. this.removeItem(k2);
  1201. }
  1202. }
  1203. // end _.storageAPI
  1204. }, store2 = (
  1205. // safely set this up (throws error in IE10/32bit mode for local files)
  1206. _2.Store("local", (function() {
  1207. try {
  1208. return localStorage;
  1209. } catch {
  1210. }
  1211. })())
  1212. );
  1213. store2.local = store2, store2._ = _2, store2.area("session", (function() {
  1214. try {
  1215. return sessionStorage;
  1216. } catch {
  1217. }
  1218. })()), store2.area("page", _2.storage("page")), typeof define2 == "function" && define2.amd !== void 0 ? define2("store2", [], function() {
  1219. return store2;
  1220. }) : typeof module < "u" && module.exports ? module.exports = store2 : (window2.store && (_2.conflict = window2.store), window2.store = store2);
  1221. })(exports, exports && exports.define);
  1222. }
  1223. });
  1224. // src/manager/runtime.tsx
  1225. init_react();
  1226. // global-externals:storybook/internal/channels
  1227. var channels_default = __STORYBOOK_CHANNELS__, { Channel, HEARTBEAT_INTERVAL, HEARTBEAT_MAX_LATENCY, PostMessageTransport, WebsocketTransport, createBrowserChannel } = __STORYBOOK_CHANNELS__;
  1228. // global-externals:storybook/internal/core-events
  1229. var core_events_default = __STORYBOOK_CORE_EVENTS__, { AI_PROMPT_NUDGE, AI_SETUP_ANALYTICS_REQUEST, AI_SETUP_ANALYTICS_RESPONSE, ARGTYPES_INFO_REQUEST, ARGTYPES_INFO_RESPONSE, CHANNEL_CREATED, CHANNEL_WS_DISCONNECT, CONFIG_ERROR, CREATE_NEW_STORYFILE_REQUEST, CREATE_NEW_STORYFILE_RESPONSE, CURRENT_STORY_WAS_SET, DOCS_PREPARED, DOCS_RENDERED, FILE_COMPONENT_SEARCH_REQUEST, FILE_COMPONENT_SEARCH_RESPONSE, FORCE_REMOUNT, FORCE_RE_RENDER, GHOST_STORIES_REQUEST, GHOST_STORIES_RESPONSE, GLOBALS_UPDATED, MANAGER_INERT_ATTRIBUTE_CHANGED, NAVIGATE_URL, OPEN_IN_EDITOR_REQUEST, OPEN_IN_EDITOR_RESPONSE, PLAY_FUNCTION_THREW_EXCEPTION, PRELOAD_ENTRIES, PREVIEW_BUILDER_PROGRESS, PREVIEW_INITIALIZED, PREVIEW_KEYDOWN, REGISTER_SUBSCRIPTION, REQUEST_WHATS_NEW_DATA, RESET_STORY_ARGS, RESULT_WHATS_NEW_DATA, SAVE_STORY_REQUEST, SAVE_STORY_RESPONSE, SELECT_STORY, SET_CONFIG, SET_CURRENT_STORY, SET_FILTER, SET_GLOBALS, SET_INDEX, SET_STORIES, SET_WHATS_NEW_CACHE, SHARED_STATE_CHANGED, SHARED_STATE_SET, SHARE_ISOLATE_MODE, SIDEBAR_FILTER_CHANGED, STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL, STORY_ARGS_UPDATED, STORY_CHANGED, STORY_ERRORED, STORY_FINISHED, STORY_HOT_UPDATED, STORY_INDEX_INVALIDATED, STORY_MISSING, STORY_PREPARED, STORY_RENDERED, STORY_RENDER_PHASE_CHANGED, STORY_SPECIFIED, STORY_THREW_EXCEPTION, STORY_UNCHANGED, TELEMETRY_ERROR, TOGGLE_WHATS_NEW_NOTIFICATIONS, UNHANDLED_ERRORS_WHILE_PLAYING, UPDATE_GLOBALS, UPDATE_QUERY_PARAMS, UPDATE_STORY_ARGS } = __STORYBOOK_CORE_EVENTS__;
  1230. // ../../node_modules/@storybook/global/dist/index.mjs
  1231. var scope = (() => {
  1232. let win;
  1233. return typeof window < "u" ? win = window : typeof globalThis < "u" ? win = globalThis : typeof global < "u" ? win = global : typeof self < "u" ? win = self : win = {}, win;
  1234. })();
  1235. // global-externals:@storybook/icons
  1236. var icons_exports = {};
  1237. __export(icons_exports, {
  1238. AccessibilityAltIcon: () => AccessibilityAltIcon,
  1239. AccessibilityIcon: () => AccessibilityIcon,
  1240. AccessibilityIgnoredIcon: () => AccessibilityIgnoredIcon,
  1241. AddIcon: () => AddIcon,
  1242. AdminIcon: () => AdminIcon,
  1243. AlertAltIcon: () => AlertAltIcon,
  1244. AlertIcon: () => AlertIcon,
  1245. AlignLeftIcon: () => AlignLeftIcon,
  1246. AlignRightIcon: () => AlignRightIcon,
  1247. AppleIcon: () => AppleIcon,
  1248. ArrowBottomLeftIcon: () => ArrowBottomLeftIcon,
  1249. ArrowBottomRightIcon: () => ArrowBottomRightIcon,
  1250. ArrowDownIcon: () => ArrowDownIcon,
  1251. ArrowLeftIcon: () => ArrowLeftIcon,
  1252. ArrowRightIcon: () => ArrowRightIcon,
  1253. ArrowSolidDownIcon: () => ArrowSolidDownIcon,
  1254. ArrowSolidLeftIcon: () => ArrowSolidLeftIcon,
  1255. ArrowSolidRightIcon: () => ArrowSolidRightIcon,
  1256. ArrowSolidUpIcon: () => ArrowSolidUpIcon,
  1257. ArrowTopLeftIcon: () => ArrowTopLeftIcon,
  1258. ArrowTopRightIcon: () => ArrowTopRightIcon,
  1259. ArrowUpIcon: () => ArrowUpIcon,
  1260. AzureDevOpsIcon: () => AzureDevOpsIcon,
  1261. BackIcon: () => BackIcon,
  1262. BasketIcon: () => BasketIcon,
  1263. BatchAcceptIcon: () => BatchAcceptIcon,
  1264. BatchDenyIcon: () => BatchDenyIcon,
  1265. BeakerIcon: () => BeakerIcon,
  1266. BellIcon: () => BellIcon,
  1267. BitbucketIcon: () => BitbucketIcon,
  1268. BoldIcon: () => BoldIcon,
  1269. BookIcon: () => BookIcon,
  1270. BookmarkHollowIcon: () => BookmarkHollowIcon,
  1271. BookmarkIcon: () => BookmarkIcon,
  1272. BottomBarIcon: () => BottomBarIcon,
  1273. BottomBarToggleIcon: () => BottomBarToggleIcon,
  1274. BoxIcon: () => BoxIcon,
  1275. BranchIcon: () => BranchIcon,
  1276. BrowserIcon: () => BrowserIcon,
  1277. BugIcon: () => BugIcon,
  1278. ButtonIcon: () => ButtonIcon,
  1279. CPUIcon: () => CPUIcon,
  1280. CalendarIcon: () => CalendarIcon,
  1281. CameraIcon: () => CameraIcon,
  1282. CameraStabilizeIcon: () => CameraStabilizeIcon,
  1283. CategoryIcon: () => CategoryIcon,
  1284. CertificateIcon: () => CertificateIcon,
  1285. ChangedIcon: () => ChangedIcon,
  1286. ChatIcon: () => ChatIcon,
  1287. CheckIcon: () => CheckIcon,
  1288. ChecklistIcon: () => ChecklistIcon,
  1289. ChevronDownIcon: () => ChevronDownIcon,
  1290. ChevronLeftIcon: () => ChevronLeftIcon,
  1291. ChevronRightIcon: () => ChevronRightIcon,
  1292. ChevronSmallDownIcon: () => ChevronSmallDownIcon,
  1293. ChevronSmallLeftIcon: () => ChevronSmallLeftIcon,
  1294. ChevronSmallRightIcon: () => ChevronSmallRightIcon,
  1295. ChevronSmallUpIcon: () => ChevronSmallUpIcon,
  1296. ChevronUpIcon: () => ChevronUpIcon,
  1297. ChromaticIcon: () => ChromaticIcon,
  1298. ChromeIcon: () => ChromeIcon,
  1299. CircleHollowIcon: () => CircleHollowIcon,
  1300. CircleIcon: () => CircleIcon,
  1301. ClearIcon: () => ClearIcon,
  1302. CloseAltIcon: () => CloseAltIcon,
  1303. CloseIcon: () => CloseIcon,
  1304. CloudHollowIcon: () => CloudHollowIcon,
  1305. CloudIcon: () => CloudIcon,
  1306. CogIcon: () => CogIcon,
  1307. CollapseIcon: () => CollapseIcon,
  1308. CommandIcon: () => CommandIcon,
  1309. CommentAddIcon: () => CommentAddIcon,
  1310. CommentIcon: () => CommentIcon,
  1311. CommentsIcon: () => CommentsIcon,
  1312. CommitIcon: () => CommitIcon,
  1313. CompassIcon: () => CompassIcon,
  1314. ComponentDrivenIcon: () => ComponentDrivenIcon,
  1315. ComponentIcon: () => ComponentIcon,
  1316. ContrastIcon: () => ContrastIcon,
  1317. ContrastIgnoredIcon: () => ContrastIgnoredIcon,
  1318. ControlsIcon: () => ControlsIcon,
  1319. CopyIcon: () => CopyIcon,
  1320. CreditIcon: () => CreditIcon,
  1321. CrossIcon: () => CrossIcon,
  1322. DashboardIcon: () => DashboardIcon,
  1323. DatabaseIcon: () => DatabaseIcon,
  1324. DeleteIcon: () => DeleteIcon,
  1325. DiamondIcon: () => DiamondIcon,
  1326. DirectionIcon: () => DirectionIcon,
  1327. DiscordIcon: () => DiscordIcon,
  1328. DocChartIcon: () => DocChartIcon,
  1329. DocListIcon: () => DocListIcon,
  1330. DocumentIcon: () => DocumentIcon,
  1331. DownloadIcon: () => DownloadIcon,
  1332. DragIcon: () => DragIcon,
  1333. EditIcon: () => EditIcon,
  1334. EditorIcon: () => EditorIcon,
  1335. EllipsisIcon: () => EllipsisIcon,
  1336. EmailIcon: () => EmailIcon,
  1337. ExpandAltIcon: () => ExpandAltIcon,
  1338. ExpandIcon: () => ExpandIcon,
  1339. EyeCloseIcon: () => EyeCloseIcon,
  1340. EyeIcon: () => EyeIcon,
  1341. FaceHappyIcon: () => FaceHappyIcon,
  1342. FaceNeutralIcon: () => FaceNeutralIcon,
  1343. FaceSadIcon: () => FaceSadIcon,
  1344. FacebookIcon: () => FacebookIcon,
  1345. FailedIcon: () => FailedIcon,
  1346. FastForwardIcon: () => FastForwardIcon,
  1347. FigmaIcon: () => FigmaIcon,
  1348. FilesIcon: () => FilesIcon,
  1349. FilterIcon: () => FilterIcon,
  1350. FlagIcon: () => FlagIcon,
  1351. FolderIcon: () => FolderIcon,
  1352. FormIcon: () => FormIcon,
  1353. GDriveIcon: () => GDriveIcon,
  1354. GiftIcon: () => GiftIcon,
  1355. GithubIcon: () => GithubIcon,
  1356. GitlabIcon: () => GitlabIcon,
  1357. GlobeIcon: () => GlobeIcon,
  1358. GoogleIcon: () => GoogleIcon,
  1359. GraphBarIcon: () => GraphBarIcon,
  1360. GraphLineIcon: () => GraphLineIcon,
  1361. GraphqlIcon: () => GraphqlIcon,
  1362. GridAltIcon: () => GridAltIcon,
  1363. GridIcon: () => GridIcon,
  1364. GrowIcon: () => GrowIcon,
  1365. HeartHollowIcon: () => HeartHollowIcon,
  1366. HeartIcon: () => HeartIcon,
  1367. HomeIcon: () => HomeIcon,
  1368. HourglassIcon: () => HourglassIcon,
  1369. InfoIcon: () => InfoIcon,
  1370. ItalicIcon: () => ItalicIcon,
  1371. JumpToIcon: () => JumpToIcon,
  1372. KeyIcon: () => KeyIcon,
  1373. LightningIcon: () => LightningIcon,
  1374. LightningOffIcon: () => LightningOffIcon,
  1375. LinkBrokenIcon: () => LinkBrokenIcon,
  1376. LinkIcon: () => LinkIcon,
  1377. LinkedinIcon: () => LinkedinIcon,
  1378. LinuxIcon: () => LinuxIcon,
  1379. ListOrderedIcon: () => ListOrderedIcon,
  1380. ListUnorderedIcon: () => ListUnorderedIcon,
  1381. LocationIcon: () => LocationIcon,
  1382. LockIcon: () => LockIcon,
  1383. MarkdownIcon: () => MarkdownIcon,
  1384. MarkupIcon: () => MarkupIcon,
  1385. MediumIcon: () => MediumIcon,
  1386. MemoryIcon: () => MemoryIcon,
  1387. MenuIcon: () => MenuIcon,
  1388. MergeIcon: () => MergeIcon,
  1389. MirrorIcon: () => MirrorIcon,
  1390. MobileIcon: () => MobileIcon,
  1391. MoonIcon: () => MoonIcon,
  1392. NutIcon: () => NutIcon,
  1393. OutboxIcon: () => OutboxIcon,
  1394. OutlineIcon: () => OutlineIcon,
  1395. PaintBrushAltIcon: () => PaintBrushAltIcon,
  1396. PaintBrushIcon: () => PaintBrushIcon,
  1397. PaperClipIcon: () => PaperClipIcon,
  1398. ParagraphIcon: () => ParagraphIcon,
  1399. PassedIcon: () => PassedIcon,
  1400. PhoneIcon: () => PhoneIcon,
  1401. PhotoDragIcon: () => PhotoDragIcon,
  1402. PhotoIcon: () => PhotoIcon,
  1403. PhotoStabilizeIcon: () => PhotoStabilizeIcon,
  1404. PinAltIcon: () => PinAltIcon,
  1405. PinIcon: () => PinIcon,
  1406. PlayAllHollowIcon: () => PlayAllHollowIcon,
  1407. PlayBackIcon: () => PlayBackIcon,
  1408. PlayHollowIcon: () => PlayHollowIcon,
  1409. PlayIcon: () => PlayIcon,
  1410. PlayNextIcon: () => PlayNextIcon,
  1411. PlusIcon: () => PlusIcon,
  1412. PointerDefaultIcon: () => PointerDefaultIcon,
  1413. PointerHandIcon: () => PointerHandIcon,
  1414. PopOutIcon: () => PopOutIcon,
  1415. PowerIcon: () => PowerIcon,
  1416. PrintIcon: () => PrintIcon,
  1417. ProceedIcon: () => ProceedIcon,
  1418. ProfileIcon: () => ProfileIcon,
  1419. PullRequestIcon: () => PullRequestIcon,
  1420. QuestionIcon: () => QuestionIcon,
  1421. RSSIcon: () => RSSIcon,
  1422. RedirectIcon: () => RedirectIcon,
  1423. ReduxIcon: () => ReduxIcon,
  1424. RefreshIcon: () => RefreshIcon,
  1425. ReplyIcon: () => ReplyIcon,
  1426. RepoIcon: () => RepoIcon,
  1427. RequestChangeIcon: () => RequestChangeIcon,
  1428. RewindIcon: () => RewindIcon,
  1429. RulerIcon: () => RulerIcon,
  1430. SaveIcon: () => SaveIcon,
  1431. SearchIcon: () => SearchIcon,
  1432. ShareAltIcon: () => ShareAltIcon,
  1433. ShareIcon: () => ShareIcon,
  1434. ShieldIcon: () => ShieldIcon,
  1435. SideBySideIcon: () => SideBySideIcon,
  1436. SidebarAltIcon: () => SidebarAltIcon,
  1437. SidebarAltToggleIcon: () => SidebarAltToggleIcon,
  1438. SidebarIcon: () => SidebarIcon,
  1439. SidebarToggleIcon: () => SidebarToggleIcon,
  1440. SortDownIcon: () => SortDownIcon,
  1441. SortUpIcon: () => SortUpIcon,
  1442. SpeakerIcon: () => SpeakerIcon,
  1443. StackedIcon: () => StackedIcon,
  1444. StarHollowIcon: () => StarHollowIcon,
  1445. StarIcon: () => StarIcon,
  1446. StatusFailIcon: () => StatusFailIcon,
  1447. StatusIcon: () => StatusIcon,
  1448. StatusNewIcon: () => StatusNewIcon,
  1449. StatusPassIcon: () => StatusPassIcon,
  1450. StatusWarnIcon: () => StatusWarnIcon,
  1451. StickerIcon: () => StickerIcon,
  1452. StopAltHollowIcon: () => StopAltHollowIcon,
  1453. StopAltIcon: () => StopAltIcon,
  1454. StopIcon: () => StopIcon,
  1455. StorybookIcon: () => StorybookIcon,
  1456. StructureIcon: () => StructureIcon,
  1457. SubtractIcon: () => SubtractIcon,
  1458. SunIcon: () => SunIcon,
  1459. SupportIcon: () => SupportIcon,
  1460. SweepIcon: () => SweepIcon,
  1461. SwitchAltIcon: () => SwitchAltIcon,
  1462. SyncIcon: () => SyncIcon,
  1463. TabletIcon: () => TabletIcon,
  1464. ThumbsUpIcon: () => ThumbsUpIcon,
  1465. TimeIcon: () => TimeIcon,
  1466. TimerIcon: () => TimerIcon,
  1467. TransferIcon: () => TransferIcon,
  1468. TrashIcon: () => TrashIcon,
  1469. TwitterIcon: () => TwitterIcon,
  1470. TypeIcon: () => TypeIcon,
  1471. UbuntuIcon: () => UbuntuIcon,
  1472. UndoIcon: () => UndoIcon,
  1473. UnfoldIcon: () => UnfoldIcon,
  1474. UnlockIcon: () => UnlockIcon,
  1475. UnpinIcon: () => UnpinIcon,
  1476. UploadIcon: () => UploadIcon,
  1477. UserAddIcon: () => UserAddIcon,
  1478. UserAltIcon: () => UserAltIcon,
  1479. UserIcon: () => UserIcon,
  1480. UsersIcon: () => UsersIcon,
  1481. VSCodeIcon: () => VSCodeIcon,
  1482. VerifiedIcon: () => VerifiedIcon,
  1483. VideoIcon: () => VideoIcon,
  1484. WandIcon: () => WandIcon,
  1485. WatchIcon: () => WatchIcon,
  1486. WindowsIcon: () => WindowsIcon,
  1487. WrenchIcon: () => WrenchIcon,
  1488. XIcon: () => XIcon,
  1489. YoutubeIcon: () => YoutubeIcon,
  1490. ZoomIcon: () => ZoomIcon,
  1491. ZoomOutIcon: () => ZoomOutIcon,
  1492. ZoomResetIcon: () => ZoomResetIcon,
  1493. default: () => icons_default,
  1494. iconList: () => iconList
  1495. });
  1496. var icons_default = __STORYBOOK_ICONS__, { AccessibilityAltIcon, AccessibilityIcon, AccessibilityIgnoredIcon, AddIcon, AdminIcon, AlertAltIcon, AlertIcon, AlignLeftIcon, AlignRightIcon, AppleIcon, ArrowBottomLeftIcon, ArrowBottomRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowSolidDownIcon, ArrowSolidLeftIcon, ArrowSolidRightIcon, ArrowSolidUpIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowUpIcon, AzureDevOpsIcon, BackIcon, BasketIcon, BatchAcceptIcon, BatchDenyIcon, BeakerIcon, BellIcon, BitbucketIcon, BoldIcon, BookIcon, BookmarkHollowIcon, BookmarkIcon, BottomBarIcon, BottomBarToggleIcon, BoxIcon, BranchIcon, BrowserIcon, BugIcon, ButtonIcon, CPUIcon, CalendarIcon, CameraIcon, CameraStabilizeIcon, CategoryIcon, CertificateIcon, ChangedIcon, ChatIcon, CheckIcon, ChecklistIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronSmallDownIcon, ChevronSmallLeftIcon, ChevronSmallRightIcon, ChevronSmallUpIcon, ChevronUpIcon, ChromaticIcon, ChromeIcon, CircleHollowIcon, CircleIcon, ClearIcon, CloseAltIcon, CloseIcon, CloudHollowIcon, CloudIcon, CogIcon, CollapseIcon, CommandIcon, CommentAddIcon, CommentIcon, CommentsIcon, CommitIcon, CompassIcon, ComponentDrivenIcon, ComponentIcon, ContrastIcon, ContrastIgnoredIcon, ControlsIcon, CopyIcon, CreditIcon, CrossIcon, DashboardIcon, DatabaseIcon, DeleteIcon, DiamondIcon, DirectionIcon, DiscordIcon, DocChartIcon, DocListIcon, DocumentIcon, DownloadIcon, DragIcon, EditIcon, EditorIcon, EllipsisIcon, EmailIcon, ExpandAltIcon, ExpandIcon, EyeCloseIcon, EyeIcon, FaceHappyIcon, FaceNeutralIcon, FaceSadIcon, FacebookIcon, FailedIcon, FastForwardIcon, FigmaIcon, FilesIcon, FilterIcon, FlagIcon, FolderIcon, FormIcon, GDriveIcon, GiftIcon, GithubIcon, GitlabIcon, GlobeIcon, GoogleIcon, GraphBarIcon, GraphLineIcon, GraphqlIcon, GridAltIcon, GridIcon, GrowIcon, HeartHollowIcon, HeartIcon, HomeIcon, HourglassIcon, InfoIcon, ItalicIcon, JumpToIcon, KeyIcon, LightningIcon, LightningOffIcon, LinkBrokenIcon, LinkIcon, LinkedinIcon, LinuxIcon, ListOrderedIcon, ListUnorderedIcon, LocationIcon, LockIcon, MarkdownIcon, MarkupIcon, MediumIcon, MemoryIcon, MenuIcon, MergeIcon, MirrorIcon, MobileIcon, MoonIcon, NutIcon, OutboxIcon, OutlineIcon, PaintBrushAltIcon, PaintBrushIcon, PaperClipIcon, ParagraphIcon, PassedIcon, PhoneIcon, PhotoDragIcon, PhotoIcon, PhotoStabilizeIcon, PinAltIcon, PinIcon, PlayAllHollowIcon, PlayBackIcon, PlayHollowIcon, PlayIcon, PlayNextIcon, PlusIcon, PointerDefaultIcon, PointerHandIcon, PopOutIcon, PowerIcon, PrintIcon, ProceedIcon, ProfileIcon, PullRequestIcon, QuestionIcon, RSSIcon, RedirectIcon, ReduxIcon, RefreshIcon, ReplyIcon, RepoIcon, RequestChangeIcon, RewindIcon, RulerIcon, SaveIcon, SearchIcon, ShareAltIcon, ShareIcon, ShieldIcon, SideBySideIcon, SidebarAltIcon, SidebarAltToggleIcon, SidebarIcon, SidebarToggleIcon, SortDownIcon, SortUpIcon, SpeakerIcon, StackedIcon, StarHollowIcon, StarIcon, StatusFailIcon, StatusIcon, StatusNewIcon, StatusPassIcon, StatusWarnIcon, StickerIcon, StopAltHollowIcon, StopAltIcon, StopIcon, StorybookIcon, StructureIcon, SubtractIcon, SunIcon, SupportIcon, SweepIcon, SwitchAltIcon, SyncIcon, TabletIcon, ThumbsUpIcon, TimeIcon, TimerIcon, TransferIcon, TrashIcon, TwitterIcon, TypeIcon, UbuntuIcon, UndoIcon, UnfoldIcon, UnlockIcon, UnpinIcon, UploadIcon, UserAddIcon, UserAltIcon, UserIcon, UsersIcon, VSCodeIcon, VerifiedIcon, VideoIcon, WandIcon, WatchIcon, WindowsIcon, WrenchIcon, XIcon, YoutubeIcon, ZoomIcon, ZoomOutIcon, ZoomResetIcon, iconList } = __STORYBOOK_ICONS__;
  1497. // global-externals:storybook/manager-api
  1498. var manager_api_default = __STORYBOOK_API__, { ActiveTabs, Consumer, ManagerContext, Provider, RequestResponseError, Tag, addons, combineParameters, controlOrMetaKey, controlOrMetaSymbol, eventMatchesShortcut, eventToShortcut, experimental_MockUniversalStore, experimental_UniversalStore, experimental_getStatusStore, experimental_getTestProviderStore, experimental_requestResponse, experimental_useStatusStore, experimental_useTestProviderStore, experimental_useUniversalStore, internal_checklistStore, internal_fullStatusStore, internal_fullTestProviderStore, internal_universalChecklistStore, internal_universalStatusStore, internal_universalTestProviderStore, isMacLike, isShortcutTaken, keyToSymbol, merge, mockChannel, optionOrAltSymbol, shortcutMatchesShortcut, shortcutToAriaKeyshortcuts, shortcutToHumanString, types, useAddonState, useArgTypes, useArgs, useChannel, useGlobalTypes, useGlobals, useParameter, useSharedState, useStoryPrepared, useStorybookApi, useStorybookState } = __STORYBOOK_API__;
  1499. // global-externals:storybook/theming
  1500. var theming_default = __STORYBOOK_THEMING__, { CacheProvider, ClassNames, Global, ThemeProvider, background, color, convert, create, createCache, createGlobal, createReset, css, darken, ensure, getPreferredColorScheme, ignoreSsrWarning, isPropValid, jsx, keyframes, lighten, srOnlyStyles, styled, themes, tokens, typography, useTheme, withTheme } = __STORYBOOK_THEMING__;
  1501. // src/toolbar/components/ToolbarManager.tsx
  1502. init_react();
  1503. // global-externals:storybook/internal/components
  1504. var components_default = __STORYBOOK_COMPONENTS__, { A, AbstractToolbar, ActionBar, ActionList, AddonPanel, Badge, Bar, Blockquote, Button, Card, ClipboardCode, Code, Collapsible, DL, Div, DocumentWrapper, EmptyTabContent, ErrorFormatter, FlexBar, Form, H1, H2, H3, H4, H5, H6, HR, IconButton, Img, LI, Link, ListItem, Loader, Modal, ModalDecorator, OL, P, Placeholder, Popover, PopoverProvider, Pre, ProgressSpinner, ResetWrapper, ScrollArea, Select, Separator, Spaced, Span, StatelessTab, StatelessTabList, StatelessTabPanel, StatelessTabsView, StorybookIcon: StorybookIcon2, StorybookLogo, SyntaxHighlighter, TT, TabBar, TabButton, TabList, TabPanel, TabWrapper, Table, Tabs, TabsState, TabsView, ToggleButton, Toolbar, Tooltip, TooltipLinkList, TooltipMessage, TooltipNote, TooltipProvider, UL, WithTooltip, WithTooltipPure, Zoom, codeCommon, components, convertToReactAriaPlacement, createCopyToClipboardFunction, getStoryHref, interleaveSeparators, nameSpaceClassNames, resetComponents, useTabsState, withReset } = __STORYBOOK_COMPONENTS__;
  1505. // src/toolbar/utils/normalize-toolbar-arg-type.ts
  1506. var defaultItemValues = {
  1507. type: "item",
  1508. value: ""
  1509. }, normalizeArgType = (key, argType) => {
  1510. let toolbar = argType.toolbar;
  1511. return toolbar ? {
  1512. ...argType,
  1513. name: argType.name || key,
  1514. description: argType.description || key,
  1515. toolbar: {
  1516. ...argType.toolbar,
  1517. items: toolbar.items.map((_item) => {
  1518. let item = typeof _item == "string" ? { value: _item, title: _item } : _item;
  1519. return item.type === "reset" && toolbar.icon && (item.icon = toolbar.icon, item.hideIcon = !0, item.value = void 0), { ...defaultItemValues, ...item };
  1520. })
  1521. }
  1522. } : null;
  1523. };
  1524. // src/toolbar/components/ToolbarMenuSelect.tsx
  1525. init_react();
  1526. // src/components/components/icon/icon.tsx
  1527. init_react();
  1528. // global-externals:storybook/internal/client-logger
  1529. var client_logger_default = __STORYBOOK_CLIENT_LOGGER__, { deprecate, logger, once, pretty } = __STORYBOOK_CLIENT_LOGGER__;
  1530. // src/components/components/icon/icon.tsx
  1531. var NEW_ICON_MAP = icons_exports, Svg = styled.svg`
  1532. display: inline-block;
  1533. shape-rendering: inherit;
  1534. vertical-align: middle;
  1535. fill: currentColor;
  1536. path {
  1537. fill: currentColor;
  1538. }
  1539. `, Icons = ({
  1540. icon,
  1541. useSymbol,
  1542. __suppressDeprecationWarning = !1,
  1543. ...props
  1544. }) => {
  1545. __suppressDeprecationWarning || deprecate(
  1546. `Use of the deprecated Icons ${`(${icon})` || ""} component detected. Please use the @storybook/icons component directly. For more informations, see the migration notes at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated`
  1547. );
  1548. let findIcon = icons[icon] || null;
  1549. if (!findIcon)
  1550. return logger.warn(
  1551. `Use of an unknown prop ${`(${icon})` || ""} in the Icons component. The Icons component is deprecated. Please use the @storybook/icons component directly. For more informations, see the migration notes at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated`
  1552. ), null;
  1553. let Icon = NEW_ICON_MAP[findIcon];
  1554. return react_default.createElement(Icon, { ...props });
  1555. }, Symbols = memo(function({ icons: keys = Object.keys(icons) }) {
  1556. return react_default.createElement(
  1557. Svg,
  1558. {
  1559. viewBox: "0 0 14 14",
  1560. style: { position: "absolute", width: 0, height: 0 },
  1561. "data-chromatic": "ignore"
  1562. },
  1563. keys.map((key) => react_default.createElement("symbol", { id: `icon--${key}`, key }, icons[key]))
  1564. );
  1565. }), icons = {
  1566. user: "UserIcon",
  1567. useralt: "UserAltIcon",
  1568. useradd: "UserAddIcon",
  1569. users: "UsersIcon",
  1570. profile: "ProfileIcon",
  1571. facehappy: "FaceHappyIcon",
  1572. faceneutral: "FaceNeutralIcon",
  1573. facesad: "FaceSadIcon",
  1574. accessibility: "AccessibilityIcon",
  1575. accessibilityalt: "AccessibilityAltIcon",
  1576. arrowup: "ChevronUpIcon",
  1577. arrowdown: "ChevronDownIcon",
  1578. arrowleft: "ChevronLeftIcon",
  1579. arrowright: "ChevronRightIcon",
  1580. arrowupalt: "ArrowUpIcon",
  1581. arrowdownalt: "ArrowDownIcon",
  1582. arrowleftalt: "ArrowLeftIcon",
  1583. arrowrightalt: "ArrowRightIcon",
  1584. expandalt: "ExpandAltIcon",
  1585. collapse: "CollapseIcon",
  1586. expand: "ExpandIcon",
  1587. unfold: "UnfoldIcon",
  1588. transfer: "TransferIcon",
  1589. redirect: "RedirectIcon",
  1590. undo: "UndoIcon",
  1591. reply: "ReplyIcon",
  1592. sync: "SyncIcon",
  1593. upload: "UploadIcon",
  1594. download: "DownloadIcon",
  1595. back: "BackIcon",
  1596. proceed: "ProceedIcon",
  1597. refresh: "RefreshIcon",
  1598. globe: "GlobeIcon",
  1599. compass: "CompassIcon",
  1600. location: "LocationIcon",
  1601. pin: "PinIcon",
  1602. time: "TimeIcon",
  1603. dashboard: "DashboardIcon",
  1604. timer: "TimerIcon",
  1605. home: "HomeIcon",
  1606. admin: "AdminIcon",
  1607. info: "InfoIcon",
  1608. question: "QuestionIcon",
  1609. support: "SupportIcon",
  1610. alert: "AlertIcon",
  1611. email: "EmailIcon",
  1612. phone: "PhoneIcon",
  1613. link: "LinkIcon",
  1614. unlink: "LinkBrokenIcon",
  1615. bell: "BellIcon",
  1616. rss: "RSSIcon",
  1617. sharealt: "ShareAltIcon",
  1618. share: "ShareIcon",
  1619. circle: "CircleIcon",
  1620. circlehollow: "CircleHollowIcon",
  1621. bookmarkhollow: "BookmarkHollowIcon",
  1622. bookmark: "BookmarkIcon",
  1623. hearthollow: "HeartHollowIcon",
  1624. heart: "HeartIcon",
  1625. starhollow: "StarHollowIcon",
  1626. star: "StarIcon",
  1627. certificate: "CertificateIcon",
  1628. verified: "VerifiedIcon",
  1629. thumbsup: "ThumbsUpIcon",
  1630. shield: "ShieldIcon",
  1631. basket: "BasketIcon",
  1632. beaker: "BeakerIcon",
  1633. hourglass: "HourglassIcon",
  1634. flag: "FlagIcon",
  1635. cloudhollow: "CloudHollowIcon",
  1636. edit: "EditIcon",
  1637. cog: "CogIcon",
  1638. nut: "NutIcon",
  1639. wrench: "WrenchIcon",
  1640. ellipsis: "EllipsisIcon",
  1641. check: "CheckIcon",
  1642. form: "FormIcon",
  1643. batchdeny: "BatchDenyIcon",
  1644. batchaccept: "BatchAcceptIcon",
  1645. controls: "ControlsIcon",
  1646. plus: "PlusIcon",
  1647. closeAlt: "CloseAltIcon",
  1648. cross: "CrossIcon",
  1649. trash: "TrashIcon",
  1650. pinalt: "PinAltIcon",
  1651. unpin: "UnpinIcon",
  1652. add: "AddIcon",
  1653. subtract: "SubtractIcon",
  1654. close: "CloseIcon",
  1655. delete: "DeleteIcon",
  1656. passed: "PassedIcon",
  1657. changed: "ChangedIcon",
  1658. failed: "FailedIcon",
  1659. clear: "ClearIcon",
  1660. comment: "CommentIcon",
  1661. commentadd: "CommentAddIcon",
  1662. requestchange: "RequestChangeIcon",
  1663. comments: "CommentsIcon",
  1664. lock: "LockIcon",
  1665. unlock: "UnlockIcon",
  1666. key: "KeyIcon",
  1667. outbox: "OutboxIcon",
  1668. credit: "CreditIcon",
  1669. button: "ButtonIcon",
  1670. type: "TypeIcon",
  1671. pointerdefault: "PointerDefaultIcon",
  1672. pointerhand: "PointerHandIcon",
  1673. browser: "BrowserIcon",
  1674. tablet: "TabletIcon",
  1675. mobile: "MobileIcon",
  1676. watch: "WatchIcon",
  1677. sidebar: "SidebarIcon",
  1678. sidebaralt: "SidebarAltIcon",
  1679. sidebaralttoggle: "SidebarAltToggleIcon",
  1680. sidebartoggle: "SidebarToggleIcon",
  1681. bottombar: "BottomBarIcon",
  1682. bottombartoggle: "BottomBarToggleIcon",
  1683. cpu: "CPUIcon",
  1684. database: "DatabaseIcon",
  1685. memory: "MemoryIcon",
  1686. structure: "StructureIcon",
  1687. box: "BoxIcon",
  1688. power: "PowerIcon",
  1689. photo: "PhotoIcon",
  1690. component: "ComponentIcon",
  1691. grid: "GridIcon",
  1692. outline: "OutlineIcon",
  1693. photodrag: "PhotoDragIcon",
  1694. search: "SearchIcon",
  1695. zoom: "ZoomIcon",
  1696. zoomout: "ZoomOutIcon",
  1697. zoomreset: "ZoomResetIcon",
  1698. eye: "EyeIcon",
  1699. eyeclose: "EyeCloseIcon",
  1700. lightning: "LightningIcon",
  1701. lightningoff: "LightningOffIcon",
  1702. contrast: "ContrastIcon",
  1703. switchalt: "SwitchAltIcon",
  1704. mirror: "MirrorIcon",
  1705. grow: "GrowIcon",
  1706. paintbrush: "PaintBrushIcon",
  1707. ruler: "RulerIcon",
  1708. stop: "StopIcon",
  1709. camera: "CameraIcon",
  1710. video: "VideoIcon",
  1711. speaker: "SpeakerIcon",
  1712. play: "PlayIcon",
  1713. playback: "PlayBackIcon",
  1714. playnext: "PlayNextIcon",
  1715. rewind: "RewindIcon",
  1716. fastforward: "FastForwardIcon",
  1717. stopalt: "StopAltIcon",
  1718. sidebyside: "SideBySideIcon",
  1719. stacked: "StackedIcon",
  1720. sun: "SunIcon",
  1721. moon: "MoonIcon",
  1722. book: "BookIcon",
  1723. document: "DocumentIcon",
  1724. copy: "CopyIcon",
  1725. category: "CategoryIcon",
  1726. folder: "FolderIcon",
  1727. print: "PrintIcon",
  1728. graphline: "GraphLineIcon",
  1729. calendar: "CalendarIcon",
  1730. graphbar: "GraphBarIcon",
  1731. menu: "MenuIcon",
  1732. menualt: "MenuIcon",
  1733. filter: "FilterIcon",
  1734. docchart: "DocChartIcon",
  1735. doclist: "DocListIcon",
  1736. markup: "MarkupIcon",
  1737. bold: "BoldIcon",
  1738. paperclip: "PaperClipIcon",
  1739. listordered: "ListOrderedIcon",
  1740. listunordered: "ListUnorderedIcon",
  1741. paragraph: "ParagraphIcon",
  1742. markdown: "MarkdownIcon",
  1743. repository: "RepoIcon",
  1744. commit: "CommitIcon",
  1745. branch: "BranchIcon",
  1746. pullrequest: "PullRequestIcon",
  1747. merge: "MergeIcon",
  1748. apple: "AppleIcon",
  1749. linux: "LinuxIcon",
  1750. ubuntu: "UbuntuIcon",
  1751. windows: "WindowsIcon",
  1752. storybook: "StorybookIcon",
  1753. azuredevops: "AzureDevOpsIcon",
  1754. bitbucket: "BitbucketIcon",
  1755. chrome: "ChromeIcon",
  1756. chromatic: "ChromaticIcon",
  1757. componentdriven: "ComponentDrivenIcon",
  1758. discord: "DiscordIcon",
  1759. facebook: "FacebookIcon",
  1760. figma: "FigmaIcon",
  1761. gdrive: "GDriveIcon",
  1762. github: "GithubIcon",
  1763. gitlab: "GitlabIcon",
  1764. google: "GoogleIcon",
  1765. graphql: "GraphqlIcon",
  1766. medium: "MediumIcon",
  1767. redux: "ReduxIcon",
  1768. twitter: "TwitterIcon",
  1769. youtube: "YoutubeIcon",
  1770. vscode: "VSCodeIcon"
  1771. };
  1772. // src/toolbar/utils/get-selected.ts
  1773. var getSelectedItem = ({ currentValue, items }) => items.find((item) => item.value === currentValue && item.type !== "reset");
  1774. // src/toolbar/constants.ts
  1775. var TOOLBAR_ID = "toolbar";
  1776. // src/toolbar/utils/register-shortcuts.ts
  1777. var registerShortcuts = async (api, id, shortcuts) => {
  1778. shortcuts.next && await api.setAddonShortcut(TOOLBAR_ID, {
  1779. label: shortcuts.next.label,
  1780. defaultShortcut: shortcuts.next.keys,
  1781. actionName: `${id}:next`,
  1782. action: shortcuts.next.action
  1783. }), shortcuts.previous && await api.setAddonShortcut(TOOLBAR_ID, {
  1784. label: shortcuts.previous.label,
  1785. defaultShortcut: shortcuts.previous.keys,
  1786. actionName: `${id}:previous`,
  1787. action: shortcuts.previous.action
  1788. }), shortcuts.reset && await api.setAddonShortcut(TOOLBAR_ID, {
  1789. label: shortcuts.reset.label,
  1790. defaultShortcut: shortcuts.reset.keys,
  1791. actionName: `${id}:reset`,
  1792. action: shortcuts.reset.action
  1793. });
  1794. };
  1795. // src/toolbar/components/ToolbarMenuSelect.tsx
  1796. var ToolbarMenuItemContainer = styled("div")({
  1797. width: "100%",
  1798. display: "flex",
  1799. alignItems: "center",
  1800. gap: 8
  1801. }), ToolbarMenuItemMiddle = styled("div")({
  1802. flex: 1
  1803. }), ToolbarMenuSelect = ({
  1804. id,
  1805. name,
  1806. description,
  1807. toolbar: {
  1808. icon: _icon,
  1809. items,
  1810. title: _title,
  1811. preventDynamicIcon,
  1812. dynamicTitle = !0,
  1813. shortcuts
  1814. }
  1815. }) => {
  1816. let api = useStorybookApi(), [globals, updateGlobals, storyGlobals] = useGlobals(), currentValue = globals[id], isOverridden = id in storyGlobals, icon = _icon, title2 = _title;
  1817. preventDynamicIcon || (icon = getSelectedItem({ currentValue, items })?.icon || icon), dynamicTitle && (title2 = getSelectedItem({ currentValue, items })?.title || title2), !title2 && !icon && console.warn(`Toolbar '${name}' has no title or icon`);
  1818. let resetItem = items.find((item) => item.type === "reset"), resetLabel = resetItem?.title, options2 = react_default.useMemo(
  1819. () => items.filter((item) => item.type === "item").map((item) => {
  1820. let itemTitle = item.title ?? item.value ?? "Untitled", iconComponent = !item.hideIcon && item.icon ? react_default.createElement(Icons, { icon: item.icon, __suppressDeprecationWarning: !0 }) : void 0;
  1821. return item.right ? {
  1822. title: itemTitle,
  1823. value: item.value,
  1824. children: react_default.createElement(ToolbarMenuItemContainer, null, iconComponent, react_default.createElement(ToolbarMenuItemMiddle, null, item.title ?? item.value), item.right)
  1825. } : {
  1826. title: itemTitle,
  1827. value: item.value,
  1828. icon: iconComponent
  1829. };
  1830. }),
  1831. [items]
  1832. );
  1833. react_default.useEffect(() => {
  1834. if (shortcuts) {
  1835. let length = options2.length;
  1836. registerShortcuts(api, id, {
  1837. next: {
  1838. ...shortcuts.next,
  1839. action: () => {
  1840. let idx = options2.findIndex((i2) => i2.value === globals[id]), nextIdx = idx < 0 ? 0 : (idx + 1) % length;
  1841. updateGlobals({ [id]: options2[nextIdx].value });
  1842. }
  1843. },
  1844. previous: {
  1845. ...shortcuts.previous,
  1846. action: () => {
  1847. let idx = options2.findIndex((i2) => i2.value === globals[id]), previousIdx = idx < 0 ? length - 1 : (idx + length - 1) % length;
  1848. updateGlobals({ [id]: options2[previousIdx].value });
  1849. }
  1850. },
  1851. reset: {
  1852. ...shortcuts.reset,
  1853. action: () => {
  1854. updateGlobals({ [id]: void 0 });
  1855. }
  1856. }
  1857. });
  1858. }
  1859. }, [api, id, shortcuts, globals, options2, updateGlobals]);
  1860. let ariaLabel = description || title2 || name || id;
  1861. return react_default.createElement(
  1862. Select,
  1863. {
  1864. defaultOptions: [currentValue],
  1865. options: options2,
  1866. disabled: isOverridden,
  1867. ariaLabel,
  1868. tooltip: ariaLabel,
  1869. resetLabel,
  1870. onReset: resetItem ? () => updateGlobals({ [id]: resetItem?.value }) : void 0,
  1871. onSelect: (selected) => updateGlobals({ [id]: selected }),
  1872. icon: icon && react_default.createElement(Icons, { icon, __suppressDeprecationWarning: !0 }),
  1873. showSelectedOptionTitle: dynamicTitle
  1874. },
  1875. title2
  1876. );
  1877. };
  1878. // src/toolbar/components/ToolbarManager.tsx
  1879. var ToolbarManager = () => {
  1880. let globalTypes = useGlobalTypes();
  1881. return Object.keys(globalTypes).some((id) => !!globalTypes[id].toolbar) ? react_default.createElement(react_default.Fragment, null, react_default.createElement(Separator, null), Object.keys(globalTypes).map((id) => {
  1882. let normalizedArgType = normalizeArgType(id, globalTypes[id]);
  1883. return normalizedArgType && react_default.createElement(ToolbarMenuSelect, { key: id, id, ...normalizedArgType });
  1884. })) : null;
  1885. };
  1886. // src/manager/index.tsx
  1887. init_react();
  1888. // global-externals:react-dom/client
  1889. var client_default = __REACT_DOM_CLIENT__, { createRoot, hydrateRoot } = __REACT_DOM_CLIENT__;
  1890. // global-externals:storybook/internal/manager-errors
  1891. var manager_errors_default = __STORYBOOK_CORE_EVENTS_MANAGER_ERRORS__, { Category, ProviderDoesNotExtendBaseProviderError, StatusTypeIdMismatchError, UncaughtManagerError } = __STORYBOOK_CORE_EVENTS_MANAGER_ERRORS__;
  1892. // global-externals:storybook/internal/router
  1893. var router_default = __STORYBOOK_ROUTER__, { BaseLocationProvider, DEEPLY_EQUAL, Link: Link2, Location, LocationProvider, Match, MemoryRouter, Route, buildArgsParam, deepDiff, getMatch, parsePath, queryFromLocation, stringifyQuery, useNavigate } = __STORYBOOK_ROUTER__;
  1894. // ../../node_modules/react-helmet-async/lib/index.module.js
  1895. init_react();
  1896. var import_prop_types = __toESM(require_prop_types()), import_react_fast_compare = __toESM(require_react_fast_compare()), import_invariant = __toESM(require_browser()), import_shallowequal = __toESM(require_shallowequal());
  1897. function a() {
  1898. return a = Object.assign || function(t2) {
  1899. for (var e2 = 1; e2 < arguments.length; e2++) {
  1900. var r4 = arguments[e2];
  1901. for (var n3 in r4) Object.prototype.hasOwnProperty.call(r4, n3) && (t2[n3] = r4[n3]);
  1902. }
  1903. return t2;
  1904. }, a.apply(this, arguments);
  1905. }
  1906. function s(t2, e2) {
  1907. t2.prototype = Object.create(e2.prototype), t2.prototype.constructor = t2, c(t2, e2);
  1908. }
  1909. function c(t2, e2) {
  1910. return c = Object.setPrototypeOf || function(t3, e3) {
  1911. return t3.__proto__ = e3, t3;
  1912. }, c(t2, e2);
  1913. }
  1914. function u(t2, e2) {
  1915. if (t2 == null) return {};
  1916. var r4, n3, i2 = {}, o3 = Object.keys(t2);
  1917. for (n3 = 0; n3 < o3.length; n3++) e2.indexOf(r4 = o3[n3]) >= 0 || (i2[r4] = t2[r4]);
  1918. return i2;
  1919. }
  1920. var l = { BASE: "base", BODY: "body", HEAD: "head", HTML: "html", LINK: "link", META: "meta", NOSCRIPT: "noscript", SCRIPT: "script", STYLE: "style", TITLE: "title", FRAGMENT: "Symbol(react.fragment)" }, p = { rel: ["amphtml", "canonical", "alternate"] }, f = { type: ["application/ld+json"] }, d = { charset: "", name: ["robots", "description"], property: ["og:type", "og:title", "og:url", "og:image", "og:image:alt", "og:description", "twitter:url", "twitter:title", "twitter:description", "twitter:image", "twitter:image:alt", "twitter:card", "twitter:site"] }, h = Object.keys(l).map(function(t2) {
  1921. return l[t2];
  1922. }), m = { accesskey: "accessKey", charset: "charSet", class: "className", contenteditable: "contentEditable", contextmenu: "contextMenu", "http-equiv": "httpEquiv", itemprop: "itemProp", tabindex: "tabIndex" }, y = Object.keys(m).reduce(function(t2, e2) {
  1923. return t2[m[e2]] = e2, t2;
  1924. }, {}), T = function(t2, e2) {
  1925. for (var r4 = t2.length - 1; r4 >= 0; r4 -= 1) {
  1926. var n3 = t2[r4];
  1927. if (Object.prototype.hasOwnProperty.call(n3, e2)) return n3[e2];
  1928. }
  1929. return null;
  1930. }, g = function(t2) {
  1931. var e2 = T(t2, l.TITLE), r4 = T(t2, "titleTemplate");
  1932. if (Array.isArray(e2) && (e2 = e2.join("")), r4 && e2) return r4.replace(/%s/g, function() {
  1933. return e2;
  1934. });
  1935. var n3 = T(t2, "defaultTitle");
  1936. return e2 || n3 || void 0;
  1937. }, b = function(t2) {
  1938. return T(t2, "onChangeClientState") || function() {
  1939. };
  1940. }, v = function(t2, e2) {
  1941. return e2.filter(function(e3) {
  1942. return e3[t2] !== void 0;
  1943. }).map(function(e3) {
  1944. return e3[t2];
  1945. }).reduce(function(t3, e3) {
  1946. return a({}, t3, e3);
  1947. }, {});
  1948. }, A2 = function(t2, e2) {
  1949. return e2.filter(function(t3) {
  1950. return t3[l.BASE] !== void 0;
  1951. }).map(function(t3) {
  1952. return t3[l.BASE];
  1953. }).reverse().reduce(function(e3, r4) {
  1954. if (!e3.length) for (var n3 = Object.keys(r4), i2 = 0; i2 < n3.length; i2 += 1) {
  1955. var o3 = n3[i2].toLowerCase();
  1956. if (t2.indexOf(o3) !== -1 && r4[o3]) return e3.concat(r4);
  1957. }
  1958. return e3;
  1959. }, []);
  1960. }, C = function(t2, e2, r4) {
  1961. var n3 = {};
  1962. return r4.filter(function(e3) {
  1963. return !!Array.isArray(e3[t2]) || (e3[t2] !== void 0 && console && typeof console.warn == "function" && console.warn("Helmet: " + t2 + ' should be of type "Array". Instead found type "' + typeof e3[t2] + '"'), !1);
  1964. }).map(function(e3) {
  1965. return e3[t2];
  1966. }).reverse().reduce(function(t3, r5) {
  1967. var i2 = {};
  1968. r5.filter(function(t4) {
  1969. for (var r6, o4 = Object.keys(t4), a2 = 0; a2 < o4.length; a2 += 1) {
  1970. var s3 = o4[a2], c3 = s3.toLowerCase();
  1971. e2.indexOf(c3) === -1 || r6 === "rel" && t4[r6].toLowerCase() === "canonical" || c3 === "rel" && t4[c3].toLowerCase() === "stylesheet" || (r6 = c3), e2.indexOf(s3) === -1 || s3 !== "innerHTML" && s3 !== "cssText" && s3 !== "itemprop" || (r6 = s3);
  1972. }
  1973. if (!r6 || !t4[r6]) return !1;
  1974. var u3 = t4[r6].toLowerCase();
  1975. return n3[r6] || (n3[r6] = {}), i2[r6] || (i2[r6] = {}), !n3[r6][u3] && (i2[r6][u3] = !0, !0);
  1976. }).reverse().forEach(function(e3) {
  1977. return t3.push(e3);
  1978. });
  1979. for (var o3 = Object.keys(i2), s2 = 0; s2 < o3.length; s2 += 1) {
  1980. var c2 = o3[s2], u2 = a({}, n3[c2], i2[c2]);
  1981. n3[c2] = u2;
  1982. }
  1983. return t3;
  1984. }, []).reverse();
  1985. }, O = function(t2, e2) {
  1986. if (Array.isArray(t2) && t2.length) {
  1987. for (var r4 = 0; r4 < t2.length; r4 += 1) if (t2[r4][e2]) return !0;
  1988. }
  1989. return !1;
  1990. }, S = function(t2) {
  1991. return Array.isArray(t2) ? t2.join("") : t2;
  1992. }, E = function(t2, e2) {
  1993. return Array.isArray(t2) ? t2.reduce(function(t3, r4) {
  1994. return (function(t4, e3) {
  1995. for (var r5 = Object.keys(t4), n3 = 0; n3 < r5.length; n3 += 1) if (e3[r5[n3]] && e3[r5[n3]].includes(t4[r5[n3]])) return !0;
  1996. return !1;
  1997. })(r4, e2) ? t3.priority.push(r4) : t3.default.push(r4), t3;
  1998. }, { priority: [], default: [] }) : { default: t2 };
  1999. }, I = function(t2, e2) {
  2000. var r4;
  2001. return a({}, t2, ((r4 = {})[e2] = void 0, r4));
  2002. }, P2 = [l.NOSCRIPT, l.SCRIPT, l.STYLE], w = function(t2, e2) {
  2003. return e2 === void 0 && (e2 = !0), e2 === !1 ? String(t2) : String(t2).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
  2004. }, x = function(t2) {
  2005. return Object.keys(t2).reduce(function(e2, r4) {
  2006. var n3 = t2[r4] !== void 0 ? r4 + '="' + t2[r4] + '"' : "" + r4;
  2007. return e2 ? e2 + " " + n3 : n3;
  2008. }, "");
  2009. }, L = function(t2, e2) {
  2010. return e2 === void 0 && (e2 = {}), Object.keys(t2).reduce(function(e3, r4) {
  2011. return e3[m[r4] || r4] = t2[r4], e3;
  2012. }, e2);
  2013. }, j = function(e2, r4) {
  2014. return r4.map(function(r5, n3) {
  2015. var i2, o3 = ((i2 = { key: n3 })["data-rh"] = !0, i2);
  2016. return Object.keys(r5).forEach(function(t2) {
  2017. var e3 = m[t2] || t2;
  2018. e3 === "innerHTML" || e3 === "cssText" ? o3.dangerouslySetInnerHTML = { __html: r5.innerHTML || r5.cssText } : o3[e3] = r5[t2];
  2019. }), react_default.createElement(e2, o3);
  2020. });
  2021. }, M = function(e2, r4, n3) {
  2022. switch (e2) {
  2023. case l.TITLE:
  2024. return { toComponent: function() {
  2025. return n4 = r4.titleAttributes, (i2 = { key: e3 = r4.title })["data-rh"] = !0, o3 = L(n4, i2), [react_default.createElement(l.TITLE, o3, e3)];
  2026. var e3, n4, i2, o3;
  2027. }, toString: function() {
  2028. return (function(t2, e3, r5, n4) {
  2029. var i2 = x(r5), o3 = S(e3);
  2030. return i2 ? "<" + t2 + ' data-rh="true" ' + i2 + ">" + w(o3, n4) + "</" + t2 + ">" : "<" + t2 + ' data-rh="true">' + w(o3, n4) + "</" + t2 + ">";
  2031. })(e2, r4.title, r4.titleAttributes, n3);
  2032. } };
  2033. case "bodyAttributes":
  2034. case "htmlAttributes":
  2035. return { toComponent: function() {
  2036. return L(r4);
  2037. }, toString: function() {
  2038. return x(r4);
  2039. } };
  2040. default:
  2041. return { toComponent: function() {
  2042. return j(e2, r4);
  2043. }, toString: function() {
  2044. return (function(t2, e3, r5) {
  2045. return e3.reduce(function(e4, n4) {
  2046. var i2 = Object.keys(n4).filter(function(t3) {
  2047. return !(t3 === "innerHTML" || t3 === "cssText");
  2048. }).reduce(function(t3, e5) {
  2049. var i3 = n4[e5] === void 0 ? e5 : e5 + '="' + w(n4[e5], r5) + '"';
  2050. return t3 ? t3 + " " + i3 : i3;
  2051. }, ""), o3 = n4.innerHTML || n4.cssText || "", a2 = P2.indexOf(t2) === -1;
  2052. return e4 + "<" + t2 + ' data-rh="true" ' + i2 + (a2 ? "/>" : ">" + o3 + "</" + t2 + ">");
  2053. }, "");
  2054. })(e2, r4, n3);
  2055. } };
  2056. }
  2057. }, k = function(t2) {
  2058. var e2 = t2.baseTag, r4 = t2.bodyAttributes, n3 = t2.encode, i2 = t2.htmlAttributes, o3 = t2.noscriptTags, a2 = t2.styleTags, s2 = t2.title, c2 = s2 === void 0 ? "" : s2, u2 = t2.titleAttributes, h2 = t2.linkTags, m2 = t2.metaTags, y2 = t2.scriptTags, T3 = { toComponent: function() {
  2059. }, toString: function() {
  2060. return "";
  2061. } };
  2062. if (t2.prioritizeSeoTags) {
  2063. var g2 = (function(t3) {
  2064. var e3 = t3.linkTags, r5 = t3.scriptTags, n4 = t3.encode, i3 = E(t3.metaTags, d), o4 = E(e3, p), a3 = E(r5, f);
  2065. return { priorityMethods: { toComponent: function() {
  2066. return [].concat(j(l.META, i3.priority), j(l.LINK, o4.priority), j(l.SCRIPT, a3.priority));
  2067. }, toString: function() {
  2068. return M(l.META, i3.priority, n4) + " " + M(l.LINK, o4.priority, n4) + " " + M(l.SCRIPT, a3.priority, n4);
  2069. } }, metaTags: i3.default, linkTags: o4.default, scriptTags: a3.default };
  2070. })(t2);
  2071. T3 = g2.priorityMethods, h2 = g2.linkTags, m2 = g2.metaTags, y2 = g2.scriptTags;
  2072. }
  2073. return { priority: T3, base: M(l.BASE, e2, n3), bodyAttributes: M("bodyAttributes", r4, n3), htmlAttributes: M("htmlAttributes", i2, n3), link: M(l.LINK, h2, n3), meta: M(l.META, m2, n3), noscript: M(l.NOSCRIPT, o3, n3), script: M(l.SCRIPT, y2, n3), style: M(l.STYLE, a2, n3), title: M(l.TITLE, { title: c2, titleAttributes: u2 }, n3) };
  2074. }, H = [], N = function(t2, e2) {
  2075. var r4 = this;
  2076. e2 === void 0 && (e2 = typeof document < "u"), this.instances = [], this.value = { setHelmet: function(t3) {
  2077. r4.context.helmet = t3;
  2078. }, helmetInstances: { get: function() {
  2079. return r4.canUseDOM ? H : r4.instances;
  2080. }, add: function(t3) {
  2081. (r4.canUseDOM ? H : r4.instances).push(t3);
  2082. }, remove: function(t3) {
  2083. var e3 = (r4.canUseDOM ? H : r4.instances).indexOf(t3);
  2084. (r4.canUseDOM ? H : r4.instances).splice(e3, 1);
  2085. } } }, this.context = t2, this.canUseDOM = e2, e2 || (t2.helmet = k({ baseTag: [], bodyAttributes: {}, encodeSpecialCharacters: !0, htmlAttributes: {}, linkTags: [], metaTags: [], noscriptTags: [], scriptTags: [], styleTags: [], title: "", titleAttributes: {} }));
  2086. }, R = react_default.createContext({}), D = import_prop_types.default.shape({ setHelmet: import_prop_types.default.func, helmetInstances: import_prop_types.default.shape({ get: import_prop_types.default.func, add: import_prop_types.default.func, remove: import_prop_types.default.func }) }), U = typeof document < "u", q = (function(e2) {
  2087. function r4(t2) {
  2088. var n3;
  2089. return (n3 = e2.call(this, t2) || this).helmetData = new N(n3.props.context, r4.canUseDOM), n3;
  2090. }
  2091. return s(r4, e2), r4.prototype.render = function() {
  2092. return react_default.createElement(R.Provider, { value: this.helmetData.value }, this.props.children);
  2093. }, r4;
  2094. })(Component);
  2095. q.canUseDOM = U, q.propTypes = { context: import_prop_types.default.shape({ helmet: import_prop_types.default.shape() }), children: import_prop_types.default.node.isRequired }, q.defaultProps = { context: {} }, q.displayName = "HelmetProvider";
  2096. var Y = function(t2, e2) {
  2097. var r4, n3 = document.head || document.querySelector(l.HEAD), i2 = n3.querySelectorAll(t2 + "[data-rh]"), o3 = [].slice.call(i2), a2 = [];
  2098. return e2 && e2.length && e2.forEach(function(e3) {
  2099. var n4 = document.createElement(t2);
  2100. for (var i3 in e3) Object.prototype.hasOwnProperty.call(e3, i3) && (i3 === "innerHTML" ? n4.innerHTML = e3.innerHTML : i3 === "cssText" ? n4.styleSheet ? n4.styleSheet.cssText = e3.cssText : n4.appendChild(document.createTextNode(e3.cssText)) : n4.setAttribute(i3, e3[i3] === void 0 ? "" : e3[i3]));
  2101. n4.setAttribute("data-rh", "true"), o3.some(function(t3, e4) {
  2102. return r4 = e4, n4.isEqualNode(t3);
  2103. }) ? o3.splice(r4, 1) : a2.push(n4);
  2104. }), o3.forEach(function(t3) {
  2105. return t3.parentNode.removeChild(t3);
  2106. }), a2.forEach(function(t3) {
  2107. return n3.appendChild(t3);
  2108. }), { oldTags: o3, newTags: a2 };
  2109. }, B = function(t2, e2) {
  2110. var r4 = document.getElementsByTagName(t2)[0];
  2111. if (r4) {
  2112. for (var n3 = r4.getAttribute("data-rh"), i2 = n3 ? n3.split(",") : [], o3 = [].concat(i2), a2 = Object.keys(e2), s2 = 0; s2 < a2.length; s2 += 1) {
  2113. var c2 = a2[s2], u2 = e2[c2] || "";
  2114. r4.getAttribute(c2) !== u2 && r4.setAttribute(c2, u2), i2.indexOf(c2) === -1 && i2.push(c2);
  2115. var l3 = o3.indexOf(c2);
  2116. l3 !== -1 && o3.splice(l3, 1);
  2117. }
  2118. for (var p2 = o3.length - 1; p2 >= 0; p2 -= 1) r4.removeAttribute(o3[p2]);
  2119. i2.length === o3.length ? r4.removeAttribute("data-rh") : r4.getAttribute("data-rh") !== a2.join(",") && r4.setAttribute("data-rh", a2.join(","));
  2120. }
  2121. }, K = function(t2, e2) {
  2122. var r4 = t2.baseTag, n3 = t2.htmlAttributes, i2 = t2.linkTags, o3 = t2.metaTags, a2 = t2.noscriptTags, s2 = t2.onChangeClientState, c2 = t2.scriptTags, u2 = t2.styleTags, p2 = t2.title, f2 = t2.titleAttributes;
  2123. B(l.BODY, t2.bodyAttributes), B(l.HTML, n3), (function(t3, e3) {
  2124. t3 !== void 0 && document.title !== t3 && (document.title = S(t3)), B(l.TITLE, e3);
  2125. })(p2, f2);
  2126. var d2 = { baseTag: Y(l.BASE, r4), linkTags: Y(l.LINK, i2), metaTags: Y(l.META, o3), noscriptTags: Y(l.NOSCRIPT, a2), scriptTags: Y(l.SCRIPT, c2), styleTags: Y(l.STYLE, u2) }, h2 = {}, m2 = {};
  2127. Object.keys(d2).forEach(function(t3) {
  2128. var e3 = d2[t3], r5 = e3.newTags, n4 = e3.oldTags;
  2129. r5.length && (h2[t3] = r5), n4.length && (m2[t3] = d2[t3].oldTags);
  2130. }), e2 && e2(), s2(t2, h2, m2);
  2131. }, _ = null, z = (function(t2) {
  2132. function e2() {
  2133. for (var e3, r5 = arguments.length, n3 = new Array(r5), i2 = 0; i2 < r5; i2++) n3[i2] = arguments[i2];
  2134. return (e3 = t2.call.apply(t2, [this].concat(n3)) || this).rendered = !1, e3;
  2135. }
  2136. s(e2, t2);
  2137. var r4 = e2.prototype;
  2138. return r4.shouldComponentUpdate = function(t3) {
  2139. return !(0, import_shallowequal.default)(t3, this.props);
  2140. }, r4.componentDidUpdate = function() {
  2141. this.emitChange();
  2142. }, r4.componentWillUnmount = function() {
  2143. this.props.context.helmetInstances.remove(this), this.emitChange();
  2144. }, r4.emitChange = function() {
  2145. var t3, e3, r5 = this.props.context, n3 = r5.setHelmet, i2 = null, o3 = (t3 = r5.helmetInstances.get().map(function(t4) {
  2146. var e4 = a({}, t4.props);
  2147. return delete e4.context, e4;
  2148. }), { baseTag: A2(["href"], t3), bodyAttributes: v("bodyAttributes", t3), defer: T(t3, "defer"), encode: T(t3, "encodeSpecialCharacters"), htmlAttributes: v("htmlAttributes", t3), linkTags: C(l.LINK, ["rel", "href"], t3), metaTags: C(l.META, ["name", "charset", "http-equiv", "property", "itemprop"], t3), noscriptTags: C(l.NOSCRIPT, ["innerHTML"], t3), onChangeClientState: b(t3), scriptTags: C(l.SCRIPT, ["src", "innerHTML"], t3), styleTags: C(l.STYLE, ["cssText"], t3), title: g(t3), titleAttributes: v("titleAttributes", t3), prioritizeSeoTags: O(t3, "prioritizeSeoTags") });
  2149. q.canUseDOM ? (e3 = o3, _ && cancelAnimationFrame(_), e3.defer ? _ = requestAnimationFrame(function() {
  2150. K(e3, function() {
  2151. _ = null;
  2152. });
  2153. }) : (K(e3), _ = null)) : k && (i2 = k(o3)), n3(i2);
  2154. }, r4.init = function() {
  2155. this.rendered || (this.rendered = !0, this.props.context.helmetInstances.add(this), this.emitChange());
  2156. }, r4.render = function() {
  2157. return this.init(), null;
  2158. }, e2;
  2159. })(Component);
  2160. z.propTypes = { context: D.isRequired }, z.displayName = "HelmetDispatcher";
  2161. var F = ["children"], G = ["children"], W = (function(e2) {
  2162. function r4() {
  2163. return e2.apply(this, arguments) || this;
  2164. }
  2165. s(r4, e2);
  2166. var o3 = r4.prototype;
  2167. return o3.shouldComponentUpdate = function(t2) {
  2168. return !(0, import_react_fast_compare.default)(I(this.props, "helmetData"), I(t2, "helmetData"));
  2169. }, o3.mapNestedChildrenToProps = function(t2, e3) {
  2170. if (!e3) return null;
  2171. switch (t2.type) {
  2172. case l.SCRIPT:
  2173. case l.NOSCRIPT:
  2174. return { innerHTML: e3 };
  2175. case l.STYLE:
  2176. return { cssText: e3 };
  2177. default:
  2178. throw new Error("<" + t2.type + " /> elements are self-closing and can not contain children. Refer to our API for more information.");
  2179. }
  2180. }, o3.flattenArrayTypeChildren = function(t2) {
  2181. var e3, r5 = t2.child, n3 = t2.arrayTypeChildren;
  2182. return a({}, n3, ((e3 = {})[r5.type] = [].concat(n3[r5.type] || [], [a({}, t2.newChildProps, this.mapNestedChildrenToProps(r5, t2.nestedChildren))]), e3));
  2183. }, o3.mapObjectTypeChildren = function(t2) {
  2184. var e3, r5, n3 = t2.child, i2 = t2.newProps, o4 = t2.newChildProps, s2 = t2.nestedChildren;
  2185. switch (n3.type) {
  2186. case l.TITLE:
  2187. return a({}, i2, ((e3 = {})[n3.type] = s2, e3.titleAttributes = a({}, o4), e3));
  2188. case l.BODY:
  2189. return a({}, i2, { bodyAttributes: a({}, o4) });
  2190. case l.HTML:
  2191. return a({}, i2, { htmlAttributes: a({}, o4) });
  2192. default:
  2193. return a({}, i2, ((r5 = {})[n3.type] = a({}, o4), r5));
  2194. }
  2195. }, o3.mapArrayTypeChildrenToProps = function(t2, e3) {
  2196. var r5 = a({}, e3);
  2197. return Object.keys(t2).forEach(function(e4) {
  2198. var n3;
  2199. r5 = a({}, r5, ((n3 = {})[e4] = t2[e4], n3));
  2200. }), r5;
  2201. }, o3.warnOnInvalidChildren = function(t2, e3) {
  2202. return (0, import_invariant.default)(h.some(function(e4) {
  2203. return t2.type === e4;
  2204. }), typeof t2.type == "function" ? "You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information." : "Only elements types " + h.join(", ") + " are allowed. Helmet does not support rendering <" + t2.type + "> elements. Refer to our API for more information."), (0, import_invariant.default)(!e3 || typeof e3 == "string" || Array.isArray(e3) && !e3.some(function(t3) {
  2205. return typeof t3 != "string";
  2206. }), "Helmet expects a string as a child of <" + t2.type + ">. Did you forget to wrap your children in braces? ( <" + t2.type + ">{``}</" + t2.type + "> ) Refer to our API for more information."), !0;
  2207. }, o3.mapChildrenToProps = function(e3, r5) {
  2208. var n3 = this, i2 = {};
  2209. return react_default.Children.forEach(e3, function(t2) {
  2210. if (t2 && t2.props) {
  2211. var e4 = t2.props, o4 = e4.children, a2 = u(e4, F), s2 = Object.keys(a2).reduce(function(t3, e5) {
  2212. return t3[y[e5] || e5] = a2[e5], t3;
  2213. }, {}), c2 = t2.type;
  2214. switch (typeof c2 == "symbol" ? c2 = c2.toString() : n3.warnOnInvalidChildren(t2, o4), c2) {
  2215. case l.FRAGMENT:
  2216. r5 = n3.mapChildrenToProps(o4, r5);
  2217. break;
  2218. case l.LINK:
  2219. case l.META:
  2220. case l.NOSCRIPT:
  2221. case l.SCRIPT:
  2222. case l.STYLE:
  2223. i2 = n3.flattenArrayTypeChildren({ child: t2, arrayTypeChildren: i2, newChildProps: s2, nestedChildren: o4 });
  2224. break;
  2225. default:
  2226. r5 = n3.mapObjectTypeChildren({ child: t2, newProps: r5, newChildProps: s2, nestedChildren: o4 });
  2227. }
  2228. }
  2229. }), this.mapArrayTypeChildrenToProps(i2, r5);
  2230. }, o3.render = function() {
  2231. var e3 = this.props, r5 = e3.children, n3 = u(e3, G), i2 = a({}, n3), o4 = n3.helmetData;
  2232. return r5 && (i2 = this.mapChildrenToProps(r5, i2)), !o4 || o4 instanceof N || (o4 = new N(o4.context, o4.instances)), o4 ? react_default.createElement(z, a({}, i2, { context: o4.value, helmetData: void 0 })) : react_default.createElement(R.Consumer, null, function(e4) {
  2233. return react_default.createElement(z, a({}, i2, { context: e4 }));
  2234. });
  2235. }, r4;
  2236. })(Component);
  2237. W.propTypes = { base: import_prop_types.default.object, bodyAttributes: import_prop_types.default.object, children: import_prop_types.default.oneOfType([import_prop_types.default.arrayOf(import_prop_types.default.node), import_prop_types.default.node]), defaultTitle: import_prop_types.default.string, defer: import_prop_types.default.bool, encodeSpecialCharacters: import_prop_types.default.bool, htmlAttributes: import_prop_types.default.object, link: import_prop_types.default.arrayOf(import_prop_types.default.object), meta: import_prop_types.default.arrayOf(import_prop_types.default.object), noscript: import_prop_types.default.arrayOf(import_prop_types.default.object), onChangeClientState: import_prop_types.default.func, script: import_prop_types.default.arrayOf(import_prop_types.default.object), style: import_prop_types.default.arrayOf(import_prop_types.default.object), title: import_prop_types.default.string, titleAttributes: import_prop_types.default.object, titleTemplate: import_prop_types.default.string, prioritizeSeoTags: import_prop_types.default.bool, helmetData: import_prop_types.default.object }, W.defaultProps = { defer: !0, encodeSpecialCharacters: !0, prioritizeSeoTags: !1 }, W.displayName = "Helmet";
  2238. // src/manager/App.tsx
  2239. init_react();
  2240. // src/manager/components/error-boundary/ManagerErrorBoundary.tsx
  2241. init_react();
  2242. // ../../node_modules/@babel/runtime/helpers/esm/extends.js
  2243. function _extends() {
  2244. return _extends = Object.assign ? Object.assign.bind() : function(n3) {
  2245. for (var e2 = 1; e2 < arguments.length; e2++) {
  2246. var t2 = arguments[e2];
  2247. for (var r4 in t2) ({}).hasOwnProperty.call(t2, r4) && (n3[r4] = t2[r4]);
  2248. }
  2249. return n3;
  2250. }, _extends.apply(null, arguments);
  2251. }
  2252. // ../../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
  2253. function _assertThisInitialized(e2) {
  2254. if (e2 === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  2255. return e2;
  2256. }
  2257. // ../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
  2258. function _setPrototypeOf(t2, e2) {
  2259. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t3, e3) {
  2260. return t3.__proto__ = e3, t3;
  2261. }, _setPrototypeOf(t2, e2);
  2262. }
  2263. // ../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
  2264. function _inheritsLoose(t2, o3) {
  2265. t2.prototype = Object.create(o3.prototype), t2.prototype.constructor = t2, _setPrototypeOf(t2, o3);
  2266. }
  2267. // ../../node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
  2268. function _getPrototypeOf(t2) {
  2269. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t3) {
  2270. return t3.__proto__ || Object.getPrototypeOf(t3);
  2271. }, _getPrototypeOf(t2);
  2272. }
  2273. // ../../node_modules/@babel/runtime/helpers/esm/isNativeFunction.js
  2274. function _isNativeFunction(t2) {
  2275. try {
  2276. return Function.toString.call(t2).indexOf("[native code]") !== -1;
  2277. } catch {
  2278. return typeof t2 == "function";
  2279. }
  2280. }
  2281. // ../../node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js
  2282. function _isNativeReflectConstruct() {
  2283. try {
  2284. var t2 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
  2285. }));
  2286. } catch {
  2287. }
  2288. return (_isNativeReflectConstruct = function() {
  2289. return !!t2;
  2290. })();
  2291. }
  2292. // ../../node_modules/@babel/runtime/helpers/esm/construct.js
  2293. function _construct(t2, e2, r4) {
  2294. if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
  2295. var o3 = [null];
  2296. o3.push.apply(o3, e2);
  2297. var p2 = new (t2.bind.apply(t2, o3))();
  2298. return r4 && _setPrototypeOf(p2, r4.prototype), p2;
  2299. }
  2300. // ../../node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js
  2301. function _wrapNativeSuper(t2) {
  2302. var r4 = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
  2303. return _wrapNativeSuper = function(t3) {
  2304. if (t3 === null || !_isNativeFunction(t3)) return t3;
  2305. if (typeof t3 != "function") throw new TypeError("Super expression must either be null or a function");
  2306. if (r4 !== void 0) {
  2307. if (r4.has(t3)) return r4.get(t3);
  2308. r4.set(t3, Wrapper9);
  2309. }
  2310. function Wrapper9() {
  2311. return _construct(t3, arguments, _getPrototypeOf(this).constructor);
  2312. }
  2313. return Wrapper9.prototype = Object.create(t3.prototype, {
  2314. constructor: {
  2315. value: Wrapper9,
  2316. enumerable: !1,
  2317. writable: !0,
  2318. configurable: !0
  2319. }
  2320. }), _setPrototypeOf(Wrapper9, t3);
  2321. }, _wrapNativeSuper(t2);
  2322. }
  2323. // ../../node_modules/polished/dist/polished.esm.js
  2324. var PolishedError = (function(_Error) {
  2325. _inheritsLoose(PolishedError2, _Error);
  2326. function PolishedError2(code) {
  2327. var _this;
  2328. if (1)
  2329. _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
  2330. else
  2331. for (var _len2, args, _key2; _key2 < _len2; _key2++)
  2332. ;
  2333. return _assertThisInitialized(_this);
  2334. }
  2335. return PolishedError2;
  2336. })(_wrapNativeSuper(Error));
  2337. function endsWith(string, suffix) {
  2338. return string.substr(-suffix.length) === suffix;
  2339. }
  2340. var cssRegex$1 = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
  2341. function stripUnit(value) {
  2342. if (typeof value != "string") return value;
  2343. var matchedValue = value.match(cssRegex$1);
  2344. return matchedValue ? parseFloat(value) : value;
  2345. }
  2346. var pxtoFactory = function(to) {
  2347. return function(pxval, base) {
  2348. base === void 0 && (base = "16px");
  2349. var newPxval = pxval, newBase = base;
  2350. if (typeof pxval == "string") {
  2351. if (!endsWith(pxval, "px"))
  2352. throw new PolishedError(69, to, pxval);
  2353. newPxval = stripUnit(pxval);
  2354. }
  2355. if (typeof base == "string") {
  2356. if (!endsWith(base, "px"))
  2357. throw new PolishedError(70, to, base);
  2358. newBase = stripUnit(base);
  2359. }
  2360. if (typeof newPxval == "string")
  2361. throw new PolishedError(71, pxval, to);
  2362. if (typeof newBase == "string")
  2363. throw new PolishedError(72, base, to);
  2364. return "" + newPxval / newBase + to;
  2365. };
  2366. }, pixelsto = pxtoFactory, em = pixelsto("em");
  2367. var rem = pixelsto("rem");
  2368. function colorToInt(color2) {
  2369. return Math.round(color2 * 255);
  2370. }
  2371. function convertToInt(red, green, blue) {
  2372. return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
  2373. }
  2374. function hslToRgb(hue, saturation, lightness, convert2) {
  2375. if (convert2 === void 0 && (convert2 = convertToInt), saturation === 0)
  2376. return convert2(lightness, lightness, lightness);
  2377. var huePrime = (hue % 360 + 360) % 360 / 60, chroma = (1 - Math.abs(2 * lightness - 1)) * saturation, secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1)), red = 0, green = 0, blue = 0;
  2378. huePrime >= 0 && huePrime < 1 ? (red = chroma, green = secondComponent) : huePrime >= 1 && huePrime < 2 ? (red = secondComponent, green = chroma) : huePrime >= 2 && huePrime < 3 ? (green = chroma, blue = secondComponent) : huePrime >= 3 && huePrime < 4 ? (green = secondComponent, blue = chroma) : huePrime >= 4 && huePrime < 5 ? (red = secondComponent, blue = chroma) : huePrime >= 5 && huePrime < 6 && (red = chroma, blue = secondComponent);
  2379. var lightnessModification = lightness - chroma / 2, finalRed = red + lightnessModification, finalGreen = green + lightnessModification, finalBlue = blue + lightnessModification;
  2380. return convert2(finalRed, finalGreen, finalBlue);
  2381. }
  2382. var namedColorMap = {
  2383. aliceblue: "f0f8ff",
  2384. antiquewhite: "faebd7",
  2385. aqua: "00ffff",
  2386. aquamarine: "7fffd4",
  2387. azure: "f0ffff",
  2388. beige: "f5f5dc",
  2389. bisque: "ffe4c4",
  2390. black: "000",
  2391. blanchedalmond: "ffebcd",
  2392. blue: "0000ff",
  2393. blueviolet: "8a2be2",
  2394. brown: "a52a2a",
  2395. burlywood: "deb887",
  2396. cadetblue: "5f9ea0",
  2397. chartreuse: "7fff00",
  2398. chocolate: "d2691e",
  2399. coral: "ff7f50",
  2400. cornflowerblue: "6495ed",
  2401. cornsilk: "fff8dc",
  2402. crimson: "dc143c",
  2403. cyan: "00ffff",
  2404. darkblue: "00008b",
  2405. darkcyan: "008b8b",
  2406. darkgoldenrod: "b8860b",
  2407. darkgray: "a9a9a9",
  2408. darkgreen: "006400",
  2409. darkgrey: "a9a9a9",
  2410. darkkhaki: "bdb76b",
  2411. darkmagenta: "8b008b",
  2412. darkolivegreen: "556b2f",
  2413. darkorange: "ff8c00",
  2414. darkorchid: "9932cc",
  2415. darkred: "8b0000",
  2416. darksalmon: "e9967a",
  2417. darkseagreen: "8fbc8f",
  2418. darkslateblue: "483d8b",
  2419. darkslategray: "2f4f4f",
  2420. darkslategrey: "2f4f4f",
  2421. darkturquoise: "00ced1",
  2422. darkviolet: "9400d3",
  2423. deeppink: "ff1493",
  2424. deepskyblue: "00bfff",
  2425. dimgray: "696969",
  2426. dimgrey: "696969",
  2427. dodgerblue: "1e90ff",
  2428. firebrick: "b22222",
  2429. floralwhite: "fffaf0",
  2430. forestgreen: "228b22",
  2431. fuchsia: "ff00ff",
  2432. gainsboro: "dcdcdc",
  2433. ghostwhite: "f8f8ff",
  2434. gold: "ffd700",
  2435. goldenrod: "daa520",
  2436. gray: "808080",
  2437. green: "008000",
  2438. greenyellow: "adff2f",
  2439. grey: "808080",
  2440. honeydew: "f0fff0",
  2441. hotpink: "ff69b4",
  2442. indianred: "cd5c5c",
  2443. indigo: "4b0082",
  2444. ivory: "fffff0",
  2445. khaki: "f0e68c",
  2446. lavender: "e6e6fa",
  2447. lavenderblush: "fff0f5",
  2448. lawngreen: "7cfc00",
  2449. lemonchiffon: "fffacd",
  2450. lightblue: "add8e6",
  2451. lightcoral: "f08080",
  2452. lightcyan: "e0ffff",
  2453. lightgoldenrodyellow: "fafad2",
  2454. lightgray: "d3d3d3",
  2455. lightgreen: "90ee90",
  2456. lightgrey: "d3d3d3",
  2457. lightpink: "ffb6c1",
  2458. lightsalmon: "ffa07a",
  2459. lightseagreen: "20b2aa",
  2460. lightskyblue: "87cefa",
  2461. lightslategray: "789",
  2462. lightslategrey: "789",
  2463. lightsteelblue: "b0c4de",
  2464. lightyellow: "ffffe0",
  2465. lime: "0f0",
  2466. limegreen: "32cd32",
  2467. linen: "faf0e6",
  2468. magenta: "f0f",
  2469. maroon: "800000",
  2470. mediumaquamarine: "66cdaa",
  2471. mediumblue: "0000cd",
  2472. mediumorchid: "ba55d3",
  2473. mediumpurple: "9370db",
  2474. mediumseagreen: "3cb371",
  2475. mediumslateblue: "7b68ee",
  2476. mediumspringgreen: "00fa9a",
  2477. mediumturquoise: "48d1cc",
  2478. mediumvioletred: "c71585",
  2479. midnightblue: "191970",
  2480. mintcream: "f5fffa",
  2481. mistyrose: "ffe4e1",
  2482. moccasin: "ffe4b5",
  2483. navajowhite: "ffdead",
  2484. navy: "000080",
  2485. oldlace: "fdf5e6",
  2486. olive: "808000",
  2487. olivedrab: "6b8e23",
  2488. orange: "ffa500",
  2489. orangered: "ff4500",
  2490. orchid: "da70d6",
  2491. palegoldenrod: "eee8aa",
  2492. palegreen: "98fb98",
  2493. paleturquoise: "afeeee",
  2494. palevioletred: "db7093",
  2495. papayawhip: "ffefd5",
  2496. peachpuff: "ffdab9",
  2497. peru: "cd853f",
  2498. pink: "ffc0cb",
  2499. plum: "dda0dd",
  2500. powderblue: "b0e0e6",
  2501. purple: "800080",
  2502. rebeccapurple: "639",
  2503. red: "f00",
  2504. rosybrown: "bc8f8f",
  2505. royalblue: "4169e1",
  2506. saddlebrown: "8b4513",
  2507. salmon: "fa8072",
  2508. sandybrown: "f4a460",
  2509. seagreen: "2e8b57",
  2510. seashell: "fff5ee",
  2511. sienna: "a0522d",
  2512. silver: "c0c0c0",
  2513. skyblue: "87ceeb",
  2514. slateblue: "6a5acd",
  2515. slategray: "708090",
  2516. slategrey: "708090",
  2517. snow: "fffafa",
  2518. springgreen: "00ff7f",
  2519. steelblue: "4682b4",
  2520. tan: "d2b48c",
  2521. teal: "008080",
  2522. thistle: "d8bfd8",
  2523. tomato: "ff6347",
  2524. turquoise: "40e0d0",
  2525. violet: "ee82ee",
  2526. wheat: "f5deb3",
  2527. white: "fff",
  2528. whitesmoke: "f5f5f5",
  2529. yellow: "ff0",
  2530. yellowgreen: "9acd32"
  2531. };
  2532. function nameToHex(color2) {
  2533. if (typeof color2 != "string") return color2;
  2534. var normalizedColorName = color2.toLowerCase();
  2535. return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color2;
  2536. }
  2537. var hexRegex = /^#[a-fA-F0-9]{6}$/, hexRgbaRegex = /^#[a-fA-F0-9]{8}$/, reducedHexRegex = /^#[a-fA-F0-9]{3}$/, reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/, rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i, rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i, hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i, hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
  2538. function parseToRgb(color2) {
  2539. if (typeof color2 != "string")
  2540. throw new PolishedError(3);
  2541. var normalizedColor = nameToHex(color2);
  2542. if (normalizedColor.match(hexRegex))
  2543. return {
  2544. red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
  2545. green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
  2546. blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
  2547. };
  2548. if (normalizedColor.match(hexRgbaRegex)) {
  2549. var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
  2550. return {
  2551. red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
  2552. green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
  2553. blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
  2554. alpha
  2555. };
  2556. }
  2557. if (normalizedColor.match(reducedHexRegex))
  2558. return {
  2559. red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
  2560. green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
  2561. blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
  2562. };
  2563. if (normalizedColor.match(reducedRgbaHexRegex)) {
  2564. var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
  2565. return {
  2566. red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
  2567. green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
  2568. blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
  2569. alpha: _alpha
  2570. };
  2571. }
  2572. var rgbMatched = rgbRegex.exec(normalizedColor);
  2573. if (rgbMatched)
  2574. return {
  2575. red: parseInt("" + rgbMatched[1], 10),
  2576. green: parseInt("" + rgbMatched[2], 10),
  2577. blue: parseInt("" + rgbMatched[3], 10)
  2578. };
  2579. var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
  2580. if (rgbaMatched)
  2581. return {
  2582. red: parseInt("" + rgbaMatched[1], 10),
  2583. green: parseInt("" + rgbaMatched[2], 10),
  2584. blue: parseInt("" + rgbaMatched[3], 10),
  2585. alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
  2586. };
  2587. var hslMatched = hslRegex.exec(normalizedColor);
  2588. if (hslMatched) {
  2589. var hue = parseInt("" + hslMatched[1], 10), saturation = parseInt("" + hslMatched[2], 10) / 100, lightness = parseInt("" + hslMatched[3], 10) / 100, rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")", hslRgbMatched = rgbRegex.exec(rgbColorString);
  2590. if (!hslRgbMatched)
  2591. throw new PolishedError(4, normalizedColor, rgbColorString);
  2592. return {
  2593. red: parseInt("" + hslRgbMatched[1], 10),
  2594. green: parseInt("" + hslRgbMatched[2], 10),
  2595. blue: parseInt("" + hslRgbMatched[3], 10)
  2596. };
  2597. }
  2598. var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
  2599. if (hslaMatched) {
  2600. var _hue = parseInt("" + hslaMatched[1], 10), _saturation = parseInt("" + hslaMatched[2], 10) / 100, _lightness = parseInt("" + hslaMatched[3], 10) / 100, _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")", _hslRgbMatched = rgbRegex.exec(_rgbColorString);
  2601. if (!_hslRgbMatched)
  2602. throw new PolishedError(4, normalizedColor, _rgbColorString);
  2603. return {
  2604. red: parseInt("" + _hslRgbMatched[1], 10),
  2605. green: parseInt("" + _hslRgbMatched[2], 10),
  2606. blue: parseInt("" + _hslRgbMatched[3], 10),
  2607. alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
  2608. };
  2609. }
  2610. throw new PolishedError(5);
  2611. }
  2612. function rgbToHsl(color2) {
  2613. var red = color2.red / 255, green = color2.green / 255, blue = color2.blue / 255, max = Math.max(red, green, blue), min = Math.min(red, green, blue), lightness = (max + min) / 2;
  2614. if (max === min)
  2615. return color2.alpha !== void 0 ? {
  2616. hue: 0,
  2617. saturation: 0,
  2618. lightness,
  2619. alpha: color2.alpha
  2620. } : {
  2621. hue: 0,
  2622. saturation: 0,
  2623. lightness
  2624. };
  2625. var hue, delta = max - min, saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
  2626. switch (max) {
  2627. case red:
  2628. hue = (green - blue) / delta + (green < blue ? 6 : 0);
  2629. break;
  2630. case green:
  2631. hue = (blue - red) / delta + 2;
  2632. break;
  2633. default:
  2634. hue = (red - green) / delta + 4;
  2635. break;
  2636. }
  2637. return hue *= 60, color2.alpha !== void 0 ? {
  2638. hue,
  2639. saturation,
  2640. lightness,
  2641. alpha: color2.alpha
  2642. } : {
  2643. hue,
  2644. saturation,
  2645. lightness
  2646. };
  2647. }
  2648. function parseToHsl(color2) {
  2649. return rgbToHsl(parseToRgb(color2));
  2650. }
  2651. var reduceHexValue = function(value) {
  2652. return value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6] ? "#" + value[1] + value[3] + value[5] : value;
  2653. }, reduceHexValue$1 = reduceHexValue;
  2654. function numberToHex(value) {
  2655. var hex = value.toString(16);
  2656. return hex.length === 1 ? "0" + hex : hex;
  2657. }
  2658. function colorToHex(color2) {
  2659. return numberToHex(Math.round(color2 * 255));
  2660. }
  2661. function convertToHex(red, green, blue) {
  2662. return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
  2663. }
  2664. function hslToHex(hue, saturation, lightness) {
  2665. return hslToRgb(hue, saturation, lightness, convertToHex);
  2666. }
  2667. function hsl(value, saturation, lightness) {
  2668. if (typeof value == "number" && typeof saturation == "number" && typeof lightness == "number")
  2669. return hslToHex(value, saturation, lightness);
  2670. if (typeof value == "object" && saturation === void 0 && lightness === void 0)
  2671. return hslToHex(value.hue, value.saturation, value.lightness);
  2672. throw new PolishedError(1);
  2673. }
  2674. function hsla(value, saturation, lightness, alpha) {
  2675. if (typeof value == "number" && typeof saturation == "number" && typeof lightness == "number" && typeof alpha == "number")
  2676. return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
  2677. if (typeof value == "object" && saturation === void 0 && lightness === void 0 && alpha === void 0)
  2678. return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
  2679. throw new PolishedError(2);
  2680. }
  2681. function rgb(value, green, blue) {
  2682. if (typeof value == "number" && typeof green == "number" && typeof blue == "number")
  2683. return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
  2684. if (typeof value == "object" && green === void 0 && blue === void 0)
  2685. return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
  2686. throw new PolishedError(6);
  2687. }
  2688. function rgba(firstValue, secondValue, thirdValue, fourthValue) {
  2689. if (typeof firstValue == "string" && typeof secondValue == "number") {
  2690. var rgbValue = parseToRgb(firstValue);
  2691. return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
  2692. } else {
  2693. if (typeof firstValue == "number" && typeof secondValue == "number" && typeof thirdValue == "number" && typeof fourthValue == "number")
  2694. return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
  2695. if (typeof firstValue == "object" && secondValue === void 0 && thirdValue === void 0 && fourthValue === void 0)
  2696. return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
  2697. }
  2698. throw new PolishedError(7);
  2699. }
  2700. var isRgb = function(color2) {
  2701. return typeof color2.red == "number" && typeof color2.green == "number" && typeof color2.blue == "number" && (typeof color2.alpha != "number" || typeof color2.alpha > "u");
  2702. }, isRgba = function(color2) {
  2703. return typeof color2.red == "number" && typeof color2.green == "number" && typeof color2.blue == "number" && typeof color2.alpha == "number";
  2704. }, isHsl = function(color2) {
  2705. return typeof color2.hue == "number" && typeof color2.saturation == "number" && typeof color2.lightness == "number" && (typeof color2.alpha != "number" || typeof color2.alpha > "u");
  2706. }, isHsla = function(color2) {
  2707. return typeof color2.hue == "number" && typeof color2.saturation == "number" && typeof color2.lightness == "number" && typeof color2.alpha == "number";
  2708. };
  2709. function toColorString(color2) {
  2710. if (typeof color2 != "object") throw new PolishedError(8);
  2711. if (isRgba(color2)) return rgba(color2);
  2712. if (isRgb(color2)) return rgb(color2);
  2713. if (isHsla(color2)) return hsla(color2);
  2714. if (isHsl(color2)) return hsl(color2);
  2715. throw new PolishedError(8);
  2716. }
  2717. function curried(f2, length, acc) {
  2718. return function() {
  2719. var combined = acc.concat(Array.prototype.slice.call(arguments));
  2720. return combined.length >= length ? f2.apply(this, combined) : curried(f2, length, combined);
  2721. };
  2722. }
  2723. function curry(f2) {
  2724. return curried(f2, f2.length, []);
  2725. }
  2726. function adjustHue(degree, color2) {
  2727. if (color2 === "transparent") return color2;
  2728. var hslColor = parseToHsl(color2);
  2729. return toColorString(_extends({}, hslColor, {
  2730. hue: hslColor.hue + parseFloat(degree)
  2731. }));
  2732. }
  2733. var curriedAdjustHue = curry(adjustHue);
  2734. function guard(lowerBoundary, upperBoundary, value) {
  2735. return Math.max(lowerBoundary, Math.min(upperBoundary, value));
  2736. }
  2737. function darken2(amount, color2) {
  2738. if (color2 === "transparent") return color2;
  2739. var hslColor = parseToHsl(color2);
  2740. return toColorString(_extends({}, hslColor, {
  2741. lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
  2742. }));
  2743. }
  2744. var curriedDarken = curry(darken2), curriedDarken$1 = curriedDarken;
  2745. function desaturate(amount, color2) {
  2746. if (color2 === "transparent") return color2;
  2747. var hslColor = parseToHsl(color2);
  2748. return toColorString(_extends({}, hslColor, {
  2749. saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
  2750. }));
  2751. }
  2752. var curriedDesaturate = curry(desaturate);
  2753. function lighten2(amount, color2) {
  2754. if (color2 === "transparent") return color2;
  2755. var hslColor = parseToHsl(color2);
  2756. return toColorString(_extends({}, hslColor, {
  2757. lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
  2758. }));
  2759. }
  2760. var curriedLighten = curry(lighten2), curriedLighten$1 = curriedLighten;
  2761. function mix(weight, color2, otherColor) {
  2762. if (color2 === "transparent") return otherColor;
  2763. if (otherColor === "transparent") return color2;
  2764. if (weight === 0) return otherColor;
  2765. var parsedColor1 = parseToRgb(color2), color1 = _extends({}, parsedColor1, {
  2766. alpha: typeof parsedColor1.alpha == "number" ? parsedColor1.alpha : 1
  2767. }), parsedColor2 = parseToRgb(otherColor), color22 = _extends({}, parsedColor2, {
  2768. alpha: typeof parsedColor2.alpha == "number" ? parsedColor2.alpha : 1
  2769. }), alphaDelta = color1.alpha - color22.alpha, x2 = parseFloat(weight) * 2 - 1, y2 = x2 * alphaDelta === -1 ? x2 : x2 + alphaDelta, z2 = 1 + x2 * alphaDelta, weight1 = (y2 / z2 + 1) / 2, weight2 = 1 - weight1, mixedColor = {
  2770. red: Math.floor(color1.red * weight1 + color22.red * weight2),
  2771. green: Math.floor(color1.green * weight1 + color22.green * weight2),
  2772. blue: Math.floor(color1.blue * weight1 + color22.blue * weight2),
  2773. alpha: color1.alpha * parseFloat(weight) + color22.alpha * (1 - parseFloat(weight))
  2774. };
  2775. return rgba(mixedColor);
  2776. }
  2777. var curriedMix = curry(mix), mix$1 = curriedMix;
  2778. function opacify(amount, color2) {
  2779. if (color2 === "transparent") return color2;
  2780. var parsedColor = parseToRgb(color2), alpha = typeof parsedColor.alpha == "number" ? parsedColor.alpha : 1, colorWithAlpha = _extends({}, parsedColor, {
  2781. alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
  2782. });
  2783. return rgba(colorWithAlpha);
  2784. }
  2785. var curriedOpacify = curry(opacify);
  2786. function saturate(amount, color2) {
  2787. if (color2 === "transparent") return color2;
  2788. var hslColor = parseToHsl(color2);
  2789. return toColorString(_extends({}, hslColor, {
  2790. saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
  2791. }));
  2792. }
  2793. var curriedSaturate = curry(saturate);
  2794. function setHue(hue, color2) {
  2795. return color2 === "transparent" ? color2 : toColorString(_extends({}, parseToHsl(color2), {
  2796. hue: parseFloat(hue)
  2797. }));
  2798. }
  2799. var curriedSetHue = curry(setHue);
  2800. function setLightness(lightness, color2) {
  2801. return color2 === "transparent" ? color2 : toColorString(_extends({}, parseToHsl(color2), {
  2802. lightness: parseFloat(lightness)
  2803. }));
  2804. }
  2805. var curriedSetLightness = curry(setLightness);
  2806. function setSaturation(saturation, color2) {
  2807. return color2 === "transparent" ? color2 : toColorString(_extends({}, parseToHsl(color2), {
  2808. saturation: parseFloat(saturation)
  2809. }));
  2810. }
  2811. var curriedSetSaturation = curry(setSaturation);
  2812. function shade(percentage, color2) {
  2813. return color2 === "transparent" ? color2 : mix$1(parseFloat(percentage), "rgb(0, 0, 0)", color2);
  2814. }
  2815. var curriedShade = curry(shade);
  2816. function tint(percentage, color2) {
  2817. return color2 === "transparent" ? color2 : mix$1(parseFloat(percentage), "rgb(255, 255, 255)", color2);
  2818. }
  2819. var curriedTint = curry(tint);
  2820. function transparentize(amount, color2) {
  2821. if (color2 === "transparent") return color2;
  2822. var parsedColor = parseToRgb(color2), alpha = typeof parsedColor.alpha == "number" ? parsedColor.alpha : 1, colorWithAlpha = _extends({}, parsedColor, {
  2823. alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
  2824. });
  2825. return rgba(colorWithAlpha);
  2826. }
  2827. var curriedTransparentize = curry(transparentize), curriedTransparentize$1 = curriedTransparentize;
  2828. // src/manager/components/error-boundary/ManagerErrorBoundary.tsx
  2829. var Container = styled.div(({ theme }) => ({
  2830. display: "flex",
  2831. justifyContent: "center",
  2832. alignItems: "center",
  2833. width: "100vw",
  2834. height: "100vh",
  2835. backgroundColor: theme.background.app,
  2836. color: theme.color.defaultText,
  2837. fontFamily: theme.typography.fonts.base
  2838. })), Content = styled.div(({ theme }) => ({
  2839. display: "flex",
  2840. flexDirection: "column",
  2841. justifyContent: "space-between",
  2842. width: "80%",
  2843. height: "80%",
  2844. padding: 20,
  2845. gap: 20,
  2846. backgroundColor: theme.background.content,
  2847. borderRadius: theme.appBorderRadius,
  2848. border: `1px solid ${theme.color.negative}`,
  2849. boxShadow: "0 0 64px rgba(0, 0, 0, 0.1)",
  2850. overflow: "auto"
  2851. })), Info = styled.div(({ theme }) => ({
  2852. display: "flex",
  2853. flexDirection: "column",
  2854. alignItems: "start",
  2855. gap: 15
  2856. })), Heading = styled.h1(({ theme }) => ({
  2857. display: "flex",
  2858. alignItems: "center",
  2859. margin: 0,
  2860. gap: 10,
  2861. fontSize: theme.typography.size.s2,
  2862. fontWeight: theme.typography.weight.bold,
  2863. color: theme.color.defaultText
  2864. })), SubHeading = styled.p(({ theme }) => ({
  2865. fontSize: theme.typography.size.s2,
  2866. color: theme.textMutedColor,
  2867. margin: 0,
  2868. lineHeight: 1.4,
  2869. textWrap: "balance"
  2870. })), ErrorWrapper = styled.div(({ theme }) => ({
  2871. display: "flex",
  2872. flexDirection: "column-reverse",
  2873. width: "100%",
  2874. flex: "0 0 auto",
  2875. border: `1px solid ${theme.appBorderColor}`,
  2876. borderRadius: theme.appBorderRadius,
  2877. pre: {
  2878. borderRadius: 0
  2879. }
  2880. })), CollapseToggle = styled.div(({ theme }) => ({
  2881. flex: "0 0 auto",
  2882. display: "flex",
  2883. alignItems: "center",
  2884. gap: 10,
  2885. height: 40,
  2886. width: "100%",
  2887. padding: "0 10px",
  2888. cursor: "pointer",
  2889. fontSize: theme.typography.size.s2,
  2890. fontWeight: theme.typography.weight.bold,
  2891. color: theme.color.defaultText,
  2892. userSelect: "none",
  2893. "&:hover": {
  2894. backgroundColor: theme.base === "light" ? "rgba(0, 0, 0, 0.02)" : "rgba(255, 255, 255, 0.03)"
  2895. },
  2896. svg: {
  2897. color: theme.textMutedColor
  2898. }
  2899. })), ErrorMessage = styled.pre(({ theme }) => ({
  2900. order: 1,
  2901. padding: "11px 15px",
  2902. margin: 0,
  2903. fontSize: theme.typography.size.s1,
  2904. color: theme.color.negativeText,
  2905. backgroundColor: curriedTransparentize$1(theme.base === "light" ? 0.95 : 0.9, theme.color.negative),
  2906. borderBottom: `1px solid ${theme.appBorderColor}`,
  2907. whiteSpace: "pre-wrap",
  2908. wordBreak: "break-word",
  2909. fontFamily: theme.typography.fonts.mono,
  2910. lineHeight: "18px"
  2911. })), ErrorStack = styled.pre(({ theme }) => ({
  2912. padding: 15,
  2913. margin: 0,
  2914. fontSize: theme.typography.size.s1,
  2915. color: theme.textMutedColor,
  2916. borderBottom: `1px solid ${theme.appBorderColor}`,
  2917. borderRadius: 0,
  2918. whiteSpace: "pre-wrap",
  2919. wordBreak: "break-word",
  2920. fontFamily: theme.typography.fonts.mono
  2921. })), ErrorFallback = ({ error, errorInfo }) => react_default.createElement(Container, { "data-testid": "manager-error-boundary" }, react_default.createElement(Content, null, react_default.createElement(Info, null, react_default.createElement(Heading, null, react_default.createElement(Badge, { status: "negative" }, "Error"), react_default.createElement("span", null, "Something went wrong")), react_default.createElement(SubHeading, null, "The Storybook Manager UI encountered an error. This is usually caused by custom addon code or configuration. Please check your browser console for more details. Try clearing browser storage if the issue persists."), react_default.createElement(Button, { asChild: !0, size: "medium" }, react_default.createElement("a", { href: window.location.origin + window.location.pathname.replace("iframe.html", "") }, react_default.createElement(SyncIcon, { size: 14 }), "Reload Storybook"))), react_default.createElement(ErrorWrapper, null, react_default.createElement(ErrorMessage, null, error.message || "Unknown error"), react_default.createElement(
  2922. Collapsible,
  2923. {
  2924. collapsed: !0,
  2925. summary: ({ isCollapsed, toggleCollapsed }) => react_default.createElement(CollapseToggle, { onClick: toggleCollapsed }, react_default.createElement(UnfoldIcon, null), isCollapsed ? "Expand error" : "Collapse error")
  2926. },
  2927. (error.stack || errorInfo?.componentStack) && react_default.createElement(ErrorStack, null, error.stack, errorInfo?.componentStack && `
  2928. Component Stack:${errorInfo.componentStack}`)
  2929. )))), ManagerErrorBoundary = class extends Component {
  2930. constructor(props) {
  2931. super(props), this.state = { hasError: !1, error: null, errorInfo: null };
  2932. }
  2933. static getDerivedStateFromError(error) {
  2934. return { hasError: !0, error };
  2935. }
  2936. componentDidCatch(error, errorInfo) {
  2937. console.error("Storybook Manager UI Error:", error), console.error("Component Stack:", errorInfo.componentStack), this.setState({ errorInfo }), typeof globalThis.sendTelemetryError == "function" && globalThis.sendTelemetryError(error);
  2938. }
  2939. render() {
  2940. let { hasError, error, errorInfo } = this.state, { children } = this.props;
  2941. return hasError && error ? react_default.createElement(ErrorFallback, { error, errorInfo }) : children;
  2942. }
  2943. };
  2944. // src/manager/components/layout/Layout.tsx
  2945. init_react();
  2946. // src/manager/constants.ts
  2947. var MEDIA_DESKTOP_BREAKPOINT = "@media (min-width: 600px)";
  2948. // src/manager/container/Notifications.tsx
  2949. init_react();
  2950. // src/manager/components/notifications/NotificationList.tsx
  2951. init_react();
  2952. // src/manager/components/layout/LayoutProvider.tsx
  2953. init_react();
  2954. // src/manager/hooks/useMedia.tsx
  2955. init_react();
  2956. function useMediaQuery(query) {
  2957. let getMatches = (queryMatch) => typeof window < "u" ? window.matchMedia(queryMatch).matches : !1, [matches, setMatches] = useState(getMatches(query));
  2958. function handleChange() {
  2959. setMatches(getMatches(query));
  2960. }
  2961. return useEffect(() => {
  2962. let matchMedia = window.matchMedia(query);
  2963. return handleChange(), matchMedia.addEventListener("change", handleChange), () => {
  2964. matchMedia.removeEventListener("change", handleChange);
  2965. };
  2966. }, [query]), matches;
  2967. }
  2968. // src/manager/components/layout/LayoutProvider.tsx
  2969. var LayoutContext = createContext({
  2970. isMobileMenuOpen: !1,
  2971. setMobileMenuOpen: () => {
  2972. },
  2973. isMobileAboutOpen: !1,
  2974. setMobileAboutOpen: () => {
  2975. },
  2976. isMobilePanelOpen: !1,
  2977. setMobilePanelOpen: () => {
  2978. },
  2979. isDesktop: !1,
  2980. isMobile: !1
  2981. }), LayoutProvider = ({ children, forceDesktop }) => {
  2982. let [isMobileMenuOpen, setMobileMenuOpen] = useState(!1), [isMobileAboutOpen, setMobileAboutOpen] = useState(!1), [isMobilePanelOpen, setMobilePanelOpen] = useState(!1), isDesktop = forceDesktop ?? useMediaQuery(`(min-width: ${600}px)`), isMobile2 = !isDesktop, contextValue = useMemo(
  2983. () => ({
  2984. isMobileMenuOpen,
  2985. setMobileMenuOpen,
  2986. isMobileAboutOpen,
  2987. setMobileAboutOpen,
  2988. isMobilePanelOpen,
  2989. setMobilePanelOpen,
  2990. isDesktop,
  2991. isMobile: isMobile2
  2992. }),
  2993. [
  2994. isMobileMenuOpen,
  2995. setMobileMenuOpen,
  2996. isMobileAboutOpen,
  2997. setMobileAboutOpen,
  2998. isMobilePanelOpen,
  2999. setMobilePanelOpen,
  3000. isDesktop,
  3001. isMobile2
  3002. ]
  3003. );
  3004. return react_default.createElement(LayoutContext.Provider, { value: contextValue }, children);
  3005. }, useLayout = () => useContext(LayoutContext);
  3006. // src/manager/components/notifications/NotificationItem.tsx
  3007. init_react();
  3008. var slideIn = keyframes({
  3009. "0%": {
  3010. opacity: 0,
  3011. transform: "translateY(30px)"
  3012. },
  3013. "100%": {
  3014. opacity: 1,
  3015. transform: "translateY(0)"
  3016. }
  3017. }), grow = keyframes({
  3018. "0%": {
  3019. width: "0%"
  3020. },
  3021. "100%": {
  3022. width: "100%"
  3023. }
  3024. }), Notification = styled.div(
  3025. ({ theme }) => ({
  3026. position: "relative",
  3027. display: "flex",
  3028. border: `1px solid ${theme.appBorderColor}`,
  3029. padding: "12px 6px 12px 12px",
  3030. borderRadius: theme.appBorderRadius + 1,
  3031. alignItems: "center",
  3032. animation: `${slideIn} 500ms`,
  3033. background: theme.base === "light" ? "hsla(203, 50%, 20%, .97)" : "hsla(203, 30%, 95%, .97)",
  3034. boxShadow: "0 2px 5px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.1)",
  3035. color: theme.color.inverseText,
  3036. textDecoration: "none",
  3037. overflow: "hidden",
  3038. [MEDIA_DESKTOP_BREAKPOINT]: {
  3039. boxShadow: `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`
  3040. }
  3041. }),
  3042. ({ duration, theme }) => duration && {
  3043. "&::after": {
  3044. content: '""',
  3045. display: "block",
  3046. position: "absolute",
  3047. bottom: 0,
  3048. left: 0,
  3049. height: 3,
  3050. background: theme.color.secondary,
  3051. animation: `${grow} ${duration}ms linear forwards reverse`
  3052. }
  3053. }
  3054. ), NotificationWithInteractiveStates = styled(Notification)({
  3055. cursor: "pointer",
  3056. border: "none",
  3057. outline: "none",
  3058. textAlign: "left",
  3059. transition: "all 150ms ease-out",
  3060. transform: "translate3d(0, 0, 0)",
  3061. "&:hover": {
  3062. transform: "translate3d(0, -3px, 0)",
  3063. boxShadow: "0 1px 3px 0 rgba(30,167,253,0.5), 0 2px 5px 0 rgba(0,0,0,0.05), 0 5px 15px 0 rgba(0,0,0,0.1)"
  3064. },
  3065. "&:active": {
  3066. transform: "translate3d(0, 0, 0)",
  3067. boxShadow: "0 1px 3px 0 rgba(30,167,253,0.5), 0 2px 5px 0 rgba(0,0,0,0.05), 0 5px 15px 0 rgba(0,0,0,0.1)"
  3068. },
  3069. "&:focus": {
  3070. boxShadow: "rgba(2,156,253,1) 0 0 0 1px inset, 0 1px 3px 0 rgba(30,167,253,0.5), 0 2px 5px 0 rgba(0,0,0,0.05), 0 5px 15px 0 rgba(0,0,0,0.1)"
  3071. }
  3072. }), NotificationButton = NotificationWithInteractiveStates.withComponent("div"), NotificationLink = NotificationWithInteractiveStates.withComponent(Link2), NotificationIconWrapper = styled.div({
  3073. display: "flex",
  3074. marginRight: 10,
  3075. alignItems: "center",
  3076. svg: {
  3077. width: 16,
  3078. height: 16
  3079. }
  3080. }), NotificationTextWrapper = styled.div(({ theme }) => ({
  3081. width: "100%",
  3082. display: "flex",
  3083. flexDirection: "column",
  3084. color: theme.color.inverseText
  3085. })), Headline = styled.div(({ theme }) => ({
  3086. height: "100%",
  3087. alignItems: "center",
  3088. whiteSpace: "balance",
  3089. overflow: "hidden",
  3090. textOverflow: "ellipsis",
  3091. fontSize: theme.typography.size.s1,
  3092. lineHeight: "16px",
  3093. fontWeight: theme.typography.weight.bold
  3094. })), SubHeadline = styled.div(({ theme }) => ({
  3095. color: curriedTransparentize$1(0.25, theme.color.inverseText),
  3096. fontSize: theme.typography.size.s1 - 1,
  3097. lineHeight: "14px",
  3098. marginTop: 2,
  3099. whiteSpace: "balance"
  3100. })), ItemContent = ({
  3101. icon,
  3102. content: { headline, subHeadline }
  3103. }) => react_default.createElement(react_default.Fragment, null, !icon || react_default.createElement(NotificationIconWrapper, null, icon), react_default.createElement(NotificationTextWrapper, null, react_default.createElement(Headline, { title: headline }, headline), subHeadline && react_default.createElement(SubHeadline, null, subHeadline))), DismissButtonWrapper = styled(Button)(({ theme }) => ({
  3104. width: 28,
  3105. alignSelf: "center",
  3106. marginTop: 0,
  3107. color: theme.base === "light" ? "rgba(255,255,255,0.7)" : " #999999"
  3108. })), DismissNotificationItem = ({ onDismiss }) => react_default.createElement(
  3109. DismissButtonWrapper,
  3110. {
  3111. padding: "small",
  3112. variant: "ghost",
  3113. ariaLabel: "Dismiss notification",
  3114. onClick: (e2) => {
  3115. e2.preventDefault(), e2.stopPropagation(), onDismiss();
  3116. }
  3117. },
  3118. react_default.createElement(CloseAltIcon, { size: 12 })
  3119. ), NotificationItemSpacer = styled.div({
  3120. height: 48
  3121. }), NotificationItem = ({
  3122. notification: { content, duration, link, onClear, onClick, id, icon },
  3123. onDismissNotification,
  3124. zIndex
  3125. }) => {
  3126. let onTimeout = useCallback(() => {
  3127. onDismissNotification(id), onClear && onClear({ dismissed: !1, timeout: !0 });
  3128. }, [id, onDismissNotification, onClear]), timer = useRef(null);
  3129. useEffect(() => {
  3130. if (duration)
  3131. return timer.current = setTimeout(onTimeout, duration), () => clearTimeout(timer.current);
  3132. }, [duration, onTimeout]);
  3133. let onDismiss = useCallback(() => {
  3134. clearTimeout(timer.current), onDismissNotification(id), onClear && onClear({ dismissed: !0, timeout: !1 });
  3135. }, [id, onDismissNotification, onClear]);
  3136. return link ? react_default.createElement(NotificationLink, { to: link, duration, style: { zIndex } }, react_default.createElement(ItemContent, { icon, content }), react_default.createElement(DismissNotificationItem, { onDismiss })) : onClick ? react_default.createElement(
  3137. NotificationButton,
  3138. {
  3139. duration,
  3140. onClick: () => onClick({ onDismiss }),
  3141. style: { zIndex }
  3142. },
  3143. react_default.createElement(ItemContent, { icon, content }),
  3144. react_default.createElement(DismissNotificationItem, { onDismiss })
  3145. ) : react_default.createElement(Notification, { duration, style: { zIndex } }, react_default.createElement(ItemContent, { icon, content }), react_default.createElement(DismissNotificationItem, { onDismiss }));
  3146. }, NotificationItem_default = NotificationItem;
  3147. // src/manager/components/notifications/NotificationList.tsx
  3148. var NotificationList = ({
  3149. notifications,
  3150. clearNotification
  3151. }) => {
  3152. let { isMobile: isMobile2 } = useLayout();
  3153. return react_default.createElement(List, { isMobile: isMobile2 }, notifications && notifications.map((notification, index) => react_default.createElement(
  3154. NotificationItem_default,
  3155. {
  3156. key: notification.id,
  3157. onDismissNotification: (id) => clearNotification(id),
  3158. notification,
  3159. zIndex: notifications.length - index
  3160. }
  3161. )));
  3162. }, List = styled.div(
  3163. {
  3164. zIndex: 200,
  3165. "> * + *": {
  3166. marginTop: 12
  3167. },
  3168. "&:empty": {
  3169. display: "none"
  3170. }
  3171. },
  3172. ({ isMobile: isMobile2 }) => isMobile2 && {
  3173. position: "fixed",
  3174. bottom: 40,
  3175. margin: 20
  3176. }
  3177. );
  3178. // src/manager/container/Notifications.tsx
  3179. var mapper = ({ state, api }) => ({
  3180. notifications: state.notifications,
  3181. clearNotification: api.clearNotification
  3182. }), Notifications = (props) => react_default.createElement(Consumer, { filter: mapper }, (fromState) => react_default.createElement(NotificationList, { ...props, ...fromState }));
  3183. // src/manager/components/mobile/navigation/MobileNavigation.tsx
  3184. init_react();
  3185. // ../../node_modules/@react-aria/utils/dist/useLayoutEffect.mjs
  3186. init_react();
  3187. var $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document < "u" ? react_default.useLayoutEffect : () => {
  3188. };
  3189. // ../../node_modules/@react-aria/utils/dist/useValueEffect.mjs
  3190. init_react();
  3191. // ../../node_modules/@react-aria/utils/dist/useId.mjs
  3192. init_react();
  3193. // ../../node_modules/@react-aria/ssr/dist/SSRProvider.mjs
  3194. init_react();
  3195. var $b5e257d569688ac6$var$defaultContext = {
  3196. prefix: String(Math.round(Math.random() * 1e10)),
  3197. current: 0
  3198. }, $b5e257d569688ac6$var$SSRContext = react_default.createContext($b5e257d569688ac6$var$defaultContext), $b5e257d569688ac6$var$IsSSRContext = react_default.createContext(!1);
  3199. var $b5e257d569688ac6$var$canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), $b5e257d569688ac6$var$componentIds = /* @__PURE__ */ new WeakMap();
  3200. function $b5e257d569688ac6$var$useCounter(isDisabled = !1) {
  3201. let ctx = useContext($b5e257d569688ac6$var$SSRContext), ref = useRef(null);
  3202. if (ref.current === null && !isDisabled) {
  3203. var _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner, _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  3204. let currentOwner = (_React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = react_default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === void 0 || (_React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner = _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner) === null || _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner === void 0 ? void 0 : _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner.current;
  3205. if (currentOwner) {
  3206. let prevComponentValue = $b5e257d569688ac6$var$componentIds.get(currentOwner);
  3207. prevComponentValue == null ? $b5e257d569688ac6$var$componentIds.set(currentOwner, {
  3208. id: ctx.current,
  3209. state: currentOwner.memoizedState
  3210. }) : currentOwner.memoizedState !== prevComponentValue.state && (ctx.current = prevComponentValue.id, $b5e257d569688ac6$var$componentIds.delete(currentOwner));
  3211. }
  3212. ref.current = ++ctx.current;
  3213. }
  3214. return ref.current;
  3215. }
  3216. function $b5e257d569688ac6$var$useLegacySSRSafeId(defaultId) {
  3217. let ctx = useContext($b5e257d569688ac6$var$SSRContext), counter = $b5e257d569688ac6$var$useCounter(!!defaultId), prefix = `react-aria${ctx.prefix}`;
  3218. return defaultId || `${prefix}-${counter}`;
  3219. }
  3220. function $b5e257d569688ac6$var$useModernSSRSafeId(defaultId) {
  3221. let id = react_default.useId(), [didSSR] = useState($b5e257d569688ac6$export$535bd6ca7f90a273()), prefix = didSSR ? "react-aria" : `react-aria${$b5e257d569688ac6$var$defaultContext.prefix}`;
  3222. return defaultId || `${prefix}-${id}`;
  3223. }
  3224. var $b5e257d569688ac6$export$619500959fc48b26 = typeof react_default.useId == "function" ? $b5e257d569688ac6$var$useModernSSRSafeId : $b5e257d569688ac6$var$useLegacySSRSafeId;
  3225. function $b5e257d569688ac6$var$getSnapshot() {
  3226. return !1;
  3227. }
  3228. function $b5e257d569688ac6$var$getServerSnapshot() {
  3229. return !0;
  3230. }
  3231. function $b5e257d569688ac6$var$subscribe(onStoreChange) {
  3232. return () => {
  3233. };
  3234. }
  3235. function $b5e257d569688ac6$export$535bd6ca7f90a273() {
  3236. return typeof react_default.useSyncExternalStore == "function" ? react_default.useSyncExternalStore($b5e257d569688ac6$var$subscribe, $b5e257d569688ac6$var$getSnapshot, $b5e257d569688ac6$var$getServerSnapshot) : useContext($b5e257d569688ac6$var$IsSSRContext);
  3237. }
  3238. // ../../node_modules/@react-aria/utils/dist/useId.mjs
  3239. var $bdb11010cef70236$var$canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), $bdb11010cef70236$export$d41a04c74483c6ef = /* @__PURE__ */ new Map(), $bdb11010cef70236$var$registry;
  3240. typeof FinalizationRegistry < "u" && ($bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue) => {
  3241. $bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue);
  3242. }));
  3243. function $bdb11010cef70236$export$f680877a34711e37(defaultId) {
  3244. let [value, setValue] = useState(defaultId), nextId = useRef(null), res = $b5e257d569688ac6$export$619500959fc48b26(value), cleanupRef = useRef(null);
  3245. if ($bdb11010cef70236$var$registry && $bdb11010cef70236$var$registry.register(cleanupRef, res), $bdb11010cef70236$var$canUseDOM) {
  3246. let cacheIdRef = $bdb11010cef70236$export$d41a04c74483c6ef.get(res);
  3247. cacheIdRef && !cacheIdRef.includes(nextId) ? cacheIdRef.push(nextId) : $bdb11010cef70236$export$d41a04c74483c6ef.set(res, [
  3248. nextId
  3249. ]);
  3250. }
  3251. return $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3252. let r4 = res;
  3253. return () => {
  3254. $bdb11010cef70236$var$registry && $bdb11010cef70236$var$registry.unregister(cleanupRef), $bdb11010cef70236$export$d41a04c74483c6ef.delete(r4);
  3255. };
  3256. }, [
  3257. res
  3258. ]), useEffect(() => {
  3259. let newId = nextId.current;
  3260. return newId && setValue(newId), () => {
  3261. newId && (nextId.current = null);
  3262. };
  3263. }), res;
  3264. }
  3265. function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
  3266. if (idA === idB) return idA;
  3267. let setIdsA = $bdb11010cef70236$export$d41a04c74483c6ef.get(idA);
  3268. if (setIdsA)
  3269. return setIdsA.forEach((ref) => ref.current = idB), idB;
  3270. let setIdsB = $bdb11010cef70236$export$d41a04c74483c6ef.get(idB);
  3271. return setIdsB ? (setIdsB.forEach((ref) => ref.current = idA), idA) : idB;
  3272. }
  3273. // ../../node_modules/@react-aria/utils/dist/chain.mjs
  3274. function $ff5963eb1fccf552$export$e08e3b67e392101e(...callbacks) {
  3275. return (...args) => {
  3276. for (let callback of callbacks) typeof callback == "function" && callback(...args);
  3277. };
  3278. }
  3279. // ../../node_modules/@react-aria/utils/dist/domHelpers.mjs
  3280. var $431fbd86ca7dc216$export$b204af158042fbac = (el) => {
  3281. var _el_ownerDocument;
  3282. return (_el_ownerDocument = el?.ownerDocument) !== null && _el_ownerDocument !== void 0 ? _el_ownerDocument : document;
  3283. }, $431fbd86ca7dc216$export$f21a1ffae260145a = (el) => el && "window" in el && el.window === el ? el : $431fbd86ca7dc216$export$b204af158042fbac(el).defaultView || window;
  3284. function $431fbd86ca7dc216$var$isNode(value) {
  3285. return value !== null && typeof value == "object" && "nodeType" in value && typeof value.nodeType == "number";
  3286. }
  3287. function $431fbd86ca7dc216$export$af51f0f06c0f328a(node) {
  3288. return $431fbd86ca7dc216$var$isNode(node) && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in node;
  3289. }
  3290. // ../../node_modules/@react-stately/flags/dist/import.mjs
  3291. var $f4e2df6bd15f8569$var$_shadowDOM = !1;
  3292. function $f4e2df6bd15f8569$export$98658e8c59125e6a() {
  3293. return $f4e2df6bd15f8569$var$_shadowDOM;
  3294. }
  3295. // ../../node_modules/@react-aria/utils/dist/DOMFunctions.mjs
  3296. function $d4ee10de306f2510$export$4282f70798064fe0(node, otherNode) {
  3297. if (!$f4e2df6bd15f8569$export$98658e8c59125e6a()) return otherNode && node ? node.contains(otherNode) : !1;
  3298. if (!node || !otherNode) return !1;
  3299. let currentNode = otherNode;
  3300. for (; currentNode !== null; ) {
  3301. if (currentNode === node) return !0;
  3302. currentNode.tagName === "SLOT" && currentNode.assignedSlot ? currentNode = currentNode.assignedSlot.parentNode : $431fbd86ca7dc216$export$af51f0f06c0f328a(currentNode) ? currentNode = currentNode.host : currentNode = currentNode.parentNode;
  3303. }
  3304. return !1;
  3305. }
  3306. var $d4ee10de306f2510$export$cd4e5573fbe2b576 = (doc = document) => {
  3307. var _activeElement_shadowRoot;
  3308. if (!$f4e2df6bd15f8569$export$98658e8c59125e6a()) return doc.activeElement;
  3309. let activeElement = doc.activeElement;
  3310. for (; activeElement && "shadowRoot" in activeElement && (!((_activeElement_shadowRoot = activeElement.shadowRoot) === null || _activeElement_shadowRoot === void 0) && _activeElement_shadowRoot.activeElement); ) activeElement = activeElement.shadowRoot.activeElement;
  3311. return activeElement;
  3312. };
  3313. function $d4ee10de306f2510$export$e58f029f0fbfdb29(event) {
  3314. return $f4e2df6bd15f8569$export$98658e8c59125e6a() && event.target.shadowRoot && event.composedPath ? event.composedPath()[0] : event.target;
  3315. }
  3316. // ../../node_modules/clsx/dist/clsx.mjs
  3317. function r2(e2) {
  3318. var t2, f2, n3 = "";
  3319. if (typeof e2 == "string" || typeof e2 == "number") n3 += e2;
  3320. else if (typeof e2 == "object") if (Array.isArray(e2)) {
  3321. var o3 = e2.length;
  3322. for (t2 = 0; t2 < o3; t2++) e2[t2] && (f2 = r2(e2[t2])) && (n3 && (n3 += " "), n3 += f2);
  3323. } else for (f2 in e2) e2[f2] && (n3 && (n3 += " "), n3 += f2);
  3324. return n3;
  3325. }
  3326. function clsx() {
  3327. for (var e2, t2, f2 = 0, n3 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t2 = r2(e2)) && (n3 && (n3 += " "), n3 += t2);
  3328. return n3;
  3329. }
  3330. var clsx_default = clsx;
  3331. // ../../node_modules/@react-aria/utils/dist/mergeProps.mjs
  3332. function $3ef42575df84b30b$export$9d1611c77c2fe928(...args) {
  3333. let result = {
  3334. ...args[0]
  3335. };
  3336. for (let i2 = 1; i2 < args.length; i2++) {
  3337. let props = args[i2];
  3338. for (let key in props) {
  3339. let a2 = result[key], b2 = props[key];
  3340. typeof a2 == "function" && typeof b2 == "function" && // This is a lot faster than a regex.
  3341. key[0] === "o" && key[1] === "n" && key.charCodeAt(2) >= /* 'A' */
  3342. 65 && key.charCodeAt(2) <= /* 'Z' */
  3343. 90 ? result[key] = $ff5963eb1fccf552$export$e08e3b67e392101e(a2, b2) : (key === "className" || key === "UNSAFE_className") && typeof a2 == "string" && typeof b2 == "string" ? result[key] = clsx_default(a2, b2) : key === "id" && a2 && b2 ? result.id = $bdb11010cef70236$export$cd8c9cb68f842629(a2, b2) : result[key] = b2 !== void 0 ? b2 : a2;
  3344. }
  3345. }
  3346. return result;
  3347. }
  3348. // ../../node_modules/@react-aria/utils/dist/mergeRefs.mjs
  3349. function $5dc95899b306f630$export$c9058316764c140e(...refs) {
  3350. return refs.length === 1 && refs[0] ? refs[0] : (value) => {
  3351. let hasCleanup = !1, cleanups = refs.map((ref) => {
  3352. let cleanup = $5dc95899b306f630$var$setRef(ref, value);
  3353. return hasCleanup || (hasCleanup = typeof cleanup == "function"), cleanup;
  3354. });
  3355. if (hasCleanup) return () => {
  3356. cleanups.forEach((cleanup, i2) => {
  3357. typeof cleanup == "function" ? cleanup() : $5dc95899b306f630$var$setRef(refs[i2], null);
  3358. });
  3359. };
  3360. };
  3361. }
  3362. function $5dc95899b306f630$var$setRef(ref, value) {
  3363. if (typeof ref == "function") return ref(value);
  3364. ref != null && (ref.current = value);
  3365. }
  3366. // ../../node_modules/@react-aria/utils/dist/filterDOMProps.mjs
  3367. var $65484d02dcb7eb3e$var$DOMPropNames = /* @__PURE__ */ new Set([
  3368. "id"
  3369. ]), $65484d02dcb7eb3e$var$labelablePropNames = /* @__PURE__ */ new Set([
  3370. "aria-label",
  3371. "aria-labelledby",
  3372. "aria-describedby",
  3373. "aria-details"
  3374. ]), $65484d02dcb7eb3e$var$linkPropNames = /* @__PURE__ */ new Set([
  3375. "href",
  3376. "hrefLang",
  3377. "target",
  3378. "rel",
  3379. "download",
  3380. "ping",
  3381. "referrerPolicy"
  3382. ]), $65484d02dcb7eb3e$var$globalAttrs = /* @__PURE__ */ new Set([
  3383. "dir",
  3384. "lang",
  3385. "hidden",
  3386. "inert",
  3387. "translate"
  3388. ]), $65484d02dcb7eb3e$var$globalEvents = /* @__PURE__ */ new Set([
  3389. "onClick",
  3390. "onAuxClick",
  3391. "onContextMenu",
  3392. "onDoubleClick",
  3393. "onMouseDown",
  3394. "onMouseEnter",
  3395. "onMouseLeave",
  3396. "onMouseMove",
  3397. "onMouseOut",
  3398. "onMouseOver",
  3399. "onMouseUp",
  3400. "onTouchCancel",
  3401. "onTouchEnd",
  3402. "onTouchMove",
  3403. "onTouchStart",
  3404. "onPointerDown",
  3405. "onPointerMove",
  3406. "onPointerUp",
  3407. "onPointerCancel",
  3408. "onPointerEnter",
  3409. "onPointerLeave",
  3410. "onPointerOver",
  3411. "onPointerOut",
  3412. "onGotPointerCapture",
  3413. "onLostPointerCapture",
  3414. "onScroll",
  3415. "onWheel",
  3416. "onAnimationStart",
  3417. "onAnimationEnd",
  3418. "onAnimationIteration",
  3419. "onTransitionCancel",
  3420. "onTransitionEnd",
  3421. "onTransitionRun",
  3422. "onTransitionStart"
  3423. ]), $65484d02dcb7eb3e$var$propRe = /^(data-.*)$/;
  3424. function $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, opts = {}) {
  3425. let { labelable, isLink, global: global2, events: events2 = global2, propNames } = opts, filteredProps = {};
  3426. for (let prop in props) Object.prototype.hasOwnProperty.call(props, prop) && ($65484d02dcb7eb3e$var$DOMPropNames.has(prop) || labelable && $65484d02dcb7eb3e$var$labelablePropNames.has(prop) || isLink && $65484d02dcb7eb3e$var$linkPropNames.has(prop) || global2 && $65484d02dcb7eb3e$var$globalAttrs.has(prop) || events2 && ($65484d02dcb7eb3e$var$globalEvents.has(prop) || prop.endsWith("Capture") && $65484d02dcb7eb3e$var$globalEvents.has(prop.slice(0, -7))) || propNames?.has(prop) || $65484d02dcb7eb3e$var$propRe.test(prop)) && (filteredProps[prop] = props[prop]);
  3427. return filteredProps;
  3428. }
  3429. // ../../node_modules/@react-aria/utils/dist/focusWithoutScrolling.mjs
  3430. function $7215afc6de606d6b$export$de79e2c695e052f3(element) {
  3431. if ($7215afc6de606d6b$var$supportsPreventScroll()) element.focus({
  3432. preventScroll: !0
  3433. });
  3434. else {
  3435. let scrollableElements = $7215afc6de606d6b$var$getScrollableElements(element);
  3436. element.focus(), $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements);
  3437. }
  3438. }
  3439. var $7215afc6de606d6b$var$supportsPreventScrollCached = null;
  3440. function $7215afc6de606d6b$var$supportsPreventScroll() {
  3441. if ($7215afc6de606d6b$var$supportsPreventScrollCached == null) {
  3442. $7215afc6de606d6b$var$supportsPreventScrollCached = !1;
  3443. try {
  3444. document.createElement("div").focus({
  3445. get preventScroll() {
  3446. return $7215afc6de606d6b$var$supportsPreventScrollCached = !0, !0;
  3447. }
  3448. });
  3449. } catch {
  3450. }
  3451. }
  3452. return $7215afc6de606d6b$var$supportsPreventScrollCached;
  3453. }
  3454. function $7215afc6de606d6b$var$getScrollableElements(element) {
  3455. let parent = element.parentNode, scrollableElements = [], rootScrollingElement = document.scrollingElement || document.documentElement;
  3456. for (; parent instanceof HTMLElement && parent !== rootScrollingElement; )
  3457. (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) && scrollableElements.push({
  3458. element: parent,
  3459. scrollTop: parent.scrollTop,
  3460. scrollLeft: parent.scrollLeft
  3461. }), parent = parent.parentNode;
  3462. return rootScrollingElement instanceof HTMLElement && scrollableElements.push({
  3463. element: rootScrollingElement,
  3464. scrollTop: rootScrollingElement.scrollTop,
  3465. scrollLeft: rootScrollingElement.scrollLeft
  3466. }), scrollableElements;
  3467. }
  3468. function $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements) {
  3469. for (let { element, scrollTop, scrollLeft } of scrollableElements)
  3470. element.scrollTop = scrollTop, element.scrollLeft = scrollLeft;
  3471. }
  3472. // ../../node_modules/@react-aria/utils/dist/platform.mjs
  3473. function $c87311424ea30a05$var$testUserAgent(re) {
  3474. var _window_navigator_userAgentData;
  3475. if (typeof window > "u" || window.navigator == null) return !1;
  3476. let brands = (_window_navigator_userAgentData = window.navigator.userAgentData) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands;
  3477. return Array.isArray(brands) && brands.some((brand) => re.test(brand.brand)) || re.test(window.navigator.userAgent);
  3478. }
  3479. function $c87311424ea30a05$var$testPlatform(re) {
  3480. var _window_navigator_userAgentData;
  3481. return typeof window < "u" && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator.userAgentData) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : !1;
  3482. }
  3483. function $c87311424ea30a05$var$cached(fn) {
  3484. let res = null;
  3485. return () => (res == null && (res = fn()), res);
  3486. }
  3487. var $c87311424ea30a05$export$9ac100e40613ea10 = $c87311424ea30a05$var$cached(function() {
  3488. return $c87311424ea30a05$var$testPlatform(/^Mac/i);
  3489. }), $c87311424ea30a05$export$186c6964ca17d99 = $c87311424ea30a05$var$cached(function() {
  3490. return $c87311424ea30a05$var$testPlatform(/^iPhone/i);
  3491. }), $c87311424ea30a05$export$7bef049ce92e4224 = $c87311424ea30a05$var$cached(function() {
  3492. return $c87311424ea30a05$var$testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
  3493. $c87311424ea30a05$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
  3494. }), $c87311424ea30a05$export$fedb369cb70207f1 = $c87311424ea30a05$var$cached(function() {
  3495. return $c87311424ea30a05$export$186c6964ca17d99() || $c87311424ea30a05$export$7bef049ce92e4224();
  3496. }), $c87311424ea30a05$export$e1865c3bedcd822b = $c87311424ea30a05$var$cached(function() {
  3497. return $c87311424ea30a05$export$9ac100e40613ea10() || $c87311424ea30a05$export$fedb369cb70207f1();
  3498. }), $c87311424ea30a05$export$78551043582a6a98 = $c87311424ea30a05$var$cached(function() {
  3499. return $c87311424ea30a05$var$testUserAgent(/AppleWebKit/i) && !$c87311424ea30a05$export$6446a186d09e379e();
  3500. }), $c87311424ea30a05$export$6446a186d09e379e = $c87311424ea30a05$var$cached(function() {
  3501. return $c87311424ea30a05$var$testUserAgent(/Chrome/i);
  3502. }), $c87311424ea30a05$export$a11b0059900ceec8 = $c87311424ea30a05$var$cached(function() {
  3503. return $c87311424ea30a05$var$testUserAgent(/Android/i);
  3504. }), $c87311424ea30a05$export$b7d78993b74f766d = $c87311424ea30a05$var$cached(function() {
  3505. return $c87311424ea30a05$var$testUserAgent(/Firefox/i);
  3506. });
  3507. // ../../node_modules/@react-aria/utils/dist/openLink.mjs
  3508. init_react();
  3509. var $ea8dcbcb9ea1b556$var$RouterContext = createContext({
  3510. isNative: !0,
  3511. open: $ea8dcbcb9ea1b556$var$openSyntheticLink,
  3512. useHref: (href) => href
  3513. });
  3514. function $ea8dcbcb9ea1b556$export$95185d699e05d4d7(target, modifiers2, setOpening = !0) {
  3515. var _window_event_type, _window_event;
  3516. let { metaKey, ctrlKey, altKey, shiftKey } = modifiers2;
  3517. $c87311424ea30a05$export$b7d78993b74f766d() && (!((_window_event = window.event) === null || _window_event === void 0 || (_window_event_type = _window_event.type) === null || _window_event_type === void 0) && _window_event_type.startsWith("key")) && target.target === "_blank" && ($c87311424ea30a05$export$9ac100e40613ea10() ? metaKey = !0 : ctrlKey = !0);
  3518. let event = $c87311424ea30a05$export$78551043582a6a98() && $c87311424ea30a05$export$9ac100e40613ea10() && !$c87311424ea30a05$export$7bef049ce92e4224() ? new KeyboardEvent("keydown", {
  3519. keyIdentifier: "Enter",
  3520. metaKey,
  3521. ctrlKey,
  3522. altKey,
  3523. shiftKey
  3524. }) : new MouseEvent("click", {
  3525. metaKey,
  3526. ctrlKey,
  3527. altKey,
  3528. shiftKey,
  3529. detail: 1,
  3530. bubbles: !0,
  3531. cancelable: !0
  3532. });
  3533. $ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = setOpening, $7215afc6de606d6b$export$de79e2c695e052f3(target), target.dispatchEvent(event), $ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = !1;
  3534. }
  3535. $ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = !1;
  3536. function $ea8dcbcb9ea1b556$var$getSyntheticLink(target, open) {
  3537. if (target instanceof HTMLAnchorElement) open(target);
  3538. else if (target.hasAttribute("data-href")) {
  3539. let link = document.createElement("a");
  3540. link.href = target.getAttribute("data-href"), target.hasAttribute("data-target") && (link.target = target.getAttribute("data-target")), target.hasAttribute("data-rel") && (link.rel = target.getAttribute("data-rel")), target.hasAttribute("data-download") && (link.download = target.getAttribute("data-download")), target.hasAttribute("data-ping") && (link.ping = target.getAttribute("data-ping")), target.hasAttribute("data-referrer-policy") && (link.referrerPolicy = target.getAttribute("data-referrer-policy")), target.appendChild(link), open(link), target.removeChild(link);
  3541. }
  3542. }
  3543. function $ea8dcbcb9ea1b556$var$openSyntheticLink(target, modifiers2) {
  3544. $ea8dcbcb9ea1b556$var$getSyntheticLink(target, (link) => $ea8dcbcb9ea1b556$export$95185d699e05d4d7(link, modifiers2));
  3545. }
  3546. // ../../node_modules/@react-aria/utils/dist/runAfterTransition.mjs
  3547. var $bbed8b41f857bcc0$var$transitionsByElement = /* @__PURE__ */ new Map(), $bbed8b41f857bcc0$var$transitionCallbacks = /* @__PURE__ */ new Set();
  3548. function $bbed8b41f857bcc0$var$setupGlobalEvents() {
  3549. if (typeof window > "u") return;
  3550. function isTransitionEvent(event) {
  3551. return "propertyName" in event;
  3552. }
  3553. let onTransitionStart = (e2) => {
  3554. if (!isTransitionEvent(e2) || !e2.target) return;
  3555. let transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e2.target);
  3556. transitions || (transitions = /* @__PURE__ */ new Set(), $bbed8b41f857bcc0$var$transitionsByElement.set(e2.target, transitions), e2.target.addEventListener("transitioncancel", onTransitionEnd, {
  3557. once: !0
  3558. })), transitions.add(e2.propertyName);
  3559. }, onTransitionEnd = (e2) => {
  3560. if (!isTransitionEvent(e2) || !e2.target) return;
  3561. let properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e2.target);
  3562. if (properties && (properties.delete(e2.propertyName), properties.size === 0 && (e2.target.removeEventListener("transitioncancel", onTransitionEnd), $bbed8b41f857bcc0$var$transitionsByElement.delete(e2.target)), $bbed8b41f857bcc0$var$transitionsByElement.size === 0)) {
  3563. for (let cb of $bbed8b41f857bcc0$var$transitionCallbacks) cb();
  3564. $bbed8b41f857bcc0$var$transitionCallbacks.clear();
  3565. }
  3566. };
  3567. document.body.addEventListener("transitionrun", onTransitionStart), document.body.addEventListener("transitionend", onTransitionEnd);
  3568. }
  3569. typeof document < "u" && (document.readyState !== "loading" ? $bbed8b41f857bcc0$var$setupGlobalEvents() : document.addEventListener("DOMContentLoaded", $bbed8b41f857bcc0$var$setupGlobalEvents));
  3570. function $bbed8b41f857bcc0$var$cleanupDetachedElements() {
  3571. for (let [eventTarget] of $bbed8b41f857bcc0$var$transitionsByElement)
  3572. "isConnected" in eventTarget && !eventTarget.isConnected && $bbed8b41f857bcc0$var$transitionsByElement.delete(eventTarget);
  3573. }
  3574. function $bbed8b41f857bcc0$export$24490316f764c430(fn) {
  3575. requestAnimationFrame(() => {
  3576. $bbed8b41f857bcc0$var$cleanupDetachedElements(), $bbed8b41f857bcc0$var$transitionsByElement.size === 0 ? fn() : $bbed8b41f857bcc0$var$transitionCallbacks.add(fn);
  3577. });
  3578. }
  3579. // ../../node_modules/@react-aria/utils/dist/useDrag1D.mjs
  3580. init_react();
  3581. // ../../node_modules/@react-aria/utils/dist/useGlobalListeners.mjs
  3582. init_react();
  3583. function $03deb23ff14920c4$export$4eaf04e54aa8eed6() {
  3584. let globalListeners = useRef(/* @__PURE__ */ new Map()), addGlobalListener = useCallback((eventTarget, type, listener, options2) => {
  3585. let fn = options2?.once ? (...args) => {
  3586. globalListeners.current.delete(listener), listener(...args);
  3587. } : listener;
  3588. globalListeners.current.set(listener, {
  3589. type,
  3590. eventTarget,
  3591. fn,
  3592. options: options2
  3593. }), eventTarget.addEventListener(type, fn, options2);
  3594. }, []), removeGlobalListener = useCallback((eventTarget, type, listener, options2) => {
  3595. var _globalListeners_current_get;
  3596. let fn = ((_globalListeners_current_get = globalListeners.current.get(listener)) === null || _globalListeners_current_get === void 0 ? void 0 : _globalListeners_current_get.fn) || listener;
  3597. eventTarget.removeEventListener(type, fn, options2), globalListeners.current.delete(listener);
  3598. }, []), removeAllGlobalListeners = useCallback(() => {
  3599. globalListeners.current.forEach((value, key) => {
  3600. removeGlobalListener(value.eventTarget, value.type, key, value.options);
  3601. });
  3602. }, [
  3603. removeGlobalListener
  3604. ]);
  3605. return useEffect(() => removeAllGlobalListeners, [
  3606. removeAllGlobalListeners
  3607. ]), {
  3608. addGlobalListener,
  3609. removeGlobalListener,
  3610. removeAllGlobalListeners
  3611. };
  3612. }
  3613. // ../../node_modules/@react-aria/utils/dist/useObjectRef.mjs
  3614. init_react();
  3615. function $df56164dff5785e2$export$4338b53315abf666(ref) {
  3616. let objRef = useRef(null), cleanupRef = useRef(void 0), refEffect = useCallback((instance) => {
  3617. if (typeof ref == "function") {
  3618. let refCallback = ref, refCleanup = refCallback(instance);
  3619. return () => {
  3620. typeof refCleanup == "function" ? refCleanup() : refCallback(null);
  3621. };
  3622. } else if (ref)
  3623. return ref.current = instance, () => {
  3624. ref.current = null;
  3625. };
  3626. }, [
  3627. ref
  3628. ]);
  3629. return useMemo(() => ({
  3630. get current() {
  3631. return objRef.current;
  3632. },
  3633. set current(value) {
  3634. objRef.current = value, cleanupRef.current && (cleanupRef.current(), cleanupRef.current = void 0), value != null && (cleanupRef.current = refEffect(value));
  3635. }
  3636. }), [
  3637. refEffect
  3638. ]);
  3639. }
  3640. // ../../node_modules/@react-aria/utils/dist/useEffectEvent.mjs
  3641. init_react();
  3642. var $8ae05eaa5c114e9c$var$_React_useInsertionEffect, $8ae05eaa5c114e9c$var$useEarlyEffect = ($8ae05eaa5c114e9c$var$_React_useInsertionEffect = react_default.useInsertionEffect) !== null && $8ae05eaa5c114e9c$var$_React_useInsertionEffect !== void 0 ? $8ae05eaa5c114e9c$var$_React_useInsertionEffect : $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c;
  3643. function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
  3644. let ref = useRef(null);
  3645. return $8ae05eaa5c114e9c$var$useEarlyEffect(() => {
  3646. ref.current = fn;
  3647. }, [
  3648. fn
  3649. ]), useCallback((...args) => {
  3650. let f2 = ref.current;
  3651. return f2?.(...args);
  3652. }, []);
  3653. }
  3654. // ../../node_modules/@react-aria/utils/dist/useUpdateEffect.mjs
  3655. init_react();
  3656. // ../../node_modules/@react-aria/utils/dist/useUpdateLayoutEffect.mjs
  3657. init_react();
  3658. // ../../node_modules/@react-aria/utils/dist/useResizeObserver.mjs
  3659. init_react();
  3660. function $9daab02d461809db$var$hasResizeObserver() {
  3661. return typeof window.ResizeObserver < "u";
  3662. }
  3663. function $9daab02d461809db$export$683480f191c0e3ea(options2) {
  3664. let { ref, box, onResize } = options2, onResizeEvent = $8ae05eaa5c114e9c$export$7f54fc3180508a52(onResize);
  3665. useEffect(() => {
  3666. let element = ref?.current;
  3667. if (element)
  3668. if ($9daab02d461809db$var$hasResizeObserver()) {
  3669. let resizeObserverInstance = new window.ResizeObserver((entries) => {
  3670. entries.length && onResizeEvent();
  3671. });
  3672. return resizeObserverInstance.observe(element, {
  3673. box
  3674. }), () => {
  3675. element && resizeObserverInstance.unobserve(element);
  3676. };
  3677. } else
  3678. return window.addEventListener("resize", onResizeEvent, !1), () => {
  3679. window.removeEventListener("resize", onResizeEvent, !1);
  3680. };
  3681. }, [
  3682. ref,
  3683. box
  3684. ]);
  3685. }
  3686. // ../../node_modules/@react-aria/utils/dist/useSyncRef.mjs
  3687. function $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref) {
  3688. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3689. if (context && context.ref && ref)
  3690. return context.ref.current = ref.current, () => {
  3691. context.ref && (context.ref.current = null);
  3692. };
  3693. });
  3694. }
  3695. // ../../node_modules/@react-aria/utils/dist/useViewportSize.mjs
  3696. init_react();
  3697. var $5df64b3807dc15ee$var$visualViewport = typeof document < "u" && window.visualViewport;
  3698. // ../../node_modules/@react-aria/utils/dist/useDescription.mjs
  3699. init_react();
  3700. // ../../node_modules/@react-aria/utils/dist/useEvent.mjs
  3701. init_react();
  3702. // ../../node_modules/@react-aria/utils/dist/isVirtualEvent.mjs
  3703. function $6a7db85432448f7f$export$60278871457622de(event) {
  3704. return event.pointerType === "" && event.isTrusted ? !0 : $c87311424ea30a05$export$a11b0059900ceec8() && event.pointerType ? event.type === "click" && event.buttons === 1 : event.detail === 0 && !event.pointerType;
  3705. }
  3706. function $6a7db85432448f7f$export$29bf1b5f2c56cf63(event) {
  3707. return !$c87311424ea30a05$export$a11b0059900ceec8() && event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse";
  3708. }
  3709. // ../../node_modules/@react-aria/utils/dist/useDeepMemo.mjs
  3710. init_react();
  3711. // ../../node_modules/@react-aria/utils/dist/useFormReset.mjs
  3712. init_react();
  3713. // ../../node_modules/@react-aria/utils/dist/useLoadMore.mjs
  3714. init_react();
  3715. // ../../node_modules/@react-aria/utils/dist/useLoadMoreSentinel.mjs
  3716. init_react();
  3717. // ../../node_modules/@react-aria/utils/dist/inertValue.mjs
  3718. init_react();
  3719. // global-externals:react-dom
  3720. var react_dom_default = __REACT_DOM__, { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED2, createPortal, createRoot: createRoot2, findDOMNode, flushSync, hydrate, hydrateRoot: hydrateRoot2, render, unmountComponentAtNode, unstable_batchedUpdates, unstable_renderSubtreeIntoContainer, version: version2 } = __REACT_DOM__;
  3721. // ../../node_modules/@react-aria/utils/dist/animation.mjs
  3722. init_react();
  3723. function $d3f049242431219c$export$6d3443f2c48bfc20(ref, isReady = !0) {
  3724. let [isEntering, setEntering] = useState(!0), isAnimationReady = isEntering && isReady;
  3725. return $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3726. if (isAnimationReady && ref.current && "getAnimations" in ref.current)
  3727. for (let animation of ref.current.getAnimations()) animation instanceof CSSTransition && animation.cancel();
  3728. }, [
  3729. ref,
  3730. isAnimationReady
  3731. ]), $d3f049242431219c$var$useAnimation(ref, isAnimationReady, useCallback(() => setEntering(!1), [])), isAnimationReady;
  3732. }
  3733. function $d3f049242431219c$export$45fda7c47f93fd48(ref, isOpen) {
  3734. let [exitState, setExitState] = useState(isOpen ? "open" : "closed");
  3735. switch (exitState) {
  3736. case "open":
  3737. isOpen || setExitState("exiting");
  3738. break;
  3739. case "closed":
  3740. case "exiting":
  3741. isOpen && setExitState("open");
  3742. break;
  3743. }
  3744. let isExiting = exitState === "exiting";
  3745. return $d3f049242431219c$var$useAnimation(ref, isExiting, useCallback(() => {
  3746. setExitState((state) => state === "exiting" ? "closed" : state);
  3747. }, [])), isExiting;
  3748. }
  3749. function $d3f049242431219c$var$useAnimation(ref, isActive, onEnd) {
  3750. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3751. if (isActive && ref.current) {
  3752. if (!("getAnimations" in ref.current)) {
  3753. onEnd();
  3754. return;
  3755. }
  3756. let animations = ref.current.getAnimations();
  3757. if (animations.length === 0) {
  3758. onEnd();
  3759. return;
  3760. }
  3761. let canceled = !1;
  3762. return Promise.all(animations.map((a2) => a2.finished)).then(() => {
  3763. canceled || flushSync(() => {
  3764. onEnd();
  3765. });
  3766. }).catch(() => {
  3767. }), () => {
  3768. canceled = !0;
  3769. };
  3770. }
  3771. }, [
  3772. ref,
  3773. isActive,
  3774. onEnd
  3775. ]);
  3776. }
  3777. // ../../node_modules/@react-aria/utils/dist/isElementVisible.mjs
  3778. var $7d2416ea0959daaa$var$supportsCheckVisibility = typeof Element < "u" && "checkVisibility" in Element.prototype;
  3779. function $7d2416ea0959daaa$var$isStyleVisible(element) {
  3780. let windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
  3781. if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return !1;
  3782. let { display, visibility } = element.style, isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
  3783. if (isVisible) {
  3784. let { getComputedStyle: getComputedStyle2 } = element.ownerDocument.defaultView, { display: computedDisplay, visibility: computedVisibility } = getComputedStyle2(element);
  3785. isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
  3786. }
  3787. return isVisible;
  3788. }
  3789. function $7d2416ea0959daaa$var$isAttributeVisible(element, childElement) {
  3790. return !element.hasAttribute("hidden") && // Ignore HiddenSelect when tree walking.
  3791. !element.hasAttribute("data-react-aria-prevent-focus") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : !0);
  3792. }
  3793. function $7d2416ea0959daaa$export$e989c0fffaa6b27a(element, childElement) {
  3794. return $7d2416ea0959daaa$var$supportsCheckVisibility ? element.checkVisibility({
  3795. visibilityProperty: !0
  3796. }) && !element.closest("[data-react-aria-prevent-focus]") : element.nodeName !== "#comment" && $7d2416ea0959daaa$var$isStyleVisible(element) && $7d2416ea0959daaa$var$isAttributeVisible(element, childElement) && (!element.parentElement || $7d2416ea0959daaa$export$e989c0fffaa6b27a(element.parentElement, element));
  3797. }
  3798. // ../../node_modules/@react-aria/utils/dist/isFocusable.mjs
  3799. var $b4b717babfbb907b$var$focusableElements = [
  3800. "input:not([disabled]):not([type=hidden])",
  3801. "select:not([disabled])",
  3802. "textarea:not([disabled])",
  3803. "button:not([disabled])",
  3804. "a[href]",
  3805. "area[href]",
  3806. "summary",
  3807. "iframe",
  3808. "object",
  3809. "embed",
  3810. "audio[controls]",
  3811. "video[controls]",
  3812. '[contenteditable]:not([contenteditable^="false"])',
  3813. "permission"
  3814. ], $b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
  3815. $b4b717babfbb907b$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
  3816. var $b4b717babfbb907b$var$TABBABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
  3817. function $b4b717babfbb907b$export$4c063cf1350e6fed(element) {
  3818. return element.matches($b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR) && $7d2416ea0959daaa$export$e989c0fffaa6b27a(element) && !$b4b717babfbb907b$var$isInert(element);
  3819. }
  3820. function $b4b717babfbb907b$var$isInert(element) {
  3821. let node = element;
  3822. for (; node != null; ) {
  3823. if (node instanceof node.ownerDocument.defaultView.HTMLElement && node.inert) return !0;
  3824. node = node.parentElement;
  3825. }
  3826. return !1;
  3827. }
  3828. // ../../node_modules/@react-stately/utils/dist/useControlledState.mjs
  3829. init_react();
  3830. var $458b0a5536c1a7cf$var$_React_useInsertionEffect, $458b0a5536c1a7cf$var$useEarlyEffect = typeof document < "u" ? ($458b0a5536c1a7cf$var$_React_useInsertionEffect = react_default.useInsertionEffect) !== null && $458b0a5536c1a7cf$var$_React_useInsertionEffect !== void 0 ? $458b0a5536c1a7cf$var$_React_useInsertionEffect : react_default.useLayoutEffect : () => {
  3831. };
  3832. function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
  3833. let [stateValue, setStateValue] = useState(value || defaultValue), valueRef = useRef(stateValue), isControlledRef = useRef(value !== void 0), isControlled = value !== void 0;
  3834. useEffect(() => {
  3835. let wasControlled = isControlledRef.current;
  3836. isControlledRef.current = isControlled;
  3837. }, [
  3838. isControlled
  3839. ]);
  3840. let currentValue = isControlled ? value : stateValue;
  3841. $458b0a5536c1a7cf$var$useEarlyEffect(() => {
  3842. valueRef.current = currentValue;
  3843. });
  3844. let [, forceUpdate] = useReducer(() => ({}), {}), setValue = useCallback((value2, ...args) => {
  3845. let newValue = typeof value2 == "function" ? value2(valueRef.current) : value2;
  3846. Object.is(valueRef.current, newValue) || (valueRef.current = newValue, setStateValue(newValue), forceUpdate(), onChange?.(newValue, ...args));
  3847. }, [
  3848. onChange
  3849. ]);
  3850. return [
  3851. currentValue,
  3852. setValue
  3853. ];
  3854. }
  3855. // ../../node_modules/@react-stately/utils/dist/number.mjs
  3856. function $9446cca9a3875146$export$7d15b64cf5a3a4c4(value, min = -1 / 0, max = 1 / 0) {
  3857. return Math.min(Math.max(value, min), max);
  3858. }
  3859. // ../../node_modules/@react-aria/landmark/dist/useLandmark.mjs
  3860. init_react();
  3861. var import_shim = __toESM(require_shim(), 1), $a86207c5d7f7e1fb$var$LANDMARK_API_VERSION = 1, $a86207c5d7f7e1fb$var$landmarkSymbol = Symbol.for("react-aria-landmark-manager");
  3862. function $a86207c5d7f7e1fb$var$subscribe(fn) {
  3863. return document.addEventListener("react-aria-landmark-manager-change", fn), () => document.removeEventListener("react-aria-landmark-manager-change", fn);
  3864. }
  3865. function $a86207c5d7f7e1fb$var$getLandmarkManager() {
  3866. if (typeof document > "u") return null;
  3867. let instance = document[$a86207c5d7f7e1fb$var$landmarkSymbol];
  3868. return instance && instance.version >= $a86207c5d7f7e1fb$var$LANDMARK_API_VERSION ? instance : (document[$a86207c5d7f7e1fb$var$landmarkSymbol] = new $a86207c5d7f7e1fb$var$LandmarkManager(), document.dispatchEvent(new CustomEvent("react-aria-landmark-manager-change")), document[$a86207c5d7f7e1fb$var$landmarkSymbol]);
  3869. }
  3870. function $a86207c5d7f7e1fb$var$useLandmarkManager() {
  3871. return (0, import_shim.useSyncExternalStore)($a86207c5d7f7e1fb$var$subscribe, $a86207c5d7f7e1fb$var$getLandmarkManager, $a86207c5d7f7e1fb$var$getLandmarkManager);
  3872. }
  3873. var $a86207c5d7f7e1fb$var$LandmarkManager = class {
  3874. setupIfNeeded() {
  3875. this.isListening || (document.addEventListener("keydown", this.f6Handler, {
  3876. capture: !0
  3877. }), document.addEventListener("focusin", this.focusinHandler, {
  3878. capture: !0
  3879. }), document.addEventListener("focusout", this.focusoutHandler, {
  3880. capture: !0
  3881. }), this.isListening = !0);
  3882. }
  3883. teardownIfNeeded() {
  3884. !this.isListening || this.landmarks.length > 0 || this.refCount > 0 || (document.removeEventListener("keydown", this.f6Handler, {
  3885. capture: !0
  3886. }), document.removeEventListener("focusin", this.focusinHandler, {
  3887. capture: !0
  3888. }), document.removeEventListener("focusout", this.focusoutHandler, {
  3889. capture: !0
  3890. }), this.isListening = !1);
  3891. }
  3892. focusLandmark(landmark, direction) {
  3893. var _this_landmarks_find_focus, _this_landmarks_find;
  3894. (_this_landmarks_find = this.landmarks.find((l3) => l3.ref.current === landmark)) === null || _this_landmarks_find === void 0 || (_this_landmarks_find_focus = _this_landmarks_find.focus) === null || _this_landmarks_find_focus === void 0 || _this_landmarks_find_focus.call(_this_landmarks_find, direction);
  3895. }
  3896. /**
  3897. * Return set of landmarks with a specific role.
  3898. */
  3899. getLandmarksByRole(role) {
  3900. return new Set(this.landmarks.filter((l3) => l3.role === role));
  3901. }
  3902. /**
  3903. * Return first landmark with a specific role.
  3904. */
  3905. getLandmarkByRole(role) {
  3906. return this.landmarks.find((l3) => l3.role === role);
  3907. }
  3908. addLandmark(newLandmark) {
  3909. if (this.setupIfNeeded(), this.landmarks.find((landmark) => landmark.ref === newLandmark.ref) || !newLandmark.ref.current) return;
  3910. if (this.landmarks.filter((landmark) => landmark.role === "main").length > 1, this.landmarks.length === 0) {
  3911. this.landmarks = [
  3912. newLandmark
  3913. ], this.checkLabels(newLandmark.role);
  3914. return;
  3915. }
  3916. let start = 0, end = this.landmarks.length - 1;
  3917. for (; start <= end; ) {
  3918. let mid = Math.floor((start + end) / 2), comparedPosition = newLandmark.ref.current.compareDocumentPosition(this.landmarks[mid].ref.current);
  3919. !!(comparedPosition & Node.DOCUMENT_POSITION_PRECEDING || comparedPosition & Node.DOCUMENT_POSITION_CONTAINS) ? start = mid + 1 : end = mid - 1;
  3920. }
  3921. this.landmarks.splice(start, 0, newLandmark), this.checkLabels(newLandmark.role);
  3922. }
  3923. updateLandmark(landmark) {
  3924. let index = this.landmarks.findIndex((l3) => l3.ref === landmark.ref);
  3925. index >= 0 && (this.landmarks[index] = {
  3926. ...this.landmarks[index],
  3927. ...landmark
  3928. }, this.checkLabels(this.landmarks[index].role));
  3929. }
  3930. removeLandmark(ref) {
  3931. this.landmarks = this.landmarks.filter((landmark) => landmark.ref !== ref), this.teardownIfNeeded();
  3932. }
  3933. /**
  3934. * Warn if there are 2+ landmarks with the same role but no label.
  3935. * Labels for landmarks with the same role must also be unique.
  3936. *
  3937. * See https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/.
  3938. */
  3939. checkLabels(role) {
  3940. let landmarksWithRole = this.getLandmarksByRole(role);
  3941. landmarksWithRole.size > 1 && [
  3942. ...landmarksWithRole
  3943. ].filter((landmark) => !landmark.label).length > 0;
  3944. }
  3945. /**
  3946. * Get the landmark that is the closest parent in the DOM.
  3947. * Returns undefined if no parent is a landmark.
  3948. */
  3949. closestLandmark(element) {
  3950. let landmarkMap = new Map(this.landmarks.map((l3) => [
  3951. l3.ref.current,
  3952. l3
  3953. ])), currentElement = element;
  3954. for (; currentElement && !landmarkMap.has(currentElement) && currentElement !== document.body && currentElement.parentElement; ) currentElement = currentElement.parentElement;
  3955. return landmarkMap.get(currentElement);
  3956. }
  3957. /**
  3958. * Gets the next landmark, in DOM focus order, or previous if backwards is specified.
  3959. * If last landmark, next should be the first landmark.
  3960. * If not inside a landmark, will return first landmark.
  3961. * Returns undefined if there are no landmarks.
  3962. */
  3963. getNextLandmark(element, { backward }) {
  3964. var _this_landmarks_nextLandmarkIndex_ref_current;
  3965. let currentLandmark = this.closestLandmark(element), nextLandmarkIndex = backward ? this.landmarks.length - 1 : 0;
  3966. currentLandmark && (nextLandmarkIndex = this.landmarks.indexOf(currentLandmark) + (backward ? -1 : 1));
  3967. let wrapIfNeeded = () => {
  3968. if (nextLandmarkIndex < 0) {
  3969. if (!element.dispatchEvent(new CustomEvent("react-aria-landmark-navigation", {
  3970. detail: {
  3971. direction: "backward"
  3972. },
  3973. bubbles: !0,
  3974. cancelable: !0
  3975. }))) return !0;
  3976. nextLandmarkIndex = this.landmarks.length - 1;
  3977. } else if (nextLandmarkIndex >= this.landmarks.length) {
  3978. if (!element.dispatchEvent(new CustomEvent("react-aria-landmark-navigation", {
  3979. detail: {
  3980. direction: "forward"
  3981. },
  3982. bubbles: !0,
  3983. cancelable: !0
  3984. }))) return !0;
  3985. nextLandmarkIndex = 0;
  3986. }
  3987. return nextLandmarkIndex < 0 || nextLandmarkIndex >= this.landmarks.length;
  3988. };
  3989. if (wrapIfNeeded()) return;
  3990. let i2 = nextLandmarkIndex;
  3991. for (; !((_this_landmarks_nextLandmarkIndex_ref_current = this.landmarks[nextLandmarkIndex].ref.current) === null || _this_landmarks_nextLandmarkIndex_ref_current === void 0) && _this_landmarks_nextLandmarkIndex_ref_current.closest("[aria-hidden=true]"); ) {
  3992. if (nextLandmarkIndex += backward ? -1 : 1, wrapIfNeeded()) return;
  3993. if (nextLandmarkIndex === i2) break;
  3994. }
  3995. return this.landmarks[nextLandmarkIndex];
  3996. }
  3997. /**
  3998. * Look at next landmark. If an element was previously focused inside, restore focus there.
  3999. * If not, focus the landmark itself.
  4000. * If no landmarks at all, or none with focusable elements, don't move focus.
  4001. */
  4002. f6Handler(e2) {
  4003. e2.key === "F6" && (e2.altKey ? this.focusMain() : this.navigate(e2.target, e2.shiftKey)) && (e2.preventDefault(), e2.stopPropagation());
  4004. }
  4005. focusMain() {
  4006. let main = this.getLandmarkByRole("main");
  4007. return main && main.ref.current && document.contains(main.ref.current) ? (this.focusLandmark(main.ref.current, "forward"), !0) : !1;
  4008. }
  4009. navigate(from, backward) {
  4010. let nextLandmark = this.getNextLandmark(from, {
  4011. backward
  4012. });
  4013. if (!nextLandmark) return !1;
  4014. if (nextLandmark.lastFocused) {
  4015. let lastFocused = nextLandmark.lastFocused;
  4016. if (document.body.contains(lastFocused))
  4017. return lastFocused.focus(), !0;
  4018. }
  4019. return nextLandmark.ref.current && document.contains(nextLandmark.ref.current) ? (this.focusLandmark(nextLandmark.ref.current, backward ? "backward" : "forward"), !0) : !1;
  4020. }
  4021. /**
  4022. * Sets lastFocused for a landmark, if focus is moved within that landmark.
  4023. * Lets the last focused landmark know it was blurred if something else is focused.
  4024. */
  4025. focusinHandler(e2) {
  4026. let currentLandmark = this.closestLandmark(e2.target);
  4027. currentLandmark && currentLandmark.ref.current !== e2.target && this.updateLandmark({
  4028. ref: currentLandmark.ref,
  4029. lastFocused: e2.target
  4030. });
  4031. let previousFocusedElement = e2.relatedTarget;
  4032. if (previousFocusedElement) {
  4033. let closestPreviousLandmark = this.closestLandmark(previousFocusedElement);
  4034. closestPreviousLandmark && closestPreviousLandmark.ref.current === previousFocusedElement && closestPreviousLandmark.blur();
  4035. }
  4036. }
  4037. /**
  4038. * Track if the focus is lost to the body. If it is, do cleanup on the landmark that last had focus.
  4039. */
  4040. focusoutHandler(e2) {
  4041. let previousFocusedElement = e2.target, nextFocusedElement = e2.relatedTarget;
  4042. if (!nextFocusedElement || nextFocusedElement === document) {
  4043. let closestPreviousLandmark = this.closestLandmark(previousFocusedElement);
  4044. closestPreviousLandmark && closestPreviousLandmark.ref.current === previousFocusedElement && closestPreviousLandmark.blur();
  4045. }
  4046. }
  4047. createLandmarkController() {
  4048. let instance = this;
  4049. return instance.refCount++, instance.setupIfNeeded(), {
  4050. navigate(direction, opts) {
  4051. let element = opts?.from || document.activeElement;
  4052. return instance.navigate(element, direction === "backward");
  4053. },
  4054. focusNext(opts) {
  4055. let element = opts?.from || document.activeElement;
  4056. return instance.navigate(element, !1);
  4057. },
  4058. focusPrevious(opts) {
  4059. let element = opts?.from || document.activeElement;
  4060. return instance.navigate(element, !0);
  4061. },
  4062. focusMain() {
  4063. return instance.focusMain();
  4064. },
  4065. dispose() {
  4066. instance && (instance.refCount--, instance.teardownIfNeeded(), instance = null);
  4067. }
  4068. };
  4069. }
  4070. registerLandmark(landmark) {
  4071. return this.landmarks.find((l3) => l3.ref === landmark.ref) ? this.updateLandmark(landmark) : this.addLandmark(landmark), () => this.removeLandmark(landmark.ref);
  4072. }
  4073. constructor() {
  4074. this.landmarks = [], this.isListening = !1, this.refCount = 0, this.version = $a86207c5d7f7e1fb$var$LANDMARK_API_VERSION, this.f6Handler = this.f6Handler.bind(this), this.focusinHandler = this.focusinHandler.bind(this), this.focusoutHandler = this.focusoutHandler.bind(this);
  4075. }
  4076. };
  4077. function $a86207c5d7f7e1fb$export$4cc632584fd87fae(props, ref) {
  4078. let { role, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, focus } = props, manager = $a86207c5d7f7e1fb$var$useLandmarkManager(), label = ariaLabel || ariaLabelledby, [isLandmarkFocused, setIsLandmarkFocused] = useState(!1), defaultFocus = useCallback(() => {
  4079. setIsLandmarkFocused(!0);
  4080. }, [
  4081. setIsLandmarkFocused
  4082. ]), blur = useCallback(() => {
  4083. setIsLandmarkFocused(!1);
  4084. }, [
  4085. setIsLandmarkFocused
  4086. ]);
  4087. return $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  4088. if (manager) return manager.registerLandmark({
  4089. ref,
  4090. label,
  4091. role,
  4092. focus: focus || defaultFocus,
  4093. blur
  4094. });
  4095. }, [
  4096. manager,
  4097. label,
  4098. ref,
  4099. role,
  4100. focus,
  4101. defaultFocus,
  4102. blur
  4103. ]), useEffect(() => {
  4104. var _ref_current;
  4105. isLandmarkFocused && ((_ref_current = ref.current) === null || _ref_current === void 0 || _ref_current.focus());
  4106. }, [
  4107. isLandmarkFocused,
  4108. ref
  4109. ]), {
  4110. landmarkProps: {
  4111. role,
  4112. tabIndex: isLandmarkFocused ? -1 : void 0,
  4113. "aria-label": ariaLabel,
  4114. "aria-labelledby": ariaLabelledby
  4115. }
  4116. };
  4117. }
  4118. // src/manager/hooks/useLandmark.ts
  4119. function useLandmark(props, ref) {
  4120. let { landmarkProps } = $a86207c5d7f7e1fb$export$4cc632584fd87fae(props, ref);
  4121. return {
  4122. landmarkProps: {
  4123. ...landmarkProps,
  4124. "data-sb-landmark": !0
  4125. }
  4126. };
  4127. }
  4128. // src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx
  4129. init_react();
  4130. var MobileAddonsDrawer = ({
  4131. children,
  4132. id,
  4133. isOpen,
  4134. onOpenChange
  4135. }) => react_default.createElement(
  4136. Modal,
  4137. {
  4138. ariaLabel: "Addon panel",
  4139. transitionDuration: 300,
  4140. variant: "bottom-drawer",
  4141. height: "42vh",
  4142. id,
  4143. open: isOpen,
  4144. onOpenChange
  4145. },
  4146. children
  4147. );
  4148. // src/manager/components/mobile/navigation/MobileMenuDrawer.tsx
  4149. init_react();
  4150. // src/manager/components/mobile/about/MobileAbout.tsx
  4151. init_react();
  4152. // ../../node_modules/react-transition-state/dist/esm/hooks/useTransitionState.mjs
  4153. init_react();
  4154. // ../../node_modules/react-transition-state/dist/esm/hooks/utils.mjs
  4155. var STATUS = ["preEnter", "entering", "entered", "preExit", "exiting", "exited", "unmounted"], getState = (status) => ({
  4156. _s: status,
  4157. status: STATUS[status],
  4158. isEnter: status < 3,
  4159. isMounted: status !== 6,
  4160. isResolved: status === 2 || status > 4
  4161. }), startOrEnd = (unmounted) => unmounted ? 6 : 5, getEndStatus = (status, unmountOnExit) => {
  4162. switch (status) {
  4163. case 1:
  4164. case 0:
  4165. return 2;
  4166. case 4:
  4167. case 3:
  4168. return startOrEnd(unmountOnExit);
  4169. }
  4170. }, getTimeout = (timeout) => typeof timeout == "object" ? [timeout.enter, timeout.exit] : [timeout, timeout], nextTick = (transitState, status) => setTimeout(() => {
  4171. isNaN(document.body.offsetTop) || transitState(status + 1);
  4172. }, 0);
  4173. // ../../node_modules/react-transition-state/dist/esm/hooks/useTransitionState.mjs
  4174. var updateState = (status, setState, latestState, timeoutId, onChange) => {
  4175. clearTimeout(timeoutId.current);
  4176. let state = getState(status);
  4177. setState(state), latestState.current = state, onChange && onChange({
  4178. current: state
  4179. });
  4180. }, useTransitionState = ({
  4181. enter = !0,
  4182. exit = !0,
  4183. preEnter,
  4184. preExit,
  4185. timeout,
  4186. initialEntered,
  4187. mountOnEnter,
  4188. unmountOnExit,
  4189. onStateChange: onChange
  4190. } = {}) => {
  4191. let [state, setState] = useState(() => getState(initialEntered ? 2 : startOrEnd(mountOnEnter))), latestState = useRef(state), timeoutId = useRef(), [enterTimeout, exitTimeout] = getTimeout(timeout), endTransition = useCallback(() => {
  4192. let status = getEndStatus(latestState.current._s, unmountOnExit);
  4193. status && updateState(status, setState, latestState, timeoutId, onChange);
  4194. }, [onChange, unmountOnExit]), toggle = useCallback((toEnter) => {
  4195. let transitState = (status) => {
  4196. switch (updateState(status, setState, latestState, timeoutId, onChange), status) {
  4197. case 1:
  4198. enterTimeout >= 0 && (timeoutId.current = setTimeout(endTransition, enterTimeout));
  4199. break;
  4200. case 4:
  4201. exitTimeout >= 0 && (timeoutId.current = setTimeout(endTransition, exitTimeout));
  4202. break;
  4203. case 0:
  4204. case 3:
  4205. timeoutId.current = nextTick(transitState, status);
  4206. break;
  4207. }
  4208. }, enterStage = latestState.current.isEnter;
  4209. typeof toEnter != "boolean" && (toEnter = !enterStage), toEnter ? !enterStage && transitState(enter ? preEnter ? 0 : 1 : 2) : enterStage && transitState(exit ? preExit ? 3 : 4 : startOrEnd(unmountOnExit));
  4210. }, [endTransition, onChange, enter, exit, preEnter, preExit, enterTimeout, exitTimeout, unmountOnExit]);
  4211. return [state, toggle, endTransition];
  4212. };
  4213. // ../../node_modules/react-transition-state/dist/esm/hooks/useTransitionMap.mjs
  4214. init_react();
  4215. var updateState2 = (key, status, setStateMap, latestStateMap, timeoutId, onChange) => {
  4216. clearTimeout(timeoutId);
  4217. let state = getState(status), stateMap = new Map(latestStateMap.current);
  4218. stateMap.set(key, state), setStateMap(stateMap), latestStateMap.current = stateMap, onChange && onChange({
  4219. key,
  4220. current: state
  4221. });
  4222. }, useTransitionMap = ({
  4223. allowMultiple,
  4224. enter = !0,
  4225. exit = !0,
  4226. preEnter,
  4227. preExit,
  4228. timeout,
  4229. initialEntered,
  4230. mountOnEnter,
  4231. unmountOnExit,
  4232. onStateChange: onChange
  4233. } = {}) => {
  4234. let [stateMap, setStateMap] = useState(/* @__PURE__ */ new Map()), latestStateMap = useRef(stateMap), configMap = useRef(/* @__PURE__ */ new Map()), [enterTimeout, exitTimeout] = getTimeout(timeout), setItem = useCallback((key, config) => {
  4235. let {
  4236. initialEntered: _initialEntered = initialEntered
  4237. } = config || {}, status = _initialEntered ? 2 : startOrEnd(mountOnEnter);
  4238. updateState2(key, status, setStateMap, latestStateMap), configMap.current.set(key, {});
  4239. }, [initialEntered, mountOnEnter]), deleteItem = useCallback((key) => {
  4240. let newStateMap = new Map(latestStateMap.current);
  4241. return newStateMap.delete(key) ? (setStateMap(newStateMap), latestStateMap.current = newStateMap, configMap.current.delete(key), !0) : !1;
  4242. }, []), endTransition = useCallback((key) => {
  4243. let stateObj = latestStateMap.current.get(key);
  4244. if (!stateObj)
  4245. return;
  4246. let {
  4247. timeoutId
  4248. } = configMap.current.get(key), status = getEndStatus(stateObj._s, unmountOnExit);
  4249. status && updateState2(key, status, setStateMap, latestStateMap, timeoutId, onChange);
  4250. }, [onChange, unmountOnExit]), toggle = useCallback((key, toEnter) => {
  4251. let stateObj = latestStateMap.current.get(key);
  4252. if (!stateObj)
  4253. return;
  4254. let config = configMap.current.get(key), transitState = (status) => {
  4255. switch (updateState2(key, status, setStateMap, latestStateMap, config.timeoutId, onChange), status) {
  4256. case 1:
  4257. enterTimeout >= 0 && (config.timeoutId = setTimeout(() => endTransition(key), enterTimeout));
  4258. break;
  4259. case 4:
  4260. exitTimeout >= 0 && (config.timeoutId = setTimeout(() => endTransition(key), exitTimeout));
  4261. break;
  4262. case 0:
  4263. case 3:
  4264. config.timeoutId = nextTick(transitState, status);
  4265. break;
  4266. }
  4267. }, enterStage = stateObj.isEnter;
  4268. typeof toEnter != "boolean" && (toEnter = !enterStage), toEnter ? enterStage || (transitState(enter ? preEnter ? 0 : 1 : 2), !allowMultiple && latestStateMap.current.forEach((_2, _key) => _key !== key && toggle(_key, !1))) : enterStage && transitState(exit ? preExit ? 3 : 4 : startOrEnd(unmountOnExit));
  4269. }, [onChange, endTransition, allowMultiple, enter, exit, preEnter, preExit, enterTimeout, exitTimeout, unmountOnExit]), toggleAll = useCallback((toEnter) => {
  4270. if (!(!allowMultiple && toEnter !== !1))
  4271. for (let key of latestStateMap.current.keys()) toggle(key, toEnter);
  4272. }, [allowMultiple, toggle]);
  4273. return {
  4274. stateMap,
  4275. toggle,
  4276. toggleAll,
  4277. endTransition,
  4278. setItem,
  4279. deleteItem
  4280. };
  4281. };
  4282. // src/manager/components/upgrade/UpgradeBlock.tsx
  4283. init_react();
  4284. var UpgradeBlock = ({ onNavigateToWhatsNew }) => {
  4285. let api = useStorybookApi(), [activeTab, setActiveTab] = useState("npm");
  4286. return react_default.createElement(Container2, null, react_default.createElement("strong", null, "You are on Storybook ", api.getCurrentVersion().version), react_default.createElement("p", null, "Run the following script to check for updates and upgrade to the latest version."), react_default.createElement(Tabs2, null, react_default.createElement(ButtonTab, { active: activeTab === "npm", onClick: () => setActiveTab("npm") }, "npm"), react_default.createElement(ButtonTab, { active: activeTab === "yarn", onClick: () => setActiveTab("yarn") }, "yarn"), react_default.createElement(ButtonTab, { active: activeTab === "pnpm", onClick: () => setActiveTab("pnpm") }, "pnpm")), react_default.createElement(Code2, null, activeTab === "npm" ? "npx storybook@latest upgrade" : `${activeTab} dlx storybook@latest upgrade`), onNavigateToWhatsNew && react_default.createElement(Link, { onClick: onNavigateToWhatsNew }, "See what's new in Storybook"));
  4287. }, Container2 = styled.div(({ theme }) => ({
  4288. border: "1px solid",
  4289. borderRadius: 5,
  4290. padding: 20,
  4291. marginTop: 0,
  4292. borderColor: theme.appBorderColor,
  4293. fontSize: theme.typography.size.s2,
  4294. width: "100%",
  4295. [MEDIA_DESKTOP_BREAKPOINT]: {
  4296. maxWidth: 400
  4297. }
  4298. })), Tabs2 = styled.div({
  4299. display: "flex",
  4300. gap: 2
  4301. }), Code2 = styled.pre(({ theme }) => ({
  4302. background: theme.base === "light" ? "rgba(0, 0, 0, 0.05)" : theme.appBorderColor,
  4303. fontSize: theme.typography.size.s2 - 1,
  4304. margin: "4px 0 16px"
  4305. })), ButtonTab = styled.button(({ theme, active }) => ({
  4306. all: "unset",
  4307. alignItems: "center",
  4308. gap: 10,
  4309. color: theme.color.defaultText,
  4310. fontSize: theme.typography.size.s2 - 1,
  4311. borderBottom: "2px solid transparent",
  4312. borderBottomColor: active ? theme.color.secondary : "none",
  4313. padding: "0 10px 5px",
  4314. marginBottom: "5px",
  4315. cursor: "pointer"
  4316. }));
  4317. // src/manager/components/mobile/about/MobileAbout.tsx
  4318. var MobileAbout = () => {
  4319. let { isMobileAboutOpen, setMobileAboutOpen } = useLayout(), aboutRef = useRef(null), [state, toggle] = useTransitionState({
  4320. timeout: 300,
  4321. mountOnEnter: !0,
  4322. unmountOnExit: !0
  4323. });
  4324. return useEffect(() => {
  4325. toggle(isMobileAboutOpen);
  4326. }, [isMobileAboutOpen, toggle]), state.isMounted ? react_default.createElement(
  4327. Container3,
  4328. {
  4329. ref: aboutRef,
  4330. $status: state.status,
  4331. $transitionDuration: 300
  4332. },
  4333. react_default.createElement(ScrollArea, { vertical: !0, offset: 3, scrollbarSize: 6 }, react_default.createElement(InnerArea, null, react_default.createElement(
  4334. CloseButton,
  4335. {
  4336. onClick: () => setMobileAboutOpen(!1),
  4337. ariaLabel: "Close about section",
  4338. tooltip: "Close about section",
  4339. variant: "ghost"
  4340. },
  4341. react_default.createElement(ArrowLeftIcon, null),
  4342. "Back"
  4343. ), react_default.createElement(LinkContainer, null, react_default.createElement(
  4344. LinkLine,
  4345. {
  4346. href: "https://github.com/storybookjs/storybook",
  4347. target: "_blank",
  4348. rel: "noopener noreferrer"
  4349. },
  4350. react_default.createElement(LinkLeft, null, react_default.createElement(GithubIcon, null), react_default.createElement("span", null, "Github")),
  4351. react_default.createElement(ShareAltIcon, { width: 12 })
  4352. ), react_default.createElement(
  4353. LinkLine,
  4354. {
  4355. href: "https://storybook.js.org/docs/get-started/install?ref=ui",
  4356. target: "_blank",
  4357. rel: "noopener noreferrer"
  4358. },
  4359. react_default.createElement(LinkLeft, null, react_default.createElement(StorybookIcon, null), react_default.createElement("span", null, "Documentation")),
  4360. react_default.createElement(ShareAltIcon, { width: 12 })
  4361. )), react_default.createElement(UpgradeBlock, null), react_default.createElement(BottomText, null, "Open source software maintained by", " ", react_default.createElement(Link, { href: "https://chromatic.com", target: "_blank", rel: "noopener noreferrer" }, "Chromatic"), " ", "and the", " ", react_default.createElement(
  4362. Link,
  4363. {
  4364. href: "https://github.com/storybookjs/storybook/graphs/contributors",
  4365. rel: "noopener noreferrer"
  4366. },
  4367. "Storybook Community"
  4368. ))))
  4369. ) : null;
  4370. }, slideFromRight = keyframes({
  4371. from: {
  4372. opacity: 0,
  4373. transform: "translate(20px, 0)"
  4374. },
  4375. to: {
  4376. opacity: 1,
  4377. transform: "translate(0, 0)"
  4378. }
  4379. }), slideToRight = keyframes({
  4380. from: {
  4381. opacity: 1,
  4382. transform: "translate(0, 0)"
  4383. },
  4384. to: {
  4385. opacity: 0,
  4386. transform: "translate(20px, 0)"
  4387. }
  4388. }), Container3 = styled.div(
  4389. ({ theme, $status, $transitionDuration }) => ({
  4390. position: "absolute",
  4391. width: "100%",
  4392. height: "100%",
  4393. borderRadius: "10px 10px 0 0",
  4394. top: 0,
  4395. left: 0,
  4396. zIndex: 11,
  4397. overflow: "auto",
  4398. color: theme.color.defaultText,
  4399. background: theme.background.content,
  4400. animation: $status === "exiting" ? `${slideToRight} ${$transitionDuration}ms` : `${slideFromRight} ${$transitionDuration}ms`
  4401. })
  4402. ), InnerArea = styled.div({
  4403. display: "flex",
  4404. flexDirection: "column",
  4405. gap: 20,
  4406. padding: "25px 12px 20px"
  4407. }), LinkContainer = styled.div({}), LinkLine = styled.a(({ theme }) => ({
  4408. all: "unset",
  4409. display: "flex",
  4410. alignItems: "center",
  4411. justifyContent: "space-between",
  4412. fontSize: theme.typography.size.s2 - 1,
  4413. borderBottom: `1px solid ${theme.appBorderColor}`,
  4414. cursor: "pointer",
  4415. padding: "0 10px",
  4416. "&:last-child": {
  4417. borderBottom: "none"
  4418. }
  4419. })), LinkLeft = styled.div(({ theme }) => ({
  4420. display: "flex",
  4421. alignItems: "center",
  4422. fontSize: theme.typography.size.s2 - 1,
  4423. height: 40,
  4424. gap: 5
  4425. })), BottomText = styled.div(({ theme }) => ({
  4426. fontSize: theme.typography.size.s2 - 1,
  4427. marginTop: 30
  4428. })), CloseButton = styled(Button)({
  4429. alignSelf: "start"
  4430. });
  4431. // src/manager/components/mobile/navigation/MobileMenuDrawer.tsx
  4432. var MobileMenuDrawer = ({
  4433. children,
  4434. id,
  4435. isOpen,
  4436. onOpenChange
  4437. }) => react_default.createElement(
  4438. Modal,
  4439. {
  4440. ariaLabel: "Menu",
  4441. transitionDuration: 300,
  4442. variant: "bottom-drawer",
  4443. height: "80vh",
  4444. id,
  4445. open: isOpen,
  4446. onOpenChange
  4447. },
  4448. children,
  4449. react_default.createElement(MobileAbout, null)
  4450. );
  4451. // src/manager/components/mobile/navigation/MobileNavigation.tsx
  4452. function combineIndexes(rootIndex, refs) {
  4453. let combinedIndex = { ...rootIndex || {} };
  4454. return Object.values(refs).forEach((ref) => {
  4455. ref.index && Object.assign(combinedIndex, ref.index);
  4456. }), combinedIndex;
  4457. }
  4458. var useFullStoryName = () => {
  4459. let { index, refs } = useStorybookState(), api = useStorybookApi(), currentStory = api.getCurrentStoryData();
  4460. if (!currentStory)
  4461. return "";
  4462. let combinedIndex = combineIndexes(index, refs || {}), storyLabel = currentStory.renderLabel?.(currentStory, api), fullStoryName = typeof storyLabel == "string" ? storyLabel : currentStory.name, node = combinedIndex[currentStory.id];
  4463. for (; node && "parent" in node && node.parent && combinedIndex[node.parent] && fullStoryName.length < 24; ) {
  4464. node = combinedIndex[node.parent];
  4465. let parentLabel = node.renderLabel?.(node, api);
  4466. fullStoryName = `${typeof parentLabel == "string" ? parentLabel : node.name}/${fullStoryName}`;
  4467. }
  4468. return fullStoryName;
  4469. }, MobileNavigation = ({
  4470. menu,
  4471. panel,
  4472. showPanel,
  4473. ...props
  4474. }) => {
  4475. let { isMobileMenuOpen, isMobilePanelOpen, setMobileMenuOpen, setMobilePanelOpen } = useLayout(), fullStoryName = useFullStoryName(), headingId = $bdb11010cef70236$export$f680877a34711e37(), sectionRef = useRef(null), { landmarkProps } = useLandmark(
  4476. { "aria-labelledby": headingId, role: "banner" },
  4477. sectionRef
  4478. );
  4479. return react_default.createElement(Container4, { ...props }, react_default.createElement(
  4480. MobileMenuDrawer,
  4481. {
  4482. id: "storybook-mobile-menu",
  4483. isOpen: isMobileMenuOpen,
  4484. onOpenChange: setMobileMenuOpen
  4485. },
  4486. menu
  4487. ), react_default.createElement(
  4488. MobileAddonsDrawer,
  4489. {
  4490. id: "storybook-mobile-addon-panel",
  4491. isOpen: isMobilePanelOpen,
  4492. onOpenChange: setMobilePanelOpen
  4493. },
  4494. panel
  4495. ), !isMobilePanelOpen && react_default.createElement(MobileBottomBar, { className: "sb-bar", ...landmarkProps, ref: sectionRef }, react_default.createElement("h2", { id: headingId, className: "sb-sr-only" }, "Navigation controls"), react_default.createElement(
  4496. BottomBarButton,
  4497. {
  4498. padding: "small",
  4499. variant: "ghost",
  4500. onClick: () => setMobileMenuOpen(!isMobileMenuOpen),
  4501. ariaLabel: "Open navigation menu",
  4502. "aria-expanded": isMobileMenuOpen,
  4503. "aria-controls": "storybook-mobile-menu"
  4504. },
  4505. react_default.createElement(MenuIcon, null),
  4506. react_default.createElement(Text, null, fullStoryName)
  4507. ), react_default.createElement("span", { className: "sb-sr-only", "aria-current": "page" }, fullStoryName), showPanel && react_default.createElement(
  4508. BottomBarButton,
  4509. {
  4510. padding: "small",
  4511. variant: "ghost",
  4512. onClick: () => setMobilePanelOpen(!0),
  4513. ariaLabel: "Open addon panel",
  4514. "aria-expanded": isMobilePanelOpen,
  4515. "aria-controls": "storybook-mobile-addon-panel"
  4516. },
  4517. react_default.createElement(BottomBarToggleIcon, null)
  4518. )));
  4519. }, Container4 = styled.section(({ theme }) => ({
  4520. bottom: 0,
  4521. left: 0,
  4522. width: "100%",
  4523. zIndex: 10,
  4524. background: theme.barBg,
  4525. borderTop: `1px solid ${theme.appBorderColor}`
  4526. })), MobileBottomBar = styled.header({
  4527. display: "flex",
  4528. alignItems: "center",
  4529. justifyContent: "space-between",
  4530. width: "100%",
  4531. height: 40,
  4532. padding: "0 6px",
  4533. /* Because Popper.js's tooltip is creating extra div layers, we have to
  4534. * punch through them to configure the button to ellipsize. */
  4535. "& > *:first-child": {
  4536. /* 6px padding * 2 + 28px for the orientation button */
  4537. maxWidth: "calc(100% - 40px)",
  4538. "& > button": {
  4539. maxWidth: "100%"
  4540. },
  4541. "& > button p": {
  4542. textOverflow: "ellipsis"
  4543. }
  4544. }
  4545. }), BottomBarButton = styled(Button)({
  4546. WebkitLineClamp: 1,
  4547. flexShrink: 1,
  4548. p: {
  4549. textOverflow: "ellipsis"
  4550. }
  4551. }), Text = styled.p({
  4552. display: "-webkit-box",
  4553. WebkitLineClamp: 1,
  4554. WebkitBoxOrient: "vertical",
  4555. overflow: "hidden"
  4556. });
  4557. // src/manager/components/layout/MainAreaContainer.tsx
  4558. init_react();
  4559. var PagesInnerContainer = styled.main(({ theme }) => ({
  4560. display: "flex",
  4561. flexDirection: "column",
  4562. gridRowStart: "sidebar-start",
  4563. gridRowEnd: "-1",
  4564. gridColumnStart: "sidebar-end",
  4565. gridColumnEnd: "-1",
  4566. backgroundColor: theme.appContentBg,
  4567. zIndex: 1
  4568. })), PagesContainer = react_default.memo(function(props) {
  4569. let { children } = props, mainRef = useRef(null), { landmarkProps } = useLandmark(
  4570. { "aria-labelledby": "main-content-heading", role: "main" },
  4571. mainRef
  4572. );
  4573. return react_default.createElement(PagesInnerContainer, { id: "main-content-wrapper", ref: mainRef, ...landmarkProps }, react_default.createElement("h2", { id: "main-content-heading", className: "sb-sr-only" }, "Main content"), children);
  4574. }), MainInnerContainer = styled.div(({ theme, shown }) => ({
  4575. flex: 1,
  4576. position: "relative",
  4577. backgroundColor: theme.appContentBg,
  4578. display: shown ? "grid" : "none",
  4579. // This is needed to make the content container fill the available space
  4580. overflow: "auto",
  4581. [MEDIA_DESKTOP_BREAKPOINT]: {
  4582. flex: "auto",
  4583. gridArea: "content"
  4584. }
  4585. })), MainAreaContainer = react_default.memo(function({
  4586. showPages,
  4587. slotMain,
  4588. slotPages
  4589. }) {
  4590. return react_default.createElement(react_default.Fragment, null, showPages ? react_default.createElement(PagesContainer, null, slotPages) : react_default.createElement(Match, { path: /(^\/story|docs|onboarding\/|^\/$)/, startsWith: !1 }, ({ match }) => react_default.createElement(MainInnerContainer, { shown: !!match }, slotMain)));
  4591. });
  4592. // src/manager/components/layout/PanelContainer.tsx
  4593. init_react();
  4594. // src/manager/components/layout/Drag.tsx
  4595. init_react();
  4596. // src/components/components/tooltip/TooltipNote.tsx
  4597. init_react();
  4598. var Note = styled.div(({ theme }) => ({
  4599. padding: "2px 6px",
  4600. lineHeight: "16px",
  4601. fontSize: 10,
  4602. fontWeight: theme.typography.weight.bold,
  4603. color: theme.color.lightest,
  4604. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)",
  4605. borderRadius: 4,
  4606. whiteSpace: "nowrap",
  4607. pointerEvents: "none",
  4608. zIndex: -1,
  4609. background: theme.base === "light" ? "rgba(60, 60, 60, 0.9)" : "rgba(0, 0, 0, 0.95)"
  4610. })), TooltipNote2 = ({ note, ...props }) => react_default.createElement(Note, { ...props }, note);
  4611. // src/components/components/tooltip/TooltipProvider.tsx
  4612. init_react();
  4613. // ../../node_modules/@react-aria/interactions/dist/utils.mjs
  4614. init_react();
  4615. function $8a9cb279dc87e130$export$525bc4921d56d4a(nativeEvent) {
  4616. let event = nativeEvent;
  4617. return event.nativeEvent = nativeEvent, event.isDefaultPrevented = () => event.defaultPrevented, event.isPropagationStopped = () => event.cancelBubble, event.persist = () => {
  4618. }, event;
  4619. }
  4620. function $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target) {
  4621. Object.defineProperty(event, "target", {
  4622. value: target
  4623. }), Object.defineProperty(event, "currentTarget", {
  4624. value: target
  4625. });
  4626. }
  4627. function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
  4628. let stateRef = useRef({
  4629. isFocused: !1,
  4630. observer: null
  4631. });
  4632. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  4633. let state = stateRef.current;
  4634. return () => {
  4635. state.observer && (state.observer.disconnect(), state.observer = null);
  4636. };
  4637. }, []);
  4638. let dispatchBlur = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4639. onBlur?.(e2);
  4640. });
  4641. return useCallback((e2) => {
  4642. if (e2.target instanceof HTMLButtonElement || e2.target instanceof HTMLInputElement || e2.target instanceof HTMLTextAreaElement || e2.target instanceof HTMLSelectElement) {
  4643. stateRef.current.isFocused = !0;
  4644. let target = e2.target, onBlurHandler = (e3) => {
  4645. if (stateRef.current.isFocused = !1, target.disabled) {
  4646. let event = $8a9cb279dc87e130$export$525bc4921d56d4a(e3);
  4647. dispatchBlur(event);
  4648. }
  4649. stateRef.current.observer && (stateRef.current.observer.disconnect(), stateRef.current.observer = null);
  4650. };
  4651. target.addEventListener("focusout", onBlurHandler, {
  4652. once: !0
  4653. }), stateRef.current.observer = new MutationObserver(() => {
  4654. if (stateRef.current.isFocused && target.disabled) {
  4655. var _stateRef_current_observer;
  4656. (_stateRef_current_observer = stateRef.current.observer) === null || _stateRef_current_observer === void 0 || _stateRef_current_observer.disconnect();
  4657. let relatedTargetEl = target === document.activeElement ? null : document.activeElement;
  4658. target.dispatchEvent(new FocusEvent("blur", {
  4659. relatedTarget: relatedTargetEl
  4660. })), target.dispatchEvent(new FocusEvent("focusout", {
  4661. bubbles: !0,
  4662. relatedTarget: relatedTargetEl
  4663. }));
  4664. }
  4665. }), stateRef.current.observer.observe(target, {
  4666. attributes: !0,
  4667. attributeFilter: [
  4668. "disabled"
  4669. ]
  4670. });
  4671. }
  4672. }, [
  4673. dispatchBlur
  4674. ]);
  4675. }
  4676. var $8a9cb279dc87e130$export$fda7da73ab5d4c48 = !1;
  4677. function $8a9cb279dc87e130$export$cabe61c495ee3649(target) {
  4678. for (; target && !$b4b717babfbb907b$export$4c063cf1350e6fed(target); ) target = target.parentElement;
  4679. let window2 = $431fbd86ca7dc216$export$f21a1ffae260145a(target), activeElement = window2.document.activeElement;
  4680. if (!activeElement || activeElement === target) return;
  4681. $8a9cb279dc87e130$export$fda7da73ab5d4c48 = !0;
  4682. let isRefocusing = !1, onBlur = (e2) => {
  4683. (e2.target === activeElement || isRefocusing) && e2.stopImmediatePropagation();
  4684. }, onFocusOut = (e2) => {
  4685. (e2.target === activeElement || isRefocusing) && (e2.stopImmediatePropagation(), !target && !isRefocusing && (isRefocusing = !0, $7215afc6de606d6b$export$de79e2c695e052f3(activeElement), cleanup()));
  4686. }, onFocus = (e2) => {
  4687. (e2.target === target || isRefocusing) && e2.stopImmediatePropagation();
  4688. }, onFocusIn = (e2) => {
  4689. (e2.target === target || isRefocusing) && (e2.stopImmediatePropagation(), isRefocusing || (isRefocusing = !0, $7215afc6de606d6b$export$de79e2c695e052f3(activeElement), cleanup()));
  4690. };
  4691. window2.addEventListener("blur", onBlur, !0), window2.addEventListener("focusout", onFocusOut, !0), window2.addEventListener("focusin", onFocusIn, !0), window2.addEventListener("focus", onFocus, !0);
  4692. let cleanup = () => {
  4693. cancelAnimationFrame(raf), window2.removeEventListener("blur", onBlur, !0), window2.removeEventListener("focusout", onFocusOut, !0), window2.removeEventListener("focusin", onFocusIn, !0), window2.removeEventListener("focus", onFocus, !0), $8a9cb279dc87e130$export$fda7da73ab5d4c48 = !1, isRefocusing = !1;
  4694. }, raf = requestAnimationFrame(cleanup);
  4695. return cleanup;
  4696. }
  4697. // ../../node_modules/@react-aria/interactions/dist/textSelection.mjs
  4698. var $14c0b72509d70225$var$state = "default", $14c0b72509d70225$var$savedUserSelect = "", $14c0b72509d70225$var$modifiedElementMap = /* @__PURE__ */ new WeakMap();
  4699. function $14c0b72509d70225$export$16a4697467175487(target) {
  4700. if ($c87311424ea30a05$export$fedb369cb70207f1()) {
  4701. if ($14c0b72509d70225$var$state === "default") {
  4702. let documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
  4703. $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect, documentObject.documentElement.style.webkitUserSelect = "none";
  4704. }
  4705. $14c0b72509d70225$var$state = "disabled";
  4706. } else if (target instanceof HTMLElement || target instanceof SVGElement) {
  4707. let property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
  4708. $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]), target.style[property] = "none";
  4709. }
  4710. }
  4711. function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
  4712. if ($c87311424ea30a05$export$fedb369cb70207f1()) {
  4713. if ($14c0b72509d70225$var$state !== "disabled") return;
  4714. $14c0b72509d70225$var$state = "restoring", setTimeout(() => {
  4715. $bbed8b41f857bcc0$export$24490316f764c430(() => {
  4716. if ($14c0b72509d70225$var$state === "restoring") {
  4717. let documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
  4718. documentObject.documentElement.style.webkitUserSelect === "none" && (documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || ""), $14c0b72509d70225$var$savedUserSelect = "", $14c0b72509d70225$var$state = "default";
  4719. }
  4720. });
  4721. }, 300);
  4722. } else if ((target instanceof HTMLElement || target instanceof SVGElement) && target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
  4723. let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target), property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
  4724. target.style[property] === "none" && (target.style[property] = targetOldUserSelect), target.getAttribute("style") === "" && target.removeAttribute("style"), $14c0b72509d70225$var$modifiedElementMap.delete(target);
  4725. }
  4726. }
  4727. // ../../node_modules/@react-aria/interactions/dist/context.mjs
  4728. init_react();
  4729. var $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = react_default.createContext({
  4730. register: () => {
  4731. }
  4732. });
  4733. $ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = "PressResponderContext";
  4734. // ../../node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js
  4735. function _class_apply_descriptor_get(receiver, descriptor) {
  4736. return descriptor.get ? descriptor.get.call(receiver) : descriptor.value;
  4737. }
  4738. // ../../node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js
  4739. function _class_extract_field_descriptor(receiver, privateMap, action) {
  4740. if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
  4741. return privateMap.get(receiver);
  4742. }
  4743. // ../../node_modules/@swc/helpers/esm/_class_private_field_get.js
  4744. function _class_private_field_get(receiver, privateMap) {
  4745. var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
  4746. return _class_apply_descriptor_get(receiver, descriptor);
  4747. }
  4748. // ../../node_modules/@swc/helpers/esm/_check_private_redeclaration.js
  4749. function _check_private_redeclaration(obj, privateCollection) {
  4750. if (privateCollection.has(obj))
  4751. throw new TypeError("Cannot initialize the same private elements twice on an object");
  4752. }
  4753. // ../../node_modules/@swc/helpers/esm/_class_private_field_init.js
  4754. function _class_private_field_init(obj, privateMap, value) {
  4755. _check_private_redeclaration(obj, privateMap), privateMap.set(obj, value);
  4756. }
  4757. // ../../node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js
  4758. function _class_apply_descriptor_set(receiver, descriptor, value) {
  4759. if (descriptor.set) descriptor.set.call(receiver, value);
  4760. else {
  4761. if (!descriptor.writable)
  4762. throw new TypeError("attempted to set read only private field");
  4763. descriptor.value = value;
  4764. }
  4765. }
  4766. // ../../node_modules/@swc/helpers/esm/_class_private_field_set.js
  4767. function _class_private_field_set(receiver, privateMap, value) {
  4768. var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
  4769. return _class_apply_descriptor_set(receiver, descriptor, value), value;
  4770. }
  4771. // ../../node_modules/@react-aria/interactions/dist/usePress.mjs
  4772. init_react();
  4773. function $f6c31cce2adf654f$var$usePressResponderContext(props) {
  4774. let context = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
  4775. if (context) {
  4776. let { register, ...contextProps } = context;
  4777. props = $3ef42575df84b30b$export$9d1611c77c2fe928(contextProps, props), register();
  4778. }
  4779. return $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, props.ref), props;
  4780. }
  4781. var $f6c31cce2adf654f$var$_shouldStopPropagation = /* @__PURE__ */ new WeakMap(), $f6c31cce2adf654f$var$PressEvent = class {
  4782. continuePropagation() {
  4783. _class_private_field_set(this, $f6c31cce2adf654f$var$_shouldStopPropagation, !1);
  4784. }
  4785. get shouldStopPropagation() {
  4786. return _class_private_field_get(this, $f6c31cce2adf654f$var$_shouldStopPropagation);
  4787. }
  4788. constructor(type, pointerType, originalEvent, state) {
  4789. _class_private_field_init(this, $f6c31cce2adf654f$var$_shouldStopPropagation, {
  4790. writable: !0,
  4791. value: void 0
  4792. }), _class_private_field_set(this, $f6c31cce2adf654f$var$_shouldStopPropagation, !0);
  4793. var _state_target;
  4794. let currentTarget = (_state_target = state?.target) !== null && _state_target !== void 0 ? _state_target : originalEvent.currentTarget, rect = currentTarget?.getBoundingClientRect(), x2, y2 = 0, clientX, clientY = null;
  4795. originalEvent.clientX != null && originalEvent.clientY != null && (clientX = originalEvent.clientX, clientY = originalEvent.clientY), rect && (clientX != null && clientY != null ? (x2 = clientX - rect.left, y2 = clientY - rect.top) : (x2 = rect.width / 2, y2 = rect.height / 2)), this.type = type, this.pointerType = pointerType, this.target = originalEvent.currentTarget, this.shiftKey = originalEvent.shiftKey, this.metaKey = originalEvent.metaKey, this.ctrlKey = originalEvent.ctrlKey, this.altKey = originalEvent.altKey, this.x = x2, this.y = y2;
  4796. }
  4797. }, $f6c31cce2adf654f$var$LINK_CLICKED = Symbol("linkClicked"), $f6c31cce2adf654f$var$STYLE_ID = "react-aria-pressable-style", $f6c31cce2adf654f$var$PRESSABLE_ATTRIBUTE = "data-react-aria-pressable";
  4798. function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
  4799. let { onPress, onPressChange, onPressStart, onPressEnd, onPressUp, onClick, isDisabled, isPressed: isPressedProp, preventFocusOnPress, shouldCancelOnPointerExit, allowTextSelectionOnPress, ref: domRef, ...domProps } = $f6c31cce2adf654f$var$usePressResponderContext(props), [isPressed, setPressed] = useState(!1), ref = useRef({
  4800. isPressed: !1,
  4801. ignoreEmulatedMouseEvents: !1,
  4802. didFirePressStart: !1,
  4803. isTriggeringEvent: !1,
  4804. activePointerId: null,
  4805. target: null,
  4806. isOverTarget: !1,
  4807. pointerType: null,
  4808. disposables: []
  4809. }), { addGlobalListener, removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6(), triggerPressStart = $8ae05eaa5c114e9c$export$7f54fc3180508a52((originalEvent, pointerType) => {
  4810. let state = ref.current;
  4811. if (isDisabled || state.didFirePressStart) return !1;
  4812. let shouldStopPropagation = !0;
  4813. if (state.isTriggeringEvent = !0, onPressStart) {
  4814. let event = new $f6c31cce2adf654f$var$PressEvent("pressstart", pointerType, originalEvent);
  4815. onPressStart(event), shouldStopPropagation = event.shouldStopPropagation;
  4816. }
  4817. return onPressChange && onPressChange(!0), state.isTriggeringEvent = !1, state.didFirePressStart = !0, setPressed(!0), shouldStopPropagation;
  4818. }), triggerPressEnd = $8ae05eaa5c114e9c$export$7f54fc3180508a52((originalEvent, pointerType, wasPressed = !0) => {
  4819. let state = ref.current;
  4820. if (!state.didFirePressStart) return !1;
  4821. state.didFirePressStart = !1, state.isTriggeringEvent = !0;
  4822. let shouldStopPropagation = !0;
  4823. if (onPressEnd) {
  4824. let event = new $f6c31cce2adf654f$var$PressEvent("pressend", pointerType, originalEvent);
  4825. onPressEnd(event), shouldStopPropagation = event.shouldStopPropagation;
  4826. }
  4827. if (onPressChange && onPressChange(!1), setPressed(!1), onPress && wasPressed && !isDisabled) {
  4828. let event = new $f6c31cce2adf654f$var$PressEvent("press", pointerType, originalEvent);
  4829. onPress(event), shouldStopPropagation && (shouldStopPropagation = event.shouldStopPropagation);
  4830. }
  4831. return state.isTriggeringEvent = !1, shouldStopPropagation;
  4832. }), triggerPressUp = $8ae05eaa5c114e9c$export$7f54fc3180508a52((originalEvent, pointerType) => {
  4833. let state = ref.current;
  4834. if (isDisabled) return !1;
  4835. if (onPressUp) {
  4836. state.isTriggeringEvent = !0;
  4837. let event = new $f6c31cce2adf654f$var$PressEvent("pressup", pointerType, originalEvent);
  4838. return onPressUp(event), state.isTriggeringEvent = !1, event.shouldStopPropagation;
  4839. }
  4840. return !0;
  4841. }), cancel = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4842. let state = ref.current;
  4843. if (state.isPressed && state.target) {
  4844. state.didFirePressStart && state.pointerType != null && triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e2), state.pointerType, !1), state.isPressed = !1, state.isOverTarget = !1, state.activePointerId = null, state.pointerType = null, removeAllGlobalListeners(), allowTextSelectionOnPress || $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
  4845. for (let dispose of state.disposables) dispose();
  4846. state.disposables = [];
  4847. }
  4848. }), cancelOnPointerExit = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4849. shouldCancelOnPointerExit && cancel(e2);
  4850. }), triggerClick = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4851. isDisabled || onClick?.(e2);
  4852. }), triggerSyntheticClick = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2, target) => {
  4853. if (!isDisabled && onClick) {
  4854. let event = new MouseEvent("click", e2);
  4855. $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target), onClick($8a9cb279dc87e130$export$525bc4921d56d4a(event));
  4856. }
  4857. }), pressProps = useMemo(() => {
  4858. let state = ref.current, pressProps2 = {
  4859. onKeyDown(e2) {
  4860. if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e2.nativeEvent, e2.currentTarget) && $d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent))) {
  4861. var _state_metaKeyEvents;
  4862. $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard($d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent), e2.key) && e2.preventDefault();
  4863. let shouldStopPropagation = !0;
  4864. if (!state.isPressed && !e2.repeat) {
  4865. state.target = e2.currentTarget, state.isPressed = !0, state.pointerType = "keyboard", shouldStopPropagation = triggerPressStart(e2, "keyboard");
  4866. let originalTarget = e2.currentTarget, pressUp = (e3) => {
  4867. $f6c31cce2adf654f$var$isValidKeyboardEvent(e3, originalTarget) && !e3.repeat && $d4ee10de306f2510$export$4282f70798064fe0(originalTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e3)) && state.target && triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e3), "keyboard");
  4868. };
  4869. addGlobalListener($431fbd86ca7dc216$export$b204af158042fbac(e2.currentTarget), "keyup", $ff5963eb1fccf552$export$e08e3b67e392101e(pressUp, onKeyUp), !0);
  4870. }
  4871. shouldStopPropagation && e2.stopPropagation(), e2.metaKey && $c87311424ea30a05$export$9ac100e40613ea10() && ((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 || _state_metaKeyEvents.set(e2.key, e2.nativeEvent));
  4872. } else e2.key === "Meta" && (state.metaKeyEvents = /* @__PURE__ */ new Map());
  4873. },
  4874. onClick(e2) {
  4875. if (!(e2 && !$d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent))) && e2 && e2.button === 0 && !state.isTriggeringEvent && !$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening) {
  4876. let shouldStopPropagation = !0;
  4877. if (isDisabled && e2.preventDefault(), !state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === "virtual" || $6a7db85432448f7f$export$60278871457622de(e2.nativeEvent))) {
  4878. let stopPressStart = triggerPressStart(e2, "virtual"), stopPressUp = triggerPressUp(e2, "virtual"), stopPressEnd = triggerPressEnd(e2, "virtual");
  4879. triggerClick(e2), shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
  4880. } else if (state.isPressed && state.pointerType !== "keyboard") {
  4881. let pointerType = state.pointerType || e2.nativeEvent.pointerType || "virtual", stopPressUp = triggerPressUp($f6c31cce2adf654f$var$createEvent(e2.currentTarget, e2), pointerType), stopPressEnd = triggerPressEnd($f6c31cce2adf654f$var$createEvent(e2.currentTarget, e2), pointerType, !0);
  4882. shouldStopPropagation = stopPressUp && stopPressEnd, state.isOverTarget = !1, triggerClick(e2), cancel(e2);
  4883. }
  4884. state.ignoreEmulatedMouseEvents = !1, shouldStopPropagation && e2.stopPropagation();
  4885. }
  4886. }
  4887. }, onKeyUp = (e2) => {
  4888. var _state_metaKeyEvents;
  4889. if (state.isPressed && state.target && $f6c31cce2adf654f$var$isValidKeyboardEvent(e2, state.target)) {
  4890. var _state_metaKeyEvents1;
  4891. $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard($d4ee10de306f2510$export$e58f029f0fbfdb29(e2), e2.key) && e2.preventDefault();
  4892. let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e2), wasPressed = $d4ee10de306f2510$export$4282f70798064fe0(state.target, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2));
  4893. triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e2), "keyboard", wasPressed), wasPressed && triggerSyntheticClick(e2, state.target), removeAllGlobalListeners(), e2.key !== "Enter" && $f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) && $d4ee10de306f2510$export$4282f70798064fe0(state.target, target) && !e2[$f6c31cce2adf654f$var$LINK_CLICKED] && (e2[$f6c31cce2adf654f$var$LINK_CLICKED] = !0, $ea8dcbcb9ea1b556$export$95185d699e05d4d7(state.target, e2, !1)), state.isPressed = !1, (_state_metaKeyEvents1 = state.metaKeyEvents) === null || _state_metaKeyEvents1 === void 0 || _state_metaKeyEvents1.delete(e2.key);
  4894. } else if (e2.key === "Meta" && (!((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0) && _state_metaKeyEvents.size)) {
  4895. var _state_target;
  4896. let events2 = state.metaKeyEvents;
  4897. state.metaKeyEvents = void 0;
  4898. for (let event of events2.values()) (_state_target = state.target) === null || _state_target === void 0 || _state_target.dispatchEvent(new KeyboardEvent("keyup", event));
  4899. }
  4900. };
  4901. if (typeof PointerEvent < "u") {
  4902. pressProps2.onPointerDown = (e2) => {
  4903. if (e2.button !== 0 || !$d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent))) return;
  4904. if ($6a7db85432448f7f$export$29bf1b5f2c56cf63(e2.nativeEvent)) {
  4905. state.pointerType = "virtual";
  4906. return;
  4907. }
  4908. state.pointerType = e2.pointerType;
  4909. let shouldStopPropagation = !0;
  4910. if (!state.isPressed) {
  4911. state.isPressed = !0, state.isOverTarget = !0, state.activePointerId = e2.pointerId, state.target = e2.currentTarget, allowTextSelectionOnPress || $14c0b72509d70225$export$16a4697467175487(state.target), shouldStopPropagation = triggerPressStart(e2, state.pointerType);
  4912. let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent);
  4913. "releasePointerCapture" in target && target.releasePointerCapture(e2.pointerId), addGlobalListener($431fbd86ca7dc216$export$b204af158042fbac(e2.currentTarget), "pointerup", onPointerUp, !1), addGlobalListener($431fbd86ca7dc216$export$b204af158042fbac(e2.currentTarget), "pointercancel", onPointerCancel, !1);
  4914. }
  4915. shouldStopPropagation && e2.stopPropagation();
  4916. }, pressProps2.onMouseDown = (e2) => {
  4917. if ($d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent)) && e2.button === 0) {
  4918. if (preventFocusOnPress) {
  4919. let dispose = $8a9cb279dc87e130$export$cabe61c495ee3649(e2.target);
  4920. dispose && state.disposables.push(dispose);
  4921. }
  4922. e2.stopPropagation();
  4923. }
  4924. }, pressProps2.onPointerUp = (e2) => {
  4925. !$d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent)) || state.pointerType === "virtual" || e2.button === 0 && !state.isPressed && triggerPressUp(e2, state.pointerType || e2.pointerType);
  4926. }, pressProps2.onPointerEnter = (e2) => {
  4927. e2.pointerId === state.activePointerId && state.target && !state.isOverTarget && state.pointerType != null && (state.isOverTarget = !0, triggerPressStart($f6c31cce2adf654f$var$createEvent(state.target, e2), state.pointerType));
  4928. }, pressProps2.onPointerLeave = (e2) => {
  4929. e2.pointerId === state.activePointerId && state.target && state.isOverTarget && state.pointerType != null && (state.isOverTarget = !1, triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e2), state.pointerType, !1), cancelOnPointerExit(e2));
  4930. };
  4931. let onPointerUp = (e2) => {
  4932. if (e2.pointerId === state.activePointerId && state.isPressed && e2.button === 0 && state.target) {
  4933. if ($d4ee10de306f2510$export$4282f70798064fe0(state.target, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2)) && state.pointerType != null) {
  4934. let clicked = !1, timeout = setTimeout(() => {
  4935. state.isPressed && state.target instanceof HTMLElement && (clicked ? cancel(e2) : ($7215afc6de606d6b$export$de79e2c695e052f3(state.target), state.target.click()));
  4936. }, 80);
  4937. addGlobalListener(e2.currentTarget, "click", () => clicked = !0, !0), state.disposables.push(() => clearTimeout(timeout));
  4938. } else cancel(e2);
  4939. state.isOverTarget = !1;
  4940. }
  4941. }, onPointerCancel = (e2) => {
  4942. cancel(e2);
  4943. };
  4944. pressProps2.onDragStart = (e2) => {
  4945. $d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent)) && cancel(e2);
  4946. };
  4947. }
  4948. return pressProps2;
  4949. }, [
  4950. addGlobalListener,
  4951. isDisabled,
  4952. preventFocusOnPress,
  4953. removeAllGlobalListeners,
  4954. allowTextSelectionOnPress,
  4955. cancel,
  4956. cancelOnPointerExit,
  4957. triggerPressEnd,
  4958. triggerPressStart,
  4959. triggerPressUp,
  4960. triggerClick,
  4961. triggerSyntheticClick
  4962. ]);
  4963. return useEffect(() => {
  4964. if (!domRef) return;
  4965. let ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(domRef.current);
  4966. if (!ownerDocument || !ownerDocument.head || ownerDocument.getElementById($f6c31cce2adf654f$var$STYLE_ID)) return;
  4967. let style = ownerDocument.createElement("style");
  4968. style.id = $f6c31cce2adf654f$var$STYLE_ID, style.textContent = `
  4969. @layer {
  4970. [${$f6c31cce2adf654f$var$PRESSABLE_ATTRIBUTE}] {
  4971. touch-action: pan-x pan-y pinch-zoom;
  4972. }
  4973. }
  4974. `.trim(), ownerDocument.head.prepend(style);
  4975. }, [
  4976. domRef
  4977. ]), useEffect(() => {
  4978. let state = ref.current;
  4979. return () => {
  4980. var _state_target;
  4981. allowTextSelectionOnPress || $14c0b72509d70225$export$b0d6fa1ab32e3295((_state_target = state.target) !== null && _state_target !== void 0 ? _state_target : void 0);
  4982. for (let dispose of state.disposables) dispose();
  4983. state.disposables = [];
  4984. };
  4985. }, [
  4986. allowTextSelectionOnPress
  4987. ]), {
  4988. isPressed: isPressedProp || isPressed,
  4989. pressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, pressProps, {
  4990. [$f6c31cce2adf654f$var$PRESSABLE_ATTRIBUTE]: !0
  4991. })
  4992. };
  4993. }
  4994. function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
  4995. return target.tagName === "A" && target.hasAttribute("href");
  4996. }
  4997. function $f6c31cce2adf654f$var$isValidKeyboardEvent(event, currentTarget) {
  4998. let { key, code } = event, element = currentTarget, role = element.getAttribute("role");
  4999. return (key === "Enter" || key === " " || key === "Spacebar" || code === "Space") && !(element instanceof $431fbd86ca7dc216$export$f21a1ffae260145a(element).HTMLInputElement && !$f6c31cce2adf654f$var$isValidInputKey(element, key) || element instanceof $431fbd86ca7dc216$export$f21a1ffae260145a(element).HTMLTextAreaElement || element.isContentEditable) && // Links should only trigger with Enter key
  5000. !((role === "link" || !role && $f6c31cce2adf654f$var$isHTMLAnchorLink(element)) && key !== "Enter");
  5001. }
  5002. function $f6c31cce2adf654f$var$createEvent(target, e2) {
  5003. let clientX = e2.clientX, clientY = e2.clientY;
  5004. return {
  5005. currentTarget: target,
  5006. shiftKey: e2.shiftKey,
  5007. ctrlKey: e2.ctrlKey,
  5008. metaKey: e2.metaKey,
  5009. altKey: e2.altKey,
  5010. clientX,
  5011. clientY
  5012. };
  5013. }
  5014. function $f6c31cce2adf654f$var$shouldPreventDefaultUp(target) {
  5015. return target instanceof HTMLInputElement ? !1 : target instanceof HTMLButtonElement ? target.type !== "submit" && target.type !== "reset" : !$f6c31cce2adf654f$var$isHTMLAnchorLink(target);
  5016. }
  5017. function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target, key) {
  5018. return target instanceof HTMLInputElement ? !$f6c31cce2adf654f$var$isValidInputKey(target, key) : $f6c31cce2adf654f$var$shouldPreventDefaultUp(target);
  5019. }
  5020. var $f6c31cce2adf654f$var$nonTextInputTypes = /* @__PURE__ */ new Set([
  5021. "checkbox",
  5022. "radio",
  5023. "range",
  5024. "color",
  5025. "file",
  5026. "image",
  5027. "button",
  5028. "submit",
  5029. "reset"
  5030. ]);
  5031. function $f6c31cce2adf654f$var$isValidInputKey(target, key) {
  5032. return target.type === "checkbox" || target.type === "radio" ? key === " " : $f6c31cce2adf654f$var$nonTextInputTypes.has(target.type);
  5033. }
  5034. // ../../node_modules/@react-aria/interactions/dist/useFocusVisible.mjs
  5035. init_react();
  5036. var $507fabe10e71c6fb$var$currentModality = null, $507fabe10e71c6fb$var$changeHandlers = /* @__PURE__ */ new Set(), $507fabe10e71c6fb$export$d90243b58daecda7 = /* @__PURE__ */ new Map(), $507fabe10e71c6fb$var$hasEventBeforeFocus = !1, $507fabe10e71c6fb$var$hasBlurredWindowRecently = !1;
  5037. function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e2) {
  5038. for (let handler of $507fabe10e71c6fb$var$changeHandlers) handler(modality, e2);
  5039. }
  5040. function $507fabe10e71c6fb$var$isValidKey(e2) {
  5041. return !(e2.metaKey || !$c87311424ea30a05$export$9ac100e40613ea10() && e2.altKey || e2.ctrlKey || e2.key === "Control" || e2.key === "Shift" || e2.key === "Meta");
  5042. }
  5043. function $507fabe10e71c6fb$var$handleKeyboardEvent(e2) {
  5044. $507fabe10e71c6fb$var$hasEventBeforeFocus = !0, $507fabe10e71c6fb$var$isValidKey(e2) && ($507fabe10e71c6fb$var$currentModality = "keyboard", $507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e2));
  5045. }
  5046. function $507fabe10e71c6fb$var$handlePointerEvent(e2) {
  5047. $507fabe10e71c6fb$var$currentModality = "pointer", (e2.type === "mousedown" || e2.type === "pointerdown") && ($507fabe10e71c6fb$var$hasEventBeforeFocus = !0, $507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e2));
  5048. }
  5049. function $507fabe10e71c6fb$var$handleClickEvent(e2) {
  5050. $6a7db85432448f7f$export$60278871457622de(e2) && ($507fabe10e71c6fb$var$hasEventBeforeFocus = !0, $507fabe10e71c6fb$var$currentModality = "virtual");
  5051. }
  5052. function $507fabe10e71c6fb$var$handleFocusEvent(e2) {
  5053. e2.target === window || e2.target === document || $8a9cb279dc87e130$export$fda7da73ab5d4c48 || !e2.isTrusted || (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently && ($507fabe10e71c6fb$var$currentModality = "virtual", $507fabe10e71c6fb$var$triggerChangeHandlers("virtual", e2)), $507fabe10e71c6fb$var$hasEventBeforeFocus = !1, $507fabe10e71c6fb$var$hasBlurredWindowRecently = !1);
  5054. }
  5055. function $507fabe10e71c6fb$var$handleWindowBlur() {
  5056. $8a9cb279dc87e130$export$fda7da73ab5d4c48 || ($507fabe10e71c6fb$var$hasEventBeforeFocus = !1, $507fabe10e71c6fb$var$hasBlurredWindowRecently = !0);
  5057. }
  5058. function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
  5059. if (typeof window > "u" || typeof document > "u" || $507fabe10e71c6fb$export$d90243b58daecda7.get($431fbd86ca7dc216$export$f21a1ffae260145a(element))) return;
  5060. let windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element), documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element), focus = windowObject.HTMLElement.prototype.focus;
  5061. windowObject.HTMLElement.prototype.focus = function() {
  5062. $507fabe10e71c6fb$var$hasEventBeforeFocus = !0, focus.apply(this, arguments);
  5063. }, documentObject.addEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, !0), documentObject.addEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, !0), documentObject.addEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, !0), windowObject.addEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, !0), windowObject.addEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, !1), typeof PointerEvent < "u" && (documentObject.addEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, !0), documentObject.addEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, !0), documentObject.addEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, !0)), windowObject.addEventListener("beforeunload", () => {
  5064. $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
  5065. }, {
  5066. once: !0
  5067. }), $507fabe10e71c6fb$export$d90243b58daecda7.set(windowObject, {
  5068. focus
  5069. });
  5070. }
  5071. var $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener) => {
  5072. let windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element), documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element);
  5073. loadListener && documentObject.removeEventListener("DOMContentLoaded", loadListener), $507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject) && (windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus, documentObject.removeEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, !0), documentObject.removeEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, !0), documentObject.removeEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, !0), windowObject.removeEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, !0), windowObject.removeEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, !1), typeof PointerEvent < "u" && (documentObject.removeEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, !0), documentObject.removeEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, !0), documentObject.removeEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, !0)), $507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject));
  5074. };
  5075. function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
  5076. let documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element), loadListener;
  5077. return documentObject.readyState !== "loading" ? $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) : (loadListener = () => {
  5078. $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
  5079. }, documentObject.addEventListener("DOMContentLoaded", loadListener)), () => $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
  5080. }
  5081. typeof document < "u" && $507fabe10e71c6fb$export$2f1888112f558a7d();
  5082. function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
  5083. return $507fabe10e71c6fb$var$currentModality !== "pointer";
  5084. }
  5085. function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
  5086. return $507fabe10e71c6fb$var$currentModality;
  5087. }
  5088. // ../../node_modules/@react-aria/interactions/dist/focusSafely.mjs
  5089. function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
  5090. let ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(element), activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
  5091. if ($507fabe10e71c6fb$export$630ff653c5ada6a9() === "virtual") {
  5092. let lastFocusedElement = activeElement;
  5093. $bbed8b41f857bcc0$export$24490316f764c430(() => {
  5094. $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument) === lastFocusedElement && element.isConnected && $7215afc6de606d6b$export$de79e2c695e052f3(element);
  5095. });
  5096. } else $7215afc6de606d6b$export$de79e2c695e052f3(element);
  5097. }
  5098. // ../../node_modules/@react-aria/interactions/dist/useFocus.mjs
  5099. init_react();
  5100. function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
  5101. let { isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange } = props, onBlur = useCallback((e2) => {
  5102. if (e2.target === e2.currentTarget)
  5103. return onBlurProp && onBlurProp(e2), onFocusChange && onFocusChange(!1), !0;
  5104. }, [
  5105. onBlurProp,
  5106. onFocusChange
  5107. ]), onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur), onFocus = useCallback((e2) => {
  5108. let ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(e2.target), activeElement = ownerDocument ? $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument) : $d4ee10de306f2510$export$cd4e5573fbe2b576();
  5109. e2.target === e2.currentTarget && activeElement === $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent) && (onFocusProp && onFocusProp(e2), onFocusChange && onFocusChange(!0), onSyntheticFocus(e2));
  5110. }, [
  5111. onFocusChange,
  5112. onFocusProp,
  5113. onSyntheticFocus
  5114. ]);
  5115. return {
  5116. focusProps: {
  5117. onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : void 0,
  5118. onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : void 0
  5119. }
  5120. };
  5121. }
  5122. // ../../node_modules/@react-aria/interactions/dist/createEventHandler.mjs
  5123. function $93925083ecbb358c$export$48d1ea6320830260(handler) {
  5124. if (!handler) return;
  5125. let shouldStopPropagation = !0;
  5126. return (e2) => {
  5127. let event = {
  5128. ...e2,
  5129. preventDefault() {
  5130. e2.preventDefault();
  5131. },
  5132. isDefaultPrevented() {
  5133. return e2.isDefaultPrevented();
  5134. },
  5135. stopPropagation() {
  5136. shouldStopPropagation = !0;
  5137. },
  5138. continuePropagation() {
  5139. shouldStopPropagation = !1;
  5140. },
  5141. isPropagationStopped() {
  5142. return shouldStopPropagation;
  5143. }
  5144. };
  5145. handler(event), shouldStopPropagation && e2.stopPropagation();
  5146. };
  5147. }
  5148. // ../../node_modules/@react-aria/interactions/dist/useKeyboard.mjs
  5149. function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
  5150. return {
  5151. keyboardProps: props.isDisabled ? {} : {
  5152. onKeyDown: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyDown),
  5153. onKeyUp: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyUp)
  5154. }
  5155. };
  5156. }
  5157. // ../../node_modules/@react-aria/interactions/dist/useFocusable.mjs
  5158. init_react();
  5159. var $f645667febf57a63$export$f9762fab77588ecb = react_default.createContext(null);
  5160. function $f645667febf57a63$var$useFocusableContext(ref) {
  5161. let context = useContext($f645667febf57a63$export$f9762fab77588ecb) || {};
  5162. $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref);
  5163. let { ref: _2, ...otherProps } = context;
  5164. return otherProps;
  5165. }
  5166. var $f645667febf57a63$export$13f3202a3e5ddd5 = react_default.forwardRef(function(props, ref) {
  5167. let { children, ...otherProps } = props, objRef = $df56164dff5785e2$export$4338b53315abf666(ref), context = {
  5168. ...otherProps,
  5169. ref: objRef
  5170. };
  5171. return react_default.createElement($f645667febf57a63$export$f9762fab77588ecb.Provider, {
  5172. value: context
  5173. }, children);
  5174. });
  5175. function $f645667febf57a63$export$4c014de7c8940b4c(props, domRef) {
  5176. let { focusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props), { keyboardProps } = $46d819fcbaf35654$export$8f71654801c2f7cd(props), interactions = $3ef42575df84b30b$export$9d1611c77c2fe928(focusProps, keyboardProps), domProps = $f645667febf57a63$var$useFocusableContext(domRef), interactionProps = props.isDisabled ? {} : domProps, autoFocusRef = useRef(props.autoFocus);
  5177. useEffect(() => {
  5178. autoFocusRef.current && domRef.current && $3ad3f6e1647bc98d$export$80f3e147d781571c(domRef.current), autoFocusRef.current = !1;
  5179. }, [
  5180. domRef
  5181. ]);
  5182. let tabIndex = props.excludeFromTabOrder ? -1 : 0;
  5183. return props.isDisabled && (tabIndex = void 0), {
  5184. focusableProps: $3ef42575df84b30b$export$9d1611c77c2fe928({
  5185. ...interactions,
  5186. tabIndex
  5187. }, interactionProps)
  5188. };
  5189. }
  5190. var $f645667febf57a63$export$35a3bebf7ef2d934 = forwardRef(({ children, ...props }, ref) => {
  5191. ref = $df56164dff5785e2$export$4338b53315abf666(ref);
  5192. let { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c(props, ref), child = react_default.Children.only(children);
  5193. useEffect(() => {
  5194. }, [
  5195. ref,
  5196. props.isDisabled
  5197. ]);
  5198. let childRef = parseInt(react_default.version, 10) < 19 ? child.ref : child.props.ref;
  5199. return react_default.cloneElement(child, {
  5200. ...$3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, child.props),
  5201. // @ts-ignore
  5202. ref: $5dc95899b306f630$export$c9058316764c140e(childRef, ref)
  5203. });
  5204. });
  5205. // ../../node_modules/@react-aria/interactions/dist/Pressable.mjs
  5206. init_react();
  5207. var $3b117e43dc0ca95d$export$27c701ed9e449e99 = react_default.forwardRef(({ children, ...props }, ref) => {
  5208. ref = $df56164dff5785e2$export$4338b53315abf666(ref);
  5209. let { pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
  5210. ...props,
  5211. ref
  5212. }), { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c(props, ref), child = react_default.Children.only(children);
  5213. useEffect(() => {
  5214. }, [
  5215. ref,
  5216. props.isDisabled
  5217. ]);
  5218. let childRef = parseInt(react_default.version, 10) < 19 ? child.ref : child.props.ref;
  5219. return react_default.cloneElement(child, {
  5220. ...$3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, focusableProps, child.props),
  5221. // @ts-ignore
  5222. ref: $5dc95899b306f630$export$c9058316764c140e(childRef, ref)
  5223. });
  5224. });
  5225. // ../../node_modules/@react-aria/interactions/dist/PressResponder.mjs
  5226. init_react();
  5227. var $f1ab8c75478c6f73$export$3351871ee4b288b8 = react_default.forwardRef(({ children, ...props }, ref) => {
  5228. let isRegistered = useRef(!1), prevContext = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
  5229. ref = $df56164dff5785e2$export$4338b53315abf666(ref || prevContext?.ref);
  5230. let context = $3ef42575df84b30b$export$9d1611c77c2fe928(prevContext || {}, {
  5231. ...props,
  5232. ref,
  5233. register() {
  5234. isRegistered.current = !0, prevContext && prevContext.register();
  5235. }
  5236. });
  5237. return $e7801be82b4b2a53$export$4debdb1a3f0fa79e(prevContext, ref), useEffect(() => {
  5238. isRegistered.current || (isRegistered.current = !0);
  5239. }, []), react_default.createElement($ae1eeba8b9eafd08$export$5165eccb35aaadb5.Provider, {
  5240. value: context
  5241. }, children);
  5242. });
  5243. // ../../node_modules/@react-aria/interactions/dist/useFocusWithin.mjs
  5244. init_react();
  5245. // ../../node_modules/@react-aria/interactions/dist/useHover.mjs
  5246. init_react();
  5247. var $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = !1, $6179b936705e76d3$var$hoverCount = 0;
  5248. function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
  5249. $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = !0, setTimeout(() => {
  5250. $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = !1;
  5251. }, 50);
  5252. }
  5253. function $6179b936705e76d3$var$handleGlobalPointerEvent(e2) {
  5254. e2.pointerType === "touch" && $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
  5255. }
  5256. function $6179b936705e76d3$var$setupGlobalTouchEvents() {
  5257. if (!(typeof document > "u"))
  5258. return $6179b936705e76d3$var$hoverCount === 0 && typeof PointerEvent < "u" && document.addEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent), $6179b936705e76d3$var$hoverCount++, () => {
  5259. $6179b936705e76d3$var$hoverCount--, !($6179b936705e76d3$var$hoverCount > 0) && typeof PointerEvent < "u" && document.removeEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
  5260. };
  5261. }
  5262. function $6179b936705e76d3$export$ae780daf29e6d456(props) {
  5263. let { onHoverStart, onHoverChange, onHoverEnd, isDisabled } = props, [isHovered, setHovered] = useState(!1), state = useRef({
  5264. isHovered: !1,
  5265. ignoreEmulatedMouseEvents: !1,
  5266. pointerType: "",
  5267. target: null
  5268. }).current;
  5269. useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
  5270. let { addGlobalListener, removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6(), { hoverProps, triggerHoverEnd } = useMemo(() => {
  5271. let triggerHoverStart = (event, pointerType) => {
  5272. if (state.pointerType = pointerType, isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
  5273. state.isHovered = !0;
  5274. let target = event.currentTarget;
  5275. state.target = target, addGlobalListener($431fbd86ca7dc216$export$b204af158042fbac(event.target), "pointerover", (e2) => {
  5276. state.isHovered && state.target && !$d4ee10de306f2510$export$4282f70798064fe0(state.target, e2.target) && triggerHoverEnd2(e2, e2.pointerType);
  5277. }, {
  5278. capture: !0
  5279. }), onHoverStart && onHoverStart({
  5280. type: "hoverstart",
  5281. target,
  5282. pointerType
  5283. }), onHoverChange && onHoverChange(!0), setHovered(!0);
  5284. }, triggerHoverEnd2 = (event, pointerType) => {
  5285. let target = state.target;
  5286. state.pointerType = "", state.target = null, !(pointerType === "touch" || !state.isHovered || !target) && (state.isHovered = !1, removeAllGlobalListeners(), onHoverEnd && onHoverEnd({
  5287. type: "hoverend",
  5288. target,
  5289. pointerType
  5290. }), onHoverChange && onHoverChange(!1), setHovered(!1));
  5291. }, hoverProps2 = {};
  5292. return typeof PointerEvent < "u" && (hoverProps2.onPointerEnter = (e2) => {
  5293. $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e2.pointerType === "mouse" || triggerHoverStart(e2, e2.pointerType);
  5294. }, hoverProps2.onPointerLeave = (e2) => {
  5295. !isDisabled && e2.currentTarget.contains(e2.target) && triggerHoverEnd2(e2, e2.pointerType);
  5296. }), {
  5297. hoverProps: hoverProps2,
  5298. triggerHoverEnd: triggerHoverEnd2
  5299. };
  5300. }, [
  5301. onHoverStart,
  5302. onHoverChange,
  5303. onHoverEnd,
  5304. isDisabled,
  5305. state,
  5306. addGlobalListener,
  5307. removeAllGlobalListeners
  5308. ]);
  5309. return useEffect(() => {
  5310. isDisabled && triggerHoverEnd({
  5311. currentTarget: state.target
  5312. }, state.pointerType);
  5313. }, [
  5314. isDisabled
  5315. ]), {
  5316. hoverProps,
  5317. isHovered
  5318. };
  5319. }
  5320. // ../../node_modules/@react-aria/interactions/dist/useInteractOutside.mjs
  5321. init_react();
  5322. // ../../node_modules/@react-aria/interactions/dist/useMove.mjs
  5323. init_react();
  5324. // ../../node_modules/@react-aria/interactions/dist/useScrollWheel.mjs
  5325. init_react();
  5326. // ../../node_modules/@react-aria/interactions/dist/useLongPress.mjs
  5327. init_react();
  5328. // ../../node_modules/react-aria-components/dist/utils.mjs
  5329. init_react();
  5330. var $64fa3d84918910a7$export$c62b8e45d58ddad9 = Symbol("default");
  5331. function $64fa3d84918910a7$export$2881499e37b75b9a({ values, children }) {
  5332. for (let [Context2, value] of values)
  5333. children = react_default.createElement(Context2.Provider, {
  5334. value
  5335. }, children);
  5336. return children;
  5337. }
  5338. function $64fa3d84918910a7$export$4d86445c2cf5e3(props) {
  5339. let { className, style, children, defaultClassName, defaultChildren, defaultStyle, values } = props;
  5340. return useMemo(() => {
  5341. let computedClassName, computedStyle, computedChildren;
  5342. return typeof className == "function" ? computedClassName = className({
  5343. ...values,
  5344. defaultClassName
  5345. }) : computedClassName = className, typeof style == "function" ? computedStyle = style({
  5346. ...values,
  5347. defaultStyle: defaultStyle || {}
  5348. }) : computedStyle = style, typeof children == "function" ? computedChildren = children({
  5349. ...values,
  5350. defaultChildren
  5351. }) : children == null ? computedChildren = defaultChildren : computedChildren = children, {
  5352. className: computedClassName ?? defaultClassName,
  5353. style: computedStyle || defaultStyle ? {
  5354. ...defaultStyle,
  5355. ...computedStyle
  5356. } : void 0,
  5357. children: computedChildren ?? defaultChildren,
  5358. "data-rac": ""
  5359. };
  5360. }, [
  5361. className,
  5362. style,
  5363. children,
  5364. defaultClassName,
  5365. defaultChildren,
  5366. defaultStyle,
  5367. values
  5368. ]);
  5369. }
  5370. function $64fa3d84918910a7$export$fabf2dc03a41866e(context, slot) {
  5371. let ctx = useContext(context);
  5372. if (slot === null)
  5373. return null;
  5374. if (ctx && typeof ctx == "object" && "slots" in ctx && ctx.slots) {
  5375. let slotKey = slot || $64fa3d84918910a7$export$c62b8e45d58ddad9;
  5376. if (!ctx.slots[slotKey]) {
  5377. let availableSlots = new Intl.ListFormat().format(Object.keys(ctx.slots).map((p2) => `"${p2}"`)), errorMessage = slot ? `Invalid slot "${slot}".` : "A slot prop is required.";
  5378. throw new Error(`${errorMessage} Valid slot names are ${availableSlots}.`);
  5379. }
  5380. return ctx.slots[slotKey];
  5381. }
  5382. return ctx;
  5383. }
  5384. function $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, context) {
  5385. let ctx = $64fa3d84918910a7$export$fabf2dc03a41866e(context, props.slot) || {}, { ref: contextRef, ...contextProps } = ctx, mergedRef = $df56164dff5785e2$export$4338b53315abf666(useMemo(() => $5dc95899b306f630$export$c9058316764c140e(ref, contextRef), [
  5386. ref,
  5387. contextRef
  5388. ])), mergedProps = $3ef42575df84b30b$export$9d1611c77c2fe928(contextProps, props);
  5389. return "style" in contextProps && contextProps.style && "style" in props && props.style && (typeof contextProps.style == "function" || typeof props.style == "function" ? mergedProps.style = (renderProps) => {
  5390. let contextStyle = typeof contextProps.style == "function" ? contextProps.style(renderProps) : contextProps.style, defaultStyle = {
  5391. ...renderProps.defaultStyle,
  5392. ...contextStyle
  5393. }, style = typeof props.style == "function" ? props.style({
  5394. ...renderProps,
  5395. defaultStyle
  5396. }) : props.style;
  5397. return {
  5398. ...defaultStyle,
  5399. ...style
  5400. };
  5401. } : mergedProps.style = {
  5402. ...contextProps.style,
  5403. ...props.style
  5404. }), [
  5405. mergedProps,
  5406. mergedRef
  5407. ];
  5408. }
  5409. // ../../node_modules/react-aria-components/dist/OverlayArrow.mjs
  5410. init_react();
  5411. var $44f671af83e7d9e0$export$2de4954e8ae13b9f = createContext({
  5412. placement: "bottom"
  5413. }), $44f671af83e7d9e0$export$746d02f47f4d381 = forwardRef(function(props, ref) {
  5414. [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $44f671af83e7d9e0$export$2de4954e8ae13b9f);
  5415. let placement = props.placement, style = {
  5416. position: "absolute",
  5417. transform: placement === "top" || placement === "bottom" ? "translateX(-50%)" : "translateY(-50%)"
  5418. };
  5419. placement != null && (style[placement] = "100%");
  5420. let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
  5421. ...props,
  5422. defaultClassName: "react-aria-OverlayArrow",
  5423. values: {
  5424. placement
  5425. }
  5426. });
  5427. renderProps.style && Object.keys(renderProps.style).forEach((key) => renderProps.style[key] === void 0 && delete renderProps.style[key]);
  5428. let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
  5429. return react_default.createElement("div", {
  5430. ...DOMProps,
  5431. ...renderProps,
  5432. style: {
  5433. ...style,
  5434. ...renderProps.style
  5435. },
  5436. ref,
  5437. "data-placement": placement
  5438. });
  5439. });
  5440. // ../../node_modules/@react-aria/tooltip/dist/useTooltip.mjs
  5441. function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
  5442. let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
  5443. labelable: !0
  5444. }), { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
  5445. onHoverStart: () => state?.open(!0),
  5446. onHoverEnd: () => state?.close()
  5447. });
  5448. return {
  5449. tooltipProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, hoverProps, {
  5450. role: "tooltip"
  5451. })
  5452. };
  5453. }
  5454. // ../../node_modules/@react-aria/tooltip/dist/useTooltipTrigger.mjs
  5455. init_react();
  5456. function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
  5457. let { isDisabled, trigger } = props, tooltipId = $bdb11010cef70236$export$f680877a34711e37(), isHovered = useRef(!1), isFocused = useRef(!1), handleShow = () => {
  5458. (isHovered.current || isFocused.current) && state.open(isFocused.current);
  5459. }, handleHide = (immediate) => {
  5460. !isHovered.current && !isFocused.current && state.close(immediate);
  5461. };
  5462. useEffect(() => {
  5463. let onKeyDown = (e2) => {
  5464. ref && ref.current && e2.key === "Escape" && (e2.stopPropagation(), state.close(!0));
  5465. };
  5466. if (state.isOpen)
  5467. return document.addEventListener("keydown", onKeyDown, !0), () => {
  5468. document.removeEventListener("keydown", onKeyDown, !0);
  5469. };
  5470. }, [
  5471. ref,
  5472. state
  5473. ]);
  5474. let onHoverStart = () => {
  5475. trigger !== "focus" && ($507fabe10e71c6fb$export$630ff653c5ada6a9() === "pointer" ? isHovered.current = !0 : isHovered.current = !1, handleShow());
  5476. }, onHoverEnd = () => {
  5477. trigger !== "focus" && (isFocused.current = !1, isHovered.current = !1, handleHide());
  5478. }, onPressStart = () => {
  5479. isFocused.current = !1, isHovered.current = !1, handleHide(!0);
  5480. }, onFocus = () => {
  5481. $507fabe10e71c6fb$export$b9b3dfddab17db27() && (isFocused.current = !0, handleShow());
  5482. }, onBlur = () => {
  5483. isFocused.current = !1, isHovered.current = !1, handleHide(!0);
  5484. }, { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
  5485. isDisabled,
  5486. onHoverStart,
  5487. onHoverEnd
  5488. }), { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c({
  5489. isDisabled,
  5490. onFocus,
  5491. onBlur
  5492. }, ref);
  5493. return {
  5494. triggerProps: {
  5495. "aria-describedby": state.isOpen ? tooltipId : void 0,
  5496. ...$3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, hoverProps, {
  5497. onPointerDown: onPressStart,
  5498. onKeyDown: onPressStart
  5499. }),
  5500. tabIndex: void 0
  5501. },
  5502. tooltipProps: {
  5503. id: tooltipId
  5504. }
  5505. };
  5506. }
  5507. // ../../node_modules/@react-aria/overlays/dist/calculatePosition.mjs
  5508. var $edcf132a9284368a$var$AXIS = {
  5509. top: "top",
  5510. bottom: "top",
  5511. left: "left",
  5512. right: "left"
  5513. }, $edcf132a9284368a$var$FLIPPED_DIRECTION = {
  5514. top: "bottom",
  5515. bottom: "top",
  5516. left: "right",
  5517. right: "left"
  5518. }, $edcf132a9284368a$var$CROSS_AXIS = {
  5519. top: "left",
  5520. left: "top"
  5521. }, $edcf132a9284368a$var$AXIS_SIZE = {
  5522. top: "height",
  5523. left: "width"
  5524. }, $edcf132a9284368a$var$TOTAL_SIZE = {
  5525. width: "totalWidth",
  5526. height: "totalHeight"
  5527. }, $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {}, $edcf132a9284368a$var$visualViewport = typeof document < "u" ? window.visualViewport : null;
  5528. function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
  5529. let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0, scroll2 = {};
  5530. var _visualViewport_scale;
  5531. let isPinchZoomedIn = ((_visualViewport_scale = $edcf132a9284368a$var$visualViewport?.scale) !== null && _visualViewport_scale !== void 0 ? _visualViewport_scale : 1) > 1;
  5532. if (containerNode.tagName === "BODY") {
  5533. let documentElement = document.documentElement;
  5534. totalWidth = documentElement.clientWidth, totalHeight = documentElement.clientHeight;
  5535. var _visualViewport_width;
  5536. width = (_visualViewport_width = $edcf132a9284368a$var$visualViewport?.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
  5537. var _visualViewport_height;
  5538. height = (_visualViewport_height = $edcf132a9284368a$var$visualViewport?.height) !== null && _visualViewport_height !== void 0 ? _visualViewport_height : totalHeight, scroll2.top = documentElement.scrollTop || containerNode.scrollTop, scroll2.left = documentElement.scrollLeft || containerNode.scrollLeft, $edcf132a9284368a$var$visualViewport && (top = $edcf132a9284368a$var$visualViewport.offsetTop, left = $edcf132a9284368a$var$visualViewport.offsetLeft);
  5539. } else
  5540. ({ width, height, top, left } = $edcf132a9284368a$var$getOffset(containerNode, !1)), scroll2.top = containerNode.scrollTop, scroll2.left = containerNode.scrollLeft, totalWidth = width, totalHeight = height;
  5541. if ($c87311424ea30a05$export$78551043582a6a98() && (containerNode.tagName === "BODY" || containerNode.tagName === "HTML") && isPinchZoomedIn) {
  5542. scroll2.top = 0, scroll2.left = 0;
  5543. var _visualViewport_pageTop;
  5544. top = (_visualViewport_pageTop = $edcf132a9284368a$var$visualViewport?.pageTop) !== null && _visualViewport_pageTop !== void 0 ? _visualViewport_pageTop : 0;
  5545. var _visualViewport_pageLeft;
  5546. left = (_visualViewport_pageLeft = $edcf132a9284368a$var$visualViewport?.pageLeft) !== null && _visualViewport_pageLeft !== void 0 ? _visualViewport_pageLeft : 0;
  5547. }
  5548. return {
  5549. width,
  5550. height,
  5551. totalWidth,
  5552. totalHeight,
  5553. scroll: scroll2,
  5554. top,
  5555. left
  5556. };
  5557. }
  5558. function $edcf132a9284368a$var$getScroll(node) {
  5559. return {
  5560. top: node.scrollTop,
  5561. left: node.scrollLeft,
  5562. width: node.scrollWidth,
  5563. height: node.scrollHeight
  5564. };
  5565. }
  5566. function $edcf132a9284368a$var$getDelta(axis, offset2, size, boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary) {
  5567. var _containerDimensions_scroll_axis;
  5568. let containerScroll = (_containerDimensions_scroll_axis = containerDimensions.scroll[axis]) !== null && _containerDimensions_scroll_axis !== void 0 ? _containerDimensions_scroll_axis : 0, boundarySize = boundaryDimensions[$edcf132a9284368a$var$AXIS_SIZE[axis]], boundaryStartEdge = boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] + padding, boundaryEndEdge = boundarySize + boundaryDimensions.scroll[$edcf132a9284368a$var$AXIS[axis]] - padding, startEdgeOffset = offset2 - containerScroll + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]], endEdgeOffset = offset2 - containerScroll + size + containerOffsetWithBoundary[axis] - boundaryDimensions[$edcf132a9284368a$var$AXIS[axis]];
  5569. return startEdgeOffset < boundaryStartEdge ? boundaryStartEdge - startEdgeOffset : endEdgeOffset > boundaryEndEdge ? Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset) : 0;
  5570. }
  5571. function $edcf132a9284368a$var$getMargins(node) {
  5572. let style = window.getComputedStyle(node);
  5573. return {
  5574. top: parseInt(style.marginTop, 10) || 0,
  5575. bottom: parseInt(style.marginBottom, 10) || 0,
  5576. left: parseInt(style.marginLeft, 10) || 0,
  5577. right: parseInt(style.marginRight, 10) || 0
  5578. };
  5579. }
  5580. function $edcf132a9284368a$var$parsePlacement(input) {
  5581. if ($edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input]) return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
  5582. let [placement, crossPlacement] = input.split(" "), axis = $edcf132a9284368a$var$AXIS[placement] || "right", crossAxis = $edcf132a9284368a$var$CROSS_AXIS[axis];
  5583. $edcf132a9284368a$var$AXIS[crossPlacement] || (crossPlacement = "center");
  5584. let size = $edcf132a9284368a$var$AXIS_SIZE[axis], crossSize = $edcf132a9284368a$var$AXIS_SIZE[crossAxis];
  5585. return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input] = {
  5586. placement,
  5587. crossPlacement,
  5588. axis,
  5589. crossAxis,
  5590. size,
  5591. crossSize
  5592. }, $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
  5593. }
  5594. function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset2, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
  5595. let { placement, crossPlacement, axis, crossAxis, size, crossSize } = placementInfo, position = {};
  5596. var _childOffset_crossAxis;
  5597. position[crossAxis] = (_childOffset_crossAxis = childOffset[crossAxis]) !== null && _childOffset_crossAxis !== void 0 ? _childOffset_crossAxis : 0;
  5598. var _childOffset_crossSize, _overlaySize_crossSize, _childOffset_crossSize1, _overlaySize_crossSize1;
  5599. crossPlacement === "center" ? position[crossAxis] += (((_childOffset_crossSize = childOffset[crossSize]) !== null && _childOffset_crossSize !== void 0 ? _childOffset_crossSize : 0) - ((_overlaySize_crossSize = overlaySize[crossSize]) !== null && _overlaySize_crossSize !== void 0 ? _overlaySize_crossSize : 0)) / 2 : crossPlacement !== crossAxis && (position[crossAxis] += ((_childOffset_crossSize1 = childOffset[crossSize]) !== null && _childOffset_crossSize1 !== void 0 ? _childOffset_crossSize1 : 0) - ((_overlaySize_crossSize1 = overlaySize[crossSize]) !== null && _overlaySize_crossSize1 !== void 0 ? _overlaySize_crossSize1 : 0)), position[crossAxis] += crossOffset;
  5600. let minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset, maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
  5601. if (position[crossAxis] = $9446cca9a3875146$export$7d15b64cf5a3a4c4(position[crossAxis], minPosition, maxPosition), placement === axis) {
  5602. let containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
  5603. position[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset2);
  5604. } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset2);
  5605. return position;
  5606. }
  5607. function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
  5608. let containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height];
  5609. var _position_bottom;
  5610. let overlayTop = position.top != null ? containerOffsetWithBoundary.top + position.top : containerOffsetWithBoundary.top + (containerHeight - ((_position_bottom = position.bottom) !== null && _position_bottom !== void 0 ? _position_bottom : 0) - overlayHeight);
  5611. var _boundaryDimensions_scroll_top, _margins_top, _margins_bottom, _boundaryDimensions_scroll_top1, _margins_top1, _margins_bottom1;
  5612. let maxHeight = heightGrowthDirection !== "top" ? (
  5613. // We want the distance between the top of the overlay to the bottom of the boundary
  5614. Math.max(0, boundaryDimensions.height + boundaryDimensions.top + ((_boundaryDimensions_scroll_top = boundaryDimensions.scroll.top) !== null && _boundaryDimensions_scroll_top !== void 0 ? _boundaryDimensions_scroll_top : 0) - overlayTop - (((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0) + padding))
  5615. ) : Math.max(0, overlayTop + overlayHeight - (boundaryDimensions.top + ((_boundaryDimensions_scroll_top1 = boundaryDimensions.scroll.top) !== null && _boundaryDimensions_scroll_top1 !== void 0 ? _boundaryDimensions_scroll_top1 : 0)) - (((_margins_top1 = margins.top) !== null && _margins_top1 !== void 0 ? _margins_top1 : 0) + ((_margins_bottom1 = margins.bottom) !== null && _margins_bottom1 !== void 0 ? _margins_bottom1 : 0) + padding));
  5616. return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
  5617. }
  5618. function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
  5619. let { placement, axis, size } = placementInfo;
  5620. var _boundaryDimensions_scroll_axis, _margins_axis;
  5621. if (placement === axis) return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - ((_boundaryDimensions_scroll_axis = boundaryDimensions.scroll[axis]) !== null && _boundaryDimensions_scroll_axis !== void 0 ? _boundaryDimensions_scroll_axis : 0) + containerOffsetWithBoundary[axis] - ((_margins_axis = margins[axis]) !== null && _margins_axis !== void 0 ? _margins_axis : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
  5622. var _margins_axis1;
  5623. return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - ((_margins_axis1 = margins[axis]) !== null && _margins_axis1 !== void 0 ? _margins_axis1 : 0) - margins[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] - padding);
  5624. }
  5625. function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip2, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset2, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
  5626. let placementInfo = $edcf132a9284368a$var$parsePlacement(placementInput), { size, crossAxis, crossSize, placement, crossPlacement } = placementInfo, position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset2, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset), normalizedOffset = offset2, space = $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset2, placementInfo);
  5627. if (flip2 && scrollSize[size] > space) {
  5628. let flippedPlacementInfo = $edcf132a9284368a$var$parsePlacement(`${$edcf132a9284368a$var$FLIPPED_DIRECTION[placement]} ${crossPlacement}`), flippedPosition = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset2, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset);
  5629. $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset2, flippedPlacementInfo) > space && (placementInfo = flippedPlacementInfo, position = flippedPosition, normalizedOffset = offset2);
  5630. }
  5631. let heightGrowthDirection = "bottom";
  5632. placementInfo.axis === "top" ? placementInfo.placement === "top" ? heightGrowthDirection = "top" : placementInfo.placement === "bottom" && (heightGrowthDirection = "bottom") : placementInfo.crossAxis === "top" && (placementInfo.crossPlacement === "top" ? heightGrowthDirection = "bottom" : placementInfo.crossPlacement === "bottom" && (heightGrowthDirection = "top"));
  5633. let delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
  5634. position[crossAxis] += delta;
  5635. let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
  5636. userSetMaxHeight && userSetMaxHeight < maxHeight && (maxHeight = userSetMaxHeight), overlaySize.height = Math.min(overlaySize.height, maxHeight), position = $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, normalizedOffset, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset), delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary), position[crossAxis] += delta;
  5637. let arrowPosition = {}, origin = childOffset[crossAxis] - position[crossAxis] - margins[$edcf132a9284368a$var$AXIS[crossAxis]], preferredArrowPosition = origin + 0.5 * childOffset[crossSize], arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
  5638. var _margins_left, _margins_right, _margins_top, _margins_bottom;
  5639. let overlayMargin = $edcf132a9284368a$var$AXIS[crossAxis] === "left" ? ((_margins_left = margins.left) !== null && _margins_left !== void 0 ? _margins_left : 0) + ((_margins_right = margins.right) !== null && _margins_right !== void 0 ? _margins_right : 0) : ((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0), arrowMaxPosition = overlaySize[crossSize] - overlayMargin - arrowSize / 2 - arrowBoundaryOffset, arrowOverlappingChildMinEdge = childOffset[crossAxis] + arrowSize / 2 - (position[crossAxis] + margins[$edcf132a9284368a$var$AXIS[crossAxis]]), arrowOverlappingChildMaxEdge = childOffset[crossAxis] + childOffset[crossSize] - arrowSize / 2 - (position[crossAxis] + margins[$edcf132a9284368a$var$AXIS[crossAxis]]), arrowPositionOverlappingChild = $9446cca9a3875146$export$7d15b64cf5a3a4c4(preferredArrowPosition, arrowOverlappingChildMinEdge, arrowOverlappingChildMaxEdge);
  5640. arrowPosition[crossAxis] = $9446cca9a3875146$export$7d15b64cf5a3a4c4(arrowPositionOverlappingChild, arrowMinPosition, arrowMaxPosition), { placement, crossPlacement } = placementInfo, arrowSize ? origin = arrowPosition[crossAxis] : crossPlacement === "right" ? origin += childOffset[crossSize] : crossPlacement === "center" && (origin += childOffset[crossSize] / 2);
  5641. let crossOrigin = placement === "left" || placement === "top" ? overlaySize[size] : 0, triggerAnchorPoint = {
  5642. x: placement === "top" || placement === "bottom" ? origin : crossOrigin,
  5643. y: placement === "left" || placement === "right" ? origin : crossOrigin
  5644. };
  5645. return {
  5646. position,
  5647. maxHeight,
  5648. arrowOffsetLeft: arrowPosition.left,
  5649. arrowOffsetTop: arrowPosition.top,
  5650. placement,
  5651. triggerAnchorPoint
  5652. };
  5653. }
  5654. function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
  5655. let { placement, targetNode, overlayNode, scrollNode, padding, shouldFlip, boundaryElement, offset: offset2, crossOffset, maxHeight, arrowSize = 0, arrowBoundaryOffset = 0 } = opts, container = overlayNode instanceof HTMLElement ? $edcf132a9284368a$var$getContainingBlock(overlayNode) : document.documentElement, isViewportContainer = container === document.documentElement, containerPositionStyle = window.getComputedStyle(container).position, isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== "static", childOffset = isViewportContainer ? $edcf132a9284368a$var$getOffset(targetNode, !1) : $edcf132a9284368a$var$getPosition(targetNode, container, !1);
  5656. if (!isViewportContainer) {
  5657. let { marginTop, marginLeft } = window.getComputedStyle(targetNode);
  5658. childOffset.top += parseInt(marginTop, 10) || 0, childOffset.left += parseInt(marginLeft, 10) || 0;
  5659. }
  5660. let overlaySize = $edcf132a9284368a$var$getOffset(overlayNode, !0), margins = $edcf132a9284368a$var$getMargins(overlayNode);
  5661. var _margins_left, _margins_right;
  5662. overlaySize.width += ((_margins_left = margins.left) !== null && _margins_left !== void 0 ? _margins_left : 0) + ((_margins_right = margins.right) !== null && _margins_right !== void 0 ? _margins_right : 0);
  5663. var _margins_top, _margins_bottom;
  5664. overlaySize.height += ((_margins_top = margins.top) !== null && _margins_top !== void 0 ? _margins_top : 0) + ((_margins_bottom = margins.bottom) !== null && _margins_bottom !== void 0 ? _margins_bottom : 0);
  5665. let scrollSize = $edcf132a9284368a$var$getScroll(scrollNode), boundaryDimensions = $edcf132a9284368a$var$getContainerDimensions(boundaryElement), containerDimensions = $edcf132a9284368a$var$getContainerDimensions(container), containerOffsetWithBoundary = boundaryElement.tagName === "BODY" ? $edcf132a9284368a$var$getOffset(container, !1) : $edcf132a9284368a$var$getPosition(container, boundaryElement, !1);
  5666. return container.tagName === "HTML" && boundaryElement.tagName === "BODY" && (containerDimensions.scroll.top = 0, containerDimensions.scroll.left = 0), $edcf132a9284368a$export$6839422d1f33cee9(placement, childOffset, overlaySize, scrollSize, margins, padding, shouldFlip, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset2, crossOffset, isContainerPositioned, maxHeight, arrowSize, arrowBoundaryOffset);
  5667. }
  5668. function $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale) {
  5669. let { top, left, width, height } = node.getBoundingClientRect();
  5670. return ignoreScale && node instanceof node.ownerDocument.defaultView.HTMLElement && (width = node.offsetWidth, height = node.offsetHeight), {
  5671. top,
  5672. left,
  5673. width,
  5674. height
  5675. };
  5676. }
  5677. function $edcf132a9284368a$var$getOffset(node, ignoreScale) {
  5678. let { top, left, width, height } = $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale), { scrollTop, scrollLeft, clientTop, clientLeft } = document.documentElement;
  5679. return {
  5680. top: top + scrollTop - clientTop,
  5681. left: left + scrollLeft - clientLeft,
  5682. width,
  5683. height
  5684. };
  5685. }
  5686. function $edcf132a9284368a$var$getPosition(node, parent, ignoreScale) {
  5687. let style = window.getComputedStyle(node), offset2;
  5688. if (style.position === "fixed") offset2 = $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale);
  5689. else {
  5690. offset2 = $edcf132a9284368a$var$getOffset(node, ignoreScale);
  5691. let parentOffset = $edcf132a9284368a$var$getOffset(parent, ignoreScale), parentStyle = window.getComputedStyle(parent);
  5692. parentOffset.top += (parseInt(parentStyle.borderTopWidth, 10) || 0) - parent.scrollTop, parentOffset.left += (parseInt(parentStyle.borderLeftWidth, 10) || 0) - parent.scrollLeft, offset2.top -= parentOffset.top, offset2.left -= parentOffset.left;
  5693. }
  5694. return offset2.top -= parseInt(style.marginTop, 10) || 0, offset2.left -= parseInt(style.marginLeft, 10) || 0, offset2;
  5695. }
  5696. function $edcf132a9284368a$var$getContainingBlock(node) {
  5697. let offsetParent = node.offsetParent;
  5698. if (offsetParent && offsetParent === document.body && window.getComputedStyle(offsetParent).position === "static" && !$edcf132a9284368a$var$isContainingBlock(offsetParent) && (offsetParent = document.documentElement), offsetParent == null)
  5699. for (offsetParent = node.parentElement; offsetParent && !$edcf132a9284368a$var$isContainingBlock(offsetParent); ) offsetParent = offsetParent.parentElement;
  5700. return offsetParent || document.documentElement;
  5701. }
  5702. function $edcf132a9284368a$var$isContainingBlock(node) {
  5703. let style = window.getComputedStyle(node);
  5704. return style.transform !== "none" || /transform|perspective/.test(style.willChange) || style.filter !== "none" || style.contain === "paint" || "backdropFilter" in style && style.backdropFilter !== "none" || "WebkitBackdropFilter" in style && style.WebkitBackdropFilter !== "none";
  5705. }
  5706. // ../../node_modules/@react-aria/overlays/dist/useCloseOnScroll.mjs
  5707. init_react();
  5708. var $dd149f63282afbbf$export$f6211563215e3b37 = /* @__PURE__ */ new WeakMap();
  5709. function $dd149f63282afbbf$export$18fc8428861184da(opts) {
  5710. let { triggerRef, isOpen, onClose } = opts;
  5711. useEffect(() => {
  5712. if (!isOpen || onClose === null) return;
  5713. let onScroll = (e2) => {
  5714. let target = e2.target;
  5715. if (!triggerRef.current || target instanceof Node && !target.contains(triggerRef.current) || e2.target instanceof HTMLInputElement || e2.target instanceof HTMLTextAreaElement) return;
  5716. let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
  5717. onCloseHandler && onCloseHandler();
  5718. };
  5719. return window.addEventListener("scroll", onScroll, !0), () => {
  5720. window.removeEventListener("scroll", onScroll, !0);
  5721. };
  5722. }, [
  5723. isOpen,
  5724. onClose,
  5725. triggerRef
  5726. ]);
  5727. }
  5728. // ../../node_modules/@react-aria/overlays/dist/useOverlayPosition.mjs
  5729. init_react();
  5730. // ../../node_modules/@react-aria/i18n/dist/utils.mjs
  5731. var $148a7a147e38ea7f$var$RTL_SCRIPTS = /* @__PURE__ */ new Set([
  5732. "Arab",
  5733. "Syrc",
  5734. "Samr",
  5735. "Mand",
  5736. "Thaa",
  5737. "Mend",
  5738. "Nkoo",
  5739. "Adlm",
  5740. "Rohg",
  5741. "Hebr"
  5742. ]), $148a7a147e38ea7f$var$RTL_LANGS = /* @__PURE__ */ new Set([
  5743. "ae",
  5744. "ar",
  5745. "arc",
  5746. "bcc",
  5747. "bqi",
  5748. "ckb",
  5749. "dv",
  5750. "fa",
  5751. "glk",
  5752. "he",
  5753. "ku",
  5754. "mzn",
  5755. "nqo",
  5756. "pnb",
  5757. "ps",
  5758. "sd",
  5759. "ug",
  5760. "ur",
  5761. "yi"
  5762. ]);
  5763. function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
  5764. if (Intl.Locale) {
  5765. let locale = new Intl.Locale(localeString).maximize(), textInfo = typeof locale.getTextInfo == "function" ? locale.getTextInfo() : locale.textInfo;
  5766. if (textInfo) return textInfo.direction === "rtl";
  5767. if (locale.script) return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(locale.script);
  5768. }
  5769. let lang = localeString.split("-")[0];
  5770. return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
  5771. }
  5772. // ../../node_modules/@react-aria/i18n/dist/useDefaultLocale.mjs
  5773. init_react();
  5774. var $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for("react-aria.i18n.locale");
  5775. function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
  5776. let locale = typeof window < "u" && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator < "u" && (navigator.language || navigator.userLanguage) || "en-US";
  5777. try {
  5778. Intl.DateTimeFormat.supportedLocalesOf([
  5779. locale
  5780. ]);
  5781. } catch {
  5782. locale = "en-US";
  5783. }
  5784. return {
  5785. locale,
  5786. direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ? "rtl" : "ltr"
  5787. };
  5788. }
  5789. var $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5(), $1e5a04cdaf7d1af8$var$listeners = /* @__PURE__ */ new Set();
  5790. function $1e5a04cdaf7d1af8$var$updateLocale() {
  5791. $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
  5792. for (let listener of $1e5a04cdaf7d1af8$var$listeners) listener($1e5a04cdaf7d1af8$var$currentLocale);
  5793. }
  5794. function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
  5795. let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273(), [defaultLocale2, setDefaultLocale] = useState($1e5a04cdaf7d1af8$var$currentLocale);
  5796. return useEffect(() => ($1e5a04cdaf7d1af8$var$listeners.size === 0 && window.addEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale), $1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale), () => {
  5797. $1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale), $1e5a04cdaf7d1af8$var$listeners.size === 0 && window.removeEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
  5798. }), []), isSSR ? {
  5799. locale: "en-US",
  5800. direction: "ltr"
  5801. } : defaultLocale2;
  5802. }
  5803. // ../../node_modules/@react-aria/i18n/dist/context.mjs
  5804. init_react();
  5805. var $18f2051aff69b9bf$var$I18nContext = react_default.createContext(null);
  5806. function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
  5807. let defaultLocale2 = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
  5808. return useContext($18f2051aff69b9bf$var$I18nContext) || defaultLocale2;
  5809. }
  5810. // ../../node_modules/tslib/tslib.es6.mjs
  5811. var extendStatics = function(d2, b2) {
  5812. return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
  5813. d3.__proto__ = b3;
  5814. } || function(d3, b3) {
  5815. for (var p2 in b3) Object.prototype.hasOwnProperty.call(b3, p2) && (d3[p2] = b3[p2]);
  5816. }, extendStatics(d2, b2);
  5817. };
  5818. function __extends(d2, b2) {
  5819. if (typeof b2 != "function" && b2 !== null)
  5820. throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
  5821. extendStatics(d2, b2);
  5822. function __() {
  5823. this.constructor = d2;
  5824. }
  5825. d2.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
  5826. }
  5827. var __assign = function() {
  5828. return __assign = Object.assign || function(t2) {
  5829. for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) {
  5830. s2 = arguments[i2];
  5831. for (var p2 in s2) Object.prototype.hasOwnProperty.call(s2, p2) && (t2[p2] = s2[p2]);
  5832. }
  5833. return t2;
  5834. }, __assign.apply(this, arguments);
  5835. };
  5836. function __rest(s2, e2) {
  5837. var t2 = {};
  5838. for (var p2 in s2) Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0 && (t2[p2] = s2[p2]);
  5839. if (s2 != null && typeof Object.getOwnPropertySymbols == "function")
  5840. for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++)
  5841. e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2]) && (t2[p2[i2]] = s2[p2[i2]]);
  5842. return t2;
  5843. }
  5844. function __spreadArray(to, from, pack) {
  5845. if (pack || arguments.length === 2) for (var i2 = 0, l3 = from.length, ar; i2 < l3; i2++)
  5846. (ar || !(i2 in from)) && (ar || (ar = Array.prototype.slice.call(from, 0, i2)), ar[i2] = from[i2]);
  5847. return to.concat(ar || Array.prototype.slice.call(from));
  5848. }
  5849. // ../../node_modules/@formatjs/fast-memoize/lib/index.js
  5850. function memoize(fn, options2) {
  5851. var cache = options2 && options2.cache ? options2.cache : cacheDefault, serializer = options2 && options2.serializer ? options2.serializer : serializerDefault, strategy = options2 && options2.strategy ? options2.strategy : strategyDefault;
  5852. return strategy(fn, {
  5853. cache,
  5854. serializer
  5855. });
  5856. }
  5857. function isPrimitive(value) {
  5858. return value == null || typeof value == "number" || typeof value == "boolean";
  5859. }
  5860. function monadic(fn, cache, serializer, arg) {
  5861. var cacheKey = isPrimitive(arg) ? arg : serializer(arg), computedValue = cache.get(cacheKey);
  5862. return typeof computedValue > "u" && (computedValue = fn.call(this, arg), cache.set(cacheKey, computedValue)), computedValue;
  5863. }
  5864. function variadic(fn, cache, serializer) {
  5865. var args = Array.prototype.slice.call(arguments, 3), cacheKey = serializer(args), computedValue = cache.get(cacheKey);
  5866. return typeof computedValue > "u" && (computedValue = fn.apply(this, args), cache.set(cacheKey, computedValue)), computedValue;
  5867. }
  5868. function assemble(fn, context, strategy, cache, serialize) {
  5869. return strategy.bind(context, fn, cache, serialize);
  5870. }
  5871. function strategyDefault(fn, options2) {
  5872. var strategy = fn.length === 1 ? monadic : variadic;
  5873. return assemble(fn, this, strategy, options2.cache.create(), options2.serializer);
  5874. }
  5875. function strategyVariadic(fn, options2) {
  5876. return assemble(fn, this, variadic, options2.cache.create(), options2.serializer);
  5877. }
  5878. function strategyMonadic(fn, options2) {
  5879. return assemble(fn, this, monadic, options2.cache.create(), options2.serializer);
  5880. }
  5881. var serializerDefault = function() {
  5882. return JSON.stringify(arguments);
  5883. }, ObjectWithoutPrototypeCache = (
  5884. /** @class */
  5885. (function() {
  5886. function ObjectWithoutPrototypeCache2() {
  5887. this.cache = /* @__PURE__ */ Object.create(null);
  5888. }
  5889. return ObjectWithoutPrototypeCache2.prototype.get = function(key) {
  5890. return this.cache[key];
  5891. }, ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
  5892. this.cache[key] = value;
  5893. }, ObjectWithoutPrototypeCache2;
  5894. })()
  5895. ), cacheDefault = {
  5896. create: function() {
  5897. return new ObjectWithoutPrototypeCache();
  5898. }
  5899. }, strategies = {
  5900. variadic: strategyVariadic,
  5901. monadic: strategyMonadic
  5902. };
  5903. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/error.js
  5904. var ErrorKind;
  5905. (function(ErrorKind2) {
  5906. ErrorKind2[ErrorKind2.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", ErrorKind2[ErrorKind2.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", ErrorKind2[ErrorKind2.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", ErrorKind2[ErrorKind2.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", ErrorKind2[ErrorKind2.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", ErrorKind2[ErrorKind2.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", ErrorKind2[ErrorKind2.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", ErrorKind2[ErrorKind2.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", ErrorKind2[ErrorKind2.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", ErrorKind2[ErrorKind2.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", ErrorKind2[ErrorKind2.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", ErrorKind2[ErrorKind2.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", ErrorKind2[ErrorKind2.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", ErrorKind2[ErrorKind2.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", ErrorKind2[ErrorKind2.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", ErrorKind2[ErrorKind2.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", ErrorKind2[ErrorKind2.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", ErrorKind2[ErrorKind2.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", ErrorKind2[ErrorKind2.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", ErrorKind2[ErrorKind2.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", ErrorKind2[ErrorKind2.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", ErrorKind2[ErrorKind2.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", ErrorKind2[ErrorKind2.INVALID_TAG = 23] = "INVALID_TAG", ErrorKind2[ErrorKind2.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", ErrorKind2[ErrorKind2.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", ErrorKind2[ErrorKind2.UNCLOSED_TAG = 27] = "UNCLOSED_TAG";
  5907. })(ErrorKind || (ErrorKind = {}));
  5908. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/types.js
  5909. var TYPE;
  5910. (function(TYPE2) {
  5911. TYPE2[TYPE2.literal = 0] = "literal", TYPE2[TYPE2.argument = 1] = "argument", TYPE2[TYPE2.number = 2] = "number", TYPE2[TYPE2.date = 3] = "date", TYPE2[TYPE2.time = 4] = "time", TYPE2[TYPE2.select = 5] = "select", TYPE2[TYPE2.plural = 6] = "plural", TYPE2[TYPE2.pound = 7] = "pound", TYPE2[TYPE2.tag = 8] = "tag";
  5912. })(TYPE || (TYPE = {}));
  5913. var SKELETON_TYPE;
  5914. (function(SKELETON_TYPE2) {
  5915. SKELETON_TYPE2[SKELETON_TYPE2.number = 0] = "number", SKELETON_TYPE2[SKELETON_TYPE2.dateTime = 1] = "dateTime";
  5916. })(SKELETON_TYPE || (SKELETON_TYPE = {}));
  5917. function isLiteralElement(el) {
  5918. return el.type === TYPE.literal;
  5919. }
  5920. function isArgumentElement(el) {
  5921. return el.type === TYPE.argument;
  5922. }
  5923. function isNumberElement(el) {
  5924. return el.type === TYPE.number;
  5925. }
  5926. function isDateElement(el) {
  5927. return el.type === TYPE.date;
  5928. }
  5929. function isTimeElement(el) {
  5930. return el.type === TYPE.time;
  5931. }
  5932. function isSelectElement(el) {
  5933. return el.type === TYPE.select;
  5934. }
  5935. function isPluralElement(el) {
  5936. return el.type === TYPE.plural;
  5937. }
  5938. function isPoundElement(el) {
  5939. return el.type === TYPE.pound;
  5940. }
  5941. function isTagElement(el) {
  5942. return el.type === TYPE.tag;
  5943. }
  5944. function isNumberSkeleton(el) {
  5945. return !!(el && typeof el == "object" && el.type === SKELETON_TYPE.number);
  5946. }
  5947. function isDateTimeSkeleton(el) {
  5948. return !!(el && typeof el == "object" && el.type === SKELETON_TYPE.dateTime);
  5949. }
  5950. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/regex.generated.js
  5951. var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  5952. // ../../node_modules/@formatjs/icu-skeleton-parser/lib/date-time.js
  5953. var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
  5954. function parseDateTimeSkeleton(skeleton) {
  5955. var result = {};
  5956. return skeleton.replace(DATE_TIME_REGEX, function(match) {
  5957. var len = match.length;
  5958. switch (match[0]) {
  5959. // Era
  5960. case "G":
  5961. result.era = len === 4 ? "long" : len === 5 ? "narrow" : "short";
  5962. break;
  5963. // Year
  5964. case "y":
  5965. result.year = len === 2 ? "2-digit" : "numeric";
  5966. break;
  5967. case "Y":
  5968. case "u":
  5969. case "U":
  5970. case "r":
  5971. throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
  5972. // Quarter
  5973. case "q":
  5974. case "Q":
  5975. throw new RangeError("`q/Q` (quarter) patterns are not supported");
  5976. // Month
  5977. case "M":
  5978. case "L":
  5979. result.month = ["numeric", "2-digit", "short", "long", "narrow"][len - 1];
  5980. break;
  5981. // Week
  5982. case "w":
  5983. case "W":
  5984. throw new RangeError("`w/W` (week) patterns are not supported");
  5985. case "d":
  5986. result.day = ["numeric", "2-digit"][len - 1];
  5987. break;
  5988. case "D":
  5989. case "F":
  5990. case "g":
  5991. throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
  5992. // Weekday
  5993. case "E":
  5994. result.weekday = len === 4 ? "long" : len === 5 ? "narrow" : "short";
  5995. break;
  5996. case "e":
  5997. if (len < 4)
  5998. throw new RangeError("`e..eee` (weekday) patterns are not supported");
  5999. result.weekday = ["short", "long", "narrow", "short"][len - 4];
  6000. break;
  6001. case "c":
  6002. if (len < 4)
  6003. throw new RangeError("`c..ccc` (weekday) patterns are not supported");
  6004. result.weekday = ["short", "long", "narrow", "short"][len - 4];
  6005. break;
  6006. // Period
  6007. case "a":
  6008. result.hour12 = !0;
  6009. break;
  6010. case "b":
  6011. // am, pm, noon, midnight
  6012. case "B":
  6013. throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
  6014. // Hour
  6015. case "h":
  6016. result.hourCycle = "h12", result.hour = ["numeric", "2-digit"][len - 1];
  6017. break;
  6018. case "H":
  6019. result.hourCycle = "h23", result.hour = ["numeric", "2-digit"][len - 1];
  6020. break;
  6021. case "K":
  6022. result.hourCycle = "h11", result.hour = ["numeric", "2-digit"][len - 1];
  6023. break;
  6024. case "k":
  6025. result.hourCycle = "h24", result.hour = ["numeric", "2-digit"][len - 1];
  6026. break;
  6027. case "j":
  6028. case "J":
  6029. case "C":
  6030. throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
  6031. // Minute
  6032. case "m":
  6033. result.minute = ["numeric", "2-digit"][len - 1];
  6034. break;
  6035. // Second
  6036. case "s":
  6037. result.second = ["numeric", "2-digit"][len - 1];
  6038. break;
  6039. case "S":
  6040. case "A":
  6041. throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
  6042. // Zone
  6043. case "z":
  6044. result.timeZoneName = len < 4 ? "short" : "long";
  6045. break;
  6046. case "Z":
  6047. // 1..3, 4, 5: The ISO8601 varios formats
  6048. case "O":
  6049. // 1, 4: milliseconds in day short, long
  6050. case "v":
  6051. // 1, 4: generic non-location format
  6052. case "V":
  6053. // 1, 2, 3, 4: time zone ID or city
  6054. case "X":
  6055. // 1, 2, 3, 4: The ISO8601 varios formats
  6056. case "x":
  6057. throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
  6058. }
  6059. return "";
  6060. }), result;
  6061. }
  6062. // ../../node_modules/@formatjs/icu-skeleton-parser/lib/regex.generated.js
  6063. var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
  6064. // ../../node_modules/@formatjs/icu-skeleton-parser/lib/number.js
  6065. function parseNumberSkeletonFromString(skeleton) {
  6066. if (skeleton.length === 0)
  6067. throw new Error("Number skeleton cannot be empty");
  6068. for (var stringTokens = skeleton.split(WHITE_SPACE_REGEX).filter(function(x2) {
  6069. return x2.length > 0;
  6070. }), tokens2 = [], _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
  6071. var stringToken = stringTokens_1[_i], stemAndOptions = stringToken.split("/");
  6072. if (stemAndOptions.length === 0)
  6073. throw new Error("Invalid number skeleton");
  6074. for (var stem = stemAndOptions[0], options2 = stemAndOptions.slice(1), _a2 = 0, options_1 = options2; _a2 < options_1.length; _a2++) {
  6075. var option = options_1[_a2];
  6076. if (option.length === 0)
  6077. throw new Error("Invalid number skeleton");
  6078. }
  6079. tokens2.push({ stem, options: options2 });
  6080. }
  6081. return tokens2;
  6082. }
  6083. function icuUnitToEcma(unit) {
  6084. return unit.replace(/^(.*?)-/, "");
  6085. }
  6086. var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g, INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g, CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
  6087. function parseSignificantPrecision(str) {
  6088. var result = {};
  6089. return str[str.length - 1] === "r" ? result.roundingPriority = "morePrecision" : str[str.length - 1] === "s" && (result.roundingPriority = "lessPrecision"), str.replace(SIGNIFICANT_PRECISION_REGEX, function(_2, g1, g2) {
  6090. return typeof g2 != "string" ? (result.minimumSignificantDigits = g1.length, result.maximumSignificantDigits = g1.length) : g2 === "+" ? result.minimumSignificantDigits = g1.length : g1[0] === "#" ? result.maximumSignificantDigits = g1.length : (result.minimumSignificantDigits = g1.length, result.maximumSignificantDigits = g1.length + (typeof g2 == "string" ? g2.length : 0)), "";
  6091. }), result;
  6092. }
  6093. function parseSign(str) {
  6094. switch (str) {
  6095. case "sign-auto":
  6096. return {
  6097. signDisplay: "auto"
  6098. };
  6099. case "sign-accounting":
  6100. case "()":
  6101. return {
  6102. currencySign: "accounting"
  6103. };
  6104. case "sign-always":
  6105. case "+!":
  6106. return {
  6107. signDisplay: "always"
  6108. };
  6109. case "sign-accounting-always":
  6110. case "()!":
  6111. return {
  6112. signDisplay: "always",
  6113. currencySign: "accounting"
  6114. };
  6115. case "sign-except-zero":
  6116. case "+?":
  6117. return {
  6118. signDisplay: "exceptZero"
  6119. };
  6120. case "sign-accounting-except-zero":
  6121. case "()?":
  6122. return {
  6123. signDisplay: "exceptZero",
  6124. currencySign: "accounting"
  6125. };
  6126. case "sign-never":
  6127. case "+_":
  6128. return {
  6129. signDisplay: "never"
  6130. };
  6131. }
  6132. }
  6133. function parseConciseScientificAndEngineeringStem(stem) {
  6134. var result;
  6135. if (stem[0] === "E" && stem[1] === "E" ? (result = {
  6136. notation: "engineering"
  6137. }, stem = stem.slice(2)) : stem[0] === "E" && (result = {
  6138. notation: "scientific"
  6139. }, stem = stem.slice(1)), result) {
  6140. var signDisplay = stem.slice(0, 2);
  6141. if (signDisplay === "+!" ? (result.signDisplay = "always", stem = stem.slice(2)) : signDisplay === "+?" && (result.signDisplay = "exceptZero", stem = stem.slice(2)), !CONCISE_INTEGER_WIDTH_REGEX.test(stem))
  6142. throw new Error("Malformed concise eng/scientific notation");
  6143. result.minimumIntegerDigits = stem.length;
  6144. }
  6145. return result;
  6146. }
  6147. function parseNotationOptions(opt) {
  6148. var result = {}, signOpts = parseSign(opt);
  6149. return signOpts || result;
  6150. }
  6151. function parseNumberSkeleton(tokens2) {
  6152. for (var result = {}, _i = 0, tokens_1 = tokens2; _i < tokens_1.length; _i++) {
  6153. var token = tokens_1[_i];
  6154. switch (token.stem) {
  6155. case "percent":
  6156. case "%":
  6157. result.style = "percent";
  6158. continue;
  6159. case "%x100":
  6160. result.style = "percent", result.scale = 100;
  6161. continue;
  6162. case "currency":
  6163. result.style = "currency", result.currency = token.options[0];
  6164. continue;
  6165. case "group-off":
  6166. case ",_":
  6167. result.useGrouping = !1;
  6168. continue;
  6169. case "precision-integer":
  6170. case ".":
  6171. result.maximumFractionDigits = 0;
  6172. continue;
  6173. case "measure-unit":
  6174. case "unit":
  6175. result.style = "unit", result.unit = icuUnitToEcma(token.options[0]);
  6176. continue;
  6177. case "compact-short":
  6178. case "K":
  6179. result.notation = "compact", result.compactDisplay = "short";
  6180. continue;
  6181. case "compact-long":
  6182. case "KK":
  6183. result.notation = "compact", result.compactDisplay = "long";
  6184. continue;
  6185. case "scientific":
  6186. result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt2) {
  6187. return __assign(__assign({}, all), parseNotationOptions(opt2));
  6188. }, {}));
  6189. continue;
  6190. case "engineering":
  6191. result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt2) {
  6192. return __assign(__assign({}, all), parseNotationOptions(opt2));
  6193. }, {}));
  6194. continue;
  6195. case "notation-simple":
  6196. result.notation = "standard";
  6197. continue;
  6198. // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
  6199. case "unit-width-narrow":
  6200. result.currencyDisplay = "narrowSymbol", result.unitDisplay = "narrow";
  6201. continue;
  6202. case "unit-width-short":
  6203. result.currencyDisplay = "code", result.unitDisplay = "short";
  6204. continue;
  6205. case "unit-width-full-name":
  6206. result.currencyDisplay = "name", result.unitDisplay = "long";
  6207. continue;
  6208. case "unit-width-iso-code":
  6209. result.currencyDisplay = "symbol";
  6210. continue;
  6211. case "scale":
  6212. result.scale = parseFloat(token.options[0]);
  6213. continue;
  6214. case "rounding-mode-floor":
  6215. result.roundingMode = "floor";
  6216. continue;
  6217. case "rounding-mode-ceiling":
  6218. result.roundingMode = "ceil";
  6219. continue;
  6220. case "rounding-mode-down":
  6221. result.roundingMode = "trunc";
  6222. continue;
  6223. case "rounding-mode-up":
  6224. result.roundingMode = "expand";
  6225. continue;
  6226. case "rounding-mode-half-even":
  6227. result.roundingMode = "halfEven";
  6228. continue;
  6229. case "rounding-mode-half-down":
  6230. result.roundingMode = "halfTrunc";
  6231. continue;
  6232. case "rounding-mode-half-up":
  6233. result.roundingMode = "halfExpand";
  6234. continue;
  6235. // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
  6236. case "integer-width":
  6237. if (token.options.length > 1)
  6238. throw new RangeError("integer-width stems only accept a single optional option");
  6239. token.options[0].replace(INTEGER_WIDTH_REGEX, function(_2, g1, g2, g3, g4, g5) {
  6240. if (g1)
  6241. result.minimumIntegerDigits = g2.length;
  6242. else {
  6243. if (g3 && g4)
  6244. throw new Error("We currently do not support maximum integer digits");
  6245. if (g5)
  6246. throw new Error("We currently do not support exact integer digits");
  6247. }
  6248. return "";
  6249. });
  6250. continue;
  6251. }
  6252. if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
  6253. result.minimumIntegerDigits = token.stem.length;
  6254. continue;
  6255. }
  6256. if (FRACTION_PRECISION_REGEX.test(token.stem)) {
  6257. if (token.options.length > 1)
  6258. throw new RangeError("Fraction-precision stems only accept a single optional option");
  6259. token.stem.replace(FRACTION_PRECISION_REGEX, function(_2, g1, g2, g3, g4, g5) {
  6260. return g2 === "*" ? result.minimumFractionDigits = g1.length : g3 && g3[0] === "#" ? result.maximumFractionDigits = g3.length : g4 && g5 ? (result.minimumFractionDigits = g4.length, result.maximumFractionDigits = g4.length + g5.length) : (result.minimumFractionDigits = g1.length, result.maximumFractionDigits = g1.length), "";
  6261. });
  6262. var opt = token.options[0];
  6263. opt === "w" ? result = __assign(__assign({}, result), { trailingZeroDisplay: "stripIfInteger" }) : opt && (result = __assign(__assign({}, result), parseSignificantPrecision(opt)));
  6264. continue;
  6265. }
  6266. if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
  6267. result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
  6268. continue;
  6269. }
  6270. var signOpts = parseSign(token.stem);
  6271. signOpts && (result = __assign(__assign({}, result), signOpts));
  6272. var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
  6273. conciseScientificAndEngineeringOpts && (result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts));
  6274. }
  6275. return result;
  6276. }
  6277. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/time-data.generated.js
  6278. var timeData = {
  6279. "001": [
  6280. "H",
  6281. "h"
  6282. ],
  6283. 419: [
  6284. "h",
  6285. "H",
  6286. "hB",
  6287. "hb"
  6288. ],
  6289. AC: [
  6290. "H",
  6291. "h",
  6292. "hb",
  6293. "hB"
  6294. ],
  6295. AD: [
  6296. "H",
  6297. "hB"
  6298. ],
  6299. AE: [
  6300. "h",
  6301. "hB",
  6302. "hb",
  6303. "H"
  6304. ],
  6305. AF: [
  6306. "H",
  6307. "hb",
  6308. "hB",
  6309. "h"
  6310. ],
  6311. AG: [
  6312. "h",
  6313. "hb",
  6314. "H",
  6315. "hB"
  6316. ],
  6317. AI: [
  6318. "H",
  6319. "h",
  6320. "hb",
  6321. "hB"
  6322. ],
  6323. AL: [
  6324. "h",
  6325. "H",
  6326. "hB"
  6327. ],
  6328. AM: [
  6329. "H",
  6330. "hB"
  6331. ],
  6332. AO: [
  6333. "H",
  6334. "hB"
  6335. ],
  6336. AR: [
  6337. "h",
  6338. "H",
  6339. "hB",
  6340. "hb"
  6341. ],
  6342. AS: [
  6343. "h",
  6344. "H"
  6345. ],
  6346. AT: [
  6347. "H",
  6348. "hB"
  6349. ],
  6350. AU: [
  6351. "h",
  6352. "hb",
  6353. "H",
  6354. "hB"
  6355. ],
  6356. AW: [
  6357. "H",
  6358. "hB"
  6359. ],
  6360. AX: [
  6361. "H"
  6362. ],
  6363. AZ: [
  6364. "H",
  6365. "hB",
  6366. "h"
  6367. ],
  6368. BA: [
  6369. "H",
  6370. "hB",
  6371. "h"
  6372. ],
  6373. BB: [
  6374. "h",
  6375. "hb",
  6376. "H",
  6377. "hB"
  6378. ],
  6379. BD: [
  6380. "h",
  6381. "hB",
  6382. "H"
  6383. ],
  6384. BE: [
  6385. "H",
  6386. "hB"
  6387. ],
  6388. BF: [
  6389. "H",
  6390. "hB"
  6391. ],
  6392. BG: [
  6393. "H",
  6394. "hB",
  6395. "h"
  6396. ],
  6397. BH: [
  6398. "h",
  6399. "hB",
  6400. "hb",
  6401. "H"
  6402. ],
  6403. BI: [
  6404. "H",
  6405. "h"
  6406. ],
  6407. BJ: [
  6408. "H",
  6409. "hB"
  6410. ],
  6411. BL: [
  6412. "H",
  6413. "hB"
  6414. ],
  6415. BM: [
  6416. "h",
  6417. "hb",
  6418. "H",
  6419. "hB"
  6420. ],
  6421. BN: [
  6422. "hb",
  6423. "hB",
  6424. "h",
  6425. "H"
  6426. ],
  6427. BO: [
  6428. "h",
  6429. "H",
  6430. "hB",
  6431. "hb"
  6432. ],
  6433. BQ: [
  6434. "H"
  6435. ],
  6436. BR: [
  6437. "H",
  6438. "hB"
  6439. ],
  6440. BS: [
  6441. "h",
  6442. "hb",
  6443. "H",
  6444. "hB"
  6445. ],
  6446. BT: [
  6447. "h",
  6448. "H"
  6449. ],
  6450. BW: [
  6451. "H",
  6452. "h",
  6453. "hb",
  6454. "hB"
  6455. ],
  6456. BY: [
  6457. "H",
  6458. "h"
  6459. ],
  6460. BZ: [
  6461. "H",
  6462. "h",
  6463. "hb",
  6464. "hB"
  6465. ],
  6466. CA: [
  6467. "h",
  6468. "hb",
  6469. "H",
  6470. "hB"
  6471. ],
  6472. CC: [
  6473. "H",
  6474. "h",
  6475. "hb",
  6476. "hB"
  6477. ],
  6478. CD: [
  6479. "hB",
  6480. "H"
  6481. ],
  6482. CF: [
  6483. "H",
  6484. "h",
  6485. "hB"
  6486. ],
  6487. CG: [
  6488. "H",
  6489. "hB"
  6490. ],
  6491. CH: [
  6492. "H",
  6493. "hB",
  6494. "h"
  6495. ],
  6496. CI: [
  6497. "H",
  6498. "hB"
  6499. ],
  6500. CK: [
  6501. "H",
  6502. "h",
  6503. "hb",
  6504. "hB"
  6505. ],
  6506. CL: [
  6507. "h",
  6508. "H",
  6509. "hB",
  6510. "hb"
  6511. ],
  6512. CM: [
  6513. "H",
  6514. "h",
  6515. "hB"
  6516. ],
  6517. CN: [
  6518. "H",
  6519. "hB",
  6520. "hb",
  6521. "h"
  6522. ],
  6523. CO: [
  6524. "h",
  6525. "H",
  6526. "hB",
  6527. "hb"
  6528. ],
  6529. CP: [
  6530. "H"
  6531. ],
  6532. CR: [
  6533. "h",
  6534. "H",
  6535. "hB",
  6536. "hb"
  6537. ],
  6538. CU: [
  6539. "h",
  6540. "H",
  6541. "hB",
  6542. "hb"
  6543. ],
  6544. CV: [
  6545. "H",
  6546. "hB"
  6547. ],
  6548. CW: [
  6549. "H",
  6550. "hB"
  6551. ],
  6552. CX: [
  6553. "H",
  6554. "h",
  6555. "hb",
  6556. "hB"
  6557. ],
  6558. CY: [
  6559. "h",
  6560. "H",
  6561. "hb",
  6562. "hB"
  6563. ],
  6564. CZ: [
  6565. "H"
  6566. ],
  6567. DE: [
  6568. "H",
  6569. "hB"
  6570. ],
  6571. DG: [
  6572. "H",
  6573. "h",
  6574. "hb",
  6575. "hB"
  6576. ],
  6577. DJ: [
  6578. "h",
  6579. "H"
  6580. ],
  6581. DK: [
  6582. "H"
  6583. ],
  6584. DM: [
  6585. "h",
  6586. "hb",
  6587. "H",
  6588. "hB"
  6589. ],
  6590. DO: [
  6591. "h",
  6592. "H",
  6593. "hB",
  6594. "hb"
  6595. ],
  6596. DZ: [
  6597. "h",
  6598. "hB",
  6599. "hb",
  6600. "H"
  6601. ],
  6602. EA: [
  6603. "H",
  6604. "h",
  6605. "hB",
  6606. "hb"
  6607. ],
  6608. EC: [
  6609. "h",
  6610. "H",
  6611. "hB",
  6612. "hb"
  6613. ],
  6614. EE: [
  6615. "H",
  6616. "hB"
  6617. ],
  6618. EG: [
  6619. "h",
  6620. "hB",
  6621. "hb",
  6622. "H"
  6623. ],
  6624. EH: [
  6625. "h",
  6626. "hB",
  6627. "hb",
  6628. "H"
  6629. ],
  6630. ER: [
  6631. "h",
  6632. "H"
  6633. ],
  6634. ES: [
  6635. "H",
  6636. "hB",
  6637. "h",
  6638. "hb"
  6639. ],
  6640. ET: [
  6641. "hB",
  6642. "hb",
  6643. "h",
  6644. "H"
  6645. ],
  6646. FI: [
  6647. "H"
  6648. ],
  6649. FJ: [
  6650. "h",
  6651. "hb",
  6652. "H",
  6653. "hB"
  6654. ],
  6655. FK: [
  6656. "H",
  6657. "h",
  6658. "hb",
  6659. "hB"
  6660. ],
  6661. FM: [
  6662. "h",
  6663. "hb",
  6664. "H",
  6665. "hB"
  6666. ],
  6667. FO: [
  6668. "H",
  6669. "h"
  6670. ],
  6671. FR: [
  6672. "H",
  6673. "hB"
  6674. ],
  6675. GA: [
  6676. "H",
  6677. "hB"
  6678. ],
  6679. GB: [
  6680. "H",
  6681. "h",
  6682. "hb",
  6683. "hB"
  6684. ],
  6685. GD: [
  6686. "h",
  6687. "hb",
  6688. "H",
  6689. "hB"
  6690. ],
  6691. GE: [
  6692. "H",
  6693. "hB",
  6694. "h"
  6695. ],
  6696. GF: [
  6697. "H",
  6698. "hB"
  6699. ],
  6700. GG: [
  6701. "H",
  6702. "h",
  6703. "hb",
  6704. "hB"
  6705. ],
  6706. GH: [
  6707. "h",
  6708. "H"
  6709. ],
  6710. GI: [
  6711. "H",
  6712. "h",
  6713. "hb",
  6714. "hB"
  6715. ],
  6716. GL: [
  6717. "H",
  6718. "h"
  6719. ],
  6720. GM: [
  6721. "h",
  6722. "hb",
  6723. "H",
  6724. "hB"
  6725. ],
  6726. GN: [
  6727. "H",
  6728. "hB"
  6729. ],
  6730. GP: [
  6731. "H",
  6732. "hB"
  6733. ],
  6734. GQ: [
  6735. "H",
  6736. "hB",
  6737. "h",
  6738. "hb"
  6739. ],
  6740. GR: [
  6741. "h",
  6742. "H",
  6743. "hb",
  6744. "hB"
  6745. ],
  6746. GT: [
  6747. "h",
  6748. "H",
  6749. "hB",
  6750. "hb"
  6751. ],
  6752. GU: [
  6753. "h",
  6754. "hb",
  6755. "H",
  6756. "hB"
  6757. ],
  6758. GW: [
  6759. "H",
  6760. "hB"
  6761. ],
  6762. GY: [
  6763. "h",
  6764. "hb",
  6765. "H",
  6766. "hB"
  6767. ],
  6768. HK: [
  6769. "h",
  6770. "hB",
  6771. "hb",
  6772. "H"
  6773. ],
  6774. HN: [
  6775. "h",
  6776. "H",
  6777. "hB",
  6778. "hb"
  6779. ],
  6780. HR: [
  6781. "H",
  6782. "hB"
  6783. ],
  6784. HU: [
  6785. "H",
  6786. "h"
  6787. ],
  6788. IC: [
  6789. "H",
  6790. "h",
  6791. "hB",
  6792. "hb"
  6793. ],
  6794. ID: [
  6795. "H"
  6796. ],
  6797. IE: [
  6798. "H",
  6799. "h",
  6800. "hb",
  6801. "hB"
  6802. ],
  6803. IL: [
  6804. "H",
  6805. "hB"
  6806. ],
  6807. IM: [
  6808. "H",
  6809. "h",
  6810. "hb",
  6811. "hB"
  6812. ],
  6813. IN: [
  6814. "h",
  6815. "H"
  6816. ],
  6817. IO: [
  6818. "H",
  6819. "h",
  6820. "hb",
  6821. "hB"
  6822. ],
  6823. IQ: [
  6824. "h",
  6825. "hB",
  6826. "hb",
  6827. "H"
  6828. ],
  6829. IR: [
  6830. "hB",
  6831. "H"
  6832. ],
  6833. IS: [
  6834. "H"
  6835. ],
  6836. IT: [
  6837. "H",
  6838. "hB"
  6839. ],
  6840. JE: [
  6841. "H",
  6842. "h",
  6843. "hb",
  6844. "hB"
  6845. ],
  6846. JM: [
  6847. "h",
  6848. "hb",
  6849. "H",
  6850. "hB"
  6851. ],
  6852. JO: [
  6853. "h",
  6854. "hB",
  6855. "hb",
  6856. "H"
  6857. ],
  6858. JP: [
  6859. "H",
  6860. "K",
  6861. "h"
  6862. ],
  6863. KE: [
  6864. "hB",
  6865. "hb",
  6866. "H",
  6867. "h"
  6868. ],
  6869. KG: [
  6870. "H",
  6871. "h",
  6872. "hB",
  6873. "hb"
  6874. ],
  6875. KH: [
  6876. "hB",
  6877. "h",
  6878. "H",
  6879. "hb"
  6880. ],
  6881. KI: [
  6882. "h",
  6883. "hb",
  6884. "H",
  6885. "hB"
  6886. ],
  6887. KM: [
  6888. "H",
  6889. "h",
  6890. "hB",
  6891. "hb"
  6892. ],
  6893. KN: [
  6894. "h",
  6895. "hb",
  6896. "H",
  6897. "hB"
  6898. ],
  6899. KP: [
  6900. "h",
  6901. "H",
  6902. "hB",
  6903. "hb"
  6904. ],
  6905. KR: [
  6906. "h",
  6907. "H",
  6908. "hB",
  6909. "hb"
  6910. ],
  6911. KW: [
  6912. "h",
  6913. "hB",
  6914. "hb",
  6915. "H"
  6916. ],
  6917. KY: [
  6918. "h",
  6919. "hb",
  6920. "H",
  6921. "hB"
  6922. ],
  6923. KZ: [
  6924. "H",
  6925. "hB"
  6926. ],
  6927. LA: [
  6928. "H",
  6929. "hb",
  6930. "hB",
  6931. "h"
  6932. ],
  6933. LB: [
  6934. "h",
  6935. "hB",
  6936. "hb",
  6937. "H"
  6938. ],
  6939. LC: [
  6940. "h",
  6941. "hb",
  6942. "H",
  6943. "hB"
  6944. ],
  6945. LI: [
  6946. "H",
  6947. "hB",
  6948. "h"
  6949. ],
  6950. LK: [
  6951. "H",
  6952. "h",
  6953. "hB",
  6954. "hb"
  6955. ],
  6956. LR: [
  6957. "h",
  6958. "hb",
  6959. "H",
  6960. "hB"
  6961. ],
  6962. LS: [
  6963. "h",
  6964. "H"
  6965. ],
  6966. LT: [
  6967. "H",
  6968. "h",
  6969. "hb",
  6970. "hB"
  6971. ],
  6972. LU: [
  6973. "H",
  6974. "h",
  6975. "hB"
  6976. ],
  6977. LV: [
  6978. "H",
  6979. "hB",
  6980. "hb",
  6981. "h"
  6982. ],
  6983. LY: [
  6984. "h",
  6985. "hB",
  6986. "hb",
  6987. "H"
  6988. ],
  6989. MA: [
  6990. "H",
  6991. "h",
  6992. "hB",
  6993. "hb"
  6994. ],
  6995. MC: [
  6996. "H",
  6997. "hB"
  6998. ],
  6999. MD: [
  7000. "H",
  7001. "hB"
  7002. ],
  7003. ME: [
  7004. "H",
  7005. "hB",
  7006. "h"
  7007. ],
  7008. MF: [
  7009. "H",
  7010. "hB"
  7011. ],
  7012. MG: [
  7013. "H",
  7014. "h"
  7015. ],
  7016. MH: [
  7017. "h",
  7018. "hb",
  7019. "H",
  7020. "hB"
  7021. ],
  7022. MK: [
  7023. "H",
  7024. "h",
  7025. "hb",
  7026. "hB"
  7027. ],
  7028. ML: [
  7029. "H"
  7030. ],
  7031. MM: [
  7032. "hB",
  7033. "hb",
  7034. "H",
  7035. "h"
  7036. ],
  7037. MN: [
  7038. "H",
  7039. "h",
  7040. "hb",
  7041. "hB"
  7042. ],
  7043. MO: [
  7044. "h",
  7045. "hB",
  7046. "hb",
  7047. "H"
  7048. ],
  7049. MP: [
  7050. "h",
  7051. "hb",
  7052. "H",
  7053. "hB"
  7054. ],
  7055. MQ: [
  7056. "H",
  7057. "hB"
  7058. ],
  7059. MR: [
  7060. "h",
  7061. "hB",
  7062. "hb",
  7063. "H"
  7064. ],
  7065. MS: [
  7066. "H",
  7067. "h",
  7068. "hb",
  7069. "hB"
  7070. ],
  7071. MT: [
  7072. "H",
  7073. "h"
  7074. ],
  7075. MU: [
  7076. "H",
  7077. "h"
  7078. ],
  7079. MV: [
  7080. "H",
  7081. "h"
  7082. ],
  7083. MW: [
  7084. "h",
  7085. "hb",
  7086. "H",
  7087. "hB"
  7088. ],
  7089. MX: [
  7090. "h",
  7091. "H",
  7092. "hB",
  7093. "hb"
  7094. ],
  7095. MY: [
  7096. "hb",
  7097. "hB",
  7098. "h",
  7099. "H"
  7100. ],
  7101. MZ: [
  7102. "H",
  7103. "hB"
  7104. ],
  7105. NA: [
  7106. "h",
  7107. "H",
  7108. "hB",
  7109. "hb"
  7110. ],
  7111. NC: [
  7112. "H",
  7113. "hB"
  7114. ],
  7115. NE: [
  7116. "H"
  7117. ],
  7118. NF: [
  7119. "H",
  7120. "h",
  7121. "hb",
  7122. "hB"
  7123. ],
  7124. NG: [
  7125. "H",
  7126. "h",
  7127. "hb",
  7128. "hB"
  7129. ],
  7130. NI: [
  7131. "h",
  7132. "H",
  7133. "hB",
  7134. "hb"
  7135. ],
  7136. NL: [
  7137. "H",
  7138. "hB"
  7139. ],
  7140. NO: [
  7141. "H",
  7142. "h"
  7143. ],
  7144. NP: [
  7145. "H",
  7146. "h",
  7147. "hB"
  7148. ],
  7149. NR: [
  7150. "H",
  7151. "h",
  7152. "hb",
  7153. "hB"
  7154. ],
  7155. NU: [
  7156. "H",
  7157. "h",
  7158. "hb",
  7159. "hB"
  7160. ],
  7161. NZ: [
  7162. "h",
  7163. "hb",
  7164. "H",
  7165. "hB"
  7166. ],
  7167. OM: [
  7168. "h",
  7169. "hB",
  7170. "hb",
  7171. "H"
  7172. ],
  7173. PA: [
  7174. "h",
  7175. "H",
  7176. "hB",
  7177. "hb"
  7178. ],
  7179. PE: [
  7180. "h",
  7181. "H",
  7182. "hB",
  7183. "hb"
  7184. ],
  7185. PF: [
  7186. "H",
  7187. "h",
  7188. "hB"
  7189. ],
  7190. PG: [
  7191. "h",
  7192. "H"
  7193. ],
  7194. PH: [
  7195. "h",
  7196. "hB",
  7197. "hb",
  7198. "H"
  7199. ],
  7200. PK: [
  7201. "h",
  7202. "hB",
  7203. "H"
  7204. ],
  7205. PL: [
  7206. "H",
  7207. "h"
  7208. ],
  7209. PM: [
  7210. "H",
  7211. "hB"
  7212. ],
  7213. PN: [
  7214. "H",
  7215. "h",
  7216. "hb",
  7217. "hB"
  7218. ],
  7219. PR: [
  7220. "h",
  7221. "H",
  7222. "hB",
  7223. "hb"
  7224. ],
  7225. PS: [
  7226. "h",
  7227. "hB",
  7228. "hb",
  7229. "H"
  7230. ],
  7231. PT: [
  7232. "H",
  7233. "hB"
  7234. ],
  7235. PW: [
  7236. "h",
  7237. "H"
  7238. ],
  7239. PY: [
  7240. "h",
  7241. "H",
  7242. "hB",
  7243. "hb"
  7244. ],
  7245. QA: [
  7246. "h",
  7247. "hB",
  7248. "hb",
  7249. "H"
  7250. ],
  7251. RE: [
  7252. "H",
  7253. "hB"
  7254. ],
  7255. RO: [
  7256. "H",
  7257. "hB"
  7258. ],
  7259. RS: [
  7260. "H",
  7261. "hB",
  7262. "h"
  7263. ],
  7264. RU: [
  7265. "H"
  7266. ],
  7267. RW: [
  7268. "H",
  7269. "h"
  7270. ],
  7271. SA: [
  7272. "h",
  7273. "hB",
  7274. "hb",
  7275. "H"
  7276. ],
  7277. SB: [
  7278. "h",
  7279. "hb",
  7280. "H",
  7281. "hB"
  7282. ],
  7283. SC: [
  7284. "H",
  7285. "h",
  7286. "hB"
  7287. ],
  7288. SD: [
  7289. "h",
  7290. "hB",
  7291. "hb",
  7292. "H"
  7293. ],
  7294. SE: [
  7295. "H"
  7296. ],
  7297. SG: [
  7298. "h",
  7299. "hb",
  7300. "H",
  7301. "hB"
  7302. ],
  7303. SH: [
  7304. "H",
  7305. "h",
  7306. "hb",
  7307. "hB"
  7308. ],
  7309. SI: [
  7310. "H",
  7311. "hB"
  7312. ],
  7313. SJ: [
  7314. "H"
  7315. ],
  7316. SK: [
  7317. "H"
  7318. ],
  7319. SL: [
  7320. "h",
  7321. "hb",
  7322. "H",
  7323. "hB"
  7324. ],
  7325. SM: [
  7326. "H",
  7327. "h",
  7328. "hB"
  7329. ],
  7330. SN: [
  7331. "H",
  7332. "h",
  7333. "hB"
  7334. ],
  7335. SO: [
  7336. "h",
  7337. "H"
  7338. ],
  7339. SR: [
  7340. "H",
  7341. "hB"
  7342. ],
  7343. SS: [
  7344. "h",
  7345. "hb",
  7346. "H",
  7347. "hB"
  7348. ],
  7349. ST: [
  7350. "H",
  7351. "hB"
  7352. ],
  7353. SV: [
  7354. "h",
  7355. "H",
  7356. "hB",
  7357. "hb"
  7358. ],
  7359. SX: [
  7360. "H",
  7361. "h",
  7362. "hb",
  7363. "hB"
  7364. ],
  7365. SY: [
  7366. "h",
  7367. "hB",
  7368. "hb",
  7369. "H"
  7370. ],
  7371. SZ: [
  7372. "h",
  7373. "hb",
  7374. "H",
  7375. "hB"
  7376. ],
  7377. TA: [
  7378. "H",
  7379. "h",
  7380. "hb",
  7381. "hB"
  7382. ],
  7383. TC: [
  7384. "h",
  7385. "hb",
  7386. "H",
  7387. "hB"
  7388. ],
  7389. TD: [
  7390. "h",
  7391. "H",
  7392. "hB"
  7393. ],
  7394. TF: [
  7395. "H",
  7396. "h",
  7397. "hB"
  7398. ],
  7399. TG: [
  7400. "H",
  7401. "hB"
  7402. ],
  7403. TH: [
  7404. "H",
  7405. "h"
  7406. ],
  7407. TJ: [
  7408. "H",
  7409. "h"
  7410. ],
  7411. TL: [
  7412. "H",
  7413. "hB",
  7414. "hb",
  7415. "h"
  7416. ],
  7417. TM: [
  7418. "H",
  7419. "h"
  7420. ],
  7421. TN: [
  7422. "h",
  7423. "hB",
  7424. "hb",
  7425. "H"
  7426. ],
  7427. TO: [
  7428. "h",
  7429. "H"
  7430. ],
  7431. TR: [
  7432. "H",
  7433. "hB"
  7434. ],
  7435. TT: [
  7436. "h",
  7437. "hb",
  7438. "H",
  7439. "hB"
  7440. ],
  7441. TW: [
  7442. "hB",
  7443. "hb",
  7444. "h",
  7445. "H"
  7446. ],
  7447. TZ: [
  7448. "hB",
  7449. "hb",
  7450. "H",
  7451. "h"
  7452. ],
  7453. UA: [
  7454. "H",
  7455. "hB",
  7456. "h"
  7457. ],
  7458. UG: [
  7459. "hB",
  7460. "hb",
  7461. "H",
  7462. "h"
  7463. ],
  7464. UM: [
  7465. "h",
  7466. "hb",
  7467. "H",
  7468. "hB"
  7469. ],
  7470. US: [
  7471. "h",
  7472. "hb",
  7473. "H",
  7474. "hB"
  7475. ],
  7476. UY: [
  7477. "h",
  7478. "H",
  7479. "hB",
  7480. "hb"
  7481. ],
  7482. UZ: [
  7483. "H",
  7484. "hB",
  7485. "h"
  7486. ],
  7487. VA: [
  7488. "H",
  7489. "h",
  7490. "hB"
  7491. ],
  7492. VC: [
  7493. "h",
  7494. "hb",
  7495. "H",
  7496. "hB"
  7497. ],
  7498. VE: [
  7499. "h",
  7500. "H",
  7501. "hB",
  7502. "hb"
  7503. ],
  7504. VG: [
  7505. "h",
  7506. "hb",
  7507. "H",
  7508. "hB"
  7509. ],
  7510. VI: [
  7511. "h",
  7512. "hb",
  7513. "H",
  7514. "hB"
  7515. ],
  7516. VN: [
  7517. "H",
  7518. "h"
  7519. ],
  7520. VU: [
  7521. "h",
  7522. "H"
  7523. ],
  7524. WF: [
  7525. "H",
  7526. "hB"
  7527. ],
  7528. WS: [
  7529. "h",
  7530. "H"
  7531. ],
  7532. XK: [
  7533. "H",
  7534. "hB",
  7535. "h"
  7536. ],
  7537. YE: [
  7538. "h",
  7539. "hB",
  7540. "hb",
  7541. "H"
  7542. ],
  7543. YT: [
  7544. "H",
  7545. "hB"
  7546. ],
  7547. ZA: [
  7548. "H",
  7549. "h",
  7550. "hb",
  7551. "hB"
  7552. ],
  7553. ZM: [
  7554. "h",
  7555. "hb",
  7556. "H",
  7557. "hB"
  7558. ],
  7559. ZW: [
  7560. "H",
  7561. "h"
  7562. ],
  7563. "af-ZA": [
  7564. "H",
  7565. "h",
  7566. "hB",
  7567. "hb"
  7568. ],
  7569. "ar-001": [
  7570. "h",
  7571. "hB",
  7572. "hb",
  7573. "H"
  7574. ],
  7575. "ca-ES": [
  7576. "H",
  7577. "h",
  7578. "hB"
  7579. ],
  7580. "en-001": [
  7581. "h",
  7582. "hb",
  7583. "H",
  7584. "hB"
  7585. ],
  7586. "en-HK": [
  7587. "h",
  7588. "hb",
  7589. "H",
  7590. "hB"
  7591. ],
  7592. "en-IL": [
  7593. "H",
  7594. "h",
  7595. "hb",
  7596. "hB"
  7597. ],
  7598. "en-MY": [
  7599. "h",
  7600. "hb",
  7601. "H",
  7602. "hB"
  7603. ],
  7604. "es-BR": [
  7605. "H",
  7606. "h",
  7607. "hB",
  7608. "hb"
  7609. ],
  7610. "es-ES": [
  7611. "H",
  7612. "h",
  7613. "hB",
  7614. "hb"
  7615. ],
  7616. "es-GQ": [
  7617. "H",
  7618. "h",
  7619. "hB",
  7620. "hb"
  7621. ],
  7622. "fr-CA": [
  7623. "H",
  7624. "h",
  7625. "hB"
  7626. ],
  7627. "gl-ES": [
  7628. "H",
  7629. "h",
  7630. "hB"
  7631. ],
  7632. "gu-IN": [
  7633. "hB",
  7634. "hb",
  7635. "h",
  7636. "H"
  7637. ],
  7638. "hi-IN": [
  7639. "hB",
  7640. "h",
  7641. "H"
  7642. ],
  7643. "it-CH": [
  7644. "H",
  7645. "h",
  7646. "hB"
  7647. ],
  7648. "it-IT": [
  7649. "H",
  7650. "h",
  7651. "hB"
  7652. ],
  7653. "kn-IN": [
  7654. "hB",
  7655. "h",
  7656. "H"
  7657. ],
  7658. "ml-IN": [
  7659. "hB",
  7660. "h",
  7661. "H"
  7662. ],
  7663. "mr-IN": [
  7664. "hB",
  7665. "hb",
  7666. "h",
  7667. "H"
  7668. ],
  7669. "pa-IN": [
  7670. "hB",
  7671. "hb",
  7672. "h",
  7673. "H"
  7674. ],
  7675. "ta-IN": [
  7676. "hB",
  7677. "h",
  7678. "hb",
  7679. "H"
  7680. ],
  7681. "te-IN": [
  7682. "hB",
  7683. "h",
  7684. "H"
  7685. ],
  7686. "zu-ZA": [
  7687. "H",
  7688. "hB",
  7689. "hb",
  7690. "h"
  7691. ]
  7692. };
  7693. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/date-time-pattern-generator.js
  7694. function getBestPattern(skeleton, locale) {
  7695. for (var skeletonCopy = "", patternPos = 0; patternPos < skeleton.length; patternPos++) {
  7696. var patternChar = skeleton.charAt(patternPos);
  7697. if (patternChar === "j") {
  7698. for (var extraLength = 0; patternPos + 1 < skeleton.length && skeleton.charAt(patternPos + 1) === patternChar; )
  7699. extraLength++, patternPos++;
  7700. var hourLen = 1 + (extraLength & 1), dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1), dayPeriodChar = "a", hourChar = getDefaultHourSymbolFromLocale(locale);
  7701. for ((hourChar == "H" || hourChar == "k") && (dayPeriodLen = 0); dayPeriodLen-- > 0; )
  7702. skeletonCopy += dayPeriodChar;
  7703. for (; hourLen-- > 0; )
  7704. skeletonCopy = hourChar + skeletonCopy;
  7705. } else patternChar === "J" ? skeletonCopy += "H" : skeletonCopy += patternChar;
  7706. }
  7707. return skeletonCopy;
  7708. }
  7709. function getDefaultHourSymbolFromLocale(locale) {
  7710. var hourCycle = locale.hourCycle;
  7711. if (hourCycle === void 0 && // @ts-ignore hourCycle(s) is not identified yet
  7712. locale.hourCycles && // @ts-ignore
  7713. locale.hourCycles.length && (hourCycle = locale.hourCycles[0]), hourCycle)
  7714. switch (hourCycle) {
  7715. case "h24":
  7716. return "k";
  7717. case "h23":
  7718. return "H";
  7719. case "h12":
  7720. return "h";
  7721. case "h11":
  7722. return "K";
  7723. default:
  7724. throw new Error("Invalid hourCycle");
  7725. }
  7726. var languageTag = locale.language, regionTag;
  7727. languageTag !== "root" && (regionTag = locale.maximize().region);
  7728. var hourCycles = timeData[regionTag || ""] || timeData[languageTag || ""] || timeData["".concat(languageTag, "-001")] || timeData["001"];
  7729. return hourCycles[0];
  7730. }
  7731. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/parser.js
  7732. var _a, SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*")), SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
  7733. function createLocation(start, end) {
  7734. return { start, end };
  7735. }
  7736. var hasNativeStartsWith = !!String.prototype.startsWith && "_a".startsWith("a", 1), hasNativeFromCodePoint = !!String.fromCodePoint, hasNativeFromEntries = !!Object.fromEntries, hasNativeCodePointAt = !!String.prototype.codePointAt, hasTrimStart = !!String.prototype.trimStart, hasTrimEnd = !!String.prototype.trimEnd, hasNativeIsSafeInteger = !!Number.isSafeInteger, isSafeInteger = hasNativeIsSafeInteger ? Number.isSafeInteger : function(n3) {
  7737. return typeof n3 == "number" && isFinite(n3) && Math.floor(n3) === n3 && Math.abs(n3) <= 9007199254740991;
  7738. }, REGEX_SUPPORTS_U_AND_Y = !0;
  7739. try {
  7740. re = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu"), REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec("a")) === null || _a === void 0 ? void 0 : _a[0]) === "a";
  7741. } catch {
  7742. REGEX_SUPPORTS_U_AND_Y = !1;
  7743. }
  7744. var re, startsWith = hasNativeStartsWith ? (
  7745. // Native
  7746. function(s2, search, position) {
  7747. return s2.startsWith(search, position);
  7748. }
  7749. ) : (
  7750. // For IE11
  7751. function(s2, search, position) {
  7752. return s2.slice(position, position + search.length) === search;
  7753. }
  7754. ), fromCodePoint = hasNativeFromCodePoint ? String.fromCodePoint : (
  7755. // IE11
  7756. function() {
  7757. for (var codePoints = [], _i = 0; _i < arguments.length; _i++)
  7758. codePoints[_i] = arguments[_i];
  7759. for (var elements = "", length = codePoints.length, i2 = 0, code; length > i2; ) {
  7760. if (code = codePoints[i2++], code > 1114111)
  7761. throw RangeError(code + " is not a valid code point");
  7762. elements += code < 65536 ? String.fromCharCode(code) : String.fromCharCode(((code -= 65536) >> 10) + 55296, code % 1024 + 56320);
  7763. }
  7764. return elements;
  7765. }
  7766. ), fromEntries = (
  7767. // native
  7768. hasNativeFromEntries ? Object.fromEntries : (
  7769. // Ponyfill
  7770. function(entries) {
  7771. for (var obj = {}, _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  7772. var _a2 = entries_1[_i], k2 = _a2[0], v2 = _a2[1];
  7773. obj[k2] = v2;
  7774. }
  7775. return obj;
  7776. }
  7777. )
  7778. ), codePointAt = hasNativeCodePointAt ? (
  7779. // Native
  7780. function(s2, index) {
  7781. return s2.codePointAt(index);
  7782. }
  7783. ) : (
  7784. // IE 11
  7785. function(s2, index) {
  7786. var size = s2.length;
  7787. if (!(index < 0 || index >= size)) {
  7788. var first = s2.charCodeAt(index), second;
  7789. return first < 55296 || first > 56319 || index + 1 === size || (second = s2.charCodeAt(index + 1)) < 56320 || second > 57343 ? first : (first - 55296 << 10) + (second - 56320) + 65536;
  7790. }
  7791. }
  7792. ), trimStart = hasTrimStart ? (
  7793. // Native
  7794. function(s2) {
  7795. return s2.trimStart();
  7796. }
  7797. ) : (
  7798. // Ponyfill
  7799. function(s2) {
  7800. return s2.replace(SPACE_SEPARATOR_START_REGEX, "");
  7801. }
  7802. ), trimEnd = hasTrimEnd ? (
  7803. // Native
  7804. function(s2) {
  7805. return s2.trimEnd();
  7806. }
  7807. ) : (
  7808. // Ponyfill
  7809. function(s2) {
  7810. return s2.replace(SPACE_SEPARATOR_END_REGEX, "");
  7811. }
  7812. );
  7813. function RE(s2, flag) {
  7814. return new RegExp(s2, flag);
  7815. }
  7816. var matchIdentifierAtIndex;
  7817. REGEX_SUPPORTS_U_AND_Y ? (IDENTIFIER_PREFIX_RE_1 = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu"), matchIdentifierAtIndex = function(s2, index) {
  7818. var _a2;
  7819. IDENTIFIER_PREFIX_RE_1.lastIndex = index;
  7820. var match = IDENTIFIER_PREFIX_RE_1.exec(s2);
  7821. return (_a2 = match[1]) !== null && _a2 !== void 0 ? _a2 : "";
  7822. }) : matchIdentifierAtIndex = function(s2, index) {
  7823. for (var match = []; ; ) {
  7824. var c2 = codePointAt(s2, index);
  7825. if (c2 === void 0 || _isWhiteSpace(c2) || _isPatternSyntax(c2))
  7826. break;
  7827. match.push(c2), index += c2 >= 65536 ? 2 : 1;
  7828. }
  7829. return fromCodePoint.apply(void 0, match);
  7830. };
  7831. var IDENTIFIER_PREFIX_RE_1, Parser = (
  7832. /** @class */
  7833. (function() {
  7834. function Parser2(message, options2) {
  7835. options2 === void 0 && (options2 = {}), this.message = message, this.position = { offset: 0, line: 1, column: 1 }, this.ignoreTag = !!options2.ignoreTag, this.locale = options2.locale, this.requiresOtherClause = !!options2.requiresOtherClause, this.shouldParseSkeletons = !!options2.shouldParseSkeletons;
  7836. }
  7837. return Parser2.prototype.parse = function() {
  7838. if (this.offset() !== 0)
  7839. throw Error("parser can only be used once");
  7840. return this.parseMessage(0, "", !1);
  7841. }, Parser2.prototype.parseMessage = function(nestingLevel, parentArgType, expectingCloseTag) {
  7842. for (var elements = []; !this.isEOF(); ) {
  7843. var char = this.char();
  7844. if (char === 123) {
  7845. var result = this.parseArgument(nestingLevel, expectingCloseTag);
  7846. if (result.err)
  7847. return result;
  7848. elements.push(result.val);
  7849. } else {
  7850. if (char === 125 && nestingLevel > 0)
  7851. break;
  7852. if (char === 35 && (parentArgType === "plural" || parentArgType === "selectordinal")) {
  7853. var position = this.clonePosition();
  7854. this.bump(), elements.push({
  7855. type: TYPE.pound,
  7856. location: createLocation(position, this.clonePosition())
  7857. });
  7858. } else if (char === 60 && !this.ignoreTag && this.peek() === 47) {
  7859. if (expectingCloseTag)
  7860. break;
  7861. return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
  7862. } else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
  7863. var result = this.parseTag(nestingLevel, parentArgType);
  7864. if (result.err)
  7865. return result;
  7866. elements.push(result.val);
  7867. } else {
  7868. var result = this.parseLiteral(nestingLevel, parentArgType);
  7869. if (result.err)
  7870. return result;
  7871. elements.push(result.val);
  7872. }
  7873. }
  7874. }
  7875. return { val: elements, err: null };
  7876. }, Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
  7877. var startPosition = this.clonePosition();
  7878. this.bump();
  7879. var tagName = this.parseTagName();
  7880. if (this.bumpSpace(), this.bumpIf("/>"))
  7881. return {
  7882. val: {
  7883. type: TYPE.literal,
  7884. value: "<".concat(tagName, "/>"),
  7885. location: createLocation(startPosition, this.clonePosition())
  7886. },
  7887. err: null
  7888. };
  7889. if (this.bumpIf(">")) {
  7890. var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, !0);
  7891. if (childrenResult.err)
  7892. return childrenResult;
  7893. var children = childrenResult.val, endTagStartPosition = this.clonePosition();
  7894. if (this.bumpIf("</")) {
  7895. if (this.isEOF() || !_isAlpha(this.char()))
  7896. return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
  7897. var closingTagNameStartPosition = this.clonePosition(), closingTagName = this.parseTagName();
  7898. return tagName !== closingTagName ? this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
  7899. val: {
  7900. type: TYPE.tag,
  7901. value: tagName,
  7902. children,
  7903. location: createLocation(startPosition, this.clonePosition())
  7904. },
  7905. err: null
  7906. } : this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition())));
  7907. } else
  7908. return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
  7909. } else
  7910. return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
  7911. }, Parser2.prototype.parseTagName = function() {
  7912. var startOffset = this.offset();
  7913. for (this.bump(); !this.isEOF() && _isPotentialElementNameChar(this.char()); )
  7914. this.bump();
  7915. return this.message.slice(startOffset, this.offset());
  7916. }, Parser2.prototype.parseLiteral = function(nestingLevel, parentArgType) {
  7917. for (var start = this.clonePosition(), value = ""; ; ) {
  7918. var parseQuoteResult = this.tryParseQuote(parentArgType);
  7919. if (parseQuoteResult) {
  7920. value += parseQuoteResult;
  7921. continue;
  7922. }
  7923. var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
  7924. if (parseUnquotedResult) {
  7925. value += parseUnquotedResult;
  7926. continue;
  7927. }
  7928. var parseLeftAngleResult = this.tryParseLeftAngleBracket();
  7929. if (parseLeftAngleResult) {
  7930. value += parseLeftAngleResult;
  7931. continue;
  7932. }
  7933. break;
  7934. }
  7935. var location2 = createLocation(start, this.clonePosition());
  7936. return {
  7937. val: { type: TYPE.literal, value, location: location2 },
  7938. err: null
  7939. };
  7940. }, Parser2.prototype.tryParseLeftAngleBracket = function() {
  7941. return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
  7942. !_isAlphaOrSlash(this.peek() || 0)) ? (this.bump(), "<") : null;
  7943. }, Parser2.prototype.tryParseQuote = function(parentArgType) {
  7944. if (this.isEOF() || this.char() !== 39)
  7945. return null;
  7946. switch (this.peek()) {
  7947. case 39:
  7948. return this.bump(), this.bump(), "'";
  7949. // '{', '<', '>', '}'
  7950. case 123:
  7951. case 60:
  7952. case 62:
  7953. case 125:
  7954. break;
  7955. case 35:
  7956. if (parentArgType === "plural" || parentArgType === "selectordinal")
  7957. break;
  7958. return null;
  7959. default:
  7960. return null;
  7961. }
  7962. this.bump();
  7963. var codePoints = [this.char()];
  7964. for (this.bump(); !this.isEOF(); ) {
  7965. var ch = this.char();
  7966. if (ch === 39)
  7967. if (this.peek() === 39)
  7968. codePoints.push(39), this.bump();
  7969. else {
  7970. this.bump();
  7971. break;
  7972. }
  7973. else
  7974. codePoints.push(ch);
  7975. this.bump();
  7976. }
  7977. return fromCodePoint.apply(void 0, codePoints);
  7978. }, Parser2.prototype.tryParseUnquoted = function(nestingLevel, parentArgType) {
  7979. if (this.isEOF())
  7980. return null;
  7981. var ch = this.char();
  7982. return ch === 60 || ch === 123 || ch === 35 && (parentArgType === "plural" || parentArgType === "selectordinal") || ch === 125 && nestingLevel > 0 ? null : (this.bump(), fromCodePoint(ch));
  7983. }, Parser2.prototype.parseArgument = function(nestingLevel, expectingCloseTag) {
  7984. var openingBracePosition = this.clonePosition();
  7985. if (this.bump(), this.bumpSpace(), this.isEOF())
  7986. return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
  7987. if (this.char() === 125)
  7988. return this.bump(), this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
  7989. var value = this.parseIdentifierIfPossible().value;
  7990. if (!value)
  7991. return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
  7992. if (this.bumpSpace(), this.isEOF())
  7993. return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
  7994. switch (this.char()) {
  7995. // Simple argument: `{name}`
  7996. case 125:
  7997. return this.bump(), {
  7998. val: {
  7999. type: TYPE.argument,
  8000. // value does not include the opening and closing braces.
  8001. value,
  8002. location: createLocation(openingBracePosition, this.clonePosition())
  8003. },
  8004. err: null
  8005. };
  8006. // Argument with options: `{name, format, ...}`
  8007. case 44:
  8008. return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())) : this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
  8009. default:
  8010. return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
  8011. }
  8012. }, Parser2.prototype.parseIdentifierIfPossible = function() {
  8013. var startingPosition = this.clonePosition(), startOffset = this.offset(), value = matchIdentifierAtIndex(this.message, startOffset), endOffset = startOffset + value.length;
  8014. this.bumpTo(endOffset);
  8015. var endPosition = this.clonePosition(), location2 = createLocation(startingPosition, endPosition);
  8016. return { value, location: location2 };
  8017. }, Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
  8018. var _a2, typeStartPosition = this.clonePosition(), argType = this.parseIdentifierIfPossible().value, typeEndPosition = this.clonePosition();
  8019. switch (argType) {
  8020. case "":
  8021. return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
  8022. case "number":
  8023. case "date":
  8024. case "time": {
  8025. this.bumpSpace();
  8026. var styleAndLocation = null;
  8027. if (this.bumpIf(",")) {
  8028. this.bumpSpace();
  8029. var styleStartPosition = this.clonePosition(), result = this.parseSimpleArgStyleIfPossible();
  8030. if (result.err)
  8031. return result;
  8032. var style = trimEnd(result.val);
  8033. if (style.length === 0)
  8034. return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
  8035. var styleLocation = createLocation(styleStartPosition, this.clonePosition());
  8036. styleAndLocation = { style, styleLocation };
  8037. }
  8038. var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
  8039. if (argCloseResult.err)
  8040. return argCloseResult;
  8041. var location_1 = createLocation(openingBracePosition, this.clonePosition());
  8042. if (styleAndLocation && startsWith(styleAndLocation?.style, "::", 0)) {
  8043. var skeleton = trimStart(styleAndLocation.style.slice(2));
  8044. if (argType === "number") {
  8045. var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
  8046. return result.err ? result : {
  8047. val: { type: TYPE.number, value, location: location_1, style: result.val },
  8048. err: null
  8049. };
  8050. } else {
  8051. if (skeleton.length === 0)
  8052. return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
  8053. var dateTimePattern = skeleton;
  8054. this.locale && (dateTimePattern = getBestPattern(skeleton, this.locale));
  8055. var style = {
  8056. type: SKELETON_TYPE.dateTime,
  8057. pattern: dateTimePattern,
  8058. location: styleAndLocation.styleLocation,
  8059. parsedOptions: this.shouldParseSkeletons ? parseDateTimeSkeleton(dateTimePattern) : {}
  8060. }, type = argType === "date" ? TYPE.date : TYPE.time;
  8061. return {
  8062. val: { type, value, location: location_1, style },
  8063. err: null
  8064. };
  8065. }
  8066. }
  8067. return {
  8068. val: {
  8069. type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
  8070. value,
  8071. location: location_1,
  8072. style: (_a2 = styleAndLocation?.style) !== null && _a2 !== void 0 ? _a2 : null
  8073. },
  8074. err: null
  8075. };
  8076. }
  8077. case "plural":
  8078. case "selectordinal":
  8079. case "select": {
  8080. var typeEndPosition_1 = this.clonePosition();
  8081. if (this.bumpSpace(), !this.bumpIf(","))
  8082. return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
  8083. this.bumpSpace();
  8084. var identifierAndLocation = this.parseIdentifierIfPossible(), pluralOffset = 0;
  8085. if (argType !== "select" && identifierAndLocation.value === "offset") {
  8086. if (!this.bumpIf(":"))
  8087. return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
  8088. this.bumpSpace();
  8089. var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
  8090. if (result.err)
  8091. return result;
  8092. this.bumpSpace(), identifierAndLocation = this.parseIdentifierIfPossible(), pluralOffset = result.val;
  8093. }
  8094. var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
  8095. if (optionsResult.err)
  8096. return optionsResult;
  8097. var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
  8098. if (argCloseResult.err)
  8099. return argCloseResult;
  8100. var location_2 = createLocation(openingBracePosition, this.clonePosition());
  8101. return argType === "select" ? {
  8102. val: {
  8103. type: TYPE.select,
  8104. value,
  8105. options: fromEntries(optionsResult.val),
  8106. location: location_2
  8107. },
  8108. err: null
  8109. } : {
  8110. val: {
  8111. type: TYPE.plural,
  8112. value,
  8113. options: fromEntries(optionsResult.val),
  8114. offset: pluralOffset,
  8115. pluralType: argType === "plural" ? "cardinal" : "ordinal",
  8116. location: location_2
  8117. },
  8118. err: null
  8119. };
  8120. }
  8121. default:
  8122. return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
  8123. }
  8124. }, Parser2.prototype.tryParseArgumentClose = function(openingBracePosition) {
  8125. return this.isEOF() || this.char() !== 125 ? this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())) : (this.bump(), { val: !0, err: null });
  8126. }, Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
  8127. for (var nestedBraces = 0, startPosition = this.clonePosition(); !this.isEOF(); ) {
  8128. var ch = this.char();
  8129. switch (ch) {
  8130. case 39: {
  8131. this.bump();
  8132. var apostrophePosition = this.clonePosition();
  8133. if (!this.bumpUntil("'"))
  8134. return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
  8135. this.bump();
  8136. break;
  8137. }
  8138. case 123: {
  8139. nestedBraces += 1, this.bump();
  8140. break;
  8141. }
  8142. case 125: {
  8143. if (nestedBraces > 0)
  8144. nestedBraces -= 1;
  8145. else
  8146. return {
  8147. val: this.message.slice(startPosition.offset, this.offset()),
  8148. err: null
  8149. };
  8150. break;
  8151. }
  8152. default:
  8153. this.bump();
  8154. break;
  8155. }
  8156. }
  8157. return {
  8158. val: this.message.slice(startPosition.offset, this.offset()),
  8159. err: null
  8160. };
  8161. }, Parser2.prototype.parseNumberSkeletonFromString = function(skeleton, location2) {
  8162. var tokens2 = [];
  8163. try {
  8164. tokens2 = parseNumberSkeletonFromString(skeleton);
  8165. } catch {
  8166. return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location2);
  8167. }
  8168. return {
  8169. val: {
  8170. type: SKELETON_TYPE.number,
  8171. tokens: tokens2,
  8172. location: location2,
  8173. parsedOptions: this.shouldParseSkeletons ? parseNumberSkeleton(tokens2) : {}
  8174. },
  8175. err: null
  8176. };
  8177. }, Parser2.prototype.tryParsePluralOrSelectOptions = function(nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
  8178. for (var _a2, hasOtherClause = !1, options2 = [], parsedSelectors = /* @__PURE__ */ new Set(), selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location; ; ) {
  8179. if (selector.length === 0) {
  8180. var startPosition = this.clonePosition();
  8181. if (parentArgType !== "select" && this.bumpIf("=")) {
  8182. var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
  8183. if (result.err)
  8184. return result;
  8185. selectorLocation = createLocation(startPosition, this.clonePosition()), selector = this.message.slice(startPosition.offset, this.offset());
  8186. } else
  8187. break;
  8188. }
  8189. if (parsedSelectors.has(selector))
  8190. return this.error(parentArgType === "select" ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
  8191. selector === "other" && (hasOtherClause = !0), this.bumpSpace();
  8192. var openingBracePosition = this.clonePosition();
  8193. if (!this.bumpIf("{"))
  8194. return this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
  8195. var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
  8196. if (fragmentResult.err)
  8197. return fragmentResult;
  8198. var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
  8199. if (argCloseResult.err)
  8200. return argCloseResult;
  8201. options2.push([
  8202. selector,
  8203. {
  8204. value: fragmentResult.val,
  8205. location: createLocation(openingBracePosition, this.clonePosition())
  8206. }
  8207. ]), parsedSelectors.add(selector), this.bumpSpace(), _a2 = this.parseIdentifierIfPossible(), selector = _a2.value, selectorLocation = _a2.location;
  8208. }
  8209. return options2.length === 0 ? this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !hasOtherClause ? this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition())) : { val: options2, err: null };
  8210. }, Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
  8211. var sign = 1, startingPosition = this.clonePosition();
  8212. this.bumpIf("+") || this.bumpIf("-") && (sign = -1);
  8213. for (var hasDigits = !1, decimal = 0; !this.isEOF(); ) {
  8214. var ch = this.char();
  8215. if (ch >= 48 && ch <= 57)
  8216. hasDigits = !0, decimal = decimal * 10 + (ch - 48), this.bump();
  8217. else
  8218. break;
  8219. }
  8220. var location2 = createLocation(startingPosition, this.clonePosition());
  8221. return hasDigits ? (decimal *= sign, isSafeInteger(decimal) ? { val: decimal, err: null } : this.error(invalidNumberError, location2)) : this.error(expectNumberError, location2);
  8222. }, Parser2.prototype.offset = function() {
  8223. return this.position.offset;
  8224. }, Parser2.prototype.isEOF = function() {
  8225. return this.offset() === this.message.length;
  8226. }, Parser2.prototype.clonePosition = function() {
  8227. return {
  8228. offset: this.position.offset,
  8229. line: this.position.line,
  8230. column: this.position.column
  8231. };
  8232. }, Parser2.prototype.char = function() {
  8233. var offset2 = this.position.offset;
  8234. if (offset2 >= this.message.length)
  8235. throw Error("out of bound");
  8236. var code = codePointAt(this.message, offset2);
  8237. if (code === void 0)
  8238. throw Error("Offset ".concat(offset2, " is at invalid UTF-16 code unit boundary"));
  8239. return code;
  8240. }, Parser2.prototype.error = function(kind, location2) {
  8241. return {
  8242. val: null,
  8243. err: {
  8244. kind,
  8245. message: this.message,
  8246. location: location2
  8247. }
  8248. };
  8249. }, Parser2.prototype.bump = function() {
  8250. if (!this.isEOF()) {
  8251. var code = this.char();
  8252. code === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += code < 65536 ? 1 : 2);
  8253. }
  8254. }, Parser2.prototype.bumpIf = function(prefix) {
  8255. if (startsWith(this.message, prefix, this.offset())) {
  8256. for (var i2 = 0; i2 < prefix.length; i2++)
  8257. this.bump();
  8258. return !0;
  8259. }
  8260. return !1;
  8261. }, Parser2.prototype.bumpUntil = function(pattern) {
  8262. var currentOffset = this.offset(), index = this.message.indexOf(pattern, currentOffset);
  8263. return index >= 0 ? (this.bumpTo(index), !0) : (this.bumpTo(this.message.length), !1);
  8264. }, Parser2.prototype.bumpTo = function(targetOffset) {
  8265. if (this.offset() > targetOffset)
  8266. throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
  8267. for (targetOffset = Math.min(targetOffset, this.message.length); ; ) {
  8268. var offset2 = this.offset();
  8269. if (offset2 === targetOffset)
  8270. break;
  8271. if (offset2 > targetOffset)
  8272. throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
  8273. if (this.bump(), this.isEOF())
  8274. break;
  8275. }
  8276. }, Parser2.prototype.bumpSpace = function() {
  8277. for (; !this.isEOF() && _isWhiteSpace(this.char()); )
  8278. this.bump();
  8279. }, Parser2.prototype.peek = function() {
  8280. if (this.isEOF())
  8281. return null;
  8282. var code = this.char(), offset2 = this.offset(), nextCode = this.message.charCodeAt(offset2 + (code >= 65536 ? 2 : 1));
  8283. return nextCode ?? null;
  8284. }, Parser2;
  8285. })()
  8286. );
  8287. function _isAlpha(codepoint) {
  8288. return codepoint >= 97 && codepoint <= 122 || codepoint >= 65 && codepoint <= 90;
  8289. }
  8290. function _isAlphaOrSlash(codepoint) {
  8291. return _isAlpha(codepoint) || codepoint === 47;
  8292. }
  8293. function _isPotentialElementNameChar(c2) {
  8294. return c2 === 45 || c2 === 46 || c2 >= 48 && c2 <= 57 || c2 === 95 || c2 >= 97 && c2 <= 122 || c2 >= 65 && c2 <= 90 || c2 == 183 || c2 >= 192 && c2 <= 214 || c2 >= 216 && c2 <= 246 || c2 >= 248 && c2 <= 893 || c2 >= 895 && c2 <= 8191 || c2 >= 8204 && c2 <= 8205 || c2 >= 8255 && c2 <= 8256 || c2 >= 8304 && c2 <= 8591 || c2 >= 11264 && c2 <= 12271 || c2 >= 12289 && c2 <= 55295 || c2 >= 63744 && c2 <= 64975 || c2 >= 65008 && c2 <= 65533 || c2 >= 65536 && c2 <= 983039;
  8295. }
  8296. function _isWhiteSpace(c2) {
  8297. return c2 >= 9 && c2 <= 13 || c2 === 32 || c2 === 133 || c2 >= 8206 && c2 <= 8207 || c2 === 8232 || c2 === 8233;
  8298. }
  8299. function _isPatternSyntax(c2) {
  8300. return c2 >= 33 && c2 <= 35 || c2 === 36 || c2 >= 37 && c2 <= 39 || c2 === 40 || c2 === 41 || c2 === 42 || c2 === 43 || c2 === 44 || c2 === 45 || c2 >= 46 && c2 <= 47 || c2 >= 58 && c2 <= 59 || c2 >= 60 && c2 <= 62 || c2 >= 63 && c2 <= 64 || c2 === 91 || c2 === 92 || c2 === 93 || c2 === 94 || c2 === 96 || c2 === 123 || c2 === 124 || c2 === 125 || c2 === 126 || c2 === 161 || c2 >= 162 && c2 <= 165 || c2 === 166 || c2 === 167 || c2 === 169 || c2 === 171 || c2 === 172 || c2 === 174 || c2 === 176 || c2 === 177 || c2 === 182 || c2 === 187 || c2 === 191 || c2 === 215 || c2 === 247 || c2 >= 8208 && c2 <= 8213 || c2 >= 8214 && c2 <= 8215 || c2 === 8216 || c2 === 8217 || c2 === 8218 || c2 >= 8219 && c2 <= 8220 || c2 === 8221 || c2 === 8222 || c2 === 8223 || c2 >= 8224 && c2 <= 8231 || c2 >= 8240 && c2 <= 8248 || c2 === 8249 || c2 === 8250 || c2 >= 8251 && c2 <= 8254 || c2 >= 8257 && c2 <= 8259 || c2 === 8260 || c2 === 8261 || c2 === 8262 || c2 >= 8263 && c2 <= 8273 || c2 === 8274 || c2 === 8275 || c2 >= 8277 && c2 <= 8286 || c2 >= 8592 && c2 <= 8596 || c2 >= 8597 && c2 <= 8601 || c2 >= 8602 && c2 <= 8603 || c2 >= 8604 && c2 <= 8607 || c2 === 8608 || c2 >= 8609 && c2 <= 8610 || c2 === 8611 || c2 >= 8612 && c2 <= 8613 || c2 === 8614 || c2 >= 8615 && c2 <= 8621 || c2 === 8622 || c2 >= 8623 && c2 <= 8653 || c2 >= 8654 && c2 <= 8655 || c2 >= 8656 && c2 <= 8657 || c2 === 8658 || c2 === 8659 || c2 === 8660 || c2 >= 8661 && c2 <= 8691 || c2 >= 8692 && c2 <= 8959 || c2 >= 8960 && c2 <= 8967 || c2 === 8968 || c2 === 8969 || c2 === 8970 || c2 === 8971 || c2 >= 8972 && c2 <= 8991 || c2 >= 8992 && c2 <= 8993 || c2 >= 8994 && c2 <= 9e3 || c2 === 9001 || c2 === 9002 || c2 >= 9003 && c2 <= 9083 || c2 === 9084 || c2 >= 9085 && c2 <= 9114 || c2 >= 9115 && c2 <= 9139 || c2 >= 9140 && c2 <= 9179 || c2 >= 9180 && c2 <= 9185 || c2 >= 9186 && c2 <= 9254 || c2 >= 9255 && c2 <= 9279 || c2 >= 9280 && c2 <= 9290 || c2 >= 9291 && c2 <= 9311 || c2 >= 9472 && c2 <= 9654 || c2 === 9655 || c2 >= 9656 && c2 <= 9664 || c2 === 9665 || c2 >= 9666 && c2 <= 9719 || c2 >= 9720 && c2 <= 9727 || c2 >= 9728 && c2 <= 9838 || c2 === 9839 || c2 >= 9840 && c2 <= 10087 || c2 === 10088 || c2 === 10089 || c2 === 10090 || c2 === 10091 || c2 === 10092 || c2 === 10093 || c2 === 10094 || c2 === 10095 || c2 === 10096 || c2 === 10097 || c2 === 10098 || c2 === 10099 || c2 === 10100 || c2 === 10101 || c2 >= 10132 && c2 <= 10175 || c2 >= 10176 && c2 <= 10180 || c2 === 10181 || c2 === 10182 || c2 >= 10183 && c2 <= 10213 || c2 === 10214 || c2 === 10215 || c2 === 10216 || c2 === 10217 || c2 === 10218 || c2 === 10219 || c2 === 10220 || c2 === 10221 || c2 === 10222 || c2 === 10223 || c2 >= 10224 && c2 <= 10239 || c2 >= 10240 && c2 <= 10495 || c2 >= 10496 && c2 <= 10626 || c2 === 10627 || c2 === 10628 || c2 === 10629 || c2 === 10630 || c2 === 10631 || c2 === 10632 || c2 === 10633 || c2 === 10634 || c2 === 10635 || c2 === 10636 || c2 === 10637 || c2 === 10638 || c2 === 10639 || c2 === 10640 || c2 === 10641 || c2 === 10642 || c2 === 10643 || c2 === 10644 || c2 === 10645 || c2 === 10646 || c2 === 10647 || c2 === 10648 || c2 >= 10649 && c2 <= 10711 || c2 === 10712 || c2 === 10713 || c2 === 10714 || c2 === 10715 || c2 >= 10716 && c2 <= 10747 || c2 === 10748 || c2 === 10749 || c2 >= 10750 && c2 <= 11007 || c2 >= 11008 && c2 <= 11055 || c2 >= 11056 && c2 <= 11076 || c2 >= 11077 && c2 <= 11078 || c2 >= 11079 && c2 <= 11084 || c2 >= 11085 && c2 <= 11123 || c2 >= 11124 && c2 <= 11125 || c2 >= 11126 && c2 <= 11157 || c2 === 11158 || c2 >= 11159 && c2 <= 11263 || c2 >= 11776 && c2 <= 11777 || c2 === 11778 || c2 === 11779 || c2 === 11780 || c2 === 11781 || c2 >= 11782 && c2 <= 11784 || c2 === 11785 || c2 === 11786 || c2 === 11787 || c2 === 11788 || c2 === 11789 || c2 >= 11790 && c2 <= 11798 || c2 === 11799 || c2 >= 11800 && c2 <= 11801 || c2 === 11802 || c2 === 11803 || c2 === 11804 || c2 === 11805 || c2 >= 11806 && c2 <= 11807 || c2 === 11808 || c2 === 11809 || c2 === 11810 || c2 === 11811 || c2 === 11812 || c2 === 11813 || c2 === 11814 || c2 === 11815 || c2 === 11816 || c2 === 11817 || c2 >= 11818 && c2 <= 11822 || c2 === 11823 || c2 >= 11824 && c2 <= 11833 || c2 >= 11834 && c2 <= 11835 || c2 >= 11836 && c2 <= 11839 || c2 === 11840 || c2 === 11841 || c2 === 11842 || c2 >= 11843 && c2 <= 11855 || c2 >= 11856 && c2 <= 11857 || c2 === 11858 || c2 >= 11859 && c2 <= 11903 || c2 >= 12289 && c2 <= 12291 || c2 === 12296 || c2 === 12297 || c2 === 12298 || c2 === 12299 || c2 === 12300 || c2 === 12301 || c2 === 12302 || c2 === 12303 || c2 === 12304 || c2 === 12305 || c2 >= 12306 && c2 <= 12307 || c2 === 12308 || c2 === 12309 || c2 === 12310 || c2 === 12311 || c2 === 12312 || c2 === 12313 || c2 === 12314 || c2 === 12315 || c2 === 12316 || c2 === 12317 || c2 >= 12318 && c2 <= 12319 || c2 === 12320 || c2 === 12336 || c2 === 64830 || c2 === 64831 || c2 >= 65093 && c2 <= 65094;
  8301. }
  8302. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/index.js
  8303. function pruneLocation(els) {
  8304. els.forEach(function(el) {
  8305. if (delete el.location, isSelectElement(el) || isPluralElement(el))
  8306. for (var k2 in el.options)
  8307. delete el.options[k2].location, pruneLocation(el.options[k2].value);
  8308. else isNumberElement(el) && isNumberSkeleton(el.style) || (isDateElement(el) || isTimeElement(el)) && isDateTimeSkeleton(el.style) ? delete el.style.location : isTagElement(el) && pruneLocation(el.children);
  8309. });
  8310. }
  8311. function parse(message, opts) {
  8312. opts === void 0 && (opts = {}), opts = __assign({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, opts);
  8313. var result = new Parser(message, opts).parse();
  8314. if (result.err) {
  8315. var error = SyntaxError(ErrorKind[result.err.kind]);
  8316. throw error.location = result.err.location, error.originalMessage = result.err.message, error;
  8317. }
  8318. return opts?.captureLocation || pruneLocation(result.val), result.val;
  8319. }
  8320. // ../../node_modules/intl-messageformat/lib/src/error.js
  8321. var ErrorCode;
  8322. (function(ErrorCode2) {
  8323. ErrorCode2.MISSING_VALUE = "MISSING_VALUE", ErrorCode2.INVALID_VALUE = "INVALID_VALUE", ErrorCode2.MISSING_INTL_API = "MISSING_INTL_API";
  8324. })(ErrorCode || (ErrorCode = {}));
  8325. var FormatError = (
  8326. /** @class */
  8327. (function(_super) {
  8328. __extends(FormatError2, _super);
  8329. function FormatError2(msg, code, originalMessage) {
  8330. var _this = _super.call(this, msg) || this;
  8331. return _this.code = code, _this.originalMessage = originalMessage, _this;
  8332. }
  8333. return FormatError2.prototype.toString = function() {
  8334. return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
  8335. }, FormatError2;
  8336. })(Error)
  8337. );
  8338. var InvalidValueError = (
  8339. /** @class */
  8340. (function(_super) {
  8341. __extends(InvalidValueError2, _super);
  8342. function InvalidValueError2(variableId, value, options2, originalMessage) {
  8343. return _super.call(this, 'Invalid values for "'.concat(variableId, '": "').concat(value, '". Options are "').concat(Object.keys(options2).join('", "'), '"'), ErrorCode.INVALID_VALUE, originalMessage) || this;
  8344. }
  8345. return InvalidValueError2;
  8346. })(FormatError)
  8347. );
  8348. var InvalidValueTypeError = (
  8349. /** @class */
  8350. (function(_super) {
  8351. __extends(InvalidValueTypeError2, _super);
  8352. function InvalidValueTypeError2(value, type, originalMessage) {
  8353. return _super.call(this, 'Value for "'.concat(value, '" must be of type ').concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
  8354. }
  8355. return InvalidValueTypeError2;
  8356. })(FormatError)
  8357. );
  8358. var MissingValueError = (
  8359. /** @class */
  8360. (function(_super) {
  8361. __extends(MissingValueError2, _super);
  8362. function MissingValueError2(variableId, originalMessage) {
  8363. return _super.call(this, 'The intl string context variable "'.concat(variableId, '" was not provided to the string "').concat(originalMessage, '"'), ErrorCode.MISSING_VALUE, originalMessage) || this;
  8364. }
  8365. return MissingValueError2;
  8366. })(FormatError)
  8367. );
  8368. // ../../node_modules/intl-messageformat/lib/src/formatters.js
  8369. var PART_TYPE;
  8370. (function(PART_TYPE2) {
  8371. PART_TYPE2[PART_TYPE2.literal = 0] = "literal", PART_TYPE2[PART_TYPE2.object = 1] = "object";
  8372. })(PART_TYPE || (PART_TYPE = {}));
  8373. function mergeLiteral(parts) {
  8374. return parts.length < 2 ? parts : parts.reduce(function(all, part) {
  8375. var lastPart = all[all.length - 1];
  8376. return !lastPart || lastPart.type !== PART_TYPE.literal || part.type !== PART_TYPE.literal ? all.push(part) : lastPart.value += part.value, all;
  8377. }, []);
  8378. }
  8379. function isFormatXMLElementFn(el) {
  8380. return typeof el == "function";
  8381. }
  8382. function formatToParts(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
  8383. if (els.length === 1 && isLiteralElement(els[0]))
  8384. return [
  8385. {
  8386. type: PART_TYPE.literal,
  8387. value: els[0].value
  8388. }
  8389. ];
  8390. for (var result = [], _i = 0, els_1 = els; _i < els_1.length; _i++) {
  8391. var el = els_1[_i];
  8392. if (isLiteralElement(el)) {
  8393. result.push({
  8394. type: PART_TYPE.literal,
  8395. value: el.value
  8396. });
  8397. continue;
  8398. }
  8399. if (isPoundElement(el)) {
  8400. typeof currentPluralValue == "number" && result.push({
  8401. type: PART_TYPE.literal,
  8402. value: formatters.getNumberFormat(locales).format(currentPluralValue)
  8403. });
  8404. continue;
  8405. }
  8406. var varName = el.value;
  8407. if (!(values && varName in values))
  8408. throw new MissingValueError(varName, originalMessage);
  8409. var value = values[varName];
  8410. if (isArgumentElement(el)) {
  8411. (!value || typeof value == "string" || typeof value == "number") && (value = typeof value == "string" || typeof value == "number" ? String(value) : ""), result.push({
  8412. type: typeof value == "string" ? PART_TYPE.literal : PART_TYPE.object,
  8413. value
  8414. });
  8415. continue;
  8416. }
  8417. if (isDateElement(el)) {
  8418. var style = typeof el.style == "string" ? formats.date[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
  8419. result.push({
  8420. type: PART_TYPE.literal,
  8421. value: formatters.getDateTimeFormat(locales, style).format(value)
  8422. });
  8423. continue;
  8424. }
  8425. if (isTimeElement(el)) {
  8426. var style = typeof el.style == "string" ? formats.time[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : formats.time.medium;
  8427. result.push({
  8428. type: PART_TYPE.literal,
  8429. value: formatters.getDateTimeFormat(locales, style).format(value)
  8430. });
  8431. continue;
  8432. }
  8433. if (isNumberElement(el)) {
  8434. var style = typeof el.style == "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
  8435. style && style.scale && (value = value * (style.scale || 1)), result.push({
  8436. type: PART_TYPE.literal,
  8437. value: formatters.getNumberFormat(locales, style).format(value)
  8438. });
  8439. continue;
  8440. }
  8441. if (isTagElement(el)) {
  8442. var children = el.children, value_1 = el.value, formatFn = values[value_1];
  8443. if (!isFormatXMLElementFn(formatFn))
  8444. throw new InvalidValueTypeError(value_1, "function", originalMessage);
  8445. var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue), chunks = formatFn(parts.map(function(p2) {
  8446. return p2.value;
  8447. }));
  8448. Array.isArray(chunks) || (chunks = [chunks]), result.push.apply(result, chunks.map(function(c2) {
  8449. return {
  8450. type: typeof c2 == "string" ? PART_TYPE.literal : PART_TYPE.object,
  8451. value: c2
  8452. };
  8453. }));
  8454. }
  8455. if (isSelectElement(el)) {
  8456. var opt = el.options[value] || el.options.other;
  8457. if (!opt)
  8458. throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
  8459. result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
  8460. continue;
  8461. }
  8462. if (isPluralElement(el)) {
  8463. var opt = el.options["=".concat(value)];
  8464. if (!opt) {
  8465. if (!Intl.PluralRules)
  8466. throw new FormatError(`Intl.PluralRules is not available in this environment.
  8467. Try polyfilling it using "@formatjs/intl-pluralrules"
  8468. `, ErrorCode.MISSING_INTL_API, originalMessage);
  8469. var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
  8470. opt = el.options[rule] || el.options.other;
  8471. }
  8472. if (!opt)
  8473. throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
  8474. result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
  8475. continue;
  8476. }
  8477. }
  8478. return mergeLiteral(result);
  8479. }
  8480. // ../../node_modules/intl-messageformat/lib/src/core.js
  8481. function mergeConfig(c1, c2) {
  8482. return c2 ? __assign(__assign(__assign({}, c1 || {}), c2 || {}), Object.keys(c1).reduce(function(all, k2) {
  8483. return all[k2] = __assign(__assign({}, c1[k2]), c2[k2] || {}), all;
  8484. }, {})) : c1;
  8485. }
  8486. function mergeConfigs(defaultConfig, configs) {
  8487. return configs ? Object.keys(defaultConfig).reduce(function(all, k2) {
  8488. return all[k2] = mergeConfig(defaultConfig[k2], configs[k2]), all;
  8489. }, __assign({}, defaultConfig)) : defaultConfig;
  8490. }
  8491. function createFastMemoizeCache(store2) {
  8492. return {
  8493. create: function() {
  8494. return {
  8495. get: function(key) {
  8496. return store2[key];
  8497. },
  8498. set: function(key, value) {
  8499. store2[key] = value;
  8500. }
  8501. };
  8502. }
  8503. };
  8504. }
  8505. function createDefaultFormatters(cache) {
  8506. return cache === void 0 && (cache = {
  8507. number: {},
  8508. dateTime: {},
  8509. pluralRules: {}
  8510. }), {
  8511. getNumberFormat: memoize(function() {
  8512. for (var _a2, args = [], _i = 0; _i < arguments.length; _i++)
  8513. args[_i] = arguments[_i];
  8514. return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args, !1)))();
  8515. }, {
  8516. cache: createFastMemoizeCache(cache.number),
  8517. strategy: strategies.variadic
  8518. }),
  8519. getDateTimeFormat: memoize(function() {
  8520. for (var _a2, args = [], _i = 0; _i < arguments.length; _i++)
  8521. args[_i] = arguments[_i];
  8522. return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args, !1)))();
  8523. }, {
  8524. cache: createFastMemoizeCache(cache.dateTime),
  8525. strategy: strategies.variadic
  8526. }),
  8527. getPluralRules: memoize(function() {
  8528. for (var _a2, args = [], _i = 0; _i < arguments.length; _i++)
  8529. args[_i] = arguments[_i];
  8530. return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args, !1)))();
  8531. }, {
  8532. cache: createFastMemoizeCache(cache.pluralRules),
  8533. strategy: strategies.variadic
  8534. })
  8535. };
  8536. }
  8537. var IntlMessageFormat = (
  8538. /** @class */
  8539. (function() {
  8540. function IntlMessageFormat2(message, locales, overrideFormats, opts) {
  8541. locales === void 0 && (locales = IntlMessageFormat2.defaultLocale);
  8542. var _this = this;
  8543. if (this.formatterCache = {
  8544. number: {},
  8545. dateTime: {},
  8546. pluralRules: {}
  8547. }, this.format = function(values) {
  8548. var parts = _this.formatToParts(values);
  8549. if (parts.length === 1)
  8550. return parts[0].value;
  8551. var result = parts.reduce(function(all, part) {
  8552. return !all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] != "string" ? all.push(part.value) : all[all.length - 1] += part.value, all;
  8553. }, []);
  8554. return result.length <= 1 ? result[0] || "" : result;
  8555. }, this.formatToParts = function(values) {
  8556. return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, void 0, _this.message);
  8557. }, this.resolvedOptions = function() {
  8558. var _a3;
  8559. return {
  8560. locale: ((_a3 = _this.resolvedLocale) === null || _a3 === void 0 ? void 0 : _a3.toString()) || Intl.NumberFormat.supportedLocalesOf(_this.locales)[0]
  8561. };
  8562. }, this.getAst = function() {
  8563. return _this.ast;
  8564. }, this.locales = locales, this.resolvedLocale = IntlMessageFormat2.resolveLocale(locales), typeof message == "string") {
  8565. if (this.message = message, !IntlMessageFormat2.__parse)
  8566. throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
  8567. var _a2 = opts || {}, formatters = _a2.formatters, parseOpts = __rest(_a2, ["formatters"]);
  8568. this.ast = IntlMessageFormat2.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));
  8569. } else
  8570. this.ast = message;
  8571. if (!Array.isArray(this.ast))
  8572. throw new TypeError("A message must be provided as a String or AST.");
  8573. this.formats = mergeConfigs(IntlMessageFormat2.formats, overrideFormats), this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
  8574. }
  8575. return Object.defineProperty(IntlMessageFormat2, "defaultLocale", {
  8576. get: function() {
  8577. return IntlMessageFormat2.memoizedDefaultLocale || (IntlMessageFormat2.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), IntlMessageFormat2.memoizedDefaultLocale;
  8578. },
  8579. enumerable: !1,
  8580. configurable: !0
  8581. }), IntlMessageFormat2.memoizedDefaultLocale = null, IntlMessageFormat2.resolveLocale = function(locales) {
  8582. if (!(typeof Intl.Locale > "u")) {
  8583. var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
  8584. return supportedLocales.length > 0 ? new Intl.Locale(supportedLocales[0]) : new Intl.Locale(typeof locales == "string" ? locales : locales[0]);
  8585. }
  8586. }, IntlMessageFormat2.__parse = parse, IntlMessageFormat2.formats = {
  8587. number: {
  8588. integer: {
  8589. maximumFractionDigits: 0
  8590. },
  8591. currency: {
  8592. style: "currency"
  8593. },
  8594. percent: {
  8595. style: "percent"
  8596. }
  8597. },
  8598. date: {
  8599. short: {
  8600. month: "numeric",
  8601. day: "numeric",
  8602. year: "2-digit"
  8603. },
  8604. medium: {
  8605. month: "short",
  8606. day: "numeric",
  8607. year: "numeric"
  8608. },
  8609. long: {
  8610. month: "long",
  8611. day: "numeric",
  8612. year: "numeric"
  8613. },
  8614. full: {
  8615. weekday: "long",
  8616. month: "long",
  8617. day: "numeric",
  8618. year: "numeric"
  8619. }
  8620. },
  8621. time: {
  8622. short: {
  8623. hour: "numeric",
  8624. minute: "numeric"
  8625. },
  8626. medium: {
  8627. hour: "numeric",
  8628. minute: "numeric",
  8629. second: "numeric"
  8630. },
  8631. long: {
  8632. hour: "numeric",
  8633. minute: "numeric",
  8634. second: "numeric",
  8635. timeZoneName: "short"
  8636. },
  8637. full: {
  8638. hour: "numeric",
  8639. minute: "numeric",
  8640. second: "numeric",
  8641. timeZoneName: "short"
  8642. }
  8643. }
  8644. }, IntlMessageFormat2;
  8645. })()
  8646. );
  8647. // ../../node_modules/@react-aria/i18n/dist/useMessageFormatter.mjs
  8648. init_react();
  8649. // ../../node_modules/@internationalized/string/dist/LocalizedStringDictionary.mjs
  8650. var $5b160d28a433310d$var$localeSymbol = Symbol.for("react-aria.i18n.locale"), $5b160d28a433310d$var$stringsSymbol = Symbol.for("react-aria.i18n.strings");
  8651. // ../../node_modules/@react-aria/i18n/dist/useLocalizedStringFormatter.mjs
  8652. init_react();
  8653. // ../../node_modules/@react-aria/i18n/dist/useListFormatter.mjs
  8654. init_react();
  8655. // ../../node_modules/@internationalized/date/dist/string.mjs
  8656. var $fae977aafc393c5c$var$requiredDurationTimeGroups = [
  8657. "hours",
  8658. "minutes",
  8659. "seconds"
  8660. ], $fae977aafc393c5c$var$requiredDurationGroups = [
  8661. "years",
  8662. "months",
  8663. "weeks",
  8664. "days",
  8665. ...$fae977aafc393c5c$var$requiredDurationTimeGroups
  8666. ];
  8667. // ../../node_modules/@internationalized/date/dist/HebrewCalendar.mjs
  8668. var $7c5f6fbf42389787$var$HOUR_PARTS = 1080, $7c5f6fbf42389787$var$DAY_PARTS = 24 * $7c5f6fbf42389787$var$HOUR_PARTS, $7c5f6fbf42389787$var$MONTH_DAYS = 29, $7c5f6fbf42389787$var$MONTH_FRACT = 12 * $7c5f6fbf42389787$var$HOUR_PARTS + 793, $7c5f6fbf42389787$var$MONTH_PARTS = $7c5f6fbf42389787$var$MONTH_DAYS * $7c5f6fbf42389787$var$DAY_PARTS + $7c5f6fbf42389787$var$MONTH_FRACT;
  8669. // ../../node_modules/@react-aria/i18n/dist/useDateFormatter.mjs
  8670. init_react();
  8671. // ../../node_modules/@internationalized/number/dist/NumberFormatter.mjs
  8672. var $488c6ddbf4ef74c2$var$supportsSignDisplay = !1;
  8673. try {
  8674. $488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat("de-DE", {
  8675. signDisplay: "exceptZero"
  8676. }).resolvedOptions().signDisplay === "exceptZero";
  8677. } catch {
  8678. }
  8679. var $488c6ddbf4ef74c2$var$supportsUnit = !1;
  8680. try {
  8681. $488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat("de-DE", {
  8682. style: "unit",
  8683. unit: "degree"
  8684. }).resolvedOptions().style === "unit";
  8685. } catch {
  8686. }
  8687. // ../../node_modules/@internationalized/number/dist/NumberParser.mjs
  8688. var $6c7bd7858deea686$var$CURRENCY_SIGN_REGEX = new RegExp("^.*\\(.*\\).*$");
  8689. // ../../node_modules/@react-aria/i18n/dist/useNumberFormatter.mjs
  8690. init_react();
  8691. // ../../node_modules/@react-aria/i18n/dist/useFilter.mjs
  8692. init_react();
  8693. // ../../node_modules/@react-aria/overlays/dist/useOverlayPosition.mjs
  8694. var $2a41e45df1593e64$var$visualViewport = typeof document < "u" ? window.visualViewport : null;
  8695. function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
  8696. let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7(), { arrowSize, targetRef, overlayRef, arrowRef, scrollRef = overlayRef, placement = "bottom", containerPadding = 12, shouldFlip = !0, boundaryElement = typeof document < "u" ? document.body : null, offset: offset2 = 0, crossOffset = 0, shouldUpdatePosition = !0, isOpen = !0, onClose, maxHeight, arrowBoundaryOffset = 0 } = props, [position, setPosition] = useState(null), deps = [
  8697. shouldUpdatePosition,
  8698. placement,
  8699. overlayRef.current,
  8700. targetRef.current,
  8701. arrowRef?.current,
  8702. scrollRef.current,
  8703. containerPadding,
  8704. shouldFlip,
  8705. boundaryElement,
  8706. offset2,
  8707. crossOffset,
  8708. isOpen,
  8709. direction,
  8710. maxHeight,
  8711. arrowBoundaryOffset,
  8712. arrowSize
  8713. ], lastScale = useRef($2a41e45df1593e64$var$visualViewport?.scale);
  8714. useEffect(() => {
  8715. isOpen && (lastScale.current = $2a41e45df1593e64$var$visualViewport?.scale);
  8716. }, [
  8717. isOpen
  8718. ]);
  8719. let updatePosition = useCallback(() => {
  8720. if (shouldUpdatePosition === !1 || !isOpen || !overlayRef.current || !targetRef.current || !boundaryElement || $2a41e45df1593e64$var$visualViewport?.scale !== lastScale.current) return;
  8721. let anchor = null;
  8722. if (scrollRef.current && scrollRef.current.contains(document.activeElement)) {
  8723. var _document_activeElement;
  8724. let anchorRect = (_document_activeElement = document.activeElement) === null || _document_activeElement === void 0 ? void 0 : _document_activeElement.getBoundingClientRect(), scrollRect = scrollRef.current.getBoundingClientRect();
  8725. var _anchorRect_top;
  8726. if (anchor = {
  8727. type: "top",
  8728. offset: ((_anchorRect_top = anchorRect?.top) !== null && _anchorRect_top !== void 0 ? _anchorRect_top : 0) - scrollRect.top
  8729. }, anchor.offset > scrollRect.height / 2) {
  8730. anchor.type = "bottom";
  8731. var _anchorRect_bottom;
  8732. anchor.offset = ((_anchorRect_bottom = anchorRect?.bottom) !== null && _anchorRect_bottom !== void 0 ? _anchorRect_bottom : 0) - scrollRect.bottom;
  8733. }
  8734. }
  8735. let overlay = overlayRef.current;
  8736. if (!maxHeight && overlayRef.current) {
  8737. var _window_visualViewport;
  8738. overlay.style.top = "0px", overlay.style.bottom = "";
  8739. var _window_visualViewport_height;
  8740. overlay.style.maxHeight = ((_window_visualViewport_height = (_window_visualViewport = window.visualViewport) === null || _window_visualViewport === void 0 ? void 0 : _window_visualViewport.height) !== null && _window_visualViewport_height !== void 0 ? _window_visualViewport_height : window.innerHeight) + "px";
  8741. }
  8742. let position2 = $edcf132a9284368a$export$b3ceb0cbf1056d98({
  8743. placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
  8744. overlayNode: overlayRef.current,
  8745. targetNode: targetRef.current,
  8746. scrollNode: scrollRef.current || overlayRef.current,
  8747. padding: containerPadding,
  8748. shouldFlip,
  8749. boundaryElement,
  8750. offset: offset2,
  8751. crossOffset,
  8752. maxHeight,
  8753. arrowSize: arrowSize ?? (arrowRef?.current ? $edcf132a9284368a$export$4b834cebd9e5cebe(arrowRef.current, !0).width : 0),
  8754. arrowBoundaryOffset
  8755. });
  8756. if (position2.position) {
  8757. if (overlay.style.top = "", overlay.style.bottom = "", overlay.style.left = "", overlay.style.right = "", Object.keys(position2.position).forEach((key) => overlay.style[key] = position2.position[key] + "px"), overlay.style.maxHeight = position2.maxHeight != null ? position2.maxHeight + "px" : "", anchor && document.activeElement && scrollRef.current) {
  8758. let anchorRect = document.activeElement.getBoundingClientRect(), scrollRect = scrollRef.current.getBoundingClientRect(), newOffset = anchorRect[anchor.type] - scrollRect[anchor.type];
  8759. scrollRef.current.scrollTop += newOffset - anchor.offset;
  8760. }
  8761. setPosition(position2);
  8762. }
  8763. }, deps);
  8764. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(updatePosition, deps), $2a41e45df1593e64$var$useResize(updatePosition), $9daab02d461809db$export$683480f191c0e3ea({
  8765. ref: overlayRef,
  8766. onResize: updatePosition
  8767. }), $9daab02d461809db$export$683480f191c0e3ea({
  8768. ref: targetRef,
  8769. onResize: updatePosition
  8770. });
  8771. let isResizing = useRef(!1);
  8772. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  8773. let timeout, onResize = () => {
  8774. isResizing.current = !0, clearTimeout(timeout), timeout = setTimeout(() => {
  8775. isResizing.current = !1;
  8776. }, 500), updatePosition();
  8777. }, onScroll = () => {
  8778. isResizing.current && onResize();
  8779. };
  8780. return $2a41e45df1593e64$var$visualViewport?.addEventListener("resize", onResize), $2a41e45df1593e64$var$visualViewport?.addEventListener("scroll", onScroll), () => {
  8781. $2a41e45df1593e64$var$visualViewport?.removeEventListener("resize", onResize), $2a41e45df1593e64$var$visualViewport?.removeEventListener("scroll", onScroll);
  8782. };
  8783. }, [
  8784. updatePosition
  8785. ]);
  8786. let close = useCallback(() => {
  8787. isResizing.current || onClose?.();
  8788. }, [
  8789. onClose,
  8790. isResizing
  8791. ]);
  8792. $dd149f63282afbbf$export$18fc8428861184da({
  8793. triggerRef: targetRef,
  8794. isOpen,
  8795. onClose: onClose && close
  8796. });
  8797. var _position_maxHeight, _position_placement, _position_triggerAnchorPoint;
  8798. return {
  8799. overlayProps: {
  8800. style: {
  8801. position: position ? "absolute" : "fixed",
  8802. top: position ? void 0 : 0,
  8803. left: position ? void 0 : 0,
  8804. zIndex: 1e5,
  8805. ...position?.position,
  8806. maxHeight: (_position_maxHeight = position?.maxHeight) !== null && _position_maxHeight !== void 0 ? _position_maxHeight : "100vh"
  8807. }
  8808. },
  8809. placement: (_position_placement = position?.placement) !== null && _position_placement !== void 0 ? _position_placement : null,
  8810. triggerAnchorPoint: (_position_triggerAnchorPoint = position?.triggerAnchorPoint) !== null && _position_triggerAnchorPoint !== void 0 ? _position_triggerAnchorPoint : null,
  8811. arrowProps: {
  8812. "aria-hidden": "true",
  8813. role: "presentation",
  8814. style: {
  8815. left: position?.arrowOffsetLeft,
  8816. top: position?.arrowOffsetTop
  8817. }
  8818. },
  8819. updatePosition
  8820. };
  8821. }
  8822. function $2a41e45df1593e64$var$useResize(onResize) {
  8823. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => (window.addEventListener("resize", onResize, !1), () => {
  8824. window.removeEventListener("resize", onResize, !1);
  8825. }), [
  8826. onResize
  8827. ]);
  8828. }
  8829. function $2a41e45df1593e64$var$translateRTL(position, direction) {
  8830. return direction === "rtl" ? position.replace("start", "right").replace("end", "left") : position.replace("start", "left").replace("end", "right");
  8831. }
  8832. // ../../node_modules/@react-aria/focus/dist/FocusScope.mjs
  8833. init_react();
  8834. var $9bf71ea28793e738$var$FocusContext = react_default.createContext(null);
  8835. function $9bf71ea28793e738$var$isElementInScope(element, scope2) {
  8836. return !element || !scope2 ? !1 : scope2.some((node) => node.contains(element));
  8837. }
  8838. var $9bf71ea28793e738$var$Tree = class _$9bf71ea28793e738$var$Tree {
  8839. get size() {
  8840. return this.fastMap.size;
  8841. }
  8842. getTreeNode(data) {
  8843. return this.fastMap.get(data);
  8844. }
  8845. addTreeNode(scopeRef, parent, nodeToRestore) {
  8846. let parentNode = this.fastMap.get(parent ?? null);
  8847. if (!parentNode) return;
  8848. let node = new $9bf71ea28793e738$var$TreeNode({
  8849. scopeRef
  8850. });
  8851. parentNode.addChild(node), node.parent = parentNode, this.fastMap.set(scopeRef, node), nodeToRestore && (node.nodeToRestore = nodeToRestore);
  8852. }
  8853. addNode(node) {
  8854. this.fastMap.set(node.scopeRef, node);
  8855. }
  8856. removeTreeNode(scopeRef) {
  8857. if (scopeRef === null) return;
  8858. let node = this.fastMap.get(scopeRef);
  8859. if (!node) return;
  8860. let parentNode = node.parent;
  8861. for (let current of this.traverse()) current !== node && node.nodeToRestore && current.nodeToRestore && node.scopeRef && node.scopeRef.current && $9bf71ea28793e738$var$isElementInScope(current.nodeToRestore, node.scopeRef.current) && (current.nodeToRestore = node.nodeToRestore);
  8862. let children = node.children;
  8863. parentNode && (parentNode.removeChild(node), children.size > 0 && children.forEach((child) => parentNode && parentNode.addChild(child))), this.fastMap.delete(node.scopeRef);
  8864. }
  8865. // Pre Order Depth First
  8866. *traverse(node = this.root) {
  8867. if (node.scopeRef != null && (yield node), node.children.size > 0) for (let child of node.children) yield* this.traverse(child);
  8868. }
  8869. clone() {
  8870. var _node_parent;
  8871. let newTree = new _$9bf71ea28793e738$var$Tree();
  8872. var _node_parent_scopeRef;
  8873. for (let node of this.traverse()) newTree.addTreeNode(node.scopeRef, (_node_parent_scopeRef = (_node_parent = node.parent) === null || _node_parent === void 0 ? void 0 : _node_parent.scopeRef) !== null && _node_parent_scopeRef !== void 0 ? _node_parent_scopeRef : null, node.nodeToRestore);
  8874. return newTree;
  8875. }
  8876. constructor() {
  8877. this.fastMap = /* @__PURE__ */ new Map(), this.root = new $9bf71ea28793e738$var$TreeNode({
  8878. scopeRef: null
  8879. }), this.fastMap.set(null, this.root);
  8880. }
  8881. }, $9bf71ea28793e738$var$TreeNode = class {
  8882. addChild(node) {
  8883. this.children.add(node), node.parent = this;
  8884. }
  8885. removeChild(node) {
  8886. this.children.delete(node), node.parent = void 0;
  8887. }
  8888. constructor(props) {
  8889. this.children = /* @__PURE__ */ new Set(), this.contain = !1, this.scopeRef = props.scopeRef;
  8890. }
  8891. }, $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
  8892. // ../../node_modules/@react-aria/focus/dist/useFocusRing.mjs
  8893. init_react();
  8894. // ../../node_modules/@react-aria/focus/dist/FocusRing.mjs
  8895. init_react();
  8896. // ../../node_modules/@react-aria/focus/dist/useHasTabbableChild.mjs
  8897. init_react();
  8898. // ../../node_modules/@react-aria/overlays/dist/useOverlay.mjs
  8899. init_react();
  8900. // ../../node_modules/@react-aria/overlays/dist/useOverlayTrigger.mjs
  8901. init_react();
  8902. // ../../node_modules/@react-aria/overlays/dist/usePreventScroll.mjs
  8903. var $49c51c25361d4cd2$var$visualViewport = typeof document < "u" && window.visualViewport;
  8904. // ../../node_modules/@react-aria/overlays/dist/PortalProvider.mjs
  8905. init_react();
  8906. var $96b38030c423d352$export$60d741e20e0aa309 = createContext({});
  8907. function $96b38030c423d352$export$9fc1347d4195ccb3() {
  8908. var _useContext;
  8909. return (_useContext = useContext($96b38030c423d352$export$60d741e20e0aa309)) !== null && _useContext !== void 0 ? _useContext : {};
  8910. }
  8911. // ../../node_modules/@react-aria/overlays/dist/useModal.mjs
  8912. init_react();
  8913. var $f57aed4a881a3485$var$Context = react_default.createContext(null);
  8914. function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
  8915. let { children } = props, parent = useContext($f57aed4a881a3485$var$Context), [modalCount, setModalCount] = useState(0), context = useMemo(() => ({
  8916. parent,
  8917. modalCount,
  8918. addModal() {
  8919. setModalCount((count) => count + 1), parent && parent.addModal();
  8920. },
  8921. removeModal() {
  8922. setModalCount((count) => count - 1), parent && parent.removeModal();
  8923. }
  8924. }), [
  8925. parent,
  8926. modalCount
  8927. ]);
  8928. return react_default.createElement($f57aed4a881a3485$var$Context.Provider, {
  8929. value: context
  8930. }, children);
  8931. }
  8932. function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
  8933. let context = useContext($f57aed4a881a3485$var$Context);
  8934. return {
  8935. modalProviderProps: {
  8936. "aria-hidden": context && context.modalCount > 0 ? !0 : void 0
  8937. }
  8938. };
  8939. }
  8940. function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
  8941. let { modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
  8942. return react_default.createElement("div", {
  8943. "data-overlay-container": !0,
  8944. ...props,
  8945. ...modalProviderProps
  8946. });
  8947. }
  8948. function $f57aed4a881a3485$export$bf688221f59024e5(props) {
  8949. return react_default.createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, react_default.createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
  8950. }
  8951. function $f57aed4a881a3485$export$b47c3594eab58386(props) {
  8952. let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273(), { portalContainer = isSSR ? null : document.body, ...rest2 } = props, { getContainer } = $96b38030c423d352$export$9fc1347d4195ccb3();
  8953. if (!props.portalContainer && getContainer && (portalContainer = getContainer()), react_default.useEffect(() => {
  8954. if (portalContainer?.closest("[data-overlay-container]")) throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.");
  8955. }, [
  8956. portalContainer
  8957. ]), !portalContainer) return null;
  8958. let contents = react_default.createElement($f57aed4a881a3485$export$bf688221f59024e5, rest2);
  8959. return react_dom_default.createPortal(contents, portalContainer);
  8960. }
  8961. // ../../node_modules/@react-aria/overlays/dist/ar-AE.mjs
  8962. var $773d5888b972f1cf$exports = {};
  8963. $773d5888b972f1cf$exports = {
  8964. dismiss: "\u062A\u062C\u0627\u0647\u0644"
  8965. };
  8966. // ../../node_modules/@react-aria/overlays/dist/bg-BG.mjs
  8967. var $d11f19852b941573$exports = {};
  8968. $d11f19852b941573$exports = {
  8969. dismiss: "\u041E\u0442\u0445\u0432\u044A\u0440\u043B\u044F\u043D\u0435"
  8970. };
  8971. // ../../node_modules/@react-aria/overlays/dist/cs-CZ.mjs
  8972. var $b983974c2ee1efb3$exports = {};
  8973. $b983974c2ee1efb3$exports = {
  8974. dismiss: "Odstranit"
  8975. };
  8976. // ../../node_modules/@react-aria/overlays/dist/da-DK.mjs
  8977. var $5809cc9d4e92de73$exports = {};
  8978. $5809cc9d4e92de73$exports = {
  8979. dismiss: "Luk"
  8980. };
  8981. // ../../node_modules/@react-aria/overlays/dist/de-DE.mjs
  8982. var $c68c2e4fc74398d1$exports = {};
  8983. $c68c2e4fc74398d1$exports = {
  8984. dismiss: "Schlie\xDFen"
  8985. };
  8986. // ../../node_modules/@react-aria/overlays/dist/el-GR.mjs
  8987. var $0898b4c153db2b77$exports = {};
  8988. $0898b4c153db2b77$exports = {
  8989. dismiss: "\u0391\u03C0\u03CC\u03C1\u03C1\u03B9\u03C8\u03B7"
  8990. };
  8991. // ../../node_modules/@react-aria/overlays/dist/en-US.mjs
  8992. var $6d74810286a15183$exports = {};
  8993. $6d74810286a15183$exports = {
  8994. dismiss: "Dismiss"
  8995. };
  8996. // ../../node_modules/@react-aria/overlays/dist/es-ES.mjs
  8997. var $309d73dc65f78055$exports = {};
  8998. $309d73dc65f78055$exports = {
  8999. dismiss: "Descartar"
  9000. };
  9001. // ../../node_modules/@react-aria/overlays/dist/et-EE.mjs
  9002. var $44ad94f7205cf593$exports = {};
  9003. $44ad94f7205cf593$exports = {
  9004. dismiss: "L\xF5peta"
  9005. };
  9006. // ../../node_modules/@react-aria/overlays/dist/fi-FI.mjs
  9007. var $7c28f5687f0779a9$exports = {};
  9008. $7c28f5687f0779a9$exports = {
  9009. dismiss: "Hylk\xE4\xE4"
  9010. };
  9011. // ../../node_modules/@react-aria/overlays/dist/fr-FR.mjs
  9012. var $e6d75df4b68bd73a$exports = {};
  9013. $e6d75df4b68bd73a$exports = {
  9014. dismiss: "Rejeter"
  9015. };
  9016. // ../../node_modules/@react-aria/overlays/dist/he-IL.mjs
  9017. var $87505c9dab186d0f$exports = {};
  9018. $87505c9dab186d0f$exports = {
  9019. dismiss: "\u05D4\u05EA\u05E2\u05DC\u05DD"
  9020. };
  9021. // ../../node_modules/@react-aria/overlays/dist/hr-HR.mjs
  9022. var $553439c3ffb3e492$exports = {};
  9023. $553439c3ffb3e492$exports = {
  9024. dismiss: "Odbaci"
  9025. };
  9026. // ../../node_modules/@react-aria/overlays/dist/hu-HU.mjs
  9027. var $74cf411061b983a2$exports = {};
  9028. $74cf411061b983a2$exports = {
  9029. dismiss: "Elutas\xEDt\xE1s"
  9030. };
  9031. // ../../node_modules/@react-aria/overlays/dist/it-IT.mjs
  9032. var $e933f298574dc435$exports = {};
  9033. $e933f298574dc435$exports = {
  9034. dismiss: "Ignora"
  9035. };
  9036. // ../../node_modules/@react-aria/overlays/dist/ja-JP.mjs
  9037. var $ac91fc9fe02f71f6$exports = {};
  9038. $ac91fc9fe02f71f6$exports = {
  9039. dismiss: "\u9589\u3058\u308B"
  9040. };
  9041. // ../../node_modules/@react-aria/overlays/dist/ko-KR.mjs
  9042. var $52b96f86422025af$exports = {};
  9043. $52b96f86422025af$exports = {
  9044. dismiss: "\uBB34\uC2DC"
  9045. };
  9046. // ../../node_modules/@react-aria/overlays/dist/lt-LT.mjs
  9047. var $c0d724c3e51dafa6$exports = {};
  9048. $c0d724c3e51dafa6$exports = {
  9049. dismiss: "Atmesti"
  9050. };
  9051. // ../../node_modules/@react-aria/overlays/dist/lv-LV.mjs
  9052. var $c92899672a3fe72e$exports = {};
  9053. $c92899672a3fe72e$exports = {
  9054. dismiss: "Ner\u0101d\u012Bt"
  9055. };
  9056. // ../../node_modules/@react-aria/overlays/dist/nb-NO.mjs
  9057. var $9f576b39d8e7a9d6$exports = {};
  9058. $9f576b39d8e7a9d6$exports = {
  9059. dismiss: "Lukk"
  9060. };
  9061. // ../../node_modules/@react-aria/overlays/dist/nl-NL.mjs
  9062. var $9d025808aeec81a7$exports = {};
  9063. $9d025808aeec81a7$exports = {
  9064. dismiss: "Negeren"
  9065. };
  9066. // ../../node_modules/@react-aria/overlays/dist/pl-PL.mjs
  9067. var $fce709921e2c0fa6$exports = {};
  9068. $fce709921e2c0fa6$exports = {
  9069. dismiss: "Zignoruj"
  9070. };
  9071. // ../../node_modules/@react-aria/overlays/dist/pt-BR.mjs
  9072. var $2599cf0c4ab37f59$exports = {};
  9073. $2599cf0c4ab37f59$exports = {
  9074. dismiss: "Descartar"
  9075. };
  9076. // ../../node_modules/@react-aria/overlays/dist/pt-PT.mjs
  9077. var $3c220ae7ef8a35fd$exports = {};
  9078. $3c220ae7ef8a35fd$exports = {
  9079. dismiss: "Dispensar"
  9080. };
  9081. // ../../node_modules/@react-aria/overlays/dist/ro-RO.mjs
  9082. var $93562b5094072f54$exports = {};
  9083. $93562b5094072f54$exports = {
  9084. dismiss: "Revocare"
  9085. };
  9086. // ../../node_modules/@react-aria/overlays/dist/ru-RU.mjs
  9087. var $cd9e2abd0d06c7b4$exports = {};
  9088. $cd9e2abd0d06c7b4$exports = {
  9089. dismiss: "\u041F\u0440\u043E\u043F\u0443\u0441\u0442\u0438\u0442\u044C"
  9090. };
  9091. // ../../node_modules/@react-aria/overlays/dist/sk-SK.mjs
  9092. var $45375701f409adf1$exports = {};
  9093. $45375701f409adf1$exports = {
  9094. dismiss: "Zru\u0161i\u0165"
  9095. };
  9096. // ../../node_modules/@react-aria/overlays/dist/sl-SI.mjs
  9097. var $27fab53a576de9dd$exports = {};
  9098. $27fab53a576de9dd$exports = {
  9099. dismiss: "Opusti"
  9100. };
  9101. // ../../node_modules/@react-aria/overlays/dist/sr-SP.mjs
  9102. var $4438748d9952e7c7$exports = {};
  9103. $4438748d9952e7c7$exports = {
  9104. dismiss: "Odbaci"
  9105. };
  9106. // ../../node_modules/@react-aria/overlays/dist/sv-SE.mjs
  9107. var $0936d7347ef4da4c$exports = {};
  9108. $0936d7347ef4da4c$exports = {
  9109. dismiss: "Avvisa"
  9110. };
  9111. // ../../node_modules/@react-aria/overlays/dist/tr-TR.mjs
  9112. var $29700c92185d38f8$exports = {};
  9113. $29700c92185d38f8$exports = {
  9114. dismiss: "Kapat"
  9115. };
  9116. // ../../node_modules/@react-aria/overlays/dist/uk-UA.mjs
  9117. var $662ccaf2be4c25b3$exports = {};
  9118. $662ccaf2be4c25b3$exports = {
  9119. dismiss: "\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438"
  9120. };
  9121. // ../../node_modules/@react-aria/overlays/dist/zh-CN.mjs
  9122. var $d80a27deda7cdb3c$exports = {};
  9123. $d80a27deda7cdb3c$exports = {
  9124. dismiss: "\u53D6\u6D88"
  9125. };
  9126. // ../../node_modules/@react-aria/overlays/dist/zh-TW.mjs
  9127. var $2b2734393847c884$exports = {};
  9128. $2b2734393847c884$exports = {
  9129. dismiss: "\u95DC\u9589"
  9130. };
  9131. // ../../node_modules/@react-aria/overlays/dist/intlStrings.mjs
  9132. var $a2f21f5f14f60553$exports = {};
  9133. $a2f21f5f14f60553$exports = {
  9134. "ar-AE": $773d5888b972f1cf$exports,
  9135. "bg-BG": $d11f19852b941573$exports,
  9136. "cs-CZ": $b983974c2ee1efb3$exports,
  9137. "da-DK": $5809cc9d4e92de73$exports,
  9138. "de-DE": $c68c2e4fc74398d1$exports,
  9139. "el-GR": $0898b4c153db2b77$exports,
  9140. "en-US": $6d74810286a15183$exports,
  9141. "es-ES": $309d73dc65f78055$exports,
  9142. "et-EE": $44ad94f7205cf593$exports,
  9143. "fi-FI": $7c28f5687f0779a9$exports,
  9144. "fr-FR": $e6d75df4b68bd73a$exports,
  9145. "he-IL": $87505c9dab186d0f$exports,
  9146. "hr-HR": $553439c3ffb3e492$exports,
  9147. "hu-HU": $74cf411061b983a2$exports,
  9148. "it-IT": $e933f298574dc435$exports,
  9149. "ja-JP": $ac91fc9fe02f71f6$exports,
  9150. "ko-KR": $52b96f86422025af$exports,
  9151. "lt-LT": $c0d724c3e51dafa6$exports,
  9152. "lv-LV": $c92899672a3fe72e$exports,
  9153. "nb-NO": $9f576b39d8e7a9d6$exports,
  9154. "nl-NL": $9d025808aeec81a7$exports,
  9155. "pl-PL": $fce709921e2c0fa6$exports,
  9156. "pt-BR": $2599cf0c4ab37f59$exports,
  9157. "pt-PT": $3c220ae7ef8a35fd$exports,
  9158. "ro-RO": $93562b5094072f54$exports,
  9159. "ru-RU": $cd9e2abd0d06c7b4$exports,
  9160. "sk-SK": $45375701f409adf1$exports,
  9161. "sl-SI": $27fab53a576de9dd$exports,
  9162. "sr-SP": $4438748d9952e7c7$exports,
  9163. "sv-SE": $0936d7347ef4da4c$exports,
  9164. "tr-TR": $29700c92185d38f8$exports,
  9165. "uk-UA": $662ccaf2be4c25b3$exports,
  9166. "zh-CN": $d80a27deda7cdb3c$exports,
  9167. "zh-TW": $2b2734393847c884$exports
  9168. };
  9169. // ../../node_modules/@react-aria/overlays/dist/DismissButton.mjs
  9170. init_react();
  9171. // ../../node_modules/@react-aria/visually-hidden/dist/VisuallyHidden.mjs
  9172. init_react();
  9173. // ../../node_modules/@react-aria/overlays/dist/ariaHideOutside.mjs
  9174. var $5e3802645cc19319$var$supportsInert = typeof HTMLElement < "u" && "inert" in HTMLElement.prototype;
  9175. // ../../node_modules/@react-aria/overlays/dist/usePopover.mjs
  9176. init_react();
  9177. // ../../node_modules/@react-aria/overlays/dist/Overlay.mjs
  9178. init_react();
  9179. var $337b884510726a0d$export$a2200b96afd16271 = react_default.createContext(null);
  9180. // ../../node_modules/@react-aria/overlays/dist/useModalOverlay.mjs
  9181. init_react();
  9182. // ../../node_modules/@react-stately/tooltip/dist/useTooltipTriggerState.mjs
  9183. init_react();
  9184. // ../../node_modules/@react-stately/overlays/dist/useOverlayTriggerState.mjs
  9185. init_react();
  9186. function $fc909762b330b746$export$61c6a8c84e605fb6(props) {
  9187. let [isOpen, setOpen] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(props.isOpen, props.defaultOpen || !1, props.onOpenChange), open = useCallback(() => {
  9188. setOpen(!0);
  9189. }, [
  9190. setOpen
  9191. ]), close = useCallback(() => {
  9192. setOpen(!1);
  9193. }, [
  9194. setOpen
  9195. ]), toggle = useCallback(() => {
  9196. setOpen(!isOpen);
  9197. }, [
  9198. setOpen,
  9199. isOpen
  9200. ]);
  9201. return {
  9202. isOpen,
  9203. setOpen,
  9204. open,
  9205. close,
  9206. toggle
  9207. };
  9208. }
  9209. // ../../node_modules/@react-stately/tooltip/dist/useTooltipTriggerState.mjs
  9210. var $8796f90736e175cb$var$TOOLTIP_DELAY = 1500, $8796f90736e175cb$var$TOOLTIP_COOLDOWN = 500, $8796f90736e175cb$var$tooltips = {}, $8796f90736e175cb$var$tooltipId = 0, $8796f90736e175cb$var$globalWarmedUp = !1, $8796f90736e175cb$var$globalWarmUpTimeout = null, $8796f90736e175cb$var$globalCooldownTimeout = null;
  9211. function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
  9212. let { delay: delay2 = $8796f90736e175cb$var$TOOLTIP_DELAY, closeDelay = $8796f90736e175cb$var$TOOLTIP_COOLDOWN } = props, { isOpen, open, close } = $fc909762b330b746$export$61c6a8c84e605fb6(props), id = useMemo(() => `${++$8796f90736e175cb$var$tooltipId}`, []), closeTimeout = useRef(null), closeCallback = useRef(close), ensureTooltipEntry = () => {
  9213. $8796f90736e175cb$var$tooltips[id] = hideTooltip;
  9214. }, closeOpenTooltips = () => {
  9215. for (let hideTooltipId in $8796f90736e175cb$var$tooltips) hideTooltipId !== id && ($8796f90736e175cb$var$tooltips[hideTooltipId](!0), delete $8796f90736e175cb$var$tooltips[hideTooltipId]);
  9216. }, showTooltip = () => {
  9217. closeTimeout.current && clearTimeout(closeTimeout.current), closeTimeout.current = null, closeOpenTooltips(), ensureTooltipEntry(), $8796f90736e175cb$var$globalWarmedUp = !0, open(), $8796f90736e175cb$var$globalWarmUpTimeout && (clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout), $8796f90736e175cb$var$globalWarmUpTimeout = null), $8796f90736e175cb$var$globalCooldownTimeout && (clearTimeout($8796f90736e175cb$var$globalCooldownTimeout), $8796f90736e175cb$var$globalCooldownTimeout = null);
  9218. }, hideTooltip = (immediate) => {
  9219. immediate || closeDelay <= 0 ? (closeTimeout.current && clearTimeout(closeTimeout.current), closeTimeout.current = null, closeCallback.current()) : closeTimeout.current || (closeTimeout.current = setTimeout(() => {
  9220. closeTimeout.current = null, closeCallback.current();
  9221. }, closeDelay)), $8796f90736e175cb$var$globalWarmUpTimeout && (clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout), $8796f90736e175cb$var$globalWarmUpTimeout = null), $8796f90736e175cb$var$globalWarmedUp && ($8796f90736e175cb$var$globalCooldownTimeout && clearTimeout($8796f90736e175cb$var$globalCooldownTimeout), $8796f90736e175cb$var$globalCooldownTimeout = setTimeout(() => {
  9222. delete $8796f90736e175cb$var$tooltips[id], $8796f90736e175cb$var$globalCooldownTimeout = null, $8796f90736e175cb$var$globalWarmedUp = !1;
  9223. }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay)));
  9224. }, warmupTooltip = () => {
  9225. closeOpenTooltips(), ensureTooltipEntry(), !isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp ? $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(() => {
  9226. $8796f90736e175cb$var$globalWarmUpTimeout = null, $8796f90736e175cb$var$globalWarmedUp = !0, showTooltip();
  9227. }, delay2) : isOpen || showTooltip();
  9228. };
  9229. return useEffect(() => {
  9230. closeCallback.current = close;
  9231. }, [
  9232. close
  9233. ]), useEffect(() => () => {
  9234. closeTimeout.current && clearTimeout(closeTimeout.current), $8796f90736e175cb$var$tooltips[id] && delete $8796f90736e175cb$var$tooltips[id];
  9235. }, [
  9236. id
  9237. ]), {
  9238. isOpen,
  9239. open: (immediate) => {
  9240. !immediate && delay2 > 0 && !closeTimeout.current ? warmupTooltip() : showTooltip();
  9241. },
  9242. close: hideTooltip
  9243. };
  9244. }
  9245. // ../../node_modules/react-aria-components/dist/Tooltip.mjs
  9246. init_react();
  9247. var $4e3b923658d69c60$export$7a7623236eec67fa = createContext(null), $4e3b923658d69c60$export$39ae08fa83328b12 = createContext(null);
  9248. function $4e3b923658d69c60$export$8c610744efcf8a1d(props) {
  9249. let state = $8796f90736e175cb$export$4d40659c25ecb50b(props), ref = useRef(null), { triggerProps, tooltipProps } = $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref);
  9250. return react_default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
  9251. values: [
  9252. [
  9253. $4e3b923658d69c60$export$7a7623236eec67fa,
  9254. state
  9255. ],
  9256. [
  9257. $4e3b923658d69c60$export$39ae08fa83328b12,
  9258. {
  9259. ...tooltipProps,
  9260. triggerRef: ref
  9261. }
  9262. ]
  9263. ]
  9264. }, react_default.createElement($f645667febf57a63$export$13f3202a3e5ddd5, {
  9265. ...triggerProps,
  9266. ref
  9267. }, props.children));
  9268. }
  9269. var $4e3b923658d69c60$export$28c660c63b792dea = forwardRef(function({ UNSTABLE_portalContainer, ...props }, ref) {
  9270. [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $4e3b923658d69c60$export$39ae08fa83328b12);
  9271. let contextState = useContext($4e3b923658d69c60$export$7a7623236eec67fa), localState = $8796f90736e175cb$export$4d40659c25ecb50b(props), state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState, isExiting = $d3f049242431219c$export$45fda7c47f93fd48(ref, state.isOpen) || props.isExiting || !1;
  9272. return !state.isOpen && !isExiting ? null : react_default.createElement($f57aed4a881a3485$export$b47c3594eab58386, {
  9273. portalContainer: UNSTABLE_portalContainer
  9274. }, react_default.createElement($4e3b923658d69c60$var$TooltipInner, {
  9275. ...props,
  9276. tooltipRef: ref,
  9277. isExiting
  9278. }));
  9279. });
  9280. function $4e3b923658d69c60$var$TooltipInner(props) {
  9281. let state = useContext($4e3b923658d69c60$export$7a7623236eec67fa), arrowRef = useRef(null), { overlayProps, arrowProps, placement, triggerAnchorPoint } = $2a41e45df1593e64$export$d39e1813b3bdd0e1({
  9282. placement: props.placement || "top",
  9283. targetRef: props.triggerRef,
  9284. overlayRef: props.tooltipRef,
  9285. arrowRef,
  9286. offset: props.offset,
  9287. crossOffset: props.crossOffset,
  9288. isOpen: state.isOpen,
  9289. arrowBoundaryOffset: props.arrowBoundaryOffset,
  9290. shouldFlip: props.shouldFlip,
  9291. containerPadding: props.containerPadding,
  9292. onClose: () => state.close(!0)
  9293. }), isEntering = $d3f049242431219c$export$6d3443f2c48bfc20(props.tooltipRef, !!placement) || props.isEntering || !1, renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
  9294. ...props,
  9295. defaultClassName: "react-aria-Tooltip",
  9296. values: {
  9297. placement,
  9298. isEntering,
  9299. isExiting: props.isExiting,
  9300. state
  9301. }
  9302. });
  9303. props = $3ef42575df84b30b$export$9d1611c77c2fe928(props, overlayProps);
  9304. let { tooltipProps } = $326e436e94273fe1$export$1c4b08e0eca38426(props, state), DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
  9305. global: !0
  9306. });
  9307. return react_default.createElement("div", {
  9308. ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, renderProps, tooltipProps),
  9309. ref: props.tooltipRef,
  9310. style: {
  9311. ...overlayProps.style,
  9312. "--trigger-anchor-point": triggerAnchorPoint ? `${triggerAnchorPoint.x}px ${triggerAnchorPoint.y}px` : void 0,
  9313. ...renderProps.style
  9314. },
  9315. "data-placement": placement ?? void 0,
  9316. "data-entering": isEntering || void 0,
  9317. "data-exiting": props.isExiting || void 0
  9318. }, react_default.createElement($44f671af83e7d9e0$export$2de4954e8ae13b9f.Provider, {
  9319. value: {
  9320. ...arrowProps,
  9321. placement,
  9322. ref: arrowRef
  9323. }
  9324. }, renderProps.children));
  9325. }
  9326. // src/components/components/shared/overlayHelpers.tsx
  9327. init_react();
  9328. var import_memoizerific = __toESM(require_memoizerific(), 1);
  9329. var convertToReactAriaPlacement2 = (0, import_memoizerific.default)(1e3)((p2) => p2 === "left-end" ? "left bottom" : p2 === "right-end" ? "right bottom" : p2 === "left-start" ? "left top" : p2 === "right-start" ? "right top" : p2.replace("-", " ")), Container5 = styled.div({
  9330. width: 500,
  9331. height: 500,
  9332. paddingTop: 100,
  9333. overflowY: "scroll",
  9334. background: "#eee",
  9335. position: "relative"
  9336. }), Trigger = forwardRef((props, ref) => react_default.createElement(
  9337. "button",
  9338. {
  9339. ...props,
  9340. ref,
  9341. style: {
  9342. width: 120,
  9343. height: 50,
  9344. margin: 10
  9345. }
  9346. }
  9347. ));
  9348. Trigger.displayName = "Trigger";
  9349. // src/components/components/tooltip/TooltipProvider.tsx
  9350. var TooltipProvider2 = ({
  9351. triggerOnFocusOnly = !1,
  9352. placement: placementProp = "top",
  9353. offset: offset2 = 8,
  9354. tooltip,
  9355. children,
  9356. defaultVisible,
  9357. startOpen,
  9358. delayShow = 400,
  9359. delayHide = 200,
  9360. visible,
  9361. onVisibleChange,
  9362. ...props
  9363. }) => {
  9364. let placement = convertToReactAriaPlacement2(placementProp), child = react_default.Children.only(children);
  9365. startOpen !== void 0 && deprecate("The `startOpen` prop is deprecated. Please use `defaultVisible` instead.");
  9366. let [isOpen, setIsOpen] = useState(defaultVisible ?? startOpen ?? !1), onOpenChange = useCallback(
  9367. (isOpen2) => {
  9368. setIsOpen(isOpen2), onVisibleChange?.(isOpen2);
  9369. },
  9370. [onVisibleChange]
  9371. );
  9372. return react_default.createElement(
  9373. $4e3b923658d69c60$export$8c610744efcf8a1d,
  9374. {
  9375. delay: delayShow,
  9376. closeDelay: delayHide,
  9377. isOpen: visible ?? isOpen,
  9378. onOpenChange,
  9379. trigger: triggerOnFocusOnly ? "focus" : void 0,
  9380. ...props
  9381. },
  9382. react_default.createElement($f645667febf57a63$export$35a3bebf7ef2d934, null, react_default.cloneElement(child, { "aria-describedby": null })),
  9383. react_default.createElement(
  9384. $4e3b923658d69c60$export$28c660c63b792dea,
  9385. {
  9386. "data-testid": "tooltip",
  9387. placement,
  9388. offset: offset2,
  9389. onOpenChange,
  9390. style: { outline: "none" },
  9391. ...props
  9392. },
  9393. tooltip
  9394. )
  9395. );
  9396. };
  9397. // src/manager/components/layout/Drag.tsx
  9398. var oppositePosition = {
  9399. left: "right",
  9400. right: "left",
  9401. top: "bottom",
  9402. bottom: "top"
  9403. }, Drag = forwardRef(function(props, ref) {
  9404. let {
  9405. overlapping,
  9406. position,
  9407. "aria-label": ariaLabel,
  9408. "aria-valuenow": ariaValueNow,
  9409. "aria-valuemax": ariaValueMax,
  9410. ...rest2
  9411. } = props, orientation = position === "left" || position === "right" ? "vertical" : "horizontal", tooltipNote = orientation === "vertical" ? "\u2190 \u2192 to resize" : "\u2191 \u2193 to resize";
  9412. return react_default.createElement(
  9413. TooltipProvider2,
  9414. {
  9415. triggerOnFocusOnly: !0,
  9416. placement: oppositePosition[position],
  9417. tooltip: react_default.createElement(TooltipNote2, { note: tooltipNote })
  9418. },
  9419. react_default.createElement(
  9420. DragHandle,
  9421. {
  9422. ref,
  9423. $orientation: orientation,
  9424. $overlapping: overlapping,
  9425. $position: position,
  9426. role: "separator",
  9427. tabIndex: 0,
  9428. "aria-orientation": orientation,
  9429. "aria-label": ariaLabel,
  9430. "aria-valuenow": ariaValueNow,
  9431. "aria-valuemin": 0,
  9432. "aria-valuemax": ariaValueMax,
  9433. ...rest2
  9434. }
  9435. )
  9436. );
  9437. }), DragHandle = styled.div(
  9438. ({ theme }) => ({
  9439. position: "absolute",
  9440. opacity: 0,
  9441. transition: "opacity 0.2s ease-in-out",
  9442. zIndex: 100,
  9443. "&:after": {
  9444. content: '""',
  9445. display: "block",
  9446. backgroundColor: theme.color.secondary
  9447. },
  9448. "&:hover": {
  9449. opacity: 1
  9450. }
  9451. }),
  9452. ({ theme, $orientation = "vertical" }) => ({
  9453. "&:focus-visible": {
  9454. opacity: 1,
  9455. outline: "2px solid transparent",
  9456. ...$orientation === "horizontal" ? { height: 7 } : { width: 7 },
  9457. boxShadow: `inset 0 0 0 4px ${theme.color.secondary}`,
  9458. "@media (forced-colors: active)": {
  9459. outline: "2px solid Highlight"
  9460. }
  9461. }
  9462. }),
  9463. ({ $orientation = "vertical", $overlapping = !0, $position = "left" }) => $orientation === "vertical" ? {
  9464. // This is an old code smell, where 10px matches the sidebar and 13px matches the addon panel.
  9465. // It should be tidied up at some point.
  9466. width: $overlapping ? $position === "left" ? 10 : 13 : 7,
  9467. height: "100%",
  9468. top: 0,
  9469. right: $position === "left" ? -7 : void 0,
  9470. left: $position === "right" ? -7 : void 0,
  9471. "&:after": {
  9472. width: 1,
  9473. height: "100%",
  9474. marginLeft: $position === "left" ? 3 : 6
  9475. },
  9476. "&:hover": {
  9477. cursor: "col-resize"
  9478. }
  9479. } : {
  9480. width: "100%",
  9481. height: $overlapping ? 13 : 7,
  9482. top: $position === "bottom" ? -7 : void 0,
  9483. bottom: $position === "top" ? -7 : void 0,
  9484. left: 0,
  9485. "&:after": {
  9486. width: "100%",
  9487. height: 1,
  9488. marginTop: 6
  9489. },
  9490. "&:hover": {
  9491. cursor: "row-resize"
  9492. }
  9493. }
  9494. );
  9495. // src/manager/components/layout/PanelContainer.tsx
  9496. var Container6 = styled.div(({ theme, position }) => ({
  9497. gridArea: "panel",
  9498. position: "relative",
  9499. backgroundColor: theme.appContentBg,
  9500. borderTop: position === "bottom" ? `1px solid ${theme.appBorderColor}` : void 0,
  9501. borderLeft: position === "right" ? `1px solid ${theme.appBorderColor}` : void 0
  9502. })), PanelSlot = styled.div({
  9503. height: "100%"
  9504. }), PanelContainer = react_default.memo(function(props) {
  9505. let { children, bottomPanelHeight, rightPanelWidth, panelMaxSize, panelResizerRef, position } = props, shouldHidePanelContent = position === "bottom" ? bottomPanelHeight === 0 : rightPanelWidth === 0;
  9506. return react_default.createElement(Container6, { position }, react_default.createElement(
  9507. Drag,
  9508. {
  9509. ref: panelResizerRef,
  9510. position,
  9511. overlapping: position === "bottom" ? !!bottomPanelHeight : !!rightPanelWidth,
  9512. "aria-label": "Addon panel resize handle",
  9513. "aria-valuenow": position === "bottom" ? bottomPanelHeight : rightPanelWidth,
  9514. "aria-valuemax": panelMaxSize
  9515. }
  9516. ), react_default.createElement(
  9517. PanelSlot,
  9518. {
  9519. hidden: shouldHidePanelContent ? !0 : void 0,
  9520. "aria-hidden": shouldHidePanelContent ? !0 : void 0
  9521. },
  9522. children
  9523. ));
  9524. });
  9525. // src/manager/components/layout/SidebarContainer.tsx
  9526. init_react();
  9527. var Container7 = styled.div(({ theme }) => ({
  9528. backgroundColor: theme.appBg,
  9529. gridArea: "sidebar",
  9530. position: "relative",
  9531. borderRight: `1px solid ${theme.appBorderColor}`
  9532. })), SidebarSlot = styled.div({
  9533. height: "100%"
  9534. }), SidebarContainer = react_default.memo(function(props) {
  9535. let { children, navSize, sidebarMaxWidth, sidebarResizerRef } = props, shouldHideSidebarContent = navSize === 0;
  9536. return react_default.createElement(Container7, null, react_default.createElement(
  9537. SidebarSlot,
  9538. {
  9539. hidden: shouldHideSidebarContent ? !0 : void 0,
  9540. "aria-hidden": shouldHideSidebarContent ? !0 : void 0
  9541. },
  9542. children
  9543. ), react_default.createElement(
  9544. Drag,
  9545. {
  9546. ref: sidebarResizerRef,
  9547. position: "left",
  9548. "aria-label": "Sidebar resize handle",
  9549. "aria-valuenow": navSize,
  9550. "aria-valuemax": sidebarMaxWidth
  9551. }
  9552. ));
  9553. });
  9554. // src/manager/components/layout/useDragging.ts
  9555. init_react();
  9556. var SNAP_THRESHOLD_PX = 30, STIFFNESS = 0.9, KEYBOARD_STEP_PX = 10, KEYBOARD_SHIFT_MULTIPLIER = 5, RESIZE_KEYS = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"];
  9557. function clamp(value, min, max) {
  9558. return Math.min(Math.max(value, min), max);
  9559. }
  9560. function interpolate(relativeValue, min, max) {
  9561. return min + (max - min) * relativeValue;
  9562. }
  9563. function computeSidebarMaxWidth(panelPosition, rightPanelWidth, showPanel) {
  9564. if (typeof window > "u")
  9565. return 0;
  9566. let panelWidth = showPanel ? panelPosition === "right" ? rightPanelWidth : 360 : 0;
  9567. return Math.max(window.innerWidth - 100 - panelWidth, 0);
  9568. }
  9569. function computePanelMaxSize(panelPosition, navSize) {
  9570. return typeof window > "u" ? 0 : Math.max(panelPosition === "bottom" ? window.innerHeight - 40 : window.innerWidth - 100 - navSize, 0);
  9571. }
  9572. function applyResizeKeyboard(state, sizeKey, key, step, minSize, maxSize, increaseKey, decreaseKey) {
  9573. let currentSize = state[sizeKey];
  9574. switch (key) {
  9575. case increaseKey:
  9576. return { ...state, [sizeKey]: clamp(currentSize + step, minSize, maxSize) };
  9577. case decreaseKey:
  9578. let effectivelyComputed = clamp(currentSize - step, 0, maxSize);
  9579. return { ...state, [sizeKey]: effectivelyComputed < minSize ? 0 : effectivelyComputed };
  9580. case "Home":
  9581. return { ...state, [sizeKey]: 0 };
  9582. case "End":
  9583. return { ...state, [sizeKey]: maxSize };
  9584. default:
  9585. return state;
  9586. }
  9587. }
  9588. function useDragging({
  9589. setState,
  9590. showPanel,
  9591. isDesktop,
  9592. navSize,
  9593. rightPanelWidth,
  9594. panelPosition
  9595. }) {
  9596. let panelResizerRef = useRef(null), sidebarResizerRef = useRef(null), sidebarMaxWidth = computeSidebarMaxWidth(panelPosition, rightPanelWidth, showPanel), panelMaxSize = computePanelMaxSize(panelPosition, navSize);
  9597. return useEffect(() => {
  9598. let panelResizer = panelResizerRef.current, sidebarResizer = sidebarResizerRef.current, previewIframe = document.querySelector("#storybook-preview-iframe"), draggedElement = null, onDragStart = (e2) => {
  9599. e2.preventDefault(), setState((state) => ({
  9600. ...state,
  9601. isDragging: !0
  9602. })), e2.currentTarget === panelResizer ? draggedElement = panelResizer : e2.currentTarget === sidebarResizer && (draggedElement = sidebarResizer), window.addEventListener("mousemove", onDrag), window.addEventListener("mouseup", onDragEnd), previewIframe && (previewIframe.style.pointerEvents = "none");
  9603. }, onDragEnd = () => {
  9604. setState((state) => {
  9605. if (draggedElement === sidebarResizer && state.navSize < 240 && state.navSize > 0)
  9606. return {
  9607. ...state,
  9608. isDragging: !1,
  9609. navSize: 240
  9610. };
  9611. if (draggedElement === panelResizer) {
  9612. if (state.panelPosition === "right" && state.rightPanelWidth < 270 && state.rightPanelWidth > 0)
  9613. return {
  9614. ...state,
  9615. isDragging: !1,
  9616. rightPanelWidth: 270
  9617. };
  9618. if (state.panelPosition === "bottom" && state.bottomPanelHeight < 40 && state.bottomPanelHeight > 0)
  9619. return {
  9620. ...state,
  9621. isDragging: !1,
  9622. bottomPanelHeight: 40
  9623. };
  9624. }
  9625. return {
  9626. ...state,
  9627. isDragging: !1
  9628. };
  9629. }), window.removeEventListener("mousemove", onDrag), window.removeEventListener("mouseup", onDragEnd), previewIframe?.removeAttribute("style"), draggedElement = null;
  9630. }, onDrag = (e2) => {
  9631. if (e2.buttons === 0) {
  9632. onDragEnd();
  9633. return;
  9634. }
  9635. setState((state) => {
  9636. if (draggedElement === sidebarResizer) {
  9637. let sidebarDragX = e2.clientX;
  9638. return sidebarDragX === state.navSize ? state : sidebarDragX <= SNAP_THRESHOLD_PX ? {
  9639. ...state,
  9640. navSize: 0
  9641. } : sidebarDragX <= 240 ? {
  9642. ...state,
  9643. navSize: interpolate(STIFFNESS, sidebarDragX, 240)
  9644. } : {
  9645. ...state,
  9646. navSize: clamp(
  9647. sidebarDragX,
  9648. 0,
  9649. computeSidebarMaxWidth(state.panelPosition, state.rightPanelWidth, showPanel)
  9650. )
  9651. };
  9652. }
  9653. if (draggedElement === panelResizer) {
  9654. let sizeAxisState = state.panelPosition === "bottom" ? "bottomPanelHeight" : "rightPanelWidth", panelDragSize = state.panelPosition === "bottom" ? (
  9655. // @ts-expect-error (non strict)
  9656. e2.view.innerHeight - e2.clientY
  9657. ) : (
  9658. // @ts-expect-error (non strict)
  9659. e2.view.innerWidth - e2.clientX
  9660. ), minimumSize = state.panelPosition === "bottom" ? 40 : 270;
  9661. return panelDragSize === state[sizeAxisState] ? state : panelDragSize <= SNAP_THRESHOLD_PX ? {
  9662. ...state,
  9663. [sizeAxisState]: 0
  9664. } : panelDragSize <= minimumSize ? {
  9665. ...state,
  9666. [sizeAxisState]: interpolate(STIFFNESS, panelDragSize, minimumSize)
  9667. } : {
  9668. ...state,
  9669. [sizeAxisState]: clamp(
  9670. panelDragSize,
  9671. 0,
  9672. computePanelMaxSize(state.panelPosition, state.navSize)
  9673. )
  9674. };
  9675. }
  9676. return state;
  9677. });
  9678. }, onSidebarKeyDown = (e2) => {
  9679. if (!RESIZE_KEYS.includes(e2.key))
  9680. return;
  9681. e2.preventDefault();
  9682. let step = e2.shiftKey ? KEYBOARD_STEP_PX * KEYBOARD_SHIFT_MULTIPLIER : KEYBOARD_STEP_PX;
  9683. setState(
  9684. (state) => applyResizeKeyboard(
  9685. state,
  9686. "navSize",
  9687. e2.key,
  9688. step,
  9689. 240,
  9690. computeSidebarMaxWidth(state.panelPosition, state.rightPanelWidth, showPanel),
  9691. "ArrowRight",
  9692. "ArrowLeft"
  9693. )
  9694. );
  9695. }, onPanelKeyDown = (e2) => {
  9696. if (!RESIZE_KEYS.includes(e2.key))
  9697. return;
  9698. e2.preventDefault();
  9699. let step = e2.shiftKey ? KEYBOARD_STEP_PX * KEYBOARD_SHIFT_MULTIPLIER : KEYBOARD_STEP_PX;
  9700. setState(
  9701. (state) => applyResizeKeyboard(
  9702. state,
  9703. state.panelPosition === "bottom" ? "bottomPanelHeight" : "rightPanelWidth",
  9704. e2.key,
  9705. step,
  9706. state.panelPosition === "bottom" ? 40 : 270,
  9707. computePanelMaxSize(state.panelPosition, state.navSize),
  9708. state.panelPosition === "bottom" ? "ArrowUp" : "ArrowLeft",
  9709. state.panelPosition === "bottom" ? "ArrowDown" : "ArrowRight"
  9710. )
  9711. );
  9712. };
  9713. return panelResizer?.addEventListener("mousedown", onDragStart), sidebarResizer?.addEventListener("mousedown", onDragStart), panelResizer?.addEventListener("keydown", onPanelKeyDown), sidebarResizer?.addEventListener("keydown", onSidebarKeyDown), () => {
  9714. panelResizer?.removeEventListener("mousedown", onDragStart), sidebarResizer?.removeEventListener("mousedown", onDragStart), panelResizer?.removeEventListener("keydown", onPanelKeyDown), sidebarResizer?.removeEventListener("keydown", onSidebarKeyDown), previewIframe?.removeAttribute("style");
  9715. };
  9716. }, [
  9717. // we need to rerun this effect when the panel is shown/hidden or when changing between mobile/desktop to re-attach the event listeners
  9718. showPanel,
  9719. isDesktop,
  9720. setState
  9721. ]), { panelResizerRef, sidebarResizerRef, sidebarMaxWidth, panelMaxSize };
  9722. }
  9723. // src/manager/components/layout/useLandmarkIndicator.ts
  9724. init_react();
  9725. function findActiveLandmarkElement() {
  9726. let currentElement = document.activeElement, landmarkElement = null;
  9727. for (; currentElement; ) {
  9728. if (currentElement instanceof HTMLElement && currentElement.hasAttribute("data-sb-landmark")) {
  9729. landmarkElement = currentElement;
  9730. break;
  9731. }
  9732. currentElement = currentElement.parentElement;
  9733. }
  9734. return landmarkElement;
  9735. }
  9736. function useRegionFocusAnimation() {
  9737. let theme = useTheme(), reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)"), currentAnimationRef = useRef(null);
  9738. return (elementToAnimate) => {
  9739. if (elementToAnimate && (currentAnimationRef.current && (currentAnimationRef.current.cancel(), currentAnimationRef.current = null), !reducedMotion)) {
  9740. let animation = elementToAnimate.animate(
  9741. [{ border: `2px solid ${theme.color.primary}` }, { border: "2px solid transparent" }],
  9742. {
  9743. duration: 1500,
  9744. pseudoElement: "::after"
  9745. }
  9746. );
  9747. currentAnimationRef.current = animation, animation.onfinish = () => {
  9748. currentAnimationRef.current = null;
  9749. };
  9750. }
  9751. };
  9752. }
  9753. function useLandmarkIndicator() {
  9754. let animateLandmark = useRegionFocusAnimation();
  9755. useEffect(() => {
  9756. let handleKeyDown = (e2) => {
  9757. if (e2.key !== "F6")
  9758. return;
  9759. let landmarkElement = findActiveLandmarkElement();
  9760. landmarkElement && animateLandmark(landmarkElement);
  9761. };
  9762. return document.addEventListener("keydown", handleKeyDown, { capture: !0 }), () => {
  9763. document.removeEventListener("keydown", handleKeyDown, { capture: !0 });
  9764. };
  9765. }, [animateLandmark]);
  9766. }
  9767. // src/manager/components/layout/Layout.tsx
  9768. var layoutStateIsEqual = (state, other) => state.navSize === other.navSize && state.bottomPanelHeight === other.bottomPanelHeight && state.rightPanelWidth === other.rightPanelWidth && state.panelPosition === other.panelPosition, useLayoutSyncingState = ({
  9769. api,
  9770. managerLayoutState,
  9771. setManagerLayoutState,
  9772. isDesktop,
  9773. hasTab
  9774. }) => {
  9775. let prevManagerLayoutStateRef = react_default.useRef(managerLayoutState), [internalDraggingSizeState, setInternalDraggingSizeState] = useState({
  9776. ...managerLayoutState,
  9777. isDragging: !1
  9778. });
  9779. useEffect(() => {
  9780. internalDraggingSizeState.isDragging || // don't interrupt user's drag
  9781. layoutStateIsEqual(managerLayoutState, prevManagerLayoutStateRef.current) || (prevManagerLayoutStateRef.current = managerLayoutState, setInternalDraggingSizeState((state) => ({ ...state, ...managerLayoutState })));
  9782. }, [internalDraggingSizeState.isDragging, managerLayoutState, setInternalDraggingSizeState]), useLayoutEffect(() => {
  9783. if (internalDraggingSizeState.isDragging || // wait with syncing managerLayoutState until user is done dragging
  9784. layoutStateIsEqual(managerLayoutState, internalDraggingSizeState))
  9785. return;
  9786. let nextState = {
  9787. navSize: internalDraggingSizeState.navSize,
  9788. bottomPanelHeight: internalDraggingSizeState.bottomPanelHeight,
  9789. rightPanelWidth: internalDraggingSizeState.rightPanelWidth
  9790. };
  9791. prevManagerLayoutStateRef.current = {
  9792. ...prevManagerLayoutStateRef.current,
  9793. ...nextState
  9794. }, setManagerLayoutState(nextState);
  9795. }, [internalDraggingSizeState, setManagerLayoutState]);
  9796. let isPagesShown = managerLayoutState.viewMode !== void 0 && managerLayoutState.viewMode !== "story" && managerLayoutState.viewMode !== "docs", isPanelShown = managerLayoutState.viewMode === "story" && !hasTab, { navSize, rightPanelWidth, bottomPanelHeight } = internalDraggingSizeState.isDragging ? internalDraggingSizeState : managerLayoutState, customisedNavSize = api.getNavSizeWithCustomisations?.(navSize) ?? navSize, customisedShowPanel = api.getShowPanelWithCustomisations?.(isPanelShown) ?? isPanelShown, { panelResizerRef, sidebarResizerRef, sidebarMaxWidth, panelMaxSize } = useDragging({
  9797. setState: setInternalDraggingSizeState,
  9798. isDesktop,
  9799. navSize: customisedNavSize,
  9800. showPanel: customisedShowPanel,
  9801. rightPanelWidth,
  9802. panelPosition: managerLayoutState.panelPosition
  9803. });
  9804. return {
  9805. navSize: customisedNavSize,
  9806. rightPanelWidth,
  9807. bottomPanelHeight,
  9808. panelPosition: managerLayoutState.panelPosition,
  9809. panelResizerRef,
  9810. sidebarResizerRef,
  9811. sidebarMaxWidth,
  9812. panelMaxSize,
  9813. showPages: isPagesShown,
  9814. showPanel: customisedShowPanel,
  9815. isDragging: internalDraggingSizeState.isDragging
  9816. };
  9817. }, OrderedMobileNavigation = styled(MobileNavigation)({
  9818. order: 1
  9819. }), Layout = ({ managerLayoutState, setManagerLayoutState, hasTab, ...slots }) => {
  9820. let { isDesktop, isMobile: isMobile2 } = useLayout(), api = useStorybookApi(), {
  9821. navSize,
  9822. rightPanelWidth,
  9823. bottomPanelHeight,
  9824. panelPosition,
  9825. panelResizerRef,
  9826. sidebarResizerRef,
  9827. sidebarMaxWidth,
  9828. panelMaxSize,
  9829. showPages,
  9830. showPanel
  9831. } = useLayoutSyncingState({ api, managerLayoutState, setManagerLayoutState, isDesktop, hasTab });
  9832. return useLandmarkIndicator(), react_default.createElement(
  9833. LayoutContainer,
  9834. {
  9835. panelPosition: managerLayoutState.panelPosition,
  9836. showPanel,
  9837. style: {
  9838. "--nav-width": `${navSize}px`,
  9839. "--right-panel-width": `${rightPanelWidth}px`,
  9840. "--bottom-panel-height": `${bottomPanelHeight}px`
  9841. }
  9842. },
  9843. react_default.createElement(react_default.Fragment, null, isDesktop && react_default.createElement(
  9844. SidebarContainer,
  9845. {
  9846. navSize,
  9847. sidebarMaxWidth,
  9848. sidebarResizerRef
  9849. },
  9850. slots.slotSidebar
  9851. ), isMobile2 && react_default.createElement(
  9852. OrderedMobileNavigation,
  9853. {
  9854. menu: slots.slotSidebar,
  9855. panel: slots.slotPanel,
  9856. showPanel
  9857. }
  9858. ), react_default.createElement(
  9859. MainAreaContainer,
  9860. {
  9861. showPages,
  9862. slotMain: slots.slotMain,
  9863. slotPages: slots.slotPages
  9864. }
  9865. ), isDesktop && showPanel && react_default.createElement(
  9866. PanelContainer,
  9867. {
  9868. bottomPanelHeight,
  9869. rightPanelWidth,
  9870. panelMaxSize,
  9871. panelResizerRef,
  9872. position: panelPosition
  9873. },
  9874. slots.slotPanel
  9875. ), isMobile2 && react_default.createElement(Notifications, null))
  9876. );
  9877. }, LayoutContainer = styled.div(({ panelPosition, showPanel }) => ({
  9878. width: "100%",
  9879. height: ["100vh", "100dvh"],
  9880. overflow: "hidden",
  9881. display: "flex",
  9882. flexDirection: "column",
  9883. colorScheme: "light dark",
  9884. [MEDIA_DESKTOP_BREAKPOINT]: {
  9885. display: "grid",
  9886. gap: 0,
  9887. // This uses CSS variables to prevent Emotion from generating a new CSS className for every possible value
  9888. gridTemplateColumns: `minmax(0, var(--nav-width)) minmax(${100}px, 1fr) minmax(0, var(--right-panel-width))`,
  9889. gridTemplateRows: "1fr minmax(0, var(--bottom-panel-height))",
  9890. gridTemplateAreas: showPanel ? panelPosition === "right" ? `"sidebar content panel"
  9891. "sidebar content panel"` : `"sidebar content content"
  9892. "sidebar panel panel"` : `"sidebar content content"
  9893. "sidebar content content"`
  9894. }
  9895. }));
  9896. // src/manager/container/Panel.tsx
  9897. init_react();
  9898. // global-externals:storybook/internal/types
  9899. var types_default = __STORYBOOK_TYPES__, { Addon_TypesEnum, CHANGE_DETECTION_STATUS_TYPE_ID, CoreWebpackCompiler, Feature, SupportedBuilder, SupportedFramework, SupportedLanguage, SupportedRenderer } = __STORYBOOK_TYPES__;
  9900. // src/core-events/index.ts
  9901. var events = /* @__PURE__ */ ((events2) => (events2.CHANNEL_WS_DISCONNECT = "channelWSDisconnect", events2.CHANNEL_CREATED = "channelCreated", events2.CONFIG_ERROR = "configError", events2.STORY_INDEX_INVALIDATED = "storyIndexInvalidated", events2.STORY_SPECIFIED = "storySpecified", events2.SET_CONFIG = "setConfig", events2.SET_STORIES = "setStories", events2.SET_INDEX = "setIndex", events2.SET_CURRENT_STORY = "setCurrentStory", events2.CURRENT_STORY_WAS_SET = "currentStoryWasSet", events2.FORCE_RE_RENDER = "forceReRender", events2.FORCE_REMOUNT = "forceRemount", events2.PRELOAD_ENTRIES = "preloadStories", events2.STORY_PREPARED = "storyPrepared", events2.DOCS_PREPARED = "docsPrepared", events2.STORY_CHANGED = "storyChanged", events2.STORY_UNCHANGED = "storyUnchanged", events2.STORY_RENDERED = "storyRendered", events2.STORY_FINISHED = "storyFinished", events2.STORY_MISSING = "storyMissing", events2.STORY_ERRORED = "storyErrored", events2.STORY_THREW_EXCEPTION = "storyThrewException", events2.STORY_RENDER_PHASE_CHANGED = "storyRenderPhaseChanged", events2.STORY_HOT_UPDATED = "storyHotUpdated", events2.PLAY_FUNCTION_THREW_EXCEPTION = "playFunctionThrewException", events2.UNHANDLED_ERRORS_WHILE_PLAYING = "unhandledErrorsWhilePlaying", events2.UPDATE_STORY_ARGS = "updateStoryArgs", events2.STORY_ARGS_UPDATED = "storyArgsUpdated", events2.RESET_STORY_ARGS = "resetStoryArgs", events2.SET_FILTER = "setFilter", events2.SET_GLOBALS = "setGlobals", events2.UPDATE_GLOBALS = "updateGlobals", events2.GLOBALS_UPDATED = "globalsUpdated", events2.REGISTER_SUBSCRIPTION = "registerSubscription", events2.PREVIEW_INITIALIZED = "previewInitialized", events2.PREVIEW_KEYDOWN = "previewKeydown", events2.PREVIEW_BUILDER_PROGRESS = "preview_builder_progress", events2.SELECT_STORY = "selectStory", events2.STORIES_COLLAPSE_ALL = "storiesCollapseAll", events2.STORIES_EXPAND_ALL = "storiesExpandAll", events2.DOCS_RENDERED = "docsRendered", events2.SHARED_STATE_CHANGED = "sharedStateChanged", events2.SHARED_STATE_SET = "sharedStateSet", events2.NAVIGATE_URL = "navigateUrl", events2.UPDATE_QUERY_PARAMS = "updateQueryParams", events2.REQUEST_WHATS_NEW_DATA = "requestWhatsNewData", events2.RESULT_WHATS_NEW_DATA = "resultWhatsNewData", events2.SET_WHATS_NEW_CACHE = "setWhatsNewCache", events2.TOGGLE_WHATS_NEW_NOTIFICATIONS = "toggleWhatsNewNotifications", events2.TELEMETRY_ERROR = "telemetryError", events2.FILE_COMPONENT_SEARCH_REQUEST = "fileComponentSearchRequest", events2.FILE_COMPONENT_SEARCH_RESPONSE = "fileComponentSearchResponse", events2.SAVE_STORY_REQUEST = "saveStoryRequest", events2.SAVE_STORY_RESPONSE = "saveStoryResponse", events2.ARGTYPES_INFO_REQUEST = "argtypesInfoRequest", events2.ARGTYPES_INFO_RESPONSE = "argtypesInfoResponse", events2.CREATE_NEW_STORYFILE_REQUEST = "createNewStoryfileRequest", events2.CREATE_NEW_STORYFILE_RESPONSE = "createNewStoryfileResponse", events2.GHOST_STORIES_REQUEST = "ghostStoriesRequest", events2.GHOST_STORIES_RESPONSE = "ghostStoriesResponse", events2.AI_SETUP_ANALYTICS_RESPONSE = "aiSetupAnalyticsResponse", events2.AI_SETUP_ANALYTICS_REQUEST = "aiSetupAnalyticsRequest", events2.OPEN_IN_EDITOR_REQUEST = "openInEditorRequest", events2.OPEN_IN_EDITOR_RESPONSE = "openInEditorResponse", events2.MANAGER_INERT_ATTRIBUTE_CHANGED = "managerInertAttributeChanged", events2.SHARE_ISOLATE_MODE = "shareIsolateMode", events2.AI_PROMPT_NUDGE = "aiPromptNudge", events2.SIDEBAR_FILTER_CHANGED = "sidebarFilterChanged", events2))(events || {});
  9902. var {
  9903. CHANNEL_WS_DISCONNECT: CHANNEL_WS_DISCONNECT2,
  9904. CHANNEL_CREATED: CHANNEL_CREATED2,
  9905. CONFIG_ERROR: CONFIG_ERROR2,
  9906. CREATE_NEW_STORYFILE_REQUEST: CREATE_NEW_STORYFILE_REQUEST2,
  9907. CREATE_NEW_STORYFILE_RESPONSE: CREATE_NEW_STORYFILE_RESPONSE2,
  9908. CURRENT_STORY_WAS_SET: CURRENT_STORY_WAS_SET2,
  9909. DOCS_PREPARED: DOCS_PREPARED2,
  9910. DOCS_RENDERED: DOCS_RENDERED2,
  9911. FILE_COMPONENT_SEARCH_REQUEST: FILE_COMPONENT_SEARCH_REQUEST2,
  9912. FILE_COMPONENT_SEARCH_RESPONSE: FILE_COMPONENT_SEARCH_RESPONSE2,
  9913. FORCE_RE_RENDER: FORCE_RE_RENDER2,
  9914. FORCE_REMOUNT: FORCE_REMOUNT2,
  9915. GLOBALS_UPDATED: GLOBALS_UPDATED2,
  9916. NAVIGATE_URL: NAVIGATE_URL2,
  9917. PLAY_FUNCTION_THREW_EXCEPTION: PLAY_FUNCTION_THREW_EXCEPTION2,
  9918. UNHANDLED_ERRORS_WHILE_PLAYING: UNHANDLED_ERRORS_WHILE_PLAYING2,
  9919. PRELOAD_ENTRIES: PRELOAD_ENTRIES2,
  9920. PREVIEW_INITIALIZED: PREVIEW_INITIALIZED2,
  9921. PREVIEW_BUILDER_PROGRESS: PREVIEW_BUILDER_PROGRESS2,
  9922. PREVIEW_KEYDOWN: PREVIEW_KEYDOWN2,
  9923. REGISTER_SUBSCRIPTION: REGISTER_SUBSCRIPTION2,
  9924. RESET_STORY_ARGS: RESET_STORY_ARGS2,
  9925. SELECT_STORY: SELECT_STORY2,
  9926. SET_CONFIG: SET_CONFIG2,
  9927. SET_CURRENT_STORY: SET_CURRENT_STORY2,
  9928. SET_FILTER: SET_FILTER2,
  9929. SET_GLOBALS: SET_GLOBALS2,
  9930. SET_INDEX: SET_INDEX2,
  9931. SET_STORIES: SET_STORIES2,
  9932. SHARED_STATE_CHANGED: SHARED_STATE_CHANGED2,
  9933. SHARED_STATE_SET: SHARED_STATE_SET2,
  9934. STORIES_COLLAPSE_ALL: STORIES_COLLAPSE_ALL2,
  9935. STORIES_EXPAND_ALL: STORIES_EXPAND_ALL2,
  9936. STORY_ARGS_UPDATED: STORY_ARGS_UPDATED2,
  9937. STORY_CHANGED: STORY_CHANGED2,
  9938. STORY_ERRORED: STORY_ERRORED2,
  9939. STORY_INDEX_INVALIDATED: STORY_INDEX_INVALIDATED2,
  9940. STORY_MISSING: STORY_MISSING2,
  9941. STORY_PREPARED: STORY_PREPARED2,
  9942. STORY_RENDER_PHASE_CHANGED: STORY_RENDER_PHASE_CHANGED2,
  9943. STORY_RENDERED: STORY_RENDERED2,
  9944. STORY_FINISHED: STORY_FINISHED2,
  9945. STORY_SPECIFIED: STORY_SPECIFIED2,
  9946. STORY_THREW_EXCEPTION: STORY_THREW_EXCEPTION2,
  9947. STORY_UNCHANGED: STORY_UNCHANGED2,
  9948. STORY_HOT_UPDATED: STORY_HOT_UPDATED2,
  9949. UPDATE_GLOBALS: UPDATE_GLOBALS2,
  9950. UPDATE_QUERY_PARAMS: UPDATE_QUERY_PARAMS2,
  9951. UPDATE_STORY_ARGS: UPDATE_STORY_ARGS2,
  9952. REQUEST_WHATS_NEW_DATA: REQUEST_WHATS_NEW_DATA2,
  9953. RESULT_WHATS_NEW_DATA: RESULT_WHATS_NEW_DATA2,
  9954. SET_WHATS_NEW_CACHE: SET_WHATS_NEW_CACHE2,
  9955. TOGGLE_WHATS_NEW_NOTIFICATIONS: TOGGLE_WHATS_NEW_NOTIFICATIONS2,
  9956. TELEMETRY_ERROR: TELEMETRY_ERROR2,
  9957. SAVE_STORY_REQUEST: SAVE_STORY_REQUEST2,
  9958. SAVE_STORY_RESPONSE: SAVE_STORY_RESPONSE2,
  9959. ARGTYPES_INFO_REQUEST: ARGTYPES_INFO_REQUEST2,
  9960. ARGTYPES_INFO_RESPONSE: ARGTYPES_INFO_RESPONSE2,
  9961. GHOST_STORIES_REQUEST: GHOST_STORIES_REQUEST2,
  9962. GHOST_STORIES_RESPONSE: GHOST_STORIES_RESPONSE2,
  9963. AI_SETUP_ANALYTICS_RESPONSE: AI_SETUP_ANALYTICS_RESPONSE2,
  9964. AI_SETUP_ANALYTICS_REQUEST: AI_SETUP_ANALYTICS_REQUEST2,
  9965. OPEN_IN_EDITOR_REQUEST: OPEN_IN_EDITOR_REQUEST2,
  9966. OPEN_IN_EDITOR_RESPONSE: OPEN_IN_EDITOR_RESPONSE2,
  9967. MANAGER_INERT_ATTRIBUTE_CHANGED: MANAGER_INERT_ATTRIBUTE_CHANGED2,
  9968. SHARE_ISOLATE_MODE: SHARE_ISOLATE_MODE2,
  9969. AI_PROMPT_NUDGE: AI_PROMPT_NUDGE2,
  9970. SIDEBAR_FILTER_CHANGED: SIDEBAR_FILTER_CHANGED2
  9971. } = events;
  9972. // ../../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
  9973. function getSymbols(object) {
  9974. return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
  9975. }
  9976. // ../../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
  9977. function getTag(value) {
  9978. return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
  9979. }
  9980. // ../../node_modules/es-toolkit/dist/compat/_internal/tags.mjs
  9981. var regexpTag = "[object RegExp]", stringTag = "[object String]", numberTag = "[object Number]", booleanTag = "[object Boolean]", argumentsTag = "[object Arguments]", symbolTag = "[object Symbol]", dateTag = "[object Date]", mapTag = "[object Map]", setTag = "[object Set]", arrayTag = "[object Array]", functionTag = "[object Function]", arrayBufferTag = "[object ArrayBuffer]", objectTag = "[object Object]", errorTag = "[object Error]", dataViewTag = "[object DataView]", uint8ArrayTag = "[object Uint8Array]", uint8ClampedArrayTag = "[object Uint8ClampedArray]", uint16ArrayTag = "[object Uint16Array]", uint32ArrayTag = "[object Uint32Array]", bigUint64ArrayTag = "[object BigUint64Array]", int8ArrayTag = "[object Int8Array]", int16ArrayTag = "[object Int16Array]", int32ArrayTag = "[object Int32Array]", bigInt64ArrayTag = "[object BigInt64Array]", float32ArrayTag = "[object Float32Array]", float64ArrayTag = "[object Float64Array]";
  9982. // ../../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
  9983. function isPlainObject(value) {
  9984. if (!value || typeof value != "object")
  9985. return !1;
  9986. let proto = Object.getPrototypeOf(value);
  9987. return proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null ? Object.prototype.toString.call(value) === "[object Object]" : !1;
  9988. }
  9989. // ../../node_modules/es-toolkit/dist/string/words.mjs
  9990. var CASE_SPLIT_PATTERN = new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+", "gu");
  9991. // ../../node_modules/es-toolkit/dist/compat/util/eq.mjs
  9992. function eq(value, other) {
  9993. return value === other || Number.isNaN(value) && Number.isNaN(other);
  9994. }
  9995. // ../../node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
  9996. function isEqualWith(a2, b2, areValuesEqual) {
  9997. return isEqualWithImpl(a2, b2, void 0, void 0, void 0, void 0, areValuesEqual);
  9998. }
  9999. function isEqualWithImpl(a2, b2, property, aParent, bParent, stack, areValuesEqual) {
  10000. let result = areValuesEqual(a2, b2, property, aParent, bParent, stack);
  10001. if (result !== void 0)
  10002. return result;
  10003. if (typeof a2 == typeof b2)
  10004. switch (typeof a2) {
  10005. case "bigint":
  10006. case "string":
  10007. case "boolean":
  10008. case "symbol":
  10009. case "undefined":
  10010. return a2 === b2;
  10011. case "number":
  10012. return a2 === b2 || Object.is(a2, b2);
  10013. case "function":
  10014. return a2 === b2;
  10015. case "object":
  10016. return areObjectsEqual(a2, b2, stack, areValuesEqual);
  10017. }
  10018. return areObjectsEqual(a2, b2, stack, areValuesEqual);
  10019. }
  10020. function areObjectsEqual(a2, b2, stack, areValuesEqual) {
  10021. if (Object.is(a2, b2))
  10022. return !0;
  10023. let aTag = getTag(a2), bTag = getTag(b2);
  10024. if (aTag === argumentsTag && (aTag = objectTag), bTag === argumentsTag && (bTag = objectTag), aTag !== bTag)
  10025. return !1;
  10026. switch (aTag) {
  10027. case stringTag:
  10028. return a2.toString() === b2.toString();
  10029. case numberTag: {
  10030. let x2 = a2.valueOf(), y2 = b2.valueOf();
  10031. return eq(x2, y2);
  10032. }
  10033. case booleanTag:
  10034. case dateTag:
  10035. case symbolTag:
  10036. return Object.is(a2.valueOf(), b2.valueOf());
  10037. case regexpTag:
  10038. return a2.source === b2.source && a2.flags === b2.flags;
  10039. case functionTag:
  10040. return a2 === b2;
  10041. }
  10042. stack = stack ?? /* @__PURE__ */ new Map();
  10043. let aStack = stack.get(a2), bStack = stack.get(b2);
  10044. if (aStack != null && bStack != null)
  10045. return aStack === b2;
  10046. stack.set(a2, b2), stack.set(b2, a2);
  10047. try {
  10048. switch (aTag) {
  10049. case mapTag: {
  10050. if (a2.size !== b2.size)
  10051. return !1;
  10052. for (let [key, value] of a2.entries())
  10053. if (!b2.has(key) || !isEqualWithImpl(value, b2.get(key), key, a2, b2, stack, areValuesEqual))
  10054. return !1;
  10055. return !0;
  10056. }
  10057. case setTag: {
  10058. if (a2.size !== b2.size)
  10059. return !1;
  10060. let aValues = Array.from(a2.values()), bValues = Array.from(b2.values());
  10061. for (let i2 = 0; i2 < aValues.length; i2++) {
  10062. let aValue = aValues[i2], index = bValues.findIndex((bValue) => isEqualWithImpl(aValue, bValue, void 0, a2, b2, stack, areValuesEqual));
  10063. if (index === -1)
  10064. return !1;
  10065. bValues.splice(index, 1);
  10066. }
  10067. return !0;
  10068. }
  10069. case arrayTag:
  10070. case uint8ArrayTag:
  10071. case uint8ClampedArrayTag:
  10072. case uint16ArrayTag:
  10073. case uint32ArrayTag:
  10074. case bigUint64ArrayTag:
  10075. case int8ArrayTag:
  10076. case int16ArrayTag:
  10077. case int32ArrayTag:
  10078. case bigInt64ArrayTag:
  10079. case float32ArrayTag:
  10080. case float64ArrayTag: {
  10081. if (typeof Buffer < "u" && Buffer.isBuffer(a2) !== Buffer.isBuffer(b2) || a2.length !== b2.length)
  10082. return !1;
  10083. for (let i2 = 0; i2 < a2.length; i2++)
  10084. if (!isEqualWithImpl(a2[i2], b2[i2], i2, a2, b2, stack, areValuesEqual))
  10085. return !1;
  10086. return !0;
  10087. }
  10088. case arrayBufferTag:
  10089. return a2.byteLength !== b2.byteLength ? !1 : areObjectsEqual(new Uint8Array(a2), new Uint8Array(b2), stack, areValuesEqual);
  10090. case dataViewTag:
  10091. return a2.byteLength !== b2.byteLength || a2.byteOffset !== b2.byteOffset ? !1 : areObjectsEqual(new Uint8Array(a2), new Uint8Array(b2), stack, areValuesEqual);
  10092. case errorTag:
  10093. return a2.name === b2.name && a2.message === b2.message;
  10094. case objectTag: {
  10095. if (!(areObjectsEqual(a2.constructor, b2.constructor, stack, areValuesEqual) || isPlainObject(a2) && isPlainObject(b2)))
  10096. return !1;
  10097. let aKeys = [...Object.keys(a2), ...getSymbols(a2)], bKeys = [...Object.keys(b2), ...getSymbols(b2)];
  10098. if (aKeys.length !== bKeys.length)
  10099. return !1;
  10100. for (let i2 = 0; i2 < aKeys.length; i2++) {
  10101. let propKey = aKeys[i2], aProp = a2[propKey];
  10102. if (!Object.hasOwn(b2, propKey))
  10103. return !1;
  10104. let bProp = b2[propKey];
  10105. if (!isEqualWithImpl(aProp, bProp, propKey, a2, b2, stack, areValuesEqual))
  10106. return !1;
  10107. }
  10108. return !0;
  10109. }
  10110. default:
  10111. return !1;
  10112. }
  10113. } finally {
  10114. stack.delete(a2), stack.delete(b2);
  10115. }
  10116. }
  10117. // ../../node_modules/es-toolkit/dist/function/noop.mjs
  10118. function noop() {
  10119. }
  10120. // ../../node_modules/es-toolkit/dist/predicate/isEqual.mjs
  10121. function isEqual(a2, b2) {
  10122. return isEqualWith(a2, b2, noop);
  10123. }
  10124. // global-externals:storybook/theming/create
  10125. var create_default = __STORYBOOK_THEMING_CREATE__, { create: create3, themes: themes2 } = __STORYBOOK_THEMING_CREATE__;
  10126. // src/manager-api/modules/layout.ts
  10127. var { document: document2 } = scope;
  10128. var focusableUIElements = {
  10129. addonPanel: "storybook-panel-region",
  10130. storySearchField: "storybook-explorer-searchfield",
  10131. storyListMenu: "storybook-explorer-menu",
  10132. storyPanelRoot: "storybook-panel-root",
  10133. showAddonPanel: "storybook-show-addon-panel",
  10134. sidebarRegion: "storybook-sidebar-region",
  10135. showSidebar: "storybook-show-sidebar"
  10136. };
  10137. // src/manager/components/panel/Panel.tsx
  10138. init_react();
  10139. var TabErrorBoundary = class extends Component {
  10140. constructor(props) {
  10141. super(props), this.state = { hasError: !1 };
  10142. }
  10143. static getDerivedStateFromError() {
  10144. return { hasError: !0 };
  10145. }
  10146. componentDidCatch(error, info) {
  10147. console.error("Error rendering addon panel"), console.error(error), console.error(info.componentStack);
  10148. }
  10149. render() {
  10150. let { hasError } = this.state;
  10151. if (hasError)
  10152. return react_default.createElement(
  10153. EmptyTabContent,
  10154. {
  10155. title: "This addon has errors",
  10156. description: "Check your browser logs and addon code to pinpoint what went wrong. This issue was not caused by Storybook."
  10157. }
  10158. );
  10159. let { children } = this.props;
  10160. return children;
  10161. }
  10162. }, Aside = styled.aside({
  10163. height: "100%",
  10164. display: "flex",
  10165. flexDirection: "column"
  10166. });
  10167. function renderChild(RenderProp) {
  10168. return react_default.createElement(RenderProp, { active: !0 });
  10169. }
  10170. var PreRenderAddons = ({ panels }) => Object.entries(panels).map(([k2, v2]) => react_default.createElement(StatelessTabPanel, { key: k2, name: k2, hasScrollbar: !1 }, react_default.createElement(TabErrorBoundary, { key: k2 }, renderChild(v2.render)))), AddonPanel2 = react_default.memo(({ panels, shortcuts, actions, selectedPanel = null, panelPosition = "right" }) => {
  10171. let { isDesktop, setMobilePanelOpen } = useLayout(), emptyState = react_default.createElement(
  10172. EmptyTabContent,
  10173. {
  10174. title: "Storybook add-ons",
  10175. description: react_default.createElement(react_default.Fragment, null, "Integrate your tools with Storybook to connect workflows and unlock advanced features."),
  10176. footer: react_default.createElement(Link, { href: "https://storybook.js.org/addons?ref=ui", target: "_blank", withArrow: !0 }, react_default.createElement(DocumentIcon, null), " Explore integrations catalog")
  10177. }
  10178. ), tools = useMemo(
  10179. () => react_default.createElement(ActionsWrapper, null, isDesktop ? react_default.createElement(react_default.Fragment, null, react_default.createElement(
  10180. Button,
  10181. {
  10182. key: "position",
  10183. padding: "small",
  10184. variant: "ghost",
  10185. onClick: actions.togglePosition,
  10186. ariaLabel: panelPosition === "bottom" ? "Move addon panel to right" : "Move addon panel to bottom",
  10187. ariaDescription: "Changes the location of the addon panel to the bottom or right of the screen, but does not have any effect on its content.",
  10188. shortcut: shortcuts.panelPosition
  10189. },
  10190. panelPosition === "bottom" ? react_default.createElement(SidebarAltIcon, null) : react_default.createElement(BottomBarIcon, null)
  10191. ), react_default.createElement(
  10192. Button,
  10193. {
  10194. key: "visibility",
  10195. padding: "small",
  10196. variant: "ghost",
  10197. onClick: actions.toggleVisibility,
  10198. ariaLabel: "Hide addon panel",
  10199. shortcut: shortcuts.togglePanel
  10200. },
  10201. react_default.createElement(CloseIcon, null)
  10202. )) : react_default.createElement(
  10203. Button,
  10204. {
  10205. padding: "small",
  10206. variant: "ghost",
  10207. onClick: () => setMobilePanelOpen(!1),
  10208. ariaLabel: "Close addon panel"
  10209. },
  10210. react_default.createElement(CloseIcon, null)
  10211. )),
  10212. [actions, isDesktop, panelPosition, setMobilePanelOpen, shortcuts]
  10213. ), asideRef = useRef(null), { landmarkProps } = useLandmark(
  10214. { "aria-labelledby": "storybook-panel-heading", role: "region" },
  10215. asideRef
  10216. );
  10217. return react_default.createElement(Aside, { ref: asideRef, id: focusableUIElements.addonPanel, ...landmarkProps }, react_default.createElement("h2", { id: "storybook-panel-heading", className: "sb-sr-only" }, "Addon panel"), react_default.createElement(
  10218. StatelessTabsView,
  10219. {
  10220. id: focusableUIElements.storyPanelRoot,
  10221. showToolsWhenEmpty: !0,
  10222. emptyState,
  10223. selected: selectedPanel ?? void 0,
  10224. onSelectionChange: (id) => actions.onSelect(id),
  10225. tools
  10226. },
  10227. react_default.createElement(StatelessTabList, { "aria-label": "Available addons" }, Object.entries(panels).map(([k2, v2]) => react_default.createElement(StatelessTab, { key: k2, name: k2 }, typeof v2.title == "function" ? react_default.createElement(v2.title, null) : v2.title))),
  10228. Object.keys(panels).length ? react_default.createElement(PreRenderAddons, { panels }) : null
  10229. ));
  10230. });
  10231. AddonPanel2.displayName = "AddonPanel";
  10232. var ActionsWrapper = styled.div({
  10233. display: "flex",
  10234. alignItems: "center",
  10235. gap: 6
  10236. });
  10237. // src/manager/container/Panel.tsx
  10238. var Panel = (props) => {
  10239. let api = useStorybookApi(), state = useStorybookState(), [story, setStory] = useState(api.getCurrentStoryData());
  10240. useChannel(
  10241. {
  10242. [STORY_PREPARED2]: () => {
  10243. setStory(api.getCurrentStoryData());
  10244. }
  10245. },
  10246. []
  10247. );
  10248. let { parameters, type } = story ?? {}, panelActions = useMemo(
  10249. () => ({
  10250. onSelect: (panel) => api.setSelectedPanel(panel),
  10251. toggleVisibility: async () => {
  10252. let wasPanelShown = api.getIsPanelShown();
  10253. api.togglePanel(), wasPanelShown && await api.focusOnUIElement(focusableUIElements.showAddonPanel) === !1 && document.body.focus();
  10254. },
  10255. togglePosition: () => api.togglePanelPosition()
  10256. }),
  10257. [api]
  10258. ), panels = useMemo(() => {
  10259. let allPanels = api.getElements(Addon_TypesEnum.PANEL);
  10260. if (!allPanels || type !== "story")
  10261. return allPanels;
  10262. let filteredPanels = {};
  10263. return Object.entries(allPanels).forEach(([id, p2]) => {
  10264. let { paramKey } = p2;
  10265. paramKey && parameters && parameters[paramKey] && parameters[paramKey].disable || p2.disabled === !0 || typeof p2.disabled == "function" && p2.disabled(parameters) || (filteredPanels[id] = p2);
  10266. }), filteredPanels;
  10267. }, [api, type, parameters]);
  10268. return react_default.createElement(
  10269. AddonPanel2,
  10270. {
  10271. panels,
  10272. selectedPanel: api.getSelectedPanel(),
  10273. panelPosition: state.layout.panelPosition,
  10274. actions: panelActions,
  10275. shortcuts: api.getShortcutKeys(),
  10276. ...props
  10277. }
  10278. );
  10279. }, Panel_default = Panel;
  10280. // src/manager/container/Preview.tsx
  10281. init_react();
  10282. var import_memoizerific2 = __toESM(require_memoizerific(), 1);
  10283. // src/manager/components/preview/Preview.tsx
  10284. init_react();
  10285. // src/manager/components/preview/FramesRenderer.tsx
  10286. init_react();
  10287. // src/manager/components/preview/Viewport.tsx
  10288. init_react();
  10289. // src/viewport/useViewport.ts
  10290. init_react();
  10291. // src/viewport/constants.ts
  10292. var ADDON_ID = "storybook/viewport", PARAM_KEY = "viewport", PANEL_ID = `${ADDON_ID}/panel`, TOOL_ID = `${ADDON_ID}/tool`;
  10293. // src/viewport/defaults.ts
  10294. var MINIMAL_VIEWPORTS = {
  10295. mobile1: {
  10296. name: "Small mobile",
  10297. styles: {
  10298. height: "568px",
  10299. width: "320px"
  10300. },
  10301. type: "mobile"
  10302. },
  10303. mobile2: {
  10304. name: "Large mobile",
  10305. styles: {
  10306. height: "896px",
  10307. width: "414px"
  10308. },
  10309. type: "mobile"
  10310. },
  10311. tablet: {
  10312. name: "Tablet",
  10313. styles: {
  10314. height: "1112px",
  10315. width: "834px"
  10316. },
  10317. type: "tablet"
  10318. },
  10319. desktop: {
  10320. name: "Desktop",
  10321. styles: {
  10322. height: "1024px",
  10323. width: "1280px"
  10324. },
  10325. type: "desktop"
  10326. }
  10327. };
  10328. // src/viewport/useViewport.ts
  10329. var URL_VALUE_PATTERN = /^([0-9]{1,4})([a-z]{0,4})-([0-9]{1,4})([a-z]{0,4})$/, VIEWPORT_MIN_WIDTH = 40, VIEWPORT_MIN_HEIGHT = 40, cycle = (viewports, current, direction = 1) => {
  10330. let keys = Object.keys(viewports), nextIndex = (current ? keys.indexOf(current) : -1) + direction;
  10331. return nextIndex < 0 ? keys[keys.length - 1] : nextIndex >= keys.length ? keys[0] : keys[nextIndex];
  10332. }, normalizeGlobal = (value, defaultIsRotated) => typeof value == "string" ? { value, isRotated: defaultIsRotated } : { value: value?.value, isRotated: value?.isRotated ?? defaultIsRotated }, parseGlobals = (globals, storyGlobals, userGlobals, options2, lastSelectedOption, disable, viewMode) => {
  10333. if (viewMode !== "story")
  10334. return {
  10335. name: "Responsive",
  10336. type: "desktop",
  10337. width: "100%",
  10338. height: "100%",
  10339. value: "100pct-100pct",
  10340. option: void 0,
  10341. isCustom: !1,
  10342. isDefault: !0,
  10343. isLocked: !0,
  10344. isRotated: !1
  10345. };
  10346. let global2 = normalizeGlobal(globals?.[PARAM_KEY]), userGlobal = normalizeGlobal(userGlobals?.[PARAM_KEY]), storyGlobal = normalizeGlobal(storyGlobals?.[PARAM_KEY]), storyHasViewport = PARAM_KEY in storyGlobals, primaryGlobal = storyHasViewport ? storyGlobal : userGlobal, secondaryGlobal = storyHasViewport ? userGlobal : storyGlobal, value = primaryGlobal?.value ?? secondaryGlobal?.value ?? global2?.value, isRotated = primaryGlobal?.isRotated ?? secondaryGlobal?.isRotated ?? global2?.isRotated ?? !1, keys = Object.keys(options2), isLocked = disable || PARAM_KEY in storyGlobals || !keys.length, [match, vx, ux, vy, uy] = value?.match(URL_VALUE_PATTERN) || [];
  10347. if (match) {
  10348. let x2 = ux && ux !== "px" ? vx : Math.max(Number(vx), VIEWPORT_MIN_WIDTH), y2 = uy && uy !== "px" ? vy : Math.max(Number(vy), VIEWPORT_MIN_HEIGHT), width = `${x2}${ux === "pct" ? "%" : ux || "px"}`, height = `${y2}${uy === "pct" ? "%" : uy || "px"}`, selection = lastSelectedOption ? options2[lastSelectedOption] : void 0;
  10349. return {
  10350. name: selection?.name ?? "Custom",
  10351. type: selection?.type ?? "other",
  10352. width: isRotated ? height : width,
  10353. height: isRotated ? width : height,
  10354. value: match,
  10355. option: void 0,
  10356. isCustom: !0,
  10357. isDefault: !1,
  10358. isLocked,
  10359. isRotated
  10360. };
  10361. }
  10362. if (value && keys.length) {
  10363. let { name, styles: styles2, type = "other" } = options2[value] ?? options2[keys[0]];
  10364. return {
  10365. name,
  10366. type,
  10367. width: isRotated ? styles2.height : styles2.width,
  10368. height: isRotated ? styles2.width : styles2.height,
  10369. value,
  10370. option: value,
  10371. isCustom: !1,
  10372. isDefault: !1,
  10373. isLocked,
  10374. isRotated
  10375. };
  10376. }
  10377. return {
  10378. name: "Responsive",
  10379. type: "desktop",
  10380. width: "100%",
  10381. height: "100%",
  10382. value: "100pct-100pct",
  10383. option: void 0,
  10384. isCustom: !1,
  10385. isDefault: !0,
  10386. isLocked,
  10387. isRotated: !1
  10388. };
  10389. }, useViewport = () => {
  10390. let api = useStorybookApi(), { viewMode } = api.getUrlState(), lastSelectedOption = useRef(), parameter = useParameter(PARAM_KEY), [globals, updateGlobals, storyGlobals, userGlobals] = useGlobals(), { options: options2 = MINIMAL_VIEWPORTS, disable = !1 } = parameter || {}, { name, type, width, height, value, option, isCustom, isDefault, isLocked, isRotated } = parseGlobals(
  10391. globals,
  10392. storyGlobals,
  10393. userGlobals,
  10394. options2,
  10395. lastSelectedOption.current,
  10396. disable,
  10397. viewMode
  10398. ), update2 = useCallback(
  10399. (input) => updateGlobals({ [PARAM_KEY]: normalizeGlobal(input, !1) }),
  10400. [updateGlobals]
  10401. ), resize = useCallback(
  10402. (width2, height2) => {
  10403. let w2 = width2.replace(/px$/, "").replace(/%$/, "pct"), h2 = height2.replace(/px$/, "").replace(/%$/, "pct"), value2 = isRotated ? `${h2}-${w2}` : `${w2}-${h2}`;
  10404. update2({ value: value2, isRotated });
  10405. },
  10406. [update2, isRotated]
  10407. );
  10408. return useEffect(() => {
  10409. parameter && option && (Object.hasOwn(options2, option) ? lastSelectedOption.current = option : (lastSelectedOption.current = void 0, PARAM_KEY in storyGlobals || update2({ value: void 0, isRotated: !1 })));
  10410. }, [parameter, storyGlobals, options2, option, update2]), useEffect(() => {
  10411. api.setAddonShortcut(ADDON_ID, {
  10412. label: "Next viewport",
  10413. defaultShortcut: ["alt", "V"],
  10414. actionName: "next",
  10415. action: () => update2({ value: cycle(options2, lastSelectedOption.current), isRotated })
  10416. }), api.setAddonShortcut(ADDON_ID, {
  10417. label: "Previous viewport",
  10418. defaultShortcut: ["alt", "shift", "V"],
  10419. actionName: "previous",
  10420. action: () => update2({ value: cycle(options2, lastSelectedOption.current, -1), isRotated })
  10421. }), api.setAddonShortcut(ADDON_ID, {
  10422. label: "Reset viewport",
  10423. defaultShortcut: ["alt", "control", "V"],
  10424. actionName: "reset",
  10425. action: () => update2({ value: void 0, isRotated: !1 })
  10426. });
  10427. }, [api, update2, options2, isRotated]), useMemo(
  10428. () => ({
  10429. name,
  10430. type,
  10431. width,
  10432. height,
  10433. value,
  10434. option,
  10435. isCustom,
  10436. isDefault,
  10437. isLocked,
  10438. isRotated,
  10439. options: options2,
  10440. lastSelectedOption: lastSelectedOption.current,
  10441. resize,
  10442. reset: () => update2({ value: void 0, isRotated: !1 }),
  10443. rotate: () => update2({ value, isRotated: !isRotated }),
  10444. select: (value2) => update2({ value: value2, isRotated })
  10445. }),
  10446. [
  10447. name,
  10448. type,
  10449. width,
  10450. height,
  10451. value,
  10452. option,
  10453. isCustom,
  10454. isDefault,
  10455. isRotated,
  10456. isLocked,
  10457. options2,
  10458. resize,
  10459. update2
  10460. ]
  10461. );
  10462. };
  10463. // src/manager/components/preview/Iframe.tsx
  10464. init_react();
  10465. var StyledIframe = styled.iframe(({ theme }) => ({
  10466. backgroundColor: theme.background.preview,
  10467. display: "block",
  10468. boxSizing: "content-box",
  10469. height: "100%",
  10470. width: "100%",
  10471. border: "none",
  10472. transition: "background-position 0s, visibility 0s",
  10473. backgroundPosition: "-1px -1px, -1px -1px, -1px -1px, -1px -1px",
  10474. margin: "auto"
  10475. }));
  10476. function IFrame(props) {
  10477. let { active, id, title: title2, src, allowFullScreen, scale, ...rest2 } = props, iFrameRef = react_default.useRef(null);
  10478. return react_default.createElement(Zoom.IFrame, { scale, active, iFrameRef }, react_default.createElement(
  10479. StyledIframe,
  10480. {
  10481. "data-is-storybook": active ? "true" : "false",
  10482. onLoad: (e2) => e2.currentTarget.setAttribute("data-is-loaded", "true"),
  10483. id,
  10484. title: title2,
  10485. src,
  10486. allow: "clipboard-write;",
  10487. allowFullScreen,
  10488. ref: iFrameRef,
  10489. ...rest2
  10490. }
  10491. ));
  10492. }
  10493. // src/manager/components/preview/NumericInput.tsx
  10494. init_react();
  10495. var Wrapper = styled.div(
  10496. ({ after: after2, before: before2, theme }) => ({
  10497. position: "relative",
  10498. display: "flex",
  10499. alignItems: "center",
  10500. width: "100%",
  10501. height: 32,
  10502. paddingInline: 9,
  10503. fontSize: theme.typography.size.s1,
  10504. color: theme.textMutedColor,
  10505. background: theme.input.background,
  10506. boxShadow: `${theme.input.border} 0 0 0 1px inset`,
  10507. borderRadius: theme.input.borderRadius,
  10508. svg: {
  10509. display: "block"
  10510. },
  10511. input: {
  10512. width: "100%",
  10513. height: "100%",
  10514. minHeight: "100%",
  10515. flex: "1 1 auto",
  10516. paddingInline: 0,
  10517. fontSize: "inherit",
  10518. background: "transparent",
  10519. border: "none",
  10520. boxShadow: "none",
  10521. color: theme.input.color,
  10522. "&:focus, &:focus-visible": {
  10523. boxShadow: "none",
  10524. outline: "none"
  10525. }
  10526. },
  10527. "input:disabled": {
  10528. background: "transparent"
  10529. },
  10530. "input + div": {
  10531. paddingInline: 0,
  10532. fontSize: "inherit"
  10533. },
  10534. "&:has(input:focus-visible)": {
  10535. outline: `2px solid ${theme.color.secondary}`,
  10536. outlineOffset: -2
  10537. },
  10538. "&:has(input:disabled)": {
  10539. background: theme.base === "light" ? theme.color.lighter : theme.input.background,
  10540. cursor: "not-allowed"
  10541. },
  10542. ...after2 && { paddingRight: 2 },
  10543. ...before2 && { paddingLeft: 2 }
  10544. })
  10545. ), NumericInput = forwardRef(function({
  10546. label,
  10547. before: before2,
  10548. after: after2,
  10549. value,
  10550. setValue,
  10551. minValue = -1 / 0,
  10552. maxValue = 1 / 0,
  10553. step = 1,
  10554. unit: fixedUnit,
  10555. baseUnit = fixedUnit,
  10556. className,
  10557. style,
  10558. ...props
  10559. }, forwardedRef) {
  10560. let baseUnitRegex = useMemo(() => baseUnit && new RegExp(`${baseUnit}$`), [baseUnit]), inputId = $bdb11010cef70236$export$f680877a34711e37(), inputRef = useRef(null), [inputValue, setInputValue] = useState(
  10561. baseUnitRegex ? value.replace(baseUnitRegex, "") : value
  10562. ), id = props.id || inputId;
  10563. useImperativeHandle(forwardedRef, () => inputRef.current);
  10564. let parseValue = useCallback(
  10565. (value2) => {
  10566. let [, inputValue2, unit = fixedUnit || baseUnit || ""] = value2.match(/(-?\d+(?:\.\d+)?)(\%|[a-z]{1,4})?$/) || [];
  10567. return { number: Math.max(minValue, Math.min(parseFloat(inputValue2), maxValue)), unit };
  10568. },
  10569. [minValue, maxValue, fixedUnit, baseUnit]
  10570. ), updateValue = useCallback(
  10571. (value2) => {
  10572. let { number, unit } = parseValue(value2);
  10573. Number.isNaN(number) ? setInputValue(value2) : (setInputValue(`${number}${unit === baseUnit ? "" : unit}`), setValue(`${number}${unit}`));
  10574. },
  10575. [parseValue, setValue, baseUnit]
  10576. ), onChange = useCallback(
  10577. (e2) => updateValue(e2.target.value),
  10578. [updateValue]
  10579. ), setInputSelection = useCallback(() => {
  10580. requestAnimationFrame(() => {
  10581. let input = inputRef.current, index = input?.value.search(/[^-\d.]/) ?? -1;
  10582. input && index >= 0 && input.setSelectionRange(index, index);
  10583. });
  10584. }, []), updateInputValue = useCallback(
  10585. () => setInputValue(baseUnitRegex ? value.replace(baseUnitRegex, "") : value),
  10586. [value, baseUnitRegex]
  10587. );
  10588. return useEffect(() => {
  10589. inputRef.current !== document.activeElement && updateInputValue();
  10590. }, [updateInputValue]), useEffect(() => {
  10591. let handleKeyDown = (e2) => {
  10592. if (e2.key !== "ArrowUp" && e2.key !== "ArrowDown")
  10593. return;
  10594. e2.preventDefault();
  10595. let { number, unit } = parseValue(inputValue);
  10596. if (!Number.isNaN(number)) {
  10597. let delta = e2.shiftKey ? step * 10 : step;
  10598. updateValue(`${e2.key === "ArrowUp" ? number + delta : number - delta}${unit}`), setInputSelection();
  10599. }
  10600. }, input = inputRef.current;
  10601. if (input)
  10602. return input.addEventListener("keydown", handleKeyDown), () => input.removeEventListener("keydown", handleKeyDown);
  10603. }, [inputValue, parseValue, setInputSelection, step, updateValue]), react_default.createElement(Wrapper, { after: after2, before: before2, className, style }, before2 && react_default.createElement("div", null, before2), label && react_default.createElement("label", { htmlFor: id, className: "sb-sr-only" }, label), react_default.createElement(
  10604. Form.Input,
  10605. {
  10606. ...props,
  10607. id,
  10608. ref: inputRef,
  10609. value: inputValue,
  10610. suffix: fixedUnit || inputValue && baseUnit,
  10611. onChange,
  10612. onFocus: setInputSelection,
  10613. onBlur: updateInputValue
  10614. }
  10615. ), after2 && react_default.createElement("div", null, after2));
  10616. });
  10617. // src/manager/components/preview/Viewport.tsx
  10618. var ViewportWrapper = styled.div(({ active, isDefault, theme }) => ({
  10619. gridArea: "1 / 1",
  10620. alignSelf: "start",
  10621. justifySelf: "start",
  10622. display: active ? "inline-flex" : "none",
  10623. flexDirection: "column",
  10624. gap: 6,
  10625. width: "100%",
  10626. height: "100%",
  10627. paddingTop: isDefault ? 0 : 6,
  10628. paddingBottom: isDefault ? 0 : 40,
  10629. paddingInline: isDefault ? 0 : 40,
  10630. '&:has([data-size-input="width"]:focus-visible)': {
  10631. "[data-dragging]": {
  10632. borderRightColor: theme.color.secondary,
  10633. boxShadow: `4px 0 5px -2px ${theme.background.hoverable}`
  10634. }
  10635. },
  10636. '&:has([data-size-input="height"]:focus-visible)': {
  10637. "[data-dragging]": {
  10638. borderBottomColor: theme.color.secondary,
  10639. boxShadow: `0 4px 5px -2px ${theme.background.hoverable}`
  10640. }
  10641. }
  10642. })), ViewportControls = styled.div({
  10643. display: "flex",
  10644. gap: 6
  10645. }), ViewportDimensions = styled.div({
  10646. display: "flex",
  10647. gap: 2
  10648. }), FrameWrapper = styled.div(({ isDefault, "data-dragging": dragging, theme }) => ({
  10649. position: "relative",
  10650. minWidth: VIEWPORT_MIN_WIDTH,
  10651. minHeight: VIEWPORT_MIN_HEIGHT,
  10652. boxSizing: "content-box",
  10653. // we're sizing the contents, not the box itself
  10654. border: `1px solid ${theme.button.border}`,
  10655. borderWidth: isDefault ? 0 : 1,
  10656. borderRadius: isDefault ? 0 : 4,
  10657. transition: "border-color 0.2s, box-shadow 0.2s",
  10658. '&:has([data-side="right"]:hover), &[data-dragging="right"]': {
  10659. borderRightColor: theme.color.secondary,
  10660. boxShadow: `4px 0 5px -2px ${theme.background.hoverable}`,
  10661. '[data-side="right"]::after': {
  10662. opacity: 1
  10663. }
  10664. },
  10665. '&:has([data-side="bottom"]:hover), &[data-dragging="bottom"]': {
  10666. borderBottomColor: theme.color.secondary,
  10667. boxShadow: `0 4px 5px -2px ${theme.background.hoverable}`,
  10668. '[data-side="bottom"]::after': {
  10669. opacity: 1
  10670. }
  10671. },
  10672. '&:has([data-side="both"]:hover), &[data-dragging="both"]': {
  10673. boxShadow: `3px 3px 5px -2px ${theme.background.hoverable}`,
  10674. "&::after, [data-side]::after": {
  10675. opacity: 1
  10676. }
  10677. },
  10678. "&::after": {
  10679. content: '""',
  10680. display: "block",
  10681. position: "absolute",
  10682. pointerEvents: "none",
  10683. bottom: 1,
  10684. right: 1,
  10685. width: 12,
  10686. height: 12,
  10687. opacity: 0,
  10688. transition: "opacity 0.2s",
  10689. background: `linear-gradient(to top left,
  10690. rgba(0,0,0,0) 0%,
  10691. rgba(0,0,0,0) calc(25% - 1px),
  10692. ${theme.color.secondary} 25%,
  10693. rgba(0,0,0,0) calc(25% + 1px),
  10694. rgba(0,0,0,0) calc(45% - 1px),
  10695. ${theme.color.secondary} 45%,
  10696. rgba(0,0,0,0) calc(45% + 1px),
  10697. rgba(0,0,0,0) 100%)`
  10698. },
  10699. iframe: {
  10700. pointerEvents: dragging === "none" ? "auto" : "none"
  10701. }
  10702. })), DragHandle2 = styled.div(
  10703. { display: "none" },
  10704. ({ theme, isDefault }) => !isDefault && {
  10705. display: "block",
  10706. position: "absolute",
  10707. fontSize: 10,
  10708. '&[data-side="both"]': {
  10709. right: -12,
  10710. bottom: -12,
  10711. width: 25,
  10712. height: 25,
  10713. cursor: "nwse-resize"
  10714. },
  10715. '&[data-side="bottom"]': {
  10716. left: 0,
  10717. right: 13,
  10718. bottom: -12,
  10719. height: 20,
  10720. cursor: "row-resize",
  10721. "&::after": {
  10722. content: "attr(data-value)",
  10723. position: "absolute",
  10724. top: "50%",
  10725. left: "50%",
  10726. transform: "translate(-50%, -50%)",
  10727. borderRadius: 4,
  10728. backgroundColor: theme.background.hoverable,
  10729. padding: "2px 4px",
  10730. opacity: 0,
  10731. transition: "opacity 0.2s"
  10732. }
  10733. },
  10734. '&[data-side="right"]': {
  10735. top: 0,
  10736. right: -12,
  10737. bottom: 13,
  10738. width: 20,
  10739. cursor: "col-resize",
  10740. "&::after": {
  10741. content: "attr(data-value)",
  10742. position: "absolute",
  10743. top: "50%",
  10744. left: "50%",
  10745. transform: "translate(-50%, -50%)",
  10746. borderRadius: 4,
  10747. backgroundColor: theme.background.hoverable,
  10748. padding: "2px 4px",
  10749. opacity: 0,
  10750. transition: "opacity 0.2s"
  10751. }
  10752. }
  10753. }
  10754. ), ScrollEdge = styled.div({
  10755. position: "absolute",
  10756. pointerEvents: "none",
  10757. width: 0,
  10758. height: 0,
  10759. '&[data-edge="right"]': {
  10760. right: -40,
  10761. height: "100%"
  10762. },
  10763. '&[data-edge="bottom"]': {
  10764. bottom: -40,
  10765. width: "100%"
  10766. },
  10767. '&[data-edge="both"]': {
  10768. right: -40,
  10769. bottom: -40
  10770. }
  10771. }), SizeInput = styled(NumericInput)({
  10772. width: 85,
  10773. height: 28,
  10774. minHeight: 28
  10775. }), Viewport = ({
  10776. active,
  10777. id,
  10778. src,
  10779. scale
  10780. }) => {
  10781. let { width, height, isCustom, isDefault, lastSelectedOption, resize, rotate, select } = useViewport(), [dragging, setDragging] = useState("none"), targetRef = useRef(null), dragRefX = useRef(null), dragRefY = useRef(null), dragRefXY = useRef(null), dragSide = useRef("none"), dragStart = useRef(), dragScrollTarget = useRef(null);
  10782. useEffect(() => {
  10783. let onDrag = (e2) => {
  10784. if (!(!targetRef.current || !dragStart.current)) {
  10785. if (dragRefX.current && (dragSide.current === "both" || dragSide.current === "right")) {
  10786. let newWidth = Math.max(VIEWPORT_MIN_WIDTH, dragStart.current[0] + e2.clientX);
  10787. targetRef.current.style.width = `${newWidth}px`, dragRefX.current.dataset.value = `${Math.round(newWidth / scale)}`;
  10788. }
  10789. if (dragRefY.current && (dragSide.current === "both" || dragSide.current === "bottom")) {
  10790. let newHeight = Math.max(VIEWPORT_MIN_HEIGHT, dragStart.current[1] + e2.clientY);
  10791. targetRef.current.style.height = `${newHeight}px`, dragRefY.current.dataset.value = `${Math.round(newHeight / scale)}`;
  10792. }
  10793. dragScrollTarget.current && dragScrollTarget.current.scrollIntoView({ block: "center", inline: "center" });
  10794. }
  10795. }, onEnd = () => {
  10796. if (window.removeEventListener("mouseup", onEnd), window.removeEventListener("mousemove", onDrag), setDragging("none"), dragStart.current = void 0, targetRef.current) {
  10797. let { clientWidth, clientHeight, dataset } = targetRef.current, scale2 = Number(dataset.scale) || 1;
  10798. resize(`${Math.round(clientWidth / scale2)}px`, `${Math.round(clientHeight / scale2)}px`);
  10799. }
  10800. }, onStart = (e2) => {
  10801. e2.preventDefault(), window.addEventListener("mouseup", onEnd), window.addEventListener("mousemove", onDrag), dragSide.current = e2.currentTarget.dataset.side, dragStart.current = [
  10802. (targetRef.current?.clientWidth ?? 0) - e2.clientX,
  10803. (targetRef.current?.clientHeight ?? 0) - e2.clientY
  10804. ], dragScrollTarget.current = targetRef.current?.querySelector(
  10805. `[data-edge="${dragSide.current}"]`
  10806. ), setDragging(dragSide.current);
  10807. }, handles = [dragRefX.current, dragRefY.current, dragRefXY.current];
  10808. return handles.forEach((el) => el?.addEventListener("mousedown", onStart)), () => handles.forEach((el) => el?.removeEventListener("mousedown", onStart));
  10809. }, [resize, scale]);
  10810. let dimensions = useMemo(() => {
  10811. let [, nx = "", ux = "px"] = width.match(/^(\d+(?:\.\d+)?)(\%|[a-z]{1,4})?$/) || [], [, ny = "", uy = "px"] = height.match(/^(\d+(?:\.\d+)?)(\%|[a-z]{1,4})?$/) || [];
  10812. return {
  10813. frame: {
  10814. width: `calc(${width} * ${scale})`,
  10815. height: `calc(${height} * ${scale})`
  10816. },
  10817. display: {
  10818. width: `${nx || width}${ux === "px" ? "" : ux}`,
  10819. height: `${ny || height}${uy === "px" ? "" : uy}`
  10820. },
  10821. locked: {
  10822. width: !nx || !ny,
  10823. height: !nx || !ny
  10824. }
  10825. };
  10826. }, [width, height, scale]);
  10827. return react_default.createElement(ViewportWrapper, { key: id, active, isDefault }, !isDefault && react_default.createElement(ViewportControls, null, react_default.createElement(ViewportDimensions, null, react_default.createElement(
  10828. SizeInput,
  10829. {
  10830. "aria-label": "Viewport width",
  10831. "data-size-input": "width",
  10832. label: "Viewport width",
  10833. before: react_default.createElement(ActionList.Action, { size: "small", readOnly: !0, "aria-hidden": !0 }, "W"),
  10834. value: width,
  10835. minValue: 0,
  10836. setValue: (value) => resize(value, height),
  10837. disabled: dimensions.locked.width
  10838. }
  10839. ), react_default.createElement(
  10840. ActionList.Button,
  10841. {
  10842. key: "viewport-rotate",
  10843. size: "small",
  10844. padding: "small",
  10845. ariaLabel: "Rotate viewport",
  10846. onClick: rotate
  10847. },
  10848. react_default.createElement(TransferIcon, null)
  10849. ), react_default.createElement(
  10850. SizeInput,
  10851. {
  10852. "aria-label": "Viewport height",
  10853. "data-size-input": "height",
  10854. label: "Viewport height",
  10855. before: react_default.createElement(ActionList.Action, { size: "small", readOnly: !0, "aria-hidden": !0 }, "H"),
  10856. value: height,
  10857. minValue: 0,
  10858. setValue: (value) => resize(width, value),
  10859. disabled: dimensions.locked.height
  10860. }
  10861. ), isCustom && lastSelectedOption && react_default.createElement(
  10862. ActionList.Button,
  10863. {
  10864. key: "viewport-restore",
  10865. size: "small",
  10866. padding: "small",
  10867. ariaLabel: "Restore viewport",
  10868. onClick: () => select(lastSelectedOption)
  10869. },
  10870. react_default.createElement(UndoIcon, null)
  10871. ))), react_default.createElement(
  10872. FrameWrapper,
  10873. {
  10874. isDefault,
  10875. "data-dragging": dragging,
  10876. "data-scale": scale,
  10877. style: isDefault ? { height: "100%", width: "100%" } : dimensions.frame,
  10878. ref: targetRef
  10879. },
  10880. react_default.createElement(
  10881. "div",
  10882. {
  10883. style: {
  10884. height: `${1 / scale * 100}%`,
  10885. width: `${1 / scale * 100}%`,
  10886. transform: scale !== 1 ? `scale(${scale})` : "none",
  10887. transformOrigin: "top left"
  10888. }
  10889. },
  10890. react_default.createElement(IFrame, { allowFullScreen: !0, active, key: id, id, title: id, src, scale: 1 }),
  10891. !isDefault && react_default.createElement(react_default.Fragment, null, react_default.createElement(ScrollEdge, { "data-edge": "right" }), react_default.createElement(ScrollEdge, { "data-edge": "bottom" }), react_default.createElement(ScrollEdge, { "data-edge": "both" }))
  10892. ),
  10893. !dimensions.locked.width && react_default.createElement(
  10894. DragHandle2,
  10895. {
  10896. ref: dragRefX,
  10897. isDefault,
  10898. "data-side": "right",
  10899. "data-value": dimensions.display.width
  10900. }
  10901. ),
  10902. !dimensions.locked.height && react_default.createElement(
  10903. DragHandle2,
  10904. {
  10905. ref: dragRefY,
  10906. isDefault,
  10907. "data-side": "bottom",
  10908. "data-value": dimensions.display.height
  10909. }
  10910. ),
  10911. !dimensions.locked.width && !dimensions.locked.height && react_default.createElement(DragHandle2, { ref: dragRefXY, isDefault, "data-side": "both" })
  10912. ));
  10913. };
  10914. // src/manager/components/preview/FramesRenderer.tsx
  10915. var getActive = (refId, refs) => refId && refs[refId] ? `storybook-ref-${refId}` : "storybook-preview-iframe", SkipToSidebarLink = styled(Button)(({ theme }) => ({
  10916. display: "none",
  10917. "@media (min-width: 600px)": {
  10918. position: "absolute",
  10919. display: "block",
  10920. top: 10,
  10921. right: 15,
  10922. padding: "10px 15px",
  10923. fontSize: theme.typography.size.s1,
  10924. transform: "translateY(-100px)",
  10925. "&:focus": {
  10926. transform: "translateY(0)",
  10927. zIndex: 1
  10928. }
  10929. }
  10930. })), whenSidebarIsVisible = ({ api, state }) => ({
  10931. isFullscreen: api.getIsFullscreen(),
  10932. isNavShown: api.getIsNavShown(),
  10933. selectedStoryId: state.storyId
  10934. }), styles = {
  10935. '#root [data-is-storybook="false"]': {
  10936. display: "none"
  10937. },
  10938. '#root [data-is-storybook="true"]': {
  10939. display: "block"
  10940. }
  10941. }, FramesRenderer = ({
  10942. api,
  10943. refs,
  10944. scale,
  10945. viewMode = "story",
  10946. refId,
  10947. queryParams = {},
  10948. storyId = "*"
  10949. }) => {
  10950. let version3 = refs[refId]?.version, active = getActive(refId, refs), { current: frames } = useRef({}), refsToLoad = Object.values(refs).filter((ref) => ref.type === "auto-inject" || ref.id === refId, {});
  10951. return frames["storybook-preview-iframe"] || (frames["storybook-preview-iframe"] = api.getStoryHrefs(storyId, {
  10952. queryParams: { ...queryParams, ...version3 && { version: version3 } },
  10953. refId,
  10954. viewMode
  10955. }).previewHref), refsToLoad.forEach((ref) => {
  10956. let id = `storybook-ref-${ref.id}`;
  10957. frames[id]?.startsWith(`${ref.url.replace(/\/?$/, "/")}iframe.html`) || (frames[id] = api.getStoryHrefs(storyId, {
  10958. queryParams: { ...queryParams, ...version3 && { version: version3 } },
  10959. refId: ref.id,
  10960. viewMode
  10961. }).previewHref);
  10962. }), react_default.createElement(Fragment, null, react_default.createElement(Global, { styles }), react_default.createElement(Consumer, { filter: whenSidebarIsVisible }, ({ isFullscreen, isNavShown, selectedStoryId }) => isFullscreen || !isNavShown || !selectedStoryId ? null : react_default.createElement(SkipToSidebarLink, { ariaLabel: !1, asChild: !0 }, react_default.createElement("a", { href: `#${selectedStoryId}`, tabIndex: 0 }, "Skip to sidebar"))), Object.entries(frames).map(([id, src]) => react_default.createElement(Viewport, { key: id, id, src, active: id === active, scale })));
  10963. };
  10964. // src/manager/components/preview/Toolbar.tsx
  10965. init_react();
  10966. var fullScreenMapper = ({ api, state }) => ({
  10967. toggle: api.toggleFullscreen,
  10968. isFullscreen: api.getIsFullscreen(),
  10969. shortcut: api.getShortcutKeys().fullScreen,
  10970. hasPanel: Object.keys(api.getElements(Addon_TypesEnum.PANEL)).length > 0,
  10971. singleStory: state.singleStory
  10972. }), fullScreenTool = {
  10973. title: "fullscreen",
  10974. id: "fullscreen",
  10975. type: types.TOOL,
  10976. // @ts-expect-error (non strict)
  10977. match: (p2) => ["story", "docs"].includes(p2.viewMode),
  10978. render: () => {
  10979. let { isMobile: isMobile2 } = useLayout();
  10980. return isMobile2 ? null : react_default.createElement(Consumer, { filter: fullScreenMapper }, ({ toggle, isFullscreen, shortcut, hasPanel, singleStory }) => (!singleStory || singleStory && hasPanel) && react_default.createElement(
  10981. Button,
  10982. {
  10983. key: "full",
  10984. padding: "small",
  10985. variant: "ghost",
  10986. onClick: () => toggle(),
  10987. ariaLabel: isFullscreen ? "Exit full screen" : "Enter full screen",
  10988. shortcut
  10989. },
  10990. isFullscreen ? react_default.createElement(CloseIcon, null) : react_default.createElement(ExpandIcon, null)
  10991. ));
  10992. }
  10993. }, ToolbarComp = react_default.memo(function({
  10994. isShown,
  10995. tools,
  10996. toolsExtra,
  10997. tabs,
  10998. tabState
  10999. }) {
  11000. let sectionRef = useRef(null), { landmarkProps } = useLandmark(
  11001. { "aria-labelledby": "sb-preview-toolbar-title", role: "region" },
  11002. sectionRef
  11003. );
  11004. return isShown && (tabs || tools || toolsExtra) ? react_default.createElement(
  11005. StyledSection,
  11006. {
  11007. className: "sb-bar",
  11008. key: "toolbar",
  11009. "data-testid": "sb-preview-toolbar",
  11010. ref: sectionRef,
  11011. ...landmarkProps
  11012. },
  11013. react_default.createElement("h2", { id: "sb-preview-toolbar-title", className: "sb-sr-only" }, "Toolbar"),
  11014. tabs.length > 1 ? react_default.createElement(react_default.Fragment, null, react_default.createElement(TabList, { state: tabState }), react_default.createElement(Separator, null)) : null,
  11015. react_default.createElement(StyledToolbar, null, react_default.createElement(Tools, { key: "left", list: tools }), react_default.createElement(Tools, { key: "right", list: toolsExtra }))
  11016. ) : null;
  11017. }), Tools = react_default.memo(function({ list }) {
  11018. return react_default.createElement(ToolGroup, null, list.filter(Boolean).map(({ render: Render, id, ...t2 }, index) => (
  11019. // @ts-expect-error (Converted from ts-ignore)
  11020. react_default.createElement(Render, { key: id || t2.key || `f-${index}` })
  11021. )));
  11022. });
  11023. function toolbarItemHasBeenExcluded(item, entry) {
  11024. let parameters = entry?.type === "story" && entry?.prepared ? entry?.parameters : {}, toolbarItemsFromStoryParameters = "toolbar" in parameters ? parameters.toolbar : void 0, { toolbar: toolbarItemsFromAddonsConfig } = addons.getConfig(), toolbarItems = merge(
  11025. toolbarItemsFromAddonsConfig || {},
  11026. toolbarItemsFromStoryParameters || {}
  11027. );
  11028. return toolbarItems ? !!toolbarItems[item?.id]?.hidden : !1;
  11029. }
  11030. function filterToolsSide(tools, entry, viewMode, location2, path, tabId) {
  11031. let filter = (item) => item && (!item.match || item.match({
  11032. storyId: entry?.id,
  11033. refId: entry?.refId,
  11034. viewMode,
  11035. location: location2,
  11036. path,
  11037. tabId
  11038. })) && !toolbarItemHasBeenExcluded(item, entry);
  11039. return tools.filter(filter);
  11040. }
  11041. var StyledSection = styled.section(({ theme }) => ({
  11042. position: "relative",
  11043. display: "flex",
  11044. alignItems: "center",
  11045. color: theme.barTextColor,
  11046. width: "100%",
  11047. flexShrink: 0,
  11048. overflowX: "auto",
  11049. overflowY: "hidden",
  11050. boxShadow: `${theme.appBorderColor} 0 -1px 0 0 inset`,
  11051. background: theme.barBg,
  11052. scrollbarColor: `${theme.barTextColor} ${theme.barBg}`,
  11053. scrollbarWidth: "thin",
  11054. zIndex: 4
  11055. })), StyledToolbar = styled(AbstractToolbar)({
  11056. flex: 1,
  11057. display: "flex",
  11058. justifyContent: "space-between",
  11059. flexWrap: "nowrap",
  11060. flexShrink: 0,
  11061. height: 40,
  11062. marginInline: 10,
  11063. gap: 30
  11064. }), ToolGroup = styled.div({
  11065. display: "flex",
  11066. whiteSpace: "nowrap",
  11067. flexBasis: "auto",
  11068. gap: 6,
  11069. alignItems: "center"
  11070. });
  11071. // src/manager/components/preview/Wrappers.tsx
  11072. init_react();
  11073. // src/manager/components/preview/utils/components.ts
  11074. var PreviewContainer = styled.div({
  11075. display: "flex",
  11076. flexDirection: "column",
  11077. width: "100%",
  11078. height: "100%",
  11079. overflow: "hidden"
  11080. }), FrameWrap = styled.main({
  11081. overflow: "auto",
  11082. width: "100%",
  11083. zIndex: 3,
  11084. background: "transparent",
  11085. flex: 1
  11086. }), CanvasWrap = styled.div(
  11087. {
  11088. alignContent: "center",
  11089. alignItems: "center",
  11090. justifyContent: "center",
  11091. justifyItems: "center",
  11092. overflow: "auto",
  11093. gridTemplateColumns: "100%",
  11094. gridTemplateRows: "100%",
  11095. position: "relative",
  11096. minWidth: "100%",
  11097. minHeight: "100%"
  11098. },
  11099. ({ show }) => ({ display: show ? "grid" : "none" })
  11100. ), UnstyledLink = styled(Link2)({
  11101. color: "inherit",
  11102. textDecoration: "inherit",
  11103. display: "inline-block"
  11104. }), DesktopOnly = styled.span({
  11105. // Hides full screen icon at mobile breakpoint defined in app.js
  11106. "@media (max-width: 599px)": {
  11107. display: "none"
  11108. }
  11109. }), IframeWrapper = styled.div(({ theme }) => ({
  11110. alignContent: "center",
  11111. alignItems: "center",
  11112. justifyContent: "center",
  11113. justifyItems: "center",
  11114. overflow: "auto",
  11115. display: "grid",
  11116. gridTemplateColumns: "100%",
  11117. gridTemplateRows: "100%",
  11118. position: "relative",
  11119. width: "100%",
  11120. height: "100%"
  11121. })), LoaderWrapper = styled.div(({ theme }) => ({
  11122. position: "absolute",
  11123. top: 0,
  11124. left: 0,
  11125. bottom: 0,
  11126. right: 0,
  11127. background: theme.background.preview,
  11128. zIndex: 1
  11129. }));
  11130. // src/manager/components/preview/Wrappers.tsx
  11131. var ApplyWrappers = ({
  11132. wrappers,
  11133. id,
  11134. storyId,
  11135. children
  11136. }) => react_default.createElement(Fragment, null, wrappers.reduceRight(
  11137. (acc, wrapper, index) => react_default.createElement(wrapper.render, { index, children: acc, id, storyId }),
  11138. children
  11139. )), defaultWrappers = [
  11140. {
  11141. id: "iframe-wrapper",
  11142. type: Addon_TypesEnum.PREVIEW,
  11143. render: (p2) => react_default.createElement(IframeWrapper, { id: "storybook-preview-wrapper" }, p2.children)
  11144. }
  11145. ];
  11146. // src/manager/components/preview/tools/zoom.tsx
  11147. init_react();
  11148. // src/manager/components/Shortcut.tsx
  11149. init_react();
  11150. var Wrapper2 = styled.span(({ theme }) => ({
  11151. display: "inline-flex",
  11152. alignItems: "center",
  11153. justifyContent: "center",
  11154. height: 16,
  11155. fontSize: "11px",
  11156. fontWeight: theme.typography.weight.regular,
  11157. background: theme.base === "light" ? "rgba(0,0,0,0.05)" : "rgba(255,255,255,0.05)",
  11158. color: theme.base === "light" ? theme.color.dark : theme.textMutedColor,
  11159. borderRadius: 2,
  11160. userSelect: "none",
  11161. pointerEvents: "none",
  11162. padding: "0 4px"
  11163. })), Key = styled.kbd(({ theme }) => ({
  11164. padding: 0,
  11165. fontFamily: theme.typography.fonts.base,
  11166. verticalAlign: "middle",
  11167. "& + &": {
  11168. marginLeft: 6
  11169. }
  11170. })), Shortcut = ({ keys }) => react_default.createElement(Wrapper2, null, keys.map((key) => react_default.createElement(Key, { key }, shortcutToHumanString([key]))));
  11171. // src/manager/components/preview/tools/zoom.tsx
  11172. var ZOOM_LEVELS = [0.25, 0.5, 0.75, 0.9, 1, 1.1, 1.25, 1.5, 2, 3, 4, 8], INITIAL_ZOOM_LEVEL = 1, ZoomButton = styled(ToggleButton)({
  11173. minWidth: 48
  11174. }), ZoomResetButton = styled(ActionList.Button)(
  11175. ({ $isInitialValue }) => ({
  11176. visibility: $isInitialValue ? "hidden" : void 0
  11177. })
  11178. ), Context = createContext({ value: INITIAL_ZOOM_LEVEL, set: (v2) => {
  11179. } }), ZoomInput = styled(NumericInput)({
  11180. input: {
  11181. width: 100
  11182. }
  11183. }), ZoomConsumer = Context.Consumer, ZoomProvider = class extends Component {
  11184. constructor() {
  11185. super(...arguments);
  11186. this.state = {
  11187. value: INITIAL_ZOOM_LEVEL
  11188. };
  11189. this.set = (value) => this.setState({ value });
  11190. }
  11191. render() {
  11192. let { children, shouldScale } = this.props, { set } = this, { value } = this.state;
  11193. return react_default.createElement(Context.Provider, { value: { value: shouldScale ? value : INITIAL_ZOOM_LEVEL, set } }, children);
  11194. }
  11195. }, Zoom2 = memo(function({ value, zoomIn, zoomOut, zoomTo, zoomBy }) {
  11196. let inputRef = useRef(null);
  11197. return react_default.createElement(
  11198. PopoverProvider,
  11199. {
  11200. padding: "none",
  11201. onVisibleChange: (isVisible) => {
  11202. isVisible && requestAnimationFrame(() => inputRef.current?.select());
  11203. },
  11204. popover: react_default.createElement(react_default.Fragment, null, react_default.createElement(ActionList, null, react_default.createElement(ActionList.Item, null, react_default.createElement(
  11205. ZoomInput,
  11206. {
  11207. "aria-label": "Zoom percentage",
  11208. ref: inputRef,
  11209. unit: "%",
  11210. before: react_default.createElement(ActionList.Button, { size: "small", padding: "small", readOnly: !0, "aria-hidden": !0 }, react_default.createElement(ZoomIcon, null)),
  11211. after: react_default.createElement(
  11212. ZoomResetButton,
  11213. {
  11214. size: "small",
  11215. padding: "small",
  11216. $isInitialValue: value === INITIAL_ZOOM_LEVEL,
  11217. onClick: () => zoomTo(INITIAL_ZOOM_LEVEL),
  11218. ariaLabel: "Reset zoom",
  11219. "aria-hidden": value === INITIAL_ZOOM_LEVEL
  11220. },
  11221. react_default.createElement(UndoIcon, null)
  11222. ),
  11223. value: `${Math.round(value * 100)}%`,
  11224. minValue: 1,
  11225. maxValue: 800,
  11226. setValue: (value2) => {
  11227. let zoomLevel = parseInt(value2, 10) / 100;
  11228. Number.isNaN(zoomLevel) || zoomTo(zoomLevel);
  11229. }
  11230. }
  11231. ))), react_default.createElement(ActionList, null, react_default.createElement(ActionList.Item, null, react_default.createElement(
  11232. ActionList.Action,
  11233. {
  11234. onClick: zoomIn,
  11235. ariaLabel: "Zoom in",
  11236. disabled: value >= ZOOM_LEVELS.at(-1)
  11237. },
  11238. react_default.createElement(ActionList.Text, null, "Zoom in"),
  11239. react_default.createElement(Shortcut, { keys: ["alt", "+"] })
  11240. )), react_default.createElement(ActionList.Item, null, react_default.createElement(
  11241. ActionList.Action,
  11242. {
  11243. onClick: zoomOut,
  11244. ariaLabel: "Zoom out",
  11245. disabled: value <= ZOOM_LEVELS.at(0)
  11246. },
  11247. react_default.createElement(ActionList.Text, null, "Zoom out"),
  11248. react_default.createElement(Shortcut, { keys: ["alt", "-"] })
  11249. )), react_default.createElement(ActionList.Item, { active: value === 0.5 }, react_default.createElement(ActionList.Action, { onClick: () => zoomTo(0.5), ariaLabel: "Zoom to 50%" }, react_default.createElement(ActionList.Text, null, "50%"))), react_default.createElement(ActionList.Item, { active: value === 1 }, react_default.createElement(ActionList.Action, { onClick: () => zoomTo(1), ariaLabel: "Zoom to 100%" }, react_default.createElement(ActionList.Text, null, "100%"), react_default.createElement(Shortcut, { keys: ["alt", "0"] }))), react_default.createElement(ActionList.Item, { active: value === 2 }, react_default.createElement(ActionList.Action, { onClick: () => zoomTo(2), ariaLabel: "Zoom to 200%" }, "200%"))))
  11250. },
  11251. react_default.createElement(
  11252. ZoomButton,
  11253. {
  11254. padding: "small",
  11255. variant: "ghost",
  11256. ariaLabel: "Change zoom level",
  11257. pressed: value !== INITIAL_ZOOM_LEVEL,
  11258. onKeyDown: (e2) => {
  11259. e2.key === "ArrowDown" ? (zoomBy(e2.getModifierState("Shift") ? -0.1 : -0.01), e2.preventDefault()) : e2.key === "ArrowUp" ? (zoomBy(e2.getModifierState("Shift") ? 0.1 : 0.01), e2.preventDefault()) : e2.key === "PageDown" ? (zoomOut(), e2.preventDefault()) : e2.key === "PageUp" ? (zoomIn(), e2.preventDefault()) : e2.key === "Home" ? (zoomTo(ZOOM_LEVELS[ZOOM_LEVELS.length - 1]), e2.preventDefault()) : e2.key === "End" && (zoomTo(ZOOM_LEVELS[0]), e2.preventDefault());
  11260. },
  11261. onWheel: (e2) => {
  11262. e2.deltaY < 0 ? zoomIn() : e2.deltaY > 0 && zoomOut(), e2.preventDefault();
  11263. }
  11264. },
  11265. Math.round(value * 100),
  11266. "%"
  11267. )
  11268. );
  11269. }), ZoomWrapper = memo(function({ set, value }) {
  11270. let api = useStorybookApi(), zoomIn = useCallback(() => {
  11271. let higherZoomLevel = ZOOM_LEVELS.find((level) => level > value);
  11272. higherZoomLevel && set(higherZoomLevel);
  11273. }, [set, value]), zoomOut = useCallback(() => {
  11274. let lowerZoomLevel = ZOOM_LEVELS.findLast((level) => level < value);
  11275. lowerZoomLevel && set(lowerZoomLevel);
  11276. }, [set, value]), zoomBy = useCallback(
  11277. (delta) => {
  11278. let min = ZOOM_LEVELS[0], max = ZOOM_LEVELS[ZOOM_LEVELS.length - 1];
  11279. set(Math.max(min, Math.min(max, value + delta)));
  11280. },
  11281. [set, value]
  11282. ), zoomTo = useCallback(
  11283. (value2) => {
  11284. set(value2);
  11285. },
  11286. [set]
  11287. );
  11288. return useEffect(() => {
  11289. api.setAddonShortcut("zoom", {
  11290. label: "Zoom to 100%",
  11291. defaultShortcut: ["alt", "0"],
  11292. actionName: "zoomReset",
  11293. action: () => zoomTo(1)
  11294. }), api.setAddonShortcut("zoom", {
  11295. label: "Zoom in",
  11296. defaultShortcut: ["alt", "="],
  11297. actionName: "zoomIn",
  11298. action: zoomIn
  11299. }), api.setAddonShortcut("zoom", {
  11300. label: "Zoom in",
  11301. defaultShortcut: ["alt", "+"],
  11302. actionName: "zoomPlus",
  11303. action: zoomIn
  11304. }), api.setAddonShortcut("zoom", {
  11305. label: "Zoom out",
  11306. defaultShortcut: ["alt", "-"],
  11307. actionName: "zoomOut",
  11308. action: zoomOut
  11309. });
  11310. }, [api, zoomIn, zoomOut, zoomTo]), react_default.createElement(Zoom2, { key: "zoom", value, zoomIn, zoomOut, zoomTo, zoomBy });
  11311. }), zoomTool = {
  11312. title: "zoom",
  11313. id: "zoom",
  11314. type: types.TOOL,
  11315. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  11316. render: () => react_default.createElement(ZoomConsumer, null, (zoomContext) => react_default.createElement(ZoomWrapper, { ...zoomContext }))
  11317. };
  11318. // src/manager/components/preview/Preview.tsx
  11319. var canvasMapper = ({ state, api }) => ({
  11320. api,
  11321. storyId: state.storyId,
  11322. refId: state.refId,
  11323. viewMode: state.viewMode,
  11324. customCanvas: api.renderPreview,
  11325. queryParams: state.customQueryParams,
  11326. getElements: api.getElements,
  11327. entry: api.getData(state.storyId, state.refId),
  11328. previewInitialized: state.previewInitialized,
  11329. refs: state.refs
  11330. }), createCanvasTab = () => ({
  11331. id: "canvas",
  11332. type: types.TAB,
  11333. title: "Canvas",
  11334. route: ({ storyId, refId }) => refId ? `/story/${refId}_${storyId}` : `/story/${storyId}`,
  11335. match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),
  11336. render: () => null
  11337. }), Preview = react_default.memo(function(props) {
  11338. let {
  11339. api,
  11340. id: previewId,
  11341. options: options2,
  11342. viewMode,
  11343. storyId,
  11344. entry = void 0,
  11345. description,
  11346. baseUrl,
  11347. withLoader = !0,
  11348. tools,
  11349. toolsExtra,
  11350. tabs,
  11351. wrappers,
  11352. tabId
  11353. } = props, tabState = useTabsState({
  11354. selected: tabId ?? "canvas",
  11355. onSelectionChange: (key) => {
  11356. api.applyQueryParams({ tab: key === "canvas" ? void 0 : key });
  11357. },
  11358. tabs: tabs.map((tab, index) => ({
  11359. id: tab.id ?? `tab-${index}`,
  11360. title: tab.title,
  11361. isDisabled: !!tab.disabled,
  11362. children: () => tab.render({ active: !0 })
  11363. }))
  11364. });
  11365. tabs.length > 1 && deprecate("Addon tabs are deprecated and will be removed in Storybook 11.");
  11366. let tabContent = tabs.find((tab) => tab.id === tabId)?.render, shouldScale = viewMode === "story", { showToolbar } = options2, customisedShowToolbar = api.getShowToolbarWithCustomisations(showToolbar), previousStoryId = useRef(storyId);
  11367. useEffect(() => {
  11368. if (entry && viewMode) {
  11369. if (storyId === previousStoryId.current)
  11370. return;
  11371. if (previousStoryId.current = storyId, viewMode.match(/docs|story/)) {
  11372. let { refId, id } = entry;
  11373. api.emit(SET_CURRENT_STORY, {
  11374. storyId: id,
  11375. viewMode,
  11376. options: { target: refId }
  11377. });
  11378. }
  11379. }
  11380. }, [entry, viewMode, storyId, api]);
  11381. let mainRef = useRef(null), { landmarkProps } = useLandmark(
  11382. { "aria-labelledby": "main-preview-heading", role: "main" },
  11383. mainRef
  11384. );
  11385. return react_default.createElement(Fragment, null, previewId === "main" && react_default.createElement(W, { key: "description" }, react_default.createElement("title", null, description)), react_default.createElement(ZoomProvider, { shouldScale }, react_default.createElement(PreviewContainer, null, react_default.createElement(
  11386. ToolbarComp,
  11387. {
  11388. key: "tools",
  11389. isShown: customisedShowToolbar,
  11390. tabs,
  11391. tabState,
  11392. tools,
  11393. toolsExtra
  11394. }
  11395. ), react_default.createElement(FrameWrap, { ref: mainRef, ...landmarkProps }, react_default.createElement("h2", { id: "main-preview-heading", className: "sb-sr-only" }, "Main preview area"), tabContent && react_default.createElement(IframeWrapper, null, tabContent({ active: !0 })), react_default.createElement(CanvasWrap, { show: !tabId || tabId === "canvas" }, react_default.createElement(Canvas, { withLoader, baseUrl, wrappers }))))));
  11396. });
  11397. var Canvas = ({ baseUrl, withLoader, wrappers }) => react_default.createElement(Consumer, { filter: canvasMapper }, ({
  11398. api,
  11399. entry,
  11400. refs,
  11401. customCanvas,
  11402. storyId,
  11403. refId,
  11404. viewMode,
  11405. queryParams,
  11406. previewInitialized
  11407. }) => {
  11408. let id = "canvas", [progress, setProgress] = useState(void 0);
  11409. useEffect(() => {
  11410. if (scope.CONFIG_TYPE === "DEVELOPMENT")
  11411. try {
  11412. addons.getChannel().on(PREVIEW_BUILDER_PROGRESS, (options2) => {
  11413. setProgress(options2);
  11414. });
  11415. } catch {
  11416. }
  11417. }, []);
  11418. let refLoading = !!refs[refId] && !refs[refId].previewInitialized, isBuilding = !(progress?.value === 1 || progress === void 0), rootLoading = !refId && (!previewInitialized || isBuilding), isLoading = entry && refLoading || rootLoading;
  11419. return react_default.createElement(ZoomConsumer, null, ({ value: scale }) => react_default.createElement(react_default.Fragment, null, withLoader && isLoading && react_default.createElement(LoaderWrapper, null, react_default.createElement(Loader, { id: "preview-loader", role: "progressbar", progress })), react_default.createElement(ApplyWrappers, { id, storyId, viewMode, wrappers }, customCanvas ? customCanvas(storyId, viewMode, id, baseUrl, scale, queryParams) : react_default.createElement(
  11420. FramesRenderer,
  11421. {
  11422. api,
  11423. refs,
  11424. scale,
  11425. entry,
  11426. viewMode,
  11427. refId,
  11428. queryParams,
  11429. storyId
  11430. }
  11431. ))));
  11432. });
  11433. function filterTabs(panels, parameters) {
  11434. let { previewTabs } = addons.getConfig(), parametersTabs = parameters ? parameters.previewTabs : void 0;
  11435. if (previewTabs || parametersTabs) {
  11436. let tabs = merge(previewTabs || {}, parametersTabs || {}), arrTabs = Object.keys(tabs).map((key, index) => ({
  11437. index,
  11438. ...typeof tabs[key] == "string" ? { title: tabs[key] } : tabs[key],
  11439. id: key
  11440. }));
  11441. return panels.filter((panel) => {
  11442. let t2 = arrTabs.find((tab) => tab.id === panel.id);
  11443. return t2 === void 0 || t2.id === "canvas" || !t2.hidden;
  11444. }).map((panel, index) => ({ ...panel, index })).sort((p1, p2) => {
  11445. let tab_1 = arrTabs.find((tab) => tab.id === p1.id), index_1 = tab_1 ? tab_1.index : arrTabs.length + p1.index, tab_2 = arrTabs.find((tab) => tab.id === p2.id), index_2 = tab_2 ? tab_2.index : arrTabs.length + p2.index;
  11446. return index_1 - index_2;
  11447. }).map((panel) => {
  11448. let t2 = arrTabs.find((tab) => tab.id === panel.id);
  11449. return t2 ? {
  11450. ...panel,
  11451. title: t2.title || panel.title,
  11452. disabled: t2.disabled,
  11453. hidden: t2.hidden
  11454. } : panel;
  11455. });
  11456. }
  11457. return panels;
  11458. }
  11459. // src/manager/components/preview/tools/addons.tsx
  11460. init_react();
  11461. var SHOW_ADDON_PANEL_BUTTON_ID = "storybook-show-addon-panel", menuMapper = ({ api, state }) => ({
  11462. isVisible: api.getIsPanelShown(),
  11463. singleStory: state.singleStory,
  11464. panelPosition: state.layout.panelPosition,
  11465. showPanel: async (forceFocus) => {
  11466. api.togglePanel(!0), api.focusOnUIElement(focusableUIElements.addonPanel, {
  11467. forceFocus,
  11468. poll: !0
  11469. });
  11470. }
  11471. }), addonsTool = {
  11472. title: "addons",
  11473. id: "addons",
  11474. type: types.TOOL,
  11475. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  11476. render: () => react_default.createElement(Consumer, { filter: menuMapper }, ({ isVisible, showPanel, singleStory, panelPosition }) => !singleStory && !isVisible && react_default.createElement(react_default.Fragment, null, react_default.createElement(
  11477. Button,
  11478. {
  11479. padding: "small",
  11480. variant: "ghost",
  11481. ariaLabel: "Show addon panel",
  11482. id: SHOW_ADDON_PANEL_BUTTON_ID,
  11483. key: "addons",
  11484. onClick: () => showPanel(!1),
  11485. onKeyDown: (e2) => {
  11486. (e2.key === "Enter" || e2.key === " ") && (e2.preventDefault(), showPanel(!0));
  11487. }
  11488. },
  11489. panelPosition === "bottom" ? react_default.createElement(BottomBarIcon, null) : react_default.createElement(SidebarAltIcon, null)
  11490. )))
  11491. };
  11492. // src/manager/components/preview/tools/menu.tsx
  11493. init_react();
  11494. var menuMapper2 = ({ api, state }) => ({
  11495. isVisible: api.getIsNavShown(),
  11496. singleStory: state.singleStory,
  11497. viewMode: state.viewMode,
  11498. showSidebar: async (forceFocus) => {
  11499. api.toggleNav(!0), api.focusOnUIElement(focusableUIElements.sidebarRegion, {
  11500. forceFocus,
  11501. poll: !0
  11502. });
  11503. }
  11504. }), menuTool = {
  11505. title: "menu",
  11506. id: "menu",
  11507. type: types.TOOL,
  11508. // @ts-expect-error (non strict)
  11509. match: ({ viewMode }) => ["story", "docs"].includes(viewMode),
  11510. render: () => react_default.createElement(Consumer, { filter: menuMapper2 }, ({ isVisible, showSidebar, singleStory }) => !singleStory && !isVisible && react_default.createElement(react_default.Fragment, null, react_default.createElement(
  11511. Button,
  11512. {
  11513. padding: "small",
  11514. variant: "ghost",
  11515. ariaLabel: "Show sidebar",
  11516. id: focusableUIElements.showSidebar,
  11517. key: "menu",
  11518. onClick: () => showSidebar(!1),
  11519. onKeyDown: (e2) => {
  11520. (e2.key === "Enter" || e2.key === " ") && (e2.preventDefault(), showSidebar(!0));
  11521. }
  11522. },
  11523. react_default.createElement(MenuIcon, null)
  11524. ), react_default.createElement(Separator, null)))
  11525. };
  11526. // src/manager/components/preview/tools/open-in-editor.tsx
  11527. init_react();
  11528. var mapper2 = ({ state, api }) => {
  11529. let { storyId, refId } = state, entry = api.getData(storyId, refId);
  11530. return {
  11531. storyId,
  11532. isCompositionStory: !!refId,
  11533. importPath: entry?.importPath
  11534. };
  11535. }, openInEditorTool = {
  11536. title: "open-in-editor",
  11537. id: "open-in-editor",
  11538. type: types.TOOL,
  11539. match: ({ viewMode, tabId }) => scope.CONFIG_TYPE === "DEVELOPMENT" && (viewMode === "story" || viewMode === "docs") && !tabId,
  11540. render: () => react_default.createElement(Consumer, { filter: mapper2 }, ({ importPath, isCompositionStory }) => {
  11541. let api = useStorybookApi();
  11542. return isCompositionStory || !importPath ? null : react_default.createElement(
  11543. Button,
  11544. {
  11545. key: "open-in-editor",
  11546. onClick: () => api.openInEditor({
  11547. file: importPath
  11548. }),
  11549. ariaLabel: "Open in editor",
  11550. padding: "small",
  11551. variant: "ghost"
  11552. },
  11553. react_default.createElement(EditorIcon, null)
  11554. );
  11555. })
  11556. };
  11557. // src/manager/components/preview/tools/remount.tsx
  11558. init_react();
  11559. var StyledAnimatedButton = styled(Button)(({ theme, animating, disabled }) => ({
  11560. opacity: disabled ? 0.5 : 1,
  11561. svg: {
  11562. animation: animating ? `${theme.animation.rotate360} 1000ms ease-out` : void 0
  11563. }
  11564. })), menuMapper3 = ({ api, state }) => {
  11565. let { storyId } = state;
  11566. return {
  11567. storyId,
  11568. remount: () => api.emit(FORCE_REMOUNT, { storyId: state.storyId }),
  11569. api
  11570. };
  11571. }, remountTool = {
  11572. title: "remount",
  11573. id: "remount",
  11574. type: types.TOOL,
  11575. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  11576. render: () => react_default.createElement(Consumer, { filter: menuMapper3 }, ({ remount, storyId, api }) => {
  11577. let [isAnimating, setIsAnimating] = useState(!1), remountComponent = () => {
  11578. storyId && remount();
  11579. };
  11580. return useEffect(() => {
  11581. let handler = () => setIsAnimating(!0);
  11582. return api.on(FORCE_REMOUNT, handler), () => api.off?.(FORCE_REMOUNT, handler);
  11583. }, [api]), react_default.createElement(
  11584. StyledAnimatedButton,
  11585. {
  11586. key: "remount",
  11587. padding: "small",
  11588. variant: "ghost",
  11589. ariaLabel: "Reload story",
  11590. onClick: remountComponent,
  11591. onAnimationEnd: () => setIsAnimating(!1),
  11592. animating: isAnimating,
  11593. disabled: !storyId
  11594. },
  11595. react_default.createElement(SyncIcon, null)
  11596. );
  11597. })
  11598. };
  11599. // src/manager/components/preview/tools/share.tsx
  11600. init_react();
  11601. // ../../node_modules/qrcode.react/lib/esm/index.js
  11602. init_react();
  11603. var __defProp2 = Object.defineProperty, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp2 = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a2, b2) => {
  11604. for (var prop in b2 || (b2 = {}))
  11605. __hasOwnProp2.call(b2, prop) && __defNormalProp(a2, prop, b2[prop]);
  11606. if (__getOwnPropSymbols)
  11607. for (var prop of __getOwnPropSymbols(b2))
  11608. __propIsEnum.call(b2, prop) && __defNormalProp(a2, prop, b2[prop]);
  11609. return a2;
  11610. }, __objRest = (source, exclude) => {
  11611. var target = {};
  11612. for (var prop in source)
  11613. __hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
  11614. if (source != null && __getOwnPropSymbols)
  11615. for (var prop of __getOwnPropSymbols(source))
  11616. exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop) && (target[prop] = source[prop]);
  11617. return target;
  11618. };
  11619. var qrcodegen;
  11620. ((qrcodegen2) => {
  11621. let _QrCode = class _QrCode2 {
  11622. /*-- Constructor (low level) and fields --*/
  11623. // Creates a new QR Code with the given version number,
  11624. // error correction level, data codeword bytes, and mask number.
  11625. // This is a low-level API that most users should not use directly.
  11626. // A mid-level API is the encodeSegments() function.
  11627. constructor(version3, errorCorrectionLevel, dataCodewords, msk) {
  11628. if (this.version = version3, this.errorCorrectionLevel = errorCorrectionLevel, this.modules = [], this.isFunction = [], version3 < _QrCode2.MIN_VERSION || version3 > _QrCode2.MAX_VERSION)
  11629. throw new RangeError("Version value out of range");
  11630. if (msk < -1 || msk > 7)
  11631. throw new RangeError("Mask value out of range");
  11632. this.size = version3 * 4 + 17;
  11633. let row = [];
  11634. for (let i2 = 0; i2 < this.size; i2++)
  11635. row.push(!1);
  11636. for (let i2 = 0; i2 < this.size; i2++)
  11637. this.modules.push(row.slice()), this.isFunction.push(row.slice());
  11638. this.drawFunctionPatterns();
  11639. let allCodewords = this.addEccAndInterleave(dataCodewords);
  11640. if (this.drawCodewords(allCodewords), msk == -1) {
  11641. let minPenalty = 1e9;
  11642. for (let i2 = 0; i2 < 8; i2++) {
  11643. this.applyMask(i2), this.drawFormatBits(i2);
  11644. let penalty = this.getPenaltyScore();
  11645. penalty < minPenalty && (msk = i2, minPenalty = penalty), this.applyMask(i2);
  11646. }
  11647. }
  11648. assert(0 <= msk && msk <= 7), this.mask = msk, this.applyMask(msk), this.drawFormatBits(msk), this.isFunction = [];
  11649. }
  11650. /*-- Static factory functions (high level) --*/
  11651. // Returns a QR Code representing the given Unicode text string at the given error correction level.
  11652. // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
  11653. // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
  11654. // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
  11655. // ecl argument if it can be done without increasing the version.
  11656. static encodeText(text, ecl) {
  11657. let segs = qrcodegen2.QrSegment.makeSegments(text);
  11658. return _QrCode2.encodeSegments(segs, ecl);
  11659. }
  11660. // Returns a QR Code representing the given binary data at the given error correction level.
  11661. // This function always encodes using the binary segment mode, not any text mode. The maximum number of
  11662. // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
  11663. // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
  11664. static encodeBinary(data, ecl) {
  11665. let seg = qrcodegen2.QrSegment.makeBytes(data);
  11666. return _QrCode2.encodeSegments([seg], ecl);
  11667. }
  11668. /*-- Static factory functions (mid level) --*/
  11669. // Returns a QR Code representing the given segments with the given encoding parameters.
  11670. // The smallest possible QR Code version within the given range is automatically
  11671. // chosen for the output. Iff boostEcl is true, then the ECC level of the result
  11672. // may be higher than the ecl argument if it can be done without increasing the
  11673. // version. The mask number is either between 0 to 7 (inclusive) to force that
  11674. // mask, or -1 to automatically choose an appropriate mask (which may be slow).
  11675. // This function allows the user to create a custom sequence of segments that switches
  11676. // between modes (such as alphanumeric and byte) to encode text in less space.
  11677. // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
  11678. static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = !0) {
  11679. if (!(_QrCode2.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode2.MAX_VERSION) || mask < -1 || mask > 7)
  11680. throw new RangeError("Invalid value");
  11681. let version3, dataUsedBits;
  11682. for (version3 = minVersion; ; version3++) {
  11683. let dataCapacityBits2 = _QrCode2.getNumDataCodewords(version3, ecl) * 8, usedBits = QrSegment.getTotalBits(segs, version3);
  11684. if (usedBits <= dataCapacityBits2) {
  11685. dataUsedBits = usedBits;
  11686. break;
  11687. }
  11688. if (version3 >= maxVersion)
  11689. throw new RangeError("Data too long");
  11690. }
  11691. for (let newEcl of [_QrCode2.Ecc.MEDIUM, _QrCode2.Ecc.QUARTILE, _QrCode2.Ecc.HIGH])
  11692. boostEcl && dataUsedBits <= _QrCode2.getNumDataCodewords(version3, newEcl) * 8 && (ecl = newEcl);
  11693. let bb = [];
  11694. for (let seg of segs) {
  11695. appendBits(seg.mode.modeBits, 4, bb), appendBits(seg.numChars, seg.mode.numCharCountBits(version3), bb);
  11696. for (let b2 of seg.getData())
  11697. bb.push(b2);
  11698. }
  11699. assert(bb.length == dataUsedBits);
  11700. let dataCapacityBits = _QrCode2.getNumDataCodewords(version3, ecl) * 8;
  11701. assert(bb.length <= dataCapacityBits), appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb), appendBits(0, (8 - bb.length % 8) % 8, bb), assert(bb.length % 8 == 0);
  11702. for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 253)
  11703. appendBits(padByte, 8, bb);
  11704. let dataCodewords = [];
  11705. for (; dataCodewords.length * 8 < bb.length; )
  11706. dataCodewords.push(0);
  11707. return bb.forEach((b2, i2) => dataCodewords[i2 >>> 3] |= b2 << 7 - (i2 & 7)), new _QrCode2(version3, ecl, dataCodewords, mask);
  11708. }
  11709. /*-- Accessor methods --*/
  11710. // Returns the color of the module (pixel) at the given coordinates, which is false
  11711. // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
  11712. // If the given coordinates are out of bounds, then false (light) is returned.
  11713. getModule(x2, y2) {
  11714. return 0 <= x2 && x2 < this.size && 0 <= y2 && y2 < this.size && this.modules[y2][x2];
  11715. }
  11716. // Modified to expose modules for easy access
  11717. getModules() {
  11718. return this.modules;
  11719. }
  11720. /*-- Private helper methods for constructor: Drawing function modules --*/
  11721. // Reads this object's version field, and draws and marks all function modules.
  11722. drawFunctionPatterns() {
  11723. for (let i2 = 0; i2 < this.size; i2++)
  11724. this.setFunctionModule(6, i2, i2 % 2 == 0), this.setFunctionModule(i2, 6, i2 % 2 == 0);
  11725. this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
  11726. let alignPatPos = this.getAlignmentPatternPositions(), numAlign = alignPatPos.length;
  11727. for (let i2 = 0; i2 < numAlign; i2++)
  11728. for (let j2 = 0; j2 < numAlign; j2++)
  11729. i2 == 0 && j2 == 0 || i2 == 0 && j2 == numAlign - 1 || i2 == numAlign - 1 && j2 == 0 || this.drawAlignmentPattern(alignPatPos[i2], alignPatPos[j2]);
  11730. this.drawFormatBits(0), this.drawVersion();
  11731. }
  11732. // Draws two copies of the format bits (with its own error correction code)
  11733. // based on the given mask and this object's error correction level field.
  11734. drawFormatBits(mask) {
  11735. let data = this.errorCorrectionLevel.formatBits << 3 | mask, rem2 = data;
  11736. for (let i2 = 0; i2 < 10; i2++)
  11737. rem2 = rem2 << 1 ^ (rem2 >>> 9) * 1335;
  11738. let bits = (data << 10 | rem2) ^ 21522;
  11739. assert(bits >>> 15 == 0);
  11740. for (let i2 = 0; i2 <= 5; i2++)
  11741. this.setFunctionModule(8, i2, getBit(bits, i2));
  11742. this.setFunctionModule(8, 7, getBit(bits, 6)), this.setFunctionModule(8, 8, getBit(bits, 7)), this.setFunctionModule(7, 8, getBit(bits, 8));
  11743. for (let i2 = 9; i2 < 15; i2++)
  11744. this.setFunctionModule(14 - i2, 8, getBit(bits, i2));
  11745. for (let i2 = 0; i2 < 8; i2++)
  11746. this.setFunctionModule(this.size - 1 - i2, 8, getBit(bits, i2));
  11747. for (let i2 = 8; i2 < 15; i2++)
  11748. this.setFunctionModule(8, this.size - 15 + i2, getBit(bits, i2));
  11749. this.setFunctionModule(8, this.size - 8, !0);
  11750. }
  11751. // Draws two copies of the version bits (with its own error correction code),
  11752. // based on this object's version field, iff 7 <= version <= 40.
  11753. drawVersion() {
  11754. if (this.version < 7)
  11755. return;
  11756. let rem2 = this.version;
  11757. for (let i2 = 0; i2 < 12; i2++)
  11758. rem2 = rem2 << 1 ^ (rem2 >>> 11) * 7973;
  11759. let bits = this.version << 12 | rem2;
  11760. assert(bits >>> 18 == 0);
  11761. for (let i2 = 0; i2 < 18; i2++) {
  11762. let color2 = getBit(bits, i2), a2 = this.size - 11 + i2 % 3, b2 = Math.floor(i2 / 3);
  11763. this.setFunctionModule(a2, b2, color2), this.setFunctionModule(b2, a2, color2);
  11764. }
  11765. }
  11766. // Draws a 9*9 finder pattern including the border separator,
  11767. // with the center module at (x, y). Modules can be out of bounds.
  11768. drawFinderPattern(x2, y2) {
  11769. for (let dy = -4; dy <= 4; dy++)
  11770. for (let dx = -4; dx <= 4; dx++) {
  11771. let dist = Math.max(Math.abs(dx), Math.abs(dy)), xx = x2 + dx, yy = y2 + dy;
  11772. 0 <= xx && xx < this.size && 0 <= yy && yy < this.size && this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
  11773. }
  11774. }
  11775. // Draws a 5*5 alignment pattern, with the center module
  11776. // at (x, y). All modules must be in bounds.
  11777. drawAlignmentPattern(x2, y2) {
  11778. for (let dy = -2; dy <= 2; dy++)
  11779. for (let dx = -2; dx <= 2; dx++)
  11780. this.setFunctionModule(x2 + dx, y2 + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
  11781. }
  11782. // Sets the color of a module and marks it as a function module.
  11783. // Only used by the constructor. Coordinates must be in bounds.
  11784. setFunctionModule(x2, y2, isDark) {
  11785. this.modules[y2][x2] = isDark, this.isFunction[y2][x2] = !0;
  11786. }
  11787. /*-- Private helper methods for constructor: Codewords and masking --*/
  11788. // Returns a new byte string representing the given data with the appropriate error correction
  11789. // codewords appended to it, based on this object's version and error correction level.
  11790. addEccAndInterleave(data) {
  11791. let ver = this.version, ecl = this.errorCorrectionLevel;
  11792. if (data.length != _QrCode2.getNumDataCodewords(ver, ecl))
  11793. throw new RangeError("Invalid argument");
  11794. let numBlocks = _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver], blockEccLen = _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver], rawCodewords = Math.floor(_QrCode2.getNumRawDataModules(ver) / 8), numShortBlocks = numBlocks - rawCodewords % numBlocks, shortBlockLen = Math.floor(rawCodewords / numBlocks), blocks = [], rsDiv = _QrCode2.reedSolomonComputeDivisor(blockEccLen);
  11795. for (let i2 = 0, k2 = 0; i2 < numBlocks; i2++) {
  11796. let dat = data.slice(k2, k2 + shortBlockLen - blockEccLen + (i2 < numShortBlocks ? 0 : 1));
  11797. k2 += dat.length;
  11798. let ecc = _QrCode2.reedSolomonComputeRemainder(dat, rsDiv);
  11799. i2 < numShortBlocks && dat.push(0), blocks.push(dat.concat(ecc));
  11800. }
  11801. let result = [];
  11802. for (let i2 = 0; i2 < blocks[0].length; i2++)
  11803. blocks.forEach((block, j2) => {
  11804. (i2 != shortBlockLen - blockEccLen || j2 >= numShortBlocks) && result.push(block[i2]);
  11805. });
  11806. return assert(result.length == rawCodewords), result;
  11807. }
  11808. // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
  11809. // data area of this QR Code. Function modules need to be marked off before this is called.
  11810. drawCodewords(data) {
  11811. if (data.length != Math.floor(_QrCode2.getNumRawDataModules(this.version) / 8))
  11812. throw new RangeError("Invalid argument");
  11813. let i2 = 0;
  11814. for (let right = this.size - 1; right >= 1; right -= 2) {
  11815. right == 6 && (right = 5);
  11816. for (let vert = 0; vert < this.size; vert++)
  11817. for (let j2 = 0; j2 < 2; j2++) {
  11818. let x2 = right - j2, y2 = (right + 1 & 2) == 0 ? this.size - 1 - vert : vert;
  11819. !this.isFunction[y2][x2] && i2 < data.length * 8 && (this.modules[y2][x2] = getBit(data[i2 >>> 3], 7 - (i2 & 7)), i2++);
  11820. }
  11821. }
  11822. assert(i2 == data.length * 8);
  11823. }
  11824. // XORs the codeword modules in this QR Code with the given mask pattern.
  11825. // The function modules must be marked and the codeword bits must be drawn
  11826. // before masking. Due to the arithmetic of XOR, calling applyMask() with
  11827. // the same mask value a second time will undo the mask. A final well-formed
  11828. // QR Code needs exactly one (not zero, two, etc.) mask applied.
  11829. applyMask(mask) {
  11830. if (mask < 0 || mask > 7)
  11831. throw new RangeError("Mask value out of range");
  11832. for (let y2 = 0; y2 < this.size; y2++)
  11833. for (let x2 = 0; x2 < this.size; x2++) {
  11834. let invert2;
  11835. switch (mask) {
  11836. case 0:
  11837. invert2 = (x2 + y2) % 2 == 0;
  11838. break;
  11839. case 1:
  11840. invert2 = y2 % 2 == 0;
  11841. break;
  11842. case 2:
  11843. invert2 = x2 % 3 == 0;
  11844. break;
  11845. case 3:
  11846. invert2 = (x2 + y2) % 3 == 0;
  11847. break;
  11848. case 4:
  11849. invert2 = (Math.floor(x2 / 3) + Math.floor(y2 / 2)) % 2 == 0;
  11850. break;
  11851. case 5:
  11852. invert2 = x2 * y2 % 2 + x2 * y2 % 3 == 0;
  11853. break;
  11854. case 6:
  11855. invert2 = (x2 * y2 % 2 + x2 * y2 % 3) % 2 == 0;
  11856. break;
  11857. case 7:
  11858. invert2 = ((x2 + y2) % 2 + x2 * y2 % 3) % 2 == 0;
  11859. break;
  11860. default:
  11861. throw new Error("Unreachable");
  11862. }
  11863. !this.isFunction[y2][x2] && invert2 && (this.modules[y2][x2] = !this.modules[y2][x2]);
  11864. }
  11865. }
  11866. // Calculates and returns the penalty score based on state of this QR Code's current modules.
  11867. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
  11868. getPenaltyScore() {
  11869. let result = 0;
  11870. for (let y2 = 0; y2 < this.size; y2++) {
  11871. let runColor = !1, runX = 0, runHistory = [0, 0, 0, 0, 0, 0, 0];
  11872. for (let x2 = 0; x2 < this.size; x2++)
  11873. this.modules[y2][x2] == runColor ? (runX++, runX == 5 ? result += _QrCode2.PENALTY_N1 : runX > 5 && result++) : (this.finderPenaltyAddHistory(runX, runHistory), runColor || (result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3), runColor = this.modules[y2][x2], runX = 1);
  11874. result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode2.PENALTY_N3;
  11875. }
  11876. for (let x2 = 0; x2 < this.size; x2++) {
  11877. let runColor = !1, runY = 0, runHistory = [0, 0, 0, 0, 0, 0, 0];
  11878. for (let y2 = 0; y2 < this.size; y2++)
  11879. this.modules[y2][x2] == runColor ? (runY++, runY == 5 ? result += _QrCode2.PENALTY_N1 : runY > 5 && result++) : (this.finderPenaltyAddHistory(runY, runHistory), runColor || (result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3), runColor = this.modules[y2][x2], runY = 1);
  11880. result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode2.PENALTY_N3;
  11881. }
  11882. for (let y2 = 0; y2 < this.size - 1; y2++)
  11883. for (let x2 = 0; x2 < this.size - 1; x2++) {
  11884. let color2 = this.modules[y2][x2];
  11885. color2 == this.modules[y2][x2 + 1] && color2 == this.modules[y2 + 1][x2] && color2 == this.modules[y2 + 1][x2 + 1] && (result += _QrCode2.PENALTY_N2);
  11886. }
  11887. let dark = 0;
  11888. for (let row of this.modules)
  11889. dark = row.reduce((sum, color2) => sum + (color2 ? 1 : 0), dark);
  11890. let total = this.size * this.size, k2 = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
  11891. return assert(0 <= k2 && k2 <= 9), result += k2 * _QrCode2.PENALTY_N4, assert(0 <= result && result <= 2568888), result;
  11892. }
  11893. /*-- Private helper functions --*/
  11894. // Returns an ascending list of positions of alignment patterns for this version number.
  11895. // Each position is in the range [0,177), and are used on both the x and y axes.
  11896. // This could be implemented as lookup table of 40 variable-length lists of integers.
  11897. getAlignmentPatternPositions() {
  11898. if (this.version == 1)
  11899. return [];
  11900. {
  11901. let numAlign = Math.floor(this.version / 7) + 2, step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2, result = [6];
  11902. for (let pos = this.size - 7; result.length < numAlign; pos -= step)
  11903. result.splice(1, 0, pos);
  11904. return result;
  11905. }
  11906. }
  11907. // Returns the number of data bits that can be stored in a QR Code of the given version number, after
  11908. // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
  11909. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
  11910. static getNumRawDataModules(ver) {
  11911. if (ver < _QrCode2.MIN_VERSION || ver > _QrCode2.MAX_VERSION)
  11912. throw new RangeError("Version number out of range");
  11913. let result = (16 * ver + 128) * ver + 64;
  11914. if (ver >= 2) {
  11915. let numAlign = Math.floor(ver / 7) + 2;
  11916. result -= (25 * numAlign - 10) * numAlign - 55, ver >= 7 && (result -= 36);
  11917. }
  11918. return assert(208 <= result && result <= 29648), result;
  11919. }
  11920. // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
  11921. // QR Code of the given version number and error correction level, with remainder bits discarded.
  11922. // This stateless pure function could be implemented as a (40*4)-cell lookup table.
  11923. static getNumDataCodewords(ver, ecl) {
  11924. return Math.floor(_QrCode2.getNumRawDataModules(ver) / 8) - _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
  11925. }
  11926. // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
  11927. // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
  11928. static reedSolomonComputeDivisor(degree) {
  11929. if (degree < 1 || degree > 255)
  11930. throw new RangeError("Degree out of range");
  11931. let result = [];
  11932. for (let i2 = 0; i2 < degree - 1; i2++)
  11933. result.push(0);
  11934. result.push(1);
  11935. let root2 = 1;
  11936. for (let i2 = 0; i2 < degree; i2++) {
  11937. for (let j2 = 0; j2 < result.length; j2++)
  11938. result[j2] = _QrCode2.reedSolomonMultiply(result[j2], root2), j2 + 1 < result.length && (result[j2] ^= result[j2 + 1]);
  11939. root2 = _QrCode2.reedSolomonMultiply(root2, 2);
  11940. }
  11941. return result;
  11942. }
  11943. // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
  11944. static reedSolomonComputeRemainder(data, divisor) {
  11945. let result = divisor.map((_2) => 0);
  11946. for (let b2 of data) {
  11947. let factor = b2 ^ result.shift();
  11948. result.push(0), divisor.forEach((coef, i2) => result[i2] ^= _QrCode2.reedSolomonMultiply(coef, factor));
  11949. }
  11950. return result;
  11951. }
  11952. // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
  11953. // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
  11954. static reedSolomonMultiply(x2, y2) {
  11955. if (x2 >>> 8 || y2 >>> 8)
  11956. throw new RangeError("Byte out of range");
  11957. let z2 = 0;
  11958. for (let i2 = 7; i2 >= 0; i2--)
  11959. z2 = z2 << 1 ^ (z2 >>> 7) * 285, z2 ^= (y2 >>> i2 & 1) * x2;
  11960. return assert(z2 >>> 8 == 0), z2;
  11961. }
  11962. // Can only be called immediately after a light run is added, and
  11963. // returns either 0, 1, or 2. A helper function for getPenaltyScore().
  11964. finderPenaltyCountPatterns(runHistory) {
  11965. let n3 = runHistory[1];
  11966. assert(n3 <= this.size * 3);
  11967. let core = n3 > 0 && runHistory[2] == n3 && runHistory[3] == n3 * 3 && runHistory[4] == n3 && runHistory[5] == n3;
  11968. return (core && runHistory[0] >= n3 * 4 && runHistory[6] >= n3 ? 1 : 0) + (core && runHistory[6] >= n3 * 4 && runHistory[0] >= n3 ? 1 : 0);
  11969. }
  11970. // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
  11971. finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
  11972. return currentRunColor && (this.finderPenaltyAddHistory(currentRunLength, runHistory), currentRunLength = 0), currentRunLength += this.size, this.finderPenaltyAddHistory(currentRunLength, runHistory), this.finderPenaltyCountPatterns(runHistory);
  11973. }
  11974. // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
  11975. finderPenaltyAddHistory(currentRunLength, runHistory) {
  11976. runHistory[0] == 0 && (currentRunLength += this.size), runHistory.pop(), runHistory.unshift(currentRunLength);
  11977. }
  11978. };
  11979. _QrCode.MIN_VERSION = 1, _QrCode.MAX_VERSION = 40, _QrCode.PENALTY_N1 = 3, _QrCode.PENALTY_N2 = 3, _QrCode.PENALTY_N3 = 40, _QrCode.PENALTY_N4 = 10, _QrCode.ECC_CODEWORDS_PER_BLOCK = [
  11980. // Version: (note that index 0 is for padding, and is set to an illegal value)
  11981. //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
  11982. [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
  11983. // Low
  11984. [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
  11985. // Medium
  11986. [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
  11987. // Quartile
  11988. [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
  11989. // High
  11990. ], _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
  11991. // Version: (note that index 0 is for padding, and is set to an illegal value)
  11992. //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
  11993. [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
  11994. // Low
  11995. [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
  11996. // Medium
  11997. [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
  11998. // Quartile
  11999. [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
  12000. // High
  12001. ];
  12002. let QrCode = _QrCode;
  12003. qrcodegen2.QrCode = _QrCode;
  12004. function appendBits(val, len, bb) {
  12005. if (len < 0 || len > 31 || val >>> len)
  12006. throw new RangeError("Value out of range");
  12007. for (let i2 = len - 1; i2 >= 0; i2--)
  12008. bb.push(val >>> i2 & 1);
  12009. }
  12010. function getBit(x2, i2) {
  12011. return (x2 >>> i2 & 1) != 0;
  12012. }
  12013. function assert(cond) {
  12014. if (!cond)
  12015. throw new Error("Assertion error");
  12016. }
  12017. let _QrSegment = class _QrSegment2 {
  12018. /*-- Constructor (low level) and fields --*/
  12019. // Creates a new QR Code segment with the given attributes and data.
  12020. // The character count (numChars) must agree with the mode and the bit buffer length,
  12021. // but the constraint isn't checked. The given bit buffer is cloned and stored.
  12022. constructor(mode, numChars, bitData) {
  12023. if (this.mode = mode, this.numChars = numChars, this.bitData = bitData, numChars < 0)
  12024. throw new RangeError("Invalid argument");
  12025. this.bitData = bitData.slice();
  12026. }
  12027. /*-- Static factory functions (mid level) --*/
  12028. // Returns a segment representing the given binary data encoded in
  12029. // byte mode. All input byte arrays are acceptable. Any text string
  12030. // can be converted to UTF-8 bytes and encoded as a byte mode segment.
  12031. static makeBytes(data) {
  12032. let bb = [];
  12033. for (let b2 of data)
  12034. appendBits(b2, 8, bb);
  12035. return new _QrSegment2(_QrSegment2.Mode.BYTE, data.length, bb);
  12036. }
  12037. // Returns a segment representing the given string of decimal digits encoded in numeric mode.
  12038. static makeNumeric(digits) {
  12039. if (!_QrSegment2.isNumeric(digits))
  12040. throw new RangeError("String contains non-numeric characters");
  12041. let bb = [];
  12042. for (let i2 = 0; i2 < digits.length; ) {
  12043. let n3 = Math.min(digits.length - i2, 3);
  12044. appendBits(parseInt(digits.substring(i2, i2 + n3), 10), n3 * 3 + 1, bb), i2 += n3;
  12045. }
  12046. return new _QrSegment2(_QrSegment2.Mode.NUMERIC, digits.length, bb);
  12047. }
  12048. // Returns a segment representing the given text string encoded in alphanumeric mode.
  12049. // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
  12050. // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
  12051. static makeAlphanumeric(text) {
  12052. if (!_QrSegment2.isAlphanumeric(text))
  12053. throw new RangeError("String contains unencodable characters in alphanumeric mode");
  12054. let bb = [], i2;
  12055. for (i2 = 0; i2 + 2 <= text.length; i2 += 2) {
  12056. let temp = _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i2)) * 45;
  12057. temp += _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i2 + 1)), appendBits(temp, 11, bb);
  12058. }
  12059. return i2 < text.length && appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i2)), 6, bb), new _QrSegment2(_QrSegment2.Mode.ALPHANUMERIC, text.length, bb);
  12060. }
  12061. // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
  12062. // The result may use various segment modes and switch modes to optimize the length of the bit stream.
  12063. static makeSegments(text) {
  12064. return text == "" ? [] : _QrSegment2.isNumeric(text) ? [_QrSegment2.makeNumeric(text)] : _QrSegment2.isAlphanumeric(text) ? [_QrSegment2.makeAlphanumeric(text)] : [_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))];
  12065. }
  12066. // Returns a segment representing an Extended Channel Interpretation
  12067. // (ECI) designator with the given assignment value.
  12068. static makeEci(assignVal) {
  12069. let bb = [];
  12070. if (assignVal < 0)
  12071. throw new RangeError("ECI assignment value out of range");
  12072. if (assignVal < 128)
  12073. appendBits(assignVal, 8, bb);
  12074. else if (assignVal < 16384)
  12075. appendBits(2, 2, bb), appendBits(assignVal, 14, bb);
  12076. else if (assignVal < 1e6)
  12077. appendBits(6, 3, bb), appendBits(assignVal, 21, bb);
  12078. else
  12079. throw new RangeError("ECI assignment value out of range");
  12080. return new _QrSegment2(_QrSegment2.Mode.ECI, 0, bb);
  12081. }
  12082. // Tests whether the given string can be encoded as a segment in numeric mode.
  12083. // A string is encodable iff each character is in the range 0 to 9.
  12084. static isNumeric(text) {
  12085. return _QrSegment2.NUMERIC_REGEX.test(text);
  12086. }
  12087. // Tests whether the given string can be encoded as a segment in alphanumeric mode.
  12088. // A string is encodable iff each character is in the following set: 0 to 9, A to Z
  12089. // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
  12090. static isAlphanumeric(text) {
  12091. return _QrSegment2.ALPHANUMERIC_REGEX.test(text);
  12092. }
  12093. /*-- Methods --*/
  12094. // Returns a new copy of the data bits of this segment.
  12095. getData() {
  12096. return this.bitData.slice();
  12097. }
  12098. // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
  12099. // the given version. The result is infinity if a segment has too many characters to fit its length field.
  12100. static getTotalBits(segs, version3) {
  12101. let result = 0;
  12102. for (let seg of segs) {
  12103. let ccbits = seg.mode.numCharCountBits(version3);
  12104. if (seg.numChars >= 1 << ccbits)
  12105. return 1 / 0;
  12106. result += 4 + ccbits + seg.bitData.length;
  12107. }
  12108. return result;
  12109. }
  12110. // Returns a new array of bytes representing the given string encoded in UTF-8.
  12111. static toUtf8ByteArray(str) {
  12112. str = encodeURI(str);
  12113. let result = [];
  12114. for (let i2 = 0; i2 < str.length; i2++)
  12115. str.charAt(i2) != "%" ? result.push(str.charCodeAt(i2)) : (result.push(parseInt(str.substring(i2 + 1, i2 + 3), 16)), i2 += 2);
  12116. return result;
  12117. }
  12118. };
  12119. _QrSegment.NUMERIC_REGEX = /^[0-9]*$/, _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, _QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
  12120. let QrSegment = _QrSegment;
  12121. qrcodegen2.QrSegment = _QrSegment;
  12122. })(qrcodegen || (qrcodegen = {}));
  12123. ((qrcodegen2) => {
  12124. let QrCode;
  12125. ((QrCode2) => {
  12126. let _Ecc = class {
  12127. // The QR Code can tolerate about 30% erroneous codewords
  12128. /*-- Constructor and fields --*/
  12129. constructor(ordinal, formatBits) {
  12130. this.ordinal = ordinal, this.formatBits = formatBits;
  12131. }
  12132. };
  12133. _Ecc.LOW = new _Ecc(0, 1), _Ecc.MEDIUM = new _Ecc(1, 0), _Ecc.QUARTILE = new _Ecc(2, 3), _Ecc.HIGH = new _Ecc(3, 2);
  12134. let Ecc = _Ecc;
  12135. QrCode2.Ecc = _Ecc;
  12136. })(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
  12137. })(qrcodegen || (qrcodegen = {}));
  12138. ((qrcodegen2) => {
  12139. let QrSegment;
  12140. ((QrSegment2) => {
  12141. let _Mode = class {
  12142. /*-- Constructor and fields --*/
  12143. constructor(modeBits, numBitsCharCount) {
  12144. this.modeBits = modeBits, this.numBitsCharCount = numBitsCharCount;
  12145. }
  12146. /*-- Method --*/
  12147. // (Package-private) Returns the bit width of the character count field for a segment in
  12148. // this mode in a QR Code at the given version number. The result is in the range [0, 16].
  12149. numCharCountBits(ver) {
  12150. return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
  12151. }
  12152. };
  12153. _Mode.NUMERIC = new _Mode(1, [10, 12, 14]), _Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]), _Mode.BYTE = new _Mode(4, [8, 16, 16]), _Mode.KANJI = new _Mode(8, [8, 10, 12]), _Mode.ECI = new _Mode(7, [0, 0, 0]);
  12154. let Mode = _Mode;
  12155. QrSegment2.Mode = _Mode;
  12156. })(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
  12157. })(qrcodegen || (qrcodegen = {}));
  12158. var qrcodegen_default = qrcodegen;
  12159. var ERROR_LEVEL_MAP = {
  12160. L: qrcodegen_default.QrCode.Ecc.LOW,
  12161. M: qrcodegen_default.QrCode.Ecc.MEDIUM,
  12162. Q: qrcodegen_default.QrCode.Ecc.QUARTILE,
  12163. H: qrcodegen_default.QrCode.Ecc.HIGH
  12164. }, DEFAULT_SIZE = 128, DEFAULT_LEVEL = "L", DEFAULT_BGCOLOR = "#FFFFFF", DEFAULT_FGCOLOR = "#000000", DEFAULT_INCLUDEMARGIN = !1, DEFAULT_MINVERSION = 1, SPEC_MARGIN_SIZE = 4, DEFAULT_MARGIN_SIZE = 0, DEFAULT_IMG_SCALE = 0.1;
  12165. function generatePath(modules, margin = 0) {
  12166. let ops = [];
  12167. return modules.forEach(function(row, y2) {
  12168. let start = null;
  12169. row.forEach(function(cell, x2) {
  12170. if (!cell && start !== null) {
  12171. ops.push(
  12172. `M${start + margin} ${y2 + margin}h${x2 - start}v1H${start + margin}z`
  12173. ), start = null;
  12174. return;
  12175. }
  12176. if (x2 === row.length - 1) {
  12177. if (!cell)
  12178. return;
  12179. start === null ? ops.push(`M${x2 + margin},${y2 + margin} h1v1H${x2 + margin}z`) : ops.push(
  12180. `M${start + margin},${y2 + margin} h${x2 + 1 - start}v1H${start + margin}z`
  12181. );
  12182. return;
  12183. }
  12184. cell && start === null && (start = x2);
  12185. });
  12186. }), ops.join("");
  12187. }
  12188. function excavateModules(modules, excavation) {
  12189. return modules.slice().map((row, y2) => y2 < excavation.y || y2 >= excavation.y + excavation.h ? row : row.map((cell, x2) => x2 < excavation.x || x2 >= excavation.x + excavation.w ? cell : !1));
  12190. }
  12191. function getImageSettings(cells, size, margin, imageSettings) {
  12192. if (imageSettings == null)
  12193. return null;
  12194. let numCells = cells.length + margin * 2, defaultSize = Math.floor(size * DEFAULT_IMG_SCALE), scale = numCells / size, w2 = (imageSettings.width || defaultSize) * scale, h2 = (imageSettings.height || defaultSize) * scale, x2 = imageSettings.x == null ? cells.length / 2 - w2 / 2 : imageSettings.x * scale, y2 = imageSettings.y == null ? cells.length / 2 - h2 / 2 : imageSettings.y * scale, opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity, excavation = null;
  12195. if (imageSettings.excavate) {
  12196. let floorX = Math.floor(x2), floorY = Math.floor(y2), ceilW = Math.ceil(w2 + x2 - floorX), ceilH = Math.ceil(h2 + y2 - floorY);
  12197. excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
  12198. }
  12199. let crossOrigin = imageSettings.crossOrigin;
  12200. return { x: x2, y: y2, h: h2, w: w2, excavation, opacity, crossOrigin };
  12201. }
  12202. function getMarginSize(includeMargin, marginSize) {
  12203. return marginSize != null ? Math.max(Math.floor(marginSize), 0) : includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
  12204. }
  12205. function useQRCode({
  12206. value,
  12207. level,
  12208. minVersion,
  12209. includeMargin,
  12210. marginSize,
  12211. imageSettings,
  12212. size,
  12213. boostLevel
  12214. }) {
  12215. let qrcode = react_default.useMemo(() => {
  12216. let segments = (Array.isArray(value) ? value : [value]).reduce((accum, v2) => (accum.push(...qrcodegen_default.QrSegment.makeSegments(v2)), accum), []);
  12217. return qrcodegen_default.QrCode.encodeSegments(
  12218. segments,
  12219. ERROR_LEVEL_MAP[level],
  12220. minVersion,
  12221. void 0,
  12222. void 0,
  12223. boostLevel
  12224. );
  12225. }, [value, level, minVersion, boostLevel]), { cells, margin, numCells, calculatedImageSettings } = react_default.useMemo(() => {
  12226. let cells2 = qrcode.getModules(), margin2 = getMarginSize(includeMargin, marginSize), numCells2 = cells2.length + margin2 * 2, calculatedImageSettings2 = getImageSettings(
  12227. cells2,
  12228. size,
  12229. margin2,
  12230. imageSettings
  12231. );
  12232. return {
  12233. cells: cells2,
  12234. margin: margin2,
  12235. numCells: numCells2,
  12236. calculatedImageSettings: calculatedImageSettings2
  12237. };
  12238. }, [qrcode, size, imageSettings, includeMargin, marginSize]);
  12239. return {
  12240. qrcode,
  12241. margin,
  12242. cells,
  12243. numCells,
  12244. calculatedImageSettings
  12245. };
  12246. }
  12247. var SUPPORTS_PATH2D = (function() {
  12248. try {
  12249. new Path2D().addPath(new Path2D());
  12250. } catch {
  12251. return !1;
  12252. }
  12253. return !0;
  12254. })(), QRCodeCanvas = react_default.forwardRef(
  12255. function(props, forwardedRef) {
  12256. let _a2 = props, {
  12257. value,
  12258. size = DEFAULT_SIZE,
  12259. level = DEFAULT_LEVEL,
  12260. bgColor = DEFAULT_BGCOLOR,
  12261. fgColor = DEFAULT_FGCOLOR,
  12262. includeMargin = DEFAULT_INCLUDEMARGIN,
  12263. minVersion = DEFAULT_MINVERSION,
  12264. boostLevel,
  12265. marginSize,
  12266. imageSettings
  12267. } = _a2, _b = __objRest(_a2, [
  12268. "value",
  12269. "size",
  12270. "level",
  12271. "bgColor",
  12272. "fgColor",
  12273. "includeMargin",
  12274. "minVersion",
  12275. "boostLevel",
  12276. "marginSize",
  12277. "imageSettings"
  12278. ]), { style } = _b, otherProps = __objRest(_b, ["style"]), imgSrc = imageSettings?.src, _canvas = react_default.useRef(null), _image = react_default.useRef(null), setCanvasRef = react_default.useCallback(
  12279. (node) => {
  12280. _canvas.current = node, typeof forwardedRef == "function" ? forwardedRef(node) : forwardedRef && (forwardedRef.current = node);
  12281. },
  12282. [forwardedRef]
  12283. ), [isImgLoaded, setIsImageLoaded] = react_default.useState(!1), { margin, cells, numCells, calculatedImageSettings } = useQRCode({
  12284. value,
  12285. level,
  12286. minVersion,
  12287. boostLevel,
  12288. includeMargin,
  12289. marginSize,
  12290. imageSettings,
  12291. size
  12292. });
  12293. react_default.useEffect(() => {
  12294. if (_canvas.current != null) {
  12295. let canvas = _canvas.current, ctx = canvas.getContext("2d");
  12296. if (!ctx)
  12297. return;
  12298. let cellsToDraw = cells, image = _image.current, haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
  12299. haveImageToRender && calculatedImageSettings.excavation != null && (cellsToDraw = excavateModules(
  12300. cells,
  12301. calculatedImageSettings.excavation
  12302. ));
  12303. let pixelRatio = window.devicePixelRatio || 1;
  12304. canvas.height = canvas.width = size * pixelRatio;
  12305. let scale = size / numCells * pixelRatio;
  12306. ctx.scale(scale, scale), ctx.fillStyle = bgColor, ctx.fillRect(0, 0, numCells, numCells), ctx.fillStyle = fgColor, SUPPORTS_PATH2D ? ctx.fill(new Path2D(generatePath(cellsToDraw, margin))) : cells.forEach(function(row, rdx) {
  12307. row.forEach(function(cell, cdx) {
  12308. cell && ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
  12309. });
  12310. }), calculatedImageSettings && (ctx.globalAlpha = calculatedImageSettings.opacity), haveImageToRender && ctx.drawImage(
  12311. image,
  12312. calculatedImageSettings.x + margin,
  12313. calculatedImageSettings.y + margin,
  12314. calculatedImageSettings.w,
  12315. calculatedImageSettings.h
  12316. );
  12317. }
  12318. }), react_default.useEffect(() => {
  12319. setIsImageLoaded(!1);
  12320. }, [imgSrc]);
  12321. let canvasStyle = __spreadValues({ height: size, width: size }, style), img = null;
  12322. return imgSrc != null && (img = react_default.createElement(
  12323. "img",
  12324. {
  12325. src: imgSrc,
  12326. key: imgSrc,
  12327. style: { display: "none" },
  12328. onLoad: () => {
  12329. setIsImageLoaded(!0);
  12330. },
  12331. ref: _image,
  12332. crossOrigin: calculatedImageSettings?.crossOrigin
  12333. }
  12334. )), react_default.createElement(react_default.Fragment, null, react_default.createElement(
  12335. "canvas",
  12336. __spreadValues({
  12337. style: canvasStyle,
  12338. height: size,
  12339. width: size,
  12340. ref: setCanvasRef,
  12341. role: "img"
  12342. }, otherProps)
  12343. ), img);
  12344. }
  12345. );
  12346. QRCodeCanvas.displayName = "QRCodeCanvas";
  12347. var QRCodeSVG = react_default.forwardRef(
  12348. function(props, forwardedRef) {
  12349. let _a2 = props, {
  12350. value,
  12351. size = DEFAULT_SIZE,
  12352. level = DEFAULT_LEVEL,
  12353. bgColor = DEFAULT_BGCOLOR,
  12354. fgColor = DEFAULT_FGCOLOR,
  12355. includeMargin = DEFAULT_INCLUDEMARGIN,
  12356. minVersion = DEFAULT_MINVERSION,
  12357. boostLevel,
  12358. title: title2,
  12359. marginSize,
  12360. imageSettings
  12361. } = _a2, otherProps = __objRest(_a2, [
  12362. "value",
  12363. "size",
  12364. "level",
  12365. "bgColor",
  12366. "fgColor",
  12367. "includeMargin",
  12368. "minVersion",
  12369. "boostLevel",
  12370. "title",
  12371. "marginSize",
  12372. "imageSettings"
  12373. ]), { margin, cells, numCells, calculatedImageSettings } = useQRCode({
  12374. value,
  12375. level,
  12376. minVersion,
  12377. boostLevel,
  12378. includeMargin,
  12379. marginSize,
  12380. imageSettings,
  12381. size
  12382. }), cellsToDraw = cells, image = null;
  12383. imageSettings != null && calculatedImageSettings != null && (calculatedImageSettings.excavation != null && (cellsToDraw = excavateModules(
  12384. cells,
  12385. calculatedImageSettings.excavation
  12386. )), image = react_default.createElement(
  12387. "image",
  12388. {
  12389. href: imageSettings.src,
  12390. height: calculatedImageSettings.h,
  12391. width: calculatedImageSettings.w,
  12392. x: calculatedImageSettings.x + margin,
  12393. y: calculatedImageSettings.y + margin,
  12394. preserveAspectRatio: "none",
  12395. opacity: calculatedImageSettings.opacity,
  12396. crossOrigin: calculatedImageSettings.crossOrigin
  12397. }
  12398. ));
  12399. let fgPath = generatePath(cellsToDraw, margin);
  12400. return react_default.createElement(
  12401. "svg",
  12402. __spreadValues({
  12403. height: size,
  12404. width: size,
  12405. viewBox: `0 0 ${numCells} ${numCells}`,
  12406. ref: forwardedRef,
  12407. role: "img"
  12408. }, otherProps),
  12409. !!title2 && react_default.createElement("title", null, title2),
  12410. react_default.createElement(
  12411. "path",
  12412. {
  12413. fill: bgColor,
  12414. d: `M0,0 h${numCells}v${numCells}H0z`,
  12415. shapeRendering: "crispEdges"
  12416. }
  12417. ),
  12418. react_default.createElement("path", { fill: fgColor, d: fgPath, shapeRendering: "crispEdges" }),
  12419. image
  12420. );
  12421. }
  12422. );
  12423. QRCodeSVG.displayName = "QRCodeSVG";
  12424. // src/manager/components/preview/tools/share.tsx
  12425. var mapper3 = ({ api, state }) => {
  12426. let { storyId, refId } = state;
  12427. return { api, refId, storyId };
  12428. }, QRContainer = styled.div(
  12429. () => ({
  12430. display: "flex",
  12431. flexDirection: "column",
  12432. padding: 8,
  12433. width: 300,
  12434. maxWidth: 300,
  12435. gap: 8
  12436. })
  12437. ), QRRow = styled.div(() => ({
  12438. display: "flex",
  12439. alignItems: "center"
  12440. })), ShareLinkInput = styled.input(({ theme }) => ({
  12441. width: "100%",
  12442. border: `1px solid ${theme.appBorderColor}`,
  12443. borderRadius: 4,
  12444. padding: "6px 8px",
  12445. fontSize: theme.typography.size.s1,
  12446. color: theme.color.defaultText,
  12447. backgroundColor: theme.background.app,
  12448. outline: "none",
  12449. textOverflow: "ellipsis",
  12450. overflow: "hidden",
  12451. whiteSpace: "nowrap",
  12452. "&:focus": {
  12453. borderColor: theme.color.secondary
  12454. }
  12455. })), QRImageContainer = styled.div(() => ({
  12456. width: 64,
  12457. height: 64,
  12458. marginRight: 12,
  12459. backgroundColor: "white",
  12460. padding: 2
  12461. }));
  12462. var QRContent = styled.div(() => ({})), QRTitle = styled.div(({ theme }) => ({
  12463. fontWeight: theme.typography.weight.bold,
  12464. fontSize: theme.typography.size.s1,
  12465. marginBottom: 4
  12466. })), QRDescription = styled.div(({ theme }) => ({
  12467. fontSize: theme.typography.size.s1,
  12468. color: theme.textMutedColor
  12469. })), isolationModeTool = {
  12470. title: "isolation mode",
  12471. id: "isolationMode",
  12472. type: types.TOOLEXTRA,
  12473. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  12474. render: () => react_default.createElement(Consumer, { filter: mapper3 }, ({ api, storyId, refId }) => {
  12475. if (!storyId) return null;
  12476. let originHrefs = api.getStoryHrefs(storyId, { base: "origin", refId });
  12477. return react_default.createElement(
  12478. Button,
  12479. {
  12480. padding: "small",
  12481. variant: "ghost",
  12482. ariaLabel: "Open in isolation mode",
  12483. tooltip: "Open in isolation mode",
  12484. onClick: () => {
  12485. window.open(originHrefs.previewHref, "_blank", "noopener,noreferrer"), api.emit(SHARE_ISOLATE_MODE, originHrefs.previewHref);
  12486. }
  12487. },
  12488. react_default.createElement(PopOutIcon, null)
  12489. );
  12490. })
  12491. };
  12492. // src/manager/container/Preview.tsx
  12493. var defaultTabs = [createCanvasTab()], defaultTools = [menuTool, remountTool], defaultToolsExtra = [
  12494. isolationModeTool,
  12495. zoomTool,
  12496. addonsTool,
  12497. fullScreenTool,
  12498. openInEditorTool
  12499. ], emptyTabsList = [], memoizedTabs = (0, import_memoizerific2.default)(1)(
  12500. (_2, tabElements, parameters, showTabs) => showTabs ? filterTabs([...defaultTabs, ...Object.values(tabElements)], parameters) : emptyTabsList
  12501. ), memoizedTools = (0, import_memoizerific2.default)(1)(
  12502. (_2, toolElements, filterProps) => filterToolsSide([...defaultTools, ...Object.values(toolElements)], ...filterProps)
  12503. ), memoizedExtra = (0, import_memoizerific2.default)(1)(
  12504. (_2, extraElements, filterProps) => filterToolsSide([...defaultToolsExtra, ...Object.values(extraElements)], ...filterProps)
  12505. ), memoizedWrapper = (0, import_memoizerific2.default)(1)((_2, previewElements) => [
  12506. ...defaultWrappers,
  12507. ...Object.values(previewElements)
  12508. ]), { PREVIEW_URL } = scope, splitTitleAddExtraSpace = (input) => input.split("/").join(" / ").replace(/\s\s/, " "), getDescription = (item) => {
  12509. if (item?.type === "story" || item?.type === "docs") {
  12510. let { title: title2, name } = item;
  12511. return title2 && name ? splitTitleAddExtraSpace(`${title2} - ${name} \u22C5 Storybook`) : "Storybook";
  12512. }
  12513. return item?.name ? `${item.name} \u22C5 Storybook` : "Storybook";
  12514. }, mapper4 = ({
  12515. api,
  12516. state
  12517. // @ts-expect-error (non strict)
  12518. }) => {
  12519. let { layout, location: location2, customQueryParams, storyId, refs, viewMode, path, refId } = state, entry = api.getData(storyId, refId), tabsList = Object.values(api.getElements(Addon_TypesEnum.TAB)), wrapperList = Object.values(api.getElements(Addon_TypesEnum.PREVIEW)), toolsList = Object.values(api.getElements(Addon_TypesEnum.TOOL)), toolsExtraList = Object.values(api.getElements(Addon_TypesEnum.TOOLEXTRA)), tabId = api.getQueryParam("tab"), tools = memoizedTools(toolsList.length, api.getElements(Addon_TypesEnum.TOOL), [
  12520. entry,
  12521. viewMode,
  12522. location2,
  12523. path,
  12524. // @ts-expect-error (non strict)
  12525. tabId
  12526. ]), toolsExtra = memoizedExtra(
  12527. toolsExtraList.length,
  12528. api.getElements(Addon_TypesEnum.TOOLEXTRA),
  12529. // @ts-expect-error (non strict)
  12530. [entry, viewMode, location2, path, tabId]
  12531. );
  12532. return {
  12533. api,
  12534. entry,
  12535. options: layout,
  12536. description: getDescription(entry),
  12537. viewMode,
  12538. refs,
  12539. storyId,
  12540. baseUrl: PREVIEW_URL || "iframe.html",
  12541. queryParams: customQueryParams,
  12542. tools,
  12543. toolsExtra,
  12544. tabs: memoizedTabs(
  12545. tabsList.length,
  12546. api.getElements(Addon_TypesEnum.TAB),
  12547. entry ? entry.parameters : void 0,
  12548. layout.showTabs
  12549. ),
  12550. wrappers: memoizedWrapper(
  12551. wrapperList.length,
  12552. api.getElements(Addon_TypesEnum.PREVIEW)
  12553. ),
  12554. tabId
  12555. };
  12556. }, PreviewConnected = react_default.memo(function(props) {
  12557. return react_default.createElement(Consumer, { filter: mapper4 }, (fromState) => react_default.createElement(Preview, { ...props, ...fromState }));
  12558. }), Preview_default = PreviewConnected;
  12559. // src/manager/container/Sidebar.tsx
  12560. init_react();
  12561. // src/manager/components/sidebar/Sidebar.tsx
  12562. init_react();
  12563. // src/manager/components/sidebar/ChecklistWidget.tsx
  12564. init_react();
  12565. // src/manager/components/Optional/Optional.tsx
  12566. init_react();
  12567. var Wrapper3 = styled.div({
  12568. display: "inline-grid",
  12569. gridTemplateColumns: "max-content",
  12570. overflow: "hidden"
  12571. }), Content2 = styled.div(({ isHidden }) => ({
  12572. display: "inline-block",
  12573. gridArea: "1/1",
  12574. opacity: isHidden === null ? 0 : 1,
  12575. visibility: isHidden ? "hidden" : "visible"
  12576. })), Optional = ({
  12577. content,
  12578. fallback
  12579. }) => {
  12580. let contentRef = useRef(null), wrapperRef = useRef(null), [hidden, setHidden] = useState(null), contentWidth = useRef(contentRef.current?.offsetWidth ?? 0), wrapperWidth = useRef(wrapperRef.current?.offsetWidth ?? 0);
  12581. return useEffect(() => {
  12582. if (contentRef.current && wrapperRef.current) {
  12583. let resizeObserver = new ResizeObserver(() => {
  12584. wrapperWidth.current = wrapperRef.current?.offsetWidth || wrapperWidth.current, contentWidth.current = contentRef.current?.offsetWidth || contentWidth.current, setHidden(contentWidth.current > wrapperWidth.current);
  12585. });
  12586. return resizeObserver.observe(wrapperRef.current), () => resizeObserver.disconnect();
  12587. }
  12588. }, []), react_default.createElement(Wrapper3, { ref: wrapperRef }, react_default.createElement(Content2, { isHidden: hidden, ref: contentRef }, content), fallback && react_default.createElement(Content2, { isHidden: !hidden }, fallback));
  12589. };
  12590. // src/manager/components/Particles/Particles.tsx
  12591. init_react();
  12592. var Shape = styled.svg(({ color: color2 }) => ({
  12593. fill: color2,
  12594. position: "absolute",
  12595. inset: "0",
  12596. margin: "auto",
  12597. width: "12px",
  12598. height: "12px",
  12599. pointerEvents: "none"
  12600. })), Donut = (props) => react_default.createElement(Shape, { viewBox: "0 0 90 90", xmlns: "http://www.w3.org/2000/svg", color: "red", ...props }, react_default.createElement("path", { d: "M45 0c24.853 0 45 20.147 45 45S69.853 90 45 90 0 69.853 0 45 20.147 0 45 0zm.5 27C35.283 27 27 35.283 27 45.5S35.283 64 45.5 64 64 55.717 64 45.5 55.717 27 45.5 27z" })), L2 = (props) => react_default.createElement(Shape, { viewBox: "0 0 55 89", xmlns: "http://www.w3.org/2000/svg", color: "#66BF3C", ...props }, react_default.createElement("path", { d: "M55 3v83a3 3 0 01-3 3H3a3 3 0 01-3-3V64a3 3 0 013-3h21a3 3 0 003-3V3a3 3 0 013-3h22a3 3 0 013 3z" })), Slice = (props) => react_default.createElement(Shape, { viewBox: "0 0 92 92", xmlns: "http://www.w3.org/2000/svg", color: "#FF4785", ...props }, react_default.createElement("path", { d: "M92 89V3c0-3-2.056-3-3-3C39.294 0 0 39.294 0 89c0 0 0 3 3 3h86a3 3 0 003-3z" })), Square = ({ style, ...props }) => react_default.createElement(
  12601. Shape,
  12602. {
  12603. viewBox: "0 0 90 90",
  12604. xmlns: "http://www.w3.org/2000/svg",
  12605. color: "#1EA7FD",
  12606. ...props,
  12607. style: { borderRadius: 5, ...style }
  12608. },
  12609. react_default.createElement("path", { d: "M0 0h90v90H0z" })
  12610. ), Triangle = (props) => react_default.createElement(Shape, { viewBox: "0 0 96 88", xmlns: "http://www.w3.org/2000/svg", color: "#FFAE00", ...props }, react_default.createElement("path", { d: "M50.63 1.785l44.928 81.77A3 3 0 0192.928 88H3.072a3 3 0 01-2.629-4.445l44.929-81.77a3 3 0 015.258 0z" })), T2 = (props) => react_default.createElement(Shape, { viewBox: "0 0 92 62", xmlns: "http://www.w3.org/2000/svg", color: "#FC521F", ...props }, react_default.createElement("path", { d: "M63 3v25a3 3 0 003 3h23a3 3 0 013 3v25a3 3 0 01-3 3H3a3 3 0 01-3-3V34a3 3 0 013-3h24a3 3 0 003-3V3a3 3 0 013-3h27a3 3 0 013 3z" })), Z = (props) => react_default.createElement(Shape, { viewBox: "0 0 56 90", xmlns: "http://www.w3.org/2000/svg", color: "#6F2CAC", ...props }, react_default.createElement("path", { d: "M28 3v25a3 3 0 003 3h22a3 3 0 013 3v53a3 3 0 01-3 3H31a3 3 0 01-3-3V62a3 3 0 00-3-3H3a3 3 0 01-3-3V3a3 3 0 013-3h22a3 3 0 013 3z" })), fadeToTransparent = keyframes`
  12611. to {
  12612. opacity: 0;
  12613. }
  12614. `, disperse = keyframes`
  12615. to {
  12616. transform: translate(
  12617. calc(cos(var(--angle)) * var(--distance)),
  12618. calc(sin(var(--angle)) * var(--distance))
  12619. ) rotate(var(--rotation));
  12620. }
  12621. `, slideDown = keyframes`
  12622. to {
  12623. transform: translateY(50px);
  12624. }
  12625. `, Container8 = styled.div({
  12626. position: "absolute",
  12627. display: "flex",
  12628. flexDirection: "row",
  12629. flexWrap: "wrap",
  12630. gap: 10,
  12631. "--particle-curve": "cubic-bezier(0.2, 0.56, 0, 1)",
  12632. animation: `${slideDown} 1000ms forwards cubic-bezier(0.587, -0.381, 0.583, 0.599)`,
  12633. animationDelay: "150ms",
  12634. zIndex: 999,
  12635. svg: {
  12636. width: 15,
  12637. height: 15,
  12638. animation: `${fadeToTransparent} var(--fade-duration) forwards, ${disperse} 1000ms forwards var(--particle-curve)`
  12639. }
  12640. }), FADE_DURATION = 1200, NUM_OF_PARTICLES = 8, JITTER = 15, random = (min, max) => Math.random() * (max - min) + min, sortRandomly = (array) => array.sort(() => Math.random() - 0.5), Particles = memo(function({
  12641. anchor: Anchor
  12642. }) {
  12643. let anchorRef = useRef(null), [left, setLeft] = useState(0), [top, setTop] = useState(0), shapes = sortRandomly([Donut, L2, Slice, Square, Triangle, T2, Z]), colors = sortRandomly([
  12644. "#FF0000",
  12645. "#FF4787",
  12646. "#66BF3C",
  12647. "#1EA7FD",
  12648. "#FC521F",
  12649. "#6F2CAC",
  12650. "#FFAE00"
  12651. ]);
  12652. return useLayoutEffect(() => {
  12653. let rect = anchorRef.current?.getBoundingClientRect();
  12654. rect && (setLeft(rect.left + rect.width / 2), setTop(rect.top + rect.height / 2));
  12655. }, []), react_default.createElement("div", { ref: anchorRef }, react_default.createElement(Anchor, null), createPortal(
  12656. react_default.createElement(Container8, { style: { top: top + "px", left: left + "px" } }, shapes.map((Particle, index) => {
  12657. let angle = 360 / NUM_OF_PARTICLES * index + random(-JITTER, JITTER), distance = random(50, 80), rotation = random(-360, 360), style = {
  12658. "--angle": angle + "deg",
  12659. "--distance": distance + "px",
  12660. "--rotation": rotation + "deg",
  12661. "--fade-duration": FADE_DURATION + "ms"
  12662. };
  12663. return react_default.createElement(Particle, { key: Particle.name, style, color: colors[index] });
  12664. })),
  12665. document.getElementById("root") ?? document.body
  12666. ));
  12667. });
  12668. // src/manager/components/TextFlip.tsx
  12669. init_react();
  12670. var slideIn2 = keyframes({
  12671. from: {
  12672. transform: "translateY(var(--slide-in-from))",
  12673. opacity: 0
  12674. }
  12675. }), slideOut = keyframes({
  12676. to: {
  12677. transform: "translateY(var(--slide-out-to))",
  12678. opacity: 0
  12679. }
  12680. }), Container9 = styled.div({
  12681. display: "inline-grid",
  12682. gridTemplateColumns: "1fr",
  12683. justifyContent: "center",
  12684. alignItems: "center"
  12685. }), Placeholder2 = styled.div({
  12686. gridArea: "1 / 1",
  12687. userSelect: "none",
  12688. visibility: "hidden"
  12689. }), Text2 = styled.span(({ duration, isExiting, isEntering, reverse }) => {
  12690. let animation;
  12691. return isExiting ? animation = `${slideOut} ${duration}ms forwards` : isEntering && (animation = `${slideIn2} ${duration}ms forwards`), {
  12692. gridArea: "1 / 1",
  12693. animation,
  12694. pointerEvents: isExiting ? "none" : "auto",
  12695. userSelect: isExiting ? "none" : "text",
  12696. "--slide-in-from": reverse ? "-100%" : "100%",
  12697. "--slide-out-to": reverse ? "100%" : "-100%",
  12698. "@media (prefers-reduced-motion: reduce)": {
  12699. animation: "none",
  12700. opacity: isExiting ? 0 : 1,
  12701. transform: "translateY(0)"
  12702. }
  12703. };
  12704. }), TextFlip = ({
  12705. text,
  12706. duration = 250,
  12707. placeholder,
  12708. ...props
  12709. }) => {
  12710. let textRef = useRef(text), [staleValue, setStaleValue] = useState(text), isAnimating = text !== staleValue, reverse = isAnimating && numericCompare(staleValue, text);
  12711. return textRef.current = text, react_default.createElement(Container9, { ...props }, isAnimating && react_default.createElement(
  12712. Text2,
  12713. {
  12714. "aria-hidden": !0,
  12715. duration,
  12716. reverse,
  12717. isExiting: !0,
  12718. onAnimationEnd: () => setStaleValue(textRef.current)
  12719. },
  12720. staleValue
  12721. ), react_default.createElement(Text2, { duration, reverse, isEntering: isAnimating }, text), placeholder && react_default.createElement(Placeholder2, { "aria-hidden": !0 }, placeholder));
  12722. };
  12723. function numericCompare(a2, b2) {
  12724. let na = Number(a2), nb = Number(b2);
  12725. return Number.isNaN(na) || Number.isNaN(nb) ? a2.localeCompare(b2, void 0, { numeric: !0 }) > 0 : na > nb;
  12726. }
  12727. // src/manager/components/sidebar/useChecklist.ts
  12728. init_react();
  12729. // ../../node_modules/es-toolkit/dist/function/debounce.mjs
  12730. function debounce(func, debounceMs, { signal, edges } = {}) {
  12731. let pendingThis, pendingArgs = null, leading = edges != null && edges.includes("leading"), trailing = edges == null || edges.includes("trailing"), invoke = () => {
  12732. pendingArgs !== null && (func.apply(pendingThis, pendingArgs), pendingThis = void 0, pendingArgs = null);
  12733. }, onTimerEnd = () => {
  12734. trailing && invoke(), cancel();
  12735. }, timeoutId = null, schedule = () => {
  12736. timeoutId != null && clearTimeout(timeoutId), timeoutId = setTimeout(() => {
  12737. timeoutId = null, onTimerEnd();
  12738. }, debounceMs);
  12739. }, cancelTimer = () => {
  12740. timeoutId !== null && (clearTimeout(timeoutId), timeoutId = null);
  12741. }, cancel = () => {
  12742. cancelTimer(), pendingThis = void 0, pendingArgs = null;
  12743. }, flush = () => {
  12744. invoke();
  12745. }, debounced = function(...args) {
  12746. if (signal?.aborted)
  12747. return;
  12748. pendingThis = this, pendingArgs = args;
  12749. let isFirstCall = timeoutId == null;
  12750. schedule(), leading && isFirstCall && invoke();
  12751. };
  12752. return debounced.schedule = schedule, debounced.cancel = cancel, debounced.flush = flush, signal?.addEventListener("abort", cancel, { once: !0 }), debounced;
  12753. }
  12754. // ../../node_modules/es-toolkit/dist/function/partial.mjs
  12755. function partial(func, ...partialArgs) {
  12756. return partialImpl(func, placeholderSymbol, ...partialArgs);
  12757. }
  12758. function partialImpl(func, placeholder, ...partialArgs) {
  12759. let partialed = function(...providedArgs) {
  12760. let providedArgsIndex = 0, substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg), remainingArgs = providedArgs.slice(providedArgsIndex);
  12761. return func.apply(this, substitutedArgs.concat(remainingArgs));
  12762. };
  12763. return func.prototype && (partialed.prototype = Object.create(func.prototype)), partialed;
  12764. }
  12765. var placeholderSymbol = Symbol("partial.placeholder");
  12766. partial.placeholder = placeholderSymbol;
  12767. // ../../node_modules/es-toolkit/dist/function/partialRight.mjs
  12768. function partialRight(func, ...partialArgs) {
  12769. return partialRightImpl(func, placeholderSymbol2, ...partialArgs);
  12770. }
  12771. function partialRightImpl(func, placeholder, ...partialArgs) {
  12772. let partialedRight = function(...providedArgs) {
  12773. let placeholderLength = partialArgs.filter((arg) => arg === placeholder).length, rangeLength = Math.max(providedArgs.length - placeholderLength, 0), remainingArgs = providedArgs.slice(0, rangeLength), providedArgsIndex = rangeLength, substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg);
  12774. return func.apply(this, remainingArgs.concat(substitutedArgs));
  12775. };
  12776. return func.prototype && (partialedRight.prototype = Object.create(func.prototype)), partialedRight;
  12777. }
  12778. var placeholderSymbol2 = Symbol("partialRight.placeholder");
  12779. partialRight.placeholder = placeholderSymbol2;
  12780. // ../../node_modules/es-toolkit/dist/function/retry.mjs
  12781. var DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
  12782. // ../../node_modules/es-toolkit/dist/function/throttle.mjs
  12783. function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
  12784. let pendingAt = null, debounced = debounce(function(...args) {
  12785. pendingAt = Date.now(), func.apply(this, args);
  12786. }, throttleMs, { signal, edges }), throttled = function(...args) {
  12787. if (pendingAt == null && (pendingAt = Date.now()), Date.now() - pendingAt >= throttleMs) {
  12788. pendingAt = Date.now(), func.apply(this, args), debounced.cancel(), debounced.schedule();
  12789. return;
  12790. }
  12791. debounced.apply(this, args);
  12792. };
  12793. return throttled.cancel = debounced.cancel, throttled.flush = debounced.flush, throttled;
  12794. }
  12795. // src/shared/checklist-store/checklistData.tsx
  12796. init_react();
  12797. // ../addons/a11y/src/constants.ts
  12798. var ADDON_ID2 = "storybook/a11y", PANEL_ID2 = `${ADDON_ID2}/panel`;
  12799. var UI_STATE_ID = `${ADDON_ID2}/ui`, RESULT = `${ADDON_ID2}/result`, REQUEST = `${ADDON_ID2}/request`, RUNNING = `${ADDON_ID2}/running`, ERROR = `${ADDON_ID2}/error`, MANUAL = `${ADDON_ID2}/manual`, SELECT = `${ADDON_ID2}/select`, DOCUMENTATION_LINK = "writing-tests/accessibility-testing", DOCUMENTATION_DISCREPANCY_LINK = `${DOCUMENTATION_LINK}#why-are-my-tests-failing-in-different-environments`;
  12800. // ../addons/onboarding/src/constants.ts
  12801. var ADDON_ID3 = "storybook/onboarding", ADDON_ONBOARDING_CHANNEL = `${ADDON_ID3}/channel`;
  12802. // src/component-testing/constants.ts
  12803. var ADDON_ID4 = "storybook/interactions", PANEL_ID3 = `${ADDON_ID4}/panel`;
  12804. var DOCUMENTATION_LINK2 = "writing-tests/integrations/vitest-addon", DOCUMENTATION_DISCREPANCY_LINK2 = `${DOCUMENTATION_LINK2}#what-happens-when-there-are-different-test-results-in-multiple-environments`;
  12805. // ../addons/vitest/src/constants.ts
  12806. var ADDON_ID5 = "storybook/test", TEST_PROVIDER_ID = `${ADDON_ID5}/test-provider`, STORYBOOK_ADDON_TEST_CHANNEL = `${ADDON_ID5}/channel`;
  12807. var DOCUMENTATION_LINK3 = "writing-tests/integrations/vitest-addon", DOCUMENTATION_FATAL_ERROR_LINK = `${DOCUMENTATION_LINK3}#what-happens-if-vitest-itself-has-an-error`;
  12808. var storeOptions = {
  12809. id: ADDON_ID5,
  12810. initialState: {
  12811. config: {
  12812. coverage: !1,
  12813. a11y: !1
  12814. },
  12815. watching: !1,
  12816. cancelling: !1,
  12817. fatalError: void 0,
  12818. index: { entries: {}, v: 5 },
  12819. previewAnnotations: [],
  12820. currentRun: {
  12821. triggeredBy: void 0,
  12822. config: {
  12823. coverage: !1,
  12824. a11y: !1
  12825. },
  12826. componentTestStatuses: [],
  12827. a11yStatuses: [],
  12828. a11yReports: {},
  12829. reports: {},
  12830. componentTestCount: {
  12831. success: 0,
  12832. error: 0
  12833. },
  12834. a11yCount: {
  12835. success: 0,
  12836. warning: 0,
  12837. error: 0
  12838. },
  12839. storyIds: void 0,
  12840. totalTestCount: void 0,
  12841. startedAt: void 0,
  12842. finishedAt: void 0,
  12843. unhandledErrors: [],
  12844. coverageSummary: void 0
  12845. }
  12846. }
  12847. };
  12848. var STORE_CHANNEL_EVENT_NAME = `UNIVERSAL_STORE:${storeOptions.id}`;
  12849. var TRIGGER_TEST_RUN_REQUEST = `${ADDON_ID5}/trigger-test-run-request`, TRIGGER_TEST_RUN_RESPONSE = `${ADDON_ID5}/trigger-test-run-response`;
  12850. // src/storybook-error.ts
  12851. function parseErrorCode({
  12852. code,
  12853. category
  12854. }) {
  12855. let paddedCode = String(code).padStart(4, "0");
  12856. return `SB_${category}_${paddedCode}`;
  12857. }
  12858. function appendErrorRef(url) {
  12859. if (/^(?!.*storybook\.js\.org)|[?&]ref=error\b/.test(url))
  12860. return url;
  12861. try {
  12862. let urlObj = new URL(url);
  12863. return urlObj.searchParams.set("ref", "error"), urlObj.toString();
  12864. } catch {
  12865. return url;
  12866. }
  12867. }
  12868. var StorybookError = class _StorybookError extends Error {
  12869. constructor(props) {
  12870. super(
  12871. _StorybookError.getFullMessage(props),
  12872. props.cause === void 0 ? void 0 : { cause: props.cause }
  12873. );
  12874. /**
  12875. * Data associated with the error. Used to provide additional information in the error message or
  12876. * to be passed to telemetry.
  12877. */
  12878. this.data = {};
  12879. /** Flag used to easily determine if the error originates from Storybook. */
  12880. this.fromStorybook = !0;
  12881. /**
  12882. * Flag used to determine if the error is handled by us and should therefore not be shown to the
  12883. * user.
  12884. */
  12885. this.isHandledError = !1;
  12886. /**
  12887. * A collection of sub errors which relate to a parent error.
  12888. *
  12889. * Sub-errors are used to represent multiple related errors that occurred together. When a
  12890. * StorybookError with sub-errors is sent to telemetry, both the parent error and each sub-error
  12891. * are sent as separate telemetry events. This allows for better error tracking and debugging.
  12892. *
  12893. * @example
  12894. *
  12895. * ```ts
  12896. * const error1 = new SomeError();
  12897. * const error2 = new AnotherError();
  12898. * const parentError = new ParentError({
  12899. * // ... other props
  12900. * subErrors: [error1, error2],
  12901. * });
  12902. * ```
  12903. */
  12904. this.subErrors = [];
  12905. this.category = props.category, this.documentation = props.documentation ?? !1, this.code = props.code, this.isHandledError = props.isHandledError ?? !1, this.name = props.name, this.subErrors = props.subErrors ?? [];
  12906. }
  12907. get fullErrorCode() {
  12908. return parseErrorCode({ code: this.code, category: this.category });
  12909. }
  12910. /** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */
  12911. get name() {
  12912. let errorName = this._name || this.constructor.name;
  12913. return `${this.fullErrorCode} (${errorName})`;
  12914. }
  12915. set name(name) {
  12916. this._name = name;
  12917. }
  12918. /** Generates the error message along with additional documentation link (if applicable). */
  12919. static getFullMessage({
  12920. documentation,
  12921. code,
  12922. category,
  12923. message
  12924. }) {
  12925. let page;
  12926. return documentation === !0 ? page = `https://storybook.js.org/error/${parseErrorCode({ code, category })}?ref=error` : typeof documentation == "string" ? page = appendErrorRef(documentation) : Array.isArray(documentation) && (page = `
  12927. ${documentation.map((doc) => ` - ${appendErrorRef(doc)}`).join(`
  12928. `)}`), `${message}${page != null ? `
  12929. More info: ${page}
  12930. ` : ""}`;
  12931. }
  12932. };
  12933. // src/manager-errors.ts
  12934. var StatusTypeIdMismatchError2 = class extends StorybookError {
  12935. constructor(data) {
  12936. super({
  12937. name: "StatusTypeIdMismatchError",
  12938. category: "MANAGER_API" /* MANAGER_API */,
  12939. code: 1,
  12940. message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
  12941. data.status,
  12942. null,
  12943. 2
  12944. )}`
  12945. });
  12946. this.data = data;
  12947. }
  12948. };
  12949. // ../../node_modules/ts-dedent/esm/index.js
  12950. function dedent(templ) {
  12951. for (var values = [], _i = 1; _i < arguments.length; _i++)
  12952. values[_i - 1] = arguments[_i];
  12953. var strings = Array.from(typeof templ == "string" ? [templ] : templ);
  12954. strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
  12955. var indentLengths = strings.reduce(function(arr, str) {
  12956. var matches = str.match(/\n([\t ]+|(?!\s).)/g);
  12957. return matches ? arr.concat(matches.map(function(match) {
  12958. var _a2, _b;
  12959. return (_b = (_a2 = match.match(/[\t ]/g)) === null || _a2 === void 0 ? void 0 : _a2.length) !== null && _b !== void 0 ? _b : 0;
  12960. })) : arr;
  12961. }, []);
  12962. if (indentLengths.length) {
  12963. var pattern_1 = new RegExp(`
  12964. [ ]{` + Math.min.apply(Math, indentLengths) + "}", "g");
  12965. strings = strings.map(function(str) {
  12966. return str.replace(pattern_1, `
  12967. `);
  12968. });
  12969. }
  12970. strings[0] = strings[0].replace(/^\r?\n/, "");
  12971. var string = strings[0];
  12972. return values.forEach(function(value, i2) {
  12973. var endentations = string.match(/(?:^|\n)( *)$/), endentation = endentations ? endentations[1] : "", indentedValue = value;
  12974. typeof value == "string" && value.includes(`
  12975. `) && (indentedValue = String(value).split(`
  12976. `).map(function(str, i3) {
  12977. return i3 === 0 ? str : "" + endentation + str;
  12978. }).join(`
  12979. `)), string += indentedValue + strings[i2 + 1];
  12980. }), string;
  12981. }
  12982. // src/preview-errors.ts
  12983. var StatusTypeIdMismatchError3 = class extends StorybookError {
  12984. constructor(data) {
  12985. super({
  12986. name: "StatusTypeIdMismatchError",
  12987. category: "PREVIEW_API" /* PREVIEW_API */,
  12988. code: 16,
  12989. message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
  12990. data.status,
  12991. null,
  12992. 2
  12993. )}`
  12994. });
  12995. this.data = data;
  12996. }
  12997. };
  12998. // src/server-errors.ts
  12999. var import_picocolors = __toESM(require_picocolors_browser(), 1);
  13000. var StatusTypeIdMismatchError4 = class extends StorybookError {
  13001. constructor(data) {
  13002. super({
  13003. name: "StatusTypeIdMismatchError",
  13004. category: "CORE-SERVER" /* CORE_SERVER */,
  13005. code: 16,
  13006. message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
  13007. data.status,
  13008. null,
  13009. 2
  13010. )}`
  13011. });
  13012. this.data = data;
  13013. }
  13014. };
  13015. // src/shared/status-store/index.ts
  13016. var STATUS_VALUE_PREFIX = "status-value:";
  13017. var statusValueShortName = (value) => value === "status-value:affected" ? "related" : value.slice(STATUS_VALUE_PREFIX.length), statusValueDescription = (value) => ({
  13018. "status-value:pending": "Stories with pending status",
  13019. "status-value:success": "Stories with passing tests",
  13020. "status-value:new": "Newly added stories",
  13021. "status-value:modified": "Stories closely linked to code changes",
  13022. "status-value:affected": "Stories likely to be affected by code changes",
  13023. "status-value:warning": "Stories with warnings",
  13024. "status-value:error": "Stories with failing tests",
  13025. "status-value:unknown": "Stories with unknown status"
  13026. })[value];
  13027. var UNIVERSAL_STATUS_STORE_OPTIONS = {
  13028. id: "storybook/status",
  13029. leader: !0,
  13030. initialState: {}
  13031. }, StatusStoreEventType = {
  13032. SELECT: "select"
  13033. };
  13034. function countStatusesByValue(allStatuses) {
  13035. let counts = {};
  13036. for (let statusByTypeId of Object.values(allStatuses))
  13037. for (let status of Object.values(statusByTypeId))
  13038. counts[status.value] = (counts[status.value] ?? 0) + 1;
  13039. return counts;
  13040. }
  13041. function createStatusStore({
  13042. universalStatusStore: universalStatusStore2,
  13043. useUniversalStore: useUniversalStore2,
  13044. environment
  13045. }) {
  13046. let fullStatusStore2 = {
  13047. getAll() {
  13048. return universalStatusStore2.getState();
  13049. },
  13050. set(statuses) {
  13051. universalStatusStore2.setState((state) => {
  13052. let newState = { ...state };
  13053. for (let status of statuses) {
  13054. let { storyId, typeId } = status;
  13055. newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
  13056. }
  13057. return newState;
  13058. });
  13059. },
  13060. onAllStatusChange(listener) {
  13061. return universalStatusStore2.onStateChange((state, prevState) => {
  13062. listener(state, prevState);
  13063. });
  13064. },
  13065. onSelect(listener) {
  13066. return universalStatusStore2.subscribe(StatusStoreEventType.SELECT, (event) => {
  13067. listener(event.payload);
  13068. });
  13069. },
  13070. selectStatuses: (statuses) => {
  13071. universalStatusStore2.send({ type: StatusStoreEventType.SELECT, payload: statuses });
  13072. },
  13073. unset(storyIds) {
  13074. if (!storyIds) {
  13075. universalStatusStore2.setState({});
  13076. return;
  13077. }
  13078. universalStatusStore2.setState((state) => {
  13079. let newState = { ...state };
  13080. for (let storyId of storyIds)
  13081. delete newState[storyId];
  13082. return newState;
  13083. });
  13084. },
  13085. typeId: void 0
  13086. }, getStatusStoreByTypeId2 = (typeId) => ({
  13087. getAll: fullStatusStore2.getAll,
  13088. set(statuses) {
  13089. universalStatusStore2.setState((state) => {
  13090. let newState = { ...state };
  13091. for (let status of statuses) {
  13092. let { storyId } = status;
  13093. if (status.typeId !== typeId)
  13094. switch (environment) {
  13095. case "server":
  13096. throw new StatusTypeIdMismatchError4({
  13097. status,
  13098. typeId
  13099. });
  13100. case "manager":
  13101. throw new StatusTypeIdMismatchError2({
  13102. status,
  13103. typeId
  13104. });
  13105. case "preview":
  13106. default:
  13107. throw new StatusTypeIdMismatchError3({
  13108. status,
  13109. typeId
  13110. });
  13111. }
  13112. newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
  13113. }
  13114. return newState;
  13115. });
  13116. },
  13117. onAllStatusChange: fullStatusStore2.onAllStatusChange,
  13118. onSelect(listener) {
  13119. return universalStatusStore2.subscribe(StatusStoreEventType.SELECT, (event) => {
  13120. event.payload.some((status) => status.typeId === typeId) && listener(event.payload);
  13121. });
  13122. },
  13123. unset(storyIds) {
  13124. universalStatusStore2.setState((state) => {
  13125. let newState = { ...state };
  13126. for (let storyId in newState)
  13127. if (newState[storyId]?.[typeId] && (!storyIds || storyIds?.includes(storyId))) {
  13128. let { [typeId]: omittedStatus, ...storyStatusesWithoutTypeId } = newState[storyId];
  13129. newState[storyId] = storyStatusesWithoutTypeId;
  13130. }
  13131. return newState;
  13132. });
  13133. },
  13134. typeId
  13135. });
  13136. return useUniversalStore2 ? {
  13137. getStatusStoreByTypeId: getStatusStoreByTypeId2,
  13138. fullStatusStore: fullStatusStore2,
  13139. universalStatusStore: universalStatusStore2,
  13140. useStatusStore: (selector) => useUniversalStore2(universalStatusStore2, selector)[0]
  13141. } : { getStatusStoreByTypeId: getStatusStoreByTypeId2, fullStatusStore: fullStatusStore2, universalStatusStore: universalStatusStore2 };
  13142. }
  13143. // src/cli/AddonVitestService.constants.ts
  13144. var SUPPORTED_FRAMEWORKS = [
  13145. "html-vite" /* HTML_VITE */,
  13146. "nextjs-vite" /* NEXTJS_VITE */,
  13147. "preact-vite" /* PREACT_VITE */,
  13148. "react-native-web-vite" /* REACT_NATIVE_WEB_VITE */,
  13149. "react-vite" /* REACT_VITE */,
  13150. "solid" /* SOLID */,
  13151. "svelte-vite" /* SVELTE_VITE */,
  13152. "sveltekit" /* SVELTEKIT */,
  13153. "vue3-vite" /* VUE3_VITE */,
  13154. "web-components-vite" /* WEB_COMPONENTS_VITE */,
  13155. "tanstack-react" /* TANSTACK_REACT */
  13156. ];
  13157. // src/docs-tools/shared.ts
  13158. var ADDON_ID6 = "storybook/docs", PANEL_ID4 = `${ADDON_ID6}/panel`;
  13159. var SNIPPET_RENDERED = `${ADDON_ID6}/snippet-rendered`;
  13160. // src/manager/components/TourGuide/TourGuide.tsx
  13161. init_react();
  13162. // ../../node_modules/react-joyride/dist/index.mjs
  13163. init_react();
  13164. // ../../node_modules/@gilbarbara/deep-equal/dist/index.mjs
  13165. function isOfType(type) {
  13166. return (value) => typeof value === type;
  13167. }
  13168. var isFunction2 = isOfType("function"), isNull2 = (value) => value === null, isRegex = (value) => Object.prototype.toString.call(value).slice(8, -1) === "RegExp", isObject = (value) => !isUndefined2(value) && !isNull2(value) && (isFunction2(value) || typeof value == "object"), isUndefined2 = isOfType("undefined");
  13169. function equalArray(left, right) {
  13170. let { length } = left;
  13171. if (length !== right.length)
  13172. return !1;
  13173. for (let index = length; index-- !== 0; )
  13174. if (!equal(left[index], right[index]))
  13175. return !1;
  13176. return !0;
  13177. }
  13178. function equalArrayBuffer(left, right) {
  13179. if (left.byteLength !== right.byteLength)
  13180. return !1;
  13181. let view1 = new DataView(left.buffer), view2 = new DataView(right.buffer), index = left.byteLength;
  13182. for (; index--; )
  13183. if (view1.getUint8(index) !== view2.getUint8(index))
  13184. return !1;
  13185. return !0;
  13186. }
  13187. function equalMap(left, right) {
  13188. if (left.size !== right.size)
  13189. return !1;
  13190. for (let index of left.entries())
  13191. if (!right.has(index[0]))
  13192. return !1;
  13193. for (let index of left.entries())
  13194. if (!equal(index[1], right.get(index[0])))
  13195. return !1;
  13196. return !0;
  13197. }
  13198. function equalSet(left, right) {
  13199. if (left.size !== right.size)
  13200. return !1;
  13201. for (let index of left.entries())
  13202. if (!right.has(index[0]))
  13203. return !1;
  13204. return !0;
  13205. }
  13206. function equal(left, right) {
  13207. if (left === right)
  13208. return !0;
  13209. if (left && isObject(left) && right && isObject(right)) {
  13210. if (left.constructor !== right.constructor)
  13211. return !1;
  13212. if (Array.isArray(left) && Array.isArray(right))
  13213. return equalArray(left, right);
  13214. if (left instanceof Map && right instanceof Map)
  13215. return equalMap(left, right);
  13216. if (left instanceof Set && right instanceof Set)
  13217. return equalSet(left, right);
  13218. if (ArrayBuffer.isView(left) && ArrayBuffer.isView(right))
  13219. return equalArrayBuffer(left, right);
  13220. if (isRegex(left) && isRegex(right))
  13221. return left.source === right.source && left.flags === right.flags;
  13222. if (left.valueOf !== Object.prototype.valueOf)
  13223. return left.valueOf() === right.valueOf();
  13224. if (left.toString !== Object.prototype.toString)
  13225. return left.toString() === right.toString();
  13226. let leftKeys = Object.keys(left), rightKeys = Object.keys(right);
  13227. if (leftKeys.length !== rightKeys.length)
  13228. return !1;
  13229. for (let index = leftKeys.length; index-- !== 0; )
  13230. if (!Object.prototype.hasOwnProperty.call(right, leftKeys[index]))
  13231. return !1;
  13232. for (let index = leftKeys.length; index-- !== 0; ) {
  13233. let key = leftKeys[index];
  13234. if (!(key === "_owner" && left.$$typeof) && !equal(left[key], right[key]))
  13235. return !1;
  13236. }
  13237. return !0;
  13238. }
  13239. return Number.isNaN(left) && Number.isNaN(right) ? !0 : left === right;
  13240. }
  13241. // ../../node_modules/is-lite/dist/index.mjs
  13242. var objectTypes = [
  13243. "Array",
  13244. "ArrayBuffer",
  13245. "AsyncFunction",
  13246. "AsyncGenerator",
  13247. "AsyncGeneratorFunction",
  13248. "Date",
  13249. "Error",
  13250. "Function",
  13251. "Generator",
  13252. "GeneratorFunction",
  13253. "HTMLElement",
  13254. "Map",
  13255. "Object",
  13256. "Promise",
  13257. "RegExp",
  13258. "Set",
  13259. "WeakMap",
  13260. "WeakSet"
  13261. ], primitiveTypes = [
  13262. "bigint",
  13263. "boolean",
  13264. "null",
  13265. "number",
  13266. "string",
  13267. "symbol",
  13268. "undefined"
  13269. ];
  13270. function getObjectType(value) {
  13271. let objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  13272. if (/HTML\w+Element/.test(objectTypeName))
  13273. return "HTMLElement";
  13274. if (isObjectType(objectTypeName))
  13275. return objectTypeName;
  13276. }
  13277. function isObjectOfType(type) {
  13278. return (value) => getObjectType(value) === type;
  13279. }
  13280. function isObjectType(name) {
  13281. return objectTypes.includes(name);
  13282. }
  13283. function isOfType2(type) {
  13284. return (value) => typeof value === type;
  13285. }
  13286. function isPrimitiveType(name) {
  13287. return primitiveTypes.includes(name);
  13288. }
  13289. var DOM_PROPERTIES_TO_CHECK = [
  13290. "innerHTML",
  13291. "ownerDocument",
  13292. "style",
  13293. "attributes",
  13294. "nodeValue"
  13295. ];
  13296. function is(value) {
  13297. if (value === null)
  13298. return "null";
  13299. switch (typeof value) {
  13300. case "bigint":
  13301. return "bigint";
  13302. case "boolean":
  13303. return "boolean";
  13304. case "number":
  13305. return "number";
  13306. case "string":
  13307. return "string";
  13308. case "symbol":
  13309. return "symbol";
  13310. case "undefined":
  13311. return "undefined";
  13312. default:
  13313. }
  13314. if (is.array(value))
  13315. return "Array";
  13316. if (is.plainFunction(value))
  13317. return "Function";
  13318. let tagType = getObjectType(value);
  13319. return tagType || "Object";
  13320. }
  13321. is.array = Array.isArray;
  13322. is.arrayOf = (target, predicate) => !is.array(target) && !is.function(predicate) ? !1 : target.every((d2) => predicate(d2));
  13323. is.asyncGeneratorFunction = (value) => getObjectType(value) === "AsyncGeneratorFunction";
  13324. is.asyncFunction = isObjectOfType("AsyncFunction");
  13325. is.bigint = isOfType2("bigint");
  13326. is.boolean = (value) => value === !0 || value === !1;
  13327. is.date = isObjectOfType("Date");
  13328. is.defined = (value) => !is.undefined(value);
  13329. is.domElement = (value) => is.object(value) && !is.plainObject(value) && value.nodeType === 1 && is.string(value.nodeName) && DOM_PROPERTIES_TO_CHECK.every((property) => property in value);
  13330. is.empty = (value) => is.string(value) && value.length === 0 || is.array(value) && value.length === 0 || is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0 || is.set(value) && value.size === 0 || is.map(value) && value.size === 0;
  13331. is.error = isObjectOfType("Error");
  13332. is.function = isOfType2("function");
  13333. is.generator = (value) => is.iterable(value) && is.function(value.next) && is.function(value.throw);
  13334. is.generatorFunction = isObjectOfType("GeneratorFunction");
  13335. is.instanceOf = (instance, class_) => !instance || !class_ ? !1 : Object.getPrototypeOf(instance) === class_.prototype;
  13336. is.iterable = (value) => !is.nullOrUndefined(value) && is.function(value[Symbol.iterator]);
  13337. is.map = isObjectOfType("Map");
  13338. is.nan = (value) => Number.isNaN(value);
  13339. is.null = (value) => value === null;
  13340. is.nullOrUndefined = (value) => is.null(value) || is.undefined(value);
  13341. is.number = (value) => isOfType2("number")(value) && !is.nan(value);
  13342. is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value));
  13343. is.object = (value) => !is.nullOrUndefined(value) && (is.function(value) || typeof value == "object");
  13344. is.oneOf = (target, value) => is.array(target) ? target.indexOf(value) > -1 : !1;
  13345. is.plainFunction = isObjectOfType("Function");
  13346. is.plainObject = (value) => {
  13347. if (getObjectType(value) !== "Object")
  13348. return !1;
  13349. let prototype = Object.getPrototypeOf(value);
  13350. return prototype === null || prototype === Object.getPrototypeOf({});
  13351. };
  13352. is.primitive = (value) => is.null(value) || isPrimitiveType(typeof value);
  13353. is.promise = isObjectOfType("Promise");
  13354. is.propertyOf = (target, key, predicate) => {
  13355. if (!is.object(target) || !key)
  13356. return !1;
  13357. let value = target[key];
  13358. return is.function(predicate) ? predicate(value) : is.defined(value);
  13359. };
  13360. is.regexp = isObjectOfType("RegExp");
  13361. is.set = isObjectOfType("Set");
  13362. is.string = isOfType2("string");
  13363. is.symbol = isOfType2("symbol");
  13364. is.undefined = isOfType2("undefined");
  13365. is.weakMap = isObjectOfType("WeakMap");
  13366. is.weakSet = isObjectOfType("WeakSet");
  13367. var src_default = is;
  13368. // ../../node_modules/react-joyride/node_modules/tree-changes/dist/index.mjs
  13369. function canHaveLength(...arguments_) {
  13370. return arguments_.every((d2) => src_default.string(d2) || src_default.array(d2) || src_default.plainObject(d2));
  13371. }
  13372. function checkEquality(left, right, value) {
  13373. return isSameType(left, right) ? [left, right].every(src_default.array) ? !left.some(hasValue(value)) && right.some(hasValue(value)) : [left, right].every(src_default.plainObject) ? !Object.entries(left).some(hasEntry(value)) && Object.entries(right).some(hasEntry(value)) : right === value : !1;
  13374. }
  13375. function compareNumbers(previousData, data, options2) {
  13376. let { actual, key, previous, type } = options2, left = nested(previousData, key), right = nested(data, key), changed = [left, right].every(src_default.number) && (type === "increased" ? left < right : left > right);
  13377. return src_default.undefined(actual) || (changed = changed && right === actual), src_default.undefined(previous) || (changed = changed && left === previous), changed;
  13378. }
  13379. function compareValues(previousData, data, options2) {
  13380. let { key, type, value } = options2, left = nested(previousData, key), right = nested(data, key), primary = type === "added" ? left : right, secondary = type === "added" ? right : left;
  13381. if (!src_default.nullOrUndefined(value)) {
  13382. if (src_default.defined(primary)) {
  13383. if (src_default.array(primary) || src_default.plainObject(primary))
  13384. return checkEquality(primary, secondary, value);
  13385. } else
  13386. return equal(secondary, value);
  13387. return !1;
  13388. }
  13389. return [left, right].every(src_default.array) ? !secondary.every(isEqualPredicate(primary)) : [left, right].every(src_default.plainObject) ? hasExtraKeys(Object.keys(primary), Object.keys(secondary)) : ![left, right].every((d2) => src_default.primitive(d2) && src_default.defined(d2)) && (type === "added" ? !src_default.defined(left) && src_default.defined(right) : src_default.defined(left) && !src_default.defined(right));
  13390. }
  13391. function getIterables(previousData, data, { key } = {}) {
  13392. let left = nested(previousData, key), right = nested(data, key);
  13393. if (!isSameType(left, right))
  13394. throw new TypeError("Inputs have different types");
  13395. if (!canHaveLength(left, right))
  13396. throw new TypeError("Inputs don't have length");
  13397. return [left, right].every(src_default.plainObject) && (left = Object.keys(left), right = Object.keys(right)), [left, right];
  13398. }
  13399. function hasEntry(input) {
  13400. return ([key, value]) => src_default.array(input) ? equal(input, value) || input.some((d2) => equal(d2, value) || src_default.array(value) && isEqualPredicate(value)(d2)) : src_default.plainObject(input) && input[key] ? !!input[key] && equal(input[key], value) : equal(input, value);
  13401. }
  13402. function hasExtraKeys(left, right) {
  13403. return right.some((d2) => !left.includes(d2));
  13404. }
  13405. function hasValue(input) {
  13406. return (value) => src_default.array(input) ? input.some((d2) => equal(d2, value) || src_default.array(value) && isEqualPredicate(value)(d2)) : equal(input, value);
  13407. }
  13408. function includesOrEqualsTo(previousValue, value) {
  13409. return src_default.array(previousValue) ? previousValue.some((d2) => equal(d2, value)) : equal(previousValue, value);
  13410. }
  13411. function isEqualPredicate(data) {
  13412. return (value) => data.some((d2) => equal(d2, value));
  13413. }
  13414. function isSameType(...arguments_) {
  13415. return arguments_.every(src_default.array) || arguments_.every(src_default.number) || arguments_.every(src_default.plainObject) || arguments_.every(src_default.string);
  13416. }
  13417. function nested(data, property) {
  13418. return src_default.plainObject(data) || src_default.array(data) ? src_default.string(property) ? property.split(".").reduce((acc, d2) => acc && acc[d2], data) : src_default.number(property) ? data[property] : data : data;
  13419. }
  13420. function treeChanges(previousData, data) {
  13421. if ([previousData, data].some(src_default.nullOrUndefined))
  13422. throw new Error("Missing required parameters");
  13423. if (![previousData, data].every((d2) => src_default.plainObject(d2) || src_default.array(d2)))
  13424. throw new Error("Expected plain objects or array");
  13425. return { added: (key, value) => {
  13426. try {
  13427. return compareValues(previousData, data, { key, type: "added", value });
  13428. } catch {
  13429. return !1;
  13430. }
  13431. }, changed: (key, actual, previous) => {
  13432. try {
  13433. let left = nested(previousData, key), right = nested(data, key), hasActual = src_default.defined(actual), hasPrevious = src_default.defined(previous);
  13434. if (hasActual || hasPrevious) {
  13435. let leftComparator = hasPrevious ? includesOrEqualsTo(previous, left) : !includesOrEqualsTo(actual, left), rightComparator = includesOrEqualsTo(actual, right);
  13436. return leftComparator && rightComparator;
  13437. }
  13438. return [left, right].every(src_default.array) || [left, right].every(src_default.plainObject) ? !equal(left, right) : left !== right;
  13439. } catch {
  13440. return !1;
  13441. }
  13442. }, changedFrom: (key, previous, actual) => {
  13443. if (!src_default.defined(key))
  13444. return !1;
  13445. try {
  13446. let left = nested(previousData, key), right = nested(data, key), hasActual = src_default.defined(actual);
  13447. return includesOrEqualsTo(previous, left) && (hasActual ? includesOrEqualsTo(actual, right) : !hasActual);
  13448. } catch {
  13449. return !1;
  13450. }
  13451. }, decreased: (key, actual, previous) => {
  13452. if (!src_default.defined(key))
  13453. return !1;
  13454. try {
  13455. return compareNumbers(previousData, data, { key, actual, previous, type: "decreased" });
  13456. } catch {
  13457. return !1;
  13458. }
  13459. }, emptied: (key) => {
  13460. try {
  13461. let [left, right] = getIterables(previousData, data, { key });
  13462. return !!left.length && !right.length;
  13463. } catch {
  13464. return !1;
  13465. }
  13466. }, filled: (key) => {
  13467. try {
  13468. let [left, right] = getIterables(previousData, data, { key });
  13469. return !left.length && !!right.length;
  13470. } catch {
  13471. return !1;
  13472. }
  13473. }, increased: (key, actual, previous) => {
  13474. if (!src_default.defined(key))
  13475. return !1;
  13476. try {
  13477. return compareNumbers(previousData, data, { key, actual, previous, type: "increased" });
  13478. } catch {
  13479. return !1;
  13480. }
  13481. }, removed: (key, value) => {
  13482. try {
  13483. return compareValues(previousData, data, { key, type: "removed", value });
  13484. } catch {
  13485. return !1;
  13486. }
  13487. } };
  13488. }
  13489. // ../../node_modules/react-joyride/dist/index.mjs
  13490. var import_scroll = __toESM(require_scroll(), 1), import_scrollparent = __toESM(require_scrollparent(), 1);
  13491. init_react();
  13492. var import_react_innertext = __toESM(require_react_innertext(), 1);
  13493. var import_deepmerge2 = __toESM(require_cjs(), 1);
  13494. var import_deepmerge3 = __toESM(require_cjs(), 1);
  13495. init_react();
  13496. init_react();
  13497. init_react();
  13498. init_react();
  13499. // ../../node_modules/react-floater/es/index.js
  13500. init_react();
  13501. var import_prop_types2 = __toESM(require_prop_types());
  13502. // ../../node_modules/popper.js/dist/esm/popper.js
  13503. var isBrowser2 = typeof window < "u" && typeof document < "u" && typeof navigator < "u", timeoutDuration = (function() {
  13504. for (var longerTimeoutBrowsers = ["Edge", "Trident", "Firefox"], i2 = 0; i2 < longerTimeoutBrowsers.length; i2 += 1)
  13505. if (isBrowser2 && navigator.userAgent.indexOf(longerTimeoutBrowsers[i2]) >= 0)
  13506. return 1;
  13507. return 0;
  13508. })();
  13509. function microtaskDebounce(fn) {
  13510. var called = !1;
  13511. return function() {
  13512. called || (called = !0, window.Promise.resolve().then(function() {
  13513. called = !1, fn();
  13514. }));
  13515. };
  13516. }
  13517. function taskDebounce(fn) {
  13518. var scheduled = !1;
  13519. return function() {
  13520. scheduled || (scheduled = !0, setTimeout(function() {
  13521. scheduled = !1, fn();
  13522. }, timeoutDuration));
  13523. };
  13524. }
  13525. var supportsMicroTasks = isBrowser2 && window.Promise, debounce2 = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  13526. function isFunction3(functionToCheck) {
  13527. var getType = {};
  13528. return functionToCheck && getType.toString.call(functionToCheck) === "[object Function]";
  13529. }
  13530. function getStyleComputedProperty(element, property) {
  13531. if (element.nodeType !== 1)
  13532. return [];
  13533. var window2 = element.ownerDocument.defaultView, css2 = window2.getComputedStyle(element, null);
  13534. return property ? css2[property] : css2;
  13535. }
  13536. function getParentNode(element) {
  13537. return element.nodeName === "HTML" ? element : element.parentNode || element.host;
  13538. }
  13539. function getScrollParent(element) {
  13540. if (!element)
  13541. return document.body;
  13542. switch (element.nodeName) {
  13543. case "HTML":
  13544. case "BODY":
  13545. return element.ownerDocument.body;
  13546. case "#document":
  13547. return element.body;
  13548. }
  13549. var _getStyleComputedProp = getStyleComputedProperty(element), overflow = _getStyleComputedProp.overflow, overflowX = _getStyleComputedProp.overflowX, overflowY = _getStyleComputedProp.overflowY;
  13550. return /(auto|scroll|overlay)/.test(overflow + overflowY + overflowX) ? element : getScrollParent(getParentNode(element));
  13551. }
  13552. function getReferenceNode(reference) {
  13553. return reference && reference.referenceNode ? reference.referenceNode : reference;
  13554. }
  13555. var isIE11 = isBrowser2 && !!(window.MSInputMethodContext && document.documentMode), isIE10 = isBrowser2 && /MSIE 10/.test(navigator.userAgent);
  13556. function isIE(version3) {
  13557. return version3 === 11 ? isIE11 : version3 === 10 ? isIE10 : isIE11 || isIE10;
  13558. }
  13559. function getOffsetParent(element) {
  13560. if (!element)
  13561. return document.documentElement;
  13562. for (var noOffsetParent = isIE(10) ? document.body : null, offsetParent = element.offsetParent || null; offsetParent === noOffsetParent && element.nextElementSibling; )
  13563. offsetParent = (element = element.nextElementSibling).offsetParent;
  13564. var nodeName = offsetParent && offsetParent.nodeName;
  13565. return !nodeName || nodeName === "BODY" || nodeName === "HTML" ? element ? element.ownerDocument.documentElement : document.documentElement : ["TH", "TD", "TABLE"].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, "position") === "static" ? getOffsetParent(offsetParent) : offsetParent;
  13566. }
  13567. function isOffsetContainer(element) {
  13568. var nodeName = element.nodeName;
  13569. return nodeName === "BODY" ? !1 : nodeName === "HTML" || getOffsetParent(element.firstElementChild) === element;
  13570. }
  13571. function getRoot(node) {
  13572. return node.parentNode !== null ? getRoot(node.parentNode) : node;
  13573. }
  13574. function findCommonOffsetParent(element1, element2) {
  13575. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType)
  13576. return document.documentElement;
  13577. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING, start = order ? element1 : element2, end = order ? element2 : element1, range = document.createRange();
  13578. range.setStart(start, 0), range.setEnd(end, 0);
  13579. var commonAncestorContainer = range.commonAncestorContainer;
  13580. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end))
  13581. return isOffsetContainer(commonAncestorContainer) ? commonAncestorContainer : getOffsetParent(commonAncestorContainer);
  13582. var element1root = getRoot(element1);
  13583. return element1root.host ? findCommonOffsetParent(element1root.host, element2) : findCommonOffsetParent(element1, getRoot(element2).host);
  13584. }
  13585. function getScroll(element) {
  13586. var side = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "top", upperSide = side === "top" ? "scrollTop" : "scrollLeft", nodeName = element.nodeName;
  13587. if (nodeName === "BODY" || nodeName === "HTML") {
  13588. var html = element.ownerDocument.documentElement, scrollingElement = element.ownerDocument.scrollingElement || html;
  13589. return scrollingElement[upperSide];
  13590. }
  13591. return element[upperSide];
  13592. }
  13593. function includeScroll(rect, element) {
  13594. var subtract = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, scrollTop = getScroll(element, "top"), scrollLeft = getScroll(element, "left"), modifier = subtract ? -1 : 1;
  13595. return rect.top += scrollTop * modifier, rect.bottom += scrollTop * modifier, rect.left += scrollLeft * modifier, rect.right += scrollLeft * modifier, rect;
  13596. }
  13597. function getBordersSize(styles2, axis) {
  13598. var sideA = axis === "x" ? "Left" : "Top", sideB = sideA === "Left" ? "Right" : "Bottom";
  13599. return parseFloat(styles2["border" + sideA + "Width"]) + parseFloat(styles2["border" + sideB + "Width"]);
  13600. }
  13601. function getSize(axis, body, html, computedStyle) {
  13602. return Math.max(body["offset" + axis], body["scroll" + axis], html["client" + axis], html["offset" + axis], html["scroll" + axis], isIE(10) ? parseInt(html["offset" + axis]) + parseInt(computedStyle["margin" + (axis === "Height" ? "Top" : "Left")]) + parseInt(computedStyle["margin" + (axis === "Height" ? "Bottom" : "Right")]) : 0);
  13603. }
  13604. function getWindowSizes(document11) {
  13605. var body = document11.body, html = document11.documentElement, computedStyle = isIE(10) && getComputedStyle(html);
  13606. return {
  13607. height: getSize("Height", body, html, computedStyle),
  13608. width: getSize("Width", body, html, computedStyle)
  13609. };
  13610. }
  13611. var classCallCheck = function(instance, Constructor) {
  13612. if (!(instance instanceof Constructor))
  13613. throw new TypeError("Cannot call a class as a function");
  13614. }, createClass = /* @__PURE__ */ (function() {
  13615. function defineProperties(target, props) {
  13616. for (var i2 = 0; i2 < props.length; i2++) {
  13617. var descriptor = props[i2];
  13618. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  13619. }
  13620. }
  13621. return function(Constructor, protoProps, staticProps) {
  13622. return protoProps && defineProperties(Constructor.prototype, protoProps), staticProps && defineProperties(Constructor, staticProps), Constructor;
  13623. };
  13624. })(), defineProperty = function(obj, key, value) {
  13625. return key in obj ? Object.defineProperty(obj, key, {
  13626. value,
  13627. enumerable: !0,
  13628. configurable: !0,
  13629. writable: !0
  13630. }) : obj[key] = value, obj;
  13631. }, _extends2 = Object.assign || function(target) {
  13632. for (var i2 = 1; i2 < arguments.length; i2++) {
  13633. var source = arguments[i2];
  13634. for (var key in source)
  13635. Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
  13636. }
  13637. return target;
  13638. };
  13639. function getClientRect(offsets) {
  13640. return _extends2({}, offsets, {
  13641. right: offsets.left + offsets.width,
  13642. bottom: offsets.top + offsets.height
  13643. });
  13644. }
  13645. function getBoundingClientRect(element) {
  13646. var rect = {};
  13647. try {
  13648. if (isIE(10)) {
  13649. rect = element.getBoundingClientRect();
  13650. var scrollTop = getScroll(element, "top"), scrollLeft = getScroll(element, "left");
  13651. rect.top += scrollTop, rect.left += scrollLeft, rect.bottom += scrollTop, rect.right += scrollLeft;
  13652. } else
  13653. rect = element.getBoundingClientRect();
  13654. } catch {
  13655. }
  13656. var result = {
  13657. left: rect.left,
  13658. top: rect.top,
  13659. width: rect.right - rect.left,
  13660. height: rect.bottom - rect.top
  13661. }, sizes = element.nodeName === "HTML" ? getWindowSizes(element.ownerDocument) : {}, width = sizes.width || element.clientWidth || result.width, height = sizes.height || element.clientHeight || result.height, horizScrollbar = element.offsetWidth - width, vertScrollbar = element.offsetHeight - height;
  13662. if (horizScrollbar || vertScrollbar) {
  13663. var styles2 = getStyleComputedProperty(element);
  13664. horizScrollbar -= getBordersSize(styles2, "x"), vertScrollbar -= getBordersSize(styles2, "y"), result.width -= horizScrollbar, result.height -= vertScrollbar;
  13665. }
  13666. return getClientRect(result);
  13667. }
  13668. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  13669. var fixedPosition = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, isIE102 = isIE(10), isHTML = parent.nodeName === "HTML", childrenRect = getBoundingClientRect(children), parentRect = getBoundingClientRect(parent), scrollParent2 = getScrollParent(children), styles2 = getStyleComputedProperty(parent), borderTopWidth = parseFloat(styles2.borderTopWidth), borderLeftWidth = parseFloat(styles2.borderLeftWidth);
  13670. fixedPosition && isHTML && (parentRect.top = Math.max(parentRect.top, 0), parentRect.left = Math.max(parentRect.left, 0));
  13671. var offsets = getClientRect({
  13672. top: childrenRect.top - parentRect.top - borderTopWidth,
  13673. left: childrenRect.left - parentRect.left - borderLeftWidth,
  13674. width: childrenRect.width,
  13675. height: childrenRect.height
  13676. });
  13677. if (offsets.marginTop = 0, offsets.marginLeft = 0, !isIE102 && isHTML) {
  13678. var marginTop = parseFloat(styles2.marginTop), marginLeft = parseFloat(styles2.marginLeft);
  13679. offsets.top -= borderTopWidth - marginTop, offsets.bottom -= borderTopWidth - marginTop, offsets.left -= borderLeftWidth - marginLeft, offsets.right -= borderLeftWidth - marginLeft, offsets.marginTop = marginTop, offsets.marginLeft = marginLeft;
  13680. }
  13681. return (isIE102 && !fixedPosition ? parent.contains(scrollParent2) : parent === scrollParent2 && scrollParent2.nodeName !== "BODY") && (offsets = includeScroll(offsets, parent)), offsets;
  13682. }
  13683. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  13684. var excludeScroll = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, html = element.ownerDocument.documentElement, relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html), width = Math.max(html.clientWidth, window.innerWidth || 0), height = Math.max(html.clientHeight, window.innerHeight || 0), scrollTop = excludeScroll ? 0 : getScroll(html), scrollLeft = excludeScroll ? 0 : getScroll(html, "left"), offset2 = {
  13685. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  13686. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  13687. width,
  13688. height
  13689. };
  13690. return getClientRect(offset2);
  13691. }
  13692. function isFixed(element) {
  13693. var nodeName = element.nodeName;
  13694. if (nodeName === "BODY" || nodeName === "HTML")
  13695. return !1;
  13696. if (getStyleComputedProperty(element, "position") === "fixed")
  13697. return !0;
  13698. var parentNode = getParentNode(element);
  13699. return parentNode ? isFixed(parentNode) : !1;
  13700. }
  13701. function getFixedPositionOffsetParent(element) {
  13702. if (!element || !element.parentElement || isIE())
  13703. return document.documentElement;
  13704. for (var el = element.parentElement; el && getStyleComputedProperty(el, "transform") === "none"; )
  13705. el = el.parentElement;
  13706. return el || document.documentElement;
  13707. }
  13708. function getBoundaries(popper, reference, padding, boundariesElement) {
  13709. var fixedPosition = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !1, boundaries = { top: 0, left: 0 }, offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  13710. if (boundariesElement === "viewport")
  13711. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  13712. else {
  13713. var boundariesNode = void 0;
  13714. boundariesElement === "scrollParent" ? (boundariesNode = getScrollParent(getParentNode(reference)), boundariesNode.nodeName === "BODY" && (boundariesNode = popper.ownerDocument.documentElement)) : boundariesElement === "window" ? boundariesNode = popper.ownerDocument.documentElement : boundariesNode = boundariesElement;
  13715. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  13716. if (boundariesNode.nodeName === "HTML" && !isFixed(offsetParent)) {
  13717. var _getWindowSizes = getWindowSizes(popper.ownerDocument), height = _getWindowSizes.height, width = _getWindowSizes.width;
  13718. boundaries.top += offsets.top - offsets.marginTop, boundaries.bottom = height + offsets.top, boundaries.left += offsets.left - offsets.marginLeft, boundaries.right = width + offsets.left;
  13719. } else
  13720. boundaries = offsets;
  13721. }
  13722. padding = padding || 0;
  13723. var isPaddingNumber = typeof padding == "number";
  13724. return boundaries.left += isPaddingNumber ? padding : padding.left || 0, boundaries.top += isPaddingNumber ? padding : padding.top || 0, boundaries.right -= isPaddingNumber ? padding : padding.right || 0, boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0, boundaries;
  13725. }
  13726. function getArea(_ref) {
  13727. var width = _ref.width, height = _ref.height;
  13728. return width * height;
  13729. }
  13730. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  13731. var padding = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 0;
  13732. if (placement.indexOf("auto") === -1)
  13733. return placement;
  13734. var boundaries = getBoundaries(popper, reference, padding, boundariesElement), rects = {
  13735. top: {
  13736. width: boundaries.width,
  13737. height: refRect.top - boundaries.top
  13738. },
  13739. right: {
  13740. width: boundaries.right - refRect.right,
  13741. height: boundaries.height
  13742. },
  13743. bottom: {
  13744. width: boundaries.width,
  13745. height: boundaries.bottom - refRect.bottom
  13746. },
  13747. left: {
  13748. width: refRect.left - boundaries.left,
  13749. height: boundaries.height
  13750. }
  13751. }, sortedAreas = Object.keys(rects).map(function(key) {
  13752. return _extends2({
  13753. key
  13754. }, rects[key], {
  13755. area: getArea(rects[key])
  13756. });
  13757. }).sort(function(a2, b2) {
  13758. return b2.area - a2.area;
  13759. }), filteredAreas = sortedAreas.filter(function(_ref2) {
  13760. var width = _ref2.width, height = _ref2.height;
  13761. return width >= popper.clientWidth && height >= popper.clientHeight;
  13762. }), computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key, variation = placement.split("-")[1];
  13763. return computedPlacement + (variation ? "-" + variation : "");
  13764. }
  13765. function getReferenceOffsets(state, popper, reference) {
  13766. var fixedPosition = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  13767. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  13768. }
  13769. function getOuterSizes(element) {
  13770. var window2 = element.ownerDocument.defaultView, styles2 = window2.getComputedStyle(element), x2 = parseFloat(styles2.marginTop || 0) + parseFloat(styles2.marginBottom || 0), y2 = parseFloat(styles2.marginLeft || 0) + parseFloat(styles2.marginRight || 0), result = {
  13771. width: element.offsetWidth + y2,
  13772. height: element.offsetHeight + x2
  13773. };
  13774. return result;
  13775. }
  13776. function getOppositePlacement(placement) {
  13777. var hash = { left: "right", right: "left", bottom: "top", top: "bottom" };
  13778. return placement.replace(/left|right|bottom|top/g, function(matched) {
  13779. return hash[matched];
  13780. });
  13781. }
  13782. function getPopperOffsets(popper, referenceOffsets, placement) {
  13783. placement = placement.split("-")[0];
  13784. var popperRect = getOuterSizes(popper), popperOffsets = {
  13785. width: popperRect.width,
  13786. height: popperRect.height
  13787. }, isHoriz = ["right", "left"].indexOf(placement) !== -1, mainSide = isHoriz ? "top" : "left", secondarySide = isHoriz ? "left" : "top", measurement = isHoriz ? "height" : "width", secondaryMeasurement = isHoriz ? "width" : "height";
  13788. return popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2, placement === secondarySide ? popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement] : popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)], popperOffsets;
  13789. }
  13790. function find(arr, check) {
  13791. return Array.prototype.find ? arr.find(check) : arr.filter(check)[0];
  13792. }
  13793. function findIndex(arr, prop, value) {
  13794. if (Array.prototype.findIndex)
  13795. return arr.findIndex(function(cur) {
  13796. return cur[prop] === value;
  13797. });
  13798. var match = find(arr, function(obj) {
  13799. return obj[prop] === value;
  13800. });
  13801. return arr.indexOf(match);
  13802. }
  13803. function runModifiers(modifiers2, data, ends) {
  13804. var modifiersToRun = ends === void 0 ? modifiers2 : modifiers2.slice(0, findIndex(modifiers2, "name", ends));
  13805. return modifiersToRun.forEach(function(modifier) {
  13806. modifier.function && console.warn("`modifier.function` is deprecated, use `modifier.fn`!");
  13807. var fn = modifier.function || modifier.fn;
  13808. modifier.enabled && isFunction3(fn) && (data.offsets.popper = getClientRect(data.offsets.popper), data.offsets.reference = getClientRect(data.offsets.reference), data = fn(data, modifier));
  13809. }), data;
  13810. }
  13811. function update() {
  13812. if (!this.state.isDestroyed) {
  13813. var data = {
  13814. instance: this,
  13815. styles: {},
  13816. arrowStyles: {},
  13817. attributes: {},
  13818. flipped: !1,
  13819. offsets: {}
  13820. };
  13821. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed), data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding), data.originalPlacement = data.placement, data.positionFixed = this.options.positionFixed, data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement), data.offsets.popper.position = this.options.positionFixed ? "fixed" : "absolute", data = runModifiers(this.modifiers, data), this.state.isCreated ? this.options.onUpdate(data) : (this.state.isCreated = !0, this.options.onCreate(data));
  13822. }
  13823. }
  13824. function isModifierEnabled(modifiers2, modifierName) {
  13825. return modifiers2.some(function(_ref) {
  13826. var name = _ref.name, enabled = _ref.enabled;
  13827. return enabled && name === modifierName;
  13828. });
  13829. }
  13830. function getSupportedPropertyName(property) {
  13831. for (var prefixes = [!1, "ms", "Webkit", "Moz", "O"], upperProp = property.charAt(0).toUpperCase() + property.slice(1), i2 = 0; i2 < prefixes.length; i2++) {
  13832. var prefix = prefixes[i2], toCheck = prefix ? "" + prefix + upperProp : property;
  13833. if (typeof document.body.style[toCheck] < "u")
  13834. return toCheck;
  13835. }
  13836. return null;
  13837. }
  13838. function destroy() {
  13839. return this.state.isDestroyed = !0, isModifierEnabled(this.modifiers, "applyStyle") && (this.popper.removeAttribute("x-placement"), this.popper.style.position = "", this.popper.style.top = "", this.popper.style.left = "", this.popper.style.right = "", this.popper.style.bottom = "", this.popper.style.willChange = "", this.popper.style[getSupportedPropertyName("transform")] = ""), this.disableEventListeners(), this.options.removeOnDestroy && this.popper.parentNode.removeChild(this.popper), this;
  13840. }
  13841. function getWindow(element) {
  13842. var ownerDocument = element.ownerDocument;
  13843. return ownerDocument ? ownerDocument.defaultView : window;
  13844. }
  13845. function attachToScrollParents(scrollParent2, event, callback, scrollParents) {
  13846. var isBody = scrollParent2.nodeName === "BODY", target = isBody ? scrollParent2.ownerDocument.defaultView : scrollParent2;
  13847. target.addEventListener(event, callback, { passive: !0 }), isBody || attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents), scrollParents.push(target);
  13848. }
  13849. function setupEventListeners(reference, options2, state, updateBound) {
  13850. state.updateBound = updateBound, getWindow(reference).addEventListener("resize", state.updateBound, { passive: !0 });
  13851. var scrollElement = getScrollParent(reference);
  13852. return attachToScrollParents(scrollElement, "scroll", state.updateBound, state.scrollParents), state.scrollElement = scrollElement, state.eventsEnabled = !0, state;
  13853. }
  13854. function enableEventListeners() {
  13855. this.state.eventsEnabled || (this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate));
  13856. }
  13857. function removeEventListeners(reference, state) {
  13858. return getWindow(reference).removeEventListener("resize", state.updateBound), state.scrollParents.forEach(function(target) {
  13859. target.removeEventListener("scroll", state.updateBound);
  13860. }), state.updateBound = null, state.scrollParents = [], state.scrollElement = null, state.eventsEnabled = !1, state;
  13861. }
  13862. function disableEventListeners() {
  13863. this.state.eventsEnabled && (cancelAnimationFrame(this.scheduleUpdate), this.state = removeEventListeners(this.reference, this.state));
  13864. }
  13865. function isNumeric(n3) {
  13866. return n3 !== "" && !isNaN(parseFloat(n3)) && isFinite(n3);
  13867. }
  13868. function setStyles(element, styles2) {
  13869. Object.keys(styles2).forEach(function(prop) {
  13870. var unit = "";
  13871. ["width", "height", "top", "right", "bottom", "left"].indexOf(prop) !== -1 && isNumeric(styles2[prop]) && (unit = "px"), element.style[prop] = styles2[prop] + unit;
  13872. });
  13873. }
  13874. function setAttributes(element, attributes) {
  13875. Object.keys(attributes).forEach(function(prop) {
  13876. var value = attributes[prop];
  13877. value !== !1 ? element.setAttribute(prop, attributes[prop]) : element.removeAttribute(prop);
  13878. });
  13879. }
  13880. function applyStyle(data) {
  13881. return setStyles(data.instance.popper, data.styles), setAttributes(data.instance.popper, data.attributes), data.arrowElement && Object.keys(data.arrowStyles).length && setStyles(data.arrowElement, data.arrowStyles), data;
  13882. }
  13883. function applyStyleOnLoad(reference, popper, options2, modifierOptions, state) {
  13884. var referenceOffsets = getReferenceOffsets(state, popper, reference, options2.positionFixed), placement = computeAutoPlacement(options2.placement, referenceOffsets, popper, reference, options2.modifiers.flip.boundariesElement, options2.modifiers.flip.padding);
  13885. return popper.setAttribute("x-placement", placement), setStyles(popper, { position: options2.positionFixed ? "fixed" : "absolute" }), options2;
  13886. }
  13887. function getRoundedOffsets(data, shouldRound) {
  13888. var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference, round = Math.round, floor = Math.floor, noRound = function(v2) {
  13889. return v2;
  13890. }, referenceWidth = round(reference.width), popperWidth = round(popper.width), isVertical = ["left", "right"].indexOf(data.placement) !== -1, isVariation = data.placement.indexOf("-") !== -1, sameWidthParity = referenceWidth % 2 === popperWidth % 2, bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1, horizontalToInteger = shouldRound ? isVertical || isVariation || sameWidthParity ? round : floor : noRound, verticalToInteger = shouldRound ? round : noRound;
  13891. return {
  13892. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  13893. top: verticalToInteger(popper.top),
  13894. bottom: verticalToInteger(popper.bottom),
  13895. right: horizontalToInteger(popper.right)
  13896. };
  13897. }
  13898. var isFirefox = isBrowser2 && /Firefox/i.test(navigator.userAgent);
  13899. function computeStyle(data, options2) {
  13900. var x2 = options2.x, y2 = options2.y, popper = data.offsets.popper, legacyGpuAccelerationOption = find(data.instance.modifiers, function(modifier) {
  13901. return modifier.name === "applyStyle";
  13902. }).gpuAcceleration;
  13903. legacyGpuAccelerationOption !== void 0 && console.warn("WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!");
  13904. var gpuAcceleration = legacyGpuAccelerationOption !== void 0 ? legacyGpuAccelerationOption : options2.gpuAcceleration, offsetParent = getOffsetParent(data.instance.popper), offsetParentRect = getBoundingClientRect(offsetParent), styles2 = {
  13905. position: popper.position
  13906. }, offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox), sideA = x2 === "bottom" ? "top" : "bottom", sideB = y2 === "right" ? "left" : "right", prefixedProperty = getSupportedPropertyName("transform"), left = void 0, top = void 0;
  13907. if (sideA === "bottom" ? offsetParent.nodeName === "HTML" ? top = -offsetParent.clientHeight + offsets.bottom : top = -offsetParentRect.height + offsets.bottom : top = offsets.top, sideB === "right" ? offsetParent.nodeName === "HTML" ? left = -offsetParent.clientWidth + offsets.right : left = -offsetParentRect.width + offsets.right : left = offsets.left, gpuAcceleration && prefixedProperty)
  13908. styles2[prefixedProperty] = "translate3d(" + left + "px, " + top + "px, 0)", styles2[sideA] = 0, styles2[sideB] = 0, styles2.willChange = "transform";
  13909. else {
  13910. var invertTop = sideA === "bottom" ? -1 : 1, invertLeft = sideB === "right" ? -1 : 1;
  13911. styles2[sideA] = top * invertTop, styles2[sideB] = left * invertLeft, styles2.willChange = sideA + ", " + sideB;
  13912. }
  13913. var attributes = {
  13914. "x-placement": data.placement
  13915. };
  13916. return data.attributes = _extends2({}, attributes, data.attributes), data.styles = _extends2({}, styles2, data.styles), data.arrowStyles = _extends2({}, data.offsets.arrow, data.arrowStyles), data;
  13917. }
  13918. function isModifierRequired(modifiers2, requestingName, requestedName) {
  13919. var requesting = find(modifiers2, function(_ref) {
  13920. var name = _ref.name;
  13921. return name === requestingName;
  13922. }), isRequired = !!requesting && modifiers2.some(function(modifier) {
  13923. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  13924. });
  13925. if (!isRequired) {
  13926. var _requesting = "`" + requestingName + "`", requested = "`" + requestedName + "`";
  13927. console.warn(requested + " modifier is required by " + _requesting + " modifier in order to work, be sure to include it before " + _requesting + "!");
  13928. }
  13929. return isRequired;
  13930. }
  13931. function arrow(data, options2) {
  13932. var _data$offsets$arrow;
  13933. if (!isModifierRequired(data.instance.modifiers, "arrow", "keepTogether"))
  13934. return data;
  13935. var arrowElement = options2.element;
  13936. if (typeof arrowElement == "string") {
  13937. if (arrowElement = data.instance.popper.querySelector(arrowElement), !arrowElement)
  13938. return data;
  13939. } else if (!data.instance.popper.contains(arrowElement))
  13940. return console.warn("WARNING: `arrow.element` must be child of its popper element!"), data;
  13941. var placement = data.placement.split("-")[0], _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference, isVertical = ["left", "right"].indexOf(placement) !== -1, len = isVertical ? "height" : "width", sideCapitalized = isVertical ? "Top" : "Left", side = sideCapitalized.toLowerCase(), altSide = isVertical ? "left" : "top", opSide = isVertical ? "bottom" : "right", arrowElementSize = getOuterSizes(arrowElement)[len];
  13942. reference[opSide] - arrowElementSize < popper[side] && (data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize)), reference[side] + arrowElementSize > popper[opSide] && (data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide]), data.offsets.popper = getClientRect(data.offsets.popper);
  13943. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2, css2 = getStyleComputedProperty(data.instance.popper), popperMarginSide = parseFloat(css2["margin" + sideCapitalized]), popperBorderSide = parseFloat(css2["border" + sideCapitalized + "Width"]), sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  13944. return sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0), data.arrowElement = arrowElement, data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ""), _data$offsets$arrow), data;
  13945. }
  13946. function getOppositeVariation(variation) {
  13947. return variation === "end" ? "start" : variation === "start" ? "end" : variation;
  13948. }
  13949. var placements = ["auto-start", "auto", "auto-end", "top-start", "top", "top-end", "right-start", "right", "right-end", "bottom-end", "bottom", "bottom-start", "left-end", "left", "left-start"], validPlacements = placements.slice(3);
  13950. function clockwise(placement) {
  13951. var counter = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, index = validPlacements.indexOf(placement), arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  13952. return counter ? arr.reverse() : arr;
  13953. }
  13954. var BEHAVIORS = {
  13955. FLIP: "flip",
  13956. CLOCKWISE: "clockwise",
  13957. COUNTERCLOCKWISE: "counterclockwise"
  13958. };
  13959. function flip(data, options2) {
  13960. if (isModifierEnabled(data.instance.modifiers, "inner") || data.flipped && data.placement === data.originalPlacement)
  13961. return data;
  13962. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options2.padding, options2.boundariesElement, data.positionFixed), placement = data.placement.split("-")[0], placementOpposite = getOppositePlacement(placement), variation = data.placement.split("-")[1] || "", flipOrder = [];
  13963. switch (options2.behavior) {
  13964. case BEHAVIORS.FLIP:
  13965. flipOrder = [placement, placementOpposite];
  13966. break;
  13967. case BEHAVIORS.CLOCKWISE:
  13968. flipOrder = clockwise(placement);
  13969. break;
  13970. case BEHAVIORS.COUNTERCLOCKWISE:
  13971. flipOrder = clockwise(placement, !0);
  13972. break;
  13973. default:
  13974. flipOrder = options2.behavior;
  13975. }
  13976. return flipOrder.forEach(function(step, index) {
  13977. if (placement !== step || flipOrder.length === index + 1)
  13978. return data;
  13979. placement = data.placement.split("-")[0], placementOpposite = getOppositePlacement(placement);
  13980. var popperOffsets = data.offsets.popper, refOffsets = data.offsets.reference, floor = Math.floor, overlapsRef = placement === "left" && floor(popperOffsets.right) > floor(refOffsets.left) || placement === "right" && floor(popperOffsets.left) < floor(refOffsets.right) || placement === "top" && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === "bottom" && floor(popperOffsets.top) < floor(refOffsets.bottom), overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left), overflowsRight = floor(popperOffsets.right) > floor(boundaries.right), overflowsTop = floor(popperOffsets.top) < floor(boundaries.top), overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom), overflowsBoundaries = placement === "left" && overflowsLeft || placement === "right" && overflowsRight || placement === "top" && overflowsTop || placement === "bottom" && overflowsBottom, isVertical = ["top", "bottom"].indexOf(placement) !== -1, flippedVariationByRef = !!options2.flipVariations && (isVertical && variation === "start" && overflowsLeft || isVertical && variation === "end" && overflowsRight || !isVertical && variation === "start" && overflowsTop || !isVertical && variation === "end" && overflowsBottom), flippedVariationByContent = !!options2.flipVariationsByContent && (isVertical && variation === "start" && overflowsRight || isVertical && variation === "end" && overflowsLeft || !isVertical && variation === "start" && overflowsBottom || !isVertical && variation === "end" && overflowsTop), flippedVariation = flippedVariationByRef || flippedVariationByContent;
  13981. (overlapsRef || overflowsBoundaries || flippedVariation) && (data.flipped = !0, (overlapsRef || overflowsBoundaries) && (placement = flipOrder[index + 1]), flippedVariation && (variation = getOppositeVariation(variation)), data.placement = placement + (variation ? "-" + variation : ""), data.offsets.popper = _extends2({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)), data = runModifiers(data.instance.modifiers, data, "flip"));
  13982. }), data;
  13983. }
  13984. function keepTogether(data) {
  13985. var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference, placement = data.placement.split("-")[0], floor = Math.floor, isVertical = ["top", "bottom"].indexOf(placement) !== -1, side = isVertical ? "right" : "bottom", opSide = isVertical ? "left" : "top", measurement = isVertical ? "width" : "height";
  13986. return popper[side] < floor(reference[opSide]) && (data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement]), popper[opSide] > floor(reference[side]) && (data.offsets.popper[opSide] = floor(reference[side])), data;
  13987. }
  13988. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  13989. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/), value = +split[1], unit = split[2];
  13990. if (!value)
  13991. return str;
  13992. if (unit.indexOf("%") === 0) {
  13993. var element = void 0;
  13994. switch (unit) {
  13995. case "%p":
  13996. element = popperOffsets;
  13997. break;
  13998. case "%":
  13999. case "%r":
  14000. default:
  14001. element = referenceOffsets;
  14002. }
  14003. var rect = getClientRect(element);
  14004. return rect[measurement] / 100 * value;
  14005. } else if (unit === "vh" || unit === "vw") {
  14006. var size = void 0;
  14007. return unit === "vh" ? size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) : size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0), size / 100 * value;
  14008. } else
  14009. return value;
  14010. }
  14011. function parseOffset(offset2, popperOffsets, referenceOffsets, basePlacement) {
  14012. var offsets = [0, 0], useHeight = ["right", "left"].indexOf(basePlacement) !== -1, fragments = offset2.split(/(\+|\-)/).map(function(frag) {
  14013. return frag.trim();
  14014. }), divider = fragments.indexOf(find(fragments, function(frag) {
  14015. return frag.search(/,|\s/) !== -1;
  14016. }));
  14017. fragments[divider] && fragments[divider].indexOf(",") === -1 && console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");
  14018. var splitRegex = /\s*,\s*|\s+/, ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
  14019. return ops = ops.map(function(op, index) {
  14020. var measurement = (index === 1 ? !useHeight : useHeight) ? "height" : "width", mergeWithPrevious = !1;
  14021. return op.reduce(function(a2, b2) {
  14022. return a2[a2.length - 1] === "" && ["+", "-"].indexOf(b2) !== -1 ? (a2[a2.length - 1] = b2, mergeWithPrevious = !0, a2) : mergeWithPrevious ? (a2[a2.length - 1] += b2, mergeWithPrevious = !1, a2) : a2.concat(b2);
  14023. }, []).map(function(str) {
  14024. return toValue(str, measurement, popperOffsets, referenceOffsets);
  14025. });
  14026. }), ops.forEach(function(op, index) {
  14027. op.forEach(function(frag, index2) {
  14028. isNumeric(frag) && (offsets[index] += frag * (op[index2 - 1] === "-" ? -1 : 1));
  14029. });
  14030. }), offsets;
  14031. }
  14032. function offset(data, _ref) {
  14033. var offset2 = _ref.offset, placement = data.placement, _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference, basePlacement = placement.split("-")[0], offsets = void 0;
  14034. return isNumeric(+offset2) ? offsets = [+offset2, 0] : offsets = parseOffset(offset2, popper, reference, basePlacement), basePlacement === "left" ? (popper.top += offsets[0], popper.left -= offsets[1]) : basePlacement === "right" ? (popper.top += offsets[0], popper.left += offsets[1]) : basePlacement === "top" ? (popper.left += offsets[0], popper.top -= offsets[1]) : basePlacement === "bottom" && (popper.left += offsets[0], popper.top += offsets[1]), data.popper = popper, data;
  14035. }
  14036. function preventOverflow(data, options2) {
  14037. var boundariesElement = options2.boundariesElement || getOffsetParent(data.instance.popper);
  14038. data.instance.reference === boundariesElement && (boundariesElement = getOffsetParent(boundariesElement));
  14039. var transformProp = getSupportedPropertyName("transform"), popperStyles = data.instance.popper.style, top = popperStyles.top, left = popperStyles.left, transform = popperStyles[transformProp];
  14040. popperStyles.top = "", popperStyles.left = "", popperStyles[transformProp] = "";
  14041. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options2.padding, boundariesElement, data.positionFixed);
  14042. popperStyles.top = top, popperStyles.left = left, popperStyles[transformProp] = transform, options2.boundaries = boundaries;
  14043. var order = options2.priority, popper = data.offsets.popper, check = {
  14044. primary: function(placement) {
  14045. var value = popper[placement];
  14046. return popper[placement] < boundaries[placement] && !options2.escapeWithReference && (value = Math.max(popper[placement], boundaries[placement])), defineProperty({}, placement, value);
  14047. },
  14048. secondary: function(placement) {
  14049. var mainSide = placement === "right" ? "left" : "top", value = popper[mainSide];
  14050. return popper[placement] > boundaries[placement] && !options2.escapeWithReference && (value = Math.min(popper[mainSide], boundaries[placement] - (placement === "right" ? popper.width : popper.height))), defineProperty({}, mainSide, value);
  14051. }
  14052. };
  14053. return order.forEach(function(placement) {
  14054. var side = ["left", "top"].indexOf(placement) !== -1 ? "primary" : "secondary";
  14055. popper = _extends2({}, popper, check[side](placement));
  14056. }), data.offsets.popper = popper, data;
  14057. }
  14058. function shift(data) {
  14059. var placement = data.placement, basePlacement = placement.split("-")[0], shiftvariation = placement.split("-")[1];
  14060. if (shiftvariation) {
  14061. var _data$offsets = data.offsets, reference = _data$offsets.reference, popper = _data$offsets.popper, isVertical = ["bottom", "top"].indexOf(basePlacement) !== -1, side = isVertical ? "left" : "top", measurement = isVertical ? "width" : "height", shiftOffsets = {
  14062. start: defineProperty({}, side, reference[side]),
  14063. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  14064. };
  14065. data.offsets.popper = _extends2({}, popper, shiftOffsets[shiftvariation]);
  14066. }
  14067. return data;
  14068. }
  14069. function hide(data) {
  14070. if (!isModifierRequired(data.instance.modifiers, "hide", "preventOverflow"))
  14071. return data;
  14072. var refRect = data.offsets.reference, bound = find(data.instance.modifiers, function(modifier) {
  14073. return modifier.name === "preventOverflow";
  14074. }).boundaries;
  14075. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  14076. if (data.hide === !0)
  14077. return data;
  14078. data.hide = !0, data.attributes["x-out-of-boundaries"] = "";
  14079. } else {
  14080. if (data.hide === !1)
  14081. return data;
  14082. data.hide = !1, data.attributes["x-out-of-boundaries"] = !1;
  14083. }
  14084. return data;
  14085. }
  14086. function inner(data) {
  14087. var placement = data.placement, basePlacement = placement.split("-")[0], _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference, isHoriz = ["left", "right"].indexOf(basePlacement) !== -1, subtractLength = ["top", "left"].indexOf(basePlacement) === -1;
  14088. return popper[isHoriz ? "left" : "top"] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? "width" : "height"] : 0), data.placement = getOppositePlacement(placement), data.offsets.popper = getClientRect(popper), data;
  14089. }
  14090. var modifiers = {
  14091. /**
  14092. * Modifier used to shift the popper on the start or end of its reference
  14093. * element.<br />
  14094. * It will read the variation of the `placement` property.<br />
  14095. * It can be one either `-end` or `-start`.
  14096. * @memberof modifiers
  14097. * @inner
  14098. */
  14099. shift: {
  14100. /** @prop {number} order=100 - Index used to define the order of execution */
  14101. order: 100,
  14102. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14103. enabled: !0,
  14104. /** @prop {ModifierFn} */
  14105. fn: shift
  14106. },
  14107. /**
  14108. * The `offset` modifier can shift your popper on both its axis.
  14109. *
  14110. * It accepts the following units:
  14111. * - `px` or unit-less, interpreted as pixels
  14112. * - `%` or `%r`, percentage relative to the length of the reference element
  14113. * - `%p`, percentage relative to the length of the popper element
  14114. * - `vw`, CSS viewport width unit
  14115. * - `vh`, CSS viewport height unit
  14116. *
  14117. * For length is intended the main axis relative to the placement of the popper.<br />
  14118. * This means that if the placement is `top` or `bottom`, the length will be the
  14119. * `width`. In case of `left` or `right`, it will be the `height`.
  14120. *
  14121. * You can provide a single value (as `Number` or `String`), or a pair of values
  14122. * as `String` divided by a comma or one (or more) white spaces.<br />
  14123. * The latter is a deprecated method because it leads to confusion and will be
  14124. * removed in v2.<br />
  14125. * Additionally, it accepts additions and subtractions between different units.
  14126. * Note that multiplications and divisions aren't supported.
  14127. *
  14128. * Valid examples are:
  14129. * ```
  14130. * 10
  14131. * '10%'
  14132. * '10, 10'
  14133. * '10%, 10'
  14134. * '10 + 10%'
  14135. * '10 - 5vh + 3%'
  14136. * '-10px + 5vh, 5px - 6%'
  14137. * ```
  14138. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  14139. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  14140. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  14141. *
  14142. * @memberof modifiers
  14143. * @inner
  14144. */
  14145. offset: {
  14146. /** @prop {number} order=200 - Index used to define the order of execution */
  14147. order: 200,
  14148. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14149. enabled: !0,
  14150. /** @prop {ModifierFn} */
  14151. fn: offset,
  14152. /** @prop {Number|String} offset=0
  14153. * The offset value as described in the modifier description
  14154. */
  14155. offset: 0
  14156. },
  14157. /**
  14158. * Modifier used to prevent the popper from being positioned outside the boundary.
  14159. *
  14160. * A scenario exists where the reference itself is not within the boundaries.<br />
  14161. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  14162. * In this case we need to decide whether the popper should either:
  14163. *
  14164. * - detach from the reference and remain "trapped" in the boundaries, or
  14165. * - if it should ignore the boundary and "escape with its reference"
  14166. *
  14167. * When `escapeWithReference` is set to`true` and reference is completely
  14168. * outside its boundaries, the popper will overflow (or completely leave)
  14169. * the boundaries in order to remain attached to the edge of the reference.
  14170. *
  14171. * @memberof modifiers
  14172. * @inner
  14173. */
  14174. preventOverflow: {
  14175. /** @prop {number} order=300 - Index used to define the order of execution */
  14176. order: 300,
  14177. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14178. enabled: !0,
  14179. /** @prop {ModifierFn} */
  14180. fn: preventOverflow,
  14181. /**
  14182. * @prop {Array} [priority=['left','right','top','bottom']]
  14183. * Popper will try to prevent overflow following these priorities by default,
  14184. * then, it could overflow on the left and on top of the `boundariesElement`
  14185. */
  14186. priority: ["left", "right", "top", "bottom"],
  14187. /**
  14188. * @prop {number} padding=5
  14189. * Amount of pixel used to define a minimum distance between the boundaries
  14190. * and the popper. This makes sure the popper always has a little padding
  14191. * between the edges of its container
  14192. */
  14193. padding: 5,
  14194. /**
  14195. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  14196. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  14197. * `viewport` or any DOM element.
  14198. */
  14199. boundariesElement: "scrollParent"
  14200. },
  14201. /**
  14202. * Modifier used to make sure the reference and its popper stay near each other
  14203. * without leaving any gap between the two. Especially useful when the arrow is
  14204. * enabled and you want to ensure that it points to its reference element.
  14205. * It cares only about the first axis. You can still have poppers with margin
  14206. * between the popper and its reference element.
  14207. * @memberof modifiers
  14208. * @inner
  14209. */
  14210. keepTogether: {
  14211. /** @prop {number} order=400 - Index used to define the order of execution */
  14212. order: 400,
  14213. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14214. enabled: !0,
  14215. /** @prop {ModifierFn} */
  14216. fn: keepTogether
  14217. },
  14218. /**
  14219. * This modifier is used to move the `arrowElement` of the popper to make
  14220. * sure it is positioned between the reference element and its popper element.
  14221. * It will read the outer size of the `arrowElement` node to detect how many
  14222. * pixels of conjunction are needed.
  14223. *
  14224. * It has no effect if no `arrowElement` is provided.
  14225. * @memberof modifiers
  14226. * @inner
  14227. */
  14228. arrow: {
  14229. /** @prop {number} order=500 - Index used to define the order of execution */
  14230. order: 500,
  14231. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14232. enabled: !0,
  14233. /** @prop {ModifierFn} */
  14234. fn: arrow,
  14235. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  14236. element: "[x-arrow]"
  14237. },
  14238. /**
  14239. * Modifier used to flip the popper's placement when it starts to overlap its
  14240. * reference element.
  14241. *
  14242. * Requires the `preventOverflow` modifier before it in order to work.
  14243. *
  14244. * **NOTE:** this modifier will interrupt the current update cycle and will
  14245. * restart it if it detects the need to flip the placement.
  14246. * @memberof modifiers
  14247. * @inner
  14248. */
  14249. flip: {
  14250. /** @prop {number} order=600 - Index used to define the order of execution */
  14251. order: 600,
  14252. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14253. enabled: !0,
  14254. /** @prop {ModifierFn} */
  14255. fn: flip,
  14256. /**
  14257. * @prop {String|Array} behavior='flip'
  14258. * The behavior used to change the popper's placement. It can be one of
  14259. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  14260. * placements (with optional variations)
  14261. */
  14262. behavior: "flip",
  14263. /**
  14264. * @prop {number} padding=5
  14265. * The popper will flip if it hits the edges of the `boundariesElement`
  14266. */
  14267. padding: 5,
  14268. /**
  14269. * @prop {String|HTMLElement} boundariesElement='viewport'
  14270. * The element which will define the boundaries of the popper position.
  14271. * The popper will never be placed outside of the defined boundaries
  14272. * (except if `keepTogether` is enabled)
  14273. */
  14274. boundariesElement: "viewport",
  14275. /**
  14276. * @prop {Boolean} flipVariations=false
  14277. * The popper will switch placement variation between `-start` and `-end` when
  14278. * the reference element overlaps its boundaries.
  14279. *
  14280. * The original placement should have a set variation.
  14281. */
  14282. flipVariations: !1,
  14283. /**
  14284. * @prop {Boolean} flipVariationsByContent=false
  14285. * The popper will switch placement variation between `-start` and `-end` when
  14286. * the popper element overlaps its reference boundaries.
  14287. *
  14288. * The original placement should have a set variation.
  14289. */
  14290. flipVariationsByContent: !1
  14291. },
  14292. /**
  14293. * Modifier used to make the popper flow toward the inner of the reference element.
  14294. * By default, when this modifier is disabled, the popper will be placed outside
  14295. * the reference element.
  14296. * @memberof modifiers
  14297. * @inner
  14298. */
  14299. inner: {
  14300. /** @prop {number} order=700 - Index used to define the order of execution */
  14301. order: 700,
  14302. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  14303. enabled: !1,
  14304. /** @prop {ModifierFn} */
  14305. fn: inner
  14306. },
  14307. /**
  14308. * Modifier used to hide the popper when its reference element is outside of the
  14309. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  14310. * be used to hide with a CSS selector the popper when its reference is
  14311. * out of boundaries.
  14312. *
  14313. * Requires the `preventOverflow` modifier before it in order to work.
  14314. * @memberof modifiers
  14315. * @inner
  14316. */
  14317. hide: {
  14318. /** @prop {number} order=800 - Index used to define the order of execution */
  14319. order: 800,
  14320. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14321. enabled: !0,
  14322. /** @prop {ModifierFn} */
  14323. fn: hide
  14324. },
  14325. /**
  14326. * Computes the style that will be applied to the popper element to gets
  14327. * properly positioned.
  14328. *
  14329. * Note that this modifier will not touch the DOM, it just prepares the styles
  14330. * so that `applyStyle` modifier can apply it. This separation is useful
  14331. * in case you need to replace `applyStyle` with a custom implementation.
  14332. *
  14333. * This modifier has `850` as `order` value to maintain backward compatibility
  14334. * with previous versions of Popper.js. Expect the modifiers ordering method
  14335. * to change in future major versions of the library.
  14336. *
  14337. * @memberof modifiers
  14338. * @inner
  14339. */
  14340. computeStyle: {
  14341. /** @prop {number} order=850 - Index used to define the order of execution */
  14342. order: 850,
  14343. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14344. enabled: !0,
  14345. /** @prop {ModifierFn} */
  14346. fn: computeStyle,
  14347. /**
  14348. * @prop {Boolean} gpuAcceleration=true
  14349. * If true, it uses the CSS 3D transformation to position the popper.
  14350. * Otherwise, it will use the `top` and `left` properties
  14351. */
  14352. gpuAcceleration: !0,
  14353. /**
  14354. * @prop {string} [x='bottom']
  14355. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  14356. * Change this if your popper should grow in a direction different from `bottom`
  14357. */
  14358. x: "bottom",
  14359. /**
  14360. * @prop {string} [x='left']
  14361. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  14362. * Change this if your popper should grow in a direction different from `right`
  14363. */
  14364. y: "right"
  14365. },
  14366. /**
  14367. * Applies the computed styles to the popper element.
  14368. *
  14369. * All the DOM manipulations are limited to this modifier. This is useful in case
  14370. * you want to integrate Popper.js inside a framework or view library and you
  14371. * want to delegate all the DOM manipulations to it.
  14372. *
  14373. * Note that if you disable this modifier, you must make sure the popper element
  14374. * has its position set to `absolute` before Popper.js can do its work!
  14375. *
  14376. * Just disable this modifier and define your own to achieve the desired effect.
  14377. *
  14378. * @memberof modifiers
  14379. * @inner
  14380. */
  14381. applyStyle: {
  14382. /** @prop {number} order=900 - Index used to define the order of execution */
  14383. order: 900,
  14384. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14385. enabled: !0,
  14386. /** @prop {ModifierFn} */
  14387. fn: applyStyle,
  14388. /** @prop {Function} */
  14389. onLoad: applyStyleOnLoad,
  14390. /**
  14391. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  14392. * @prop {Boolean} gpuAcceleration=true
  14393. * If true, it uses the CSS 3D transformation to position the popper.
  14394. * Otherwise, it will use the `top` and `left` properties
  14395. */
  14396. gpuAcceleration: void 0
  14397. }
  14398. }, Defaults = {
  14399. /**
  14400. * Popper's placement.
  14401. * @prop {Popper.placements} placement='bottom'
  14402. */
  14403. placement: "bottom",
  14404. /**
  14405. * Set this to true if you want popper to position it self in 'fixed' mode
  14406. * @prop {Boolean} positionFixed=false
  14407. */
  14408. positionFixed: !1,
  14409. /**
  14410. * Whether events (resize, scroll) are initially enabled.
  14411. * @prop {Boolean} eventsEnabled=true
  14412. */
  14413. eventsEnabled: !0,
  14414. /**
  14415. * Set to true if you want to automatically remove the popper when
  14416. * you call the `destroy` method.
  14417. * @prop {Boolean} removeOnDestroy=false
  14418. */
  14419. removeOnDestroy: !1,
  14420. /**
  14421. * Callback called when the popper is created.<br />
  14422. * By default, it is set to no-op.<br />
  14423. * Access Popper.js instance with `data.instance`.
  14424. * @prop {onCreate}
  14425. */
  14426. onCreate: function() {
  14427. },
  14428. /**
  14429. * Callback called when the popper is updated. This callback is not called
  14430. * on the initialization/creation of the popper, but only on subsequent
  14431. * updates.<br />
  14432. * By default, it is set to no-op.<br />
  14433. * Access Popper.js instance with `data.instance`.
  14434. * @prop {onUpdate}
  14435. */
  14436. onUpdate: function() {
  14437. },
  14438. /**
  14439. * List of modifiers used to modify the offsets before they are applied to the popper.
  14440. * They provide most of the functionalities of Popper.js.
  14441. * @prop {modifiers}
  14442. */
  14443. modifiers
  14444. }, Popper = (function() {
  14445. function Popper2(reference, popper) {
  14446. var _this = this, options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
  14447. classCallCheck(this, Popper2), this.scheduleUpdate = function() {
  14448. return requestAnimationFrame(_this.update);
  14449. }, this.update = debounce2(this.update.bind(this)), this.options = _extends2({}, Popper2.Defaults, options2), this.state = {
  14450. isDestroyed: !1,
  14451. isCreated: !1,
  14452. scrollParents: []
  14453. }, this.reference = reference && reference.jquery ? reference[0] : reference, this.popper = popper && popper.jquery ? popper[0] : popper, this.options.modifiers = {}, Object.keys(_extends2({}, Popper2.Defaults.modifiers, options2.modifiers)).forEach(function(name) {
  14454. _this.options.modifiers[name] = _extends2({}, Popper2.Defaults.modifiers[name] || {}, options2.modifiers ? options2.modifiers[name] : {});
  14455. }), this.modifiers = Object.keys(this.options.modifiers).map(function(name) {
  14456. return _extends2({
  14457. name
  14458. }, _this.options.modifiers[name]);
  14459. }).sort(function(a2, b2) {
  14460. return a2.order - b2.order;
  14461. }), this.modifiers.forEach(function(modifierOptions) {
  14462. modifierOptions.enabled && isFunction3(modifierOptions.onLoad) && modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  14463. }), this.update();
  14464. var eventsEnabled = this.options.eventsEnabled;
  14465. eventsEnabled && this.enableEventListeners(), this.state.eventsEnabled = eventsEnabled;
  14466. }
  14467. return createClass(Popper2, [{
  14468. key: "update",
  14469. value: function() {
  14470. return update.call(this);
  14471. }
  14472. }, {
  14473. key: "destroy",
  14474. value: function() {
  14475. return destroy.call(this);
  14476. }
  14477. }, {
  14478. key: "enableEventListeners",
  14479. value: function() {
  14480. return enableEventListeners.call(this);
  14481. }
  14482. }, {
  14483. key: "disableEventListeners",
  14484. value: function() {
  14485. return disableEventListeners.call(this);
  14486. }
  14487. /**
  14488. * Schedules an update. It will run on the next UI update available.
  14489. * @method scheduleUpdate
  14490. * @memberof Popper
  14491. */
  14492. /**
  14493. * Collection of utilities useful when writing custom modifiers.
  14494. * Starting from version 1.7, this method is available only if you
  14495. * include `popper-utils.js` before `popper.js`.
  14496. *
  14497. * **DEPRECATION**: This way to access PopperUtils is deprecated
  14498. * and will be removed in v2! Use the PopperUtils module directly instead.
  14499. * Due to the high instability of the methods contained in Utils, we can't
  14500. * guarantee them to follow semver. Use them at your own risk!
  14501. * @static
  14502. * @private
  14503. * @type {Object}
  14504. * @deprecated since version 1.8
  14505. * @member Utils
  14506. * @memberof Popper
  14507. */
  14508. }]), Popper2;
  14509. })();
  14510. Popper.Utils = (typeof window < "u" ? window : global).PopperUtils;
  14511. Popper.placements = placements;
  14512. Popper.Defaults = Defaults;
  14513. var popper_default = Popper;
  14514. // ../../node_modules/react-floater/es/index.js
  14515. var import_deepmerge = __toESM(require_cjs());
  14516. // ../../node_modules/react-floater/node_modules/is-lite/esm/index.js
  14517. var DOM_PROPERTIES_TO_CHECK2 = [
  14518. "innerHTML",
  14519. "ownerDocument",
  14520. "style",
  14521. "attributes",
  14522. "nodeValue"
  14523. ], objectTypes2 = [
  14524. "Array",
  14525. "ArrayBuffer",
  14526. "AsyncFunction",
  14527. "AsyncGenerator",
  14528. "AsyncGeneratorFunction",
  14529. "Date",
  14530. "Error",
  14531. "Function",
  14532. "Generator",
  14533. "GeneratorFunction",
  14534. "HTMLElement",
  14535. "Map",
  14536. "Object",
  14537. "Promise",
  14538. "RegExp",
  14539. "Set",
  14540. "WeakMap",
  14541. "WeakSet"
  14542. ], primitiveTypes2 = [
  14543. "bigint",
  14544. "boolean",
  14545. "null",
  14546. "number",
  14547. "string",
  14548. "symbol",
  14549. "undefined"
  14550. ];
  14551. function getObjectType2(value) {
  14552. var objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  14553. if (/HTML\w+Element/.test(objectTypeName))
  14554. return "HTMLElement";
  14555. if (isObjectType2(objectTypeName))
  14556. return objectTypeName;
  14557. }
  14558. function isObjectOfType2(type) {
  14559. return function(value) {
  14560. return getObjectType2(value) === type;
  14561. };
  14562. }
  14563. function isObjectType2(name) {
  14564. return objectTypes2.includes(name);
  14565. }
  14566. function isOfType3(type) {
  14567. return function(value) {
  14568. return typeof value === type;
  14569. };
  14570. }
  14571. function isPrimitiveType2(name) {
  14572. return primitiveTypes2.includes(name);
  14573. }
  14574. function is2(value) {
  14575. if (value === null)
  14576. return "null";
  14577. switch (typeof value) {
  14578. case "bigint":
  14579. return "bigint";
  14580. case "boolean":
  14581. return "boolean";
  14582. case "number":
  14583. return "number";
  14584. case "string":
  14585. return "string";
  14586. case "symbol":
  14587. return "symbol";
  14588. case "undefined":
  14589. return "undefined";
  14590. default:
  14591. }
  14592. if (is2.array(value))
  14593. return "Array";
  14594. if (is2.plainFunction(value))
  14595. return "Function";
  14596. var tagType = getObjectType2(value);
  14597. return tagType || "Object";
  14598. }
  14599. is2.array = Array.isArray;
  14600. is2.arrayOf = function(target, predicate) {
  14601. return !is2.array(target) && !is2.function(predicate) ? !1 : target.every(function(d2) {
  14602. return predicate(d2);
  14603. });
  14604. };
  14605. is2.asyncGeneratorFunction = function(value) {
  14606. return getObjectType2(value) === "AsyncGeneratorFunction";
  14607. };
  14608. is2.asyncFunction = isObjectOfType2("AsyncFunction");
  14609. is2.bigint = isOfType3("bigint");
  14610. is2.boolean = function(value) {
  14611. return value === !0 || value === !1;
  14612. };
  14613. is2.date = isObjectOfType2("Date");
  14614. is2.defined = function(value) {
  14615. return !is2.undefined(value);
  14616. };
  14617. is2.domElement = function(value) {
  14618. return is2.object(value) && !is2.plainObject(value) && value.nodeType === 1 && is2.string(value.nodeName) && DOM_PROPERTIES_TO_CHECK2.every(function(property) {
  14619. return property in value;
  14620. });
  14621. };
  14622. is2.empty = function(value) {
  14623. return is2.string(value) && value.length === 0 || is2.array(value) && value.length === 0 || is2.object(value) && !is2.map(value) && !is2.set(value) && Object.keys(value).length === 0 || is2.set(value) && value.size === 0 || is2.map(value) && value.size === 0;
  14624. };
  14625. is2.error = isObjectOfType2("Error");
  14626. is2.function = isOfType3("function");
  14627. is2.generator = function(value) {
  14628. return is2.iterable(value) && is2.function(value.next) && is2.function(value.throw);
  14629. };
  14630. is2.generatorFunction = isObjectOfType2("GeneratorFunction");
  14631. is2.instanceOf = function(instance, class_) {
  14632. return !instance || !class_ ? !1 : Object.getPrototypeOf(instance) === class_.prototype;
  14633. };
  14634. is2.iterable = function(value) {
  14635. return !is2.nullOrUndefined(value) && is2.function(value[Symbol.iterator]);
  14636. };
  14637. is2.map = isObjectOfType2("Map");
  14638. is2.nan = function(value) {
  14639. return Number.isNaN(value);
  14640. };
  14641. is2.null = function(value) {
  14642. return value === null;
  14643. };
  14644. is2.nullOrUndefined = function(value) {
  14645. return is2.null(value) || is2.undefined(value);
  14646. };
  14647. is2.number = function(value) {
  14648. return isOfType3("number")(value) && !is2.nan(value);
  14649. };
  14650. is2.numericString = function(value) {
  14651. return is2.string(value) && value.length > 0 && !Number.isNaN(Number(value));
  14652. };
  14653. is2.object = function(value) {
  14654. return !is2.nullOrUndefined(value) && (is2.function(value) || typeof value == "object");
  14655. };
  14656. is2.oneOf = function(target, value) {
  14657. return is2.array(target) ? target.indexOf(value) > -1 : !1;
  14658. };
  14659. is2.plainFunction = isObjectOfType2("Function");
  14660. is2.plainObject = function(value) {
  14661. if (getObjectType2(value) !== "Object")
  14662. return !1;
  14663. var prototype = Object.getPrototypeOf(value);
  14664. return prototype === null || prototype === Object.getPrototypeOf({});
  14665. };
  14666. is2.primitive = function(value) {
  14667. return is2.null(value) || isPrimitiveType2(typeof value);
  14668. };
  14669. is2.promise = isObjectOfType2("Promise");
  14670. is2.propertyOf = function(target, key, predicate) {
  14671. if (!is2.object(target) || !key)
  14672. return !1;
  14673. var value = target[key];
  14674. return is2.function(predicate) ? predicate(value) : is2.defined(value);
  14675. };
  14676. is2.regexp = isObjectOfType2("RegExp");
  14677. is2.set = isObjectOfType2("Set");
  14678. is2.string = isOfType3("string");
  14679. is2.symbol = isOfType3("symbol");
  14680. is2.undefined = isOfType3("undefined");
  14681. is2.weakMap = isObjectOfType2("WeakMap");
  14682. is2.weakSet = isObjectOfType2("WeakSet");
  14683. var esm_default = is2;
  14684. // ../../node_modules/tree-changes/node_modules/@gilbarbara/deep-equal/esm/helpers.js
  14685. function isOfType4(type) {
  14686. return function(value) {
  14687. return typeof value === type;
  14688. };
  14689. }
  14690. var isFunction4 = isOfType4("function"), isNull3 = function(value) {
  14691. return value === null;
  14692. }, isRegex2 = function(value) {
  14693. return Object.prototype.toString.call(value).slice(8, -1) === "RegExp";
  14694. }, isObject2 = function(value) {
  14695. return !isUndefined3(value) && !isNull3(value) && (isFunction4(value) || typeof value == "object");
  14696. }, isUndefined3 = isOfType4("undefined");
  14697. // ../../node_modules/tree-changes/node_modules/@gilbarbara/deep-equal/esm/index.js
  14698. var __values = function(o3) {
  14699. var s2 = typeof Symbol == "function" && Symbol.iterator, m2 = s2 && o3[s2], i2 = 0;
  14700. if (m2) return m2.call(o3);
  14701. if (o3 && typeof o3.length == "number") return {
  14702. next: function() {
  14703. return o3 && i2 >= o3.length && (o3 = void 0), { value: o3 && o3[i2++], done: !o3 };
  14704. }
  14705. };
  14706. throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined.");
  14707. };
  14708. function equalArray2(left, right) {
  14709. var length = left.length;
  14710. if (length !== right.length)
  14711. return !1;
  14712. for (var index = length; index-- !== 0; )
  14713. if (!equal2(left[index], right[index]))
  14714. return !1;
  14715. return !0;
  14716. }
  14717. function equalArrayBuffer2(left, right) {
  14718. if (left.byteLength !== right.byteLength)
  14719. return !1;
  14720. for (var view1 = new DataView(left.buffer), view2 = new DataView(right.buffer), index = left.byteLength; index--; )
  14721. if (view1.getUint8(index) !== view2.getUint8(index))
  14722. return !1;
  14723. return !0;
  14724. }
  14725. function equalMap2(left, right) {
  14726. var e_1, _a2, e_2, _b;
  14727. if (left.size !== right.size)
  14728. return !1;
  14729. try {
  14730. for (var _c = __values(left.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
  14731. var index = _d.value;
  14732. if (!right.has(index[0]))
  14733. return !1;
  14734. }
  14735. } catch (e_1_1) {
  14736. e_1 = { error: e_1_1 };
  14737. } finally {
  14738. try {
  14739. _d && !_d.done && (_a2 = _c.return) && _a2.call(_c);
  14740. } finally {
  14741. if (e_1) throw e_1.error;
  14742. }
  14743. }
  14744. try {
  14745. for (var _e = __values(left.entries()), _f = _e.next(); !_f.done; _f = _e.next()) {
  14746. var index = _f.value;
  14747. if (!equal2(index[1], right.get(index[0])))
  14748. return !1;
  14749. }
  14750. } catch (e_2_1) {
  14751. e_2 = { error: e_2_1 };
  14752. } finally {
  14753. try {
  14754. _f && !_f.done && (_b = _e.return) && _b.call(_e);
  14755. } finally {
  14756. if (e_2) throw e_2.error;
  14757. }
  14758. }
  14759. return !0;
  14760. }
  14761. function equalSet2(left, right) {
  14762. var e_3, _a2;
  14763. if (left.size !== right.size)
  14764. return !1;
  14765. try {
  14766. for (var _b = __values(left.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
  14767. var index = _c.value;
  14768. if (!right.has(index[0]))
  14769. return !1;
  14770. }
  14771. } catch (e_3_1) {
  14772. e_3 = { error: e_3_1 };
  14773. } finally {
  14774. try {
  14775. _c && !_c.done && (_a2 = _b.return) && _a2.call(_b);
  14776. } finally {
  14777. if (e_3) throw e_3.error;
  14778. }
  14779. }
  14780. return !0;
  14781. }
  14782. function equal2(left, right) {
  14783. if (left === right)
  14784. return !0;
  14785. if (left && isObject2(left) && right && isObject2(right)) {
  14786. if (left.constructor !== right.constructor)
  14787. return !1;
  14788. if (Array.isArray(left) && Array.isArray(right))
  14789. return equalArray2(left, right);
  14790. if (left instanceof Map && right instanceof Map)
  14791. return equalMap2(left, right);
  14792. if (left instanceof Set && right instanceof Set)
  14793. return equalSet2(left, right);
  14794. if (ArrayBuffer.isView(left) && ArrayBuffer.isView(right))
  14795. return equalArrayBuffer2(left, right);
  14796. if (isRegex2(left) && isRegex2(right))
  14797. return left.source === right.source && left.flags === right.flags;
  14798. if (left.valueOf !== Object.prototype.valueOf)
  14799. return left.valueOf() === right.valueOf();
  14800. if (left.toString !== Object.prototype.toString)
  14801. return left.toString() === right.toString();
  14802. var leftKeys = Object.keys(left), rightKeys = Object.keys(right);
  14803. if (leftKeys.length !== rightKeys.length)
  14804. return !1;
  14805. for (var index = leftKeys.length; index-- !== 0; )
  14806. if (!Object.prototype.hasOwnProperty.call(right, leftKeys[index]))
  14807. return !1;
  14808. for (var index = leftKeys.length; index-- !== 0; ) {
  14809. var key = leftKeys[index];
  14810. if (!(key === "_owner" && left.$$typeof) && !equal2(left[key], right[key]))
  14811. return !1;
  14812. }
  14813. return !0;
  14814. }
  14815. return Number.isNaN(left) && Number.isNaN(right) ? !0 : left === right;
  14816. }
  14817. // ../../node_modules/tree-changes/node_modules/is-lite/esm/index.js
  14818. var DOM_PROPERTIES_TO_CHECK3 = [
  14819. "innerHTML",
  14820. "ownerDocument",
  14821. "style",
  14822. "attributes",
  14823. "nodeValue"
  14824. ], objectTypes3 = [
  14825. "Array",
  14826. "ArrayBuffer",
  14827. "AsyncFunction",
  14828. "AsyncGenerator",
  14829. "AsyncGeneratorFunction",
  14830. "Date",
  14831. "Error",
  14832. "Function",
  14833. "Generator",
  14834. "GeneratorFunction",
  14835. "HTMLElement",
  14836. "Map",
  14837. "Object",
  14838. "Promise",
  14839. "RegExp",
  14840. "Set",
  14841. "WeakMap",
  14842. "WeakSet"
  14843. ], primitiveTypes3 = [
  14844. "bigint",
  14845. "boolean",
  14846. "null",
  14847. "number",
  14848. "string",
  14849. "symbol",
  14850. "undefined"
  14851. ];
  14852. function getObjectType3(value) {
  14853. var objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  14854. if (/HTML\w+Element/.test(objectTypeName))
  14855. return "HTMLElement";
  14856. if (isObjectType3(objectTypeName))
  14857. return objectTypeName;
  14858. }
  14859. function isObjectOfType3(type) {
  14860. return function(value) {
  14861. return getObjectType3(value) === type;
  14862. };
  14863. }
  14864. function isObjectType3(name) {
  14865. return objectTypes3.includes(name);
  14866. }
  14867. function isOfType5(type) {
  14868. return function(value) {
  14869. return typeof value === type;
  14870. };
  14871. }
  14872. function isPrimitiveType3(name) {
  14873. return primitiveTypes3.includes(name);
  14874. }
  14875. function is3(value) {
  14876. if (value === null)
  14877. return "null";
  14878. switch (typeof value) {
  14879. case "bigint":
  14880. return "bigint";
  14881. case "boolean":
  14882. return "boolean";
  14883. case "number":
  14884. return "number";
  14885. case "string":
  14886. return "string";
  14887. case "symbol":
  14888. return "symbol";
  14889. case "undefined":
  14890. return "undefined";
  14891. default:
  14892. }
  14893. if (is3.array(value))
  14894. return "Array";
  14895. if (is3.plainFunction(value))
  14896. return "Function";
  14897. var tagType = getObjectType3(value);
  14898. return tagType || "Object";
  14899. }
  14900. is3.array = Array.isArray;
  14901. is3.arrayOf = function(target, predicate) {
  14902. return !is3.array(target) && !is3.function(predicate) ? !1 : target.every(function(d2) {
  14903. return predicate(d2);
  14904. });
  14905. };
  14906. is3.asyncGeneratorFunction = function(value) {
  14907. return getObjectType3(value) === "AsyncGeneratorFunction";
  14908. };
  14909. is3.asyncFunction = isObjectOfType3("AsyncFunction");
  14910. is3.bigint = isOfType5("bigint");
  14911. is3.boolean = function(value) {
  14912. return value === !0 || value === !1;
  14913. };
  14914. is3.date = isObjectOfType3("Date");
  14915. is3.defined = function(value) {
  14916. return !is3.undefined(value);
  14917. };
  14918. is3.domElement = function(value) {
  14919. return is3.object(value) && !is3.plainObject(value) && value.nodeType === 1 && is3.string(value.nodeName) && DOM_PROPERTIES_TO_CHECK3.every(function(property) {
  14920. return property in value;
  14921. });
  14922. };
  14923. is3.empty = function(value) {
  14924. return is3.string(value) && value.length === 0 || is3.array(value) && value.length === 0 || is3.object(value) && !is3.map(value) && !is3.set(value) && Object.keys(value).length === 0 || is3.set(value) && value.size === 0 || is3.map(value) && value.size === 0;
  14925. };
  14926. is3.error = isObjectOfType3("Error");
  14927. is3.function = isOfType5("function");
  14928. is3.generator = function(value) {
  14929. return is3.iterable(value) && is3.function(value.next) && is3.function(value.throw);
  14930. };
  14931. is3.generatorFunction = isObjectOfType3("GeneratorFunction");
  14932. is3.instanceOf = function(instance, class_) {
  14933. return !instance || !class_ ? !1 : Object.getPrototypeOf(instance) === class_.prototype;
  14934. };
  14935. is3.iterable = function(value) {
  14936. return !is3.nullOrUndefined(value) && is3.function(value[Symbol.iterator]);
  14937. };
  14938. is3.map = isObjectOfType3("Map");
  14939. is3.nan = function(value) {
  14940. return Number.isNaN(value);
  14941. };
  14942. is3.null = function(value) {
  14943. return value === null;
  14944. };
  14945. is3.nullOrUndefined = function(value) {
  14946. return is3.null(value) || is3.undefined(value);
  14947. };
  14948. is3.number = function(value) {
  14949. return isOfType5("number")(value) && !is3.nan(value);
  14950. };
  14951. is3.numericString = function(value) {
  14952. return is3.string(value) && value.length > 0 && !Number.isNaN(Number(value));
  14953. };
  14954. is3.object = function(value) {
  14955. return !is3.nullOrUndefined(value) && (is3.function(value) || typeof value == "object");
  14956. };
  14957. is3.oneOf = function(target, value) {
  14958. return is3.array(target) ? target.indexOf(value) > -1 : !1;
  14959. };
  14960. is3.plainFunction = isObjectOfType3("Function");
  14961. is3.plainObject = function(value) {
  14962. if (getObjectType3(value) !== "Object")
  14963. return !1;
  14964. var prototype = Object.getPrototypeOf(value);
  14965. return prototype === null || prototype === Object.getPrototypeOf({});
  14966. };
  14967. is3.primitive = function(value) {
  14968. return is3.null(value) || isPrimitiveType3(typeof value);
  14969. };
  14970. is3.promise = isObjectOfType3("Promise");
  14971. is3.propertyOf = function(target, key, predicate) {
  14972. if (!is3.object(target) || !key)
  14973. return !1;
  14974. var value = target[key];
  14975. return is3.function(predicate) ? predicate(value) : is3.defined(value);
  14976. };
  14977. is3.regexp = isObjectOfType3("RegExp");
  14978. is3.set = isObjectOfType3("Set");
  14979. is3.string = isOfType5("string");
  14980. is3.symbol = isOfType5("symbol");
  14981. is3.undefined = isOfType5("undefined");
  14982. is3.weakMap = isObjectOfType3("WeakMap");
  14983. is3.weakSet = isObjectOfType3("WeakSet");
  14984. var esm_default2 = is3;
  14985. // ../../node_modules/tree-changes/esm/helpers.js
  14986. function canHaveLength2() {
  14987. for (var arguments_ = [], _i = 0; _i < arguments.length; _i++)
  14988. arguments_[_i] = arguments[_i];
  14989. return arguments_.every(function(d2) {
  14990. return esm_default2.string(d2) || esm_default2.array(d2) || esm_default2.plainObject(d2);
  14991. });
  14992. }
  14993. function checkEquality2(left, right, value) {
  14994. return isSameType2(left, right) ? [left, right].every(esm_default2.array) ? !left.some(hasValue2(value)) && right.some(hasValue2(value)) : [left, right].every(esm_default2.plainObject) ? !Object.entries(left).some(hasEntry2(value)) && Object.entries(right).some(hasEntry2(value)) : right === value : !1;
  14995. }
  14996. function compareNumbers2(previousData, data, options2) {
  14997. var actual = options2.actual, key = options2.key, previous = options2.previous, type = options2.type, left = nested2(previousData, key), right = nested2(data, key), changed = [left, right].every(esm_default2.number) && (type === "increased" ? left < right : left > right);
  14998. return esm_default2.undefined(actual) || (changed = changed && right === actual), esm_default2.undefined(previous) || (changed = changed && left === previous), changed;
  14999. }
  15000. function compareValues2(previousData, data, options2) {
  15001. var key = options2.key, type = options2.type, value = options2.value, left = nested2(previousData, key), right = nested2(data, key), primary = type === "added" ? left : right, secondary = type === "added" ? right : left;
  15002. if (!esm_default2.nullOrUndefined(value)) {
  15003. if (esm_default2.defined(primary)) {
  15004. if (esm_default2.array(primary) || esm_default2.plainObject(primary))
  15005. return checkEquality2(primary, secondary, value);
  15006. } else
  15007. return equal2(secondary, value);
  15008. return !1;
  15009. }
  15010. return [left, right].every(esm_default2.array) ? !secondary.every(isEqualPredicate2(primary)) : [left, right].every(esm_default2.plainObject) ? hasExtraKeys2(Object.keys(primary), Object.keys(secondary)) : ![left, right].every(function(d2) {
  15011. return esm_default2.primitive(d2) && esm_default2.defined(d2);
  15012. }) && (type === "added" ? !esm_default2.defined(left) && esm_default2.defined(right) : esm_default2.defined(left) && !esm_default2.defined(right));
  15013. }
  15014. function getIterables2(previousData, data, _a2) {
  15015. var _b = _a2 === void 0 ? {} : _a2, key = _b.key, left = nested2(previousData, key), right = nested2(data, key);
  15016. if (!isSameType2(left, right))
  15017. throw new TypeError("Inputs have different types");
  15018. if (!canHaveLength2(left, right))
  15019. throw new TypeError("Inputs don't have length");
  15020. return [left, right].every(esm_default2.plainObject) && (left = Object.keys(left), right = Object.keys(right)), [left, right];
  15021. }
  15022. function hasEntry2(input) {
  15023. return function(_a2) {
  15024. var key = _a2[0], value = _a2[1];
  15025. return esm_default2.array(input) ? equal2(input, value) || input.some(function(d2) {
  15026. return equal2(d2, value) || esm_default2.array(value) && isEqualPredicate2(value)(d2);
  15027. }) : esm_default2.plainObject(input) && input[key] ? !!input[key] && equal2(input[key], value) : equal2(input, value);
  15028. };
  15029. }
  15030. function hasExtraKeys2(left, right) {
  15031. return right.some(function(d2) {
  15032. return !left.includes(d2);
  15033. });
  15034. }
  15035. function hasValue2(input) {
  15036. return function(value) {
  15037. return esm_default2.array(input) ? input.some(function(d2) {
  15038. return equal2(d2, value) || esm_default2.array(value) && isEqualPredicate2(value)(d2);
  15039. }) : equal2(input, value);
  15040. };
  15041. }
  15042. function includesOrEqualsTo2(previousValue, value) {
  15043. return esm_default2.array(previousValue) ? previousValue.some(function(d2) {
  15044. return equal2(d2, value);
  15045. }) : equal2(previousValue, value);
  15046. }
  15047. function isEqualPredicate2(data) {
  15048. return function(value) {
  15049. return data.some(function(d2) {
  15050. return equal2(d2, value);
  15051. });
  15052. };
  15053. }
  15054. function isSameType2() {
  15055. for (var arguments_ = [], _i = 0; _i < arguments.length; _i++)
  15056. arguments_[_i] = arguments[_i];
  15057. return arguments_.every(esm_default2.array) || arguments_.every(esm_default2.number) || arguments_.every(esm_default2.plainObject) || arguments_.every(esm_default2.string);
  15058. }
  15059. function nested2(data, property) {
  15060. if (esm_default2.plainObject(data) || esm_default2.array(data)) {
  15061. if (esm_default2.string(property)) {
  15062. var props = property.split(".");
  15063. return props.reduce(function(acc, d2) {
  15064. return acc && acc[d2];
  15065. }, data);
  15066. }
  15067. return esm_default2.number(property) ? data[property] : data;
  15068. }
  15069. return data;
  15070. }
  15071. // ../../node_modules/tree-changes/esm/index.js
  15072. function treeChanges2(previousData, data) {
  15073. if ([previousData, data].some(esm_default2.nullOrUndefined))
  15074. throw new Error("Missing required parameters");
  15075. if (![previousData, data].every(function(d2) {
  15076. return esm_default2.plainObject(d2) || esm_default2.array(d2);
  15077. }))
  15078. throw new Error("Expected plain objects or array");
  15079. var added = function(key, value) {
  15080. try {
  15081. return compareValues2(previousData, data, { key, type: "added", value });
  15082. } catch {
  15083. return !1;
  15084. }
  15085. }, changed = function(key, actual, previous) {
  15086. try {
  15087. var left = nested2(previousData, key), right = nested2(data, key), hasActual = esm_default2.defined(actual), hasPrevious = esm_default2.defined(previous);
  15088. if (hasActual || hasPrevious) {
  15089. var leftComparator = hasPrevious ? includesOrEqualsTo2(previous, left) : !includesOrEqualsTo2(actual, left), rightComparator = includesOrEqualsTo2(actual, right);
  15090. return leftComparator && rightComparator;
  15091. }
  15092. return [left, right].every(esm_default2.array) || [left, right].every(esm_default2.plainObject) ? !equal2(left, right) : left !== right;
  15093. } catch {
  15094. return !1;
  15095. }
  15096. }, changedFrom = function(key, previous, actual) {
  15097. if (!esm_default2.defined(key))
  15098. return !1;
  15099. try {
  15100. var left = nested2(previousData, key), right = nested2(data, key), hasActual = esm_default2.defined(actual);
  15101. return includesOrEqualsTo2(previous, left) && (hasActual ? includesOrEqualsTo2(actual, right) : !hasActual);
  15102. } catch {
  15103. return !1;
  15104. }
  15105. }, changedTo = function(key, actual) {
  15106. return esm_default2.defined(key) ? changed(key, actual) : !1;
  15107. }, decreased = function(key, actual, previous) {
  15108. if (!esm_default2.defined(key))
  15109. return !1;
  15110. try {
  15111. return compareNumbers2(previousData, data, { key, actual, previous, type: "decreased" });
  15112. } catch {
  15113. return !1;
  15114. }
  15115. }, emptied = function(key) {
  15116. try {
  15117. var _a2 = getIterables2(previousData, data, { key }), left = _a2[0], right = _a2[1];
  15118. return !!left.length && !right.length;
  15119. } catch {
  15120. return !1;
  15121. }
  15122. }, filled = function(key) {
  15123. try {
  15124. var _a2 = getIterables2(previousData, data, { key }), left = _a2[0], right = _a2[1];
  15125. return !left.length && !!right.length;
  15126. } catch {
  15127. return !1;
  15128. }
  15129. }, increased = function(key, actual, previous) {
  15130. if (!esm_default2.defined(key))
  15131. return !1;
  15132. try {
  15133. return compareNumbers2(previousData, data, { key, actual, previous, type: "increased" });
  15134. } catch {
  15135. return !1;
  15136. }
  15137. }, removed = function(key, value) {
  15138. try {
  15139. return compareValues2(previousData, data, { key, type: "removed", value });
  15140. } catch {
  15141. return !1;
  15142. }
  15143. };
  15144. return { added, changed, changedFrom, changedTo, decreased, emptied, filled, increased, removed };
  15145. }
  15146. // ../../node_modules/react-floater/es/index.js
  15147. function ownKeys(e2, r4) {
  15148. var t2 = Object.keys(e2);
  15149. if (Object.getOwnPropertySymbols) {
  15150. var o3 = Object.getOwnPropertySymbols(e2);
  15151. r4 && (o3 = o3.filter(function(r5) {
  15152. return Object.getOwnPropertyDescriptor(e2, r5).enumerable;
  15153. })), t2.push.apply(t2, o3);
  15154. }
  15155. return t2;
  15156. }
  15157. function _objectSpread2(e2) {
  15158. for (var r4 = 1; r4 < arguments.length; r4++) {
  15159. var t2 = arguments[r4] != null ? arguments[r4] : {};
  15160. r4 % 2 ? ownKeys(Object(t2), !0).forEach(function(r5) {
  15161. _defineProperty(e2, r5, t2[r5]);
  15162. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys(Object(t2)).forEach(function(r5) {
  15163. Object.defineProperty(e2, r5, Object.getOwnPropertyDescriptor(t2, r5));
  15164. });
  15165. }
  15166. return e2;
  15167. }
  15168. function _classCallCheck(instance, Constructor) {
  15169. if (!(instance instanceof Constructor))
  15170. throw new TypeError("Cannot call a class as a function");
  15171. }
  15172. function _defineProperties(target, props) {
  15173. for (var i2 = 0; i2 < props.length; i2++) {
  15174. var descriptor = props[i2];
  15175. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
  15176. }
  15177. }
  15178. function _createClass(Constructor, protoProps, staticProps) {
  15179. return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  15180. writable: !1
  15181. }), Constructor;
  15182. }
  15183. function _defineProperty(obj, key, value) {
  15184. return key = _toPropertyKey(key), key in obj ? Object.defineProperty(obj, key, {
  15185. value,
  15186. enumerable: !0,
  15187. configurable: !0,
  15188. writable: !0
  15189. }) : obj[key] = value, obj;
  15190. }
  15191. function _inherits(subClass, superClass) {
  15192. if (typeof superClass != "function" && superClass !== null)
  15193. throw new TypeError("Super expression must either be null or a function");
  15194. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15195. constructor: {
  15196. value: subClass,
  15197. writable: !0,
  15198. configurable: !0
  15199. }
  15200. }), Object.defineProperty(subClass, "prototype", {
  15201. writable: !1
  15202. }), superClass && _setPrototypeOf2(subClass, superClass);
  15203. }
  15204. function _getPrototypeOf2(o3) {
  15205. return _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o4) {
  15206. return o4.__proto__ || Object.getPrototypeOf(o4);
  15207. }, _getPrototypeOf2(o3);
  15208. }
  15209. function _setPrototypeOf2(o3, p2) {
  15210. return _setPrototypeOf2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o4, p3) {
  15211. return o4.__proto__ = p3, o4;
  15212. }, _setPrototypeOf2(o3, p2);
  15213. }
  15214. function _isNativeReflectConstruct2() {
  15215. if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
  15216. if (typeof Proxy == "function") return !0;
  15217. try {
  15218. return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
  15219. })), !0;
  15220. } catch {
  15221. return !1;
  15222. }
  15223. }
  15224. function _objectWithoutPropertiesLoose(source, excluded) {
  15225. if (source == null) return {};
  15226. var target = {}, sourceKeys = Object.keys(source), key, i2;
  15227. for (i2 = 0; i2 < sourceKeys.length; i2++)
  15228. key = sourceKeys[i2], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
  15229. return target;
  15230. }
  15231. function _objectWithoutProperties(source, excluded) {
  15232. if (source == null) return {};
  15233. var target = _objectWithoutPropertiesLoose(source, excluded), key, i2;
  15234. if (Object.getOwnPropertySymbols) {
  15235. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  15236. for (i2 = 0; i2 < sourceSymbolKeys.length; i2++)
  15237. key = sourceSymbolKeys[i2], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
  15238. }
  15239. return target;
  15240. }
  15241. function _assertThisInitialized2(self2) {
  15242. if (self2 === void 0)
  15243. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15244. return self2;
  15245. }
  15246. function _possibleConstructorReturn(self2, call) {
  15247. if (call && (typeof call == "object" || typeof call == "function"))
  15248. return call;
  15249. if (call !== void 0)
  15250. throw new TypeError("Derived constructors may only return object or undefined");
  15251. return _assertThisInitialized2(self2);
  15252. }
  15253. function _createSuper(Derived) {
  15254. var hasNativeReflectConstruct = _isNativeReflectConstruct2();
  15255. return function() {
  15256. var Super = _getPrototypeOf2(Derived), result;
  15257. if (hasNativeReflectConstruct) {
  15258. var NewTarget = _getPrototypeOf2(this).constructor;
  15259. result = Reflect.construct(Super, arguments, NewTarget);
  15260. } else
  15261. result = Super.apply(this, arguments);
  15262. return _possibleConstructorReturn(this, result);
  15263. };
  15264. }
  15265. function _toPrimitive(input, hint) {
  15266. if (typeof input != "object" || input === null) return input;
  15267. var prim = input[Symbol.toPrimitive];
  15268. if (prim !== void 0) {
  15269. var res = prim.call(input, hint || "default");
  15270. if (typeof res != "object") return res;
  15271. throw new TypeError("@@toPrimitive must return a primitive value.");
  15272. }
  15273. return (hint === "string" ? String : Number)(input);
  15274. }
  15275. function _toPropertyKey(arg) {
  15276. var key = _toPrimitive(arg, "string");
  15277. return typeof key == "symbol" ? key : String(key);
  15278. }
  15279. var DEFAULTS = { flip: { padding: 20 }, preventOverflow: { padding: 10 } }, VALIDATOR_ARG_ERROR_MESSAGE = "The typeValidator argument must be a function with the signature function(props, propName, componentName).", MESSAGE_ARG_ERROR_MESSAGE = "The error message is optional, but must be a string if provided.";
  15280. function propIsRequired(condition, props, propName, componentName) {
  15281. return typeof condition == "boolean" ? condition : typeof condition == "function" ? condition(props, propName, componentName) : condition ? !!condition : !1;
  15282. }
  15283. function propExists(props, propName) {
  15284. return Object.hasOwnProperty.call(props, propName);
  15285. }
  15286. function missingPropError(props, propName, componentName, message) {
  15287. return message ? new Error(message) : new Error("Required ".concat(props[propName], " `").concat(propName, "` was not specified in `").concat(componentName, "`."));
  15288. }
  15289. function guardAgainstInvalidArgTypes(typeValidator, message) {
  15290. if (typeof typeValidator != "function")
  15291. throw new TypeError(VALIDATOR_ARG_ERROR_MESSAGE);
  15292. if (message && typeof message != "string")
  15293. throw new TypeError(MESSAGE_ARG_ERROR_MESSAGE);
  15294. }
  15295. function isRequiredIf(typeValidator, condition, message) {
  15296. return guardAgainstInvalidArgTypes(typeValidator, message), function(props, propName, componentName) {
  15297. for (var _len = arguments.length, rest2 = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++)
  15298. rest2[_key - 3] = arguments[_key];
  15299. return propIsRequired(condition, props, propName, componentName) ? propExists(props, propName) ? typeValidator.apply(void 0, [props, propName, componentName].concat(rest2)) : missingPropError(props, propName, componentName, message) : typeValidator.apply(void 0, [props, propName, componentName].concat(rest2));
  15300. };
  15301. }
  15302. var STATUS2 = { INIT: "init", IDLE: "idle", OPENING: "opening", OPEN: "open", CLOSING: "closing", ERROR: "error" }, isReact16 = react_dom_default.createPortal !== void 0;
  15303. function canUseDOM() {
  15304. return !!(typeof window < "u" && window.document && window.document.createElement);
  15305. }
  15306. function isMobile() {
  15307. return "ontouchstart" in window && /Mobi/.test(navigator.userAgent);
  15308. }
  15309. function log(_ref) {
  15310. var title2 = _ref.title, data = _ref.data, _ref$warn = _ref.warn, warn = _ref$warn === void 0 ? !1 : _ref$warn, _ref$debug = _ref.debug, debug = _ref$debug === void 0 ? !1 : _ref$debug, logFn = warn ? console.warn || console.error : console.log;
  15311. debug && title2 && data && (console.groupCollapsed("%creact-floater: ".concat(title2), "color: #9b00ff; font-weight: bold; font-size: 12px;"), Array.isArray(data) ? data.forEach(function(d2) {
  15312. esm_default.plainObject(d2) && d2.key ? logFn.apply(console, [d2.key, d2.value]) : logFn.apply(console, [d2]);
  15313. }) : logFn.apply(console, [data]), console.groupEnd());
  15314. }
  15315. function on(element, event, cb) {
  15316. var capture = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  15317. element.addEventListener(event, cb, capture);
  15318. }
  15319. function off(element, event, cb) {
  15320. var capture = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  15321. element.removeEventListener(event, cb, capture);
  15322. }
  15323. function once3(element, event, cb) {
  15324. var capture = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, _nextCB;
  15325. _nextCB = function(e2) {
  15326. cb(e2), off(element, event, _nextCB);
  15327. }, on(element, event, _nextCB, capture);
  15328. }
  15329. function noop2() {
  15330. }
  15331. var ReactFloaterPortal = (function(_React$Component) {
  15332. _inherits(ReactFloaterPortal2, _React$Component);
  15333. var _super = _createSuper(ReactFloaterPortal2);
  15334. function ReactFloaterPortal2() {
  15335. return _classCallCheck(this, ReactFloaterPortal2), _super.apply(this, arguments);
  15336. }
  15337. return _createClass(ReactFloaterPortal2, [{ key: "componentDidMount", value: function() {
  15338. canUseDOM() && (this.node || this.appendNode(), isReact16 || this.renderPortal());
  15339. } }, { key: "componentDidUpdate", value: function() {
  15340. canUseDOM() && (isReact16 || this.renderPortal());
  15341. } }, { key: "componentWillUnmount", value: function() {
  15342. !canUseDOM() || !this.node || (isReact16 || react_dom_default.unmountComponentAtNode(this.node), this.node && this.node.parentNode === document.body && (document.body.removeChild(this.node), this.node = void 0));
  15343. } }, { key: "appendNode", value: function() {
  15344. var _this$props = this.props, id = _this$props.id, zIndex = _this$props.zIndex;
  15345. this.node || (this.node = document.createElement("div"), id && (this.node.id = id), zIndex && (this.node.style.zIndex = zIndex), document.body.appendChild(this.node));
  15346. } }, { key: "renderPortal", value: function() {
  15347. if (!canUseDOM()) return null;
  15348. var _this$props2 = this.props, children = _this$props2.children, setRef = _this$props2.setRef;
  15349. if (this.node || this.appendNode(), isReact16)
  15350. return react_dom_default.createPortal(children, this.node);
  15351. var portal = react_dom_default.unstable_renderSubtreeIntoContainer(this, children.length > 1 ? react_default.createElement("div", null, children) : children[0], this.node);
  15352. return setRef(portal), null;
  15353. } }, { key: "renderReact16", value: function() {
  15354. var _this$props3 = this.props, hasChildren = _this$props3.hasChildren, placement = _this$props3.placement, target = _this$props3.target;
  15355. return hasChildren ? this.renderPortal() : target || placement === "center" ? this.renderPortal() : null;
  15356. } }, { key: "render", value: function() {
  15357. return isReact16 ? this.renderReact16() : null;
  15358. } }]), ReactFloaterPortal2;
  15359. })(react_default.Component);
  15360. _defineProperty(ReactFloaterPortal, "propTypes", { children: import_prop_types2.default.oneOfType([import_prop_types2.default.element, import_prop_types2.default.array]), hasChildren: import_prop_types2.default.bool, id: import_prop_types2.default.oneOfType([import_prop_types2.default.string, import_prop_types2.default.number]), placement: import_prop_types2.default.string, setRef: import_prop_types2.default.func.isRequired, target: import_prop_types2.default.oneOfType([import_prop_types2.default.object, import_prop_types2.default.string]), zIndex: import_prop_types2.default.number });
  15361. var FloaterArrow = (function(_React$Component) {
  15362. _inherits(FloaterArrow2, _React$Component);
  15363. var _super = _createSuper(FloaterArrow2);
  15364. function FloaterArrow2() {
  15365. return _classCallCheck(this, FloaterArrow2), _super.apply(this, arguments);
  15366. }
  15367. return _createClass(FloaterArrow2, [{ key: "parentStyle", get: function() {
  15368. var _this$props = this.props, placement = _this$props.placement, styles2 = _this$props.styles, length = styles2.arrow.length, arrow2 = { pointerEvents: "none", position: "absolute", width: "100%" };
  15369. return placement.startsWith("top") ? (arrow2.bottom = 0, arrow2.left = 0, arrow2.right = 0, arrow2.height = length) : placement.startsWith("bottom") ? (arrow2.left = 0, arrow2.right = 0, arrow2.top = 0, arrow2.height = length) : placement.startsWith("left") ? (arrow2.right = 0, arrow2.top = 0, arrow2.bottom = 0) : placement.startsWith("right") && (arrow2.left = 0, arrow2.top = 0), arrow2;
  15370. } }, { key: "render", value: function() {
  15371. var _this$props2 = this.props, placement = _this$props2.placement, setArrowRef = _this$props2.setArrowRef, styles2 = _this$props2.styles, _styles$arrow = styles2.arrow, color2 = _styles$arrow.color, display = _styles$arrow.display, length = _styles$arrow.length, margin = _styles$arrow.margin, position = _styles$arrow.position, spread2 = _styles$arrow.spread, arrowStyles = { display, position }, points, x2 = spread2, y2 = length;
  15372. return placement.startsWith("top") ? (points = "0,0 ".concat(x2 / 2, ",").concat(y2, " ").concat(x2, ",0"), arrowStyles.bottom = 0, arrowStyles.marginLeft = margin, arrowStyles.marginRight = margin) : placement.startsWith("bottom") ? (points = "".concat(x2, ",").concat(y2, " ").concat(x2 / 2, ",0 0,").concat(y2), arrowStyles.top = 0, arrowStyles.marginLeft = margin, arrowStyles.marginRight = margin) : placement.startsWith("left") ? (y2 = spread2, x2 = length, points = "0,0 ".concat(x2, ",").concat(y2 / 2, " 0,").concat(y2), arrowStyles.right = 0, arrowStyles.marginTop = margin, arrowStyles.marginBottom = margin) : placement.startsWith("right") && (y2 = spread2, x2 = length, points = "".concat(x2, ",").concat(y2, " ").concat(x2, ",0 0,").concat(y2 / 2), arrowStyles.left = 0, arrowStyles.marginTop = margin, arrowStyles.marginBottom = margin), react_default.createElement("div", { className: "__floater__arrow", style: this.parentStyle }, react_default.createElement("span", { ref: setArrowRef, style: arrowStyles }, react_default.createElement("svg", { width: x2, height: y2, version: "1.1", xmlns: "http://www.w3.org/2000/svg" }, react_default.createElement("polygon", { points, fill: color2 }))));
  15373. } }]), FloaterArrow2;
  15374. })(react_default.Component);
  15375. _defineProperty(FloaterArrow, "propTypes", { placement: import_prop_types2.default.string.isRequired, setArrowRef: import_prop_types2.default.func.isRequired, styles: import_prop_types2.default.object.isRequired });
  15376. var _excluded$1 = ["color", "height", "width"];
  15377. function FloaterCloseBtn(_ref) {
  15378. var handleClick = _ref.handleClick, styles2 = _ref.styles, color2 = styles2.color, height = styles2.height, width = styles2.width, style = _objectWithoutProperties(styles2, _excluded$1);
  15379. return react_default.createElement("button", { "aria-label": "close", onClick: handleClick, style, type: "button" }, react_default.createElement("svg", { width: "".concat(width, "px"), height: "".concat(height, "px"), viewBox: "0 0 18 18", version: "1.1", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid" }, react_default.createElement("g", null, react_default.createElement("path", { d: "M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z", fill: color2 }))));
  15380. }
  15381. FloaterCloseBtn.propTypes = { handleClick: import_prop_types2.default.func.isRequired, styles: import_prop_types2.default.object.isRequired };
  15382. function FloaterContainer(_ref) {
  15383. var content = _ref.content, footer = _ref.footer, handleClick = _ref.handleClick, open = _ref.open, positionWrapper = _ref.positionWrapper, showCloseButton = _ref.showCloseButton, title2 = _ref.title, styles2 = _ref.styles, output = { content: react_default.isValidElement(content) ? content : react_default.createElement("div", { className: "__floater__content", style: styles2.content }, content) };
  15384. return title2 && (output.title = react_default.isValidElement(title2) ? title2 : react_default.createElement("div", { className: "__floater__title", style: styles2.title }, title2)), footer && (output.footer = react_default.isValidElement(footer) ? footer : react_default.createElement("div", { className: "__floater__footer", style: styles2.footer }, footer)), (showCloseButton || positionWrapper) && !esm_default.boolean(open) && (output.close = react_default.createElement(FloaterCloseBtn, { styles: styles2.close, handleClick })), react_default.createElement("div", { className: "__floater__container", style: styles2.container }, output.close, output.title, output.content, output.footer);
  15385. }
  15386. FloaterContainer.propTypes = { content: import_prop_types2.default.node.isRequired, footer: import_prop_types2.default.node, handleClick: import_prop_types2.default.func.isRequired, open: import_prop_types2.default.bool, positionWrapper: import_prop_types2.default.bool.isRequired, showCloseButton: import_prop_types2.default.bool.isRequired, styles: import_prop_types2.default.object.isRequired, title: import_prop_types2.default.node };
  15387. var Floater = (function(_React$Component) {
  15388. _inherits(Floater2, _React$Component);
  15389. var _super = _createSuper(Floater2);
  15390. function Floater2() {
  15391. return _classCallCheck(this, Floater2), _super.apply(this, arguments);
  15392. }
  15393. return _createClass(Floater2, [{ key: "style", get: function() {
  15394. var _this$props = this.props, disableAnimation = _this$props.disableAnimation, component = _this$props.component, placement = _this$props.placement, hideArrow = _this$props.hideArrow, status = _this$props.status, styles2 = _this$props.styles, length = styles2.arrow.length, floater = styles2.floater, floaterCentered = styles2.floaterCentered, floaterClosing = styles2.floaterClosing, floaterOpening = styles2.floaterOpening, floaterWithAnimation = styles2.floaterWithAnimation, floaterWithComponent = styles2.floaterWithComponent, element = {};
  15395. return hideArrow || (placement.startsWith("top") ? element.padding = "0 0 ".concat(length, "px") : placement.startsWith("bottom") ? element.padding = "".concat(length, "px 0 0") : placement.startsWith("left") ? element.padding = "0 ".concat(length, "px 0 0") : placement.startsWith("right") && (element.padding = "0 0 0 ".concat(length, "px"))), [STATUS2.OPENING, STATUS2.OPEN].indexOf(status) !== -1 && (element = _objectSpread2(_objectSpread2({}, element), floaterOpening)), status === STATUS2.CLOSING && (element = _objectSpread2(_objectSpread2({}, element), floaterClosing)), status === STATUS2.OPEN && !disableAnimation && (element = _objectSpread2(_objectSpread2({}, element), floaterWithAnimation)), placement === "center" && (element = _objectSpread2(_objectSpread2({}, element), floaterCentered)), component && (element = _objectSpread2(_objectSpread2({}, element), floaterWithComponent)), _objectSpread2(_objectSpread2({}, floater), element);
  15396. } }, { key: "render", value: function() {
  15397. var _this$props2 = this.props, component = _this$props2.component, closeFn = _this$props2.handleClick, hideArrow = _this$props2.hideArrow, setFloaterRef = _this$props2.setFloaterRef, status = _this$props2.status, output = {}, classes = ["__floater"];
  15398. return component ? react_default.isValidElement(component) ? output.content = react_default.cloneElement(component, { closeFn }) : output.content = component({ closeFn }) : output.content = react_default.createElement(FloaterContainer, this.props), status === STATUS2.OPEN && classes.push("__floater__open"), hideArrow || (output.arrow = react_default.createElement(FloaterArrow, this.props)), react_default.createElement("div", { ref: setFloaterRef, className: classes.join(" "), style: this.style }, react_default.createElement("div", { className: "__floater__body" }, output.content, output.arrow));
  15399. } }]), Floater2;
  15400. })(react_default.Component);
  15401. _defineProperty(Floater, "propTypes", { component: import_prop_types2.default.oneOfType([import_prop_types2.default.func, import_prop_types2.default.element]), content: import_prop_types2.default.node, disableAnimation: import_prop_types2.default.bool.isRequired, footer: import_prop_types2.default.node, handleClick: import_prop_types2.default.func.isRequired, hideArrow: import_prop_types2.default.bool.isRequired, open: import_prop_types2.default.bool, placement: import_prop_types2.default.string.isRequired, positionWrapper: import_prop_types2.default.bool.isRequired, setArrowRef: import_prop_types2.default.func.isRequired, setFloaterRef: import_prop_types2.default.func.isRequired, showCloseButton: import_prop_types2.default.bool, status: import_prop_types2.default.string.isRequired, styles: import_prop_types2.default.object.isRequired, title: import_prop_types2.default.node });
  15402. var ReactFloaterWrapper = (function(_React$Component) {
  15403. _inherits(ReactFloaterWrapper2, _React$Component);
  15404. var _super = _createSuper(ReactFloaterWrapper2);
  15405. function ReactFloaterWrapper2() {
  15406. return _classCallCheck(this, ReactFloaterWrapper2), _super.apply(this, arguments);
  15407. }
  15408. return _createClass(ReactFloaterWrapper2, [{ key: "render", value: function() {
  15409. var _this$props = this.props, children = _this$props.children, handleClick = _this$props.handleClick, handleMouseEnter = _this$props.handleMouseEnter, handleMouseLeave = _this$props.handleMouseLeave, setChildRef = _this$props.setChildRef, setWrapperRef = _this$props.setWrapperRef, style = _this$props.style, styles2 = _this$props.styles, element;
  15410. if (children)
  15411. if (react_default.Children.count(children) === 1)
  15412. if (!react_default.isValidElement(children))
  15413. element = react_default.createElement("span", null, children);
  15414. else {
  15415. var refProp = esm_default.function(children.type) ? "innerRef" : "ref";
  15416. element = react_default.cloneElement(react_default.Children.only(children), _defineProperty({}, refProp, setChildRef));
  15417. }
  15418. else
  15419. element = children;
  15420. return element ? react_default.createElement("span", { ref: setWrapperRef, style: _objectSpread2(_objectSpread2({}, styles2), style), onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, element) : null;
  15421. } }]), ReactFloaterWrapper2;
  15422. })(react_default.Component);
  15423. _defineProperty(ReactFloaterWrapper, "propTypes", { children: import_prop_types2.default.node, handleClick: import_prop_types2.default.func.isRequired, handleMouseEnter: import_prop_types2.default.func.isRequired, handleMouseLeave: import_prop_types2.default.func.isRequired, setChildRef: import_prop_types2.default.func.isRequired, setWrapperRef: import_prop_types2.default.func.isRequired, style: import_prop_types2.default.object, styles: import_prop_types2.default.object.isRequired });
  15424. var defaultOptions = { zIndex: 100 };
  15425. function getStyles(styles2) {
  15426. var options2 = (0, import_deepmerge.default)(defaultOptions, styles2.options || {});
  15427. return { wrapper: { cursor: "help", display: "inline-flex", flexDirection: "column", zIndex: options2.zIndex }, wrapperPosition: { left: -1e3, position: "absolute", top: -1e3, visibility: "hidden" }, floater: { display: "inline-block", filter: "drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))", maxWidth: 300, opacity: 0, position: "relative", transition: "opacity 0.3s", visibility: "hidden", zIndex: options2.zIndex }, floaterOpening: { opacity: 1, visibility: "visible" }, floaterWithAnimation: { opacity: 1, transition: "opacity 0.3s, transform 0.2s", visibility: "visible" }, floaterWithComponent: { maxWidth: "100%" }, floaterClosing: { opacity: 0, visibility: "visible" }, floaterCentered: { left: "50%", position: "fixed", top: "50%", transform: "translate(-50%, -50%)" }, container: { backgroundColor: "#fff", color: "#666", minHeight: 60, minWidth: 200, padding: 20, position: "relative", zIndex: 10 }, title: { borderBottom: "1px solid #555", color: "#555", fontSize: 18, marginBottom: 5, paddingBottom: 6, paddingRight: 18 }, content: { fontSize: 15 }, close: { backgroundColor: "transparent", border: 0, borderRadius: 0, color: "#555", fontSize: 0, height: 15, outline: "none", padding: 10, position: "absolute", right: 0, top: 0, width: 15, WebkitAppearance: "none" }, footer: { borderTop: "1px solid #ccc", fontSize: 13, marginTop: 10, paddingTop: 5 }, arrow: { color: "#fff", display: "inline-flex", length: 16, margin: 8, position: "absolute", spread: 32 }, options: options2 };
  15428. }
  15429. var _excluded = ["arrow", "flip", "offset"], POSITIONING_PROPS = ["position", "top", "right", "bottom", "left"], ReactFloater = (function(_React$Component) {
  15430. _inherits(ReactFloater2, _React$Component);
  15431. var _super = _createSuper(ReactFloater2);
  15432. function ReactFloater2(props) {
  15433. var _this;
  15434. return _classCallCheck(this, ReactFloater2), _this = _super.call(this, props), _defineProperty(_assertThisInitialized2(_this), "setArrowRef", function(ref) {
  15435. _this.arrowRef = ref;
  15436. }), _defineProperty(_assertThisInitialized2(_this), "setChildRef", function(ref) {
  15437. _this.childRef = ref;
  15438. }), _defineProperty(_assertThisInitialized2(_this), "setFloaterRef", function(ref) {
  15439. _this.floaterRef = ref;
  15440. }), _defineProperty(_assertThisInitialized2(_this), "setWrapperRef", function(ref) {
  15441. _this.wrapperRef = ref;
  15442. }), _defineProperty(_assertThisInitialized2(_this), "handleTransitionEnd", function() {
  15443. var status = _this.state.status, callback = _this.props.callback;
  15444. _this.wrapperPopper && _this.wrapperPopper.instance.update(), _this.setState({ status: status === STATUS2.OPENING ? STATUS2.OPEN : STATUS2.IDLE }, function() {
  15445. var newStatus = _this.state.status;
  15446. callback(newStatus === STATUS2.OPEN ? "open" : "close", _this.props);
  15447. });
  15448. }), _defineProperty(_assertThisInitialized2(_this), "handleClick", function() {
  15449. var _this$props = _this.props, event = _this$props.event, open = _this$props.open;
  15450. if (!esm_default.boolean(open)) {
  15451. var _this$state = _this.state, positionWrapper = _this$state.positionWrapper, status = _this$state.status;
  15452. (_this.event === "click" || _this.event === "hover" && positionWrapper) && (log({ title: "click", data: [{ event, status: status === STATUS2.OPEN ? "closing" : "opening" }], debug: _this.debug }), _this.toggle());
  15453. }
  15454. }), _defineProperty(_assertThisInitialized2(_this), "handleMouseEnter", function() {
  15455. var _this$props2 = _this.props, event = _this$props2.event, open = _this$props2.open;
  15456. if (!(esm_default.boolean(open) || isMobile())) {
  15457. var status = _this.state.status;
  15458. _this.event === "hover" && status === STATUS2.IDLE && (log({ title: "mouseEnter", data: [{ key: "originalEvent", value: event }], debug: _this.debug }), clearTimeout(_this.eventDelayTimeout), _this.toggle());
  15459. }
  15460. }), _defineProperty(_assertThisInitialized2(_this), "handleMouseLeave", function() {
  15461. var _this$props3 = _this.props, event = _this$props3.event, eventDelay = _this$props3.eventDelay, open = _this$props3.open;
  15462. if (!(esm_default.boolean(open) || isMobile())) {
  15463. var _this$state2 = _this.state, status = _this$state2.status, positionWrapper = _this$state2.positionWrapper;
  15464. _this.event === "hover" && (log({ title: "mouseLeave", data: [{ key: "originalEvent", value: event }], debug: _this.debug }), eventDelay ? [STATUS2.OPENING, STATUS2.OPEN].indexOf(status) !== -1 && !positionWrapper && !_this.eventDelayTimeout && (_this.eventDelayTimeout = setTimeout(function() {
  15465. delete _this.eventDelayTimeout, _this.toggle();
  15466. }, eventDelay * 1e3)) : _this.toggle(STATUS2.IDLE));
  15467. }
  15468. }), _this.state = { currentPlacement: props.placement, needsUpdate: !1, positionWrapper: props.wrapperOptions.position && !!props.target, status: STATUS2.INIT, statusWrapper: STATUS2.INIT }, _this._isMounted = !1, _this.hasMounted = !1, canUseDOM() && window.addEventListener("load", function() {
  15469. _this.popper && _this.popper.instance.update(), _this.wrapperPopper && _this.wrapperPopper.instance.update();
  15470. }), _this;
  15471. }
  15472. return _createClass(ReactFloater2, [{ key: "componentDidMount", value: function() {
  15473. if (canUseDOM()) {
  15474. var positionWrapper = this.state.positionWrapper, _this$props5 = this.props, children = _this$props5.children, open = _this$props5.open, target = _this$props5.target;
  15475. this._isMounted = !0, log({ title: "init", data: { hasChildren: !!children, hasTarget: !!target, isControlled: esm_default.boolean(open), positionWrapper, target: this.target, floater: this.floaterRef }, debug: this.debug }), this.hasMounted || (this.initPopper(), this.hasMounted = !0), !children && target && esm_default.boolean(open);
  15476. }
  15477. } }, { key: "componentDidUpdate", value: function(prevProps, prevState) {
  15478. if (canUseDOM()) {
  15479. var _this$props6 = this.props, autoOpen = _this$props6.autoOpen, open = _this$props6.open, target = _this$props6.target, wrapperOptions = _this$props6.wrapperOptions, _treeChanges = treeChanges2(prevState, this.state), changedFrom = _treeChanges.changedFrom, changed = _treeChanges.changed;
  15480. if (prevProps.open !== open) {
  15481. var forceStatus;
  15482. esm_default.boolean(open) && (forceStatus = open ? STATUS2.OPENING : STATUS2.CLOSING), this.toggle(forceStatus);
  15483. }
  15484. (prevProps.wrapperOptions.position !== wrapperOptions.position || prevProps.target !== target) && this.changeWrapperPosition(this.props), changed("status", STATUS2.IDLE) && open ? this.toggle(STATUS2.OPEN) : changedFrom("status", STATUS2.INIT, STATUS2.IDLE) && autoOpen && this.toggle(STATUS2.OPEN), this.popper && changed("status", STATUS2.OPENING) && this.popper.instance.update(), this.floaterRef && (changed("status", STATUS2.OPENING) || changed("status", STATUS2.CLOSING)) && once3(this.floaterRef, "transitionend", this.handleTransitionEnd), changed("needsUpdate", !0) && this.rebuildPopper();
  15485. }
  15486. } }, { key: "componentWillUnmount", value: function() {
  15487. canUseDOM() && (this._isMounted = !1, this.popper && this.popper.instance.destroy(), this.wrapperPopper && this.wrapperPopper.instance.destroy());
  15488. } }, { key: "initPopper", value: function() {
  15489. var _this2 = this, target = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.target, positionWrapper = this.state.positionWrapper, _this$props7 = this.props, disableFlip = _this$props7.disableFlip, getPopper = _this$props7.getPopper, hideArrow = _this$props7.hideArrow, offset2 = _this$props7.offset, placement = _this$props7.placement, wrapperOptions = _this$props7.wrapperOptions, flipBehavior = placement === "top" || placement === "bottom" ? "flip" : ["right", "bottom-end", "top-end", "left", "top-start", "bottom-start"];
  15490. if (placement === "center")
  15491. this.setState({ status: STATUS2.IDLE });
  15492. else if (target && this.floaterRef) {
  15493. var _this$options = this.options, arrow2 = _this$options.arrow, flip2 = _this$options.flip, offsetOptions = _this$options.offset, rest2 = _objectWithoutProperties(_this$options, _excluded);
  15494. new popper_default(target, this.floaterRef, { placement, modifiers: _objectSpread2({ arrow: _objectSpread2({ enabled: !hideArrow, element: this.arrowRef }, arrow2), flip: _objectSpread2({ enabled: !disableFlip, behavior: flipBehavior }, flip2), offset: _objectSpread2({ offset: "0, ".concat(offset2, "px") }, offsetOptions) }, rest2), onCreate: function(data) {
  15495. var _this2$floaterRef;
  15496. if (_this2.popper = data, !((_this2$floaterRef = _this2.floaterRef) !== null && _this2$floaterRef !== void 0 && _this2$floaterRef.isConnected)) {
  15497. _this2.setState({ needsUpdate: !0 });
  15498. return;
  15499. }
  15500. getPopper(data, "floater"), _this2._isMounted && _this2.setState({ currentPlacement: data.placement, status: STATUS2.IDLE }), placement !== data.placement && setTimeout(function() {
  15501. data.instance.update();
  15502. }, 1);
  15503. }, onUpdate: function(data) {
  15504. _this2.popper = data;
  15505. var currentPlacement = _this2.state.currentPlacement;
  15506. _this2._isMounted && data.placement !== currentPlacement && _this2.setState({ currentPlacement: data.placement });
  15507. } });
  15508. }
  15509. if (positionWrapper) {
  15510. var wrapperOffset = esm_default.undefined(wrapperOptions.offset) ? 0 : wrapperOptions.offset;
  15511. new popper_default(this.target, this.wrapperRef, { placement: wrapperOptions.placement || placement, modifiers: { arrow: { enabled: !1 }, offset: { offset: "0, ".concat(wrapperOffset, "px") }, flip: { enabled: !1 } }, onCreate: function(data) {
  15512. _this2.wrapperPopper = data, _this2._isMounted && _this2.setState({ statusWrapper: STATUS2.IDLE }), getPopper(data, "wrapper"), placement !== data.placement && setTimeout(function() {
  15513. data.instance.update();
  15514. }, 1);
  15515. } });
  15516. }
  15517. } }, { key: "rebuildPopper", value: function() {
  15518. var _this3 = this;
  15519. this.floaterRefInterval = setInterval(function() {
  15520. var _this3$floaterRef;
  15521. (_this3$floaterRef = _this3.floaterRef) !== null && _this3$floaterRef !== void 0 && _this3$floaterRef.isConnected && (clearInterval(_this3.floaterRefInterval), _this3.setState({ needsUpdate: !1 }), _this3.initPopper());
  15522. }, 50);
  15523. } }, { key: "changeWrapperPosition", value: function(_ref) {
  15524. var target = _ref.target, wrapperOptions = _ref.wrapperOptions;
  15525. this.setState({ positionWrapper: wrapperOptions.position && !!target });
  15526. } }, { key: "toggle", value: function(forceStatus) {
  15527. var status = this.state.status, nextStatus = status === STATUS2.OPEN ? STATUS2.CLOSING : STATUS2.OPENING;
  15528. esm_default.undefined(forceStatus) || (nextStatus = forceStatus), this.setState({ status: nextStatus });
  15529. } }, { key: "debug", get: function() {
  15530. var debug = this.props.debug;
  15531. return debug || canUseDOM() && "ReactFloaterDebug" in window && !!window.ReactFloaterDebug;
  15532. } }, { key: "event", get: function() {
  15533. var _this$props8 = this.props, disableHoverToClick = _this$props8.disableHoverToClick, event = _this$props8.event;
  15534. return event === "hover" && isMobile() && !disableHoverToClick ? "click" : event;
  15535. } }, { key: "options", get: function() {
  15536. var options2 = this.props.options;
  15537. return (0, import_deepmerge.default)(DEFAULTS, options2 || {});
  15538. } }, { key: "styles", get: function() {
  15539. var _this4 = this, _this$state3 = this.state, status = _this$state3.status, positionWrapper = _this$state3.positionWrapper, statusWrapper = _this$state3.statusWrapper, styles2 = this.props.styles, nextStyles = (0, import_deepmerge.default)(getStyles(styles2), styles2);
  15540. if (positionWrapper) {
  15541. var wrapperStyles;
  15542. [STATUS2.IDLE].indexOf(status) === -1 || [STATUS2.IDLE].indexOf(statusWrapper) === -1 ? wrapperStyles = nextStyles.wrapperPosition : wrapperStyles = this.wrapperPopper.styles, nextStyles.wrapper = _objectSpread2(_objectSpread2({}, nextStyles.wrapper), wrapperStyles);
  15543. }
  15544. if (this.target) {
  15545. var targetStyles = window.getComputedStyle(this.target);
  15546. this.wrapperStyles ? nextStyles.wrapper = _objectSpread2(_objectSpread2({}, nextStyles.wrapper), this.wrapperStyles) : ["relative", "static"].indexOf(targetStyles.position) === -1 && (this.wrapperStyles = {}, positionWrapper || (POSITIONING_PROPS.forEach(function(d2) {
  15547. _this4.wrapperStyles[d2] = targetStyles[d2];
  15548. }), nextStyles.wrapper = _objectSpread2(_objectSpread2({}, nextStyles.wrapper), this.wrapperStyles), this.target.style.position = "relative", this.target.style.top = "auto", this.target.style.right = "auto", this.target.style.bottom = "auto", this.target.style.left = "auto"));
  15549. }
  15550. return nextStyles;
  15551. } }, { key: "target", get: function() {
  15552. if (!canUseDOM()) return null;
  15553. var target = this.props.target;
  15554. return target ? esm_default.domElement(target) ? target : document.querySelector(target) : this.childRef || this.wrapperRef;
  15555. } }, { key: "render", value: function() {
  15556. var _this$state4 = this.state, currentPlacement = _this$state4.currentPlacement, positionWrapper = _this$state4.positionWrapper, status = _this$state4.status, _this$props9 = this.props, children = _this$props9.children, component = _this$props9.component, content = _this$props9.content, disableAnimation = _this$props9.disableAnimation, footer = _this$props9.footer, hideArrow = _this$props9.hideArrow, id = _this$props9.id, open = _this$props9.open, showCloseButton = _this$props9.showCloseButton, style = _this$props9.style, target = _this$props9.target, title2 = _this$props9.title, wrapper = react_default.createElement(ReactFloaterWrapper, { handleClick: this.handleClick, handleMouseEnter: this.handleMouseEnter, handleMouseLeave: this.handleMouseLeave, setChildRef: this.setChildRef, setWrapperRef: this.setWrapperRef, style, styles: this.styles.wrapper }, children), output = {};
  15557. return positionWrapper ? output.wrapperInPortal = wrapper : output.wrapperAsChildren = wrapper, react_default.createElement("span", null, react_default.createElement(ReactFloaterPortal, { hasChildren: !!children, id, placement: currentPlacement, setRef: this.setFloaterRef, target, zIndex: this.styles.options.zIndex }, react_default.createElement(Floater, { component, content, disableAnimation, footer, handleClick: this.handleClick, hideArrow: hideArrow || currentPlacement === "center", open, placement: currentPlacement, positionWrapper, setArrowRef: this.setArrowRef, setFloaterRef: this.setFloaterRef, showCloseButton, status, styles: this.styles, title: title2 }), output.wrapperInPortal), output.wrapperAsChildren);
  15558. } }]), ReactFloater2;
  15559. })(react_default.Component);
  15560. _defineProperty(ReactFloater, "propTypes", { autoOpen: import_prop_types2.default.bool, callback: import_prop_types2.default.func, children: import_prop_types2.default.node, component: isRequiredIf(import_prop_types2.default.oneOfType([import_prop_types2.default.func, import_prop_types2.default.element]), function(props) {
  15561. return !props.content;
  15562. }), content: isRequiredIf(import_prop_types2.default.node, function(props) {
  15563. return !props.component;
  15564. }), debug: import_prop_types2.default.bool, disableAnimation: import_prop_types2.default.bool, disableFlip: import_prop_types2.default.bool, disableHoverToClick: import_prop_types2.default.bool, event: import_prop_types2.default.oneOf(["hover", "click"]), eventDelay: import_prop_types2.default.number, footer: import_prop_types2.default.node, getPopper: import_prop_types2.default.func, hideArrow: import_prop_types2.default.bool, id: import_prop_types2.default.oneOfType([import_prop_types2.default.string, import_prop_types2.default.number]), offset: import_prop_types2.default.number, open: import_prop_types2.default.bool, options: import_prop_types2.default.object, placement: import_prop_types2.default.oneOf(["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "right", "right-start", "right-end", "auto", "center"]), showCloseButton: import_prop_types2.default.bool, style: import_prop_types2.default.object, styles: import_prop_types2.default.object, target: import_prop_types2.default.oneOfType([import_prop_types2.default.object, import_prop_types2.default.string]), title: import_prop_types2.default.node, wrapperOptions: import_prop_types2.default.shape({ offset: import_prop_types2.default.number, placement: import_prop_types2.default.oneOf(["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "right", "right-start", "right-end", "auto"]), position: import_prop_types2.default.bool }) });
  15565. _defineProperty(ReactFloater, "defaultProps", { autoOpen: !1, callback: noop2, debug: !1, disableAnimation: !1, disableFlip: !1, disableHoverToClick: !1, event: "click", eventDelay: 0.4, getPopper: noop2, hideArrow: !1, offset: 15, placement: "bottom", showCloseButton: !1, styles: {}, target: null, wrapperOptions: { position: !1 } });
  15566. // ../../node_modules/react-joyride/dist/index.mjs
  15567. init_react();
  15568. init_react();
  15569. init_react();
  15570. init_react();
  15571. var __defProp3 = Object.defineProperty, __defNormalProp2 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), ACTIONS = {
  15572. INIT: "init",
  15573. START: "start",
  15574. STOP: "stop",
  15575. RESET: "reset",
  15576. PREV: "prev",
  15577. NEXT: "next",
  15578. GO: "go",
  15579. CLOSE: "close",
  15580. SKIP: "skip",
  15581. UPDATE: "update"
  15582. }, EVENTS = {
  15583. TOUR_START: "tour:start",
  15584. STEP_BEFORE: "step:before",
  15585. BEACON: "beacon",
  15586. TOOLTIP: "tooltip",
  15587. STEP_AFTER: "step:after",
  15588. TOUR_END: "tour:end",
  15589. TOUR_STATUS: "tour:status",
  15590. TARGET_NOT_FOUND: "error:target_not_found",
  15591. ERROR: "error"
  15592. }, LIFECYCLE = {
  15593. INIT: "init",
  15594. READY: "ready",
  15595. BEACON: "beacon",
  15596. TOOLTIP: "tooltip",
  15597. COMPLETE: "complete",
  15598. ERROR: "error"
  15599. };
  15600. var STATUS3 = {
  15601. IDLE: "idle",
  15602. READY: "ready",
  15603. WAITING: "waiting",
  15604. RUNNING: "running",
  15605. PAUSED: "paused",
  15606. SKIPPED: "skipped",
  15607. FINISHED: "finished",
  15608. ERROR: "error"
  15609. };
  15610. function canUseDOM2() {
  15611. var _a2;
  15612. return !!(typeof window < "u" && ((_a2 = window.document) != null && _a2.createElement));
  15613. }
  15614. function getClientRect2(element) {
  15615. return element ? element.getBoundingClientRect() : null;
  15616. }
  15617. function getDocumentHeight(median = !1) {
  15618. let { body, documentElement } = document;
  15619. if (!body || !documentElement)
  15620. return 0;
  15621. if (median) {
  15622. let heights = [
  15623. body.scrollHeight,
  15624. body.offsetHeight,
  15625. documentElement.clientHeight,
  15626. documentElement.scrollHeight,
  15627. documentElement.offsetHeight
  15628. ].sort((a2, b2) => a2 - b2), middle = Math.floor(heights.length / 2);
  15629. return heights.length % 2 === 0 ? (heights[middle - 1] + heights[middle]) / 2 : heights[middle];
  15630. }
  15631. return Math.max(
  15632. body.scrollHeight,
  15633. body.offsetHeight,
  15634. documentElement.clientHeight,
  15635. documentElement.scrollHeight,
  15636. documentElement.offsetHeight
  15637. );
  15638. }
  15639. function getElement(element) {
  15640. if (typeof element == "string")
  15641. try {
  15642. return document.querySelector(element);
  15643. } catch {
  15644. return null;
  15645. }
  15646. return element;
  15647. }
  15648. function getStyleComputedProperty2(el) {
  15649. return !el || el.nodeType !== 1 ? null : getComputedStyle(el);
  15650. }
  15651. function getScrollParent2(element, skipFix, forListener) {
  15652. if (!element)
  15653. return scrollDocument();
  15654. let parent = (0, import_scrollparent.default)(element);
  15655. if (parent) {
  15656. if (parent.isSameNode(scrollDocument()))
  15657. return forListener ? document : scrollDocument();
  15658. if (!(parent.scrollHeight > parent.offsetHeight) && !skipFix)
  15659. return parent.style.overflow = "initial", scrollDocument();
  15660. }
  15661. return parent;
  15662. }
  15663. function hasCustomScrollParent(element, skipFix) {
  15664. if (!element)
  15665. return !1;
  15666. let parent = getScrollParent2(element, skipFix);
  15667. return parent ? !parent.isSameNode(scrollDocument()) : !1;
  15668. }
  15669. function hasCustomOffsetParent(element) {
  15670. return element.offsetParent !== document.body;
  15671. }
  15672. function hasPosition(el, type = "fixed") {
  15673. if (!el || !(el instanceof HTMLElement))
  15674. return !1;
  15675. let { nodeName } = el, styles2 = getStyleComputedProperty2(el);
  15676. return nodeName === "BODY" || nodeName === "HTML" ? !1 : styles2 && styles2.position === type ? !0 : el.parentNode ? hasPosition(el.parentNode, type) : !1;
  15677. }
  15678. function isElementVisible(element) {
  15679. var _a2;
  15680. if (!element)
  15681. return !1;
  15682. let parentElement = element;
  15683. for (; parentElement && parentElement !== document.body; ) {
  15684. if (parentElement instanceof HTMLElement) {
  15685. let { display, visibility } = getComputedStyle(parentElement);
  15686. if (display === "none" || visibility === "hidden")
  15687. return !1;
  15688. }
  15689. parentElement = (_a2 = parentElement.parentElement) != null ? _a2 : null;
  15690. }
  15691. return !0;
  15692. }
  15693. function getElementPosition(element, offset2, skipFix) {
  15694. var _a2, _b, _c;
  15695. let elementRect = getClientRect2(element), parent = getScrollParent2(element, skipFix), hasScrollParent = hasCustomScrollParent(element, skipFix), isFixedTarget = hasPosition(element), parentTop = 0, top = (_a2 = elementRect?.top) != null ? _a2 : 0;
  15696. if (hasScrollParent && isFixedTarget) {
  15697. let offsetTop = (_b = element?.offsetTop) != null ? _b : 0, parentScrollTop = (_c = parent?.scrollTop) != null ? _c : 0;
  15698. top = offsetTop - parentScrollTop;
  15699. } else parent instanceof HTMLElement && (parentTop = parent.scrollTop, !hasScrollParent && !hasPosition(element) && (top += parentTop), parent.isSameNode(scrollDocument()) || (top += scrollDocument().scrollTop));
  15700. return Math.floor(top - offset2);
  15701. }
  15702. function getScrollTo(element, offset2, skipFix) {
  15703. var _a2;
  15704. if (!element)
  15705. return 0;
  15706. let { offsetTop = 0, scrollTop = 0 } = (_a2 = (0, import_scrollparent.default)(element)) != null ? _a2 : {}, top = element.getBoundingClientRect().top + scrollTop;
  15707. offsetTop && (hasCustomScrollParent(element, skipFix) || hasCustomOffsetParent(element)) && (top -= offsetTop);
  15708. let output = Math.floor(top - offset2);
  15709. return output < 0 ? 0 : output;
  15710. }
  15711. function scrollDocument() {
  15712. var _a2;
  15713. return (_a2 = document.scrollingElement) != null ? _a2 : document.documentElement;
  15714. }
  15715. function scrollTo(value, options2) {
  15716. let { duration, element } = options2;
  15717. return new Promise((resolve, reject) => {
  15718. let { scrollTop } = element, limit = value > scrollTop ? value - scrollTop : scrollTop - value;
  15719. import_scroll.default.top(element, value, { duration: limit < 100 ? 50 : duration }, (error) => error && error.message !== "Element already at target scroll position" ? reject(error) : resolve());
  15720. });
  15721. }
  15722. var isReact162 = createPortal !== void 0;
  15723. function getBrowser(userAgent = navigator.userAgent) {
  15724. let browser = userAgent;
  15725. return typeof window > "u" ? browser = "node" : document.documentMode ? browser = "ie" : /Edge/.test(userAgent) ? browser = "edge" : window.opera || userAgent.includes(" OPR/") ? browser = "opera" : typeof window.InstallTrigger < "u" ? browser = "firefox" : window.chrome ? browser = "chrome" : /(Version\/([\d._]+).*Safari|CriOS|FxiOS| Mobile\/)/.test(userAgent) && (browser = "safari"), browser;
  15726. }
  15727. function getObjectType4(value) {
  15728. return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
  15729. }
  15730. function getReactNodeText(input, options2 = {}) {
  15731. let { defaultValue, step, steps } = options2, text = (0, import_react_innertext.default)(input);
  15732. if (text)
  15733. (text.includes("{step}") || text.includes("{steps}")) && step && steps && (text = text.replace("{step}", step.toString()).replace("{steps}", steps.toString()));
  15734. else if (isValidElement(input) && !Object.values(input.props).length && getObjectType4(input.type) === "function") {
  15735. let component = input.type({});
  15736. text = getReactNodeText(component, options2);
  15737. } else
  15738. text = (0, import_react_innertext.default)(defaultValue);
  15739. return text;
  15740. }
  15741. function hasValidKeys(object, keys) {
  15742. return !src_default.plainObject(object) || !src_default.array(keys) ? !1 : Object.keys(object).every((d2) => keys.includes(d2));
  15743. }
  15744. function hexToRGB(hex) {
  15745. let shorthandRegex = /^#?([\da-f])([\da-f])([\da-f])$/i, properHex = hex.replace(shorthandRegex, (_m, r4, g2, b2) => r4 + r4 + g2 + g2 + b2 + b2), result = /^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i.exec(properHex);
  15746. return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : [];
  15747. }
  15748. function hideBeacon(step) {
  15749. return step.disableBeacon || step.placement === "center";
  15750. }
  15751. function isLegacy() {
  15752. return !["chrome", "safari", "firefox", "opera"].includes(getBrowser());
  15753. }
  15754. function log2({ data, debug = !1, title: title2, warn = !1 }) {
  15755. let logFn = warn ? console.warn || console.error : console.log;
  15756. debug && (title2 && data ? (console.groupCollapsed(
  15757. `%creact-joyride: ${title2}`,
  15758. "color: #ff0044; font-weight: bold; font-size: 12px;"
  15759. ), Array.isArray(data) ? data.forEach((d2) => {
  15760. src_default.plainObject(d2) && d2.key ? logFn.apply(console, [d2.key, d2.value]) : logFn.apply(console, [d2]);
  15761. }) : logFn.apply(console, [data]), console.groupEnd()) : console.error("Missing title or data props"));
  15762. }
  15763. function objectKeys(input) {
  15764. return Object.keys(input);
  15765. }
  15766. function omit2(input, ...filter) {
  15767. if (!src_default.plainObject(input))
  15768. throw new TypeError("Expected an object");
  15769. let output = {};
  15770. for (let key in input)
  15771. ({}).hasOwnProperty.call(input, key) && (filter.includes(key) || (output[key] = input[key]));
  15772. return output;
  15773. }
  15774. function pick2(input, ...filter) {
  15775. if (!src_default.plainObject(input))
  15776. throw new TypeError("Expected an object");
  15777. if (!filter.length)
  15778. return input;
  15779. let output = {};
  15780. for (let key in input)
  15781. ({}).hasOwnProperty.call(input, key) && filter.includes(key) && (output[key] = input[key]);
  15782. return output;
  15783. }
  15784. function replaceLocaleContent(input, step, steps) {
  15785. let replacer = (text) => text.replace("{step}", String(step)).replace("{steps}", String(steps));
  15786. if (getObjectType4(input) === "string")
  15787. return replacer(input);
  15788. if (!isValidElement(input))
  15789. return input;
  15790. let { children } = input.props;
  15791. if (getObjectType4(children) === "string" && children.includes("{step}"))
  15792. return cloneElement(input, {
  15793. children: replacer(children)
  15794. });
  15795. if (Array.isArray(children))
  15796. return cloneElement(input, {
  15797. children: children.map((child) => typeof child == "string" ? replacer(child) : replaceLocaleContent(child, step, steps))
  15798. });
  15799. if (getObjectType4(input.type) === "function" && !Object.values(input.props).length) {
  15800. let component = input.type({});
  15801. return replaceLocaleContent(component, step, steps);
  15802. }
  15803. return input;
  15804. }
  15805. function shouldScroll(options2) {
  15806. let { isFirstStep, lifecycle, previousLifecycle, scrollToFirstStep, step, target } = options2;
  15807. return !step.disableScrolling && (!isFirstStep || scrollToFirstStep || lifecycle === LIFECYCLE.TOOLTIP) && step.placement !== "center" && (!step.isFixed || !hasPosition(target)) && // fixed steps don't need to scroll
  15808. previousLifecycle !== lifecycle && [LIFECYCLE.BEACON, LIFECYCLE.TOOLTIP].includes(lifecycle);
  15809. }
  15810. var defaultFloaterProps = {
  15811. options: {
  15812. preventOverflow: {
  15813. boundariesElement: "scrollParent"
  15814. }
  15815. },
  15816. wrapperOptions: {
  15817. offset: -18,
  15818. position: !0
  15819. }
  15820. }, defaultLocale = {
  15821. back: "Back",
  15822. close: "Close",
  15823. last: "Last",
  15824. next: "Next",
  15825. nextLabelWithProgress: "Next (Step {step} of {steps})",
  15826. open: "Open the dialog",
  15827. skip: "Skip"
  15828. }, defaultStep = {
  15829. event: "click",
  15830. placement: "bottom",
  15831. offset: 10,
  15832. disableBeacon: !1,
  15833. disableCloseOnEsc: !1,
  15834. disableOverlay: !1,
  15835. disableOverlayClose: !1,
  15836. disableScrollParentFix: !1,
  15837. disableScrolling: !1,
  15838. hideBackButton: !1,
  15839. hideCloseButton: !1,
  15840. hideFooter: !1,
  15841. isFixed: !1,
  15842. locale: defaultLocale,
  15843. showProgress: !1,
  15844. showSkipButton: !1,
  15845. spotlightClicks: !1,
  15846. spotlightPadding: 10
  15847. }, defaultProps = {
  15848. continuous: !1,
  15849. debug: !1,
  15850. disableCloseOnEsc: !1,
  15851. disableOverlay: !1,
  15852. disableOverlayClose: !1,
  15853. disableScrolling: !1,
  15854. disableScrollParentFix: !1,
  15855. getHelpers: void 0,
  15856. hideBackButton: !1,
  15857. run: !0,
  15858. scrollOffset: 20,
  15859. scrollDuration: 300,
  15860. scrollToFirstStep: !1,
  15861. showSkipButton: !1,
  15862. showProgress: !1,
  15863. spotlightClicks: !1,
  15864. spotlightPadding: 10,
  15865. steps: []
  15866. }, defaultOptions2 = {
  15867. arrowColor: "#fff",
  15868. backgroundColor: "#fff",
  15869. beaconSize: 36,
  15870. overlayColor: "rgba(0, 0, 0, 0.5)",
  15871. primaryColor: "#f04",
  15872. spotlightShadow: "0 0 15px rgba(0, 0, 0, 0.5)",
  15873. textColor: "#333",
  15874. width: 380,
  15875. zIndex: 100
  15876. }, buttonBase = {
  15877. backgroundColor: "transparent",
  15878. border: 0,
  15879. borderRadius: 0,
  15880. color: "#555",
  15881. cursor: "pointer",
  15882. fontSize: 16,
  15883. lineHeight: 1,
  15884. padding: 8,
  15885. WebkitAppearance: "none"
  15886. }, spotlight = {
  15887. borderRadius: 4,
  15888. position: "absolute"
  15889. };
  15890. function getStyles2(props, step) {
  15891. var _a2, _b, _c, _d, _e;
  15892. let { floaterProps, styles: styles2 } = props, mergedFloaterProps = (0, import_deepmerge3.default)((_a2 = step.floaterProps) != null ? _a2 : {}, floaterProps ?? {}), mergedStyles = (0, import_deepmerge3.default)(styles2 ?? {}, (_b = step.styles) != null ? _b : {}), options2 = (0, import_deepmerge3.default)(defaultOptions2, mergedStyles.options || {}), hideBeacon2 = step.placement === "center" || step.disableBeacon, { width } = options2;
  15893. window.innerWidth > 480 && (width = 380), "width" in options2 && (width = typeof options2.width == "number" && window.innerWidth < options2.width ? window.innerWidth - 30 : options2.width);
  15894. let overlay = {
  15895. bottom: 0,
  15896. left: 0,
  15897. overflow: "hidden",
  15898. position: "absolute",
  15899. right: 0,
  15900. top: 0,
  15901. zIndex: options2.zIndex
  15902. }, defaultStyles = {
  15903. beacon: {
  15904. ...buttonBase,
  15905. display: hideBeacon2 ? "none" : "inline-block",
  15906. height: options2.beaconSize,
  15907. position: "relative",
  15908. width: options2.beaconSize,
  15909. zIndex: options2.zIndex
  15910. },
  15911. beaconInner: {
  15912. animation: "joyride-beacon-inner 1.2s infinite ease-in-out",
  15913. backgroundColor: options2.primaryColor,
  15914. borderRadius: "50%",
  15915. display: "block",
  15916. height: "50%",
  15917. left: "50%",
  15918. opacity: 0.7,
  15919. position: "absolute",
  15920. top: "50%",
  15921. transform: "translate(-50%, -50%)",
  15922. width: "50%"
  15923. },
  15924. beaconOuter: {
  15925. animation: "joyride-beacon-outer 1.2s infinite ease-in-out",
  15926. backgroundColor: `rgba(${hexToRGB(options2.primaryColor).join(",")}, 0.2)`,
  15927. border: `2px solid ${options2.primaryColor}`,
  15928. borderRadius: "50%",
  15929. boxSizing: "border-box",
  15930. display: "block",
  15931. height: "100%",
  15932. left: 0,
  15933. opacity: 0.9,
  15934. position: "absolute",
  15935. top: 0,
  15936. transformOrigin: "center",
  15937. width: "100%"
  15938. },
  15939. tooltip: {
  15940. backgroundColor: options2.backgroundColor,
  15941. borderRadius: 5,
  15942. boxSizing: "border-box",
  15943. color: options2.textColor,
  15944. fontSize: 16,
  15945. maxWidth: "100%",
  15946. padding: 15,
  15947. position: "relative",
  15948. width
  15949. },
  15950. tooltipContainer: {
  15951. lineHeight: 1.4,
  15952. textAlign: "center"
  15953. },
  15954. tooltipTitle: {
  15955. fontSize: 18,
  15956. margin: 0
  15957. },
  15958. tooltipContent: {
  15959. padding: "20px 10px"
  15960. },
  15961. tooltipFooter: {
  15962. alignItems: "center",
  15963. display: "flex",
  15964. justifyContent: "flex-end",
  15965. marginTop: 15
  15966. },
  15967. tooltipFooterSpacer: {
  15968. flex: 1
  15969. },
  15970. buttonNext: {
  15971. ...buttonBase,
  15972. backgroundColor: options2.primaryColor,
  15973. borderRadius: 4,
  15974. color: "#fff"
  15975. },
  15976. buttonBack: {
  15977. ...buttonBase,
  15978. color: options2.primaryColor,
  15979. marginLeft: "auto",
  15980. marginRight: 5
  15981. },
  15982. buttonClose: {
  15983. ...buttonBase,
  15984. color: options2.textColor,
  15985. height: 14,
  15986. padding: 15,
  15987. position: "absolute",
  15988. right: 0,
  15989. top: 0,
  15990. width: 14
  15991. },
  15992. buttonSkip: {
  15993. ...buttonBase,
  15994. color: options2.textColor,
  15995. fontSize: 14
  15996. },
  15997. overlay: {
  15998. ...overlay,
  15999. backgroundColor: options2.overlayColor,
  16000. mixBlendMode: "hard-light"
  16001. },
  16002. overlayLegacy: {
  16003. ...overlay
  16004. },
  16005. overlayLegacyCenter: {
  16006. ...overlay,
  16007. backgroundColor: options2.overlayColor
  16008. },
  16009. spotlight: {
  16010. ...spotlight,
  16011. backgroundColor: "gray"
  16012. },
  16013. spotlightLegacy: {
  16014. ...spotlight,
  16015. boxShadow: `0 0 0 9999px ${options2.overlayColor}, ${options2.spotlightShadow}`
  16016. },
  16017. floaterStyles: {
  16018. arrow: {
  16019. color: (_e = (_d = (_c = mergedFloaterProps?.styles) == null ? void 0 : _c.arrow) == null ? void 0 : _d.color) != null ? _e : options2.arrowColor
  16020. },
  16021. options: {
  16022. zIndex: options2.zIndex + 100
  16023. }
  16024. },
  16025. options: options2
  16026. };
  16027. return (0, import_deepmerge3.default)(defaultStyles, mergedStyles);
  16028. }
  16029. function getTourProps(props) {
  16030. return pick2(
  16031. props,
  16032. "beaconComponent",
  16033. "disableCloseOnEsc",
  16034. "disableOverlay",
  16035. "disableOverlayClose",
  16036. "disableScrolling",
  16037. "disableScrollParentFix",
  16038. "floaterProps",
  16039. "hideBackButton",
  16040. "hideCloseButton",
  16041. "locale",
  16042. "showProgress",
  16043. "showSkipButton",
  16044. "spotlightClicks",
  16045. "spotlightPadding",
  16046. "styles",
  16047. "tooltipComponent"
  16048. );
  16049. }
  16050. function getMergedStep(props, currentStep) {
  16051. var _a2, _b, _c, _d, _e, _f;
  16052. let step = currentStep ?? {}, mergedStep = import_deepmerge2.default.all([defaultStep, getTourProps(props), step], {
  16053. isMergeableObject: src_default.plainObject
  16054. }), mergedStyles = getStyles2(props, mergedStep), scrollParent2 = hasCustomScrollParent(
  16055. getElement(mergedStep.target),
  16056. mergedStep.disableScrollParentFix
  16057. ), floaterProps = import_deepmerge2.default.all([
  16058. defaultFloaterProps,
  16059. (_a2 = props.floaterProps) != null ? _a2 : {},
  16060. (_b = mergedStep.floaterProps) != null ? _b : {}
  16061. ]);
  16062. return floaterProps.offset = mergedStep.offset, floaterProps.styles = (0, import_deepmerge2.default)((_c = floaterProps.styles) != null ? _c : {}, mergedStyles.floaterStyles), floaterProps.offset += (_e = (_d = props.spotlightPadding) != null ? _d : mergedStep.spotlightPadding) != null ? _e : 0, mergedStep.placementBeacon && floaterProps.wrapperOptions && (floaterProps.wrapperOptions.placement = mergedStep.placementBeacon), scrollParent2 && floaterProps.options.preventOverflow && (floaterProps.options.preventOverflow.boundariesElement = "window"), {
  16063. ...mergedStep,
  16064. locale: import_deepmerge2.default.all([defaultLocale, (_f = props.locale) != null ? _f : {}, mergedStep.locale || {}]),
  16065. floaterProps,
  16066. styles: omit2(mergedStyles, "floaterStyles")
  16067. };
  16068. }
  16069. function validateStep(step, debug = !1) {
  16070. return src_default.plainObject(step) ? step.target ? !0 : (log2({
  16071. title: "validateStep",
  16072. data: "target is missing from the step",
  16073. warn: !0,
  16074. debug
  16075. }), !1) : (log2({
  16076. title: "validateStep",
  16077. data: "step must be an object",
  16078. warn: !0,
  16079. debug
  16080. }), !1);
  16081. }
  16082. function validateSteps(steps, debug = !1) {
  16083. return src_default.array(steps) ? steps.every((d2) => validateStep(d2, debug)) : (log2({
  16084. title: "validateSteps",
  16085. data: "steps must be an array",
  16086. warn: !0,
  16087. debug
  16088. }), !1);
  16089. }
  16090. var defaultState = {
  16091. action: "init",
  16092. controlled: !1,
  16093. index: 0,
  16094. lifecycle: LIFECYCLE.INIT,
  16095. origin: null,
  16096. size: 0,
  16097. status: STATUS3.IDLE
  16098. }, validKeys = objectKeys(omit2(defaultState, "controlled", "size")), Store = class {
  16099. constructor(options2) {
  16100. __publicField(this, "beaconPopper"), __publicField(this, "tooltipPopper"), __publicField(this, "data", /* @__PURE__ */ new Map()), __publicField(this, "listener"), __publicField(this, "store", /* @__PURE__ */ new Map()), __publicField(this, "addListener", (listener) => {
  16101. this.listener = listener;
  16102. }), __publicField(this, "setSteps", (steps2) => {
  16103. let { size, status } = this.getState(), state = {
  16104. size: steps2.length,
  16105. status
  16106. };
  16107. this.data.set("steps", steps2), status === STATUS3.WAITING && !size && steps2.length && (state.status = STATUS3.RUNNING), this.setState(state);
  16108. }), __publicField(this, "getPopper", (name) => name === "beacon" ? this.beaconPopper : this.tooltipPopper), __publicField(this, "setPopper", (name, popper) => {
  16109. name === "beacon" ? this.beaconPopper = popper : this.tooltipPopper = popper;
  16110. }), __publicField(this, "cleanupPoppers", () => {
  16111. this.beaconPopper = null, this.tooltipPopper = null;
  16112. }), __publicField(this, "close", (origin = null) => {
  16113. let { index, status } = this.getState();
  16114. status === STATUS3.RUNNING && this.setState({
  16115. ...this.getNextState({ action: ACTIONS.CLOSE, index: index + 1, origin })
  16116. });
  16117. }), __publicField(this, "go", (nextIndex) => {
  16118. let { controlled, status } = this.getState();
  16119. if (controlled || status !== STATUS3.RUNNING)
  16120. return;
  16121. let step = this.getSteps()[nextIndex];
  16122. this.setState({
  16123. ...this.getNextState({ action: ACTIONS.GO, index: nextIndex }),
  16124. status: step ? status : STATUS3.FINISHED
  16125. });
  16126. }), __publicField(this, "info", () => this.getState()), __publicField(this, "next", () => {
  16127. let { index, status } = this.getState();
  16128. status === STATUS3.RUNNING && this.setState(this.getNextState({ action: ACTIONS.NEXT, index: index + 1 }));
  16129. }), __publicField(this, "open", () => {
  16130. let { status } = this.getState();
  16131. status === STATUS3.RUNNING && this.setState({
  16132. ...this.getNextState({ action: ACTIONS.UPDATE, lifecycle: LIFECYCLE.TOOLTIP })
  16133. });
  16134. }), __publicField(this, "prev", () => {
  16135. let { index, status } = this.getState();
  16136. status === STATUS3.RUNNING && this.setState({
  16137. ...this.getNextState({ action: ACTIONS.PREV, index: index - 1 })
  16138. });
  16139. }), __publicField(this, "reset", (restart = !1) => {
  16140. let { controlled } = this.getState();
  16141. controlled || this.setState({
  16142. ...this.getNextState({ action: ACTIONS.RESET, index: 0 }),
  16143. status: restart ? STATUS3.RUNNING : STATUS3.READY
  16144. });
  16145. }), __publicField(this, "skip", () => {
  16146. let { status } = this.getState();
  16147. status === STATUS3.RUNNING && this.setState({
  16148. action: ACTIONS.SKIP,
  16149. lifecycle: LIFECYCLE.INIT,
  16150. status: STATUS3.SKIPPED
  16151. });
  16152. }), __publicField(this, "start", (nextIndex) => {
  16153. let { index, size } = this.getState();
  16154. this.setState({
  16155. ...this.getNextState(
  16156. {
  16157. action: ACTIONS.START,
  16158. index: src_default.number(nextIndex) ? nextIndex : index
  16159. },
  16160. !0
  16161. ),
  16162. status: size ? STATUS3.RUNNING : STATUS3.WAITING
  16163. });
  16164. }), __publicField(this, "stop", (advance = !1) => {
  16165. let { index, status } = this.getState();
  16166. [STATUS3.FINISHED, STATUS3.SKIPPED].includes(status) || this.setState({
  16167. ...this.getNextState({ action: ACTIONS.STOP, index: index + (advance ? 1 : 0) }),
  16168. status: STATUS3.PAUSED
  16169. });
  16170. }), __publicField(this, "update", (state) => {
  16171. var _a2, _b;
  16172. if (!hasValidKeys(state, validKeys))
  16173. throw new Error(`State is not valid. Valid keys: ${validKeys.join(", ")}`);
  16174. this.setState({
  16175. ...this.getNextState(
  16176. {
  16177. ...this.getState(),
  16178. ...state,
  16179. action: (_a2 = state.action) != null ? _a2 : ACTIONS.UPDATE,
  16180. origin: (_b = state.origin) != null ? _b : null
  16181. },
  16182. !0
  16183. )
  16184. });
  16185. });
  16186. let { continuous = !1, stepIndex, steps = [] } = options2 ?? {};
  16187. this.setState(
  16188. {
  16189. action: ACTIONS.INIT,
  16190. controlled: src_default.number(stepIndex),
  16191. continuous,
  16192. index: src_default.number(stepIndex) ? stepIndex : 0,
  16193. lifecycle: LIFECYCLE.INIT,
  16194. origin: null,
  16195. status: steps.length ? STATUS3.READY : STATUS3.IDLE
  16196. },
  16197. !0
  16198. ), this.beaconPopper = null, this.tooltipPopper = null, this.listener = null, this.setSteps(steps);
  16199. }
  16200. getState() {
  16201. return this.store.size ? {
  16202. action: this.store.get("action") || "",
  16203. controlled: this.store.get("controlled") || !1,
  16204. index: parseInt(this.store.get("index"), 10),
  16205. lifecycle: this.store.get("lifecycle") || "",
  16206. origin: this.store.get("origin") || null,
  16207. size: this.store.get("size") || 0,
  16208. status: this.store.get("status") || ""
  16209. } : { ...defaultState };
  16210. }
  16211. getNextState(state, force = !1) {
  16212. var _a2, _b, _c, _d, _e;
  16213. let { action, controlled, index, size, status } = this.getState(), newIndex = src_default.number(state.index) ? state.index : index, nextIndex = controlled && !force ? index : Math.min(Math.max(newIndex, 0), size);
  16214. return {
  16215. action: (_a2 = state.action) != null ? _a2 : action,
  16216. controlled,
  16217. index: nextIndex,
  16218. lifecycle: (_b = state.lifecycle) != null ? _b : LIFECYCLE.INIT,
  16219. origin: (_c = state.origin) != null ? _c : null,
  16220. size: (_d = state.size) != null ? _d : size,
  16221. status: nextIndex === size ? STATUS3.FINISHED : (_e = state.status) != null ? _e : status
  16222. };
  16223. }
  16224. getSteps() {
  16225. let steps = this.data.get("steps");
  16226. return Array.isArray(steps) ? steps : [];
  16227. }
  16228. hasUpdatedState(oldState) {
  16229. let before2 = JSON.stringify(oldState), after2 = JSON.stringify(this.getState());
  16230. return before2 !== after2;
  16231. }
  16232. setState(nextState, initial = !1) {
  16233. let state = this.getState(), {
  16234. action,
  16235. index,
  16236. lifecycle,
  16237. origin = null,
  16238. size,
  16239. status
  16240. } = {
  16241. ...state,
  16242. ...nextState
  16243. };
  16244. this.store.set("action", action), this.store.set("index", index), this.store.set("lifecycle", lifecycle), this.store.set("origin", origin), this.store.set("size", size), this.store.set("status", status), initial && (this.store.set("controlled", nextState.controlled), this.store.set("continuous", nextState.continuous)), this.listener && this.hasUpdatedState(state) && this.listener(this.getState());
  16245. }
  16246. getHelpers() {
  16247. return {
  16248. close: this.close,
  16249. go: this.go,
  16250. info: this.info,
  16251. next: this.next,
  16252. open: this.open,
  16253. prev: this.prev,
  16254. reset: this.reset,
  16255. skip: this.skip
  16256. };
  16257. }
  16258. };
  16259. function createStore(options2) {
  16260. return new Store(options2);
  16261. }
  16262. function JoyrideSpotlight({ styles: styles2 }) {
  16263. return createElement(
  16264. "div",
  16265. {
  16266. key: "JoyrideSpotlight",
  16267. className: "react-joyride__spotlight",
  16268. "data-test-id": "spotlight",
  16269. style: styles2
  16270. }
  16271. );
  16272. }
  16273. var Spotlight_default = JoyrideSpotlight, JoyrideOverlay = class extends Component {
  16274. constructor() {
  16275. super(...arguments), __publicField(this, "isActive", !1), __publicField(this, "resizeTimeout"), __publicField(this, "scrollTimeout"), __publicField(this, "scrollParent"), __publicField(this, "state", {
  16276. isScrolling: !1,
  16277. mouseOverSpotlight: !1,
  16278. showSpotlight: !0
  16279. }), __publicField(this, "hideSpotlight", () => {
  16280. let { continuous, disableOverlay, lifecycle } = this.props, hiddenLifecycles = [
  16281. LIFECYCLE.INIT,
  16282. LIFECYCLE.BEACON,
  16283. LIFECYCLE.COMPLETE,
  16284. LIFECYCLE.ERROR
  16285. ];
  16286. return disableOverlay || (continuous ? hiddenLifecycles.includes(lifecycle) : lifecycle !== LIFECYCLE.TOOLTIP);
  16287. }), __publicField(this, "handleMouseMove", (event) => {
  16288. let { mouseOverSpotlight } = this.state, { height, left, position, top, width } = this.spotlightStyles, offsetY = position === "fixed" ? event.clientY : event.pageY, offsetX = position === "fixed" ? event.clientX : event.pageX, inSpotlightHeight = offsetY >= top && offsetY <= top + height, inSpotlight = offsetX >= left && offsetX <= left + width && inSpotlightHeight;
  16289. inSpotlight !== mouseOverSpotlight && this.updateState({ mouseOverSpotlight: inSpotlight });
  16290. }), __publicField(this, "handleScroll", () => {
  16291. let { target } = this.props, element = getElement(target);
  16292. if (this.scrollParent !== document) {
  16293. let { isScrolling } = this.state;
  16294. isScrolling || this.updateState({ isScrolling: !0, showSpotlight: !1 }), clearTimeout(this.scrollTimeout), this.scrollTimeout = window.setTimeout(() => {
  16295. this.updateState({ isScrolling: !1, showSpotlight: !0 });
  16296. }, 50);
  16297. } else hasPosition(element, "sticky") && this.updateState({});
  16298. }), __publicField(this, "handleResize", () => {
  16299. clearTimeout(this.resizeTimeout), this.resizeTimeout = window.setTimeout(() => {
  16300. this.isActive && this.forceUpdate();
  16301. }, 100);
  16302. });
  16303. }
  16304. componentDidMount() {
  16305. let { debug, disableScrolling, disableScrollParentFix = !1, target } = this.props, element = getElement(target);
  16306. this.scrollParent = getScrollParent2(element ?? document.body, disableScrollParentFix, !0), this.isActive = !0, window.addEventListener("resize", this.handleResize);
  16307. }
  16308. componentDidUpdate(previousProps) {
  16309. var _a2;
  16310. let { disableScrollParentFix, lifecycle, spotlightClicks, target } = this.props, { changed } = treeChanges(previousProps, this.props);
  16311. if (changed("target") || changed("disableScrollParentFix")) {
  16312. let element = getElement(target);
  16313. this.scrollParent = getScrollParent2(element ?? document.body, disableScrollParentFix, !0);
  16314. }
  16315. changed("lifecycle", LIFECYCLE.TOOLTIP) && ((_a2 = this.scrollParent) == null || _a2.addEventListener("scroll", this.handleScroll, { passive: !0 }), setTimeout(() => {
  16316. let { isScrolling } = this.state;
  16317. isScrolling || this.updateState({ showSpotlight: !0 });
  16318. }, 100)), (changed("spotlightClicks") || changed("disableOverlay") || changed("lifecycle")) && (spotlightClicks && lifecycle === LIFECYCLE.TOOLTIP ? window.addEventListener("mousemove", this.handleMouseMove, !1) : lifecycle !== LIFECYCLE.TOOLTIP && window.removeEventListener("mousemove", this.handleMouseMove));
  16319. }
  16320. componentWillUnmount() {
  16321. var _a2;
  16322. this.isActive = !1, window.removeEventListener("mousemove", this.handleMouseMove), window.removeEventListener("resize", this.handleResize), clearTimeout(this.resizeTimeout), clearTimeout(this.scrollTimeout), (_a2 = this.scrollParent) == null || _a2.removeEventListener("scroll", this.handleScroll);
  16323. }
  16324. get overlayStyles() {
  16325. let { mouseOverSpotlight } = this.state, { disableOverlayClose, placement, styles: styles2 } = this.props, baseStyles = styles2.overlay;
  16326. return isLegacy() && (baseStyles = placement === "center" ? styles2.overlayLegacyCenter : styles2.overlayLegacy), {
  16327. cursor: disableOverlayClose ? "default" : "pointer",
  16328. height: getDocumentHeight(),
  16329. pointerEvents: mouseOverSpotlight ? "none" : "auto",
  16330. ...baseStyles
  16331. };
  16332. }
  16333. get spotlightStyles() {
  16334. var _a2, _b, _c;
  16335. let { showSpotlight } = this.state, {
  16336. disableScrollParentFix = !1,
  16337. spotlightClicks,
  16338. spotlightPadding = 0,
  16339. styles: styles2,
  16340. target
  16341. } = this.props, element = getElement(target), elementRect = getClientRect2(element), isFixedTarget = hasPosition(element), top = getElementPosition(element, spotlightPadding, disableScrollParentFix);
  16342. return {
  16343. ...isLegacy() ? styles2.spotlightLegacy : styles2.spotlight,
  16344. height: Math.round(((_a2 = elementRect?.height) != null ? _a2 : 0) + spotlightPadding * 2),
  16345. left: Math.round(((_b = elementRect?.left) != null ? _b : 0) - spotlightPadding),
  16346. opacity: showSpotlight ? 1 : 0,
  16347. pointerEvents: spotlightClicks ? "none" : "auto",
  16348. position: isFixedTarget ? "fixed" : "absolute",
  16349. top,
  16350. transition: "opacity 0.2s",
  16351. width: Math.round(((_c = elementRect?.width) != null ? _c : 0) + spotlightPadding * 2)
  16352. };
  16353. }
  16354. updateState(state) {
  16355. this.isActive && this.setState((previousState) => ({ ...previousState, ...state }));
  16356. }
  16357. render() {
  16358. let { showSpotlight } = this.state, { onClickOverlay, placement } = this.props, { hideSpotlight, overlayStyles, spotlightStyles } = this;
  16359. if (hideSpotlight())
  16360. return null;
  16361. let spotlight2 = placement !== "center" && showSpotlight && createElement(Spotlight_default, { styles: spotlightStyles });
  16362. if (getBrowser() === "safari") {
  16363. let { mixBlendMode, zIndex, ...safariOverlay } = overlayStyles;
  16364. spotlight2 = createElement("div", { style: { ...safariOverlay } }, spotlight2), delete overlayStyles.backgroundColor;
  16365. }
  16366. return createElement(
  16367. "div",
  16368. {
  16369. className: "react-joyride__overlay",
  16370. "data-test-id": "overlay",
  16371. onClick: onClickOverlay,
  16372. role: "presentation",
  16373. style: overlayStyles
  16374. },
  16375. spotlight2
  16376. );
  16377. }
  16378. }, JoyridePortal = class extends Component {
  16379. constructor() {
  16380. super(...arguments), __publicField(this, "node", null);
  16381. }
  16382. componentDidMount() {
  16383. let { id } = this.props;
  16384. canUseDOM2() && (this.node = document.createElement("div"), this.node.id = id, document.body.appendChild(this.node), isReact162 || this.renderReact15());
  16385. }
  16386. componentDidUpdate() {
  16387. canUseDOM2() && (isReact162 || this.renderReact15());
  16388. }
  16389. componentWillUnmount() {
  16390. !canUseDOM2() || !this.node || (isReact162 || unmountComponentAtNode(this.node), this.node.parentNode === document.body && (document.body.removeChild(this.node), this.node = null));
  16391. }
  16392. renderReact15() {
  16393. if (!canUseDOM2())
  16394. return;
  16395. let { children } = this.props;
  16396. this.node && unstable_renderSubtreeIntoContainer(this, children, this.node);
  16397. }
  16398. renderReact16() {
  16399. if (!canUseDOM2() || !isReact162)
  16400. return null;
  16401. let { children } = this.props;
  16402. return this.node ? createPortal(children, this.node) : null;
  16403. }
  16404. render() {
  16405. return isReact162 ? this.renderReact16() : null;
  16406. }
  16407. }, Scope = class {
  16408. constructor(element, options2) {
  16409. if (__publicField(this, "element"), __publicField(this, "options"), __publicField(this, "canBeTabbed", (element2) => {
  16410. let { tabIndex } = element2;
  16411. return tabIndex === null || tabIndex < 0 ? !1 : this.canHaveFocus(element2);
  16412. }), __publicField(this, "canHaveFocus", (element2) => {
  16413. let validTabNodes = /input|select|textarea|button|object/, nodeName = element2.nodeName.toLowerCase();
  16414. return (validTabNodes.test(nodeName) && !element2.getAttribute("disabled") || nodeName === "a" && !!element2.getAttribute("href")) && this.isVisible(element2);
  16415. }), __publicField(this, "findValidTabElements", () => [].slice.call(this.element.querySelectorAll("*"), 0).filter(this.canBeTabbed)), __publicField(this, "handleKeyDown", (event) => {
  16416. let { code = "Tab" } = this.options;
  16417. event.code === code && this.interceptTab(event);
  16418. }), __publicField(this, "interceptTab", (event) => {
  16419. event.preventDefault();
  16420. let elements = this.findValidTabElements(), { shiftKey } = event;
  16421. if (!elements.length)
  16422. return;
  16423. let x2 = document.activeElement ? elements.indexOf(document.activeElement) : 0;
  16424. x2 === -1 || !shiftKey && x2 + 1 === elements.length ? x2 = 0 : shiftKey && x2 === 0 ? x2 = elements.length - 1 : x2 += shiftKey ? -1 : 1, elements[x2].focus();
  16425. }), __publicField(this, "isHidden", (element2) => {
  16426. let noSize = element2.offsetWidth <= 0 && element2.offsetHeight <= 0, style = window.getComputedStyle(element2);
  16427. return noSize && !element2.innerHTML ? !0 : noSize && style.getPropertyValue("overflow") !== "visible" || style.getPropertyValue("display") === "none";
  16428. }), __publicField(this, "isVisible", (element2) => {
  16429. let parentElement = element2;
  16430. for (; parentElement; )
  16431. if (parentElement instanceof HTMLElement) {
  16432. if (parentElement === document.body)
  16433. break;
  16434. if (this.isHidden(parentElement))
  16435. return !1;
  16436. parentElement = parentElement.parentNode;
  16437. }
  16438. return !0;
  16439. }), __publicField(this, "removeScope", () => {
  16440. window.removeEventListener("keydown", this.handleKeyDown);
  16441. }), __publicField(this, "checkFocus", (target) => {
  16442. document.activeElement !== target && (target.focus(), window.requestAnimationFrame(() => this.checkFocus(target)));
  16443. }), __publicField(this, "setFocus", () => {
  16444. let { selector } = this.options;
  16445. if (!selector)
  16446. return;
  16447. let target = this.element.querySelector(selector);
  16448. target && window.requestAnimationFrame(() => this.checkFocus(target));
  16449. }), !(element instanceof HTMLElement))
  16450. throw new TypeError("Invalid parameter: element must be an HTMLElement");
  16451. this.element = element, this.options = options2, window.addEventListener("keydown", this.handleKeyDown, !1), this.setFocus();
  16452. }
  16453. }, JoyrideBeacon = class extends Component {
  16454. constructor(props) {
  16455. if (super(props), __publicField(this, "beacon", null), __publicField(this, "setBeaconRef", (c2) => {
  16456. this.beacon = c2;
  16457. }), props.beaconComponent)
  16458. return;
  16459. let head = document.head || document.getElementsByTagName("head")[0], style = document.createElement("style");
  16460. style.id = "joyride-beacon-animation", props.nonce && style.setAttribute("nonce", props.nonce), style.appendChild(document.createTextNode(`
  16461. @keyframes joyride-beacon-inner {
  16462. 20% {
  16463. opacity: 0.9;
  16464. }
  16465. 90% {
  16466. opacity: 0.7;
  16467. }
  16468. }
  16469. @keyframes joyride-beacon-outer {
  16470. 0% {
  16471. transform: scale(1);
  16472. }
  16473. 45% {
  16474. opacity: 0.7;
  16475. transform: scale(0.75);
  16476. }
  16477. 100% {
  16478. opacity: 0.9;
  16479. transform: scale(1);
  16480. }
  16481. }
  16482. `)), head.appendChild(style);
  16483. }
  16484. componentDidMount() {
  16485. let { shouldFocus } = this.props;
  16486. setTimeout(() => {
  16487. src_default.domElement(this.beacon) && shouldFocus && this.beacon.focus();
  16488. }, 0);
  16489. }
  16490. componentWillUnmount() {
  16491. let style = document.getElementById("joyride-beacon-animation");
  16492. style?.parentNode && style.parentNode.removeChild(style);
  16493. }
  16494. render() {
  16495. let {
  16496. beaconComponent,
  16497. continuous,
  16498. index,
  16499. isLastStep,
  16500. locale,
  16501. onClickOrHover,
  16502. size,
  16503. step,
  16504. styles: styles2
  16505. } = this.props, title2 = getReactNodeText(locale.open), sharedProps = {
  16506. "aria-label": title2,
  16507. onClick: onClickOrHover,
  16508. onMouseEnter: onClickOrHover,
  16509. ref: this.setBeaconRef,
  16510. title: title2
  16511. }, component;
  16512. return beaconComponent ? component = createElement(
  16513. beaconComponent,
  16514. {
  16515. continuous,
  16516. index,
  16517. isLastStep,
  16518. size,
  16519. step,
  16520. ...sharedProps
  16521. }
  16522. ) : component = createElement(
  16523. "button",
  16524. {
  16525. key: "JoyrideBeacon",
  16526. className: "react-joyride__beacon",
  16527. "data-test-id": "button-beacon",
  16528. style: styles2.beacon,
  16529. type: "button",
  16530. ...sharedProps
  16531. },
  16532. createElement("span", { style: styles2.beaconInner }),
  16533. createElement("span", { style: styles2.beaconOuter })
  16534. ), component;
  16535. }
  16536. };
  16537. function JoyrideTooltipCloseButton({ styles: styles2, ...props }) {
  16538. let { color: color2, height, width, ...style } = styles2;
  16539. return react_default.createElement("button", { style, type: "button", ...props }, react_default.createElement(
  16540. "svg",
  16541. {
  16542. height: typeof height == "number" ? `${height}px` : height,
  16543. preserveAspectRatio: "xMidYMid",
  16544. version: "1.1",
  16545. viewBox: "0 0 18 18",
  16546. width: typeof width == "number" ? `${width}px` : width,
  16547. xmlns: "http://www.w3.org/2000/svg"
  16548. },
  16549. react_default.createElement("g", null, react_default.createElement(
  16550. "path",
  16551. {
  16552. d: "M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",
  16553. fill: color2
  16554. }
  16555. ))
  16556. ));
  16557. }
  16558. var CloseButton_default = JoyrideTooltipCloseButton;
  16559. function JoyrideTooltipContainer(props) {
  16560. let { backProps, closeProps, index, isLastStep, primaryProps, skipProps, step, tooltipProps } = props, { content, hideBackButton, hideCloseButton, hideFooter, showSkipButton, styles: styles2, title: title2 } = step, output = {};
  16561. return output.primary = createElement(
  16562. "button",
  16563. {
  16564. "data-test-id": "button-primary",
  16565. style: styles2.buttonNext,
  16566. type: "button",
  16567. ...primaryProps
  16568. }
  16569. ), showSkipButton && !isLastStep && (output.skip = createElement(
  16570. "button",
  16571. {
  16572. "aria-live": "off",
  16573. "data-test-id": "button-skip",
  16574. style: styles2.buttonSkip,
  16575. type: "button",
  16576. ...skipProps
  16577. }
  16578. )), !hideBackButton && index > 0 && (output.back = createElement("button", { "data-test-id": "button-back", style: styles2.buttonBack, type: "button", ...backProps })), output.close = !hideCloseButton && createElement(CloseButton_default, { "data-test-id": "button-close", styles: styles2.buttonClose, ...closeProps }), createElement(
  16579. "div",
  16580. {
  16581. key: "JoyrideTooltip",
  16582. "aria-label": getReactNodeText(title2 ?? content),
  16583. className: "react-joyride__tooltip",
  16584. style: styles2.tooltip,
  16585. ...tooltipProps
  16586. },
  16587. createElement("div", { style: styles2.tooltipContainer }, title2 && createElement("h1", { "aria-label": getReactNodeText(title2), style: styles2.tooltipTitle }, title2), createElement("div", { style: styles2.tooltipContent }, content)),
  16588. !hideFooter && createElement("div", { style: styles2.tooltipFooter }, createElement("div", { style: styles2.tooltipFooterSpacer }, output.skip), output.back, output.primary),
  16589. output.close
  16590. );
  16591. }
  16592. var Container_default = JoyrideTooltipContainer, JoyrideTooltip = class extends Component {
  16593. constructor() {
  16594. super(...arguments), __publicField(this, "handleClickBack", (event) => {
  16595. event.preventDefault();
  16596. let { helpers } = this.props;
  16597. helpers.prev();
  16598. }), __publicField(this, "handleClickClose", (event) => {
  16599. event.preventDefault();
  16600. let { helpers } = this.props;
  16601. helpers.close("button_close");
  16602. }), __publicField(this, "handleClickPrimary", (event) => {
  16603. event.preventDefault();
  16604. let { continuous, helpers } = this.props;
  16605. if (!continuous) {
  16606. helpers.close("button_primary");
  16607. return;
  16608. }
  16609. helpers.next();
  16610. }), __publicField(this, "handleClickSkip", (event) => {
  16611. event.preventDefault();
  16612. let { helpers } = this.props;
  16613. helpers.skip();
  16614. }), __publicField(this, "getElementsProps", () => {
  16615. let { continuous, index, isLastStep, setTooltipRef, size, step } = this.props, { back, close, last, next, nextLabelWithProgress, skip } = step.locale, backText = getReactNodeText(back), closeText = getReactNodeText(close), lastText = getReactNodeText(last), nextText = getReactNodeText(next), skipText = getReactNodeText(skip), primary = close, primaryText = closeText;
  16616. if (continuous) {
  16617. if (primary = next, primaryText = nextText, step.showProgress && !isLastStep) {
  16618. let labelWithProgress = getReactNodeText(nextLabelWithProgress, {
  16619. step: index + 1,
  16620. steps: size
  16621. });
  16622. primary = replaceLocaleContent(nextLabelWithProgress, index + 1, size), primaryText = labelWithProgress;
  16623. }
  16624. isLastStep && (primary = last, primaryText = lastText);
  16625. }
  16626. return {
  16627. backProps: {
  16628. "aria-label": backText,
  16629. children: back,
  16630. "data-action": "back",
  16631. onClick: this.handleClickBack,
  16632. role: "button",
  16633. title: backText
  16634. },
  16635. closeProps: {
  16636. "aria-label": closeText,
  16637. children: close,
  16638. "data-action": "close",
  16639. onClick: this.handleClickClose,
  16640. role: "button",
  16641. title: closeText
  16642. },
  16643. primaryProps: {
  16644. "aria-label": primaryText,
  16645. children: primary,
  16646. "data-action": "primary",
  16647. onClick: this.handleClickPrimary,
  16648. role: "button",
  16649. title: primaryText
  16650. },
  16651. skipProps: {
  16652. "aria-label": skipText,
  16653. children: skip,
  16654. "data-action": "skip",
  16655. onClick: this.handleClickSkip,
  16656. role: "button",
  16657. title: skipText
  16658. },
  16659. tooltipProps: {
  16660. "aria-modal": !0,
  16661. ref: setTooltipRef,
  16662. role: "alertdialog"
  16663. }
  16664. };
  16665. });
  16666. }
  16667. render() {
  16668. let { continuous, index, isLastStep, setTooltipRef, size, step } = this.props, { beaconComponent, tooltipComponent, ...cleanStep } = step, component;
  16669. if (tooltipComponent) {
  16670. let renderProps = {
  16671. ...this.getElementsProps(),
  16672. continuous,
  16673. index,
  16674. isLastStep,
  16675. size,
  16676. step: cleanStep,
  16677. setTooltipRef
  16678. };
  16679. component = createElement(tooltipComponent, { ...renderProps });
  16680. } else
  16681. component = createElement(
  16682. Container_default,
  16683. {
  16684. ...this.getElementsProps(),
  16685. continuous,
  16686. index,
  16687. isLastStep,
  16688. size,
  16689. step
  16690. }
  16691. );
  16692. return component;
  16693. }
  16694. }, JoyrideStep = class extends Component {
  16695. constructor() {
  16696. super(...arguments), __publicField(this, "scope", null), __publicField(this, "tooltip", null), __publicField(this, "handleClickHoverBeacon", (event) => {
  16697. let { step, store: store2 } = this.props;
  16698. event.type === "mouseenter" && step.event !== "hover" || store2.update({ lifecycle: LIFECYCLE.TOOLTIP });
  16699. }), __publicField(this, "setTooltipRef", (element) => {
  16700. this.tooltip = element;
  16701. }), __publicField(this, "setPopper", (popper, type) => {
  16702. var _a2;
  16703. let { action, lifecycle, step, store: store2 } = this.props;
  16704. type === "wrapper" ? store2.setPopper("beacon", popper) : store2.setPopper("tooltip", popper), store2.getPopper("beacon") && (store2.getPopper("tooltip") || step.placement === "center") && lifecycle === LIFECYCLE.INIT && store2.update({
  16705. action,
  16706. lifecycle: LIFECYCLE.READY
  16707. }), (_a2 = step.floaterProps) != null && _a2.getPopper && step.floaterProps.getPopper(popper, type);
  16708. }), __publicField(this, "renderTooltip", (renderProps) => {
  16709. let { continuous, helpers, index, size, step } = this.props;
  16710. return createElement(
  16711. JoyrideTooltip,
  16712. {
  16713. continuous,
  16714. helpers,
  16715. index,
  16716. isLastStep: index + 1 === size,
  16717. setTooltipRef: this.setTooltipRef,
  16718. size,
  16719. step,
  16720. ...renderProps
  16721. }
  16722. );
  16723. });
  16724. }
  16725. componentDidMount() {
  16726. let { debug, index } = this.props;
  16727. log2({
  16728. title: `step:${index}`,
  16729. data: [{ key: "props", value: this.props }],
  16730. debug
  16731. });
  16732. }
  16733. componentDidUpdate(previousProps) {
  16734. var _a2;
  16735. let {
  16736. action,
  16737. callback,
  16738. continuous,
  16739. controlled,
  16740. debug,
  16741. helpers,
  16742. index,
  16743. lifecycle,
  16744. shouldScroll: shouldScroll2,
  16745. status,
  16746. step,
  16747. store: store2
  16748. } = this.props, { changed, changedFrom } = treeChanges(previousProps, this.props), state = helpers.info(), skipBeacon = continuous && action !== ACTIONS.CLOSE && (index > 0 || action === ACTIONS.PREV), hasStoreChanged = changed("action") || changed("index") || changed("lifecycle") || changed("status"), isInitial = changedFrom("lifecycle", [LIFECYCLE.TOOLTIP, LIFECYCLE.INIT], LIFECYCLE.INIT), isAfterAction = changed("action", [
  16749. ACTIONS.NEXT,
  16750. ACTIONS.PREV,
  16751. ACTIONS.SKIP,
  16752. ACTIONS.CLOSE
  16753. ]), isControlled = controlled && index === previousProps.index;
  16754. if (isAfterAction && (isInitial || isControlled) && callback({
  16755. ...state,
  16756. index: previousProps.index,
  16757. lifecycle: LIFECYCLE.COMPLETE,
  16758. step: previousProps.step,
  16759. type: EVENTS.STEP_AFTER
  16760. }), step.placement === "center" && status === STATUS3.RUNNING && changed("index") && action !== ACTIONS.START && lifecycle === LIFECYCLE.INIT && store2.update({ lifecycle: LIFECYCLE.READY }), hasStoreChanged) {
  16761. let element = getElement(step.target), elementExists = !!element;
  16762. elementExists && isElementVisible(element) ? (changedFrom("status", STATUS3.READY, STATUS3.RUNNING) || changedFrom("lifecycle", LIFECYCLE.INIT, LIFECYCLE.READY)) && callback({
  16763. ...state,
  16764. step,
  16765. type: EVENTS.STEP_BEFORE
  16766. }) : (console.warn(elementExists ? "Target not visible" : "Target not mounted", step), callback({
  16767. ...state,
  16768. type: EVENTS.TARGET_NOT_FOUND,
  16769. step
  16770. }), controlled || store2.update({ index: index + (action === ACTIONS.PREV ? -1 : 1) }));
  16771. }
  16772. changedFrom("lifecycle", LIFECYCLE.INIT, LIFECYCLE.READY) && store2.update({
  16773. lifecycle: hideBeacon(step) || skipBeacon ? LIFECYCLE.TOOLTIP : LIFECYCLE.BEACON
  16774. }), changed("index") && log2({
  16775. title: `step:${lifecycle}`,
  16776. data: [{ key: "props", value: this.props }],
  16777. debug
  16778. }), changed("lifecycle", LIFECYCLE.BEACON) && callback({
  16779. ...state,
  16780. step,
  16781. type: EVENTS.BEACON
  16782. }), changed("lifecycle", LIFECYCLE.TOOLTIP) && (callback({
  16783. ...state,
  16784. step,
  16785. type: EVENTS.TOOLTIP
  16786. }), shouldScroll2 && this.tooltip && (this.scope = new Scope(this.tooltip, { selector: "[data-action=primary]" }), this.scope.setFocus())), changedFrom("lifecycle", [LIFECYCLE.TOOLTIP, LIFECYCLE.INIT], LIFECYCLE.INIT) && ((_a2 = this.scope) == null || _a2.removeScope(), store2.cleanupPoppers());
  16787. }
  16788. componentWillUnmount() {
  16789. var _a2;
  16790. (_a2 = this.scope) == null || _a2.removeScope();
  16791. }
  16792. get open() {
  16793. let { lifecycle, step } = this.props;
  16794. return hideBeacon(step) || lifecycle === LIFECYCLE.TOOLTIP;
  16795. }
  16796. render() {
  16797. let { continuous, debug, index, nonce, shouldScroll: shouldScroll2, size, step } = this.props, target = getElement(step.target);
  16798. return !validateStep(step) || !src_default.domElement(target) ? null : createElement("div", { key: `JoyrideStep-${index}`, className: "react-joyride__step" }, createElement(
  16799. ReactFloater,
  16800. {
  16801. ...step.floaterProps,
  16802. component: this.renderTooltip,
  16803. debug,
  16804. getPopper: this.setPopper,
  16805. id: `react-joyride-step-${index}`,
  16806. open: this.open,
  16807. placement: step.placement,
  16808. target: step.target
  16809. },
  16810. createElement(
  16811. JoyrideBeacon,
  16812. {
  16813. beaconComponent: step.beaconComponent,
  16814. continuous,
  16815. index,
  16816. isLastStep: index + 1 === size,
  16817. locale: step.locale,
  16818. nonce,
  16819. onClickOrHover: this.handleClickHoverBeacon,
  16820. shouldFocus: shouldScroll2,
  16821. size,
  16822. step,
  16823. styles: step.styles
  16824. }
  16825. )
  16826. ));
  16827. }
  16828. }, Joyride = class extends Component {
  16829. constructor(props) {
  16830. super(props), __publicField(this, "helpers"), __publicField(this, "store"), __publicField(this, "callback", (data) => {
  16831. let { callback } = this.props;
  16832. src_default.function(callback) && callback(data);
  16833. }), __publicField(this, "handleKeyboard", (event) => {
  16834. let { index, lifecycle } = this.state, { steps } = this.props, step = steps[index];
  16835. lifecycle === LIFECYCLE.TOOLTIP && event.code === "Escape" && step && !step.disableCloseOnEsc && this.store.close("keyboard");
  16836. }), __publicField(this, "handleClickOverlay", () => {
  16837. let { index } = this.state, { steps } = this.props;
  16838. getMergedStep(this.props, steps[index]).disableOverlayClose || this.helpers.close("overlay");
  16839. }), __publicField(this, "syncState", (state) => {
  16840. this.setState(state);
  16841. });
  16842. let { debug, getHelpers, run = !0, stepIndex } = props;
  16843. this.store = createStore({
  16844. ...props,
  16845. controlled: run && src_default.number(stepIndex)
  16846. }), this.helpers = this.store.getHelpers();
  16847. let { addListener } = this.store;
  16848. log2({
  16849. title: "init",
  16850. data: [
  16851. { key: "props", value: this.props },
  16852. { key: "state", value: this.state }
  16853. ],
  16854. debug
  16855. }), addListener(this.syncState), getHelpers && getHelpers(this.helpers), this.state = this.store.getState();
  16856. }
  16857. componentDidMount() {
  16858. if (!canUseDOM2())
  16859. return;
  16860. let { debug, disableCloseOnEsc, run, steps } = this.props, { start } = this.store;
  16861. validateSteps(steps, debug) && run && start(), disableCloseOnEsc || document.body.addEventListener("keydown", this.handleKeyboard, { passive: !0 });
  16862. }
  16863. componentDidUpdate(previousProps, previousState) {
  16864. if (!canUseDOM2())
  16865. return;
  16866. let { action, controlled, index, status } = this.state, { debug, run, stepIndex, steps } = this.props, { stepIndex: previousStepIndex, steps: previousSteps } = previousProps, { reset, setSteps, start, stop, update: update2 } = this.store, { changed: changedProps } = treeChanges(previousProps, this.props), { changed, changedFrom } = treeChanges(previousState, this.state), step = getMergedStep(this.props, steps[index]), stepsChanged = !equal(previousSteps, steps), stepIndexChanged = src_default.number(stepIndex) && changedProps("stepIndex"), target = getElement(step.target);
  16867. if (stepsChanged && (validateSteps(steps, debug) ? setSteps(steps) : console.warn("Steps are not valid", steps)), changedProps("run") && (run ? start(stepIndex) : stop()), stepIndexChanged) {
  16868. let nextAction = src_default.number(previousStepIndex) && previousStepIndex < stepIndex ? ACTIONS.NEXT : ACTIONS.PREV;
  16869. action === ACTIONS.STOP && (nextAction = ACTIONS.START), [STATUS3.FINISHED, STATUS3.SKIPPED].includes(status) || update2({
  16870. action: action === ACTIONS.CLOSE ? ACTIONS.CLOSE : nextAction,
  16871. index: stepIndex,
  16872. lifecycle: LIFECYCLE.INIT
  16873. });
  16874. }
  16875. !controlled && status === STATUS3.RUNNING && index === 0 && !target && (this.store.update({ index: index + 1 }), this.callback({
  16876. ...this.state,
  16877. type: EVENTS.TARGET_NOT_FOUND,
  16878. step
  16879. }));
  16880. let callbackData = {
  16881. ...this.state,
  16882. index,
  16883. step
  16884. };
  16885. if (changed("action", [
  16886. ACTIONS.NEXT,
  16887. ACTIONS.PREV,
  16888. ACTIONS.SKIP,
  16889. ACTIONS.CLOSE
  16890. ]) && changed("status", STATUS3.PAUSED)) {
  16891. let previousStep = getMergedStep(this.props, steps[previousState.index]);
  16892. this.callback({
  16893. ...callbackData,
  16894. index: previousState.index,
  16895. lifecycle: LIFECYCLE.COMPLETE,
  16896. step: previousStep,
  16897. type: EVENTS.STEP_AFTER
  16898. });
  16899. }
  16900. if (changed("status", [STATUS3.FINISHED, STATUS3.SKIPPED])) {
  16901. let previousStep = getMergedStep(this.props, steps[previousState.index]);
  16902. controlled || this.callback({
  16903. ...callbackData,
  16904. index: previousState.index,
  16905. lifecycle: LIFECYCLE.COMPLETE,
  16906. step: previousStep,
  16907. type: EVENTS.STEP_AFTER
  16908. }), this.callback({
  16909. ...callbackData,
  16910. type: EVENTS.TOUR_END,
  16911. // Return the last step when the tour is finished
  16912. step: previousStep,
  16913. index: previousState.index
  16914. }), reset();
  16915. } else changedFrom("status", [STATUS3.IDLE, STATUS3.READY], STATUS3.RUNNING) ? this.callback({
  16916. ...callbackData,
  16917. type: EVENTS.TOUR_START
  16918. }) : (changed("status") || changed("action", ACTIONS.RESET)) && this.callback({
  16919. ...callbackData,
  16920. type: EVENTS.TOUR_STATUS
  16921. });
  16922. this.scrollToStep(previousState);
  16923. }
  16924. componentWillUnmount() {
  16925. let { disableCloseOnEsc } = this.props;
  16926. disableCloseOnEsc || document.body.removeEventListener("keydown", this.handleKeyboard);
  16927. }
  16928. scrollToStep(previousState) {
  16929. let { index, lifecycle, status } = this.state, {
  16930. debug,
  16931. disableScrollParentFix = !1,
  16932. scrollDuration,
  16933. scrollOffset = 20,
  16934. scrollToFirstStep = !1,
  16935. steps
  16936. } = this.props, step = getMergedStep(this.props, steps[index]), target = getElement(step.target), shouldScrollToStep = shouldScroll({
  16937. isFirstStep: index === 0,
  16938. lifecycle,
  16939. previousLifecycle: previousState.lifecycle,
  16940. scrollToFirstStep,
  16941. step,
  16942. target
  16943. });
  16944. if (status === STATUS3.RUNNING && shouldScrollToStep) {
  16945. let hasCustomScroll = hasCustomScrollParent(target, disableScrollParentFix), scrollParent2 = getScrollParent2(target, disableScrollParentFix), scrollY = Math.floor(getScrollTo(target, scrollOffset, disableScrollParentFix)) || 0;
  16946. log2({
  16947. title: "scrollToStep",
  16948. data: [
  16949. { key: "index", value: index },
  16950. { key: "lifecycle", value: lifecycle },
  16951. { key: "status", value: status }
  16952. ],
  16953. debug
  16954. });
  16955. let beaconPopper = this.store.getPopper("beacon"), tooltipPopper = this.store.getPopper("tooltip");
  16956. if (lifecycle === LIFECYCLE.BEACON && beaconPopper) {
  16957. let { offsets, placement } = beaconPopper;
  16958. !["bottom"].includes(placement) && !hasCustomScroll && (scrollY = Math.floor(offsets.popper.top - scrollOffset));
  16959. } else if (lifecycle === LIFECYCLE.TOOLTIP && tooltipPopper) {
  16960. let { flipped, offsets, placement } = tooltipPopper;
  16961. ["top", "right", "left"].includes(placement) && !flipped && !hasCustomScroll ? scrollY = Math.floor(offsets.popper.top - scrollOffset) : scrollY -= step.spotlightPadding;
  16962. }
  16963. scrollY = scrollY >= 0 ? scrollY : 0, status === STATUS3.RUNNING && scrollTo(scrollY, { element: scrollParent2, duration: scrollDuration }).then(
  16964. () => {
  16965. setTimeout(() => {
  16966. var _a2;
  16967. (_a2 = this.store.getPopper("tooltip")) == null || _a2.instance.update();
  16968. }, 10);
  16969. }
  16970. );
  16971. }
  16972. }
  16973. render() {
  16974. if (!canUseDOM2())
  16975. return null;
  16976. let { index, lifecycle, status } = this.state, {
  16977. continuous = !1,
  16978. debug = !1,
  16979. nonce,
  16980. scrollToFirstStep = !1,
  16981. steps
  16982. } = this.props, isRunning = status === STATUS3.RUNNING, content = {};
  16983. if (isRunning && steps[index]) {
  16984. let step = getMergedStep(this.props, steps[index]);
  16985. content.step = createElement(
  16986. JoyrideStep,
  16987. {
  16988. ...this.state,
  16989. callback: this.callback,
  16990. continuous,
  16991. debug,
  16992. helpers: this.helpers,
  16993. nonce,
  16994. shouldScroll: !step.disableScrolling && (index !== 0 || scrollToFirstStep),
  16995. step,
  16996. store: this.store
  16997. }
  16998. ), content.overlay = createElement(JoyridePortal, { id: "react-joyride-portal" }, createElement(
  16999. JoyrideOverlay,
  17000. {
  17001. ...step,
  17002. continuous,
  17003. debug,
  17004. lifecycle,
  17005. onClickOverlay: this.handleClickOverlay
  17006. }
  17007. ));
  17008. }
  17009. return createElement("div", { className: "react-joyride" }, content.step, content.overlay);
  17010. }
  17011. };
  17012. __publicField(Joyride, "defaultProps", defaultProps);
  17013. var components_default2 = Joyride;
  17014. // src/manager/components/TourGuide/HighlightElement.tsx
  17015. init_react();
  17016. var HIGHLIGHT_KEYFRAMES_ID = "storybook-highlight-element-keyframes", keyframes2 = `
  17017. @keyframes sb-highlight-pulsate {
  17018. 0% {
  17019. box-shadow: rgba(2,156,253,1) 0 0 2px 1px, 0 0 0 0 rgba(2, 156, 253, 0.7), 0 0 0 0 rgba(2, 156, 253, 0.4);
  17020. }
  17021. 50% {
  17022. box-shadow: rgba(2,156,253,1) 0 0 2px 1px, 0 0 0 20px rgba(2, 156, 253, 0), 0 0 0 40px rgba(2, 156, 253, 0);
  17023. }
  17024. 100% {
  17025. box-shadow: rgba(2,156,253,1) 0 0 2px 1px, 0 0 0 0 rgba(2, 156, 253, 0), 0 0 0 0 rgba(2, 156, 253, 0);
  17026. }
  17027. }
  17028. `, createOverlay = (element) => {
  17029. let overlay = document.createElement("div");
  17030. return overlay.id = "storybook-highlight-element", overlay.style.position = "fixed", overlay.style.pointerEvents = "none", overlay.style.zIndex = "2147483647", overlay.style.transition = "opacity 0.2s ease-in-out", requestAnimationFrame(() => {
  17031. updateOverlayStyles(element, overlay), element.scrollIntoView({ behavior: "smooth", block: "center" });
  17032. }), overlay;
  17033. }, updateOverlayStyles = (element, overlay) => {
  17034. let rect = element.getBoundingClientRect(), computedStyle = window.getComputedStyle(element);
  17035. overlay.style.top = `${rect.top}px`, overlay.style.left = `${rect.left}px`, overlay.style.width = `${rect.width}px`, overlay.style.height = `${rect.height}px`, overlay.style.borderRadius = computedStyle.borderRadius;
  17036. }, findScrollableAncestors = (element) => {
  17037. let scrollableAncestors = [window], parent = element.parentElement;
  17038. for (; parent; ) {
  17039. let style = window.getComputedStyle(parent);
  17040. (style.overflow === "auto" || style.overflow === "scroll" || style.overflowX === "auto" || style.overflowX === "scroll" || style.overflowY === "auto" || style.overflowY === "scroll") && scrollableAncestors.push(parent), parent = parent.parentElement;
  17041. }
  17042. return scrollableAncestors;
  17043. };
  17044. function HighlightElement({
  17045. targetSelector,
  17046. pulsating = !1
  17047. }) {
  17048. return useEffect(() => {
  17049. let element = document.querySelector(targetSelector);
  17050. if (!element || !element.parentElement)
  17051. return;
  17052. let overlay = document.body.appendChild(createOverlay(element));
  17053. if (pulsating) {
  17054. if (!document.getElementById(HIGHLIGHT_KEYFRAMES_ID)) {
  17055. let style = document.createElement("style");
  17056. style.id = HIGHLIGHT_KEYFRAMES_ID, style.innerHTML = keyframes2, document.head.appendChild(style);
  17057. }
  17058. overlay.style.animation = "sb-highlight-pulsate 3s infinite", overlay.style.transformOrigin = "center", overlay.style.animationTimingFunction = "ease-in-out";
  17059. } else
  17060. overlay.style.boxShadow = "rgba(2,156,253,1) 0 0 2px 1px";
  17061. let scrollTimeout = null, handleScroll = () => {
  17062. overlay.parentElement && overlay.remove(), scrollTimeout !== null && clearTimeout(scrollTimeout), scrollTimeout = window.setTimeout(() => {
  17063. element && (updateOverlayStyles(element, overlay), overlay.style.opacity = "0", document.body.appendChild(overlay), requestAnimationFrame(() => overlay.style.opacity = "1"));
  17064. }, 150);
  17065. }, resizeObserver = new ResizeObserver(
  17066. () => overlay.parentElement && updateOverlayStyles(element, overlay)
  17067. );
  17068. resizeObserver.observe(window.document.body), resizeObserver.observe(element);
  17069. let scrollContainers = findScrollableAncestors(element);
  17070. return scrollContainers.forEach(
  17071. (el) => el.addEventListener("scroll", handleScroll, { passive: !0 })
  17072. ), scrollContainers.filter((el) => el !== window).forEach((el) => resizeObserver.observe(el)), () => {
  17073. scrollTimeout !== null && clearTimeout(scrollTimeout), overlay.parentElement && overlay.remove(), scrollContainers.forEach((el) => el.removeEventListener("scroll", handleScroll)), resizeObserver.disconnect();
  17074. };
  17075. }, [targetSelector, pulsating]), null;
  17076. }
  17077. // src/manager/components/TourGuide/TourTooltip.tsx
  17078. init_react();
  17079. var ONBOARDING_ARROW_STYLE_ID = "storybook-onboarding-arrow-style", TooltipBody = styled.div`
  17080. padding: 15px;
  17081. border-radius: 5px;
  17082. `, Wrapper4 = styled.div`
  17083. display: flex;
  17084. flex-direction: column;
  17085. align-items: flex-start;
  17086. `, TooltipHeader = styled.div`
  17087. display: flex;
  17088. align-items: center;
  17089. align-self: stretch;
  17090. justify-content: space-between;
  17091. margin: -5px -5px 5px 0;
  17092. `, TooltipTitle = styled.div`
  17093. line-height: 18px;
  17094. font-weight: 700;
  17095. font-size: 14px;
  17096. margin: 5px 5px 5px 0;
  17097. `, TooltipContent = styled.p`
  17098. font-size: 14px;
  17099. line-height: 18px;
  17100. text-align: start;
  17101. text-wrap: balance;
  17102. margin: 0;
  17103. margin-top: 5px;
  17104. `, TooltipFooter = styled.div`
  17105. display: flex;
  17106. align-items: center;
  17107. justify-content: space-between;
  17108. margin-top: 15px;
  17109. `, Count = styled.span`
  17110. font-size: 13px;
  17111. `, NextButton = styled(Button)(({ theme }) => ({
  17112. background: theme.color.lightest,
  17113. border: "none",
  17114. boxShadow: "none",
  17115. color: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary),
  17116. "&:hover, &:focus": {
  17117. background: curriedTransparentize$1(0.1, theme.color.lightest),
  17118. color: theme.base === "light" ? curriedLighten$1(0.1, theme.color.secondary) : curriedDarken$1(0.3, theme.color.secondary)
  17119. }
  17120. })), TourTooltip = ({
  17121. index,
  17122. size,
  17123. step,
  17124. closeProps,
  17125. primaryProps,
  17126. tooltipProps
  17127. }) => (useEffect(() => {
  17128. let style = document.createElement("style");
  17129. return style.id = ONBOARDING_ARROW_STYLE_ID, style.innerHTML = `
  17130. .__floater__arrow { container-type: size; }
  17131. .__floater__arrow span { background: ${color.secondary}; }
  17132. .__floater__arrow span::before, .__floater__arrow span::after {
  17133. content: '';
  17134. display: block;
  17135. width: 2px;
  17136. height: 2px;
  17137. background: ${color.secondary};
  17138. box-shadow: 0 0 0 2px ${color.secondary};
  17139. border-radius: 3px;
  17140. flex: 0 0 2px;
  17141. }
  17142. @container (min-height: 1px) {
  17143. .__floater__arrow span { flex-direction: column; }
  17144. }
  17145. `, document.head.appendChild(style), () => document.getElementById(ONBOARDING_ARROW_STYLE_ID)?.remove();
  17146. }, []), react_default.createElement(TooltipBody, { ...tooltipProps, style: step.styles?.tooltip }, react_default.createElement(Wrapper4, null, react_default.createElement(TooltipHeader, null, step.title && react_default.createElement(TooltipTitle, null, step.title), react_default.createElement(
  17147. Button,
  17148. {
  17149. ...closeProps,
  17150. onClick: closeProps.onClick,
  17151. variant: "solid",
  17152. padding: "small",
  17153. ariaLabel: "Close"
  17154. },
  17155. react_default.createElement(CloseAltIcon, null)
  17156. )), react_default.createElement(TooltipContent, null, step.content)), react_default.createElement(TooltipFooter, { id: "buttonNext" }, react_default.createElement(Count, null, index + 1, " of ", size), !step.hideNextButton && react_default.createElement(NextButton, { ...primaryProps }, index + 1 === size ? "Done" : "Next"))));
  17157. // src/manager/components/TourGuide/TourGuide.tsx
  17158. var TourGuide = ({
  17159. step,
  17160. steps,
  17161. onNext,
  17162. onComplete,
  17163. onDismiss
  17164. }) => {
  17165. let [stepIndex, setStepIndex] = useState(step ? null : 0), theme = useTheme(), timeoutRef = useRef(void 0), updateStepIndex = useCallback((index) => {
  17166. clearTimeout(timeoutRef.current), setStepIndex((current) => index === -1 ? null : current === null || current === index ? index : (timeoutRef.current = setTimeout(setStepIndex, 300, index), null));
  17167. }, []);
  17168. useEffect(
  17169. () => step ? updateStepIndex(steps.findIndex(({ key }) => key === step)) : void 0,
  17170. [step, steps, updateStepIndex]
  17171. );
  17172. let mappedSteps = useMemo(() => steps.map((step2, index) => {
  17173. let next = () => updateStepIndex(index + 1);
  17174. return {
  17175. disableBeacon: !0,
  17176. disableOverlay: !0,
  17177. spotlightClicks: !0,
  17178. offset: 0,
  17179. ...step2,
  17180. content: react_default.createElement(react_default.Fragment, null, step2.content, step2.highlight && react_default.createElement(HighlightElement, { targetSelector: step2.highlight, pulsating: !0 })),
  17181. onNext: step2.onNext ? () => step2.onNext?.({ next }) : onNext && (() => onNext?.({ next }))
  17182. };
  17183. }), [steps, onNext, updateStepIndex]), callback = useCallback(
  17184. (data) => {
  17185. data.action === ACTIONS.NEXT && data.lifecycle === "complete" && (data.index === data.size - 1 ? onComplete?.() : data.step?.onNext ? data.step.onNext() : updateStepIndex(data.index + 1)), data.action === ACTIONS.CLOSE && onDismiss?.();
  17186. },
  17187. [onComplete, onDismiss, updateStepIndex]
  17188. );
  17189. return stepIndex === null ? null : react_default.createElement(
  17190. components_default2,
  17191. {
  17192. continuous: !0,
  17193. steps: mappedSteps,
  17194. stepIndex,
  17195. spotlightPadding: 0,
  17196. disableCloseOnEsc: !0,
  17197. disableOverlayClose: !0,
  17198. disableScrolling: !0,
  17199. callback,
  17200. tooltipComponent: TourTooltip,
  17201. floaterProps: {
  17202. disableAnimation: !0,
  17203. styles: {
  17204. arrow: {
  17205. length: 20,
  17206. spread: 2
  17207. },
  17208. floater: {
  17209. filter: theme.base === "light" ? "drop-shadow(0px 5px 5px rgba(0,0,0,0.05)) drop-shadow(0 1px 3px rgba(0,0,0,0.1))" : "drop-shadow(#fff5 0px 0px 0.5px) drop-shadow(#fff5 0px 0px 0.5px)"
  17210. }
  17211. }
  17212. },
  17213. styles: {
  17214. overlay: {
  17215. mixBlendMode: "unset",
  17216. backgroundColor: steps[stepIndex]?.target === "body" ? "rgba(27, 28, 29, 0.2)" : "none"
  17217. },
  17218. spotlight: {
  17219. backgroundColor: "none",
  17220. border: `solid 2px ${theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary)}`,
  17221. boxShadow: "0px 0px 0px 9999px rgba(27, 28, 29, 0.2)"
  17222. },
  17223. tooltip: {
  17224. width: 280,
  17225. color: theme.color.lightest,
  17226. background: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary)
  17227. },
  17228. options: {
  17229. zIndex: 9998,
  17230. primaryColor: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary),
  17231. arrowColor: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary)
  17232. }
  17233. }
  17234. }
  17235. );
  17236. }, root = null;
  17237. TourGuide.render = (props) => {
  17238. let container = document.getElementById("storybook-tour");
  17239. container || (container = document.createElement("div"), container.id = "storybook-tour", document.body.appendChild(container)), root = root ?? createRoot(container), root.render(
  17240. props ? react_default.createElement(ThemeProvider, { theme: convert(themes.light) }, react_default.createElement(
  17241. TourGuide,
  17242. {
  17243. ...props,
  17244. onComplete: () => {
  17245. props.onComplete?.(), root?.render(null), root = null;
  17246. },
  17247. onDismiss: () => {
  17248. props.onDismiss?.(), root?.render(null), root = null;
  17249. }
  17250. }
  17251. )) : null
  17252. );
  17253. };
  17254. // src/manager/hooks/useLocation.ts
  17255. init_react();
  17256. var LocationMonitor = {
  17257. _currentHref: globalThis.window?.location.href ?? "",
  17258. _intervalId: null,
  17259. _listeners: /* @__PURE__ */ new Set(),
  17260. start() {
  17261. this._intervalId === null && (this._intervalId = setInterval(() => {
  17262. let newLocation = globalThis.window.location;
  17263. newLocation.href !== this._currentHref && (this._currentHref = newLocation.href, this._listeners.forEach((listener) => listener(newLocation)));
  17264. }, 100));
  17265. },
  17266. stop() {
  17267. this._intervalId !== null && (clearInterval(this._intervalId), this._intervalId = null);
  17268. },
  17269. subscribe(...listeners) {
  17270. return listeners.forEach((listener) => this._listeners.add(listener)), this.start(), () => {
  17271. listeners.forEach((listener) => this._listeners.delete(listener)), this._listeners.size === 0 && this.stop();
  17272. };
  17273. }
  17274. }, useLocationHash = () => {
  17275. let [hash, setHash] = useState(globalThis.window?.location.hash ?? "");
  17276. return useEffect(() => LocationMonitor.subscribe((location2) => setHash(location2.hash)), []), hash.slice(1);
  17277. };
  17278. // src/shared/utils/ai-prompts.ts
  17279. function getAiSetupPrompt(executor = "npx storybook") {
  17280. return `Run \`${executor} ai setup\` and follow its instructions precisely.`;
  17281. }
  17282. // src/shared/checklist-store/checklistData.tsx
  17283. var CodeWrapper = styled.div(({ theme }) => ({
  17284. alignSelf: "stretch",
  17285. background: theme.background.content,
  17286. borderRadius: theme.appBorderRadius,
  17287. margin: "5px 0",
  17288. padding: 10,
  17289. fontSize: theme.typography.size.s1,
  17290. ".linenumber": {
  17291. opacity: 0.5
  17292. }
  17293. })), CodeSnippet = (props) => react_default.createElement(ThemeProvider, { theme: convert(themes.dark) }, react_default.createElement(CodeWrapper, null, react_default.createElement(SyntaxHighlighter, { ...props }))), isExample = (id) => id.startsWith("example-") || id.startsWith("configure-your-project--"), subscribeToIndex = (condition) => ({ api, done }) => {
  17294. let check = () => condition(
  17295. Object.entries(api.getIndex()?.entries || {}).reduce(
  17296. (acc, [id, entry]) => isExample(entry.id) ? acc : Object.assign(acc, { [id]: entry }),
  17297. {}
  17298. )
  17299. );
  17300. if (check())
  17301. done();
  17302. else
  17303. return api.once(PREVIEW_INITIALIZED, () => check() && done()), api.on(STORY_INDEX_INVALIDATED, () => check() && done());
  17304. }, checklistData = {
  17305. sections: [
  17306. {
  17307. id: "basics",
  17308. title: "Storybook basics",
  17309. items: [
  17310. {
  17311. id: "aiSetup",
  17312. label: "Set up with AI",
  17313. icon: WandIcon,
  17314. available: ({ storeState }) => !!storeState.aiOptIn && storeState.items.aiSetup?.status !== "done",
  17315. criteria: "ai setup command has not been run yet",
  17316. showOnGuidePage: !1,
  17317. action: {
  17318. label: "Copy prompt",
  17319. copyContent: getAiSetupPrompt(),
  17320. onClick: ({ api }) => {
  17321. api.emit(AI_PROMPT_NUDGE, { id: "setup", origin: "onboarding-checklist-side" });
  17322. }
  17323. }
  17324. },
  17325. {
  17326. id: "guidedTour",
  17327. label: "Take the guided tour",
  17328. available: ({ index }) => !!index && "example-button--primary" in index && !!globalThis?.FEATURES?.controls && addons.experimental_getRegisteredAddons().includes(ADDON_ID3),
  17329. criteria: "Guided tour is completed",
  17330. subscribe: ({ api, accept }) => api.on(ADDON_ONBOARDING_CHANNEL, ({ step, type }) => {
  17331. type !== "dismiss" && ["6:IntentSurvey", "7:FinishedOnboarding"].includes(step) && accept();
  17332. }),
  17333. action: {
  17334. label: "Start",
  17335. onClick: ({ api }) => {
  17336. api.toggleNav(!0);
  17337. let path = api.getUrlState().path || "";
  17338. path.startsWith("/story/") ? document.location.href = `/?path=${path}&onboarding=true` : document.location.href = "/?onboarding=true";
  17339. }
  17340. }
  17341. },
  17342. {
  17343. id: "onboardingSurvey",
  17344. label: "Complete the onboarding survey",
  17345. available: () => addons.experimental_getRegisteredAddons().includes(ADDON_ID3),
  17346. afterCompletion: "immutable",
  17347. criteria: "Onboarding survey is completed",
  17348. subscribe: ({ api, accept }) => api.on(ADDON_ONBOARDING_CHANNEL, ({ type }) => type === "survey" && accept()),
  17349. action: {
  17350. label: "Open",
  17351. onClick: ({ api }) => {
  17352. let path = api.getUrlState().path || "";
  17353. document.location.href = `/?path=${path}&onboarding=survey`;
  17354. }
  17355. }
  17356. },
  17357. {
  17358. id: "renderComponent",
  17359. label: "Render your first component",
  17360. criteria: "A story finished rendering successfully",
  17361. subscribe: ({ api, done }) => api.on(
  17362. STORY_FINISHED,
  17363. ({ storyId, status }) => status === "success" && !isExample(storyId) && done()
  17364. ),
  17365. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Storybook renders your components in isolation, using stories. That allows you to work on the bit of UI you need, without worrying about the rest of the app."), react_default.createElement("p", null, "Rendering your components can often require", " ", react_default.createElement(
  17366. Link,
  17367. {
  17368. href: api.getDocsUrl({
  17369. subpath: "writing-stories/decorators",
  17370. renderer: !0,
  17371. ref: "guide"
  17372. }),
  17373. target: "_blank"
  17374. },
  17375. "setting up surrounding context in decorators"
  17376. ), " ", "or", " ", react_default.createElement(
  17377. Link,
  17378. {
  17379. href: api.getDocsUrl({
  17380. subpath: "configure/styling-and-css",
  17381. renderer: !0,
  17382. ref: "guide"
  17383. }),
  17384. target: "_blank"
  17385. },
  17386. "applying global styles"
  17387. ), ". Once you've got it working for one component, you're ready to make Storybook the home for all of your UI."), react_default.createElement("p", null, "Stories are written in CSF, a format specifically designed to help with UI development. Here's an example:"), react_default.createElement(CodeSnippet, { language: "typescript" }, `// Button.stories.ts
  17388. // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
  17389. import type { Meta, StoryObj } from '@storybook/your-framework';
  17390. import { Button } from './Button';
  17391. const meta = {
  17392. // \u{1F447} The component you're working on
  17393. component: Button,
  17394. } satisfies Meta<typeof Button>;
  17395. export default meta;
  17396. // \u{1F447} Type helper to reduce boilerplate
  17397. type Story = StoryObj<typeof meta>;
  17398. // \u{1F447} A story named Primary that renders \`<Button primary label="Button" />\`
  17399. export const Primary: Story = {
  17400. args: {
  17401. primary: true,
  17402. label: 'Button',
  17403. },
  17404. };`), react_default.createElement("p", null, react_default.createElement(
  17405. Link,
  17406. {
  17407. href: api.getDocsUrl({
  17408. subpath: "writing-stories",
  17409. renderer: !0,
  17410. ref: "guide"
  17411. }),
  17412. target: "_blank",
  17413. withArrow: !0
  17414. },
  17415. "Learn more about stories"
  17416. )))
  17417. },
  17418. {
  17419. id: "moreComponents",
  17420. label: "Add 5 components",
  17421. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Storybook gets better as you add more components. Start with the easy ones, like Button or Avatar, and work your way up to more complex components, like Select, Autocomplete, or even full pages."), react_default.createElement(
  17422. "img",
  17423. {
  17424. src: api.getDocsUrl({
  17425. asset: "onboarding/sidebar-components.png",
  17426. ref: "guide"
  17427. }),
  17428. alt: "Components in the sidebar"
  17429. }
  17430. ), react_default.createElement("p", null, react_default.createElement(
  17431. Link,
  17432. {
  17433. href: api.getDocsUrl({
  17434. subpath: "get-started/whats-a-story#create-a-new-story",
  17435. renderer: !0,
  17436. ref: "guide"
  17437. }),
  17438. target: "_blank",
  17439. withArrow: !0
  17440. },
  17441. "Learn how to add components without writing any code"
  17442. ))),
  17443. criteria: "At least 5 components exist in the index",
  17444. subscribe: subscribeToIndex((entries) => {
  17445. let stories = Object.values(entries).filter(
  17446. (entry) => entry.type === "story"
  17447. );
  17448. return new Set(stories.map(({ title: title2 }) => title2)).size >= 5;
  17449. })
  17450. },
  17451. {
  17452. id: "moreStories",
  17453. label: "Add 20 stories",
  17454. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "More stories for your components means better documentation and more test coverage."), react_default.createElement(
  17455. "img",
  17456. {
  17457. src: api.getDocsUrl({
  17458. asset: "onboarding/sidebar-many-stories.png",
  17459. ref: "guide"
  17460. }),
  17461. alt: "Stories in the sidebar"
  17462. }
  17463. ), react_default.createElement("p", null, react_default.createElement(
  17464. Link,
  17465. {
  17466. href: api.getDocsUrl({
  17467. subpath: "essentials/controls#creating-and-editing-stories-from-controls",
  17468. renderer: !0,
  17469. ref: "guide"
  17470. }),
  17471. target: "_blank",
  17472. withArrow: !0
  17473. },
  17474. "Learn how to use Controls to add stories without writing any code"
  17475. ))),
  17476. criteria: "At least 20 stories exist in the index",
  17477. subscribe: subscribeToIndex((entries) => Object.values(entries).filter(
  17478. (entry) => entry.type === "story"
  17479. ).length >= 20)
  17480. },
  17481. {
  17482. id: "whatsNewStorybook10",
  17483. label: "See what's new",
  17484. criteria: "What's New page is opened",
  17485. action: {
  17486. label: "Go",
  17487. onClick: ({ api }) => api.navigate("/settings/whats-new")
  17488. },
  17489. subscribe: ({ accept }) => LocationMonitor.subscribe((l3) => l3.search.endsWith("/settings/whats-new") && accept())
  17490. }
  17491. ]
  17492. },
  17493. {
  17494. id: "development",
  17495. title: "Development",
  17496. items: [
  17497. {
  17498. id: "controls",
  17499. label: "Change a story with Controls",
  17500. available: () => !!globalThis?.FEATURES?.controls,
  17501. criteria: "Story args are updated",
  17502. subscribe: ({ api, done }) => api.on(STORY_ARGS_UPDATED, done),
  17503. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "When you change the value of one of the inputs in the Controls table, the story automatically updates to reflect that change. It's a great way to explore how a component handles various inputs."), react_default.createElement(
  17504. "img",
  17505. {
  17506. src: api.getDocsUrl({
  17507. asset: "api/doc-block-controls.png",
  17508. ref: "guide"
  17509. }),
  17510. alt: "Screenshot of Controls block"
  17511. }
  17512. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17513. Link,
  17514. {
  17515. href: api.getDocsUrl({
  17516. subpath: "essentials/controls",
  17517. renderer: !0,
  17518. ref: "guide"
  17519. }),
  17520. target: "_blank"
  17521. },
  17522. "Controls documentation"
  17523. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to use the Controls panel to edit or save a new story"), react_default.createElement("li", null, "How to configure the table")))
  17524. },
  17525. {
  17526. id: "viewports",
  17527. label: "Check responsiveness with Viewports",
  17528. available: () => !!globalThis?.FEATURES?.viewport,
  17529. criteria: "Viewport global is updated",
  17530. subscribe: ({ api, done }) => api.on(UPDATE_GLOBALS, ({ globals }) => globals?.viewport && done()),
  17531. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Many UI components need to be responsive to the viewport size. Storybook has built-in support for previewing stories in various device sizes."), react_default.createElement(
  17532. "img",
  17533. {
  17534. src: api.getDocsUrl({
  17535. asset: "onboarding/viewports-menu.png",
  17536. ref: "guide"
  17537. }),
  17538. alt: "Screenshot of Viewports menu"
  17539. }
  17540. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17541. Link,
  17542. {
  17543. href: api.getDocsUrl({
  17544. subpath: "essentials/viewport",
  17545. renderer: !0,
  17546. ref: "guide"
  17547. }),
  17548. target: "_blank"
  17549. },
  17550. "Viewports documentation"
  17551. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to configure which viewports are available"), react_default.createElement("li", null, "How to force a story to ", react_default.createElement("em", null, "always"), " render in a specific viewport")))
  17552. },
  17553. {
  17554. id: "organizeStories",
  17555. label: "Group your components",
  17556. criteria: "A root node exists in the index",
  17557. subscribe: subscribeToIndex(
  17558. (entries) => Object.values(entries).some(({ title: title2 }) => title2.includes("/"))
  17559. ),
  17560. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "It's helpful for projects to organize their sidebar into groups. We're big fans of Atomic Design (atoms, molecules, organisms, pages), but we've also seen organization by domain (profile, billing, dashboard, etc). Being organized helps everyone use your Storybook more effectively."), react_default.createElement("p", null, "You can create a section like so:"), react_default.createElement(CodeSnippet, { language: "typescript" }, `// Button.stories.js
  17561. export default {
  17562. component: Button,
  17563. - title: 'Button', // You may not have this
  17564. + title: 'Atoms/Button',
  17565. }`), react_default.createElement("p", null, "Which would look like:"), react_default.createElement(
  17566. "img",
  17567. {
  17568. src: api.getDocsUrl({
  17569. asset: "onboarding/sidebar-with-groups.png",
  17570. ref: "guide"
  17571. }),
  17572. alt: "Grouped components in the sidebar"
  17573. }
  17574. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17575. Link,
  17576. {
  17577. href: api.getDocsUrl({
  17578. subpath: "writing-stories/naming-components-and-hierarchy",
  17579. renderer: !0,
  17580. ref: "guide"
  17581. }),
  17582. target: "_blank"
  17583. },
  17584. "story organization documentation"
  17585. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "The full hierarchy available"), react_default.createElement("li", null, "How to configure the sorting of your stories")))
  17586. }
  17587. ]
  17588. },
  17589. {
  17590. id: "share",
  17591. title: "Share",
  17592. items: [
  17593. {
  17594. id: "shareStorybook",
  17595. label: "Share your Storybook for feedback",
  17596. available: () => addons.experimental_getRegisteredAddons(Addon_TypesEnum.TOOLEXTRA).includes("chromaui/addon-visual-tests/share-tool"),
  17597. criteria: "User has shared their Storybook",
  17598. subscribe: ({ api, done }) => {
  17599. let SHARE_PROGRESS_KEY = "chromaui/addon-visual-tests/shareProgress";
  17600. return api.on("experimental_useSharedState_setValue", (key, value) => {
  17601. key === SHARE_PROGRESS_KEY && value?.status === "complete" && done();
  17602. });
  17603. },
  17604. action: {
  17605. label: "Share",
  17606. onClick: () => document.getElementById("chromatic-share-button")?.click()
  17607. },
  17608. content: () => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Share your Storybook with your team in one click using Chromatic. Click the", " ", react_default.createElement("strong", null, "Share"), " button in the toolbar to publish and get a shareable link."), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(Link, { href: "https://www.chromatic.com/docs/sharing", target: "_blank", withArrow: !0 }, "sharing documentation")))
  17609. },
  17610. {
  17611. id: "publishStorybook",
  17612. label: "Publish your Storybook for feedback",
  17613. available: () => !addons.experimental_getRegisteredAddons(Addon_TypesEnum.TOOLEXTRA).includes("chromaui/addon-visual-tests/share-tool"),
  17614. criteria: "User has published their Storybook",
  17615. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Publishing your Storybook is easy and unlocks super clear review cycles and other collaborative workflows."), react_default.createElement("p", null, "Run ", react_default.createElement("code", null, "npx storybook build"), " in CI and deploy it using services like", " ", react_default.createElement(Link, { href: "https://chromatic.com", target: "_blank" }, "Chromatic"), ",", " ", react_default.createElement(Link, { href: "https://vercel.com", target: "_blank", rel: "noopener noreferrer" }, "Vercel"), ", or", " ", react_default.createElement(Link, { href: "https://www.netlify.com", target: "_blank", rel: "noopener noreferrer" }, "Netlify"), "."), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17616. Link,
  17617. {
  17618. href: api.getDocsUrl({
  17619. subpath: "sharing/publish-storybook",
  17620. renderer: !0,
  17621. ref: "guide"
  17622. }),
  17623. target: "_blank",
  17624. withArrow: !0
  17625. },
  17626. "publishing documentation"
  17627. )))
  17628. }
  17629. ]
  17630. },
  17631. {
  17632. id: "testing",
  17633. title: "Testing",
  17634. items: [
  17635. {
  17636. id: "installVitest",
  17637. label: "Install Vitest addon",
  17638. afterCompletion: "unavailable",
  17639. available: () => !!globalThis.STORYBOOK_FRAMEWORK && SUPPORTED_FRAMEWORKS.includes(globalThis.STORYBOOK_FRAMEWORK),
  17640. criteria: "@storybook/addon-vitest registered in .storybook/main.js|ts",
  17641. subscribe: ({ done }) => {
  17642. addons.experimental_getRegisteredAddons().includes(ADDON_ID5) && done();
  17643. },
  17644. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Run this command to install the Vitest addon, enabling you to run component tests on your stories inside Storybook\u2019s UI:"), react_default.createElement(CodeSnippet, { language: "bash" }, "npx storybook add @storybook/addon-vitest"), react_default.createElement("p", null, react_default.createElement("em", null, "Restart your Storybook after installing the addon.")), react_default.createElement(
  17645. "img",
  17646. {
  17647. src: api.getDocsUrl({
  17648. asset: "writing-tests/testing-ui-overview.png",
  17649. ref: "guide"
  17650. }),
  17651. alt: "Storybook app with story status indicators, testing widget, and addon panel annotated"
  17652. }
  17653. ), react_default.createElement("p", null, react_default.createElement(
  17654. Link,
  17655. {
  17656. href: api.getDocsUrl({
  17657. subpath: "writing-tests/integrations/vitest-addon",
  17658. renderer: !0,
  17659. ref: "guide"
  17660. }),
  17661. target: "_blank",
  17662. withArrow: !0
  17663. },
  17664. "Learn more about the Vitest addon"
  17665. )))
  17666. },
  17667. {
  17668. id: "runTests",
  17669. after: ["installVitest"],
  17670. label: "Test your components",
  17671. criteria: "Component tests are run from the test widget in the sidebar",
  17672. subscribe: ({ done }) => internal_universalTestProviderStore.onStateChange((state) => {
  17673. state["storybook/test"] === "test-provider-state:running" && (TourGuide.render(null), done());
  17674. }),
  17675. action: {
  17676. label: "Start",
  17677. onClick: ({ api }) => {
  17678. api.toggleNav(!0), TourGuide.render({
  17679. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  17680. // @ts-ignore Circular reference in Step type
  17681. steps: [
  17682. {
  17683. title: "Testing widget",
  17684. content: "Run tests right from your Storybook sidebar using the testing widget.",
  17685. placement: "right-end",
  17686. target: "#storybook-testing-module",
  17687. highlight: "#storybook-testing-module",
  17688. onNext: ({ next }) => {
  17689. let toggle = document.getElementById("testing-module-collapse-toggle");
  17690. toggle?.getAttribute("aria-label") === "Expand testing module" ? (toggle.click(), setTimeout(next, 300)) : next();
  17691. }
  17692. },
  17693. {
  17694. title: "Start a test run",
  17695. content: "Start a test run at the click of a button using Vitest.",
  17696. placement: "right",
  17697. target: '[data-module-id="storybook/test/test-provider"] button[aria-label="Start test run"]',
  17698. highlight: '[data-module-id="storybook/test/test-provider"] button[aria-label="Start test run"]',
  17699. hideNextButton: !0
  17700. }
  17701. ]
  17702. });
  17703. }
  17704. },
  17705. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Stories make great test cases. You can quickly test all of your stories directly from the test widget, at the bottom of the sidebar."), react_default.createElement(
  17706. "img",
  17707. {
  17708. src: api.getDocsUrl({
  17709. asset: "onboarding/test-widget-with-failures.png",
  17710. ref: "guide"
  17711. }),
  17712. alt: "Test widget showing test failures"
  17713. }
  17714. ), react_default.createElement("p", null, "Use the menu on a story or component to see details about a test failure or run tests for just that selection."), react_default.createElement(
  17715. "img",
  17716. {
  17717. src: api.getDocsUrl({
  17718. asset: "writing-tests/context-menu.png",
  17719. ref: "guide"
  17720. }),
  17721. alt: "Screenshot of story sidebar item with open menu"
  17722. }
  17723. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17724. Link,
  17725. {
  17726. href: api.getDocsUrl({
  17727. subpath: "writing-tests#component-tests",
  17728. renderer: !0,
  17729. ref: "guide"
  17730. }),
  17731. target: "_blank"
  17732. },
  17733. "component testing documentation"
  17734. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "About helpful features, like watch mode and sidebar filtering"), react_default.createElement("li", null, "How to run tests via CLI and in CI"), react_default.createElement("li", null, "About other capabilities, like accessibility checks and code coverage reporting")))
  17735. },
  17736. {
  17737. id: "writeInteractions",
  17738. label: "Test functionality with interactions",
  17739. available: () => !!globalThis?.FEATURES?.interactions,
  17740. criteria: "At least one story with a play or test function",
  17741. subscribe: subscribeToIndex(
  17742. (entries) => Object.values(entries).some(
  17743. (entry) => entry.tags?.includes(Tag.PLAY_FN) || entry.tags?.includes(Tag.TEST_FN)
  17744. )
  17745. ),
  17746. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "When you need to test non-visual or particularly complex behavior of a component, add a play function."), react_default.createElement(CodeSnippet, { language: "typescript" }, `// Button.stories.ts
  17747. // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
  17748. import type { Meta, StoryObj } from '@storybook/your-framework';
  17749. import { expect, fn } from 'storybook/test';
  17750. import { Button } from './Button';
  17751. const meta = {
  17752. component: Button,
  17753. args: {
  17754. // \u{1F447} Provide a mock function to spy on
  17755. onClick: fn(),
  17756. },
  17757. } satisfies Meta<typeof Button>;
  17758. export default meta;
  17759. type Story = StoryObj<typeof meta>;
  17760. export const Disabled: Story = {
  17761. args: {
  17762. disabled: true,
  17763. label: 'Button',
  17764. },
  17765. play: async function({ args, canvas, userEvent }) {
  17766. const button = canvas.getByRole('button', { name: /button/i });
  17767. // \u{1F447} Simulate behavior
  17768. await userEvent.click(button);
  17769. // \u{1F447} Make assertions
  17770. await expect(button).toHaveAttribute('aria-disabled', 'true');
  17771. await expect(args.onClick).not.toHaveBeenCalled();
  17772. }
  17773. };`), react_default.createElement("p", null, "You can interact with and debug each step defined in a play function within the Interactions panel."), react_default.createElement(
  17774. "img",
  17775. {
  17776. src: api.getDocsUrl({
  17777. asset: "writing-tests/interaction-test-pass.png",
  17778. ref: "guide"
  17779. }),
  17780. alt: "Storybook with a LoginForm component and passing interactions in the Interactions panel"
  17781. }
  17782. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17783. Link,
  17784. {
  17785. href: api.getDocsUrl({
  17786. subpath: "writing-tests/interaction-testing",
  17787. renderer: !0,
  17788. ref: "guide"
  17789. }),
  17790. target: "_blank"
  17791. },
  17792. "interaction testing documentation"
  17793. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "The full ", react_default.createElement("code", null, "play"), " function API"), react_default.createElement("li", null, "How to run code before and after tests"), react_default.createElement("li", null, "How to group interactions into steps")))
  17794. },
  17795. {
  17796. id: "installA11y",
  17797. label: "Install Accessibility addon",
  17798. afterCompletion: "unavailable",
  17799. criteria: "@storybook/addon-a11y registered in .storybook/main.js|ts",
  17800. subscribe: ({ done }) => {
  17801. addons.experimental_getRegisteredAddons().includes(ADDON_ID2) && done();
  17802. },
  17803. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Accessibility tests help ensure your UI is usable by everyone, no matter their ability."), react_default.createElement("p", null, "If you are not yet using the accessibility addon, run this command to install and set it up, enabling you to run accessibility checks alongside your component tests:"), react_default.createElement(CodeSnippet, { language: "bash" }, "npx storybook add @storybook/addon-a11y"), react_default.createElement("p", null, react_default.createElement("em", null, "Restart your Storybook after installing the addon.")), react_default.createElement("p", null, react_default.createElement(
  17804. Link,
  17805. {
  17806. href: api.getDocsUrl({
  17807. subpath: "writing-tests/accessibility-testing",
  17808. renderer: !0,
  17809. ref: "guide"
  17810. }),
  17811. target: "_blank",
  17812. withArrow: !0
  17813. },
  17814. "Learn more about the Accessibility addon"
  17815. )))
  17816. },
  17817. {
  17818. id: "accessibilityTests",
  17819. after: ["installA11y"],
  17820. label: "Run accessibility tests",
  17821. criteria: "Accessibility tests are run from the test widget in the sidebar",
  17822. subscribe: ({ api, done }) => api.on(
  17823. STORYBOOK_ADDON_TEST_CHANNEL,
  17824. ({ type, payload }) => type === "test-run-completed" && payload.config.a11y && done()
  17825. ),
  17826. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Expand the test widget, check the Accessibility checkbox, and click the Run component tests button."), react_default.createElement(
  17827. "img",
  17828. {
  17829. src: api.getDocsUrl({
  17830. asset: "writing-tests/test-widget-a11y-enabled.png",
  17831. ref: "guide"
  17832. }),
  17833. alt: "Testing widget with accessibility activated"
  17834. }
  17835. ), react_default.createElement("p", null, "If there are any failures, you can use the Accessibility panel to debug any violations."), react_default.createElement(
  17836. "img",
  17837. {
  17838. src: api.getDocsUrl({
  17839. asset: "writing-tests/addon-a11y-debug-violations.png",
  17840. ref: "guide"
  17841. }),
  17842. alt: "Storybook app with accessibility panel open, showing violations and an interactive popover on the violating elements in the preview"
  17843. }
  17844. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17845. Link,
  17846. {
  17847. href: api.getDocsUrl({
  17848. subpath: "writing-tests/accessibility-testing",
  17849. renderer: !0,
  17850. ref: "guide"
  17851. }),
  17852. target: "_blank"
  17853. },
  17854. "accessibility testing documentation"
  17855. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "The recommended workflow"), react_default.createElement("li", null, "How to run accessibility tests via CLI and in CI"), react_default.createElement("li", null, "How to configure accessibility checks")))
  17856. },
  17857. {
  17858. id: "installChromatic",
  17859. label: "Install Visual Tests addon",
  17860. afterCompletion: "unavailable",
  17861. available: () => !0,
  17862. // TODO check for compatibility with the project (not React Native)
  17863. criteria: "@chromatic-com/storybook registered in .storybook/main.js|ts",
  17864. subscribe: ({ done }) => {
  17865. addons.experimental_getRegisteredAddons().includes("chromaui/addon-visual-tests") && done();
  17866. },
  17867. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Visual tests verify the appearance of your UI components."), react_default.createElement("p", null, "If you are not yet using the visual tests addon, run this command to install and set it up, enabling you to run visual tests on your stories (this requires a free Chromatic account):"), react_default.createElement(CodeSnippet, { language: "bash" }, "npx storybook add @chromatic-com/storybook"), react_default.createElement("p", null, react_default.createElement("em", null, "Restart your Storybook after installing the addon.")), react_default.createElement("p", null, react_default.createElement(
  17868. Link,
  17869. {
  17870. href: api.getDocsUrl({
  17871. subpath: "writing-tests/visual-testing",
  17872. renderer: !0,
  17873. ref: "guide"
  17874. }),
  17875. target: "_blank",
  17876. withArrow: !0
  17877. },
  17878. "Learn more about the Visual Tests addon"
  17879. )))
  17880. },
  17881. {
  17882. id: "visualTests",
  17883. after: ["installChromatic"],
  17884. label: "Run visual tests",
  17885. criteria: "Visual tests are run from the test widget in the sidebar or the Visual Tests panel",
  17886. subscribe: ({ api, done }) => api.on("chromaui/addon-visual-tests/startBuild", done),
  17887. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Expand the test widget and click the Run visual tests button."), react_default.createElement(
  17888. "img",
  17889. {
  17890. src: api.getDocsUrl({
  17891. asset: "writing-tests/test-widget-expanded-with-vta.png",
  17892. ref: "guide"
  17893. }),
  17894. alt: "Expanded testing widget, showing the Visual tests section"
  17895. }
  17896. ), react_default.createElement("p", null, "You can use the Visual tests panel to verify the resulting diffs as either an unexpected change which needs fixed or an expected change which can then be accepted and become the new baseline."), react_default.createElement(
  17897. "img",
  17898. {
  17899. src: api.getDocsUrl({
  17900. asset: "writing-tests/vta-run-from-panel.png",
  17901. ref: "guide"
  17902. }),
  17903. alt: "Visual tests addon panel showing a diff from the baseline"
  17904. }
  17905. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17906. Link,
  17907. {
  17908. href: api.getDocsUrl({
  17909. subpath: "writing-tests/visual-testing",
  17910. renderer: !0,
  17911. ref: "guide"
  17912. }),
  17913. target: "_blank"
  17914. },
  17915. "visual testing documentation"
  17916. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to automate your visual tests in CI")))
  17917. },
  17918. {
  17919. id: "coverage",
  17920. after: ["installVitest"],
  17921. label: "Generate a coverage report",
  17922. criteria: "Generate a coverage report",
  17923. subscribe: ({ api, done }) => api.on(
  17924. STORYBOOK_ADDON_TEST_CHANNEL,
  17925. ({ type, payload }) => type === "test-run-completed" && payload.config.coverage && done()
  17926. ),
  17927. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Coverage reports show you which code is\u2014and, more importantly\u2014isn't executed while running your component tests. You use it to be sure you're testing the right things."), react_default.createElement("p", null, "To generate a coverage report, expand the test widget in the sidebar and check the Coverage checkbox. The next time you run component tests, it will generate an interactive report, which you can view by clicking the results summary in the test widget."), react_default.createElement(
  17928. "img",
  17929. {
  17930. src: api.getDocsUrl({
  17931. asset: "writing-tests/test-widget-coverage-summary.png",
  17932. ref: "guide"
  17933. }),
  17934. alt: "Test widget with coverage summary"
  17935. }
  17936. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17937. Link,
  17938. {
  17939. href: api.getDocsUrl({
  17940. subpath: "writing-tests/test-coverage",
  17941. renderer: !0,
  17942. ref: "guide"
  17943. }),
  17944. target: "_blank"
  17945. },
  17946. "test coverage documentation"
  17947. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to automate reporting in CI"), react_default.createElement("li", null, "How to configure the coverage results")))
  17948. },
  17949. {
  17950. id: "ciTests",
  17951. label: "Automate tests in CI",
  17952. criteria: "Have a CI workflow that runs component tests, either with Vitest or Chromatic",
  17953. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Automating component tests in CI is the best tool ensuring the quality and reliability of your project."), react_default.createElement("p", null, "You can automate all of Storybook's tests by using Chromatic or by running the", react_default.createElement("code", null, "vitest --project storybook"), " command in your CI scripts."), react_default.createElement(
  17954. "img",
  17955. {
  17956. src: api.getDocsUrl({
  17957. asset: "writing-tests/test-ci-workflow-pr-status-checks.png",
  17958. ref: "guide"
  17959. }),
  17960. alt: 'GitHub pull request status checks, with a failing "UI Tests / test" check'
  17961. }
  17962. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17963. Link,
  17964. {
  17965. href: api.getDocsUrl({
  17966. subpath: "writing-tests/in-ci",
  17967. renderer: !0,
  17968. ref: "guide"
  17969. }),
  17970. target: "_blank"
  17971. },
  17972. "testing in CI documentation"
  17973. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to test in your CI platform (GitHub Actions, Circle CI, etc.)"), react_default.createElement("li", null, "How to debug test failures in a published Storybook"), react_default.createElement("li", null, "How to run your other Vitest tests alongside your Storybook tests")))
  17974. }
  17975. ]
  17976. },
  17977. {
  17978. id: "document",
  17979. title: "Document",
  17980. items: [
  17981. {
  17982. id: "installDocs",
  17983. label: "Install Docs addon",
  17984. afterCompletion: "unavailable",
  17985. criteria: "@storybook/addon-docs registered in .storybook/main.js|ts",
  17986. subscribe: ({ done }) => {
  17987. addons.experimental_getRegisteredAddons().includes(ADDON_ID6) && done();
  17988. },
  17989. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Storybook Docs transforms your Storybook stories into component documentation. Add the Docs addon to your Storybook project to get started:"), react_default.createElement(CodeSnippet, { language: "bash" }, "npx storybook add @storybook/addon-docs"), react_default.createElement("p", null, react_default.createElement("em", null, "Restart your Storybook after installing the addon.")), react_default.createElement("p", null, react_default.createElement(
  17990. Link,
  17991. {
  17992. href: api.getDocsUrl({
  17993. subpath: "writing-docs",
  17994. renderer: !0,
  17995. ref: "guide"
  17996. }),
  17997. target: "_blank",
  17998. withArrow: !0
  17999. },
  18000. "Learn more about Storybook Docs"
  18001. )))
  18002. },
  18003. {
  18004. id: "autodocs",
  18005. after: ["installDocs"],
  18006. label: "Automatically document your components",
  18007. criteria: "At least one component with the autodocs tag applied",
  18008. subscribe: subscribeToIndex(
  18009. (entries) => Object.values(entries).some((entry) => entry.tags?.includes(Tag.AUTODOCS))
  18010. ),
  18011. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "Add the autodocs tag to a component's meta to automatically generate documentation for that component, complete with examples, source code, an API table, and a description."), react_default.createElement(CodeSnippet, { language: "typescript" }, `// Button.stories.js
  18012. const meta = {
  18013. component: Button,
  18014. tags: ['autodocs'], // \u{1F448} Add this tag
  18015. }
  18016. export default meta;`), react_default.createElement("p", null, "That tag can also be applied in ", react_default.createElement("code", null, ".storybook/preview.ts"), ", to generate documentation for ", react_default.createElement("em", null, "all"), " components."), react_default.createElement(
  18017. "img",
  18018. {
  18019. src: api.getDocsUrl({
  18020. asset: "writing-docs/autodocs.png",
  18021. ref: "guide"
  18022. }),
  18023. alt: "Storybook autodocs page, showing a title, description, primary story, controls table, and additional stories"
  18024. }
  18025. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  18026. Link,
  18027. {
  18028. href: api.getDocsUrl({
  18029. subpath: "writing-docs/autodocs",
  18030. renderer: !0,
  18031. ref: "guide"
  18032. }),
  18033. target: "_blank"
  18034. },
  18035. "autodocs documentation"
  18036. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to generate a table of contents"), react_default.createElement("li", null, "How to enhance your component documentation with JSDoc comments"), react_default.createElement("li", null, "How to customize the generated page")))
  18037. },
  18038. {
  18039. id: "mdxDocs",
  18040. after: ["installDocs"],
  18041. label: "Custom content with MDX",
  18042. criteria: "At least one MDX page",
  18043. subscribe: subscribeToIndex(
  18044. (entries) => Object.values(entries).some((entry) => entry.type === "docs")
  18045. ),
  18046. content: ({ api }) => react_default.createElement(react_default.Fragment, null, react_default.createElement("p", null, "You can use MDX (markdown + React components) to provide an introduction to your project, document things like design tokens, or go beyond the automatic documentation for your components."), react_default.createElement("p", null, "For a start, create an ", react_default.createElement("code", null, "introduction.mdx"), " file and (using markdown and Storybook's", " ", react_default.createElement(
  18047. Link,
  18048. {
  18049. href: api.getDocsUrl({
  18050. subpath: "writing-docs/doc-blocks",
  18051. renderer: !0,
  18052. ref: "guide"
  18053. }),
  18054. target: "_blank"
  18055. },
  18056. "doc blocks"
  18057. ), ") write a usage guide for your project."), react_default.createElement(CodeSnippet, { language: "jsx" }, `{ /* introduction.mdx */ }
  18058. import { Meta, Title, Subtitle } from '@storybook/addon-docs/blocks';
  18059. <Meta title="Get started" />
  18060. <Title>Get started with My Awesome Project</Title>
  18061. <Subtitle>It's really awesome</Subtitle>
  18062. My Awesome Project is designed to work with Your Awesome Project seamlessly.
  18063. Follow this guide and you'll be ready in no time.
  18064. ## Install
  18065. \`\`\`sh
  18066. npm install @my/awesome-project
  18067. \`\`\``), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  18068. Link,
  18069. {
  18070. href: api.getDocsUrl({
  18071. subpath: "writing-docs/mdx",
  18072. renderer: !0,
  18073. ref: "guide"
  18074. }),
  18075. target: "_blank"
  18076. },
  18077. "MDX documentation"
  18078. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to reference stories in your content"), react_default.createElement("li", null, "How to import and display markdown files, such as READMEs")))
  18079. }
  18080. ]
  18081. }
  18082. ]
  18083. };
  18084. // src/manager/components/sidebar/useChecklist.ts
  18085. var subscriptions = /* @__PURE__ */ new Map(), useStoryIndex = () => {
  18086. let state = useStorybookState(), [index, setIndex] = useState(() => state.index), updateIndex = useMemo(() => throttle(setIndex, 500), []);
  18087. return useEffect(() => updateIndex(state.index), [state.index, updateIndex]), useEffect(() => () => updateIndex.cancel?.(), [updateIndex]), index;
  18088. }, checkAvailable = (item, itemsById, context) => {
  18089. if (item.available && !item.available(context))
  18090. return !1;
  18091. for (let afterId of item.after ?? [])
  18092. if (itemsById[afterId] && !checkAvailable(itemsById[afterId], itemsById, context))
  18093. return !1;
  18094. return !0;
  18095. }, checkSkipped = (item, itemsById, state) => {
  18096. if (state[item.id].status === "skipped")
  18097. return !0;
  18098. for (let afterId of item.after ?? [])
  18099. if (itemsById[afterId] && checkSkipped(itemsById[afterId], itemsById, state))
  18100. return !0;
  18101. return !1;
  18102. }, getAncestorIds = (item, itemsById) => !item.after || item.after.length === 0 ? [] : item.after.flatMap((afterId) => {
  18103. let afterItem = itemsById[afterId];
  18104. return afterItem ? [...getAncestorIds(afterItem, itemsById), afterId] : [];
  18105. }), checkLockedBy = (item, itemsById, state) => getAncestorIds(item, itemsById).find(
  18106. (id) => state[id].status !== "accepted" && state[id].status !== "done"
  18107. ), useChecklist = () => {
  18108. let api = useStorybookApi(), index = useStoryIndex(), [checklistState] = experimental_useUniversalStore(internal_universalChecklistStore), { loaded, items, widget } = checklistState, { status } = internal_universalChecklistStore, [initialized, setInitialized] = useState(!1), [ready, setReady] = useState(!1), debounceReady = useMemo(() => debounce(() => setReady(!0), 500), []), itemsById = useMemo(() => Object.fromEntries(
  18109. checklistData.sections.flatMap(
  18110. ({ items: items2, id: sectionId, title: sectionTitle }, sectionIndex) => items2.map(({ id, ...item }, itemIndex) => [id, { id, itemIndex, sectionId, sectionIndex, sectionTitle, ...item }])
  18111. )
  18112. ), []), allItems = useMemo(() => Object.values(itemsById).map((item) => {
  18113. let { status: status2, mutedAt } = items[item.id], isOpen = status2 === "open", isAccepted = status2 === "accepted", isDone = status2 === "done", isCompleted = isAccepted || isDone, isSkipped = !isCompleted && checkSkipped(item, itemsById, items), isMuted = !!mutedAt || !!widget.disable, isAvailable = isCompleted ? item.afterCompletion !== "unavailable" : checkAvailable(item, itemsById, { api, index, item, storeState: checklistState }), isLockedBy = checkLockedBy(item, itemsById, items), isImmutable = isCompleted && item.afterCompletion === "immutable";
  18114. return {
  18115. ...item,
  18116. isAvailable,
  18117. isOpen,
  18118. isLockedBy,
  18119. isImmutable,
  18120. isReady: isOpen && isAvailable && !isMuted && !isLockedBy,
  18121. isCompleted,
  18122. isAccepted,
  18123. isDone,
  18124. isSkipped,
  18125. isMuted
  18126. };
  18127. }), [itemsById, items, widget, api, index, checklistState]), itemCollections = useMemo(() => {
  18128. let availableItems = allItems.filter((item) => item.isAvailable), openItems = availableItems.filter((item) => item.isOpen), readyItems = openItems.filter((item) => item.isReady), nextItems = Object.values(
  18129. readyItems.reduce((acc, item) => (acc[item.sectionId] ??= [], acc[item.sectionId].push({ ...item, itemIndex: acc[item.sectionId].length }), acc), {})
  18130. ).flat().sort((a2, b2) => a2.itemIndex - b2.itemIndex).slice(0, 3).sort((a2, b2) => a2.sectionIndex - b2.sectionIndex), progress = availableItems.length ? Math.round((availableItems.length - openItems.length) / availableItems.length * 100) : 100;
  18131. return { availableItems, openItems, readyItems, nextItems, progress };
  18132. }, [allItems]);
  18133. return useEffect(() => {
  18134. if (!(!loaded || status !== experimental_UniversalStore.Status.READY))
  18135. for (let item of allItems) {
  18136. if (!item.subscribe)
  18137. continue;
  18138. let subscribed = subscriptions.has(item.id);
  18139. if (item.isOpen && item.isAvailable && !subscribed)
  18140. subscriptions.set(
  18141. item.id,
  18142. item.subscribe({
  18143. api,
  18144. item,
  18145. accept: () => internal_checklistStore.accept(item.id),
  18146. done: () => internal_checklistStore.done(item.id),
  18147. skip: () => internal_checklistStore.skip(item.id)
  18148. })
  18149. );
  18150. else if (subscribed && !(item.isOpen && item.isAvailable)) {
  18151. let unsubscribe = subscriptions.get(item.id);
  18152. subscriptions.delete(item.id), typeof unsubscribe == "function" && unsubscribe();
  18153. }
  18154. }
  18155. }, [api, loaded, status, allItems]), useEffect(() => {
  18156. let initialize = () => setInitialized(!0), timeout = setTimeout(initialize, 1e3);
  18157. return api.once(PREVIEW_INITIALIZED, initialize), () => {
  18158. clearTimeout(timeout), api.off(PREVIEW_INITIALIZED, initialize);
  18159. };
  18160. }, [api]), useEffect(() => {
  18161. initialized && items && status === experimental_UniversalStore.Status.READY && debounceReady();
  18162. }, [initialized, items, status, debounceReady]), {
  18163. ready,
  18164. allItems,
  18165. ...itemCollections,
  18166. ...internal_checklistStore,
  18167. ...checklistState
  18168. };
  18169. };
  18170. // src/shared/useCopyButton.ts
  18171. init_react();
  18172. // ../../node_modules/@react-aria/live-announcer/dist/LiveAnnouncer.mjs
  18173. var $319e236875307eab$var$liveAnnouncer = null;
  18174. function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = 7e3) {
  18175. $319e236875307eab$var$liveAnnouncer ? $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout) : ($319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer(), (typeof IS_REACT_ACT_ENVIRONMENT == "boolean" ? IS_REACT_ACT_ENVIRONMENT : typeof jest < "u") ? $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout) : setTimeout(() => {
  18176. $319e236875307eab$var$liveAnnouncer?.isAttached() && $319e236875307eab$var$liveAnnouncer?.announce(message, assertiveness, timeout);
  18177. }, 100));
  18178. }
  18179. function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
  18180. $319e236875307eab$var$liveAnnouncer && $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
  18181. }
  18182. var $319e236875307eab$var$LiveAnnouncer = class {
  18183. isAttached() {
  18184. var _this_node;
  18185. return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;
  18186. }
  18187. createLog(ariaLive) {
  18188. let node = document.createElement("div");
  18189. return node.setAttribute("role", "log"), node.setAttribute("aria-live", ariaLive), node.setAttribute("aria-relevant", "additions"), node;
  18190. }
  18191. destroy() {
  18192. this.node && (document.body.removeChild(this.node), this.node = null);
  18193. }
  18194. announce(message, assertiveness = "assertive", timeout = 7e3) {
  18195. var _this_assertiveLog, _this_politeLog;
  18196. if (!this.node) return;
  18197. let node = document.createElement("div");
  18198. typeof message == "object" ? (node.setAttribute("role", "img"), node.setAttribute("aria-labelledby", message["aria-labelledby"])) : node.textContent = message, assertiveness === "assertive" ? (_this_assertiveLog = this.assertiveLog) === null || _this_assertiveLog === void 0 || _this_assertiveLog.appendChild(node) : (_this_politeLog = this.politeLog) === null || _this_politeLog === void 0 || _this_politeLog.appendChild(node), message !== "" && setTimeout(() => {
  18199. node.remove();
  18200. }, timeout);
  18201. }
  18202. clear(assertiveness) {
  18203. this.node && ((!assertiveness || assertiveness === "assertive") && this.assertiveLog && (this.assertiveLog.innerHTML = ""), (!assertiveness || assertiveness === "polite") && this.politeLog && (this.politeLog.innerHTML = ""));
  18204. }
  18205. constructor() {
  18206. this.node = null, this.assertiveLog = null, this.politeLog = null, typeof document < "u" && (this.node = document.createElement("div"), this.node.dataset.liveAnnouncer = "true", Object.assign(this.node.style, {
  18207. border: 0,
  18208. clip: "rect(0 0 0 0)",
  18209. clipPath: "inset(50%)",
  18210. height: "1px",
  18211. margin: "-1px",
  18212. overflow: "hidden",
  18213. padding: 0,
  18214. position: "absolute",
  18215. width: "1px",
  18216. whiteSpace: "nowrap"
  18217. }), this.assertiveLog = this.createLog("assertive"), this.node.appendChild(this.assertiveLog), this.politeLog = this.createLog("polite"), this.node.appendChild(this.politeLog), document.body.prepend(this.node));
  18218. }
  18219. };
  18220. // src/shared/useCopyButton.ts
  18221. function useCopyButton({
  18222. children = "Copy",
  18223. childrenOnCopy = "Copied!",
  18224. content,
  18225. onCopy,
  18226. ariaLabel = !1,
  18227. ariaLabelOnCopy = !1,
  18228. duration = 3e3
  18229. }) {
  18230. let [copied, setCopied] = useState(!1), timerRef = useRef(null);
  18231. useEffect(
  18232. () => () => {
  18233. timerRef.current && clearTimeout(timerRef.current);
  18234. },
  18235. []
  18236. );
  18237. let handleClick = useCallback(
  18238. (e2) => {
  18239. timerRef.current && clearTimeout(timerRef.current);
  18240. let announcement = typeof ariaLabelOnCopy == "string" ? ariaLabelOnCopy : "Copied to clipboard";
  18241. navigator.clipboard?.writeText(content).then(() => {
  18242. onCopy?.(e2), setCopied(!0), $319e236875307eab$export$a9b970dcc4ae71a9(announcement, "polite"), timerRef.current = setTimeout(() => {
  18243. setCopied(!1), $319e236875307eab$export$d10ae4f68404609a("polite"), timerRef.current = null;
  18244. }, duration);
  18245. });
  18246. },
  18247. [content, onCopy, ariaLabelOnCopy, duration]
  18248. );
  18249. return {
  18250. // @ts-expect-error - TypeScript is not realising T is constrained identically in both interfaces.
  18251. children: copied ? childrenOnCopy : children,
  18252. buttonProps: useMemo(
  18253. () => ({
  18254. onClick: handleClick,
  18255. ariaLabel: copied ? ariaLabelOnCopy : ariaLabel
  18256. }),
  18257. [handleClick, copied, ariaLabelOnCopy, ariaLabel]
  18258. )
  18259. };
  18260. }
  18261. // src/manager/components/sidebar/ChecklistWidget.tsx
  18262. var fadeScaleIn = keyframes`
  18263. from {
  18264. opacity: 0;
  18265. transform: scale(0.7);
  18266. }
  18267. to {
  18268. opacity: 1;
  18269. transform: scale(1);
  18270. }
  18271. `, expand = keyframes`
  18272. from {
  18273. transform: scaleX(0);
  18274. }
  18275. to {
  18276. transform: scaleX(1);
  18277. }
  18278. `, useTransitionArray = (array, subset, options2) => {
  18279. let keyFnRef = useRef(options2.keyFn), { setItem, toggle, stateMap } = useTransitionMap({
  18280. allowMultiple: !0,
  18281. mountOnEnter: !0,
  18282. unmountOnExit: !0,
  18283. preEnter: !0,
  18284. ...options2
  18285. });
  18286. return useEffect(() => {
  18287. let keyFn = keyFnRef.current;
  18288. array.forEach((task) => setItem(keyFn(task)));
  18289. }, [array, setItem]), useEffect(() => {
  18290. let keyFn = keyFnRef.current;
  18291. array.forEach((task) => toggle(keyFn(task), subset.map(keyFn).includes(keyFn(task))));
  18292. }, [array, subset, toggle]), Array.from(stateMap).map(
  18293. ([key, value]) => [array.find((item) => keyFnRef.current(item) === key), value]
  18294. );
  18295. }, CollapsibleWithMargin = styled(Collapsible)(({ collapsed }) => ({
  18296. marginTop: collapsed ? 0 : 16
  18297. })), HoverCard = styled(Card)({
  18298. "&:hover #checklist-module-collapse-toggle": {
  18299. opacity: 1
  18300. }
  18301. }), CollapseToggle2 = styled(ActionList.Button)({
  18302. opacity: 0,
  18303. transition: "opacity var(--transition-duration, 0.2s)",
  18304. "&:focus, &:hover": {
  18305. opacity: 1
  18306. }
  18307. }), ProgressCircle = styled(ProgressSpinner)(({ theme }) => ({
  18308. color: theme.color.secondary
  18309. })), Checked = styled(StatusPassIcon)(({ theme }) => ({
  18310. padding: 1,
  18311. borderRadius: "50%",
  18312. background: theme.color.positive,
  18313. color: theme.background.content,
  18314. animation: `${fadeScaleIn} 500ms forwards`
  18315. })), ItemLabel = styled.span(
  18316. ({ theme, isCompleted, isSkipped }) => ({
  18317. position: "relative",
  18318. margin: "0 -2px",
  18319. padding: "0 2px",
  18320. color: isSkipped ? theme.color.mediumdark : isCompleted ? theme.base === "dark" ? theme.color.positive : theme.color.positiveText : theme.color.defaultText,
  18321. transition: "color 500ms"
  18322. }),
  18323. ({ theme, isSkipped }) => isSkipped && {
  18324. alignSelf: "flex-start",
  18325. "&:after": {
  18326. content: '""',
  18327. position: "absolute",
  18328. top: "50%",
  18329. left: 0,
  18330. width: "100%",
  18331. height: 1,
  18332. background: theme.color.mediumdark,
  18333. animation: `${expand} 500ms forwards`,
  18334. transformOrigin: "left"
  18335. }
  18336. }
  18337. ), title = (progress) => {
  18338. switch (!0) {
  18339. case progress < 50:
  18340. return "Get started";
  18341. case progress < 75:
  18342. return "Level up";
  18343. default:
  18344. return "Become an expert";
  18345. }
  18346. }, OpenGuideButton = ({
  18347. children,
  18348. afterClick
  18349. }) => {
  18350. let api = useStorybookApi();
  18351. return react_default.createElement(
  18352. ActionList.Action,
  18353. {
  18354. ariaLabel: "Open onboarding guide",
  18355. onClick: (e2) => {
  18356. e2.stopPropagation(), api.navigate("/settings/guide"), afterClick?.();
  18357. }
  18358. },
  18359. react_default.createElement(ActionList.Icon, null, react_default.createElement(ListUnorderedIcon, null)),
  18360. children
  18361. );
  18362. }, CopyButton = ({
  18363. label,
  18364. copyContent,
  18365. onClick,
  18366. ...props
  18367. }) => {
  18368. let { children: copyChildren, buttonProps: copyButtonProps } = useCopyButton({
  18369. children: label,
  18370. childrenOnCopy: react_default.createElement(react_default.Fragment, null, react_default.createElement(CheckIcon, null), " Copied!"),
  18371. onCopy: onClick,
  18372. content: copyContent
  18373. });
  18374. return react_default.createElement(ActionList.Button, { ...props, ...copyButtonProps }, copyChildren);
  18375. }, ChecklistWidget = () => {
  18376. let api = useStorybookApi(), { loaded, ready, allItems, nextItems, progress, accept, mute, items } = useChecklist(), [renderItems, setRenderItems] = useState(nextItems), [animated, setAnimated] = useState(!1);
  18377. useEffect(() => {
  18378. if (ready) {
  18379. let timeout = setTimeout(setAnimated, 1e3, !0);
  18380. return () => clearTimeout(timeout);
  18381. }
  18382. }, [ready]), useEffect(() => {
  18383. if (!animated) {
  18384. setRenderItems(nextItems);
  18385. return;
  18386. }
  18387. setRenderItems((current) => {
  18388. let animateOut = !1, prevItems = current.map((item) => {
  18389. let { status } = items[item.id], isAccepted = status === "accepted", isDone = status === "done", isSkipped = status === "skipped";
  18390. return animateOut = animateOut || isAccepted || isDone || isSkipped, { ...item, isCompleted: isAccepted || isDone, isAccepted, isDone, isSkipped };
  18391. });
  18392. return animateOut ? prevItems : nextItems;
  18393. });
  18394. let timeout = setTimeout(setRenderItems, 2e3, nextItems);
  18395. return () => clearTimeout(timeout);
  18396. }, [animated, nextItems, items]);
  18397. let hasItems = renderItems.length > 0, transitionItems = useTransitionArray(allItems, renderItems, {
  18398. keyFn: (item) => item.id,
  18399. timeout: animated ? 300 : 0
  18400. });
  18401. return api.getIsNavShown() ? react_default.createElement(CollapsibleWithMargin, { collapsed: !hasItems || !loaded }, react_default.createElement(HoverCard, { id: "storybook-checklist-widget", outlineAnimation: "rainbow" }, react_default.createElement(
  18402. Collapsible,
  18403. {
  18404. storageKey: "checklist-widget",
  18405. initialCollapsed: !hasItems,
  18406. disabled: !hasItems,
  18407. summary: ({ isCollapsed, toggleCollapsed, toggleProps }) => react_default.createElement(ActionList, { as: "div", onClick: toggleCollapsed }, react_default.createElement(ActionList.Item, { as: "div" }, react_default.createElement(ActionList.Item, { as: "div", style: { flexShrink: 1 } }, loaded && react_default.createElement(
  18408. Optional,
  18409. {
  18410. content: react_default.createElement(OpenGuideButton, null, react_default.createElement("strong", null, title(progress))),
  18411. fallback: react_default.createElement(OpenGuideButton, null)
  18412. }
  18413. )), react_default.createElement(ActionList.Item, { as: "div" }, react_default.createElement(
  18414. CollapseToggle2,
  18415. {
  18416. ...toggleProps,
  18417. id: "checklist-module-collapse-toggle",
  18418. ariaLabel: `${isCollapsed ? "Expand" : "Collapse"} onboarding guide`
  18419. },
  18420. react_default.createElement(
  18421. ChevronSmallUpIcon,
  18422. {
  18423. style: {
  18424. transform: isCollapsed ? "rotate(180deg)" : "none",
  18425. transition: "transform 250ms",
  18426. willChange: "auto"
  18427. }
  18428. }
  18429. )
  18430. ), loaded && react_default.createElement(
  18431. PopoverProvider,
  18432. {
  18433. ariaLabel: "Onboarding guide menu",
  18434. padding: 0,
  18435. popover: ({ onHide }) => react_default.createElement(ActionList, null, react_default.createElement(ActionList.Item, null, react_default.createElement(OpenGuideButton, { afterClick: onHide }, react_default.createElement(ActionList.Text, null, "Open full guide"))), react_default.createElement(ActionList.Item, null, react_default.createElement(
  18436. ActionList.Action,
  18437. {
  18438. ariaLabel: !1,
  18439. onClick: (e2) => {
  18440. e2.stopPropagation(), mute(allItems.map(({ id }) => id)), onHide();
  18441. }
  18442. },
  18443. react_default.createElement(ActionList.Icon, null, react_default.createElement(EyeCloseIcon, null)),
  18444. react_default.createElement(ActionList.Text, null, "Remove from sidebar")
  18445. )))
  18446. },
  18447. react_default.createElement(
  18448. ActionList.Button,
  18449. {
  18450. ariaLabel: `${progress}% completed`,
  18451. onClick: (e2) => e2.stopPropagation()
  18452. },
  18453. react_default.createElement(
  18454. ProgressCircle,
  18455. {
  18456. percentage: progress,
  18457. running: !1,
  18458. size: 16,
  18459. width: 1.5
  18460. }
  18461. ),
  18462. react_default.createElement(TextFlip, { text: `${progress}%`, placeholder: "00%" })
  18463. )
  18464. ))))
  18465. },
  18466. react_default.createElement(ActionList, null, transitionItems.map(
  18467. ([item, { status, isMounted }]) => isMounted && react_default.createElement(ActionList.HoverItem, { key: item.id, targetId: item.id, transitionStatus: status }, react_default.createElement(
  18468. ActionList.Action,
  18469. {
  18470. ariaLabel: `Open onboarding guide for ${item.label}`,
  18471. onClick: () => api.navigate(`/settings/guide#${item.id}`)
  18472. },
  18473. react_default.createElement(ActionList.Icon, null, item.isCompleted && animated ? react_default.createElement(Particles, { anchor: Checked, key: item.id }) : item.icon ? react_default.createElement(item.icon, null) : react_default.createElement(CircleHollowIcon, null)),
  18474. react_default.createElement(ActionList.Text, null, react_default.createElement(ItemLabel, { isCompleted: item.isCompleted, isSkipped: item.isSkipped }, item.label))
  18475. ), item.action && (item.action.copyContent ? react_default.createElement(
  18476. CopyButton,
  18477. {
  18478. "data-target-id": item.id,
  18479. label: item.action.label,
  18480. copyContent: item.action.copyContent,
  18481. onClick: (e2) => {
  18482. e2.stopPropagation(), item.action?.onClick({
  18483. api,
  18484. accept: () => accept(item.id)
  18485. });
  18486. }
  18487. }
  18488. ) : react_default.createElement(
  18489. ActionList.Button,
  18490. {
  18491. "data-target-id": item.id,
  18492. ariaLabel: !1,
  18493. onClick: (e2) => {
  18494. e2.stopPropagation(), item.action?.onClick({
  18495. api,
  18496. accept: () => accept(item.id)
  18497. });
  18498. }
  18499. },
  18500. item.action.label
  18501. )))
  18502. ))
  18503. ))) : null;
  18504. };
  18505. // src/manager/components/sidebar/CreateNewStoryFileModal.tsx
  18506. init_react();
  18507. // src/manager/hooks/useDebounce.ts
  18508. init_react();
  18509. function useDebounce(value, delay2) {
  18510. let [debouncedValue, setDebouncedValue] = useState(value);
  18511. return useEffect(() => {
  18512. let handler = setTimeout(() => {
  18513. setDebouncedValue(value);
  18514. }, delay2);
  18515. return () => {
  18516. clearTimeout(handler);
  18517. };
  18518. }, [value, delay2]), debouncedValue;
  18519. }
  18520. // src/manager/components/sidebar/FileSearchModal.tsx
  18521. init_react();
  18522. // src/manager/hooks/useMeasure.tsx
  18523. init_react();
  18524. function useMeasure() {
  18525. let [dimensions, setDimensions] = react_default.useState({
  18526. width: null,
  18527. height: null
  18528. }), prevObserver = react_default.useRef(null);
  18529. return [react_default.useCallback((node) => {
  18530. if (prevObserver.current && (prevObserver.current.disconnect(), prevObserver.current = null), node?.nodeType === Node.ELEMENT_NODE) {
  18531. let observer = new ResizeObserver(([entry]) => {
  18532. if (entry && entry.borderBoxSize) {
  18533. let { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];
  18534. setDimensions({ width, height });
  18535. }
  18536. });
  18537. observer.observe(node), prevObserver.current = observer;
  18538. }
  18539. }, []), dimensions];
  18540. }
  18541. // src/manager/components/sidebar/FileSearchList.tsx
  18542. init_react();
  18543. // ../../node_modules/@tanstack/react-virtual/dist/esm/index.js
  18544. init_react();
  18545. // ../../node_modules/@tanstack/virtual-core/dist/esm/utils.js
  18546. function memo2(getDeps, fn, opts) {
  18547. let deps = opts.initialDeps ?? [], result;
  18548. function memoizedFunction() {
  18549. var _a2, _b, _c, _d;
  18550. let depTime;
  18551. opts.key && ((_a2 = opts.debug) != null && _a2.call(opts)) && (depTime = Date.now());
  18552. let newDeps = getDeps();
  18553. if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep)))
  18554. return result;
  18555. deps = newDeps;
  18556. let resultTime;
  18557. if (opts.key && ((_b = opts.debug) != null && _b.call(opts)) && (resultTime = Date.now()), result = fn(...newDeps), opts.key && ((_c = opts.debug) != null && _c.call(opts))) {
  18558. let depEndTime = Math.round((Date.now() - depTime) * 100) / 100, resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100, resultFpsPercentage = resultEndTime / 16, pad = (str, num) => {
  18559. for (str = String(str); str.length < num; )
  18560. str = " " + str;
  18561. return str;
  18562. };
  18563. console.info(
  18564. `%c\u23F1 ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,
  18565. `
  18566. font-size: .6rem;
  18567. font-weight: bold;
  18568. color: hsl(${Math.max(
  18569. 0,
  18570. Math.min(120 - 120 * resultFpsPercentage, 120)
  18571. )}deg 100% 31%);`,
  18572. opts?.key
  18573. );
  18574. }
  18575. return (_d = opts?.onChange) == null || _d.call(opts, result), result;
  18576. }
  18577. return memoizedFunction.updateDeps = (newDeps) => {
  18578. deps = newDeps;
  18579. }, memoizedFunction;
  18580. }
  18581. function notUndefined(value, msg) {
  18582. if (value === void 0)
  18583. throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
  18584. return value;
  18585. }
  18586. var approxEqual = (a2, b2) => Math.abs(a2 - b2) < 1.01, debounce3 = (targetWindow, fn, ms) => {
  18587. let timeoutId;
  18588. return function(...args) {
  18589. targetWindow.clearTimeout(timeoutId), timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
  18590. };
  18591. };
  18592. // ../../node_modules/@tanstack/virtual-core/dist/esm/index.js
  18593. var getRect = (element) => {
  18594. let { offsetWidth, offsetHeight } = element;
  18595. return { width: offsetWidth, height: offsetHeight };
  18596. }, defaultKeyExtractor = (index) => index, defaultRangeExtractor = (range) => {
  18597. let start = Math.max(range.startIndex - range.overscan, 0), end = Math.min(range.endIndex + range.overscan, range.count - 1), arr = [];
  18598. for (let i2 = start; i2 <= end; i2++)
  18599. arr.push(i2);
  18600. return arr;
  18601. }, observeElementRect = (instance, cb) => {
  18602. let element = instance.scrollElement;
  18603. if (!element)
  18604. return;
  18605. let targetWindow = instance.targetWindow;
  18606. if (!targetWindow)
  18607. return;
  18608. let handler = (rect) => {
  18609. let { width, height } = rect;
  18610. cb({ width: Math.round(width), height: Math.round(height) });
  18611. };
  18612. if (handler(getRect(element)), !targetWindow.ResizeObserver)
  18613. return () => {
  18614. };
  18615. let observer = new targetWindow.ResizeObserver((entries) => {
  18616. let run = () => {
  18617. let entry = entries[0];
  18618. if (entry?.borderBoxSize) {
  18619. let box = entry.borderBoxSize[0];
  18620. if (box) {
  18621. handler({ width: box.inlineSize, height: box.blockSize });
  18622. return;
  18623. }
  18624. }
  18625. handler(getRect(element));
  18626. };
  18627. instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
  18628. });
  18629. return observer.observe(element, { box: "border-box" }), () => {
  18630. observer.unobserve(element);
  18631. };
  18632. }, addEventListenerOptions = {
  18633. passive: !0
  18634. };
  18635. var supportsScrollend = typeof window > "u" ? !0 : "onscrollend" in window, observeElementOffset = (instance, cb) => {
  18636. let element = instance.scrollElement;
  18637. if (!element)
  18638. return;
  18639. let targetWindow = instance.targetWindow;
  18640. if (!targetWindow)
  18641. return;
  18642. let offset2 = 0, fallback = instance.options.useScrollendEvent && supportsScrollend ? () => {
  18643. } : debounce3(
  18644. targetWindow,
  18645. () => {
  18646. cb(offset2, !1);
  18647. },
  18648. instance.options.isScrollingResetDelay
  18649. ), createHandler = (isScrolling) => () => {
  18650. let { horizontal, isRtl } = instance.options;
  18651. offset2 = horizontal ? element.scrollLeft * (isRtl && -1 || 1) : element.scrollTop, fallback(), cb(offset2, isScrolling);
  18652. }, handler = createHandler(!0), endHandler = createHandler(!1);
  18653. endHandler(), element.addEventListener("scroll", handler, addEventListenerOptions);
  18654. let registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
  18655. return registerScrollendEvent && element.addEventListener("scrollend", endHandler, addEventListenerOptions), () => {
  18656. element.removeEventListener("scroll", handler), registerScrollendEvent && element.removeEventListener("scrollend", endHandler);
  18657. };
  18658. };
  18659. var measureElement = (element, entry, instance) => {
  18660. if (entry?.borderBoxSize) {
  18661. let box = entry.borderBoxSize[0];
  18662. if (box)
  18663. return Math.round(
  18664. box[instance.options.horizontal ? "inlineSize" : "blockSize"]
  18665. );
  18666. }
  18667. return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
  18668. };
  18669. var elementScroll = (offset2, {
  18670. adjustments = 0,
  18671. behavior
  18672. }, instance) => {
  18673. var _a2, _b;
  18674. let toOffset = offset2 + adjustments;
  18675. (_b = (_a2 = instance.scrollElement) == null ? void 0 : _a2.scrollTo) == null || _b.call(_a2, {
  18676. [instance.options.horizontal ? "left" : "top"]: toOffset,
  18677. behavior
  18678. });
  18679. }, Virtualizer = class {
  18680. constructor(opts) {
  18681. this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
  18682. let _ro = null, get2 = () => _ro || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : _ro = new this.targetWindow.ResizeObserver((entries) => {
  18683. entries.forEach((entry) => {
  18684. let run = () => {
  18685. this._measureElement(entry.target, entry);
  18686. };
  18687. this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
  18688. });
  18689. }));
  18690. return {
  18691. disconnect: () => {
  18692. var _a2;
  18693. (_a2 = get2()) == null || _a2.disconnect(), _ro = null;
  18694. },
  18695. observe: (target) => {
  18696. var _a2;
  18697. return (_a2 = get2()) == null ? void 0 : _a2.observe(target, { box: "border-box" });
  18698. },
  18699. unobserve: (target) => {
  18700. var _a2;
  18701. return (_a2 = get2()) == null ? void 0 : _a2.unobserve(target);
  18702. }
  18703. };
  18704. })(), this.range = null, this.setOptions = (opts2) => {
  18705. Object.entries(opts2).forEach(([key, value]) => {
  18706. typeof value > "u" && delete opts2[key];
  18707. }), this.options = {
  18708. debug: !1,
  18709. initialOffset: 0,
  18710. overscan: 1,
  18711. paddingStart: 0,
  18712. paddingEnd: 0,
  18713. scrollPaddingStart: 0,
  18714. scrollPaddingEnd: 0,
  18715. horizontal: !1,
  18716. getItemKey: defaultKeyExtractor,
  18717. rangeExtractor: defaultRangeExtractor,
  18718. onChange: () => {
  18719. },
  18720. measureElement,
  18721. initialRect: { width: 0, height: 0 },
  18722. scrollMargin: 0,
  18723. gap: 0,
  18724. indexAttribute: "data-index",
  18725. initialMeasurementsCache: [],
  18726. lanes: 1,
  18727. isScrollingResetDelay: 150,
  18728. enabled: !0,
  18729. isRtl: !1,
  18730. useScrollendEvent: !1,
  18731. useAnimationFrameWithResizeObserver: !1,
  18732. ...opts2
  18733. };
  18734. }, this.notify = (sync) => {
  18735. var _a2, _b;
  18736. (_b = (_a2 = this.options).onChange) == null || _b.call(_a2, this, sync);
  18737. }, this.maybeNotify = memo2(
  18738. () => (this.calculateRange(), [
  18739. this.isScrolling,
  18740. this.range ? this.range.startIndex : null,
  18741. this.range ? this.range.endIndex : null
  18742. ]),
  18743. (isScrolling) => {
  18744. this.notify(isScrolling);
  18745. },
  18746. {
  18747. key: !1,
  18748. debug: () => this.options.debug,
  18749. initialDeps: [
  18750. this.isScrolling,
  18751. this.range ? this.range.startIndex : null,
  18752. this.range ? this.range.endIndex : null
  18753. ]
  18754. }
  18755. ), this.cleanup = () => {
  18756. this.unsubs.filter(Boolean).forEach((d2) => d2()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
  18757. }, this._didMount = () => () => {
  18758. this.cleanup();
  18759. }, this._willUpdate = () => {
  18760. var _a2;
  18761. let scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
  18762. if (this.scrollElement !== scrollElement) {
  18763. if (this.cleanup(), !scrollElement) {
  18764. this.maybeNotify();
  18765. return;
  18766. }
  18767. this.scrollElement = scrollElement, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((_a2 = this.scrollElement) == null ? void 0 : _a2.window) ?? null, this.elementsCache.forEach((cached) => {
  18768. this.observer.observe(cached);
  18769. }), this._scrollToOffset(this.getScrollOffset(), {
  18770. adjustments: void 0,
  18771. behavior: void 0
  18772. }), this.unsubs.push(
  18773. this.options.observeElementRect(this, (rect) => {
  18774. this.scrollRect = rect, this.maybeNotify();
  18775. })
  18776. ), this.unsubs.push(
  18777. this.options.observeElementOffset(this, (offset2, isScrolling) => {
  18778. this.scrollAdjustments = 0, this.scrollDirection = isScrolling ? this.getScrollOffset() < offset2 ? "forward" : "backward" : null, this.scrollOffset = offset2, this.isScrolling = isScrolling, this.maybeNotify();
  18779. })
  18780. );
  18781. }
  18782. }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (measurements, index) => {
  18783. let furthestMeasurementsFound = /* @__PURE__ */ new Map(), furthestMeasurements = /* @__PURE__ */ new Map();
  18784. for (let m2 = index - 1; m2 >= 0; m2--) {
  18785. let measurement = measurements[m2];
  18786. if (furthestMeasurementsFound.has(measurement.lane))
  18787. continue;
  18788. let previousFurthestMeasurement = furthestMeasurements.get(
  18789. measurement.lane
  18790. );
  18791. if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end ? furthestMeasurements.set(measurement.lane, measurement) : measurement.end < previousFurthestMeasurement.end && furthestMeasurementsFound.set(measurement.lane, !0), furthestMeasurementsFound.size === this.options.lanes)
  18792. break;
  18793. }
  18794. return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a2, b2) => a2.end === b2.end ? a2.index - b2.index : a2.end - b2.end)[0] : void 0;
  18795. }, this.getMeasurementOptions = memo2(
  18796. () => [
  18797. this.options.count,
  18798. this.options.paddingStart,
  18799. this.options.scrollMargin,
  18800. this.options.getItemKey,
  18801. this.options.enabled
  18802. ],
  18803. (count, paddingStart, scrollMargin, getItemKey, enabled) => (this.pendingMeasuredCacheIndexes = [], {
  18804. count,
  18805. paddingStart,
  18806. scrollMargin,
  18807. getItemKey,
  18808. enabled
  18809. }),
  18810. {
  18811. key: !1
  18812. }
  18813. ), this.getMeasurements = memo2(
  18814. () => [this.getMeasurementOptions(), this.itemSizeCache],
  18815. ({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
  18816. if (!enabled)
  18817. return this.measurementsCache = [], this.itemSizeCache.clear(), [];
  18818. this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((item) => {
  18819. this.itemSizeCache.set(item.key, item.size);
  18820. }));
  18821. let min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
  18822. this.pendingMeasuredCacheIndexes = [];
  18823. let measurements = this.measurementsCache.slice(0, min);
  18824. for (let i2 = min; i2 < count; i2++) {
  18825. let key = getItemKey(i2), furthestMeasurement = this.options.lanes === 1 ? measurements[i2 - 1] : this.getFurthestMeasurement(measurements, i2), start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin, measuredSize = itemSizeCache.get(key), size = typeof measuredSize == "number" ? measuredSize : this.options.estimateSize(i2), end = start + size, lane = furthestMeasurement ? furthestMeasurement.lane : i2 % this.options.lanes;
  18826. measurements[i2] = {
  18827. index: i2,
  18828. start,
  18829. size,
  18830. end,
  18831. key,
  18832. lane
  18833. };
  18834. }
  18835. return this.measurementsCache = measurements, measurements;
  18836. },
  18837. {
  18838. key: !1,
  18839. debug: () => this.options.debug
  18840. }
  18841. ), this.calculateRange = memo2(
  18842. () => [
  18843. this.getMeasurements(),
  18844. this.getSize(),
  18845. this.getScrollOffset(),
  18846. this.options.lanes
  18847. ],
  18848. (measurements, outerSize, scrollOffset, lanes) => this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
  18849. measurements,
  18850. outerSize,
  18851. scrollOffset,
  18852. lanes
  18853. }) : null,
  18854. {
  18855. key: !1,
  18856. debug: () => this.options.debug
  18857. }
  18858. ), this.getVirtualIndexes = memo2(
  18859. () => {
  18860. let startIndex = null, endIndex = null, range = this.calculateRange();
  18861. return range && (startIndex = range.startIndex, endIndex = range.endIndex), this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]), [
  18862. this.options.rangeExtractor,
  18863. this.options.overscan,
  18864. this.options.count,
  18865. startIndex,
  18866. endIndex
  18867. ];
  18868. },
  18869. (rangeExtractor, overscan, count, startIndex, endIndex) => startIndex === null || endIndex === null ? [] : rangeExtractor({
  18870. startIndex,
  18871. endIndex,
  18872. overscan,
  18873. count
  18874. }),
  18875. {
  18876. key: !1,
  18877. debug: () => this.options.debug
  18878. }
  18879. ), this.indexFromElement = (node) => {
  18880. let attributeName = this.options.indexAttribute, indexStr = node.getAttribute(attributeName);
  18881. return indexStr ? parseInt(indexStr, 10) : (console.warn(
  18882. `Missing attribute name '${attributeName}={index}' on measured element.`
  18883. ), -1);
  18884. }, this._measureElement = (node, entry) => {
  18885. let index = this.indexFromElement(node), item = this.measurementsCache[index];
  18886. if (!item)
  18887. return;
  18888. let key = item.key, prevNode = this.elementsCache.get(key);
  18889. prevNode !== node && (prevNode && this.observer.unobserve(prevNode), this.observer.observe(node), this.elementsCache.set(key, node)), node.isConnected && this.resizeItem(index, this.options.measureElement(node, entry, this));
  18890. }, this.resizeItem = (index, size) => {
  18891. let item = this.measurementsCache[index];
  18892. if (!item)
  18893. return;
  18894. let itemSize = this.itemSizeCache.get(item.key) ?? item.size, delta = size - itemSize;
  18895. delta !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments) && this._scrollToOffset(this.getScrollOffset(), {
  18896. adjustments: this.scrollAdjustments += delta,
  18897. behavior: void 0
  18898. }), this.pendingMeasuredCacheIndexes.push(item.index), this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size)), this.notify(!1));
  18899. }, this.measureElement = (node) => {
  18900. if (!node) {
  18901. this.elementsCache.forEach((cached, key) => {
  18902. cached.isConnected || (this.observer.unobserve(cached), this.elementsCache.delete(key));
  18903. });
  18904. return;
  18905. }
  18906. this._measureElement(node, void 0);
  18907. }, this.getVirtualItems = memo2(
  18908. () => [this.getVirtualIndexes(), this.getMeasurements()],
  18909. (indexes, measurements) => {
  18910. let virtualItems = [];
  18911. for (let k2 = 0, len = indexes.length; k2 < len; k2++) {
  18912. let i2 = indexes[k2], measurement = measurements[i2];
  18913. virtualItems.push(measurement);
  18914. }
  18915. return virtualItems;
  18916. },
  18917. {
  18918. key: !1,
  18919. debug: () => this.options.debug
  18920. }
  18921. ), this.getVirtualItemForOffset = (offset2) => {
  18922. let measurements = this.getMeasurements();
  18923. if (measurements.length !== 0)
  18924. return notUndefined(
  18925. measurements[findNearestBinarySearch(
  18926. 0,
  18927. measurements.length - 1,
  18928. (index) => notUndefined(measurements[index]).start,
  18929. offset2
  18930. )]
  18931. );
  18932. }, this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
  18933. let size = this.getSize(), scrollOffset = this.getScrollOffset();
  18934. align === "auto" && (align = toOffset >= scrollOffset + size ? "end" : "start"), align === "center" ? toOffset += (itemSize - size) / 2 : align === "end" && (toOffset -= size);
  18935. let maxOffset = this.getTotalSize() + this.options.scrollMargin - size;
  18936. return Math.max(Math.min(maxOffset, toOffset), 0);
  18937. }, this.getOffsetForIndex = (index, align = "auto") => {
  18938. index = Math.max(0, Math.min(index, this.options.count - 1));
  18939. let item = this.measurementsCache[index];
  18940. if (!item)
  18941. return;
  18942. let size = this.getSize(), scrollOffset = this.getScrollOffset();
  18943. if (align === "auto")
  18944. if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd)
  18945. align = "end";
  18946. else if (item.start <= scrollOffset + this.options.scrollPaddingStart)
  18947. align = "start";
  18948. else
  18949. return [scrollOffset, align];
  18950. let toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
  18951. return [
  18952. this.getOffsetForAlignment(toOffset, align, item.size),
  18953. align
  18954. ];
  18955. }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
  18956. behavior === "smooth" && this.isDynamicMode() && console.warn(
  18957. "The `smooth` scroll behavior is not fully supported with dynamic size."
  18958. ), this._scrollToOffset(this.getOffsetForAlignment(toOffset, align), {
  18959. adjustments: void 0,
  18960. behavior
  18961. });
  18962. }, this.scrollToIndex = (index, { align: initialAlign = "auto", behavior } = {}) => {
  18963. behavior === "smooth" && this.isDynamicMode() && console.warn(
  18964. "The `smooth` scroll behavior is not fully supported with dynamic size."
  18965. ), index = Math.max(0, Math.min(index, this.options.count - 1));
  18966. let attempts = 0, maxAttempts = 10, tryScroll = (currentAlign) => {
  18967. if (!this.targetWindow) return;
  18968. let offsetInfo = this.getOffsetForIndex(index, currentAlign);
  18969. if (!offsetInfo) {
  18970. console.warn("Failed to get offset for index:", index);
  18971. return;
  18972. }
  18973. let [offset2, align] = offsetInfo;
  18974. this._scrollToOffset(offset2, { adjustments: void 0, behavior }), this.targetWindow.requestAnimationFrame(() => {
  18975. let currentOffset = this.getScrollOffset(), afterInfo = this.getOffsetForIndex(index, align);
  18976. if (!afterInfo) {
  18977. console.warn("Failed to get offset for index:", index);
  18978. return;
  18979. }
  18980. approxEqual(afterInfo[0], currentOffset) || scheduleRetry(align);
  18981. });
  18982. }, scheduleRetry = (align) => {
  18983. this.targetWindow && (attempts++, attempts < maxAttempts ? this.targetWindow.requestAnimationFrame(() => tryScroll(align)) : console.warn(
  18984. `Failed to scroll to index ${index} after ${maxAttempts} attempts.`
  18985. ));
  18986. };
  18987. tryScroll(initialAlign);
  18988. }, this.scrollBy = (delta, { behavior } = {}) => {
  18989. behavior === "smooth" && this.isDynamicMode() && console.warn(
  18990. "The `smooth` scroll behavior is not fully supported with dynamic size."
  18991. ), this._scrollToOffset(this.getScrollOffset() + delta, {
  18992. adjustments: void 0,
  18993. behavior
  18994. });
  18995. }, this.getTotalSize = () => {
  18996. var _a2;
  18997. let measurements = this.getMeasurements(), end;
  18998. if (measurements.length === 0)
  18999. end = this.options.paddingStart;
  19000. else if (this.options.lanes === 1)
  19001. end = ((_a2 = measurements[measurements.length - 1]) == null ? void 0 : _a2.end) ?? 0;
  19002. else {
  19003. let endByLane = Array(this.options.lanes).fill(null), endIndex = measurements.length - 1;
  19004. for (; endIndex >= 0 && endByLane.some((val) => val === null); ) {
  19005. let item = measurements[endIndex];
  19006. endByLane[item.lane] === null && (endByLane[item.lane] = item.end), endIndex--;
  19007. }
  19008. end = Math.max(...endByLane.filter((val) => val !== null));
  19009. }
  19010. return Math.max(
  19011. end - this.options.scrollMargin + this.options.paddingEnd,
  19012. 0
  19013. );
  19014. }, this._scrollToOffset = (offset2, {
  19015. adjustments,
  19016. behavior
  19017. }) => {
  19018. this.options.scrollToFn(offset2, { behavior, adjustments }, this);
  19019. }, this.measure = () => {
  19020. this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
  19021. }, this.setOptions(opts);
  19022. }
  19023. }, findNearestBinarySearch = (low, high, getCurrentValue, value) => {
  19024. for (; low <= high; ) {
  19025. let middle = (low + high) / 2 | 0, currentValue = getCurrentValue(middle);
  19026. if (currentValue < value)
  19027. low = middle + 1;
  19028. else if (currentValue > value)
  19029. high = middle - 1;
  19030. else
  19031. return middle;
  19032. }
  19033. return low > 0 ? low - 1 : 0;
  19034. };
  19035. function calculateRange({
  19036. measurements,
  19037. outerSize,
  19038. scrollOffset,
  19039. lanes
  19040. }) {
  19041. let lastIndex = measurements.length - 1, getOffset = (index) => measurements[index].start;
  19042. if (measurements.length <= lanes)
  19043. return {
  19044. startIndex: 0,
  19045. endIndex: lastIndex
  19046. };
  19047. let startIndex = findNearestBinarySearch(
  19048. 0,
  19049. lastIndex,
  19050. getOffset,
  19051. scrollOffset
  19052. ), endIndex = startIndex;
  19053. if (lanes === 1)
  19054. for (; endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize; )
  19055. endIndex++;
  19056. else if (lanes > 1) {
  19057. let endPerLane = Array(lanes).fill(0);
  19058. for (; endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize); ) {
  19059. let item = measurements[endIndex];
  19060. endPerLane[item.lane] = item.end, endIndex++;
  19061. }
  19062. let startPerLane = Array(lanes).fill(scrollOffset + outerSize);
  19063. for (; startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset); ) {
  19064. let item = measurements[startIndex];
  19065. startPerLane[item.lane] = item.start, startIndex--;
  19066. }
  19067. startIndex = Math.max(0, startIndex - startIndex % lanes), endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
  19068. }
  19069. return { startIndex, endIndex };
  19070. }
  19071. // ../../node_modules/@tanstack/react-virtual/dist/esm/index.js
  19072. var useIsomorphicLayoutEffect = typeof document < "u" ? useLayoutEffect : useEffect;
  19073. function useVirtualizerBase(options2) {
  19074. let rerender = useReducer(() => ({}), {})[1], resolvedOptions = {
  19075. ...options2,
  19076. onChange: (instance2, sync) => {
  19077. var _a2;
  19078. sync ? flushSync(rerender) : rerender(), (_a2 = options2.onChange) == null || _a2.call(options2, instance2, sync);
  19079. }
  19080. }, [instance] = useState(
  19081. () => new Virtualizer(resolvedOptions)
  19082. );
  19083. return instance.setOptions(resolvedOptions), useIsomorphicLayoutEffect(() => instance._didMount(), []), useIsomorphicLayoutEffect(() => instance._willUpdate()), instance;
  19084. }
  19085. function useVirtualizer(options2) {
  19086. return useVirtualizerBase({
  19087. observeElementRect,
  19088. observeElementOffset,
  19089. scrollToFn: elementScroll,
  19090. ...options2
  19091. });
  19092. }
  19093. // src/manager/components/sidebar/FIleSearchList.utils.tsx
  19094. init_react();
  19095. var useArrowKeyNavigation = ({
  19096. parentRef,
  19097. rowVirtualizer,
  19098. selectedItem
  19099. }) => {
  19100. useEffect(() => {
  19101. let handleArrowKeys = (event) => {
  19102. if (!parentRef.current)
  19103. return;
  19104. let maxIndex = rowVirtualizer.options.count, activeElement = document.activeElement, rowIndex = parseInt(activeElement.getAttribute("data-index") || "-1", 10), isActiveElementInput = activeElement.tagName === "INPUT", getFirstElement = () => document.querySelector('[data-index="0"]'), getLastElement = () => document.querySelector(`[data-index="${maxIndex - 1}"]`);
  19105. if (event.code === "ArrowDown" && activeElement) {
  19106. if (event.stopPropagation(), isActiveElementInput) {
  19107. getFirstElement()?.focus();
  19108. return;
  19109. }
  19110. if (rowIndex === maxIndex - 1) {
  19111. flushSync(() => {
  19112. rowVirtualizer.scrollToIndex(0, { align: "start" });
  19113. }), setTimeout(() => {
  19114. getFirstElement()?.focus();
  19115. }, 100);
  19116. return;
  19117. }
  19118. if (selectedItem === rowIndex) {
  19119. document.querySelector(
  19120. `[data-index-position="${selectedItem}_first"]`
  19121. )?.focus();
  19122. return;
  19123. }
  19124. if (selectedItem !== null && activeElement.getAttribute("data-index-position")?.includes("last")) {
  19125. document.querySelector(
  19126. `[data-index="${selectedItem + 1}"]`
  19127. )?.focus();
  19128. return;
  19129. }
  19130. activeElement.nextElementSibling?.focus();
  19131. }
  19132. if (event.code === "ArrowUp" && activeElement) {
  19133. if (isActiveElementInput) {
  19134. flushSync(() => {
  19135. rowVirtualizer.scrollToIndex(maxIndex - 1, { align: "start" });
  19136. }), setTimeout(() => {
  19137. getLastElement()?.focus();
  19138. }, 100);
  19139. return;
  19140. }
  19141. if (selectedItem !== null && activeElement.getAttribute("data-index-position")?.includes("first")) {
  19142. document.querySelector(
  19143. `[data-index="${selectedItem}"]`
  19144. )?.focus();
  19145. return;
  19146. }
  19147. activeElement.previousElementSibling?.focus();
  19148. }
  19149. };
  19150. return document.addEventListener("keydown", handleArrowKeys, { capture: !0 }), () => {
  19151. document.removeEventListener("keydown", handleArrowKeys, { capture: !0 });
  19152. };
  19153. }, [rowVirtualizer, selectedItem, parentRef]);
  19154. };
  19155. // src/manager/components/sidebar/FileList.tsx
  19156. var FileListWrapper = styled("div")(({ theme }) => ({
  19157. marginTop: "-16px",
  19158. // after element which fades out the list
  19159. "&::after": {
  19160. content: '""',
  19161. position: "fixed",
  19162. pointerEvents: "none",
  19163. bottom: 0,
  19164. left: 0,
  19165. right: 0,
  19166. height: "80px",
  19167. background: `linear-gradient(${rgba(theme.barBg, 0)} 10%, ${theme.barBg} 80%)`
  19168. }
  19169. })), FileList = styled("div")({
  19170. height: "280px",
  19171. overflow: "auto",
  19172. msOverflowStyle: "none",
  19173. scrollbarWidth: "none",
  19174. position: "relative",
  19175. "::-webkit-scrollbar": {
  19176. display: "none"
  19177. }
  19178. }), FileListLi = styled("li")(({ theme }) => ({
  19179. ":focus-visible": {
  19180. outline: "none",
  19181. ".file-list-item": {
  19182. borderRadius: "4px",
  19183. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : theme.color.mediumlight,
  19184. "> svg": {
  19185. display: "flex"
  19186. }
  19187. }
  19188. }
  19189. })), FileListItem = styled("div")({
  19190. display: "flex",
  19191. flexDirection: "column",
  19192. position: "relative"
  19193. }), FileListItemContentWrapper = styled.div(({ theme, selected, disabled, error }) => ({
  19194. display: "flex",
  19195. alignItems: "flex-start",
  19196. gap: "8px",
  19197. alignSelf: "stretch",
  19198. padding: "8px 16px",
  19199. cursor: "pointer",
  19200. borderRadius: "4px",
  19201. ...selected && {
  19202. borderRadius: "4px",
  19203. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : theme.color.mediumlight,
  19204. "> svg": {
  19205. display: "flex"
  19206. }
  19207. },
  19208. ...disabled && {
  19209. cursor: "not-allowed",
  19210. div: {
  19211. color: `${theme.textMutedColor} !important`
  19212. }
  19213. },
  19214. ...error && {
  19215. background: theme.base === "light" ? "#00000011" : "#00000033"
  19216. },
  19217. "&:hover": {
  19218. background: error ? "#00000022" : theme.base === "dark" ? "rgba(255,255,255,.1)" : theme.color.mediumlight,
  19219. "> svg": {
  19220. display: "flex"
  19221. }
  19222. }
  19223. })), FileListUl = styled("ul")({
  19224. margin: 0,
  19225. padding: "0 0 0 0",
  19226. width: "100%",
  19227. position: "relative"
  19228. }), FileListItemContent = styled("div")({
  19229. display: "flex",
  19230. flexDirection: "column",
  19231. alignItems: "flex-start",
  19232. width: "calc(100% - 50px)"
  19233. }), FileListIconWrapper = styled("div")(({ theme, error }) => ({
  19234. color: error ? theme.color.negativeText : theme.color.secondary
  19235. })), FileListItemLabel = styled("div")(({ theme, error }) => ({
  19236. color: error ? theme.color.negativeText : theme.base === "dark" ? theme.color.lighter : theme.color.darkest,
  19237. fontSize: "14px",
  19238. whiteSpace: "nowrap",
  19239. textOverflow: "ellipsis",
  19240. overflow: "hidden",
  19241. maxWidth: "100%"
  19242. })), FileListItemPath = styled("div")(({ theme }) => ({
  19243. color: theme.textMutedColor,
  19244. fontSize: "14px",
  19245. whiteSpace: "nowrap",
  19246. textOverflow: "ellipsis",
  19247. overflow: "hidden",
  19248. maxWidth: "100%"
  19249. })), FileListExport = styled("ul")({
  19250. margin: 0,
  19251. padding: 0
  19252. }), FileListItemExport = styled("li")(({ theme, error }) => ({
  19253. padding: "8px 16px 8px 58px",
  19254. display: "flex",
  19255. gap: "8px",
  19256. alignItems: "center",
  19257. justifyContent: "space-between",
  19258. fontSize: "14px",
  19259. cursor: "pointer",
  19260. borderRadius: "4px",
  19261. ":focus-visible": {
  19262. outline: "none"
  19263. },
  19264. ...error && {
  19265. background: "#F9ECEC",
  19266. color: theme.color.negativeText
  19267. },
  19268. "&:hover,:focus-visible": {
  19269. background: error ? "#F9ECEC" : theme.base === "dark" ? "rgba(255, 255, 255, 0.1)" : theme.color.mediumlight,
  19270. "> svg": {
  19271. display: "flex"
  19272. }
  19273. },
  19274. "> div > svg": {
  19275. color: error ? theme.color.negativeText : theme.color.secondary
  19276. }
  19277. })), FileListItemExportName = styled("div")({
  19278. display: "flex",
  19279. alignItems: "center",
  19280. gap: "8px",
  19281. width: "calc(100% - 20px)"
  19282. }), FileListItemExportNameContent = styled("span")(({ theme }) => ({
  19283. whiteSpace: "nowrap",
  19284. textOverflow: "ellipsis",
  19285. overflow: "hidden",
  19286. display: "inline-block",
  19287. color: theme.base === "dark" ? theme.color.lightest : theme.color.darkest
  19288. })), FileListItemExportNameContentWithExport = styled(FileListItemExportNameContent)({
  19289. maxWidth: "calc(100% - 120px)"
  19290. }), DefaultExport = styled("span")(({ theme }) => ({
  19291. display: "inline-block",
  19292. padding: `1px ${theme.appBorderRadius}px`,
  19293. borderRadius: "2px",
  19294. fontSize: "10px",
  19295. color: theme.color.defaultText,
  19296. backgroundColor: theme.base === "dark" ? "rgba(255, 255, 255, 0.1)" : "#F2F4F5"
  19297. })), NoResults = styled("div")(({ theme }) => ({
  19298. textAlign: "center",
  19299. maxWidth: "334px",
  19300. margin: "16px auto 50px auto",
  19301. fontSize: "14px",
  19302. color: theme.base === "dark" ? theme.color.lightest : "#000"
  19303. })), NoResultsDescription = styled("p")(({ theme }) => ({
  19304. margin: 0,
  19305. color: theme.textMutedColor
  19306. }));
  19307. // src/manager/components/sidebar/FileSearchListSkeleton.tsx
  19308. init_react();
  19309. var FileListItemContentWrapperSkeleton = styled("div")(({ theme }) => ({
  19310. display: "flex",
  19311. alignItems: "flex-start",
  19312. gap: "8px",
  19313. alignSelf: "stretch",
  19314. padding: "8px 16px"
  19315. })), FileListItemContentSkeleton = styled("div")({
  19316. display: "flex",
  19317. flexDirection: "column",
  19318. alignItems: "flex-start",
  19319. width: "100%",
  19320. borderRadius: "3px"
  19321. }), FileListIconWrapperSkeleton = styled.div(({ theme }) => ({
  19322. width: "14px",
  19323. height: "14px",
  19324. borderRadius: "3px",
  19325. marginTop: "1px",
  19326. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : "rgba(0,0,0,.1)",
  19327. animation: `${theme.animation.glow} 1.5s ease-in-out infinite`
  19328. })), FileListItemSkeleton = styled.div(({ theme }) => ({
  19329. height: "16px",
  19330. borderRadius: "3px",
  19331. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : "rgba(0,0,0,.1)",
  19332. animation: `${theme.animation.glow} 1.5s ease-in-out infinite`,
  19333. width: "100%",
  19334. maxWidth: "100%",
  19335. "+ div": {
  19336. marginTop: "6px"
  19337. }
  19338. })), FileSearchListLoadingSkeleton = () => react_default.createElement(FileList, null, [1, 2, 3].map((result) => react_default.createElement(FileListItem, { key: result }, react_default.createElement(FileListItemContentWrapperSkeleton, null, react_default.createElement(FileListIconWrapperSkeleton, null), react_default.createElement(FileListItemContentSkeleton, null, react_default.createElement(FileListItemSkeleton, { style: { width: "90px" } }), react_default.createElement(FileListItemSkeleton, { style: { width: "300px" } }))))));
  19339. // src/manager/components/sidebar/FileSearchList.tsx
  19340. var TreeExpandIconStyled = styled(ChevronSmallRightIcon)(({ theme }) => ({
  19341. color: theme.textMutedColor,
  19342. marginTop: 2
  19343. })), TreeCollapseIconStyled = styled(ChevronSmallDownIcon)(({ theme }) => ({
  19344. color: theme.textMutedColor,
  19345. marginTop: 2
  19346. })), FileSearchList = memo(function({
  19347. isLoading,
  19348. searchResults,
  19349. onNewStory,
  19350. errorItemId
  19351. }) {
  19352. let [selectedItem, setSelectedItem] = useState(null), parentRef = react_default.useRef(), sortedSearchResults = useMemo(() => [...searchResults ?? []].sort((a2, b2) => {
  19353. let isALowPriority = a2.exportedComponents === null || a2.exportedComponents?.length === 0, hasAStory = a2.storyFileExists, isBLowPriority = b2.exportedComponents === null || b2.exportedComponents?.length === 0, hasBStory = b2.storyFileExists;
  19354. return hasAStory && !hasBStory ? -1 : hasBStory && !hasAStory || isALowPriority && !isBLowPriority ? 1 : !isALowPriority && isBLowPriority ? -1 : 0;
  19355. }), [searchResults]), count = searchResults?.length || 0, rowVirtualizer = useVirtualizer({
  19356. count,
  19357. // @ts-expect-error (non strict)
  19358. getScrollElement: () => parentRef.current,
  19359. paddingStart: 16,
  19360. paddingEnd: 40,
  19361. estimateSize: () => 54,
  19362. overscan: 2
  19363. });
  19364. useArrowKeyNavigation({ rowVirtualizer, parentRef, selectedItem });
  19365. let handleFileItemSelection = useCallback(
  19366. ({ virtualItem, searchResult, itemId }) => {
  19367. searchResult?.exportedComponents?.length > 1 ? setSelectedItem((sItem) => sItem === virtualItem.index ? null : virtualItem.index) : searchResult?.exportedComponents?.length === 1 && onNewStory({
  19368. componentExportName: searchResult.exportedComponents[0].name,
  19369. componentFilePath: searchResult.filepath,
  19370. componentIsDefaultExport: searchResult.exportedComponents[0].default,
  19371. selectedItemId: itemId,
  19372. componentExportCount: 1
  19373. });
  19374. },
  19375. [onNewStory]
  19376. ), handleFileItemComponentSelection = useCallback(
  19377. ({ searchResult, component, id }) => {
  19378. onNewStory({
  19379. componentExportName: component.name,
  19380. componentFilePath: searchResult.filepath,
  19381. componentIsDefaultExport: component.default,
  19382. selectedItemId: id,
  19383. // @ts-expect-error (non strict)
  19384. componentExportCount: searchResult.exportedComponents.length
  19385. });
  19386. },
  19387. [onNewStory]
  19388. ), ListItem2 = useCallback(
  19389. ({
  19390. virtualItem,
  19391. selected,
  19392. searchResult,
  19393. noExports
  19394. }) => {
  19395. let itemError = errorItemId === searchResult.filepath, itemSelected = selected === virtualItem.index, tooltip = noExports ? "We can't evaluate exports for this file. Automatic story creation is disabled." : void 0;
  19396. return react_default.createElement(
  19397. FileListItem,
  19398. {
  19399. "aria-expanded": itemSelected,
  19400. "aria-controls": `file-list-export-${virtualItem.index}`,
  19401. id: `file-list-item-wrapper-${virtualItem.index}`
  19402. },
  19403. react_default.createElement(
  19404. TooltipProvider,
  19405. {
  19406. tooltip: tooltip ? react_default.createElement(TooltipNote, { note: tooltip }) : void 0,
  19407. placement: "top-start",
  19408. delayHide: 100,
  19409. delayShow: 200
  19410. },
  19411. react_default.createElement(
  19412. FileListItemContentWrapper,
  19413. {
  19414. className: "file-list-item",
  19415. selected: itemSelected,
  19416. error: itemError,
  19417. disabled: noExports
  19418. },
  19419. itemSelected ? react_default.createElement(TreeCollapseIconStyled, { size: 14 }) : react_default.createElement(TreeExpandIconStyled, { size: 14 }),
  19420. react_default.createElement(FileListIconWrapper, { error: itemError }, react_default.createElement(ComponentIcon, null)),
  19421. react_default.createElement(FileListItemContent, null, react_default.createElement(FileListItemLabel, { error: itemError }, searchResult.filepath.split("/").at(-1)), react_default.createElement(FileListItemPath, null, searchResult.filepath))
  19422. )
  19423. ),
  19424. searchResult?.exportedComponents?.length > 1 && itemSelected && react_default.createElement(
  19425. FileListExport,
  19426. {
  19427. role: "region",
  19428. id: `file-list-export-${virtualItem.index}`,
  19429. "aria-labelledby": `file-list-item-wrapper-${virtualItem.index}`,
  19430. onClick: (e2) => {
  19431. e2.stopPropagation();
  19432. },
  19433. onKeyUp: (e2) => {
  19434. e2.key === "Enter" && e2.stopPropagation();
  19435. }
  19436. },
  19437. searchResult.exportedComponents?.map((component, itemExportId) => {
  19438. let itemExportError = errorItemId === `${searchResult.filepath}_${itemExportId}`, position = itemExportId === 0 ? "first" : (
  19439. // @ts-expect-error (non strict)
  19440. itemExportId === searchResult.exportedComponents.length - 1 ? "last" : "middle"
  19441. );
  19442. return react_default.createElement(
  19443. FileListItemExport,
  19444. {
  19445. tabIndex: 0,
  19446. "data-index-position": `${virtualItem.index}_${position}`,
  19447. key: component.name,
  19448. error: itemExportError,
  19449. onClick: () => {
  19450. handleFileItemComponentSelection({
  19451. searchResult,
  19452. component,
  19453. id: `${searchResult.filepath}_${itemExportId}`
  19454. });
  19455. },
  19456. onKeyUp: (event) => {
  19457. event.key === "Enter" && handleFileItemComponentSelection({
  19458. searchResult,
  19459. component,
  19460. id: `${searchResult.filepath}_${itemExportId}`
  19461. });
  19462. }
  19463. },
  19464. react_default.createElement(FileListItemExportName, null, react_default.createElement(BookmarkHollowIcon, null), component.default ? react_default.createElement(react_default.Fragment, null, react_default.createElement(FileListItemExportNameContentWithExport, null, searchResult.filepath.split("/").at(-1)?.split(".")?.at(0)), react_default.createElement(DefaultExport, null, "Default export")) : react_default.createElement(FileListItemExportNameContent, null, component.name))
  19465. );
  19466. })
  19467. )
  19468. );
  19469. },
  19470. [handleFileItemComponentSelection, errorItemId]
  19471. );
  19472. return isLoading && (searchResults === null || searchResults?.length === 0) ? react_default.createElement(FileSearchListLoadingSkeleton, null) : searchResults?.length === 0 ? react_default.createElement(NoResults, null, react_default.createElement("p", null, "We could not find any file with that name"), react_default.createElement(NoResultsDescription, null, "You may want to try using different keywords, check for typos, and adjust your filters")) : sortedSearchResults?.length > 0 ? react_default.createElement(FileListWrapper, null, react_default.createElement(FileList, { ref: parentRef }, react_default.createElement(
  19473. FileListUl,
  19474. {
  19475. style: {
  19476. height: `${rowVirtualizer.getTotalSize()}px`
  19477. }
  19478. },
  19479. rowVirtualizer.getVirtualItems().map((virtualItem) => {
  19480. let searchResult = sortedSearchResults[virtualItem.index], noExports = searchResult.exportedComponents === null || searchResult.exportedComponents?.length === 0, itemProps = {};
  19481. return react_default.createElement(
  19482. FileListLi,
  19483. {
  19484. key: virtualItem.key,
  19485. "data-index": virtualItem.index,
  19486. ref: rowVirtualizer.measureElement,
  19487. onClick: () => {
  19488. handleFileItemSelection({
  19489. virtualItem,
  19490. itemId: searchResult.filepath,
  19491. searchResult
  19492. });
  19493. },
  19494. onKeyUp: (event) => {
  19495. event.key === "Enter" && handleFileItemSelection({
  19496. virtualItem,
  19497. itemId: searchResult.filepath,
  19498. searchResult
  19499. });
  19500. },
  19501. style: {
  19502. position: "absolute",
  19503. top: 0,
  19504. left: 0,
  19505. width: "100%",
  19506. transform: `translateY(${virtualItem.start}px)`
  19507. },
  19508. tabIndex: 0
  19509. },
  19510. react_default.createElement(
  19511. ListItem2,
  19512. {
  19513. ...itemProps,
  19514. key: virtualItem.index,
  19515. searchResult,
  19516. selected: selectedItem,
  19517. virtualItem,
  19518. noExports
  19519. }
  19520. )
  19521. );
  19522. })
  19523. ))) : null;
  19524. });
  19525. // src/manager/components/sidebar/FileSearchModal.tsx
  19526. var MODAL_HEIGHT = 418, ModalStyled = styled(Modal)(() => ({
  19527. boxShadow: "none",
  19528. background: "transparent",
  19529. overflow: "visible"
  19530. })), ModalChild = styled.div(({ theme, height }) => ({
  19531. backgroundColor: theme.background.bar,
  19532. borderRadius: 6,
  19533. boxShadow: "rgba(255, 255, 255, 0.05) 0 0 0 1px inset, rgba(14, 18, 22, 0.35) 0px 10px 18px -10px",
  19534. padding: "16px",
  19535. transition: "height 0.3s",
  19536. height: height ? `${height + 32}px` : "auto",
  19537. overflow: "hidden"
  19538. })), ModalContent = styled(Modal.Content)(({ theme }) => ({
  19539. margin: 0,
  19540. color: theme.color.defaultText
  19541. })), ModalInput = styled(Form.Input)(({ theme }) => ({
  19542. paddingLeft: 40,
  19543. paddingRight: 28,
  19544. fontSize: 14,
  19545. height: 40,
  19546. ...theme.base === "light" && {
  19547. color: theme.color.darkest
  19548. },
  19549. "::placeholder": {
  19550. color: theme.color.mediumdark
  19551. },
  19552. "&:invalid:not(:placeholder-shown)": {
  19553. boxShadow: `${theme.color.negative} 0 0 0 1px inset`
  19554. },
  19555. "&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration": {
  19556. display: "none"
  19557. }
  19558. })), SearchField = styled.div({
  19559. display: "flex",
  19560. flexDirection: "column",
  19561. flexGrow: 1,
  19562. position: "relative"
  19563. }), SearchIconWrapper = styled.div(({ theme }) => ({
  19564. position: "absolute",
  19565. top: 0,
  19566. left: 16,
  19567. zIndex: 1,
  19568. pointerEvents: "none",
  19569. color: theme.darkest,
  19570. display: "flex",
  19571. alignItems: "center",
  19572. height: "100%"
  19573. })), LoadingIcon = styled.div(({ theme }) => ({
  19574. position: "absolute",
  19575. top: 0,
  19576. right: 16,
  19577. zIndex: 1,
  19578. color: theme.darkest,
  19579. display: "flex",
  19580. alignItems: "center",
  19581. height: "100%",
  19582. "@keyframes spin": {
  19583. from: { transform: "rotate(0deg)" },
  19584. to: { transform: "rotate(360deg)" }
  19585. },
  19586. animation: "spin 1s linear infinite"
  19587. })), ModalError = styled(Modal.Error)({
  19588. position: "absolute",
  19589. padding: "8px 40px 8px 16px",
  19590. bottom: 0,
  19591. maxHeight: "initial",
  19592. width: "100%",
  19593. div: {
  19594. wordBreak: "break-word"
  19595. },
  19596. "> div": {
  19597. padding: 0
  19598. }
  19599. }), ModalErrorCloseIcon = styled(CloseAltIcon)({
  19600. position: "absolute",
  19601. top: 4,
  19602. right: -24,
  19603. cursor: "pointer"
  19604. }), FileSearchModal = ({
  19605. open,
  19606. onOpenChange,
  19607. fileSearchQuery,
  19608. setFileSearchQuery,
  19609. isLoading,
  19610. error,
  19611. searchResults,
  19612. onCreateNewStory,
  19613. setError
  19614. }) => {
  19615. let [modalContentRef, modalContentDimensions] = useMeasure(), [modalMaxHeight, setModalMaxHeight] = useState(modalContentDimensions.height), [, startTransition2] = useTransition(), [searchInputValue, setSearchInputValue] = useState(fileSearchQuery);
  19616. return useEffect(() => {
  19617. modalMaxHeight < modalContentDimensions.height && setModalMaxHeight(modalContentDimensions.height);
  19618. }, [modalContentDimensions.height, modalMaxHeight]), react_default.createElement(
  19619. ModalStyled,
  19620. {
  19621. ariaLabel: "Add a new story",
  19622. height: MODAL_HEIGHT,
  19623. width: 440,
  19624. open,
  19625. onOpenChange
  19626. },
  19627. react_default.createElement(ModalChild, { height: fileSearchQuery === "" ? modalContentDimensions.height : modalMaxHeight }, react_default.createElement(ModalContent, { ref: modalContentRef }, react_default.createElement(Modal.Header, null, react_default.createElement(Modal.Title, null, "Add a new story"), react_default.createElement(Modal.Description, null, "We will create a new story for your component")), react_default.createElement(SearchField, null, react_default.createElement(SearchIconWrapper, null, react_default.createElement(SearchIcon, null)), react_default.createElement(
  19628. ModalInput,
  19629. {
  19630. placeholder: "./components/**/*.tsx",
  19631. type: "search",
  19632. required: !0,
  19633. autoFocus: !0,
  19634. value: searchInputValue,
  19635. onChange: (e2) => {
  19636. let newValue = e2.target.value;
  19637. setSearchInputValue(newValue), startTransition2(() => {
  19638. setFileSearchQuery(newValue);
  19639. });
  19640. }
  19641. }
  19642. ), isLoading && react_default.createElement(LoadingIcon, null, react_default.createElement(SyncIcon, null))), react_default.createElement(
  19643. FileSearchList,
  19644. {
  19645. errorItemId: error?.selectedItemId,
  19646. isLoading,
  19647. searchResults,
  19648. onNewStory: onCreateNewStory
  19649. }
  19650. ))),
  19651. error && fileSearchQuery !== "" && react_default.createElement(ModalError, null, react_default.createElement("div", null, error.error), react_default.createElement(
  19652. ModalErrorCloseIcon,
  19653. {
  19654. onClick: () => {
  19655. setError(null);
  19656. }
  19657. }
  19658. ))
  19659. );
  19660. };
  19661. // src/manager/utils/trySelectStory.ts
  19662. async function trySelectStory(selectStory, storyId, attempt = 1) {
  19663. if (attempt > 10)
  19664. throw new Error("We could not select the new story. Please try again.");
  19665. try {
  19666. selectStory(storyId);
  19667. } catch {
  19668. return await new Promise((resolve) => setTimeout(resolve, 500)), trySelectStory(selectStory, storyId, attempt + 1);
  19669. }
  19670. }
  19671. // src/manager/components/sidebar/CreateNewStoryFileModal.tsx
  19672. var isRendererReact = scope.STORYBOOK_RENDERER === "react", CreateNewStoryFileModal = ({ open, onOpenChange }) => {
  19673. let [isLoading, setLoading] = useState(!1), [fileSearchQuery, setFileSearchQuery] = useState(""), fileSearchQueryDebounced = useDebounce(fileSearchQuery, 600), fileSearchQueryDeferred = useDeferredValue(fileSearchQueryDebounced), emittedValue = useRef(null), [error, setError] = useState(
  19674. null
  19675. ), api = useStorybookApi(), hasRunGhostStoriesFlow = useRef(!1), [searchResults, setSearchResults] = useState(null), handleSuccessfullyCreatedStory = useCallback(
  19676. (componentExportName) => {
  19677. api.addNotification({
  19678. id: "create-new-story-file-success",
  19679. content: {
  19680. headline: "Story file created",
  19681. subHeadline: `${componentExportName} was created`
  19682. },
  19683. duration: 8e3,
  19684. icon: react_default.createElement(CheckIcon, null)
  19685. }), onOpenChange(!1);
  19686. },
  19687. [api, onOpenChange]
  19688. ), handleStoryAlreadyExists = useCallback(() => {
  19689. api.addNotification({
  19690. id: "create-new-story-file-error",
  19691. content: {
  19692. headline: "Story already exists",
  19693. subHeadline: "Successfully navigated to existing story"
  19694. },
  19695. duration: 8e3,
  19696. icon: react_default.createElement(CheckIcon, null)
  19697. }), onOpenChange(!1);
  19698. }, [api, onOpenChange]), handleFileSearch = useCallback(() => {
  19699. setLoading(!0);
  19700. let channel = addons.getChannel(), set = (data) => {
  19701. data.id === fileSearchQueryDeferred && (data.success ? setSearchResults(data.payload.files) : setError({ error: data.error }), channel.off(FILE_COMPONENT_SEARCH_RESPONSE, set), setLoading(!1), emittedValue.current = null);
  19702. };
  19703. return channel.on(FILE_COMPONENT_SEARCH_RESPONSE, set), fileSearchQueryDeferred !== "" && emittedValue.current !== fileSearchQueryDeferred ? (emittedValue.current = fileSearchQueryDeferred, channel.emit(FILE_COMPONENT_SEARCH_REQUEST, {
  19704. id: fileSearchQueryDeferred,
  19705. payload: {}
  19706. })) : (setSearchResults(null), setLoading(!1)), () => {
  19707. channel.off(FILE_COMPONENT_SEARCH_RESPONSE, set);
  19708. };
  19709. }, [fileSearchQueryDeferred]), handleCreateNewStory = useCallback(
  19710. async ({
  19711. componentExportName,
  19712. componentFilePath,
  19713. componentIsDefaultExport,
  19714. componentExportCount,
  19715. selectedItemId
  19716. }) => {
  19717. try {
  19718. let channel = addons.getChannel(), createNewStoryResult = await experimental_requestResponse(channel, CREATE_NEW_STORYFILE_REQUEST, CREATE_NEW_STORYFILE_RESPONSE, {
  19719. componentExportName,
  19720. componentFilePath,
  19721. componentIsDefaultExport,
  19722. componentExportCount
  19723. });
  19724. setError(null);
  19725. let storyId = createNewStoryResult.storyId;
  19726. await trySelectStory(api.selectStory, storyId), handleSuccessfullyCreatedStory(componentExportName), handleFileSearch();
  19727. } catch (e2) {
  19728. switch (e2?.payload?.type) {
  19729. case "STORY_FILE_EXISTS":
  19730. let err = e2;
  19731. await trySelectStory(api.selectStory, err.payload.kind), handleStoryAlreadyExists();
  19732. break;
  19733. default:
  19734. setError({ selectedItemId, error: e2?.message });
  19735. break;
  19736. }
  19737. }
  19738. },
  19739. [api?.selectStory, handleSuccessfullyCreatedStory, handleFileSearch, handleStoryAlreadyExists]
  19740. );
  19741. useEffect(() => {
  19742. setError(null);
  19743. }, [fileSearchQueryDeferred]), useEffect(() => handleFileSearch(), [handleFileSearch]);
  19744. let executeGhostStoriesFlow = useCallback(async () => {
  19745. addons.getChannel().emit(GHOST_STORIES_REQUEST);
  19746. }, []);
  19747. return useEffect(() => {
  19748. open && isRendererReact && !hasRunGhostStoriesFlow.current && (hasRunGhostStoriesFlow.current = !0, executeGhostStoriesFlow());
  19749. }, [open, executeGhostStoriesFlow]), react_default.createElement(
  19750. FileSearchModal,
  19751. {
  19752. error,
  19753. fileSearchQuery,
  19754. fileSearchQueryDeferred,
  19755. onCreateNewStory: handleCreateNewStory,
  19756. isLoading,
  19757. onOpenChange,
  19758. open,
  19759. searchResults,
  19760. setError,
  19761. setFileSearchQuery
  19762. }
  19763. );
  19764. };
  19765. // src/manager/components/sidebar/Explorer.tsx
  19766. init_react();
  19767. // src/manager/components/sidebar/HighlightStyles.tsx
  19768. init_react();
  19769. var HighlightStyles = ({ refId, itemId }) => react_default.createElement(
  19770. Global,
  19771. {
  19772. styles: ({ color: color2 }) => {
  19773. let background2 = curriedTransparentize$1(0.85, color2.secondary);
  19774. return {
  19775. [`[data-ref-id="${refId}"][data-item-id="${itemId}"]:not([data-selected="true"])`]: {
  19776. '&[data-nodetype="component"], &[data-nodetype="group"]': {
  19777. background: background2,
  19778. "&:hover, &:focus": { background: background2 }
  19779. },
  19780. '&[data-nodetype="story"], &[data-nodetype="document"], &[data-nodetype="test"]': {
  19781. color: color2.defaultText,
  19782. background: background2,
  19783. "&:hover, &:focus": { background: background2 }
  19784. }
  19785. }
  19786. };
  19787. }
  19788. }
  19789. );
  19790. // src/manager/components/sidebar/Refs.tsx
  19791. init_react();
  19792. // src/shared/utils/story-index-filters.ts
  19793. var getActiveFilterCount = ({
  19794. includedTagFilters,
  19795. excludedTagFilters,
  19796. includedStatusFilters,
  19797. excludedStatusFilters
  19798. }) => (includedTagFilters?.length ?? 0) + (excludedTagFilters?.length ?? 0) + (includedStatusFilters?.length ?? 0) + (excludedStatusFilters?.length ?? 0);
  19799. // src/manager/utils/tree.ts
  19800. var import_memoizerific3 = __toESM(require_memoizerific(), 1);
  19801. var { document: document3, window: globalWindow } = scope, createId = (itemId, refId) => !refId || refId === DEFAULT_REF_ID ? itemId : `${refId}_${itemId}`, getLink = (item, refId) => `${document3.location.pathname}?path=/${item.type}/${createId(item.id, refId)}`;
  19802. var get = (0, import_memoizerific3.default)(1e3)((id, dataset) => dataset[id]), getParent = (0, import_memoizerific3.default)(1e3)((id, dataset) => {
  19803. let item = get(id, dataset);
  19804. return item && item.type !== "root" ? get(item.parent, dataset) : void 0;
  19805. }), getParents = (0, import_memoizerific3.default)(1e3)((id, dataset) => {
  19806. let parent = getParent(id, dataset);
  19807. return parent ? [parent, ...getParents(parent.id, dataset)] : [];
  19808. }), getAncestorIds2 = (0, import_memoizerific3.default)(1e3)(
  19809. (data, id) => getParents(id, data).map((item) => item.id)
  19810. ), getDescendantIds = (0, import_memoizerific3.default)(1e3)((data, id, skipLeafs) => {
  19811. let entry = data[id];
  19812. return !entry || !("children" in entry) || !entry.children ? [] : entry.children.reduce((acc, childId) => {
  19813. let child = data[childId];
  19814. return !child || skipLeafs && (child.type === "story" || child.type === "docs") || acc.push(childId, ...getDescendantIds(data, childId, skipLeafs)), acc;
  19815. }, []);
  19816. });
  19817. function getPath(item, ref) {
  19818. let parent = item.type !== "root" && item.parent ? ref.index[item.parent] : null;
  19819. return parent ? [...getPath(parent, ref), parent.name] : ref.id === DEFAULT_REF_ID ? [] : [ref.title || ref.id];
  19820. }
  19821. var searchItem = (item, ref) => ({ ...item, refId: ref.id, path: getPath(item, ref) });
  19822. function cycle2(array, index, delta) {
  19823. let next = index + delta % array.length;
  19824. return next < 0 && (next = array.length + next), next >= array.length && (next -= array.length), next;
  19825. }
  19826. var scrollIntoView = (element, center = !1) => {
  19827. if (!element)
  19828. return;
  19829. let { top, bottom } = element.getBoundingClientRect();
  19830. if (!top || !bottom)
  19831. return;
  19832. let bottomOffset = document3?.querySelector("#sidebar-bottom-wrapper")?.getBoundingClientRect().top || globalWindow.innerHeight || document3.documentElement.clientHeight;
  19833. bottom > bottomOffset && element.scrollIntoView({ block: center ? "center" : "nearest" });
  19834. }, getStateType = (isLoading, isAuthRequired, isError2, isEmpty) => {
  19835. switch (!0) {
  19836. case isAuthRequired:
  19837. return "auth";
  19838. case isError2:
  19839. return "error";
  19840. case isLoading:
  19841. return "loading";
  19842. case isEmpty:
  19843. return "empty";
  19844. default:
  19845. return "ready";
  19846. }
  19847. }, isAncestor = (element, maybeAncestor) => !element || !maybeAncestor ? !1 : element === maybeAncestor ? !0 : isAncestor(element.parentElement || void 0, maybeAncestor), removeNoiseFromName = (storyName) => storyName.replaceAll(/(\s|-|_)/gi, ""), isStoryHoistable = (storyName, componentName) => removeNoiseFromName(storyName) === removeNoiseFromName(componentName);
  19848. // src/manager/components/sidebar/RefBlocks.tsx
  19849. init_react();
  19850. // src/manager/components/sidebar/Loader.tsx
  19851. init_react();
  19852. var LOADER_SEQUENCE = [0, 0, 1, 1, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3], Loadingitem = styled.div(
  19853. {
  19854. cursor: "progress",
  19855. fontSize: 13,
  19856. height: "16px",
  19857. marginTop: 4,
  19858. marginBottom: 4,
  19859. alignItems: "center",
  19860. overflow: "hidden"
  19861. },
  19862. ({ depth = 0 }) => ({
  19863. marginLeft: depth * 15,
  19864. maxWidth: 85 - depth * 5
  19865. }),
  19866. ({ theme }) => theme.animation.inlineGlow,
  19867. ({ theme }) => ({
  19868. background: theme.appBorderColor
  19869. })
  19870. ), Contained = styled.div({
  19871. display: "flex",
  19872. flexDirection: "column",
  19873. paddingLeft: 20,
  19874. paddingRight: 20
  19875. }), Loader2 = ({ size }) => {
  19876. let repeats = Math.ceil(size / LOADER_SEQUENCE.length), sequence = Array.from(Array(repeats)).fill(LOADER_SEQUENCE).flat().slice(0, size);
  19877. return react_default.createElement(Fragment, null, sequence.map((depth, index) => react_default.createElement(Loadingitem, { depth, key: index })));
  19878. };
  19879. // src/manager/components/sidebar/NoResults.tsx
  19880. var NoResults2 = styled.div(({ theme }) => ({
  19881. display: "flex",
  19882. flexDirection: "column",
  19883. textAlign: "center",
  19884. textWrap: "balance",
  19885. gap: 4,
  19886. padding: "20px 0",
  19887. lineHeight: "18px",
  19888. fontSize: `${theme.typography.size.s2}px`,
  19889. color: theme.color.defaultText,
  19890. small: {
  19891. color: theme.textMutedColor,
  19892. fontSize: `${theme.typography.size.s1}px`
  19893. },
  19894. button: {
  19895. marginTop: 8,
  19896. alignSelf: "center"
  19897. }
  19898. }));
  19899. // src/manager/components/sidebar/RefBlocks.tsx
  19900. var { window: globalWindow2 } = scope, TextStyle = styled.div(({ theme }) => ({
  19901. fontSize: theme.typography.size.s2,
  19902. lineHeight: "20px",
  19903. margin: 0
  19904. })), Text3 = styled.div(({ theme }) => ({
  19905. fontSize: theme.typography.size.s2,
  19906. lineHeight: "20px",
  19907. margin: 0,
  19908. code: {
  19909. fontSize: theme.typography.size.s1
  19910. },
  19911. ul: {
  19912. paddingLeft: 20,
  19913. marginTop: 8,
  19914. marginBottom: 8
  19915. }
  19916. })), ErrorDisplay = styled.pre(
  19917. {
  19918. boxSizing: "border-box",
  19919. borderRadius: 8,
  19920. overflow: "auto",
  19921. whiteSpace: "pre"
  19922. },
  19923. ({ isMobile: isMobile2 }) => isMobile2 ? {
  19924. maxWidth: "calc(100vw - 40px)"
  19925. } : {
  19926. minWidth: 420,
  19927. maxWidth: 640
  19928. },
  19929. ({ theme }) => ({
  19930. color: theme.color.dark
  19931. })
  19932. ), AuthBlock = ({ loginUrl, id }) => {
  19933. let [isAuthAttempted, setAuthAttempted] = useState(!1), refresh = useCallback(() => {
  19934. globalWindow2.document.location.reload();
  19935. }, []), open = useCallback((e2) => {
  19936. e2.preventDefault();
  19937. let childWindow = globalWindow2.open(loginUrl, `storybook_auth_${id}`, "resizable,scrollbars"), timer = setInterval(() => {
  19938. childWindow ? childWindow.closed && (clearInterval(timer), setAuthAttempted(!0)) : (logger.error("unable to access loginUrl window"), clearInterval(timer));
  19939. }, 1e3);
  19940. }, []);
  19941. return react_default.createElement(Contained, null, react_default.createElement(Spaced, null, isAuthAttempted ? react_default.createElement(Fragment, null, react_default.createElement(Text3, null, "Authentication on ", react_default.createElement("strong", null, loginUrl), " concluded. Refresh the page to fetch this Storybook."), react_default.createElement("div", null, react_default.createElement(Button, { ariaLabel: !1, size: "small", variant: "outline", onClick: refresh }, react_default.createElement(SyncIcon, null), "Refresh now"))) : react_default.createElement(Fragment, null, react_default.createElement(Text3, null, "Sign in to browse this Storybook."), react_default.createElement("div", null, react_default.createElement(Button, { size: "small", variant: "outline", onClick: open }, react_default.createElement(LockIcon, null), "Sign in")))));
  19942. }, ErrorBlock = ({ error }) => {
  19943. let { isMobile: isMobile2 } = useLayout();
  19944. return react_default.createElement(Contained, null, react_default.createElement(Spaced, null, react_default.createElement(TextStyle, null, "Oh no! Something went wrong loading this Storybook.", react_default.createElement("br", null), react_default.createElement(
  19945. PopoverProvider,
  19946. {
  19947. ariaLabel: "Error details",
  19948. hasCloseButton: !0,
  19949. offset: isMobile2 ? 0 : 8,
  19950. placement: isMobile2 ? "bottom-end" : "bottom-start",
  19951. popover: react_default.createElement(ErrorDisplay, { isMobile: isMobile2 }, react_default.createElement(ErrorFormatter, { error }))
  19952. },
  19953. react_default.createElement(Link, null, "View error ", react_default.createElement(ChevronDownIcon, null))
  19954. ), " ", react_default.createElement(Link, { href: "https://storybook.js.org/docs?ref=ui", cancel: !1, target: "_blank" }, "View docs"))));
  19955. }, FlexSpaced = styled(Spaced)({
  19956. display: "flex"
  19957. }), WideSpaced = styled(Spaced)({
  19958. flex: 1
  19959. }), EmptyBlock = ({
  19960. isMain,
  19961. hasEntries,
  19962. activeFilterCount
  19963. }) => {
  19964. let api = useStorybookApi();
  19965. return react_default.createElement(Contained, null, react_default.createElement(FlexSpaced, { col: 1 }, react_default.createElement(WideSpaced, null, hasEntries ? react_default.createElement(NoResults2, null, react_default.createElement("strong", null, "No stories found"), activeFilterCount > 0 ? react_default.createElement("small", null, "Your selected filters did not match any stories.") : react_default.createElement("small", null, "Try adding some stories!"), activeFilterCount > 0 ? react_default.createElement(
  19966. Button,
  19967. {
  19968. ariaLabel: !1,
  19969. size: "small",
  19970. variant: "outline",
  19971. onClick: async () => {
  19972. await api.setAllTagFilters([], []), await api.resetStatusFilters();
  19973. }
  19974. },
  19975. react_default.createElement(SweepIcon, null),
  19976. "Clear filters"
  19977. ) : null) : isMain ? react_default.createElement(Text3, null, "Oh no! Your Storybook is empty. This can happen when:", react_default.createElement("ul", null, react_default.createElement("li", null, "Your", " ", react_default.createElement(
  19978. Link,
  19979. {
  19980. href: "https://storybook.js.org/docs/api/main-config/main-config-stories?ref=ui",
  19981. cancel: !1,
  19982. target: "_blank"
  19983. },
  19984. "stories glob configuration"
  19985. ), " ", "does not match any files.", " "), react_default.createElement("li", null, "You have", " ", react_default.createElement(
  19986. Link,
  19987. {
  19988. href: "https://storybook.js.org/docs/writing-stories?ref=ui",
  19989. cancel: !1,
  19990. target: "_blank"
  19991. },
  19992. "no stories defined"
  19993. ), " ", "in your story files.", " "))) : react_default.createElement(Text3, null, "This composed Storybook is empty. Perhaps no stories match your selected filters."))));
  19994. }, LoaderBlock = ({ isMain }) => react_default.createElement(Contained, null, react_default.createElement(Loader2, { size: isMain ? 17 : 5 }));
  19995. // src/manager/components/sidebar/RefIndicator.tsx
  19996. init_react();
  19997. var { document: document4, window: globalWindow3 } = scope, IndicatorPlacement = styled.div(({ theme }) => ({
  19998. height: 16,
  19999. display: "flex",
  20000. alignItems: "center",
  20001. "& > * + *": {
  20002. marginLeft: theme.layoutMargin
  20003. }
  20004. })), IndicatorClickTarget = styled(Button)(({ theme }) => ({
  20005. color: theme.textMutedColor,
  20006. svg: {
  20007. height: 14,
  20008. width: 14,
  20009. padding: 2,
  20010. transition: "all 150ms ease-out",
  20011. color: "inherit"
  20012. }
  20013. })), MessageTitle = styled.span(({ theme }) => ({
  20014. fontWeight: theme.typography.weight.bold
  20015. })), StyledMessage = styled.a(({ theme }) => ({
  20016. textDecoration: "none",
  20017. lineHeight: "16px",
  20018. padding: 15,
  20019. display: "flex",
  20020. flexDirection: "row",
  20021. alignItems: "flex-start",
  20022. color: theme.color.defaultText,
  20023. "&:not(:last-child)": {
  20024. borderBottom: `1px solid ${theme.appBorderColor}`
  20025. },
  20026. "&:hover": {
  20027. background: theme.background.hoverable,
  20028. color: theme.color.defaultText
  20029. },
  20030. "&:link, &:active, &:focus": {
  20031. color: theme.color.defaultText
  20032. },
  20033. "&:focus-visible": {
  20034. background: theme.background.hoverable,
  20035. borderRadius: 8,
  20036. boxShadow: `inset 0 0 0 2px ${theme.color.secondary}`,
  20037. outline: "none"
  20038. },
  20039. "& > *": {
  20040. flex: 1
  20041. },
  20042. "& > svg": {
  20043. marginTop: 3,
  20044. width: 16,
  20045. height: 16,
  20046. marginRight: 10,
  20047. flex: "unset"
  20048. }
  20049. })), Message = ({ href, blank = !0, children, onClick }) => react_default.createElement(StyledMessage, { href, target: blank ? "_blank" : void 0, onClick }, children), MessageWrapper = styled.div(
  20050. ({ isMobile: isMobile2 }) => ({
  20051. width: isMobile2 ? "calc(100vw - 20px)" : 280,
  20052. boxSizing: "border-box",
  20053. borderRadius: 8,
  20054. overflow: "hidden"
  20055. }),
  20056. ({ theme }) => ({
  20057. color: theme.color.dark
  20058. })
  20059. ), SubtleSelect = styled(Select)(({ theme }) => ({
  20060. background: "transparent",
  20061. color: theme.color.defaultText,
  20062. fontSize: theme.typography.size.s1,
  20063. fontWeight: theme.typography.weight.regular
  20064. })), RefIndicator = react_default.memo(
  20065. forwardRef(
  20066. ({ state, ...ref }, forwardedRef) => {
  20067. let api = useStorybookApi(), { isMobile: isMobile2 } = useLayout(), list = useMemo(() => Object.values(ref.index || {}), [ref.index]), componentCount = useMemo(
  20068. () => list.filter((v2) => v2.type === "component").length,
  20069. [list]
  20070. ), leafCount = useMemo(
  20071. () => list.filter((v2) => v2.type === "docs" || v2.type === "story").length,
  20072. [list]
  20073. ), currentVersion = useMemo(() => {
  20074. if (ref.versions)
  20075. return Object.entries(ref.versions).find(([, v2]) => v2 === ref.url)?.[0];
  20076. }, [ref.versions, ref.url]);
  20077. return react_default.createElement(IndicatorPlacement, { ref: forwardedRef }, react_default.createElement(
  20078. PopoverProvider,
  20079. {
  20080. ariaLabel: "Composed Storybook status",
  20081. placement: isMobile2 ? "bottom" : "bottom-start",
  20082. padding: 0,
  20083. popover: () => react_default.createElement(MessageWrapper, { isMobile: isMobile2 }, react_default.createElement(Spaced, { row: 0 }, state === "loading" && react_default.createElement(LoadingMessage, { url: ref.url }), (state === "error" || state === "empty") && react_default.createElement(ErrorOccurredMessage, { url: ref.url }), state === "ready" && react_default.createElement(react_default.Fragment, null, react_default.createElement(ReadyMessage, { url: ref.url, componentCount, leafCount }), ref.sourceUrl && react_default.createElement(SourceCodeMessage, { url: ref.sourceUrl })), state === "auth" && react_default.createElement(LoginRequiredMessage, { ...ref }), ref.type === "auto-inject" && state !== "error" && react_default.createElement(PerformanceDegradedMessage, null), state !== "loading" && react_default.createElement(ReadDocsMessage, null)))
  20084. },
  20085. react_default.createElement(
  20086. IndicatorClickTarget,
  20087. {
  20088. variant: "ghost",
  20089. padding: "small",
  20090. size: "small",
  20091. "data-action": "toggle-indicator",
  20092. ariaLabel: "Extra actions"
  20093. },
  20094. react_default.createElement(GlobeIcon, null)
  20095. )
  20096. ), ref.versions && Object.keys(ref.versions).length ? react_default.createElement(react_default.Fragment, null, react_default.createElement(
  20097. SubtleSelect,
  20098. {
  20099. padding: "small",
  20100. size: "small",
  20101. ariaLabel: "Version",
  20102. tooltip: "Choose version",
  20103. defaultOptions: currentVersion,
  20104. onSelect: (item) => {
  20105. let href = ref.versions?.[item];
  20106. href && api.changeRefVersion(ref.id, href);
  20107. },
  20108. options: Object.entries(ref.versions).map(([id, href]) => ({
  20109. value: id,
  20110. title: id,
  20111. href
  20112. }))
  20113. },
  20114. "version"
  20115. )) : null);
  20116. }
  20117. )
  20118. ), ReadyMessage = ({ url, componentCount, leafCount }) => {
  20119. let theme = useTheme();
  20120. return react_default.createElement(Message, { href: url.replace(/\/?$/, "/index.html") }, react_default.createElement(GlobeIcon, { color: theme.color.secondary }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "View external Storybook"), react_default.createElement("div", null, "Explore ", componentCount, " components and ", leafCount, " stories in a new browser tab.")));
  20121. }, SourceCodeMessage = ({ url }) => {
  20122. let theme = useTheme();
  20123. return react_default.createElement(Message, { href: url }, react_default.createElement(MarkupIcon, { color: theme.color.secondary }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "View source code")));
  20124. }, LoginRequiredMessage = ({ loginUrl, id }) => {
  20125. let theme = useTheme(), open = useCallback(
  20126. (e2) => {
  20127. e2.preventDefault();
  20128. let childWindow = globalWindow3.open(
  20129. loginUrl,
  20130. `storybook_auth_${id}`,
  20131. "resizable,scrollbars"
  20132. ), timer = setInterval(() => {
  20133. childWindow ? childWindow.closed && (clearInterval(timer), document4.location.reload()) : clearInterval(timer);
  20134. }, 1e3);
  20135. },
  20136. [id, loginUrl]
  20137. );
  20138. return react_default.createElement(Message, { onClick: open, blank: !1 }, react_default.createElement(LockIcon, { color: theme.color.gold }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "Log in required"), react_default.createElement("div", null, "You need to authenticate to view this Storybook's components.")));
  20139. }, ReadDocsMessage = () => {
  20140. let theme = useTheme();
  20141. return react_default.createElement(Message, { href: "https://storybook.js.org/docs/sharing/storybook-composition?ref=ui" }, react_default.createElement(DocumentIcon, { color: theme.color.green }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "Read Composition docs"), react_default.createElement("div", null, "Learn how to combine multiple Storybooks into one.")));
  20142. }, ErrorOccurredMessage = ({ url }) => {
  20143. let theme = useTheme();
  20144. return react_default.createElement(Message, { href: url.replace(/\/?$/, "/index.html") }, react_default.createElement(AlertIcon, { color: theme.color.negative }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "Something went wrong"), react_default.createElement("div", null, "This external Storybook didn't load. Debug it in a new tab now.")));
  20145. }, LoadingMessage = ({ url }) => {
  20146. let theme = useTheme();
  20147. return react_default.createElement(Message, { href: url.replace(/\/?$/, "/index.html") }, react_default.createElement(TimeIcon, { color: theme.color.secondary }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "Please wait"), react_default.createElement("div", null, "This Storybook is loading.")));
  20148. }, PerformanceDegradedMessage = () => {
  20149. let theme = useTheme();
  20150. return react_default.createElement(Message, { href: "https://storybook.js.org/docs/sharing/storybook-composition?ref=ui" }, react_default.createElement(LightningIcon, { color: theme.color.gold }), react_default.createElement("div", null, react_default.createElement(MessageTitle, null, "Reduce lag"), react_default.createElement("div", null, "Learn how to speed up Composition performance.")));
  20151. };
  20152. // src/manager/components/sidebar/Tree.tsx
  20153. init_react();
  20154. // src/manager/utils/status.tsx
  20155. init_react();
  20156. var import_memoizerific4 = __toESM(require_memoizerific(), 1);
  20157. // src/manager/components/sidebar/IconSymbols.tsx
  20158. init_react();
  20159. var Svg2 = styled.svg`
  20160. position: absolute;
  20161. width: 0;
  20162. height: 0;
  20163. display: inline-block;
  20164. shape-rendering: inherit;
  20165. vertical-align: middle;
  20166. `, GROUP_ID = "icon--group", COMPONENT_ID = "icon--component", DOCUMENT_ID = "icon--document", STORY_ID = "icon--story", TEST_ID = "icon--test", SUCCESS_ID = "icon--success", ERROR_ID = "icon--error", WARNING_ID = "icon--warning", DOT_ID = "icon--dot", NEW_ID = "icon--new", MODIFIED_ID = "icon--modified", AFFECTED_ID = "icon--affected", IconSymbols = () => react_default.createElement(Svg2, { "data-chromatic": "ignore" }, react_default.createElement("symbol", { id: GROUP_ID }, react_default.createElement(
  20167. "path",
  20168. {
  20169. fillRule: "evenodd",
  20170. clipRule: "evenodd",
  20171. d: "M6.586 3.504l-1.5-1.5H1v9h12v-7.5H6.586zm.414-1L5.793 1.297a1 1 0 00-.707-.293H.5a.5.5 0 00-.5.5v10a.5.5 0 00.5.5h13a.5.5 0 00.5-.5v-8.5a.5.5 0 00-.5-.5H7z",
  20172. fill: "currentColor"
  20173. }
  20174. )), react_default.createElement("symbol", { id: COMPONENT_ID }, react_default.createElement(
  20175. "path",
  20176. {
  20177. fillRule: "evenodd",
  20178. clipRule: "evenodd",
  20179. d: "M3.5 1.004a2.5 2.5 0 00-2.5 2.5v7a2.5 2.5 0 002.5 2.5h7a2.5 2.5 0 002.5-2.5v-7a2.5 2.5 0 00-2.5-2.5h-7zm8.5 5.5H7.5v-4.5h3a1.5 1.5 0 011.5 1.5v3zm0 1v3a1.5 1.5 0 01-1.5 1.5h-3v-4.5H12zm-5.5 4.5v-4.5H2v3a1.5 1.5 0 001.5 1.5h3zM2 6.504h4.5v-4.5h-3a1.5 1.5 0 00-1.5 1.5v3z",
  20180. fill: "currentColor"
  20181. }
  20182. )), react_default.createElement("symbol", { id: DOCUMENT_ID }, react_default.createElement(
  20183. "path",
  20184. {
  20185. d: "M4 5.5a.5.5 0 01.5-.5h5a.5.5 0 010 1h-5a.5.5 0 01-.5-.5zM4.5 7.5a.5.5 0 000 1h5a.5.5 0 000-1h-5zM4 10.5a.5.5 0 01.5-.5h5a.5.5 0 010 1h-5a.5.5 0 01-.5-.5z",
  20186. fill: "currentColor"
  20187. }
  20188. ), react_default.createElement(
  20189. "path",
  20190. {
  20191. fillRule: "evenodd",
  20192. clipRule: "evenodd",
  20193. d: "M1.5 0a.5.5 0 00-.5.5v13a.5.5 0 00.5.5h11a.5.5 0 00.5-.5V3.207a.5.5 0 00-.146-.353L10.146.146A.5.5 0 009.793 0H1.5zM2 1h7.5v2a.5.5 0 00.5.5h2V13H2V1z",
  20194. fill: "currentColor"
  20195. }
  20196. )), react_default.createElement("symbol", { id: STORY_ID }, react_default.createElement(
  20197. "path",
  20198. {
  20199. fillRule: "evenodd",
  20200. clipRule: "evenodd",
  20201. d: "M3.5 0h7a.5.5 0 01.5.5v13a.5.5 0 01-.454.498.462.462 0 01-.371-.118L7 11.159l-3.175 2.72a.46.46 0 01-.379.118A.5.5 0 013 13.5V.5a.5.5 0 01.5-.5zM4 12.413l2.664-2.284a.454.454 0 01.377-.128.498.498 0 01.284.12L10 12.412V1H4v11.413z",
  20202. fill: "currentColor"
  20203. }
  20204. )), react_default.createElement("symbol", { id: TEST_ID }, react_default.createElement(
  20205. "path",
  20206. {
  20207. fillRule: "evenodd",
  20208. clipRule: "evenodd",
  20209. d: "M4.5 2h.75v3.866l-3.034 5.26A1.25 1.25 0 003.299 13H10.7a1.25 1.25 0 001.083-1.875L8.75 5.866V2h.75a.5.5 0 100-1h-5a.5.5 0 000 1zm1.75 4V2h1.5v4.134l.067.116L8.827 8H5.173l1.01-1.75.067-.116V6zM4.597 9l-1.515 2.625A.25.25 0 003.3 12H10.7a.25.25 0 00.217-.375L9.404 9H4.597z",
  20210. fill: "currentColor"
  20211. }
  20212. )), react_default.createElement("symbol", { id: SUCCESS_ID }, react_default.createElement(
  20213. "path",
  20214. {
  20215. fillRule: "evenodd",
  20216. clipRule: "evenodd",
  20217. d: "M10.854 4.146a.5.5 0 010 .708l-5 5a.5.5 0 01-.708 0l-2-2a.5.5 0 11.708-.708L5.5 8.793l4.646-4.647a.5.5 0 01.708 0z",
  20218. fill: "currentColor"
  20219. }
  20220. )), react_default.createElement("symbol", { id: ERROR_ID }, react_default.createElement(
  20221. "path",
  20222. {
  20223. fillRule: "evenodd",
  20224. clipRule: "evenodd",
  20225. d: "M7 4a3 3 0 100 6 3 3 0 000-6zM3 7a4 4 0 118 0 4 4 0 01-8 0z",
  20226. fill: "currentColor"
  20227. }
  20228. )), react_default.createElement("symbol", { id: WARNING_ID }, react_default.createElement(
  20229. "path",
  20230. {
  20231. fillRule: "evenodd",
  20232. clipRule: "evenodd",
  20233. d: "M7.206 3.044a.498.498 0 01.23.212l3.492 5.985a.494.494 0 01.006.507.497.497 0 01-.443.252H3.51a.499.499 0 01-.437-.76l3.492-5.984a.497.497 0 01.642-.212zM7 4.492L4.37 9h5.26L7 4.492z",
  20234. fill: "currentColor"
  20235. }
  20236. )), react_default.createElement("symbol", { id: DOT_ID }, react_default.createElement("circle", { cx: "3", cy: "3", r: "3", fill: "currentColor" })), react_default.createElement("symbol", { id: NEW_ID }, react_default.createElement(
  20237. "path",
  20238. {
  20239. d: "M7 3.5L6.96971 3.68173C6.68873 5.36762 5.36762 6.68873 3.68173 6.96971L3.5 7",
  20240. stroke: "currentColor",
  20241. strokeLinecap: "round",
  20242. fill: "none"
  20243. }
  20244. ), react_default.createElement(
  20245. "path",
  20246. {
  20247. d: "M7 3.5L7.03029 3.68173C7.31127 5.36762 8.63238 6.68873 10.3183 6.96971L10.5 7",
  20248. stroke: "currentColor",
  20249. strokeLinecap: "round",
  20250. fill: "none"
  20251. }
  20252. ), react_default.createElement(
  20253. "path",
  20254. {
  20255. d: "M7 10.5L6.96971 10.3183C6.68873 8.63238 5.36762 7.31127 3.68173 7.03029L3.5 7",
  20256. stroke: "currentColor",
  20257. strokeLinecap: "round",
  20258. fill: "none"
  20259. }
  20260. ), react_default.createElement(
  20261. "path",
  20262. {
  20263. d: "M7 10.5L7.03029 10.3183C7.31127 8.63238 8.63238 7.31127 10.3183 7.03029L10.5 7",
  20264. stroke: "currentColor",
  20265. strokeLinecap: "round",
  20266. fill: "none"
  20267. }
  20268. ), react_default.createElement("path", { d: "M7 4.5L4.5 7L7 9.5L9.5 7L7 4.5Z", fill: "currentColor" })), react_default.createElement("symbol", { id: MODIFIED_ID }, react_default.createElement("circle", { cx: "7", cy: "7", r: "3", fill: "currentColor" })), react_default.createElement("symbol", { id: AFFECTED_ID }, react_default.createElement("circle", { cx: "7", cy: "7", r: "3", fill: "currentColor" }))), UseSymbol = ({ type }) => type === "group" ? react_default.createElement("use", { xlinkHref: `#${GROUP_ID}` }) : type === "component" ? react_default.createElement("use", { xlinkHref: `#${COMPONENT_ID}` }) : type === "document" ? react_default.createElement("use", { xlinkHref: `#${DOCUMENT_ID}` }) : type === "story" ? react_default.createElement("use", { xlinkHref: `#${STORY_ID}` }) : type === "test" ? react_default.createElement("use", { xlinkHref: `#${TEST_ID}` }) : type === "success" ? react_default.createElement("use", { xlinkHref: `#${SUCCESS_ID}` }) : type === "error" ? react_default.createElement("use", { xlinkHref: `#${ERROR_ID}` }) : type === "warning" ? react_default.createElement("use", { xlinkHref: `#${WARNING_ID}` }) : type === "dot" ? react_default.createElement("use", { xlinkHref: `#${DOT_ID}` }) : type === "new" ? react_default.createElement("use", { xlinkHref: `#${NEW_ID}` }) : type === "modified" ? react_default.createElement("use", { xlinkHref: `#${MODIFIED_ID}` }) : type === "affected" ? react_default.createElement("use", { xlinkHref: `#${AFFECTED_ID}` }) : null;
  20269. // src/manager/utils/status.tsx
  20270. var SmallIcons = styled(CircleIcon)({
  20271. // specificity hack
  20272. "&&&": {
  20273. width: 6,
  20274. height: 6
  20275. }
  20276. }), LoadingIcons = styled(SmallIcons)(({ theme: { animation } }) => ({
  20277. // specificity hack
  20278. animation: `${animation.glow} 1.5s ease-in-out infinite`
  20279. })), statusPriority = [
  20280. "status-value:unknown",
  20281. "status-value:pending",
  20282. "status-value:success",
  20283. "status-value:affected",
  20284. "status-value:modified",
  20285. "status-value:new",
  20286. "status-value:warning",
  20287. "status-value:error"
  20288. ], getStatus = (0, import_memoizerific4.default)(10)((theme, status) => {
  20289. let defaultIconColor = theme.base === "light" ? curriedTransparentize$1(0.3, theme.color.defaultText) : curriedTransparentize$1(0.6, theme.color.defaultText);
  20290. return {
  20291. "status-value:unknown": {
  20292. icon: null,
  20293. iconColor: defaultIconColor,
  20294. textColor: null
  20295. },
  20296. "status-value:pending": {
  20297. icon: react_default.createElement(LoadingIcons, { key: "icon" }),
  20298. iconColor: defaultIconColor,
  20299. textColor: "currentColor"
  20300. },
  20301. "status-value:success": {
  20302. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "success" })),
  20303. iconColor: theme.color.positive,
  20304. textColor: "currentColor"
  20305. },
  20306. "status-value:new": {
  20307. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "new" })),
  20308. iconColor: theme.fgColor.accent,
  20309. textColor: null
  20310. },
  20311. "status-value:modified": {
  20312. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "modified" })),
  20313. iconColor: theme.fgColor.accent,
  20314. textColor: null
  20315. },
  20316. "status-value:affected": {
  20317. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "affected" })),
  20318. iconColor: theme.fgColor.accent,
  20319. textColor: null
  20320. },
  20321. "status-value:warning": {
  20322. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "warning" })),
  20323. iconColor: theme.color.warning,
  20324. textColor: theme.fgColor.warning
  20325. },
  20326. "status-value:error": {
  20327. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "error" })),
  20328. iconColor: theme.color.negative,
  20329. textColor: theme.fgColor.negative
  20330. }
  20331. }[status];
  20332. });
  20333. function getChangeDetectionStatus(statuses) {
  20334. let changeValues = Object.values(statuses).filter((status) => status.typeId === CHANGE_DETECTION_STATUS_TYPE_ID).map((status) => status.value), testValues = Object.values(statuses).filter((status) => status.typeId !== CHANGE_DETECTION_STATUS_TYPE_ID).map((status) => status.value);
  20335. return {
  20336. changeStatus: getMostCriticalStatusValue(changeValues),
  20337. testStatus: getMostCriticalStatusValue(testValues)
  20338. };
  20339. }
  20340. var getMostCriticalStatusValue = (statusValues) => statusPriority.reduce(
  20341. (acc, value) => statusValues.includes(value) ? value : acc,
  20342. "status-value:unknown"
  20343. );
  20344. function getGroupStatus(collapsedData, allStatuses) {
  20345. return Object.values(collapsedData).reduce((acc, item) => {
  20346. if (item.type === "group" || item.type === "component" || item.type === "story") {
  20347. let leafs = getDescendantIds(collapsedData, item.id, !1).map((id) => collapsedData[id]).filter((i2) => i2.type === "story"), combinedStatus = getMostCriticalStatusValue(
  20348. // @ts-expect-error (non strict)
  20349. leafs.flatMap((story) => Object.values(allStatuses[story.id] || {})).map((s2) => s2.value)
  20350. );
  20351. combinedStatus && (acc[item.id] = combinedStatus);
  20352. }
  20353. return acc;
  20354. }, {});
  20355. }
  20356. function getGroupDualStatus(collapsedData, allStatuses) {
  20357. return Object.values(collapsedData).reduce((acc, item) => {
  20358. if (item.type === "group" || item.type === "component" || item.type === "story") {
  20359. let allDescendantStatuses = getDescendantIds(collapsedData, item.id, !1).map((id) => collapsedData[id]).filter((i2) => i2.type === "story").flatMap(
  20360. (story) => Object.values(allStatuses[story.id] || {})
  20361. ), changeValues = allDescendantStatuses.filter((s2) => s2.typeId === CHANGE_DETECTION_STATUS_TYPE_ID).map((s2) => s2.value), testValues = allDescendantStatuses.filter((s2) => s2.typeId !== CHANGE_DETECTION_STATUS_TYPE_ID).map((s2) => s2.value);
  20362. acc[item.id] = {
  20363. change: getMostCriticalStatusValue(changeValues),
  20364. test: getMostCriticalStatusValue(testValues)
  20365. };
  20366. }
  20367. return acc;
  20368. }, {});
  20369. }
  20370. // src/manager/components/sidebar/ContextMenu.tsx
  20371. init_react();
  20372. // src/manager/components/sidebar/StatusButton.tsx
  20373. init_react();
  20374. var withStatusColor = ({ theme, status }) => ({
  20375. color: getStatus(theme, status).iconColor ?? void 0
  20376. }), StatusLabel = styled.div(withStatusColor, {
  20377. margin: 3
  20378. }), StyledButton = styled(Button)(
  20379. withStatusColor,
  20380. ({ theme, height, width }) => ({
  20381. transition: "none",
  20382. display: "inline-flex",
  20383. alignItems: "center",
  20384. justifyContent: "center",
  20385. width: width || 28,
  20386. height: height || 28,
  20387. "&:hover": {
  20388. color: theme.color.secondary,
  20389. background: theme.base === "dark" ? curriedDarken$1(0.3, theme.color.secondary) : curriedLighten$1(0.4, theme.color.secondary)
  20390. },
  20391. '[data-selected="true"] &': {
  20392. background: theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary,
  20393. boxShadow: `0 0 5px 5px ${theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary}`,
  20394. "&:hover": {
  20395. background: theme.base === "dark" ? curriedDarken$1(0.1, theme.color.secondary) : theme.color.secondary
  20396. }
  20397. },
  20398. "&:focus": {
  20399. color: theme.color.secondary,
  20400. borderColor: theme.color.secondary,
  20401. outlineOffset: -2,
  20402. "&:not(:focus-visible)": {
  20403. borderColor: "transparent"
  20404. }
  20405. }
  20406. }),
  20407. ({ theme, selectedItem }) => selectedItem && {
  20408. "&:hover": {
  20409. boxShadow: `inset 0 0 0 2px ${theme.color.secondary}`,
  20410. background: "rgba(255, 255, 255, 0.2)"
  20411. }
  20412. }
  20413. ), StatusButton = forwardRef((props, ref) => react_default.createElement(StyledButton, { variant: "ghost", padding: "small", ...props, ref }));
  20414. StatusButton.displayName = "StatusButton";
  20415. // src/manager/components/sidebar/StatusContext.tsx
  20416. init_react();
  20417. var StatusContext = createContext({});
  20418. // src/manager/components/sidebar/ContextMenu.tsx
  20419. var empty = {
  20420. onMouseEnter: () => {
  20421. },
  20422. node: null
  20423. }, FloatingStatusButton = styled(StatusButton)({
  20424. background: "var(--tree-node-background-hover)",
  20425. boxShadow: "0 0 5px 5px var(--tree-node-background-hover)",
  20426. position: "absolute",
  20427. right: 0,
  20428. zIndex: 1,
  20429. "&:focus-visible": {
  20430. outlineOffset: -2
  20431. }
  20432. }), useContextMenu = (context, links, api) => {
  20433. let [hoverCount, setHoverCount] = useState(0), [isOpen, setIsOpen] = useState(!1), { allStatuses, groupStatus } = useContext(StatusContext), exportName = context && "exportName" in context ? context.exportName ?? "" : "", { children: copyText, buttonProps: copyButtonProps } = useCopyButton({
  20434. children: "Copy story name",
  20435. content: exportName
  20436. }), shortcutKeys = api.getShortcutKeys(), enableShortcuts = !!shortcutKeys, topLinks = useMemo(() => {
  20437. let defaultLinks = [];
  20438. return context && "importPath" in context && context.importPath && defaultLinks.push({
  20439. id: "open-in-editor",
  20440. title: "Open in editor",
  20441. icon: react_default.createElement(EditorIcon, null),
  20442. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.openInEditor }) : null,
  20443. onClick: (e2) => {
  20444. context.importPath && (e2.preventDefault(), api.openInEditor({ file: context.importPath }));
  20445. }
  20446. }), context.type === "story" && defaultLinks.push({
  20447. id: "copy-story-name",
  20448. title: copyText,
  20449. icon: react_default.createElement(CopyIcon, null),
  20450. // TODO: bring this back once we want to add shortcuts for this
  20451. // right:
  20452. // enableShortcuts && shortcutKeys.copyStoryName ? (
  20453. // <Shortcut keys={shortcutKeys.copyStoryName} />
  20454. // ) : null,
  20455. onClick: (e2) => {
  20456. e2.preventDefault(), copyButtonProps.onClick(e2);
  20457. }
  20458. }), defaultLinks;
  20459. }, [api, context, copyText, copyButtonProps, enableShortcuts, shortcutKeys]), handlers = useMemo(() => ({
  20460. onMouseEnter: () => {
  20461. setHoverCount((c2) => c2 + 1);
  20462. },
  20463. onOpen: (event) => {
  20464. event.stopPropagation(), setIsOpen(!0);
  20465. },
  20466. onClose: () => {
  20467. setIsOpen(!1);
  20468. }
  20469. }), []), providerLinks = useMemo(() => {
  20470. let registeredTestProviders = api.getElements(Addon_TypesEnum.experimental_TEST_PROVIDER);
  20471. return hoverCount ? generateTestProviderLinks(registeredTestProviders, context) : [];
  20472. }, [api, context, hoverCount]), shouldRender = !context.refId && (providerLinks.length > 0 || links.length > 0 || topLinks.length > 0), isLeafNode = context.type === "story" || context.type === "docs", itemStatus = useMemo(() => {
  20473. let status = "status-value:unknown";
  20474. if (!context)
  20475. return status;
  20476. if (isLeafNode) {
  20477. let values = Object.values(allStatuses?.[context.id] || {}).map((s2) => s2.value);
  20478. status = getMostCriticalStatusValue(values);
  20479. }
  20480. if (!isLeafNode) {
  20481. let groupValue = groupStatus && groupStatus[context.id];
  20482. status = groupValue === "status-value:success" || groupValue === void 0 ? "status-value:unknown" : groupValue;
  20483. }
  20484. return status;
  20485. }, [allStatuses, groupStatus, context, isLeafNode]), MenuIcon2 = useMemo(() => context.type !== "story" && context.type !== "docs" ? itemStatus !== "status-value:success" && itemStatus !== "status-value:unknown" ? react_default.createElement("svg", { key: "icon", viewBox: "0 0 6 6", width: "6", height: "6" }, react_default.createElement(UseSymbol, { type: "dot" })) : react_default.createElement(EllipsisIcon, null) : itemStatus === "status-value:error" ? react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "error" })) : itemStatus === "status-value:warning" ? react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "warning" })) : itemStatus === "status-value:success" ? react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "success" })) : react_default.createElement(EllipsisIcon, null), [itemStatus, context.type]);
  20486. return useMemo(() => globalThis.CONFIG_TYPE !== "DEVELOPMENT" ? empty : {
  20487. onMouseEnter: handlers.onMouseEnter,
  20488. node: shouldRender ? react_default.createElement(
  20489. PopoverProvider,
  20490. {
  20491. ariaLabel: "Context menu",
  20492. placement: "bottom-end",
  20493. defaultVisible: !1,
  20494. visible: isOpen,
  20495. onVisibleChange: setIsOpen,
  20496. popover: react_default.createElement(LiveContextMenu, { context, links: [...topLinks, ...links] }),
  20497. hasChrome: !0,
  20498. padding: 0
  20499. },
  20500. react_default.createElement(
  20501. FloatingStatusButton,
  20502. {
  20503. "data-displayed": isOpen ? "on" : "off",
  20504. "data-testid": "context-menu",
  20505. ariaLabel: "Open context menu",
  20506. type: "button",
  20507. status: itemStatus,
  20508. onClick: handlers.onOpen
  20509. },
  20510. MenuIcon2
  20511. )
  20512. ) : null
  20513. }, [context, handlers, isOpen, shouldRender, links, topLinks, itemStatus, MenuIcon2]);
  20514. }, LiveContextMenu = ({
  20515. context,
  20516. links,
  20517. ...rest2
  20518. }) => {
  20519. let registeredTestProviders = useStorybookApi().getElements(
  20520. Addon_TypesEnum.experimental_TEST_PROVIDER
  20521. ), providerLinks = generateTestProviderLinks(registeredTestProviders, context), all = (Array.isArray(links[0]) || links.length === 0 ? links : [links]).concat([providerLinks]);
  20522. return react_default.createElement(TooltipLinkList, { ...rest2, links: all });
  20523. };
  20524. function generateTestProviderLinks(registeredTestProviders, context) {
  20525. return Object.entries(registeredTestProviders).map(([testProviderId, state]) => {
  20526. if (!state)
  20527. return null;
  20528. let content = state.sidebarContextMenu?.({ context });
  20529. return content ? {
  20530. id: testProviderId,
  20531. content
  20532. } : null;
  20533. }).filter(Boolean);
  20534. }
  20535. // src/manager/components/sidebar/TreeNode.tsx
  20536. init_react();
  20537. // src/manager/components/sidebar/components/CollapseIcon.tsx
  20538. init_react();
  20539. var CollapseIconWrapper = styled.div(({ theme, isExpanded }) => ({
  20540. width: 8,
  20541. height: 8,
  20542. display: "flex",
  20543. justifyContent: "center",
  20544. alignItems: "center",
  20545. transform: isExpanded ? "rotateZ(90deg)" : "none",
  20546. transition: "transform .1s ease-out",
  20547. color: theme.textMutedColor
  20548. })), CollapseIcon2 = (props) => react_default.createElement(CollapseIconWrapper, { ...props }, react_default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "8", height: "8", fill: "none" }, react_default.createElement(
  20549. "path",
  20550. {
  20551. fill: "currentColor",
  20552. fillRule: "evenodd",
  20553. clipRule: "evenodd",
  20554. d: "M1.896 7.146a.5.5 0 1 0 .708.708l3.5-3.5a.5.5 0 0 0 0-.708l-3.5-3.5a.5.5 0 1 0-.708.708L5.043 4 1.896 7.146Z"
  20555. }
  20556. )));
  20557. // src/manager/components/sidebar/TreeNode.tsx
  20558. var TypeIcon2 = styled.svg(
  20559. ({ theme, type }) => ({
  20560. width: 14,
  20561. height: 14,
  20562. flex: "0 0 auto",
  20563. color: type === "group" ? theme.base === "dark" ? theme.color.primary : theme.color.ultraviolet : type === "component" ? theme.color.secondary : type === "document" ? theme.base === "dark" ? theme.color.gold : "#ff8300" : type === "story" ? theme.color.seafoam : type === "test" ? theme.color.green : "currentColor"
  20564. })
  20565. ), commonNodeStyles = ({
  20566. theme,
  20567. depth = 0,
  20568. isExpandable = !1
  20569. }) => ({
  20570. flex: 1,
  20571. width: "100%",
  20572. cursor: "pointer",
  20573. display: "flex",
  20574. alignItems: "start",
  20575. textAlign: "left",
  20576. textDecoration: "none",
  20577. border: "none",
  20578. color: "inherit",
  20579. fontSize: `${theme.typography.size.s2}px`,
  20580. fontWeight: "inherit",
  20581. background: "transparent",
  20582. minHeight: 28,
  20583. borderRadius: 4,
  20584. gap: 6,
  20585. paddingLeft: `${(isExpandable ? 8 : 22) + depth * 18}px`,
  20586. paddingTop: 5,
  20587. paddingBottom: 4,
  20588. paddingRight: 6,
  20589. overflowWrap: "break-word",
  20590. wordWrap: "break-word",
  20591. wordBreak: "break-word"
  20592. }), BranchNode = styled.button(commonNodeStyles), LeafNode = styled.a(commonNodeStyles), RootNode = styled.div({
  20593. display: "flex",
  20594. alignItems: "center",
  20595. justifyContent: "space-between",
  20596. marginTop: 16,
  20597. marginBottom: 4,
  20598. "&:first-of-type": {
  20599. marginTop: 0
  20600. }
  20601. }), Wrapper5 = styled.div({
  20602. display: "flex",
  20603. alignItems: "center",
  20604. gap: 6,
  20605. marginTop: 2
  20606. }), GroupNode = react_default.memo(function({
  20607. children,
  20608. isExpanded = !1,
  20609. isExpandable = !1,
  20610. ...props
  20611. }) {
  20612. return react_default.createElement(BranchNode, { isExpandable, tabIndex: -1, ...props }, react_default.createElement(Wrapper5, null, isExpandable && react_default.createElement(CollapseIcon2, { isExpanded }), react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "14", height: "14", type: "group" }, react_default.createElement(UseSymbol, { type: "group" }))), children);
  20613. }), ComponentNode = react_default.memo(
  20614. function({
  20615. theme,
  20616. children,
  20617. isExpanded = !1,
  20618. isExpandable = !1,
  20619. isSelected,
  20620. ...props
  20621. }) {
  20622. return react_default.createElement(BranchNode, { isExpandable, tabIndex: -1, ...props }, react_default.createElement(Wrapper5, null, isExpandable && react_default.createElement(CollapseIcon2, { isExpanded }), react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "12", height: "12", type: "component" }, react_default.createElement(UseSymbol, { type: "component" }))), children);
  20623. }
  20624. ), DocumentNode = react_default.memo(function({ theme, children, docsMode, ...props }) {
  20625. return react_default.createElement(LeafNode, { tabIndex: -1, rel: "canonical", ...props }, react_default.createElement(Wrapper5, null, react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "12", height: "12", type: "document" }, react_default.createElement(UseSymbol, { type: "document" }))), children);
  20626. }), StoryBranchNode = react_default.memo(
  20627. function({
  20628. theme,
  20629. children,
  20630. isExpandable = !1,
  20631. isExpanded = !1,
  20632. isSelected,
  20633. ...props
  20634. }) {
  20635. return react_default.createElement(BranchNode, { isExpandable, tabIndex: -1, ...props }, react_default.createElement(Wrapper5, null, isExpandable && react_default.createElement(CollapseIcon2, { isExpanded }), react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "12", height: "12", type: "story" }, react_default.createElement(UseSymbol, { type: "story" }))), children);
  20636. }
  20637. ), StoryLeafNode = react_default.memo(function({
  20638. theme,
  20639. children,
  20640. ...props
  20641. }) {
  20642. return react_default.createElement(LeafNode, { tabIndex: -1, rel: "canonical", ...props }, react_default.createElement(Wrapper5, null, react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "12", height: "12", type: "story" }, react_default.createElement(UseSymbol, { type: "story" }))), children);
  20643. }), TestNode = react_default.memo(function({
  20644. theme,
  20645. children,
  20646. ...props
  20647. }) {
  20648. return react_default.createElement(LeafNode, { tabIndex: -1, rel: "canonical", ...props }, react_default.createElement(Wrapper5, null, react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "12", height: "12", type: "test" }, react_default.createElement(UseSymbol, { type: "test" }))), children);
  20649. });
  20650. // src/manager/components/sidebar/useExpanded.ts
  20651. init_react();
  20652. // src/manager/keybinding.ts
  20653. var codeToKeyMap = {
  20654. // event.code => event.key
  20655. Space: " ",
  20656. Slash: "/",
  20657. ArrowLeft: "ArrowLeft",
  20658. ArrowUp: "ArrowUp",
  20659. ArrowRight: "ArrowRight",
  20660. ArrowDown: "ArrowDown",
  20661. Escape: "Escape",
  20662. Enter: "Enter"
  20663. }, allFalse = { alt: !1, ctrl: !1, meta: !1, shift: !1 }, matchesModifiers = (modifiers2, event) => {
  20664. let { alt, ctrl, meta, shift: shift2 } = modifiers2 === !1 ? allFalse : modifiers2;
  20665. return !(typeof alt == "boolean" && alt !== event.altKey || typeof ctrl == "boolean" && ctrl !== event.ctrlKey || typeof meta == "boolean" && meta !== event.metaKey || typeof shift2 == "boolean" && shift2 !== event.shiftKey);
  20666. }, matchesKeyCode = (code, event) => event.code ? event.code === code : event.key === codeToKeyMap[code];
  20667. // src/manager/components/sidebar/useExpanded.ts
  20668. var { document: document5 } = scope, initializeExpanded = ({
  20669. refId,
  20670. data,
  20671. initialExpanded,
  20672. highlightedRef,
  20673. rootIds,
  20674. selectedStoryId
  20675. }) => {
  20676. let selectedStory = selectedStoryId && data[selectedStoryId], candidates = [...rootIds];
  20677. return highlightedRef.current?.refId === refId && candidates.push(...getAncestorIds2(data, highlightedRef.current?.itemId)), selectedStory && "children" in selectedStory && selectedStory.children?.length && candidates.push(selectedStoryId), candidates.reduce(
  20678. // @ts-expect-error (non strict)
  20679. (acc, id) => Object.assign(acc, { [id]: id in initialExpanded ? initialExpanded[id] : !0 }),
  20680. {}
  20681. );
  20682. }, noop3 = () => {
  20683. }, useExpanded = ({
  20684. containerRef,
  20685. isBrowsing,
  20686. refId,
  20687. data,
  20688. initialExpanded,
  20689. rootIds,
  20690. highlightedRef,
  20691. setHighlightedItemId,
  20692. selectedStoryId,
  20693. onSelectStoryId
  20694. }) => {
  20695. let api = useStorybookApi(), [expanded, setExpanded] = useReducer(
  20696. (state, { ids, value }) => ids.reduce((acc, id) => Object.assign(acc, { [id]: value }), { ...state }),
  20697. // @ts-expect-error (non strict)
  20698. { refId, data, highlightedRef, rootIds, initialExpanded, selectedStoryId },
  20699. initializeExpanded
  20700. ), getElementByDataItemId = useCallback(
  20701. (id) => containerRef.current?.querySelector(`[data-item-id="${id}"]`),
  20702. [containerRef]
  20703. ), highlightElement = useCallback(
  20704. (element) => {
  20705. setHighlightedItemId(element.getAttribute("data-item-id")), scrollIntoView(element);
  20706. },
  20707. [setHighlightedItemId]
  20708. ), updateExpanded = useCallback(
  20709. ({ ids, value }) => {
  20710. if (setExpanded({ ids, value }), ids.length === 1) {
  20711. let element = containerRef.current?.querySelector(
  20712. `[data-item-id="${ids[0]}"][data-ref-id="${refId}"]`
  20713. );
  20714. element && highlightElement(element);
  20715. }
  20716. },
  20717. [containerRef, highlightElement, refId]
  20718. );
  20719. useEffect(() => {
  20720. setExpanded({ ids: getAncestorIds2(data, selectedStoryId), value: !0 });
  20721. }, [data, selectedStoryId]);
  20722. let collapseAll = useCallback(() => {
  20723. let ids = Object.keys(data).filter((id) => !rootIds.includes(id));
  20724. setExpanded({ ids, value: !1 });
  20725. }, [data, rootIds]), expandAll = useCallback(() => {
  20726. setExpanded({ ids: Object.keys(data), value: !0 });
  20727. }, [data]);
  20728. return useEffect(() => api ? (api.on(STORIES_COLLAPSE_ALL, collapseAll), api.on(STORIES_EXPAND_ALL, expandAll), () => {
  20729. api.off(STORIES_COLLAPSE_ALL, collapseAll), api.off(STORIES_EXPAND_ALL, expandAll);
  20730. }) : noop3, [api, collapseAll, expandAll]), useEffect(() => {
  20731. let menuElement = document5.getElementById("storybook-explorer-menu"), navigateTree = throttle((event) => {
  20732. let highlightedItemId = highlightedRef.current?.refId === refId && highlightedRef.current?.itemId;
  20733. if (!isBrowsing || !containerRef.current || !highlightedItemId || event.repeat || !matchesModifiers(!1, event))
  20734. return;
  20735. let isEnter = matchesKeyCode("Enter", event), isSpace = matchesKeyCode("Space", event), isArrowLeft = matchesKeyCode("ArrowLeft", event), isArrowRight = matchesKeyCode("ArrowRight", event);
  20736. if (!(isEnter || isSpace || isArrowLeft || isArrowRight))
  20737. return;
  20738. let highlightedElement = getElementByDataItemId(highlightedItemId);
  20739. if (!highlightedElement || highlightedElement.getAttribute("data-ref-id") !== refId)
  20740. return;
  20741. let target = event.target;
  20742. if (!isAncestor(menuElement, target) && !isAncestor(target, menuElement))
  20743. return;
  20744. if (target.hasAttribute("data-action")) {
  20745. if (isEnter || isSpace)
  20746. return;
  20747. target.blur();
  20748. }
  20749. let type = highlightedElement.getAttribute("data-nodetype");
  20750. type && (isEnter || isSpace) && ["component", "story", "document", "test"].includes(type) && onSelectStoryId(highlightedItemId);
  20751. let isExpanded = highlightedElement.getAttribute("aria-expanded");
  20752. if (isArrowLeft) {
  20753. if (isExpanded === "true") {
  20754. setExpanded({ ids: [highlightedItemId], value: !1 });
  20755. return;
  20756. }
  20757. let parentId = highlightedElement.getAttribute("data-parent-id"), parentElement = parentId && getElementByDataItemId(parentId);
  20758. if (parentElement && parentElement.getAttribute("data-highlightable") === "true") {
  20759. highlightElement(parentElement);
  20760. return;
  20761. }
  20762. setExpanded({ ids: getDescendantIds(data, highlightedItemId, !0), value: !1 });
  20763. return;
  20764. }
  20765. isArrowRight && (isExpanded === "false" ? updateExpanded({ ids: [highlightedItemId], value: !0 }) : isExpanded === "true" && updateExpanded({ ids: getDescendantIds(data, highlightedItemId, !0), value: !0 }));
  20766. }, 60);
  20767. return document5.addEventListener("keydown", navigateTree), () => document5.removeEventListener("keydown", navigateTree);
  20768. }, [
  20769. containerRef,
  20770. isBrowsing,
  20771. refId,
  20772. data,
  20773. highlightedRef,
  20774. setHighlightedItemId,
  20775. onSelectStoryId
  20776. ]), [expanded, updateExpanded];
  20777. };
  20778. // src/manager/components/sidebar/Tree.tsx
  20779. var CollapseButton = styled(Button)(({ theme }) => ({
  20780. fontSize: `${theme.typography.size.s1 - 1}px`,
  20781. fontWeight: theme.typography.weight.bold,
  20782. letterSpacing: "0.16em",
  20783. textTransform: "uppercase",
  20784. color: theme.textMutedColor,
  20785. padding: "0 8px"
  20786. })), LeafNodeStyleWrapper = styled.div(({ theme }) => ({
  20787. position: "relative",
  20788. display: "flex",
  20789. justifyContent: "space-between",
  20790. alignItems: "flex-start",
  20791. color: theme.color.defaultText,
  20792. background: "transparent",
  20793. minHeight: 28,
  20794. borderRadius: 4,
  20795. overflow: "hidden",
  20796. "--tree-node-background-hover": theme.background.content,
  20797. [MEDIA_DESKTOP_BREAKPOINT]: {
  20798. "--tree-node-background-hover": theme.background.app
  20799. },
  20800. "&:hover, &:focus": {
  20801. "--tree-node-background-hover": theme.background.hoverable,
  20802. background: "var(--tree-node-background-hover)",
  20803. outline: "none"
  20804. },
  20805. '& [data-displayed="off"]': {
  20806. visibility: "hidden"
  20807. },
  20808. '&:hover [data-displayed="off"]': {
  20809. visibility: "visible"
  20810. },
  20811. '& [data-displayed="on"] + *': {
  20812. visibility: "hidden"
  20813. },
  20814. '&:hover [data-displayed="off"] + *': {
  20815. visibility: "hidden"
  20816. },
  20817. '&[data-selected="true"]': {
  20818. color: theme.color.lightest,
  20819. background: theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary,
  20820. fontWeight: theme.typography.weight.bold,
  20821. "&&:hover, &&:focus": {
  20822. background: theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary
  20823. },
  20824. svg: { color: theme.color.lightest }
  20825. },
  20826. a: { color: "currentColor" }
  20827. })), SkipToContentLink = styled(Button)(({ theme }) => ({
  20828. display: "none",
  20829. "@media (min-width: 600px)": {
  20830. display: "block",
  20831. fontSize: "10px",
  20832. overflow: "hidden",
  20833. width: 1,
  20834. height: "20px",
  20835. boxSizing: "border-box",
  20836. opacity: 0,
  20837. padding: 0,
  20838. "&:focus": {
  20839. opacity: 1,
  20840. padding: "5px 10px",
  20841. background: "white",
  20842. color: theme.color.secondary,
  20843. width: "auto"
  20844. }
  20845. }
  20846. })), StatusSlots = styled.div({
  20847. display: "flex",
  20848. alignItems: "center"
  20849. });
  20850. var getStatusLabel = (status) => status.split(":")[1].replace(/^./, (char) => char.toUpperCase()), Node2 = react_default.memo(function(props) {
  20851. let {
  20852. item,
  20853. statuses,
  20854. groupDualStatus,
  20855. refId,
  20856. docsMode,
  20857. isOrphan,
  20858. isDisplayed,
  20859. isSelected,
  20860. isFullyExpanded,
  20861. setFullyExpanded,
  20862. isExpanded,
  20863. setExpanded,
  20864. onSelectStoryId,
  20865. api,
  20866. isModifiedFilterActive
  20867. } = props, theme = useTheme(), { isDesktop, isMobile: isMobile2, setMobileMenuOpen } = useLayout(), statusLinks = useMemo(() => item.type === "story" || item.type === "docs" ? Object.entries(statuses).filter(([, status]) => status.sidebarContextMenu !== !1).sort((a2, b2) => statusPriority.indexOf(a2[1].value) - statusPriority.indexOf(b2[1].value)).map(([typeId, status]) => ({
  20868. id: typeId,
  20869. title: status.title,
  20870. description: status.description,
  20871. "aria-label": `Test status for ${status.title}: ${status.value}`,
  20872. icon: getStatus(theme, status.value).icon,
  20873. onClick: () => {
  20874. onSelectStoryId(item.id), internal_fullStatusStore.selectStatuses([status]);
  20875. }
  20876. })) : [], [item.id, item.type, onSelectStoryId, statuses, theme]), contextMenu = useContextMenu(item, statusLinks, api);
  20877. refId !== "storybook_internal" && (contextMenu = { node: null, onMouseEnter: () => {
  20878. } });
  20879. let id = createId(item.id, refId);
  20880. if (item.type === "story" && !("children" in item && item.children) && (!("subtype" in item) || item.subtype !== "test") || item.type === "docs") {
  20881. let LeafNode3 = item.type === "docs" ? DocumentNode : StoryLeafNode, { changeStatus, testStatus } = getChangeDetectionStatus(statuses || {}), leafChangeIcon = changeStatus === "status-value:unknown" || changeStatus === "status-value:affected" || changeStatus === "status-value:modified" && !isModifiedFilterActive ? null : getStatus(theme, changeStatus).icon, { icon: testIcon } = getStatus(theme, testStatus), overallStoryStatus = getMostCriticalStatusValue([changeStatus, testStatus]), { textColor } = getStatus(theme, overallStoryStatus);
  20882. return react_default.createElement(
  20883. LeafNodeStyleWrapper,
  20884. {
  20885. key: id,
  20886. className: "sidebar-item",
  20887. "data-selected": isSelected,
  20888. "data-ref-id": refId,
  20889. "data-item-id": item.id,
  20890. "data-parent-id": item.parent,
  20891. "data-nodetype": item.type === "docs" ? "document" : "story",
  20892. "data-highlightable": isDisplayed,
  20893. onMouseEnter: contextMenu.onMouseEnter
  20894. },
  20895. react_default.createElement(
  20896. LeafNode3,
  20897. {
  20898. style: isSelected ? {} : { color: textColor },
  20899. href: getLink(item, refId),
  20900. id,
  20901. depth: isOrphan ? item.depth : item.depth - 1,
  20902. onClick: (event) => {
  20903. event.preventDefault(), onSelectStoryId(item.id), isMobile2 && setMobileMenuOpen(!1);
  20904. },
  20905. ...item.type === "docs" && { docsMode }
  20906. },
  20907. item.renderLabel?.(item, api) || item.name
  20908. ),
  20909. isSelected && react_default.createElement(SkipToContentLink, { asChild: !0, ariaLabel: !1 }, react_default.createElement("a", { href: "#storybook-preview-wrapper" }, "Skip to content")),
  20910. contextMenu.node,
  20911. leafChangeIcon && testIcon ? react_default.createElement(StatusSlots, null, react_default.createElement(
  20912. StatusButton,
  20913. {
  20914. ariaLabel: `Change status: ${getStatusLabel(changeStatus)}`,
  20915. "data-testid": "tree-change-status-button",
  20916. type: "button",
  20917. status: changeStatus,
  20918. selectedItem: isSelected
  20919. },
  20920. leafChangeIcon
  20921. ), react_default.createElement(
  20922. StatusButton,
  20923. {
  20924. ariaLabel: `Test status: ${getStatusLabel(testStatus)}`,
  20925. "data-testid": "tree-status-button",
  20926. type: "button",
  20927. status: testStatus,
  20928. selectedItem: isSelected
  20929. },
  20930. testIcon
  20931. )) : leafChangeIcon ? react_default.createElement(
  20932. StatusButton,
  20933. {
  20934. ariaLabel: `Change status: ${getStatusLabel(changeStatus)}`,
  20935. "data-testid": "tree-change-status-button",
  20936. type: "button",
  20937. status: changeStatus,
  20938. selectedItem: isSelected
  20939. },
  20940. leafChangeIcon
  20941. ) : testIcon ? react_default.createElement(
  20942. StatusButton,
  20943. {
  20944. ariaLabel: `Test status: ${getStatusLabel(testStatus)}`,
  20945. "data-testid": "tree-status-button",
  20946. type: "button",
  20947. status: testStatus,
  20948. selectedItem: isSelected
  20949. },
  20950. testIcon
  20951. ) : null
  20952. );
  20953. }
  20954. if (item.type === "root")
  20955. return react_default.createElement(
  20956. RootNode,
  20957. {
  20958. key: id,
  20959. id,
  20960. className: "sidebar-subheading",
  20961. "data-ref-id": refId,
  20962. "data-item-id": item.id,
  20963. "data-nodetype": "root"
  20964. },
  20965. react_default.createElement(
  20966. CollapseButton,
  20967. {
  20968. variant: "ghost",
  20969. ariaLabel: isExpanded ? "Collapse" : "Expand",
  20970. "data-action": "collapse-root",
  20971. onClick: (event) => {
  20972. event.preventDefault(), setExpanded({ ids: [item.id], value: !isExpanded });
  20973. },
  20974. "aria-expanded": isExpanded
  20975. },
  20976. react_default.createElement(CollapseIcon2, { isExpanded }),
  20977. item.renderLabel?.(item, api) || item.name
  20978. ),
  20979. isExpanded && react_default.createElement(
  20980. Button,
  20981. {
  20982. padding: "small",
  20983. variant: "ghost",
  20984. className: "sidebar-subheading-action",
  20985. ariaLabel: isFullyExpanded ? "Collapse all" : "Expand all",
  20986. "data-action": "expand-all",
  20987. "data-expanded": isFullyExpanded,
  20988. onClick: (event) => {
  20989. event.preventDefault(), setFullyExpanded();
  20990. }
  20991. },
  20992. isFullyExpanded ? react_default.createElement(CollapseIcon, null) : react_default.createElement(ExpandAltIcon, null)
  20993. )
  20994. );
  20995. if (item.type === "component" || item.type === "group" || item.type === "story" && "children" in item && item.children) {
  20996. let { children = [] } = item, BranchNode2 = { component: ComponentNode, group: GroupNode, story: StoryBranchNode }[item.type], { changeStatus: localChange, testStatus: localTest } = getChangeDetectionStatus(
  20997. statuses || {}
  20998. ), groupDual = groupDualStatus?.[item.id] || {
  20999. change: "status-value:unknown",
  21000. test: "status-value:unknown"
  21001. }, branchChange = getMostCriticalStatusValue([localChange, groupDual.change]), branchTest = getMostCriticalStatusValue([localTest, groupDual.test]), branchChangeIcon = branchChange !== "status-value:unknown" && branchChange !== "status-value:affected" && (branchChange !== "status-value:modified" || isModifiedFilterActive) ? getStatus(theme, branchChange).icon : null, branchTestIcon = getStatus(theme, branchTest).icon, overallStatus = getMostCriticalStatusValue([branchChange, branchTest]), color2 = overallStatus ? getStatus(theme, overallStatus).textColor : null;
  21002. return react_default.createElement(
  21003. LeafNodeStyleWrapper,
  21004. {
  21005. key: id,
  21006. className: "sidebar-item",
  21007. "data-selected": isSelected,
  21008. "data-ref-id": refId,
  21009. "data-item-id": item.id,
  21010. "data-parent-id": item.parent,
  21011. "data-nodetype": item.type,
  21012. "data-highlightable": isDisplayed,
  21013. onMouseEnter: contextMenu.onMouseEnter
  21014. },
  21015. react_default.createElement(
  21016. BranchNode2,
  21017. {
  21018. id,
  21019. style: color2 && !isSelected ? { color: color2 } : {},
  21020. "aria-controls": children.join(" "),
  21021. "aria-expanded": isExpanded,
  21022. depth: isOrphan ? item.depth : item.depth - 1,
  21023. isExpandable: children.length > 0,
  21024. isExpanded,
  21025. onClick: (event) => {
  21026. event.preventDefault(), item.type === "story" ? (onSelectStoryId(item.id), (!isExpanded || isSelected) && setExpanded({ ids: [item.id], value: !isExpanded })) : item.type === "component" ? (!isExpanded && isDesktop && onSelectStoryId(item.id), setExpanded({ ids: [item.id], value: !isExpanded })) : setExpanded({ ids: [item.id], value: !isExpanded });
  21027. },
  21028. onMouseEnter: () => {
  21029. (item.type === "component" || item.type === "story") && api.emit(PRELOAD_ENTRIES, {
  21030. ids: [children[0]],
  21031. options: { target: refId }
  21032. });
  21033. }
  21034. },
  21035. item.renderLabel?.(item, api) || item.name
  21036. ),
  21037. isSelected && react_default.createElement(SkipToContentLink, { asChild: !0, ariaLabel: !1 }, react_default.createElement("a", { href: "#storybook-preview-wrapper" }, "Skip to content")),
  21038. contextMenu.node,
  21039. branchChangeIcon && branchTestIcon ? react_default.createElement(StatusSlots, null, react_default.createElement(
  21040. StatusButton,
  21041. {
  21042. ariaLabel: `Change status: ${getStatusLabel(branchChange)}`,
  21043. "data-testid": "tree-change-status-button",
  21044. type: "button",
  21045. status: branchChange,
  21046. selectedItem: isSelected
  21047. },
  21048. branchChangeIcon
  21049. ), react_default.createElement(
  21050. StatusButton,
  21051. {
  21052. ariaLabel: `Test status: ${getStatusLabel(branchTest)}`,
  21053. "data-testid": "tree-status-button",
  21054. type: "button",
  21055. status: branchTest,
  21056. selectedItem: isSelected
  21057. },
  21058. branchTestIcon
  21059. )) : branchChangeIcon ? react_default.createElement(
  21060. StatusButton,
  21061. {
  21062. ariaLabel: `Change status: ${getStatusLabel(branchChange)}`,
  21063. "data-testid": "tree-change-status-button",
  21064. type: "button",
  21065. status: branchChange,
  21066. selectedItem: isSelected
  21067. },
  21068. branchChangeIcon
  21069. ) : branchTestIcon ? react_default.createElement(
  21070. StatusButton,
  21071. {
  21072. ariaLabel: `Test status: ${getStatusLabel(branchTest)}`,
  21073. "data-testid": "tree-status-button",
  21074. type: "button",
  21075. status: branchTest,
  21076. selectedItem: isSelected
  21077. },
  21078. branchTestIcon
  21079. ) : null
  21080. );
  21081. }
  21082. let isTest = item.type === "story" && item.subtype === "test", LeafNode2 = isTest ? TestNode : { docs: DocumentNode, story: StoryLeafNode }[item.type], nodeType = isTest ? "test" : { docs: "document", story: "story" }[item.type], leafStatuses = Object.fromEntries(
  21083. Object.entries(statuses || {}).filter(
  21084. ([, status]) => status.typeId !== CHANGE_DETECTION_STATUS_TYPE_ID || status.value === "status-value:new"
  21085. )
  21086. ), leafStatus = getMostCriticalStatusValue(Object.values(leafStatuses).map((s2) => s2.value)), { icon: leafIcon, textColor: leafColor } = getStatus(theme, leafStatus), leafStatusButton = leafIcon ? react_default.createElement(
  21087. StatusButton,
  21088. {
  21089. ariaLabel: `Status: ${getStatusLabel(leafStatus)}`,
  21090. "data-testid": "tree-status-button",
  21091. role: "status",
  21092. type: "button",
  21093. status: leafStatus,
  21094. selectedItem: isSelected
  21095. },
  21096. leafIcon
  21097. ) : null;
  21098. return react_default.createElement(
  21099. LeafNodeStyleWrapper,
  21100. {
  21101. key: id,
  21102. className: "sidebar-item",
  21103. "data-selected": isSelected,
  21104. "data-ref-id": refId,
  21105. "data-item-id": item.id,
  21106. "data-parent-id": item.parent,
  21107. "data-nodetype": nodeType,
  21108. "data-highlightable": isDisplayed,
  21109. onMouseEnter: contextMenu.onMouseEnter
  21110. },
  21111. react_default.createElement(
  21112. LeafNode2,
  21113. {
  21114. style: leafColor && !isSelected ? { color: leafColor } : {},
  21115. href: getLink(item, refId),
  21116. id,
  21117. depth: isOrphan ? item.depth : item.depth - 1,
  21118. onClick: (event) => {
  21119. event.preventDefault(), onSelectStoryId(item.id), isMobile2 && setMobileMenuOpen(!1);
  21120. }
  21121. },
  21122. item.renderLabel?.(item, api) || item.name
  21123. ),
  21124. isSelected && react_default.createElement(SkipToContentLink, { ariaLabel: !1, asChild: !0 }, react_default.createElement("a", { href: "#storybook-preview-wrapper" }, "Skip to content")),
  21125. contextMenu.node,
  21126. leafStatusButton
  21127. );
  21128. }), Root = react_default.memo(function({
  21129. setExpanded,
  21130. isFullyExpanded,
  21131. expandableDescendants,
  21132. ...props
  21133. }) {
  21134. let setFullyExpanded = useCallback(
  21135. () => setExpanded({ ids: expandableDescendants, value: !isFullyExpanded }),
  21136. [setExpanded, isFullyExpanded, expandableDescendants]
  21137. );
  21138. return react_default.createElement(
  21139. Node2,
  21140. {
  21141. ...props,
  21142. setExpanded,
  21143. isFullyExpanded,
  21144. setFullyExpanded
  21145. }
  21146. );
  21147. }), Tree = react_default.memo(function({
  21148. isBrowsing,
  21149. refId,
  21150. data,
  21151. allStatuses,
  21152. docsMode,
  21153. highlightedRef,
  21154. setHighlightedItemId,
  21155. selectedStoryId,
  21156. onSelectStoryId
  21157. }) {
  21158. let containerRef = useRef(null), api = useStorybookApi(), isModifiedFilterActive = (useStorybookState().includedStatusFilters ?? []).includes("status-value:modified"), [rootIds, orphanIds, initialExpanded] = useMemo(
  21159. () => Object.keys(data).reduce(
  21160. (acc, id) => {
  21161. let item = data[id];
  21162. return item.type === "root" ? acc[0].push(id) : item.parent || acc[1].push(id), item.type === "root" && item.startCollapsed && (acc[2][id] = !1), acc;
  21163. },
  21164. [[], [], {}]
  21165. ),
  21166. [data]
  21167. ), { expandableDescendants } = useMemo(() => [...orphanIds, ...rootIds].reduce(
  21168. (acc, nodeId) => (acc.expandableDescendants[nodeId] = getDescendantIds(data, nodeId, !1).filter(
  21169. (d2) => !["story", "docs"].includes(data[d2].type)
  21170. ), acc),
  21171. { orphansFirst: [], expandableDescendants: {} }
  21172. ), [data, rootIds, orphanIds]), singleStoryComponentIds = useMemo(() => Object.keys(data).filter((id) => {
  21173. let entry = data[id];
  21174. if (entry.type !== "component")
  21175. return !1;
  21176. let { children = [], name } = entry;
  21177. if (children.length !== 1)
  21178. return !1;
  21179. let onlyChild = data[children[0]];
  21180. return onlyChild.type === "docs" ? !0 : onlyChild.type === "story" && onlyChild.subtype === "story" ? isStoryHoistable(onlyChild.name, name) : !1;
  21181. }), [data]), collapsedItems = useMemo(
  21182. () => Object.keys(data).filter((id) => !singleStoryComponentIds.includes(id)),
  21183. [data, singleStoryComponentIds]
  21184. ), collapsedData = useMemo(() => singleStoryComponentIds.reduce(
  21185. (acc, id) => {
  21186. let { children, parent, name } = data[id], [childId] = children;
  21187. if (parent) {
  21188. let siblings = [...data[parent].children];
  21189. siblings[siblings.indexOf(id)] = childId, acc[parent] = { ...data[parent], children: siblings };
  21190. }
  21191. return acc[childId] = {
  21192. ...data[childId],
  21193. name,
  21194. parent,
  21195. depth: data[childId].depth - 1
  21196. }, acc;
  21197. },
  21198. { ...data }
  21199. ), [data, singleStoryComponentIds]), ancestry = useMemo(() => collapsedItems.reduce(
  21200. (acc, id) => Object.assign(acc, { [id]: getAncestorIds2(collapsedData, id) }),
  21201. {}
  21202. ), [collapsedItems, collapsedData]), [expanded, setExpanded] = useExpanded({
  21203. // @ts-expect-error (non strict)
  21204. containerRef,
  21205. isBrowsing,
  21206. refId,
  21207. data: collapsedData,
  21208. initialExpanded,
  21209. rootIds,
  21210. highlightedRef,
  21211. setHighlightedItemId,
  21212. selectedStoryId,
  21213. onSelectStoryId
  21214. }), groupStatus = useMemo(
  21215. () => getGroupStatus(collapsedData, allStatuses ?? {}),
  21216. [collapsedData, allStatuses]
  21217. ), groupDualStatus = useMemo(
  21218. () => getGroupDualStatus(collapsedData, allStatuses ?? {}),
  21219. [collapsedData, allStatuses]
  21220. ), treeItems = useMemo(() => collapsedItems.map((itemId) => {
  21221. let item = collapsedData[itemId], id = createId(itemId, refId);
  21222. if (item.type === "root") {
  21223. let descendants = expandableDescendants[item.id], isFullyExpanded = descendants.every((d2) => expanded[d2]);
  21224. return (
  21225. // @ts-expect-error (TODO)
  21226. react_default.createElement(
  21227. Root,
  21228. {
  21229. api,
  21230. key: id,
  21231. item,
  21232. refId,
  21233. collapsedData,
  21234. isOrphan: !1,
  21235. isDisplayed: !0,
  21236. isSelected: selectedStoryId === itemId,
  21237. isExpanded: !!expanded[itemId],
  21238. setExpanded,
  21239. isFullyExpanded,
  21240. expandableDescendants: descendants,
  21241. onSelectStoryId,
  21242. isModifiedFilterActive
  21243. }
  21244. )
  21245. );
  21246. }
  21247. let isDisplayed = !item.parent || ancestry[itemId].every((a2) => expanded[a2]);
  21248. return isDisplayed === !1 ? null : react_default.createElement(
  21249. Node2,
  21250. {
  21251. api,
  21252. collapsedData,
  21253. key: id,
  21254. item,
  21255. statuses: allStatuses?.[itemId] ?? {},
  21256. groupDualStatus,
  21257. refId,
  21258. docsMode,
  21259. isOrphan: orphanIds.some((oid) => itemId === oid || itemId.startsWith(`${oid}-`)),
  21260. isDisplayed,
  21261. isSelected: selectedStoryId === itemId,
  21262. isExpanded: !!expanded[itemId],
  21263. setExpanded,
  21264. onSelectStoryId,
  21265. isModifiedFilterActive
  21266. }
  21267. );
  21268. }), [
  21269. ancestry,
  21270. api,
  21271. collapsedData,
  21272. collapsedItems,
  21273. docsMode,
  21274. expandableDescendants,
  21275. expanded,
  21276. groupDualStatus,
  21277. isModifiedFilterActive,
  21278. onSelectStoryId,
  21279. orphanIds,
  21280. refId,
  21281. selectedStoryId,
  21282. setExpanded,
  21283. allStatuses
  21284. ]);
  21285. return react_default.createElement(StatusContext.Provider, { value: { data, allStatuses, groupStatus } }, react_default.createElement("div", { ref: containerRef }, treeItems));
  21286. });
  21287. // src/manager/components/sidebar/Refs.tsx
  21288. var Wrapper6 = styled.div(({ isMain }) => ({
  21289. position: "relative",
  21290. marginTop: isMain ? void 0 : 0
  21291. })), RefHead = styled.div(({ theme }) => ({
  21292. fontWeight: theme.typography.weight.bold,
  21293. fontSize: theme.typography.size.s2,
  21294. // Similar to ListItem.tsx
  21295. textDecoration: "none",
  21296. lineHeight: "16px",
  21297. display: "flex",
  21298. alignItems: "center",
  21299. justifyContent: "space-between",
  21300. background: "transparent",
  21301. width: "100%",
  21302. marginTop: 20,
  21303. paddingTop: 16,
  21304. paddingBottom: 12,
  21305. borderTop: `1px solid ${theme.appBorderColor}`,
  21306. color: theme.color.defaultText
  21307. })), RefTitle = styled.div({
  21308. textOverflow: "ellipsis",
  21309. whiteSpace: "nowrap",
  21310. flex: 1,
  21311. overflow: "hidden",
  21312. marginLeft: 2
  21313. }), CollapseButton2 = styled.button(({ theme }) => ({
  21314. all: "unset",
  21315. display: "flex",
  21316. padding: "0px 8px",
  21317. gap: 6,
  21318. alignItems: "center",
  21319. cursor: "pointer",
  21320. overflow: "hidden",
  21321. "&:focus": {
  21322. borderColor: theme.color.secondary,
  21323. "span:first-of-type": {
  21324. borderLeftColor: theme.color.secondary
  21325. }
  21326. }
  21327. })), Ref = react_default.memo(function(props) {
  21328. let storybookState = useStorybookState(), api = useStorybookApi(), {
  21329. filteredIndex: index,
  21330. id: refId,
  21331. title: title2 = refId,
  21332. isLoading: isLoadingMain,
  21333. isBrowsing,
  21334. hasEntries,
  21335. selectedStoryId,
  21336. highlightedRef,
  21337. setHighlighted,
  21338. loginUrl,
  21339. type,
  21340. expanded = !0,
  21341. indexError,
  21342. previewInitialized,
  21343. allStatuses
  21344. } = props, length = useMemo(() => index ? Object.keys(index).length : 0, [index]), indicatorRef = useRef(null), isMain = refId === DEFAULT_REF_ID, isLoading = isLoadingMain || (type === "auto-inject" && !previewInitialized || type === "server-checked") || type === "unknown", isError2 = !!indexError, isEmpty = !isLoading && length === 0, isAuthRequired = !!loginUrl && length === 0, activeFilterCount = getActiveFilterCount(storybookState), state = getStateType(isLoading, isAuthRequired, isError2, isEmpty), [isExpanded, setExpanded] = useState(expanded);
  21345. useEffect(() => {
  21346. index && selectedStoryId && index[selectedStoryId] && setExpanded(!0);
  21347. }, [index, selectedStoryId]);
  21348. let handleClick = useCallback(() => setExpanded((value) => !value), []), setHighlightedItemId = useCallback(
  21349. (itemId) => setHighlighted({ itemId, refId }),
  21350. [setHighlighted, refId]
  21351. ), onSelectStoryId = useCallback(
  21352. (storyId) => api?.selectStory(storyId, void 0, { ref: isMain ? void 0 : refId }),
  21353. [api, isMain, refId]
  21354. );
  21355. return react_default.createElement(react_default.Fragment, null, isMain || react_default.createElement(
  21356. RefHead,
  21357. {
  21358. "aria-label": `${isExpanded ? "Hide" : "Show"} ${title2} stories`,
  21359. "aria-expanded": isExpanded
  21360. },
  21361. react_default.createElement(CollapseButton2, { "data-action": "collapse-ref", onClick: handleClick }, react_default.createElement(CollapseIcon2, { isExpanded }), react_default.createElement(RefTitle, { title: title2 }, title2)),
  21362. react_default.createElement(RefIndicator, { ...props, state, ref: indicatorRef })
  21363. ), isExpanded && react_default.createElement(Wrapper6, { "data-title": title2, isMain }, state === "auth" && react_default.createElement(AuthBlock, { id: refId, loginUrl }), state === "error" && react_default.createElement(ErrorBlock, { error: indexError }), state === "loading" && react_default.createElement(LoaderBlock, { isMain }), state === "empty" && react_default.createElement(
  21364. EmptyBlock,
  21365. {
  21366. isMain,
  21367. hasEntries,
  21368. activeFilterCount
  21369. }
  21370. ), state === "ready" && react_default.createElement(
  21371. Tree,
  21372. {
  21373. allStatuses,
  21374. isBrowsing,
  21375. isMain,
  21376. refId,
  21377. data: index,
  21378. docsMode: storybookState.docsOptions.docsMode,
  21379. selectedStoryId,
  21380. onSelectStoryId,
  21381. highlightedRef,
  21382. setHighlightedItemId
  21383. }
  21384. )));
  21385. });
  21386. // src/manager/components/sidebar/useHighlighted.ts
  21387. init_react();
  21388. var { document: document6, window: globalWindow4 } = scope, fromSelection = (selection) => selection ? { itemId: selection.storyId, refId: selection.refId } : null, scrollToSelector = (selector, options2 = {}, _attempt = 1) => {
  21389. let { containerRef, center = !1, attempts = 3, delay: delay2 = 500 } = options2, element = (containerRef ? containerRef.current : document6)?.querySelector(selector);
  21390. element ? scrollIntoView(element, center) : _attempt <= attempts && setTimeout(scrollToSelector, delay2, selector, options2, _attempt + 1);
  21391. }, useHighlighted = ({
  21392. containerRef,
  21393. isLoading,
  21394. isBrowsing,
  21395. selected
  21396. }) => {
  21397. let initialHighlight = fromSelection(selected), highlightedRef = useRef(initialHighlight), [highlighted, setHighlighted] = useState(initialHighlight), api = useStorybookApi(), updateHighlighted = useCallback(
  21398. (highlight) => {
  21399. highlightedRef.current = highlight, setHighlighted(highlight);
  21400. },
  21401. [highlightedRef]
  21402. ), highlightElement = useCallback(
  21403. (element, center = !1) => {
  21404. let itemId = element.getAttribute("data-item-id"), refId = element.getAttribute("data-ref-id");
  21405. !itemId || !refId || (updateHighlighted({ itemId, refId }), scrollIntoView(element, center));
  21406. },
  21407. [updateHighlighted]
  21408. );
  21409. return useEffect(() => {
  21410. let highlight = fromSelection(selected);
  21411. updateHighlighted(highlight), highlight && scrollToSelector(`[data-item-id="${highlight.itemId}"][data-ref-id="${highlight.refId}"]`, {
  21412. containerRef,
  21413. center: !0
  21414. });
  21415. }, [containerRef, selected, updateHighlighted]), useEffect(() => {
  21416. let menuElement = document6.getElementById("storybook-explorer-menu"), lastRequestId, navigateTree = (event) => {
  21417. if (isLoading || !isBrowsing || !containerRef.current || !matchesModifiers(!1, event))
  21418. return;
  21419. let isArrowUp = matchesKeyCode("ArrowUp", event), isArrowDown = matchesKeyCode("ArrowDown", event);
  21420. if (!(isArrowUp || isArrowDown))
  21421. return;
  21422. let requestId = globalWindow4.requestAnimationFrame(() => {
  21423. globalWindow4.cancelAnimationFrame(lastRequestId), lastRequestId = requestId;
  21424. let target = event.target;
  21425. if (!isAncestor(menuElement, target) && !isAncestor(target, menuElement))
  21426. return;
  21427. target.hasAttribute("data-action") && target.blur();
  21428. let highlightable = Array.from(
  21429. containerRef.current?.querySelectorAll("[data-highlightable=true]") || []
  21430. ), currentIndex = highlightable.findIndex(
  21431. (el) => el.getAttribute("data-item-id") === highlightedRef.current?.itemId && el.getAttribute("data-ref-id") === highlightedRef.current?.refId
  21432. ), nextIndex = cycle2(highlightable, currentIndex, isArrowUp ? -1 : 1), didRunAround = isArrowUp ? nextIndex === highlightable.length - 1 : nextIndex === 0;
  21433. if (highlightElement(highlightable[nextIndex], didRunAround), highlightable[nextIndex].getAttribute("data-nodetype") === "component") {
  21434. let { itemId, refId } = highlightedRef.current, item = api.resolveStory(itemId, refId === "storybook_internal" ? void 0 : refId);
  21435. item?.type === "component" && api.emit(PRELOAD_ENTRIES, {
  21436. ids: [item.children[0]],
  21437. options: { target: refId }
  21438. });
  21439. }
  21440. });
  21441. };
  21442. return document6.addEventListener("keydown", navigateTree), () => document6.removeEventListener("keydown", navigateTree);
  21443. }, [api, containerRef, isLoading, isBrowsing, highlightedRef, highlightElement]), [highlighted, updateHighlighted, highlightedRef];
  21444. };
  21445. // src/manager/components/sidebar/Explorer.tsx
  21446. var Explorer = react_default.memo(function({
  21447. hasEntries,
  21448. isLoading,
  21449. isBrowsing,
  21450. isHidden,
  21451. dataset,
  21452. selected,
  21453. ...restProps
  21454. }) {
  21455. let containerRef = useRef(null), [highlighted, setHighlighted, highlightedRef] = useHighlighted({
  21456. containerRef,
  21457. isLoading,
  21458. isBrowsing,
  21459. selected
  21460. }), { landmarkProps } = useLandmark(
  21461. { "aria-labelledby": "storybook-explorer-tree-heading", role: "navigation" },
  21462. containerRef
  21463. );
  21464. return react_default.createElement(
  21465. "nav",
  21466. {
  21467. hidden: isHidden || void 0,
  21468. "aria-hidden": isHidden || void 0,
  21469. className: isBrowsing ? void 0 : "sb-sr-only",
  21470. ref: containerRef,
  21471. id: "storybook-explorer-tree",
  21472. "data-highlighted-ref-id": highlighted?.refId,
  21473. "data-highlighted-item-id": highlighted?.itemId,
  21474. ...landmarkProps,
  21475. ...restProps
  21476. },
  21477. react_default.createElement("h2", { id: "storybook-explorer-tree-heading", className: "sb-sr-only" }, "Stories"),
  21478. highlighted && react_default.createElement(HighlightStyles, { ...highlighted }),
  21479. dataset.entries.map(([refId, ref]) => react_default.createElement(
  21480. Ref,
  21481. {
  21482. ...ref,
  21483. key: refId,
  21484. isLoading,
  21485. isBrowsing,
  21486. hasEntries,
  21487. selectedStoryId: selected?.refId === ref.id ? selected.storyId : null,
  21488. highlightedRef,
  21489. setHighlighted
  21490. }
  21491. ))
  21492. );
  21493. });
  21494. // src/manager/components/sidebar/Heading.tsx
  21495. init_react();
  21496. // src/manager/components/sidebar/Brand.tsx
  21497. init_react();
  21498. var StorybookLogoStyled = styled(StorybookLogo)(({ theme }) => ({
  21499. width: "auto",
  21500. height: "22px !important",
  21501. display: "block",
  21502. color: theme.base === "light" ? theme.color.defaultText : theme.color.lightest
  21503. })), Img2 = styled.img({
  21504. display: "block",
  21505. maxWidth: "150px !important",
  21506. maxHeight: "100px"
  21507. }), LogoLink = styled.a(({ theme }) => ({
  21508. display: "inline-flex",
  21509. alignItems: "center",
  21510. height: "100%",
  21511. margin: "-3px -4px",
  21512. padding: "2px 3px",
  21513. border: "1px solid transparent",
  21514. borderRadius: 3,
  21515. color: "inherit",
  21516. textDecoration: "none",
  21517. "&:focus-visible": {
  21518. outline: `2px solid ${theme.color.secondary}`,
  21519. outlineOffset: 2
  21520. }
  21521. })), Brand = withTheme(({ theme }) => {
  21522. let { title: title2 = "Storybook", url = "./", image, target } = theme.brand, targetValue = target || (url === "./" ? "" : "_blank");
  21523. if (image === null)
  21524. return title2 === null ? null : url ? react_default.createElement(LogoLink, { href: url, target: targetValue, dangerouslySetInnerHTML: { __html: title2 } }) : react_default.createElement("div", { dangerouslySetInnerHTML: { __html: title2 } });
  21525. let logo = image ? react_default.createElement(Img2, { src: image, alt: title2 }) : react_default.createElement(StorybookLogoStyled, { alt: title2 });
  21526. return url ? react_default.createElement(LogoLink, { title: title2, href: url, target: targetValue }, logo) : react_default.createElement("div", null, logo);
  21527. });
  21528. // src/manager/components/sidebar/Menu.tsx
  21529. init_react();
  21530. var buttonStyleAdditions = ({
  21531. highlighted,
  21532. isMobile: isMobile2,
  21533. theme
  21534. }) => css`
  21535. position: relative;
  21536. overflow: visible;
  21537. margin-top: 0;
  21538. z-index: 1;
  21539. ${isMobile2 && `
  21540. width: 36px;
  21541. height: 36px;
  21542. `}
  21543. ${highlighted && `
  21544. &:before,
  21545. &:after {
  21546. content: '';
  21547. position: absolute;
  21548. top: 6px;
  21549. right: 6px;
  21550. width: 5px;
  21551. height: 5px;
  21552. z-index: 2;
  21553. border-radius: 50%;
  21554. background: ${theme.background.app};
  21555. border: 1px solid ${theme.background.app};
  21556. box-shadow: 0 0 0 2px ${theme.background.app};
  21557. }
  21558. &:after {
  21559. background: ${theme.color.positive};
  21560. border: 1px solid rgba(0, 0, 0, 0.1);
  21561. box-shadow: 0 0 0 2px ${theme.background.app};
  21562. }
  21563. &:hover:after,
  21564. &:focus-visible:after {
  21565. box-shadow: 0 0 0 2px ${curriedTransparentize$1(0.88, theme.color.secondary)};
  21566. }
  21567. `}
  21568. `, Container10 = styled.div({
  21569. minWidth: 250
  21570. }), SidebarButton = styled(Button)(buttonStyleAdditions), SidebarToggleButton = styled(ToggleButton)(buttonStyleAdditions), MenuButtonGroup = styled.div({
  21571. display: "flex",
  21572. gap: 6
  21573. }), SidebarMenuList = ({ menu, onHide }) => react_default.createElement(Container10, null, menu.filter((links) => links.length).flatMap((links) => react_default.createElement(ActionList, { key: links.map((link) => link.id).join("_") }, links.map((link) => {
  21574. let linkContent = react_default.createElement(react_default.Fragment, null, (link.icon || link.input) && react_default.createElement(ActionList.Icon, null, link.icon || link.input), (link.title || link.center) && react_default.createElement(ActionList.Text, null, link.title || link.center), link.right);
  21575. return react_default.createElement(ActionList.Item, { key: link.id, active: link.active }, react_default.createElement(
  21576. ActionList.Action,
  21577. {
  21578. asChild: !!link.href,
  21579. ariaLabel: !1,
  21580. id: `list-item-${link.id}`,
  21581. disabled: link.disabled,
  21582. onClick: (e2) => {
  21583. if (link.disabled) {
  21584. e2.preventDefault();
  21585. return;
  21586. }
  21587. link.href && link.internal && e2.preventDefault(), link.onClick?.(e2, {
  21588. id: link.id,
  21589. active: link.active,
  21590. disabled: link.disabled,
  21591. title: link.title,
  21592. href: link.href
  21593. }), link.closeOnClick && onHide();
  21594. }
  21595. },
  21596. link.href ? react_default.createElement(
  21597. "a",
  21598. {
  21599. href: link.href,
  21600. target: link.internal ? void 0 : "_blank",
  21601. rel: link.internal ? "canonical" : "noreferrer"
  21602. },
  21603. linkContent
  21604. ) : linkContent
  21605. ));
  21606. })))), SidebarMenu = ({ menu, isHighlighted, onClick }) => {
  21607. let [isTooltipVisible, setIsTooltipVisible] = useState(!1), { isMobile: isMobile2, setMobileMenuOpen } = useLayout();
  21608. return isMobile2 ? react_default.createElement(MenuButtonGroup, null, react_default.createElement(
  21609. SidebarButton,
  21610. {
  21611. padding: "small",
  21612. variant: "ghost",
  21613. ariaLabel: "About Storybook",
  21614. highlighted: !!isHighlighted,
  21615. onClick: (e2) => {
  21616. onClick?.(e2), e2.preventDefault();
  21617. },
  21618. isMobile: !0,
  21619. asChild: !0
  21620. },
  21621. react_default.createElement("a", { href: "./?path=/settings/about", rel: "canonical" }, react_default.createElement(CogIcon, null))
  21622. ), react_default.createElement(
  21623. SidebarButton,
  21624. {
  21625. padding: "small",
  21626. variant: "ghost",
  21627. ariaLabel: "Close menu",
  21628. highlighted: !1,
  21629. onClick: () => setMobileMenuOpen(!1),
  21630. isMobile: !0
  21631. },
  21632. react_default.createElement(CloseIcon, null)
  21633. )) : react_default.createElement(
  21634. PopoverProvider,
  21635. {
  21636. ariaLabel: "Storybook menu",
  21637. placement: "bottom-start",
  21638. padding: 0,
  21639. popover: ({ onHide }) => react_default.createElement(SidebarMenuList, { onHide, menu }),
  21640. onVisibleChange: setIsTooltipVisible
  21641. },
  21642. react_default.createElement(
  21643. SidebarToggleButton,
  21644. {
  21645. ariaLabel: "Settings",
  21646. pressed: isTooltipVisible,
  21647. highlighted: !!isHighlighted,
  21648. padding: "small",
  21649. variant: "ghost",
  21650. size: "medium",
  21651. isMobile: !1
  21652. },
  21653. react_default.createElement(CogIcon, null)
  21654. )
  21655. );
  21656. };
  21657. // src/manager/components/sidebar/Heading.tsx
  21658. var BrandArea = styled.div(({ theme }) => ({
  21659. fontSize: theme.typography.size.s2,
  21660. fontWeight: theme.typography.weight.bold,
  21661. color: theme.color.defaultText,
  21662. marginRight: 20,
  21663. display: "flex",
  21664. width: "100%",
  21665. alignItems: "center",
  21666. minHeight: 22,
  21667. "& > * > *": {
  21668. maxWidth: "100%"
  21669. },
  21670. "& > *": {
  21671. maxWidth: "100%",
  21672. height: "auto",
  21673. display: "block",
  21674. flex: "1 1 auto"
  21675. }
  21676. })), HeadingWrapper = styled.div({
  21677. display: "flex",
  21678. alignItems: "center",
  21679. justifyContent: "space-between",
  21680. position: "relative",
  21681. minHeight: 42,
  21682. paddingLeft: 8
  21683. }), SkipToCanvasLink = styled(Button)(({ theme }) => ({
  21684. display: "none",
  21685. "@media (min-width: 600px)": {
  21686. display: "block",
  21687. position: "absolute",
  21688. fontSize: theme.typography.size.s1,
  21689. border: 0,
  21690. width: 1,
  21691. height: 1,
  21692. padding: 0,
  21693. margin: -1,
  21694. overflow: "hidden",
  21695. clip: "rect(0, 0, 0, 0)",
  21696. whiteSpace: "nowrap",
  21697. wordWrap: "normal",
  21698. opacity: 0,
  21699. transition: "opacity 150ms ease-out",
  21700. "&:focus": {
  21701. width: "100%",
  21702. height: "inherit",
  21703. padding: "10px 15px",
  21704. margin: 0,
  21705. clip: "unset",
  21706. overflow: "unset",
  21707. opacity: 1,
  21708. zIndex: 3
  21709. }
  21710. }
  21711. })), Heading2 = ({
  21712. menuHighlighted = !1,
  21713. menu,
  21714. skipLinkHref,
  21715. isLoading,
  21716. onMenuClick,
  21717. ...props
  21718. }) => react_default.createElement(HeadingWrapper, { ...props }, skipLinkHref && react_default.createElement(SkipToCanvasLink, { ariaLabel: !1, asChild: !0 }, react_default.createElement("a", { href: skipLinkHref, tabIndex: 0 }, "Skip to content")), react_default.createElement(BrandArea, null, react_default.createElement(Brand, null)), react_default.createElement(SidebarMenu, { menu, isHighlighted: menuHighlighted, onClick: onMenuClick }));
  21719. // src/manager/components/sidebar/Search.tsx
  21720. init_react();
  21721. // ../../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
  21722. function _objectWithoutPropertiesLoose2(r4, e2) {
  21723. if (r4 == null) return {};
  21724. var t2 = {};
  21725. for (var n3 in r4) if ({}.hasOwnProperty.call(r4, n3)) {
  21726. if (e2.indexOf(n3) !== -1) continue;
  21727. t2[n3] = r4[n3];
  21728. }
  21729. return t2;
  21730. }
  21731. // ../../node_modules/downshift/dist/downshift.esm.js
  21732. var import_prop_types3 = __toESM(require_prop_types());
  21733. init_react();
  21734. var import_react_is = __toESM(require_react_is());
  21735. // ../../node_modules/compute-scroll-into-view/dist/index.js
  21736. var t = (t2) => typeof t2 == "object" && t2 != null && t2.nodeType === 1, e = (t2, e2) => (!e2 || t2 !== "hidden") && t2 !== "visible" && t2 !== "clip", n2 = (t2, n3) => {
  21737. if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
  21738. let o3 = getComputedStyle(t2, null);
  21739. return e(o3.overflowY, n3) || e(o3.overflowX, n3) || ((t3) => {
  21740. let e2 = ((t4) => {
  21741. if (!t4.ownerDocument || !t4.ownerDocument.defaultView) return null;
  21742. try {
  21743. return t4.ownerDocument.defaultView.frameElement;
  21744. } catch {
  21745. return null;
  21746. }
  21747. })(t3);
  21748. return !!e2 && (e2.clientHeight < t3.scrollHeight || e2.clientWidth < t3.scrollWidth);
  21749. })(t2);
  21750. }
  21751. return !1;
  21752. }, o2 = (t2, e2, n3, o3, l3, r4, i2, s2) => r4 < t2 && i2 > e2 || r4 > t2 && i2 < e2 ? 0 : r4 <= t2 && s2 <= n3 || i2 >= e2 && s2 >= n3 ? r4 - t2 - o3 : i2 > e2 && s2 < n3 || r4 < t2 && s2 > n3 ? i2 - e2 + l3 : 0, l2 = (t2) => {
  21753. let e2 = t2.parentElement;
  21754. return e2 ?? (t2.getRootNode().host || null);
  21755. }, r3 = (e2, r4) => {
  21756. var i2, s2, d2, h2;
  21757. if (typeof document > "u") return [];
  21758. let { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g2 } = r4, p2 = typeof a2 == "function" ? a2 : (t2) => t2 !== a2;
  21759. if (!t(e2)) throw new TypeError("Invalid target");
  21760. let m2 = document.scrollingElement || document.documentElement, w2 = [], W2 = e2;
  21761. for (; t(W2) && p2(W2); ) {
  21762. if (W2 = l2(W2), W2 === m2) {
  21763. w2.push(W2);
  21764. break;
  21765. }
  21766. W2 != null && W2 === document.body && n2(W2) && !n2(document.documentElement) || W2 != null && n2(W2, g2) && w2.push(W2);
  21767. }
  21768. let b2 = (s2 = (i2 = window.visualViewport) == null ? void 0 : i2.width) != null ? s2 : innerWidth, H7 = (h2 = (d2 = window.visualViewport) == null ? void 0 : d2.height) != null ? h2 : innerHeight, { scrollX: y2, scrollY: M2 } = window, { height: v2, width: E2, top: x2, right: C2, bottom: I2, left: R2 } = e2.getBoundingClientRect(), { top: T3, right: B2, bottom: F2, left: V } = ((t2) => {
  21769. let e3 = window.getComputedStyle(t2);
  21770. return { top: parseFloat(e3.scrollMarginTop) || 0, right: parseFloat(e3.scrollMarginRight) || 0, bottom: parseFloat(e3.scrollMarginBottom) || 0, left: parseFloat(e3.scrollMarginLeft) || 0 };
  21771. })(e2), k2 = f2 === "start" || f2 === "nearest" ? x2 - T3 : f2 === "end" ? I2 + F2 : x2 + v2 / 2 - T3 + F2, D2 = u2 === "center" ? R2 + E2 / 2 - V + B2 : u2 === "end" ? C2 + B2 : R2 - V, L3 = [];
  21772. for (let t2 = 0; t2 < w2.length; t2++) {
  21773. let e3 = w2[t2], { height: l3, width: r5, top: i3, right: s3, bottom: d3, left: h3 } = e3.getBoundingClientRect();
  21774. if (c2 === "if-needed" && x2 >= 0 && R2 >= 0 && I2 <= H7 && C2 <= b2 && (e3 === m2 && !n2(e3) || x2 >= i3 && I2 <= d3 && R2 >= h3 && C2 <= s3)) return L3;
  21775. let a3 = getComputedStyle(e3), g3 = parseInt(a3.borderLeftWidth, 10), p3 = parseInt(a3.borderTopWidth, 10), W3 = parseInt(a3.borderRightWidth, 10), T4 = parseInt(a3.borderBottomWidth, 10), B3 = 0, F3 = 0, V2 = "offsetWidth" in e3 ? e3.offsetWidth - e3.clientWidth - g3 - W3 : 0, S2 = "offsetHeight" in e3 ? e3.offsetHeight - e3.clientHeight - p3 - T4 : 0, X = "offsetWidth" in e3 ? e3.offsetWidth === 0 ? 0 : r5 / e3.offsetWidth : 0, Y2 = "offsetHeight" in e3 ? e3.offsetHeight === 0 ? 0 : l3 / e3.offsetHeight : 0;
  21776. if (m2 === e3) B3 = f2 === "start" ? k2 : f2 === "end" ? k2 - H7 : f2 === "nearest" ? o2(M2, M2 + H7, H7, p3, T4, M2 + k2, M2 + k2 + v2, v2) : k2 - H7 / 2, F3 = u2 === "start" ? D2 : u2 === "center" ? D2 - b2 / 2 : u2 === "end" ? D2 - b2 : o2(y2, y2 + b2, b2, g3, W3, y2 + D2, y2 + D2 + E2, E2), B3 = Math.max(0, B3 + M2), F3 = Math.max(0, F3 + y2);
  21777. else {
  21778. B3 = f2 === "start" ? k2 - i3 - p3 : f2 === "end" ? k2 - d3 + T4 + S2 : f2 === "nearest" ? o2(i3, d3, l3, p3, T4 + S2, k2, k2 + v2, v2) : k2 - (i3 + l3 / 2) + S2 / 2, F3 = u2 === "start" ? D2 - h3 - g3 : u2 === "center" ? D2 - (h3 + r5 / 2) + V2 / 2 : u2 === "end" ? D2 - s3 + W3 + V2 : o2(h3, s3, r5, g3, W3 + V2, D2, D2 + E2, E2);
  21779. let { scrollLeft: t3, scrollTop: n3 } = e3;
  21780. B3 = Y2 === 0 ? 0 : Math.max(0, Math.min(n3 + B3 / Y2, e3.scrollHeight - l3 / Y2 + S2)), F3 = X === 0 ? 0 : Math.max(0, Math.min(t3 + F3 / X, e3.scrollWidth - r5 / X + V2)), k2 += n3 - B3, D2 += t3 - F3;
  21781. }
  21782. L3.push({ el: e3, top: B3, left: F3 });
  21783. }
  21784. return L3;
  21785. };
  21786. // ../../node_modules/downshift/dist/downshift.esm.js
  21787. var idCounter = 0;
  21788. function cbToCb(cb) {
  21789. return typeof cb == "function" ? cb : noop4;
  21790. }
  21791. function noop4() {
  21792. }
  21793. function scrollIntoView2(node, menuNode) {
  21794. if (node) {
  21795. var actions = r3(node, {
  21796. boundary: menuNode,
  21797. block: "nearest",
  21798. scrollMode: "if-needed"
  21799. });
  21800. actions.forEach(function(_ref) {
  21801. var el = _ref.el, top = _ref.top, left = _ref.left;
  21802. el.scrollTop = top, el.scrollLeft = left;
  21803. });
  21804. }
  21805. }
  21806. function isOrContainsNode(parent, child, environment) {
  21807. var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
  21808. return result;
  21809. }
  21810. function debounce4(fn, time) {
  21811. var timeoutId;
  21812. function cancel() {
  21813. timeoutId && clearTimeout(timeoutId);
  21814. }
  21815. function wrapper() {
  21816. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
  21817. args[_key] = arguments[_key];
  21818. cancel(), timeoutId = setTimeout(function() {
  21819. timeoutId = null, fn.apply(void 0, args);
  21820. }, time);
  21821. }
  21822. return wrapper.cancel = cancel, wrapper;
  21823. }
  21824. function callAllEventHandlers() {
  21825. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++)
  21826. fns[_key2] = arguments[_key2];
  21827. return function(event) {
  21828. for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++)
  21829. args[_key3 - 1] = arguments[_key3];
  21830. return fns.some(function(fn) {
  21831. return fn && fn.apply(void 0, [event].concat(args)), event.preventDownshiftDefault || event.hasOwnProperty("nativeEvent") && event.nativeEvent.preventDownshiftDefault;
  21832. });
  21833. };
  21834. }
  21835. function handleRefs() {
  21836. for (var _len4 = arguments.length, refs = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++)
  21837. refs[_key4] = arguments[_key4];
  21838. return function(node) {
  21839. refs.forEach(function(ref) {
  21840. typeof ref == "function" ? ref(node) : ref && (ref.current = node);
  21841. });
  21842. };
  21843. }
  21844. function generateId() {
  21845. return String(idCounter++);
  21846. }
  21847. function getA11yStatusMessage(_ref2) {
  21848. var isOpen = _ref2.isOpen, resultCount = _ref2.resultCount, previousResultCount = _ref2.previousResultCount;
  21849. return isOpen ? resultCount ? resultCount !== previousResultCount ? resultCount + " result" + (resultCount === 1 ? " is" : "s are") + " available, use up and down arrow keys to navigate. Press Enter key to select." : "" : "No results are available." : "";
  21850. }
  21851. function unwrapArray(arg, defaultValue) {
  21852. return arg = Array.isArray(arg) ? (
  21853. /* istanbul ignore next (preact) */
  21854. arg[0]
  21855. ) : arg, !arg && defaultValue ? defaultValue : arg;
  21856. }
  21857. function isDOMElement(element) {
  21858. return typeof element.type == "string";
  21859. }
  21860. function getElementProps(element) {
  21861. return element.props;
  21862. }
  21863. var stateKeys = ["highlightedIndex", "inputValue", "isOpen", "selectedItem", "type"];
  21864. function pickState(state) {
  21865. state === void 0 && (state = {});
  21866. var result = {};
  21867. return stateKeys.forEach(function(k2) {
  21868. state.hasOwnProperty(k2) && (result[k2] = state[k2]);
  21869. }), result;
  21870. }
  21871. function getState2(state, props) {
  21872. return !state || !props ? state : Object.keys(state).reduce(function(prevState, key) {
  21873. return prevState[key] = isControlledProp(props, key) ? props[key] : state[key], prevState;
  21874. }, {});
  21875. }
  21876. function isControlledProp(props, key) {
  21877. return props[key] !== void 0;
  21878. }
  21879. function normalizeArrowKey(event) {
  21880. var key = event.key, keyCode = event.keyCode;
  21881. return keyCode >= 37 && keyCode <= 40 && key.indexOf("Arrow") !== 0 ? "Arrow" + key : key;
  21882. }
  21883. function getHighlightedIndex(start, offset2, items, isItemDisabled2, circular) {
  21884. circular === void 0 && (circular = !1);
  21885. var count = items.length;
  21886. if (count === 0)
  21887. return -1;
  21888. var itemsLastIndex = count - 1;
  21889. (typeof start != "number" || start < 0 || start > itemsLastIndex) && (start = offset2 > 0 ? -1 : itemsLastIndex + 1);
  21890. var current = start + offset2;
  21891. current < 0 ? current = circular ? itemsLastIndex : 0 : current > itemsLastIndex && (current = circular ? 0 : itemsLastIndex);
  21892. var highlightedIndex = getNonDisabledIndex(current, offset2 < 0, items, isItemDisabled2, circular);
  21893. return highlightedIndex === -1 ? start >= count ? -1 : start : highlightedIndex;
  21894. }
  21895. function getNonDisabledIndex(start, backwards, items, isItemDisabled2, circular) {
  21896. circular === void 0 && (circular = !1);
  21897. var count = items.length;
  21898. if (backwards) {
  21899. for (var index = start; index >= 0; index--)
  21900. if (!isItemDisabled2(items[index], index))
  21901. return index;
  21902. } else
  21903. for (var _index = start; _index < count; _index++)
  21904. if (!isItemDisabled2(items[_index], _index))
  21905. return _index;
  21906. return circular ? getNonDisabledIndex(backwards ? count - 1 : 0, backwards, items, isItemDisabled2) : -1;
  21907. }
  21908. function targetWithinDownshift(target, downshiftElements, environment, checkActiveElement) {
  21909. return checkActiveElement === void 0 && (checkActiveElement = !0), environment && downshiftElements.some(function(contextNode) {
  21910. return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
  21911. });
  21912. }
  21913. var cleanupStatus = debounce4(function(documentProp) {
  21914. getStatusDiv(documentProp).textContent = "";
  21915. }, 500);
  21916. function getStatusDiv(documentProp) {
  21917. var statusDiv = documentProp.getElementById("a11y-status-message");
  21918. return statusDiv || (statusDiv = documentProp.createElement("div"), statusDiv.setAttribute("id", "a11y-status-message"), statusDiv.setAttribute("role", "status"), statusDiv.setAttribute("aria-live", "polite"), statusDiv.setAttribute("aria-relevant", "additions text"), Object.assign(statusDiv.style, {
  21919. border: "0",
  21920. clip: "rect(0 0 0 0)",
  21921. height: "1px",
  21922. margin: "-1px",
  21923. overflow: "hidden",
  21924. padding: "0",
  21925. position: "absolute",
  21926. width: "1px"
  21927. }), documentProp.body.appendChild(statusDiv), statusDiv);
  21928. }
  21929. function setStatus(status, documentProp) {
  21930. if (!(!status || !documentProp)) {
  21931. var div = getStatusDiv(documentProp);
  21932. div.textContent = status, cleanupStatus(documentProp);
  21933. }
  21934. }
  21935. function cleanupStatusDiv(documentProp) {
  21936. var statusDiv = documentProp?.getElementById("a11y-status-message");
  21937. statusDiv && statusDiv.remove();
  21938. }
  21939. var unknown = 0, mouseUp = 1, itemMouseEnter = 2, keyDownArrowUp = 3, keyDownArrowDown = 4, keyDownEscape = 5, keyDownEnter = 6, keyDownHome = 7, keyDownEnd = 8, clickItem = 9, blurInput = 10, changeInput = 11, keyDownSpaceButton = 12, clickButton = 13, blurButton = 14, controlledPropUpdatedSelectedItem = 15, touchEnd = 16, stateChangeTypes$3 = Object.freeze({
  21940. __proto__: null,
  21941. blurButton,
  21942. blurInput,
  21943. changeInput,
  21944. clickButton,
  21945. clickItem,
  21946. controlledPropUpdatedSelectedItem,
  21947. itemMouseEnter,
  21948. keyDownArrowDown,
  21949. keyDownArrowUp,
  21950. keyDownEnd,
  21951. keyDownEnter,
  21952. keyDownEscape,
  21953. keyDownHome,
  21954. keyDownSpaceButton,
  21955. mouseUp,
  21956. touchEnd,
  21957. unknown
  21958. }), _excluded$3 = ["refKey", "ref"], _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"], _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"], _excluded4$2 = ["refKey", "ref"], _excluded5 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"], Downshift = (function() {
  21959. var Downshift2 = (function(_Component) {
  21960. function Downshift3(_props) {
  21961. var _this;
  21962. _this = _Component.call(this, _props) || this, _this.id = _this.props.id || "downshift-" + generateId(), _this.menuId = _this.props.menuId || _this.id + "-menu", _this.labelId = _this.props.labelId || _this.id + "-label", _this.inputId = _this.props.inputId || _this.id + "-input", _this.getItemId = _this.props.getItemId || function(index) {
  21963. return _this.id + "-item-" + index;
  21964. }, _this.items = [], _this.itemCount = null, _this.previousResultCount = 0, _this.timeoutIds = [], _this.internalSetTimeout = function(fn, time) {
  21965. var id = setTimeout(function() {
  21966. _this.timeoutIds = _this.timeoutIds.filter(function(i2) {
  21967. return i2 !== id;
  21968. }), fn();
  21969. }, time);
  21970. _this.timeoutIds.push(id);
  21971. }, _this.setItemCount = function(count) {
  21972. _this.itemCount = count;
  21973. }, _this.unsetItemCount = function() {
  21974. _this.itemCount = null;
  21975. }, _this.isItemDisabled = function(_item, index) {
  21976. var currentElementNode = _this.getItemNodeFromIndex(index);
  21977. return currentElementNode && currentElementNode.hasAttribute("disabled");
  21978. }, _this.setHighlightedIndex = function(highlightedIndex, otherStateToSet) {
  21979. highlightedIndex === void 0 && (highlightedIndex = _this.props.defaultHighlightedIndex), otherStateToSet === void 0 && (otherStateToSet = {}), otherStateToSet = pickState(otherStateToSet), _this.internalSetState(_extends({
  21980. highlightedIndex
  21981. }, otherStateToSet));
  21982. }, _this.clearSelection = function(cb) {
  21983. _this.internalSetState({
  21984. selectedItem: null,
  21985. inputValue: "",
  21986. highlightedIndex: _this.props.defaultHighlightedIndex,
  21987. isOpen: _this.props.defaultIsOpen
  21988. }, cb);
  21989. }, _this.selectItem = function(item, otherStateToSet, cb) {
  21990. otherStateToSet = pickState(otherStateToSet), _this.internalSetState(_extends({
  21991. isOpen: _this.props.defaultIsOpen,
  21992. highlightedIndex: _this.props.defaultHighlightedIndex,
  21993. selectedItem: item,
  21994. inputValue: _this.props.itemToString(item)
  21995. }, otherStateToSet), cb);
  21996. }, _this.selectItemAtIndex = function(itemIndex, otherStateToSet, cb) {
  21997. var item = _this.items[itemIndex];
  21998. item != null && _this.selectItem(item, otherStateToSet, cb);
  21999. }, _this.selectHighlightedItem = function(otherStateToSet, cb) {
  22000. return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
  22001. }, _this.internalSetState = function(stateToSet, cb) {
  22002. var isItemSelected, onChangeArg, onStateChangeArg = {}, isStateToSetFunction = typeof stateToSet == "function";
  22003. return !isStateToSetFunction && stateToSet.hasOwnProperty("inputValue") && _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet)), _this.setState(function(state) {
  22004. var _newStateToSet;
  22005. state = _this.getState(state);
  22006. var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
  22007. newStateToSet = _this.props.stateReducer(state, newStateToSet), isItemSelected = newStateToSet.hasOwnProperty("selectedItem");
  22008. var nextState = {};
  22009. return isItemSelected && newStateToSet.selectedItem !== state.selectedItem && (onChangeArg = newStateToSet.selectedItem), (_newStateToSet = newStateToSet).type || (_newStateToSet.type = unknown), Object.keys(newStateToSet).forEach(function(key) {
  22010. state[key] !== newStateToSet[key] && (onStateChangeArg[key] = newStateToSet[key]), key !== "type" && (newStateToSet[key], isControlledProp(_this.props, key) || (nextState[key] = newStateToSet[key]));
  22011. }), isStateToSetFunction && newStateToSet.hasOwnProperty("inputValue") && _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet)), nextState;
  22012. }, function() {
  22013. cbToCb(cb)();
  22014. var hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
  22015. hasMoreStateThanType && _this.props.onStateChange(onStateChangeArg, _this.getStateAndHelpers()), isItemSelected && _this.props.onSelect(stateToSet.selectedItem, _this.getStateAndHelpers()), onChangeArg !== void 0 && _this.props.onChange(onChangeArg, _this.getStateAndHelpers()), _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
  22016. });
  22017. }, _this.rootRef = function(node) {
  22018. return _this._rootNode = node;
  22019. }, _this.getRootProps = function(_temp, _temp2) {
  22020. var _extends22, _ref = _temp === void 0 ? {} : _temp, _ref$refKey = _ref.refKey, refKey = _ref$refKey === void 0 ? "ref" : _ref$refKey, ref = _ref.ref, rest2 = _objectWithoutPropertiesLoose2(_ref, _excluded$3), _ref2 = _temp2 === void 0 ? {} : _temp2, _ref2$suppressRefErro = _ref2.suppressRefError, suppressRefError = _ref2$suppressRefErro === void 0 ? !1 : _ref2$suppressRefErro;
  22021. _this.getRootProps.called = !0, _this.getRootProps.refKey = refKey, _this.getRootProps.suppressRefError = suppressRefError;
  22022. var _this$getState = _this.getState(), isOpen = _this$getState.isOpen;
  22023. return _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, _this.rootRef), _extends22.role = "combobox", _extends22["aria-expanded"] = isOpen, _extends22["aria-haspopup"] = "listbox", _extends22["aria-owns"] = isOpen ? _this.menuId : void 0, _extends22["aria-labelledby"] = _this.labelId, _extends22), rest2);
  22024. }, _this.keyDownHandlers = {
  22025. ArrowDown: function(event) {
  22026. var _this2 = this;
  22027. if (event.preventDefault(), this.getState().isOpen) {
  22028. var amount = event.shiftKey ? 5 : 1;
  22029. this.moveHighlightedIndex(amount, {
  22030. type: keyDownArrowDown
  22031. });
  22032. } else
  22033. this.internalSetState({
  22034. isOpen: !0,
  22035. type: keyDownArrowDown
  22036. }, function() {
  22037. var itemCount = _this2.getItemCount();
  22038. if (itemCount > 0) {
  22039. var _this2$getState = _this2.getState(), highlightedIndex = _this2$getState.highlightedIndex, nextHighlightedIndex = getHighlightedIndex(highlightedIndex, 1, {
  22040. length: itemCount
  22041. }, _this2.isItemDisabled, !0);
  22042. _this2.setHighlightedIndex(nextHighlightedIndex, {
  22043. type: keyDownArrowDown
  22044. });
  22045. }
  22046. });
  22047. },
  22048. ArrowUp: function(event) {
  22049. var _this3 = this;
  22050. if (event.preventDefault(), this.getState().isOpen) {
  22051. var amount = event.shiftKey ? -5 : -1;
  22052. this.moveHighlightedIndex(amount, {
  22053. type: keyDownArrowUp
  22054. });
  22055. } else
  22056. this.internalSetState({
  22057. isOpen: !0,
  22058. type: keyDownArrowUp
  22059. }, function() {
  22060. var itemCount = _this3.getItemCount();
  22061. if (itemCount > 0) {
  22062. var _this3$getState = _this3.getState(), highlightedIndex = _this3$getState.highlightedIndex, nextHighlightedIndex = getHighlightedIndex(highlightedIndex, -1, {
  22063. length: itemCount
  22064. }, _this3.isItemDisabled, !0);
  22065. _this3.setHighlightedIndex(nextHighlightedIndex, {
  22066. type: keyDownArrowUp
  22067. });
  22068. }
  22069. });
  22070. },
  22071. Enter: function(event) {
  22072. if (event.which !== 229) {
  22073. var _this$getState2 = this.getState(), isOpen = _this$getState2.isOpen, highlightedIndex = _this$getState2.highlightedIndex;
  22074. if (isOpen && highlightedIndex != null) {
  22075. event.preventDefault();
  22076. var item = this.items[highlightedIndex], itemNode = this.getItemNodeFromIndex(highlightedIndex);
  22077. if (item == null || itemNode && itemNode.hasAttribute("disabled"))
  22078. return;
  22079. this.selectHighlightedItem({
  22080. type: keyDownEnter
  22081. });
  22082. }
  22083. }
  22084. },
  22085. Escape: function(event) {
  22086. event.preventDefault(), this.reset(_extends({
  22087. type: keyDownEscape
  22088. }, !this.state.isOpen && {
  22089. selectedItem: null,
  22090. inputValue: ""
  22091. }));
  22092. }
  22093. }, _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
  22094. " ": function(event) {
  22095. event.preventDefault(), this.toggleMenu({
  22096. type: keyDownSpaceButton
  22097. });
  22098. }
  22099. }), _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
  22100. Home: function(event) {
  22101. var _this$getState3 = this.getState(), isOpen = _this$getState3.isOpen;
  22102. if (isOpen) {
  22103. event.preventDefault();
  22104. var itemCount = this.getItemCount();
  22105. if (!(itemCount <= 0 || !isOpen)) {
  22106. var newHighlightedIndex = getNonDisabledIndex(0, !1, {
  22107. length: itemCount
  22108. }, this.isItemDisabled);
  22109. this.setHighlightedIndex(newHighlightedIndex, {
  22110. type: keyDownHome
  22111. });
  22112. }
  22113. }
  22114. },
  22115. End: function(event) {
  22116. var _this$getState4 = this.getState(), isOpen = _this$getState4.isOpen;
  22117. if (isOpen) {
  22118. event.preventDefault();
  22119. var itemCount = this.getItemCount();
  22120. if (!(itemCount <= 0 || !isOpen)) {
  22121. var newHighlightedIndex = getNonDisabledIndex(itemCount - 1, !0, {
  22122. length: itemCount
  22123. }, this.isItemDisabled);
  22124. this.setHighlightedIndex(newHighlightedIndex, {
  22125. type: keyDownEnd
  22126. });
  22127. }
  22128. }
  22129. }
  22130. }), _this.getToggleButtonProps = function(_temp3) {
  22131. var _ref3 = _temp3 === void 0 ? {} : _temp3, onClick = _ref3.onClick;
  22132. _ref3.onPress;
  22133. var onKeyDown = _ref3.onKeyDown, onKeyUp = _ref3.onKeyUp, onBlur = _ref3.onBlur, rest2 = _objectWithoutPropertiesLoose2(_ref3, _excluded2$3), _this$getState5 = _this.getState(), isOpen = _this$getState5.isOpen, enabledEventHandlers = {
  22134. onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
  22135. onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
  22136. onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
  22137. onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
  22138. }, eventHandlers = rest2.disabled ? {} : enabledEventHandlers;
  22139. return _extends({
  22140. type: "button",
  22141. role: "button",
  22142. "aria-label": isOpen ? "close menu" : "open menu",
  22143. "aria-haspopup": !0,
  22144. "data-toggle": !0
  22145. }, eventHandlers, rest2);
  22146. }, _this.buttonHandleKeyUp = function(event) {
  22147. event.preventDefault();
  22148. }, _this.buttonHandleKeyDown = function(event) {
  22149. var key = normalizeArrowKey(event);
  22150. _this.buttonKeyDownHandlers[key] && _this.buttonKeyDownHandlers[key].call(_this, event);
  22151. }, _this.buttonHandleClick = function(event) {
  22152. if (event.preventDefault(), _this.props.environment) {
  22153. var _this$props$environme = _this.props.environment.document, body = _this$props$environme.body, activeElement = _this$props$environme.activeElement;
  22154. body && body === activeElement && event.target.focus();
  22155. }
  22156. _this.internalSetTimeout(function() {
  22157. return _this.toggleMenu({
  22158. type: clickButton
  22159. });
  22160. });
  22161. }, _this.buttonHandleBlur = function(event) {
  22162. var blurTarget = event.target;
  22163. _this.internalSetTimeout(function() {
  22164. if (!(_this.isMouseDown || !_this.props.environment)) {
  22165. var activeElement = _this.props.environment.document.activeElement;
  22166. (activeElement == null || activeElement.id !== _this.inputId) && activeElement !== blurTarget && _this.reset({
  22167. type: blurButton
  22168. });
  22169. }
  22170. });
  22171. }, _this.getLabelProps = function(props) {
  22172. return _extends({
  22173. htmlFor: _this.inputId,
  22174. id: _this.labelId
  22175. }, props);
  22176. }, _this.getInputProps = function(_temp4) {
  22177. var _ref4 = _temp4 === void 0 ? {} : _temp4, onKeyDown = _ref4.onKeyDown, onBlur = _ref4.onBlur, onChange = _ref4.onChange, onInput = _ref4.onInput;
  22178. _ref4.onChangeText;
  22179. var rest2 = _objectWithoutPropertiesLoose2(_ref4, _excluded3$2), onChangeKey, eventHandlers = {};
  22180. onChangeKey = "onChange";
  22181. var _this$getState6 = _this.getState(), inputValue = _this$getState6.inputValue, isOpen = _this$getState6.isOpen, highlightedIndex = _this$getState6.highlightedIndex;
  22182. if (!rest2.disabled) {
  22183. var _eventHandlers;
  22184. eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
  22185. }
  22186. return _extends({
  22187. "aria-autocomplete": "list",
  22188. "aria-activedescendant": isOpen && typeof highlightedIndex == "number" && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : void 0,
  22189. "aria-controls": isOpen ? _this.menuId : void 0,
  22190. "aria-labelledby": rest2 && rest2["aria-label"] ? void 0 : _this.labelId,
  22191. // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
  22192. // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
  22193. autoComplete: "off",
  22194. value: inputValue,
  22195. id: _this.inputId
  22196. }, eventHandlers, rest2);
  22197. }, _this.inputHandleKeyDown = function(event) {
  22198. var key = normalizeArrowKey(event);
  22199. key && _this.inputKeyDownHandlers[key] && _this.inputKeyDownHandlers[key].call(_this, event);
  22200. }, _this.inputHandleChange = function(event) {
  22201. _this.internalSetState({
  22202. type: changeInput,
  22203. isOpen: !0,
  22204. inputValue: event.target.value,
  22205. highlightedIndex: _this.props.defaultHighlightedIndex
  22206. });
  22207. }, _this.inputHandleBlur = function() {
  22208. _this.internalSetTimeout(function() {
  22209. var _activeElement$datase;
  22210. if (!(_this.isMouseDown || !_this.props.environment)) {
  22211. var activeElement = _this.props.environment.document.activeElement, downshiftButtonIsActive = (activeElement == null || (_activeElement$datase = activeElement.dataset) == null ? void 0 : _activeElement$datase.toggle) && _this._rootNode && _this._rootNode.contains(activeElement);
  22212. downshiftButtonIsActive || _this.reset({
  22213. type: blurInput
  22214. });
  22215. }
  22216. });
  22217. }, _this.menuRef = function(node) {
  22218. _this._menuNode = node;
  22219. }, _this.getMenuProps = function(_temp5, _temp6) {
  22220. var _extends3, _ref5 = _temp5 === void 0 ? {} : _temp5, _ref5$refKey = _ref5.refKey, refKey = _ref5$refKey === void 0 ? "ref" : _ref5$refKey, ref = _ref5.ref, props = _objectWithoutPropertiesLoose2(_ref5, _excluded4$2), _ref6 = _temp6 === void 0 ? {} : _temp6, _ref6$suppressRefErro = _ref6.suppressRefError, suppressRefError = _ref6$suppressRefErro === void 0 ? !1 : _ref6$suppressRefErro;
  22221. return _this.getMenuProps.called = !0, _this.getMenuProps.refKey = refKey, _this.getMenuProps.suppressRefError = suppressRefError, _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = "listbox", _extends3["aria-labelledby"] = props && props["aria-label"] ? void 0 : _this.labelId, _extends3.id = _this.menuId, _extends3), props);
  22222. }, _this.getItemProps = function(_temp7) {
  22223. var _enabledEventHandlers, _ref7 = _temp7 === void 0 ? {} : _temp7, onMouseMove = _ref7.onMouseMove, onMouseDown = _ref7.onMouseDown, onClick = _ref7.onClick;
  22224. _ref7.onPress;
  22225. var index = _ref7.index, _ref7$item = _ref7.item, item = _ref7$item === void 0 ? (
  22226. /* istanbul ignore next */
  22227. void 0
  22228. ) : _ref7$item, rest2 = _objectWithoutPropertiesLoose2(_ref7, _excluded5);
  22229. index === void 0 ? (_this.items.push(item), index = _this.items.indexOf(item)) : _this.items[index] = item;
  22230. var onSelectKey = "onClick", customClickHandler = onClick, enabledEventHandlers = (_enabledEventHandlers = {
  22231. // onMouseMove is used over onMouseEnter here. onMouseMove
  22232. // is only triggered on actual mouse movement while onMouseEnter
  22233. // can fire on DOM changes, interrupting keyboard navigation
  22234. onMouseMove: callAllEventHandlers(onMouseMove, function() {
  22235. index !== _this.getState().highlightedIndex && (_this.setHighlightedIndex(index, {
  22236. type: itemMouseEnter
  22237. }), _this.avoidScrolling = !0, _this.internalSetTimeout(function() {
  22238. return _this.avoidScrolling = !1;
  22239. }, 250));
  22240. }),
  22241. onMouseDown: callAllEventHandlers(onMouseDown, function(event) {
  22242. event.preventDefault();
  22243. })
  22244. }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function() {
  22245. _this.selectItemAtIndex(index, {
  22246. type: clickItem
  22247. });
  22248. }), _enabledEventHandlers), eventHandlers = rest2.disabled ? {
  22249. onMouseDown: enabledEventHandlers.onMouseDown
  22250. } : enabledEventHandlers;
  22251. return _extends({
  22252. id: _this.getItemId(index),
  22253. role: "option",
  22254. "aria-selected": _this.getState().highlightedIndex === index
  22255. }, eventHandlers, rest2);
  22256. }, _this.clearItems = function() {
  22257. _this.items = [];
  22258. }, _this.reset = function(otherStateToSet, cb) {
  22259. otherStateToSet === void 0 && (otherStateToSet = {}), otherStateToSet = pickState(otherStateToSet), _this.internalSetState(function(_ref8) {
  22260. var selectedItem = _ref8.selectedItem;
  22261. return _extends({
  22262. isOpen: _this.props.defaultIsOpen,
  22263. highlightedIndex: _this.props.defaultHighlightedIndex,
  22264. inputValue: _this.props.itemToString(selectedItem)
  22265. }, otherStateToSet);
  22266. }, cb);
  22267. }, _this.toggleMenu = function(otherStateToSet, cb) {
  22268. otherStateToSet === void 0 && (otherStateToSet = {}), otherStateToSet = pickState(otherStateToSet), _this.internalSetState(function(_ref9) {
  22269. var isOpen = _ref9.isOpen;
  22270. return _extends({
  22271. isOpen: !isOpen
  22272. }, isOpen && {
  22273. highlightedIndex: _this.props.defaultHighlightedIndex
  22274. }, otherStateToSet);
  22275. }, function() {
  22276. var _this$getState7 = _this.getState(), isOpen = _this$getState7.isOpen, highlightedIndex = _this$getState7.highlightedIndex;
  22277. isOpen && _this.getItemCount() > 0 && typeof highlightedIndex == "number" && _this.setHighlightedIndex(highlightedIndex, otherStateToSet), cbToCb(cb)();
  22278. });
  22279. }, _this.openMenu = function(cb) {
  22280. _this.internalSetState({
  22281. isOpen: !0
  22282. }, cb);
  22283. }, _this.closeMenu = function(cb) {
  22284. _this.internalSetState({
  22285. isOpen: !1
  22286. }, cb);
  22287. }, _this.updateStatus = debounce4(function() {
  22288. var _this$props;
  22289. if ((_this$props = _this.props) != null && (_this$props = _this$props.environment) != null && _this$props.document) {
  22290. var state = _this.getState(), item = _this.items[state.highlightedIndex], resultCount = _this.getItemCount(), status = _this.props.getA11yStatusMessage(_extends({
  22291. itemToString: _this.props.itemToString,
  22292. previousResultCount: _this.previousResultCount,
  22293. resultCount,
  22294. highlightedItem: item
  22295. }, state));
  22296. _this.previousResultCount = resultCount, setStatus(status, _this.props.environment.document);
  22297. }
  22298. }, 200);
  22299. var _this$props2 = _this.props, defaultHighlightedIndex = _this$props2.defaultHighlightedIndex, _this$props2$initialH = _this$props2.initialHighlightedIndex, _highlightedIndex = _this$props2$initialH === void 0 ? defaultHighlightedIndex : _this$props2$initialH, defaultIsOpen = _this$props2.defaultIsOpen, _this$props2$initialI = _this$props2.initialIsOpen, _isOpen = _this$props2$initialI === void 0 ? defaultIsOpen : _this$props2$initialI, _this$props2$initialI2 = _this$props2.initialInputValue, _inputValue = _this$props2$initialI2 === void 0 ? "" : _this$props2$initialI2, _this$props2$initialS = _this$props2.initialSelectedItem, _selectedItem = _this$props2$initialS === void 0 ? null : _this$props2$initialS, _state = _this.getState({
  22300. highlightedIndex: _highlightedIndex,
  22301. isOpen: _isOpen,
  22302. inputValue: _inputValue,
  22303. selectedItem: _selectedItem
  22304. });
  22305. return _state.selectedItem != null && _this.props.initialInputValue === void 0 && (_state.inputValue = _this.props.itemToString(_state.selectedItem)), _this.state = _state, _this;
  22306. }
  22307. _inheritsLoose(Downshift3, _Component);
  22308. var _proto = Downshift3.prototype;
  22309. return _proto.internalClearTimeouts = function() {
  22310. this.timeoutIds.forEach(function(id) {
  22311. clearTimeout(id);
  22312. }), this.timeoutIds = [];
  22313. }, _proto.getState = function(stateToMerge) {
  22314. return stateToMerge === void 0 && (stateToMerge = this.state), getState2(stateToMerge, this.props);
  22315. }, _proto.getItemCount = function() {
  22316. var itemCount = this.items.length;
  22317. return this.itemCount != null ? itemCount = this.itemCount : this.props.itemCount !== void 0 && (itemCount = this.props.itemCount), itemCount;
  22318. }, _proto.getItemNodeFromIndex = function(index) {
  22319. return this.props.environment ? this.props.environment.document.getElementById(this.getItemId(index)) : null;
  22320. }, _proto.scrollHighlightedItemIntoView = function() {
  22321. {
  22322. var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
  22323. this.props.scrollIntoView(node, this._menuNode);
  22324. }
  22325. }, _proto.moveHighlightedIndex = function(amount, otherStateToSet) {
  22326. var itemCount = this.getItemCount(), _this$getState8 = this.getState(), highlightedIndex = _this$getState8.highlightedIndex;
  22327. if (itemCount > 0) {
  22328. var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, amount, {
  22329. length: itemCount
  22330. }, this.isItemDisabled, !0);
  22331. this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
  22332. }
  22333. }, _proto.getStateAndHelpers = function() {
  22334. var _this$getState9 = this.getState(), highlightedIndex = _this$getState9.highlightedIndex, inputValue = _this$getState9.inputValue, selectedItem = _this$getState9.selectedItem, isOpen = _this$getState9.isOpen, itemToString2 = this.props.itemToString, id = this.id, getRootProps = this.getRootProps, getToggleButtonProps = this.getToggleButtonProps, getLabelProps = this.getLabelProps, getMenuProps = this.getMenuProps, getInputProps = this.getInputProps, getItemProps = this.getItemProps, openMenu = this.openMenu, closeMenu = this.closeMenu, toggleMenu = this.toggleMenu, selectItem = this.selectItem, selectItemAtIndex = this.selectItemAtIndex, selectHighlightedItem = this.selectHighlightedItem, setHighlightedIndex = this.setHighlightedIndex, clearSelection = this.clearSelection, clearItems = this.clearItems, reset = this.reset, setItemCount = this.setItemCount, unsetItemCount = this.unsetItemCount, setState = this.internalSetState;
  22335. return {
  22336. // prop getters
  22337. getRootProps,
  22338. getToggleButtonProps,
  22339. getLabelProps,
  22340. getMenuProps,
  22341. getInputProps,
  22342. getItemProps,
  22343. // actions
  22344. reset,
  22345. openMenu,
  22346. closeMenu,
  22347. toggleMenu,
  22348. selectItem,
  22349. selectItemAtIndex,
  22350. selectHighlightedItem,
  22351. setHighlightedIndex,
  22352. clearSelection,
  22353. clearItems,
  22354. setItemCount,
  22355. unsetItemCount,
  22356. setState,
  22357. // props
  22358. itemToString: itemToString2,
  22359. // derived
  22360. id,
  22361. // state
  22362. highlightedIndex,
  22363. inputValue,
  22364. isOpen,
  22365. selectedItem
  22366. };
  22367. }, _proto.componentDidMount = function() {
  22368. var _this4 = this;
  22369. if (!this.props.environment)
  22370. this.cleanup = function() {
  22371. _this4.internalClearTimeouts();
  22372. };
  22373. else {
  22374. var onMouseDown = function() {
  22375. _this4.isMouseDown = !0;
  22376. }, onMouseUp = function(event) {
  22377. _this4.isMouseDown = !1;
  22378. var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment);
  22379. !contextWithinDownshift && _this4.getState().isOpen && _this4.reset({
  22380. type: mouseUp
  22381. }, function() {
  22382. return _this4.props.onOuterClick(_this4.getStateAndHelpers());
  22383. });
  22384. }, onTouchStart = function() {
  22385. _this4.isTouchMove = !1;
  22386. }, onTouchMove = function() {
  22387. _this4.isTouchMove = !0;
  22388. }, onTouchEnd = function(event) {
  22389. var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment, !1);
  22390. !_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen && _this4.reset({
  22391. type: touchEnd
  22392. }, function() {
  22393. return _this4.props.onOuterClick(_this4.getStateAndHelpers());
  22394. });
  22395. }, environment = this.props.environment;
  22396. environment.addEventListener("mousedown", onMouseDown), environment.addEventListener("mouseup", onMouseUp), environment.addEventListener("touchstart", onTouchStart), environment.addEventListener("touchmove", onTouchMove), environment.addEventListener("touchend", onTouchEnd), this.cleanup = function() {
  22397. _this4.internalClearTimeouts(), _this4.updateStatus.cancel(), environment.removeEventListener("mousedown", onMouseDown), environment.removeEventListener("mouseup", onMouseUp), environment.removeEventListener("touchstart", onTouchStart), environment.removeEventListener("touchmove", onTouchMove), environment.removeEventListener("touchend", onTouchEnd);
  22398. };
  22399. }
  22400. }, _proto.shouldScroll = function(prevState, prevProps) {
  22401. var _ref0 = this.props.highlightedIndex === void 0 ? this.getState() : this.props, currentHighlightedIndex = _ref0.highlightedIndex, _ref1 = prevProps.highlightedIndex === void 0 ? prevState : prevProps, prevHighlightedIndex = _ref1.highlightedIndex, scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen, scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
  22402. return scrollWhenOpen || scrollWhenNavigating;
  22403. }, _proto.componentDidUpdate = function(prevProps, prevState) {
  22404. isControlledProp(this.props, "selectedItem") && this.props.selectedItemChanged(prevProps.selectedItem, this.props.selectedItem) && this.internalSetState({
  22405. type: controlledPropUpdatedSelectedItem,
  22406. inputValue: this.props.itemToString(this.props.selectedItem)
  22407. }), !this.avoidScrolling && this.shouldScroll(prevState, prevProps) && this.scrollHighlightedItemIntoView(), this.updateStatus();
  22408. }, _proto.componentWillUnmount = function() {
  22409. this.cleanup();
  22410. }, _proto.render = function() {
  22411. var children = unwrapArray(this.props.children, noop4);
  22412. this.clearItems(), this.getRootProps.called = !1, this.getRootProps.refKey = void 0, this.getRootProps.suppressRefError = void 0, this.getMenuProps.called = !1, this.getMenuProps.refKey = void 0, this.getMenuProps.suppressRefError = void 0, this.getLabelProps.called = !1, this.getInputProps.called = !1;
  22413. var element = unwrapArray(children(this.getStateAndHelpers()));
  22414. if (!element)
  22415. return null;
  22416. if (this.getRootProps.called || this.props.suppressRefError)
  22417. return element;
  22418. if (isDOMElement(element))
  22419. return cloneElement(element, this.getRootProps(getElementProps(element)));
  22420. }, Downshift3;
  22421. })(Component);
  22422. return Downshift2.defaultProps = {
  22423. defaultHighlightedIndex: null,
  22424. defaultIsOpen: !1,
  22425. getA11yStatusMessage,
  22426. itemToString: function(i2) {
  22427. return i2 == null ? "" : String(i2);
  22428. },
  22429. onStateChange: noop4,
  22430. onInputValueChange: noop4,
  22431. onUserAction: noop4,
  22432. onChange: noop4,
  22433. onSelect: noop4,
  22434. onOuterClick: noop4,
  22435. selectedItemChanged: function(prevItem, item) {
  22436. return prevItem !== item;
  22437. },
  22438. environment: (
  22439. /* istanbul ignore next (ssr) */
  22440. typeof window > "u" ? void 0 : window
  22441. ),
  22442. stateReducer: function(state, stateToSet) {
  22443. return stateToSet;
  22444. },
  22445. suppressRefError: !1,
  22446. scrollIntoView: scrollIntoView2
  22447. }, Downshift2.stateChangeTypes = stateChangeTypes$3, Downshift2;
  22448. })();
  22449. var dropdownDefaultStateValues = {
  22450. highlightedIndex: -1,
  22451. isOpen: !1,
  22452. selectedItem: null,
  22453. inputValue: ""
  22454. };
  22455. function callOnChangeProps(action, state, newState) {
  22456. var props = action.props, type = action.type, changes = {};
  22457. Object.keys(state).forEach(function(key) {
  22458. invokeOnChangeHandler(key, action, state, newState), newState[key] !== state[key] && (changes[key] = newState[key]);
  22459. }), props.onStateChange && Object.keys(changes).length && props.onStateChange(_extends({
  22460. type
  22461. }, changes));
  22462. }
  22463. function invokeOnChangeHandler(key, action, state, newState) {
  22464. var props = action.props, type = action.type, handler = "on" + capitalizeString(key) + "Change";
  22465. props[handler] && newState[key] !== void 0 && newState[key] !== state[key] && props[handler](_extends({
  22466. type
  22467. }, newState));
  22468. }
  22469. function stateReducer(s2, a2) {
  22470. return a2.changes;
  22471. }
  22472. var updateA11yStatus = debounce4(function(status, document11) {
  22473. setStatus(status, document11);
  22474. }, 200), useIsomorphicLayoutEffect2 = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u" ? useLayoutEffect : useEffect, useElementIds = "useId" in react_default ? function(_ref) {
  22475. var id = _ref.id, labelId = _ref.labelId, menuId = _ref.menuId, getItemId = _ref.getItemId, toggleButtonId = _ref.toggleButtonId, inputId = _ref.inputId, reactId = "downshift-" + react_default.useId();
  22476. id || (id = reactId);
  22477. var elementIdsRef = useRef({
  22478. labelId: labelId || id + "-label",
  22479. menuId: menuId || id + "-menu",
  22480. getItemId: getItemId || function(index) {
  22481. return id + "-item-" + index;
  22482. },
  22483. toggleButtonId: toggleButtonId || id + "-toggle-button",
  22484. inputId: inputId || id + "-input"
  22485. });
  22486. return elementIdsRef.current;
  22487. } : function(_ref2) {
  22488. var _ref2$id = _ref2.id, id = _ref2$id === void 0 ? "downshift-" + generateId() : _ref2$id, labelId = _ref2.labelId, menuId = _ref2.menuId, getItemId = _ref2.getItemId, toggleButtonId = _ref2.toggleButtonId, inputId = _ref2.inputId, elementIdsRef = useRef({
  22489. labelId: labelId || id + "-label",
  22490. menuId: menuId || id + "-menu",
  22491. getItemId: getItemId || function(index) {
  22492. return id + "-item-" + index;
  22493. },
  22494. toggleButtonId: toggleButtonId || id + "-toggle-button",
  22495. inputId: inputId || id + "-input"
  22496. });
  22497. return elementIdsRef.current;
  22498. };
  22499. function getItemAndIndex(itemProp, indexProp, items, errorMessage) {
  22500. var item, index;
  22501. if (itemProp === void 0) {
  22502. if (indexProp === void 0)
  22503. throw new Error(errorMessage);
  22504. item = items[indexProp], index = indexProp;
  22505. } else
  22506. index = indexProp === void 0 ? items.indexOf(itemProp) : indexProp, item = itemProp;
  22507. return [item, index];
  22508. }
  22509. function isAcceptedCharacterKey(key) {
  22510. return /^\S{1}$/.test(key);
  22511. }
  22512. function capitalizeString(string) {
  22513. return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
  22514. }
  22515. function useLatestRef(val) {
  22516. var ref = useRef(val);
  22517. return ref.current = val, ref;
  22518. }
  22519. function useEnhancedReducer(reducer, props, createInitialState, isStateEqual2) {
  22520. var prevStateRef = useRef(), actionRef = useRef(), enhancedReducer = useCallback(function(state2, action2) {
  22521. actionRef.current = action2, state2 = getState2(state2, action2.props);
  22522. var changes = reducer(state2, action2), newState = action2.props.stateReducer(state2, _extends({}, action2, {
  22523. changes
  22524. }));
  22525. return newState;
  22526. }, [reducer]), _useReducer = useReducer(enhancedReducer, props, createInitialState), state = _useReducer[0], dispatch = _useReducer[1], propsRef = useLatestRef(props), dispatchWithProps = useCallback(function(action2) {
  22527. return dispatch(_extends({
  22528. props: propsRef.current
  22529. }, action2));
  22530. }, [propsRef]), action = actionRef.current;
  22531. return useEffect(function() {
  22532. var prevState = getState2(prevStateRef.current, action?.props), shouldCallOnChangeProps = action && prevStateRef.current && !isStateEqual2(prevState, state);
  22533. shouldCallOnChangeProps && callOnChangeProps(action, prevState, state), prevStateRef.current = state;
  22534. }, [state, action, isStateEqual2]), [state, dispatchWithProps];
  22535. }
  22536. function useControlledReducer$1(reducer, props, createInitialState, isStateEqual2) {
  22537. var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual2), state = _useEnhancedReducer[0], dispatch = _useEnhancedReducer[1];
  22538. return [getState2(state, props), dispatch];
  22539. }
  22540. var defaultProps$3 = {
  22541. itemToString: function(item) {
  22542. return item ? String(item) : "";
  22543. },
  22544. itemToKey: function(item) {
  22545. return item;
  22546. },
  22547. stateReducer,
  22548. scrollIntoView: scrollIntoView2,
  22549. environment: (
  22550. /* istanbul ignore next (ssr) */
  22551. typeof window > "u" ? void 0 : window
  22552. )
  22553. };
  22554. function getDefaultValue$1(props, propKey, defaultStateValues2) {
  22555. defaultStateValues2 === void 0 && (defaultStateValues2 = dropdownDefaultStateValues);
  22556. var defaultValue = props["default" + capitalizeString(propKey)];
  22557. return defaultValue !== void 0 ? defaultValue : defaultStateValues2[propKey];
  22558. }
  22559. function getInitialValue$1(props, propKey, defaultStateValues2) {
  22560. defaultStateValues2 === void 0 && (defaultStateValues2 = dropdownDefaultStateValues);
  22561. var value = props[propKey];
  22562. if (value !== void 0)
  22563. return value;
  22564. var initialValue = props["initial" + capitalizeString(propKey)];
  22565. return initialValue !== void 0 ? initialValue : getDefaultValue$1(props, propKey, defaultStateValues2);
  22566. }
  22567. function getInitialState$2(props) {
  22568. var selectedItem = getInitialValue$1(props, "selectedItem"), isOpen = getInitialValue$1(props, "isOpen"), highlightedIndex = getInitialHighlightedIndex(props), inputValue = getInitialValue$1(props, "inputValue");
  22569. return {
  22570. highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function(item) {
  22571. return props.itemToKey(item) === props.itemToKey(selectedItem);
  22572. }) : highlightedIndex,
  22573. isOpen,
  22574. selectedItem,
  22575. inputValue
  22576. };
  22577. }
  22578. function getHighlightedIndexOnOpen(props, state, offset2) {
  22579. var items = props.items, initialHighlightedIndex = props.initialHighlightedIndex, defaultHighlightedIndex = props.defaultHighlightedIndex, isItemDisabled2 = props.isItemDisabled, itemToKey2 = props.itemToKey, selectedItem = state.selectedItem, highlightedIndex = state.highlightedIndex;
  22580. return items.length === 0 ? -1 : initialHighlightedIndex !== void 0 && highlightedIndex === initialHighlightedIndex && !isItemDisabled2(items[initialHighlightedIndex], initialHighlightedIndex) ? initialHighlightedIndex : defaultHighlightedIndex !== void 0 && !isItemDisabled2(items[defaultHighlightedIndex], defaultHighlightedIndex) ? defaultHighlightedIndex : selectedItem ? items.findIndex(function(item) {
  22581. return itemToKey2(selectedItem) === itemToKey2(item);
  22582. }) : offset2 < 0 && !isItemDisabled2(items[items.length - 1], items.length - 1) ? items.length - 1 : offset2 > 0 && !isItemDisabled2(items[0], 0) ? 0 : -1;
  22583. }
  22584. function useMouseAndTouchTracker(environment, handleBlur, downshiftElementsRefs) {
  22585. var mouseAndTouchTrackersRef = useRef({
  22586. isMouseDown: !1,
  22587. isTouchMove: !1,
  22588. isTouchEnd: !1
  22589. });
  22590. return useEffect(function() {
  22591. if (!environment)
  22592. return noop4;
  22593. var downshiftElements = downshiftElementsRefs.map(function(ref) {
  22594. return ref.current;
  22595. });
  22596. function onMouseDown() {
  22597. mouseAndTouchTrackersRef.current.isTouchEnd = !1, mouseAndTouchTrackersRef.current.isMouseDown = !0;
  22598. }
  22599. function onMouseUp(event) {
  22600. mouseAndTouchTrackersRef.current.isMouseDown = !1, targetWithinDownshift(event.target, downshiftElements, environment) || handleBlur();
  22601. }
  22602. function onTouchStart() {
  22603. mouseAndTouchTrackersRef.current.isTouchEnd = !1, mouseAndTouchTrackersRef.current.isTouchMove = !1;
  22604. }
  22605. function onTouchMove() {
  22606. mouseAndTouchTrackersRef.current.isTouchMove = !0;
  22607. }
  22608. function onTouchEnd(event) {
  22609. mouseAndTouchTrackersRef.current.isTouchEnd = !0, !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElements, environment, !1) && handleBlur();
  22610. }
  22611. return environment.addEventListener("mousedown", onMouseDown), environment.addEventListener("mouseup", onMouseUp), environment.addEventListener("touchstart", onTouchStart), environment.addEventListener("touchmove", onTouchMove), environment.addEventListener("touchend", onTouchEnd), function() {
  22612. environment.removeEventListener("mousedown", onMouseDown), environment.removeEventListener("mouseup", onMouseUp), environment.removeEventListener("touchstart", onTouchStart), environment.removeEventListener("touchmove", onTouchMove), environment.removeEventListener("touchend", onTouchEnd);
  22613. };
  22614. }, [downshiftElementsRefs, environment, handleBlur]), mouseAndTouchTrackersRef.current;
  22615. }
  22616. var useGetterPropsCalledChecker = function() {
  22617. return noop4;
  22618. };
  22619. function useA11yMessageStatus(getA11yStatusMessage2, options2, dependencyArray, environment) {
  22620. environment === void 0 && (environment = {});
  22621. var document11 = environment.document, isInitialMount = useIsInitialMount();
  22622. useEffect(function() {
  22623. if (!(!getA11yStatusMessage2 || isInitialMount || !document11)) {
  22624. var status = getA11yStatusMessage2(options2);
  22625. updateA11yStatus(status, document11);
  22626. }
  22627. }, dependencyArray), useEffect(function() {
  22628. return function() {
  22629. updateA11yStatus.cancel(), cleanupStatusDiv(document11);
  22630. };
  22631. }, [document11]);
  22632. }
  22633. function useScrollIntoView(_ref3) {
  22634. var highlightedIndex = _ref3.highlightedIndex, isOpen = _ref3.isOpen, itemRefs = _ref3.itemRefs, getItemNodeFromIndex = _ref3.getItemNodeFromIndex, menuElement = _ref3.menuElement, scrollIntoViewProp = _ref3.scrollIntoView, shouldScrollRef = useRef(!0);
  22635. return useIsomorphicLayoutEffect2(function() {
  22636. highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length || (shouldScrollRef.current === !1 ? shouldScrollRef.current = !0 : scrollIntoViewProp(getItemNodeFromIndex(highlightedIndex), menuElement));
  22637. }, [highlightedIndex]), shouldScrollRef;
  22638. }
  22639. var useControlPropsValidator = noop4;
  22640. function getChangesOnSelection(props, highlightedIndex, inputValue) {
  22641. var _props$items;
  22642. inputValue === void 0 && (inputValue = !0);
  22643. var shouldSelect = ((_props$items = props.items) == null ? void 0 : _props$items.length) && highlightedIndex >= 0;
  22644. return _extends({
  22645. isOpen: !1,
  22646. highlightedIndex: -1
  22647. }, shouldSelect && _extends({
  22648. selectedItem: props.items[highlightedIndex],
  22649. isOpen: getDefaultValue$1(props, "isOpen"),
  22650. highlightedIndex: getDefaultValue$1(props, "highlightedIndex")
  22651. }, inputValue && {
  22652. inputValue: props.itemToString(props.items[highlightedIndex])
  22653. }));
  22654. }
  22655. function isDropdownsStateEqual(prevState, newState) {
  22656. return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
  22657. }
  22658. function useIsInitialMount() {
  22659. var isInitialMountRef = react_default.useRef(!0);
  22660. return react_default.useEffect(function() {
  22661. return isInitialMountRef.current = !1, function() {
  22662. isInitialMountRef.current = !0;
  22663. };
  22664. }, []), isInitialMountRef.current;
  22665. }
  22666. function getDefaultHighlightedIndex(props) {
  22667. var highlightedIndex = getDefaultValue$1(props, "highlightedIndex");
  22668. return highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex) ? -1 : highlightedIndex;
  22669. }
  22670. function getInitialHighlightedIndex(props) {
  22671. var highlightedIndex = getInitialValue$1(props, "highlightedIndex");
  22672. return highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex) ? -1 : highlightedIndex;
  22673. }
  22674. var commonPropTypes = {
  22675. environment: import_prop_types3.default.shape({
  22676. addEventListener: import_prop_types3.default.func.isRequired,
  22677. removeEventListener: import_prop_types3.default.func.isRequired,
  22678. document: import_prop_types3.default.shape({
  22679. createElement: import_prop_types3.default.func.isRequired,
  22680. getElementById: import_prop_types3.default.func.isRequired,
  22681. activeElement: import_prop_types3.default.any.isRequired,
  22682. body: import_prop_types3.default.any.isRequired
  22683. }).isRequired,
  22684. Node: import_prop_types3.default.func.isRequired
  22685. }),
  22686. itemToString: import_prop_types3.default.func,
  22687. itemToKey: import_prop_types3.default.func,
  22688. stateReducer: import_prop_types3.default.func
  22689. }, commonDropdownPropTypes = _extends({}, commonPropTypes, {
  22690. getA11yStatusMessage: import_prop_types3.default.func,
  22691. highlightedIndex: import_prop_types3.default.number,
  22692. defaultHighlightedIndex: import_prop_types3.default.number,
  22693. initialHighlightedIndex: import_prop_types3.default.number,
  22694. isOpen: import_prop_types3.default.bool,
  22695. defaultIsOpen: import_prop_types3.default.bool,
  22696. initialIsOpen: import_prop_types3.default.bool,
  22697. selectedItem: import_prop_types3.default.any,
  22698. initialSelectedItem: import_prop_types3.default.any,
  22699. defaultSelectedItem: import_prop_types3.default.any,
  22700. id: import_prop_types3.default.string,
  22701. labelId: import_prop_types3.default.string,
  22702. menuId: import_prop_types3.default.string,
  22703. getItemId: import_prop_types3.default.func,
  22704. toggleButtonId: import_prop_types3.default.string,
  22705. onSelectedItemChange: import_prop_types3.default.func,
  22706. onHighlightedIndexChange: import_prop_types3.default.func,
  22707. onStateChange: import_prop_types3.default.func,
  22708. onIsOpenChange: import_prop_types3.default.func,
  22709. scrollIntoView: import_prop_types3.default.func
  22710. });
  22711. function downshiftCommonReducer(state, action, stateChangeTypes2) {
  22712. var type = action.type, props = action.props, changes;
  22713. switch (type) {
  22714. case stateChangeTypes2.ItemMouseMove:
  22715. changes = {
  22716. highlightedIndex: action.disabled ? -1 : action.index
  22717. };
  22718. break;
  22719. case stateChangeTypes2.MenuMouseLeave:
  22720. changes = {
  22721. highlightedIndex: -1
  22722. };
  22723. break;
  22724. case stateChangeTypes2.ToggleButtonClick:
  22725. case stateChangeTypes2.FunctionToggleMenu:
  22726. changes = {
  22727. isOpen: !state.isOpen,
  22728. highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
  22729. };
  22730. break;
  22731. case stateChangeTypes2.FunctionOpenMenu:
  22732. changes = {
  22733. isOpen: !0,
  22734. highlightedIndex: getHighlightedIndexOnOpen(props, state, 0)
  22735. };
  22736. break;
  22737. case stateChangeTypes2.FunctionCloseMenu:
  22738. changes = {
  22739. isOpen: !1
  22740. };
  22741. break;
  22742. case stateChangeTypes2.FunctionSetHighlightedIndex:
  22743. changes = {
  22744. highlightedIndex: props.isItemDisabled(props.items[action.highlightedIndex], action.highlightedIndex) ? -1 : action.highlightedIndex
  22745. };
  22746. break;
  22747. case stateChangeTypes2.FunctionSetInputValue:
  22748. changes = {
  22749. inputValue: action.inputValue
  22750. };
  22751. break;
  22752. case stateChangeTypes2.FunctionReset:
  22753. changes = {
  22754. highlightedIndex: getDefaultHighlightedIndex(props),
  22755. isOpen: getDefaultValue$1(props, "isOpen"),
  22756. selectedItem: getDefaultValue$1(props, "selectedItem"),
  22757. inputValue: getDefaultValue$1(props, "inputValue")
  22758. };
  22759. break;
  22760. default:
  22761. throw new Error("Reducer called without proper action type.");
  22762. }
  22763. return _extends({}, state, changes);
  22764. }
  22765. function getItemIndexByCharacterKey(_a2) {
  22766. for (var keysSoFar = _a2.keysSoFar, highlightedIndex = _a2.highlightedIndex, items = _a2.items, itemToString2 = _a2.itemToString, isItemDisabled2 = _a2.isItemDisabled, lowerCasedKeysSoFar = keysSoFar.toLowerCase(), index = 0; index < items.length; index++) {
  22767. var offsetIndex = (index + highlightedIndex + (keysSoFar.length < 2 ? 1 : 0)) % items.length, item = items[offsetIndex];
  22768. if (item !== void 0 && itemToString2(item).toLowerCase().startsWith(lowerCasedKeysSoFar) && !isItemDisabled2(item, offsetIndex))
  22769. return offsetIndex;
  22770. }
  22771. return highlightedIndex;
  22772. }
  22773. var propTypes$2 = __assign(__assign({}, commonDropdownPropTypes), { items: import_prop_types3.default.array.isRequired, isItemDisabled: import_prop_types3.default.func }), defaultProps$2 = __assign(__assign({}, defaultProps$3), { isItemDisabled: function() {
  22774. return !1;
  22775. } }), validatePropTypes$2 = noop4, ToggleButtonClick$1 = 0, ToggleButtonKeyDownArrowDown = 1, ToggleButtonKeyDownArrowUp = 2, ToggleButtonKeyDownCharacter = 3, ToggleButtonKeyDownEscape = 4, ToggleButtonKeyDownHome = 5, ToggleButtonKeyDownEnd = 6, ToggleButtonKeyDownEnter = 7, ToggleButtonKeyDownSpaceButton = 8, ToggleButtonKeyDownPageUp = 9, ToggleButtonKeyDownPageDown = 10, ToggleButtonBlur = 11, MenuMouseLeave$1 = 12, ItemMouseMove$1 = 13, ItemClick$1 = 14, FunctionToggleMenu$1 = 15, FunctionOpenMenu$1 = 16, FunctionCloseMenu$1 = 17, FunctionSetHighlightedIndex$1 = 18, FunctionSelectItem$1 = 19, FunctionSetInputValue$1 = 20, FunctionReset$2 = 21, stateChangeTypes$2 = Object.freeze({
  22776. __proto__: null,
  22777. FunctionCloseMenu: FunctionCloseMenu$1,
  22778. FunctionOpenMenu: FunctionOpenMenu$1,
  22779. FunctionReset: FunctionReset$2,
  22780. FunctionSelectItem: FunctionSelectItem$1,
  22781. FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
  22782. FunctionSetInputValue: FunctionSetInputValue$1,
  22783. FunctionToggleMenu: FunctionToggleMenu$1,
  22784. ItemClick: ItemClick$1,
  22785. ItemMouseMove: ItemMouseMove$1,
  22786. MenuMouseLeave: MenuMouseLeave$1,
  22787. ToggleButtonBlur,
  22788. ToggleButtonClick: ToggleButtonClick$1,
  22789. ToggleButtonKeyDownArrowDown,
  22790. ToggleButtonKeyDownArrowUp,
  22791. ToggleButtonKeyDownCharacter,
  22792. ToggleButtonKeyDownEnd,
  22793. ToggleButtonKeyDownEnter,
  22794. ToggleButtonKeyDownEscape,
  22795. ToggleButtonKeyDownHome,
  22796. ToggleButtonKeyDownPageDown,
  22797. ToggleButtonKeyDownPageUp,
  22798. ToggleButtonKeyDownSpaceButton
  22799. });
  22800. function downshiftSelectReducer(state, action) {
  22801. var _props$items, type = action.type, props = action.props, altKey = action.altKey, changes;
  22802. switch (type) {
  22803. case ItemClick$1:
  22804. changes = {
  22805. isOpen: getDefaultValue$1(props, "isOpen"),
  22806. highlightedIndex: getDefaultHighlightedIndex(props),
  22807. selectedItem: props.items[action.index]
  22808. };
  22809. break;
  22810. case ToggleButtonKeyDownCharacter:
  22811. {
  22812. var lowercasedKey = action.key, inputValue = "" + state.inputValue + lowercasedKey, prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.findIndex(function(item) {
  22813. return props.itemToKey(item) === props.itemToKey(state.selectedItem);
  22814. }) : state.highlightedIndex, highlightedIndex = getItemIndexByCharacterKey({
  22815. keysSoFar: inputValue,
  22816. highlightedIndex: prevHighlightedIndex,
  22817. items: props.items,
  22818. itemToString: props.itemToString,
  22819. isItemDisabled: props.isItemDisabled
  22820. });
  22821. changes = {
  22822. inputValue,
  22823. highlightedIndex,
  22824. isOpen: !0
  22825. };
  22826. }
  22827. break;
  22828. case ToggleButtonKeyDownArrowDown:
  22829. {
  22830. var _highlightedIndex = state.isOpen ? getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
  22831. changes = {
  22832. highlightedIndex: _highlightedIndex,
  22833. isOpen: !0
  22834. };
  22835. }
  22836. break;
  22837. case ToggleButtonKeyDownArrowUp:
  22838. if (state.isOpen && altKey)
  22839. changes = getChangesOnSelection(props, state.highlightedIndex, !1);
  22840. else {
  22841. var _highlightedIndex2 = state.isOpen ? getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled) : getHighlightedIndexOnOpen(props, state, -1);
  22842. changes = {
  22843. highlightedIndex: _highlightedIndex2,
  22844. isOpen: !0
  22845. };
  22846. }
  22847. break;
  22848. // only triggered when menu is open.
  22849. case ToggleButtonKeyDownEnter:
  22850. case ToggleButtonKeyDownSpaceButton:
  22851. changes = getChangesOnSelection(props, state.highlightedIndex, !1);
  22852. break;
  22853. case ToggleButtonKeyDownHome:
  22854. changes = {
  22855. highlightedIndex: getNonDisabledIndex(0, !1, props.items, props.isItemDisabled),
  22856. isOpen: !0
  22857. };
  22858. break;
  22859. case ToggleButtonKeyDownEnd:
  22860. changes = {
  22861. highlightedIndex: getNonDisabledIndex(props.items.length - 1, !0, props.items, props.isItemDisabled),
  22862. isOpen: !0
  22863. };
  22864. break;
  22865. case ToggleButtonKeyDownPageUp:
  22866. changes = {
  22867. highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled)
  22868. };
  22869. break;
  22870. case ToggleButtonKeyDownPageDown:
  22871. changes = {
  22872. highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled)
  22873. };
  22874. break;
  22875. case ToggleButtonKeyDownEscape:
  22876. changes = {
  22877. isOpen: !1,
  22878. highlightedIndex: -1
  22879. };
  22880. break;
  22881. case ToggleButtonBlur:
  22882. changes = _extends({
  22883. isOpen: !1,
  22884. highlightedIndex: -1
  22885. }, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && {
  22886. selectedItem: props.items[state.highlightedIndex]
  22887. });
  22888. break;
  22889. case FunctionSelectItem$1:
  22890. changes = {
  22891. selectedItem: action.selectedItem
  22892. };
  22893. break;
  22894. default:
  22895. return downshiftCommonReducer(state, action, stateChangeTypes$2);
  22896. }
  22897. return _extends({}, state, changes);
  22898. }
  22899. var _excluded$2 = ["onClick"], _excluded2$2 = ["onMouseLeave", "refKey", "ref"], _excluded3$1 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref"], _excluded4$1 = ["item", "index", "onMouseMove", "onClick", "onMouseDown", "onPress", "refKey", "disabled", "ref"];
  22900. useSelect.stateChangeTypes = stateChangeTypes$2;
  22901. function useSelect(userProps) {
  22902. userProps === void 0 && (userProps = {}), validatePropTypes$2(userProps, useSelect);
  22903. var props = _extends({}, defaultProps$2, userProps), scrollIntoView3 = props.scrollIntoView, environment = props.environment, getA11yStatusMessage2 = props.getA11yStatusMessage, _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$2, isDropdownsStateEqual), state = _useControlledReducer[0], dispatch = _useControlledReducer[1], isOpen = state.isOpen, highlightedIndex = state.highlightedIndex, selectedItem = state.selectedItem, inputValue = state.inputValue, toggleButtonRef = useRef(null), menuRef = useRef(null), itemRefs = useRef({}), clearTimeoutRef = useRef(null), elementIds = useElementIds(props), latest = useLatestRef({
  22904. state,
  22905. props
  22906. }), getItemNodeFromIndex = useCallback(function(index) {
  22907. return itemRefs.current[elementIds.getItemId(index)];
  22908. }, [elementIds]);
  22909. useA11yMessageStatus(getA11yStatusMessage2, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
  22910. var shouldScrollRef = useScrollIntoView({
  22911. menuElement: menuRef.current,
  22912. highlightedIndex,
  22913. isOpen,
  22914. itemRefs,
  22915. scrollIntoView: scrollIntoView3,
  22916. getItemNodeFromIndex
  22917. });
  22918. useEffect(function() {
  22919. return clearTimeoutRef.current = debounce4(function(outerDispatch) {
  22920. outerDispatch({
  22921. type: FunctionSetInputValue$1,
  22922. inputValue: ""
  22923. });
  22924. }, 500), function() {
  22925. clearTimeoutRef.current.cancel();
  22926. };
  22927. }, []), useEffect(function() {
  22928. inputValue && clearTimeoutRef.current(dispatch);
  22929. }, [dispatch, inputValue]), useControlPropsValidator({
  22930. props,
  22931. state
  22932. }), useEffect(function() {
  22933. var focusOnOpen = getInitialValue$1(props, "isOpen");
  22934. focusOnOpen && toggleButtonRef.current && toggleButtonRef.current.focus();
  22935. }, []);
  22936. var mouseAndTouchTrackers = useMouseAndTouchTracker(environment, useCallback(function() {
  22937. latest.current.state.isOpen && dispatch({
  22938. type: ToggleButtonBlur
  22939. });
  22940. }, [dispatch, latest]), useMemo(function() {
  22941. return [menuRef, toggleButtonRef];
  22942. }, [menuRef.current, toggleButtonRef.current])), setGetterPropCallInfo = useGetterPropsCalledChecker("getMenuProps", "getToggleButtonProps");
  22943. useEffect(function() {
  22944. isOpen || (itemRefs.current = {});
  22945. }, [isOpen]);
  22946. var toggleButtonKeyDownHandlers = useMemo(function() {
  22947. return {
  22948. ArrowDown: function(event) {
  22949. event.preventDefault(), dispatch({
  22950. type: ToggleButtonKeyDownArrowDown,
  22951. altKey: event.altKey
  22952. });
  22953. },
  22954. ArrowUp: function(event) {
  22955. event.preventDefault(), dispatch({
  22956. type: ToggleButtonKeyDownArrowUp,
  22957. altKey: event.altKey
  22958. });
  22959. },
  22960. Home: function(event) {
  22961. event.preventDefault(), dispatch({
  22962. type: ToggleButtonKeyDownHome
  22963. });
  22964. },
  22965. End: function(event) {
  22966. event.preventDefault(), dispatch({
  22967. type: ToggleButtonKeyDownEnd
  22968. });
  22969. },
  22970. Escape: function() {
  22971. latest.current.state.isOpen && dispatch({
  22972. type: ToggleButtonKeyDownEscape
  22973. });
  22974. },
  22975. Enter: function(event) {
  22976. event.preventDefault(), dispatch({
  22977. type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
  22978. });
  22979. },
  22980. PageUp: function(event) {
  22981. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  22982. type: ToggleButtonKeyDownPageUp
  22983. }));
  22984. },
  22985. PageDown: function(event) {
  22986. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  22987. type: ToggleButtonKeyDownPageDown
  22988. }));
  22989. },
  22990. " ": function(event) {
  22991. event.preventDefault();
  22992. var currentState = latest.current.state;
  22993. if (!currentState.isOpen) {
  22994. dispatch({
  22995. type: ToggleButtonClick$1
  22996. });
  22997. return;
  22998. }
  22999. currentState.inputValue ? dispatch({
  23000. type: ToggleButtonKeyDownCharacter,
  23001. key: " "
  23002. }) : dispatch({
  23003. type: ToggleButtonKeyDownSpaceButton
  23004. });
  23005. }
  23006. };
  23007. }, [dispatch, latest]), toggleMenu = useCallback(function() {
  23008. dispatch({
  23009. type: FunctionToggleMenu$1
  23010. });
  23011. }, [dispatch]), closeMenu = useCallback(function() {
  23012. dispatch({
  23013. type: FunctionCloseMenu$1
  23014. });
  23015. }, [dispatch]), openMenu = useCallback(function() {
  23016. dispatch({
  23017. type: FunctionOpenMenu$1
  23018. });
  23019. }, [dispatch]), setHighlightedIndex = useCallback(function(newHighlightedIndex) {
  23020. dispatch({
  23021. type: FunctionSetHighlightedIndex$1,
  23022. highlightedIndex: newHighlightedIndex
  23023. });
  23024. }, [dispatch]), selectItem = useCallback(function(newSelectedItem) {
  23025. dispatch({
  23026. type: FunctionSelectItem$1,
  23027. selectedItem: newSelectedItem
  23028. });
  23029. }, [dispatch]), reset = useCallback(function() {
  23030. dispatch({
  23031. type: FunctionReset$2
  23032. });
  23033. }, [dispatch]), setInputValue = useCallback(function(newInputValue) {
  23034. dispatch({
  23035. type: FunctionSetInputValue$1,
  23036. inputValue: newInputValue
  23037. });
  23038. }, [dispatch]), getLabelProps = useCallback(function(_temp) {
  23039. var _ref = _temp === void 0 ? {} : _temp, onClick = _ref.onClick, labelProps = _objectWithoutPropertiesLoose2(_ref, _excluded$2), labelHandleClick = function() {
  23040. var _toggleButtonRef$curr;
  23041. (_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
  23042. };
  23043. return _extends({
  23044. id: elementIds.labelId,
  23045. htmlFor: elementIds.toggleButtonId,
  23046. onClick: callAllEventHandlers(onClick, labelHandleClick)
  23047. }, labelProps);
  23048. }, [elementIds]), getMenuProps = useCallback(function(_temp2, _temp3) {
  23049. var _extends22, _ref2 = _temp2 === void 0 ? {} : _temp2, onMouseLeave = _ref2.onMouseLeave, _ref2$refKey = _ref2.refKey, refKey = _ref2$refKey === void 0 ? "ref" : _ref2$refKey, ref = _ref2.ref, rest2 = _objectWithoutPropertiesLoose2(_ref2, _excluded2$2), _ref3 = _temp3 === void 0 ? {} : _temp3, _ref3$suppressRefErro = _ref3.suppressRefError, suppressRefError = _ref3$suppressRefErro === void 0 ? !1 : _ref3$suppressRefErro, menuHandleMouseLeave = function() {
  23050. dispatch({
  23051. type: MenuMouseLeave$1
  23052. });
  23053. };
  23054. return setGetterPropCallInfo("getMenuProps", suppressRefError, refKey, menuRef), _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, function(menuNode) {
  23055. menuRef.current = menuNode;
  23056. }), _extends22.id = elementIds.menuId, _extends22.role = "listbox", _extends22["aria-labelledby"] = rest2 && rest2["aria-label"] ? void 0 : "" + elementIds.labelId, _extends22.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends22), rest2);
  23057. }, [dispatch, setGetterPropCallInfo, elementIds]), getToggleButtonProps = useCallback(function(_temp4, _temp5) {
  23058. var _extends3, _ref4 = _temp4 === void 0 ? {} : _temp4, onBlur = _ref4.onBlur, onClick = _ref4.onClick;
  23059. _ref4.onPress;
  23060. var onKeyDown = _ref4.onKeyDown, _ref4$refKey = _ref4.refKey, refKey = _ref4$refKey === void 0 ? "ref" : _ref4$refKey, ref = _ref4.ref, rest2 = _objectWithoutPropertiesLoose2(_ref4, _excluded3$1), _ref5 = _temp5 === void 0 ? {} : _temp5, _ref5$suppressRefErro = _ref5.suppressRefError, suppressRefError = _ref5$suppressRefErro === void 0 ? !1 : _ref5$suppressRefErro, latestState = latest.current.state, toggleButtonHandleClick = function() {
  23061. dispatch({
  23062. type: ToggleButtonClick$1
  23063. });
  23064. }, toggleButtonHandleBlur = function() {
  23065. latestState.isOpen && !mouseAndTouchTrackers.isMouseDown && dispatch({
  23066. type: ToggleButtonBlur
  23067. });
  23068. }, toggleButtonHandleKeyDown = function(event) {
  23069. var key = normalizeArrowKey(event);
  23070. key && toggleButtonKeyDownHandlers[key] ? toggleButtonKeyDownHandlers[key](event) : isAcceptedCharacterKey(key) && dispatch({
  23071. type: ToggleButtonKeyDownCharacter,
  23072. key
  23073. });
  23074. }, toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(toggleButtonNode) {
  23075. toggleButtonRef.current = toggleButtonNode;
  23076. }), _extends3["aria-activedescendant"] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : "", _extends3["aria-controls"] = elementIds.menuId, _extends3["aria-expanded"] = latest.current.state.isOpen, _extends3["aria-haspopup"] = "listbox", _extends3["aria-labelledby"] = rest2 && rest2["aria-label"] ? void 0 : "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = "combobox", _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest2);
  23077. return rest2.disabled || (toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick), toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown)), setGetterPropCallInfo("getToggleButtonProps", suppressRefError, refKey, toggleButtonRef), toggleProps;
  23078. }, [dispatch, elementIds, latest, mouseAndTouchTrackers, setGetterPropCallInfo, toggleButtonKeyDownHandlers]), getItemProps = useCallback(function(_temp6) {
  23079. var _extends4, _ref6 = _temp6 === void 0 ? {} : _temp6, itemProp = _ref6.item, indexProp = _ref6.index, onMouseMove = _ref6.onMouseMove, onClick = _ref6.onClick, onMouseDown = _ref6.onMouseDown;
  23080. _ref6.onPress;
  23081. var _ref6$refKey = _ref6.refKey, refKey = _ref6$refKey === void 0 ? "ref" : _ref6$refKey, disabledProp = _ref6.disabled, ref = _ref6.ref, rest2 = _objectWithoutPropertiesLoose2(_ref6, _excluded4$1);
  23082. disabledProp !== void 0 && console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.');
  23083. var _latest$current = latest.current, latestState = _latest$current.state, latestProps = _latest$current.props, _getItemAndIndex = getItemAndIndex(itemProp, indexProp, latestProps.items, "Pass either item or index to getItemProps!"), item = _getItemAndIndex[0], index = _getItemAndIndex[1], disabled = latestProps.isItemDisabled(item, index), itemHandleMouseMove = function() {
  23084. mouseAndTouchTrackers.isTouchEnd || index === latestState.highlightedIndex || (shouldScrollRef.current = !1, dispatch({
  23085. type: ItemMouseMove$1,
  23086. index,
  23087. disabled
  23088. }));
  23089. }, itemHandleClick = function() {
  23090. dispatch({
  23091. type: ItemClick$1,
  23092. index
  23093. });
  23094. }, itemHandleMouseDown = function(e2) {
  23095. return e2.preventDefault();
  23096. }, itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function(itemNode) {
  23097. itemNode && (itemRefs.current[elementIds.getItemId(index)] = itemNode);
  23098. }), _extends4["aria-disabled"] = disabled, _extends4["aria-selected"] = item === latestState.selectedItem, _extends4.id = elementIds.getItemId(index), _extends4.role = "option", _extends4), rest2);
  23099. return disabled || (itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick)), itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove), itemProps.onMouseDown = callAllEventHandlers(onMouseDown, itemHandleMouseDown), itemProps;
  23100. }, [latest, elementIds, mouseAndTouchTrackers, shouldScrollRef, dispatch]);
  23101. return {
  23102. // prop getters.
  23103. getToggleButtonProps,
  23104. getLabelProps,
  23105. getMenuProps,
  23106. getItemProps,
  23107. // actions.
  23108. toggleMenu,
  23109. openMenu,
  23110. closeMenu,
  23111. setHighlightedIndex,
  23112. selectItem,
  23113. reset,
  23114. setInputValue,
  23115. // state.
  23116. highlightedIndex,
  23117. isOpen,
  23118. selectedItem,
  23119. inputValue
  23120. };
  23121. }
  23122. var InputKeyDownArrowDown = 0, InputKeyDownArrowUp = 1, InputKeyDownEscape = 2, InputKeyDownHome = 3, InputKeyDownEnd = 4, InputKeyDownPageUp = 5, InputKeyDownPageDown = 6, InputKeyDownEnter = 7, InputChange = 8, InputBlur = 9, InputClick = 10, MenuMouseLeave = 11, ItemMouseMove = 12, ItemClick = 13, ToggleButtonClick = 14, FunctionToggleMenu = 15, FunctionOpenMenu = 16, FunctionCloseMenu = 17, FunctionSetHighlightedIndex = 18, FunctionSelectItem = 19, FunctionSetInputValue = 20, FunctionReset$1 = 21, ControlledPropUpdatedSelectedItem = 22, stateChangeTypes$1 = Object.freeze({
  23123. __proto__: null,
  23124. ControlledPropUpdatedSelectedItem,
  23125. FunctionCloseMenu,
  23126. FunctionOpenMenu,
  23127. FunctionReset: FunctionReset$1,
  23128. FunctionSelectItem,
  23129. FunctionSetHighlightedIndex,
  23130. FunctionSetInputValue,
  23131. FunctionToggleMenu,
  23132. InputBlur,
  23133. InputChange,
  23134. InputClick,
  23135. InputKeyDownArrowDown,
  23136. InputKeyDownArrowUp,
  23137. InputKeyDownEnd,
  23138. InputKeyDownEnter,
  23139. InputKeyDownEscape,
  23140. InputKeyDownHome,
  23141. InputKeyDownPageDown,
  23142. InputKeyDownPageUp,
  23143. ItemClick,
  23144. ItemMouseMove,
  23145. MenuMouseLeave,
  23146. ToggleButtonClick
  23147. });
  23148. function getInitialState$1(props) {
  23149. var initialState = getInitialState$2(props), selectedItem = initialState.selectedItem, inputValue = initialState.inputValue;
  23150. return inputValue === "" && selectedItem && props.defaultInputValue === void 0 && props.initialInputValue === void 0 && props.inputValue === void 0 && (inputValue = props.itemToString(selectedItem)), _extends({}, initialState, {
  23151. inputValue
  23152. });
  23153. }
  23154. var propTypes$1 = _extends({}, commonDropdownPropTypes, {
  23155. items: import_prop_types3.default.array.isRequired,
  23156. isItemDisabled: import_prop_types3.default.func,
  23157. inputValue: import_prop_types3.default.string,
  23158. defaultInputValue: import_prop_types3.default.string,
  23159. initialInputValue: import_prop_types3.default.string,
  23160. inputId: import_prop_types3.default.string,
  23161. onInputValueChange: import_prop_types3.default.func
  23162. });
  23163. function useControlledReducer(reducer, props, createInitialState, isStateEqual2) {
  23164. var previousSelectedItemRef = useRef(), _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual2), state = _useEnhancedReducer[0], dispatch = _useEnhancedReducer[1], isInitialMount = useIsInitialMount();
  23165. return useEffect(function() {
  23166. if (isControlledProp(props, "selectedItem")) {
  23167. if (!isInitialMount) {
  23168. var shouldCallDispatch = props.itemToKey(props.selectedItem) !== props.itemToKey(previousSelectedItemRef.current);
  23169. shouldCallDispatch && dispatch({
  23170. type: ControlledPropUpdatedSelectedItem,
  23171. inputValue: props.itemToString(props.selectedItem)
  23172. });
  23173. }
  23174. previousSelectedItemRef.current = state.selectedItem === previousSelectedItemRef.current ? props.selectedItem : state.selectedItem;
  23175. }
  23176. }, [state.selectedItem, props.selectedItem]), [getState2(state, props), dispatch];
  23177. }
  23178. var validatePropTypes$1 = noop4, defaultProps$1 = _extends({}, defaultProps$3, {
  23179. isItemDisabled: function() {
  23180. return !1;
  23181. }
  23182. });
  23183. function downshiftUseComboboxReducer(state, action) {
  23184. var _props$items, type = action.type, props = action.props, altKey = action.altKey, changes;
  23185. switch (type) {
  23186. case ItemClick:
  23187. changes = {
  23188. isOpen: getDefaultValue$1(props, "isOpen"),
  23189. highlightedIndex: getDefaultHighlightedIndex(props),
  23190. selectedItem: props.items[action.index],
  23191. inputValue: props.itemToString(props.items[action.index])
  23192. };
  23193. break;
  23194. case InputKeyDownArrowDown:
  23195. state.isOpen ? changes = {
  23196. highlightedIndex: getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled, !0)
  23197. } : changes = {
  23198. highlightedIndex: altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1),
  23199. isOpen: props.items.length >= 0
  23200. };
  23201. break;
  23202. case InputKeyDownArrowUp:
  23203. state.isOpen ? altKey ? changes = getChangesOnSelection(props, state.highlightedIndex) : changes = {
  23204. highlightedIndex: getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled, !0)
  23205. } : changes = {
  23206. highlightedIndex: getHighlightedIndexOnOpen(props, state, -1),
  23207. isOpen: props.items.length >= 0
  23208. };
  23209. break;
  23210. case InputKeyDownEnter:
  23211. changes = getChangesOnSelection(props, state.highlightedIndex);
  23212. break;
  23213. case InputKeyDownEscape:
  23214. changes = _extends({
  23215. isOpen: !1,
  23216. highlightedIndex: -1
  23217. }, !state.isOpen && {
  23218. selectedItem: null,
  23219. inputValue: ""
  23220. });
  23221. break;
  23222. case InputKeyDownPageUp:
  23223. changes = {
  23224. highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled, !0)
  23225. };
  23226. break;
  23227. case InputKeyDownPageDown:
  23228. changes = {
  23229. highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled, !0)
  23230. };
  23231. break;
  23232. case InputKeyDownHome:
  23233. changes = {
  23234. highlightedIndex: getNonDisabledIndex(0, !1, props.items, props.isItemDisabled)
  23235. };
  23236. break;
  23237. case InputKeyDownEnd:
  23238. changes = {
  23239. highlightedIndex: getNonDisabledIndex(props.items.length - 1, !0, props.items, props.isItemDisabled)
  23240. };
  23241. break;
  23242. case InputBlur:
  23243. changes = _extends({
  23244. isOpen: !1,
  23245. highlightedIndex: -1
  23246. }, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && action.selectItem && {
  23247. selectedItem: props.items[state.highlightedIndex],
  23248. inputValue: props.itemToString(props.items[state.highlightedIndex])
  23249. });
  23250. break;
  23251. case InputChange:
  23252. changes = {
  23253. isOpen: !0,
  23254. highlightedIndex: getDefaultHighlightedIndex(props),
  23255. inputValue: action.inputValue
  23256. };
  23257. break;
  23258. case InputClick:
  23259. changes = {
  23260. isOpen: !state.isOpen,
  23261. highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
  23262. };
  23263. break;
  23264. case FunctionSelectItem:
  23265. changes = {
  23266. selectedItem: action.selectedItem,
  23267. inputValue: props.itemToString(action.selectedItem)
  23268. };
  23269. break;
  23270. case ControlledPropUpdatedSelectedItem:
  23271. changes = {
  23272. inputValue: action.inputValue
  23273. };
  23274. break;
  23275. default:
  23276. return downshiftCommonReducer(state, action, stateChangeTypes$1);
  23277. }
  23278. return _extends({}, state, changes);
  23279. }
  23280. var _excluded$12 = ["onMouseLeave", "refKey", "ref"], _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onMouseDown", "onClick", "onPress", "disabled"], _excluded3 = ["onClick", "onPress", "refKey", "ref"], _excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "onClick", "refKey", "ref"];
  23281. useCombobox.stateChangeTypes = stateChangeTypes$1;
  23282. function useCombobox(userProps) {
  23283. userProps === void 0 && (userProps = {}), validatePropTypes$1(userProps, useCombobox);
  23284. var props = _extends({}, defaultProps$1, userProps), items = props.items, scrollIntoView3 = props.scrollIntoView, environment = props.environment, getA11yStatusMessage2 = props.getA11yStatusMessage, _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$1, isDropdownsStateEqual), state = _useControlledReducer[0], dispatch = _useControlledReducer[1], isOpen = state.isOpen, highlightedIndex = state.highlightedIndex, selectedItem = state.selectedItem, inputValue = state.inputValue, menuRef = useRef(null), itemRefs = useRef({}), inputRef = useRef(null), toggleButtonRef = useRef(null), isInitialMount = useIsInitialMount(), elementIds = useElementIds(props), previousResultCountRef = useRef(), latest = useLatestRef({
  23285. state,
  23286. props
  23287. }), getItemNodeFromIndex = useCallback(function(index) {
  23288. return itemRefs.current[elementIds.getItemId(index)];
  23289. }, [elementIds]);
  23290. useA11yMessageStatus(getA11yStatusMessage2, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
  23291. var shouldScrollRef = useScrollIntoView({
  23292. menuElement: menuRef.current,
  23293. highlightedIndex,
  23294. isOpen,
  23295. itemRefs,
  23296. scrollIntoView: scrollIntoView3,
  23297. getItemNodeFromIndex
  23298. });
  23299. useControlPropsValidator({
  23300. props,
  23301. state
  23302. }), useEffect(function() {
  23303. var focusOnOpen = getInitialValue$1(props, "isOpen");
  23304. focusOnOpen && inputRef.current && inputRef.current.focus();
  23305. }, []), useEffect(function() {
  23306. isInitialMount || (previousResultCountRef.current = items.length);
  23307. });
  23308. var mouseAndTouchTrackers = useMouseAndTouchTracker(environment, useCallback(function() {
  23309. latest.current.state.isOpen && dispatch({
  23310. type: InputBlur,
  23311. selectItem: !1
  23312. });
  23313. }, [dispatch, latest]), useMemo(function() {
  23314. return [menuRef, toggleButtonRef, inputRef];
  23315. }, [menuRef.current, toggleButtonRef.current, inputRef.current])), setGetterPropCallInfo = useGetterPropsCalledChecker("getInputProps", "getMenuProps");
  23316. useEffect(function() {
  23317. isOpen || (itemRefs.current = {});
  23318. }, [isOpen]), useEffect(function() {
  23319. var _inputRef$current;
  23320. !isOpen || !(environment != null && environment.document) || !(inputRef != null && (_inputRef$current = inputRef.current) != null && _inputRef$current.focus) || environment.document.activeElement !== inputRef.current && inputRef.current.focus();
  23321. }, [isOpen, environment]);
  23322. var inputKeyDownHandlers = useMemo(function() {
  23323. return {
  23324. ArrowDown: function(event) {
  23325. event.preventDefault(), dispatch({
  23326. type: InputKeyDownArrowDown,
  23327. altKey: event.altKey
  23328. });
  23329. },
  23330. ArrowUp: function(event) {
  23331. event.preventDefault(), dispatch({
  23332. type: InputKeyDownArrowUp,
  23333. altKey: event.altKey
  23334. });
  23335. },
  23336. Home: function(event) {
  23337. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23338. type: InputKeyDownHome
  23339. }));
  23340. },
  23341. End: function(event) {
  23342. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23343. type: InputKeyDownEnd
  23344. }));
  23345. },
  23346. Escape: function(event) {
  23347. var latestState = latest.current.state;
  23348. (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) && (event.preventDefault(), dispatch({
  23349. type: InputKeyDownEscape
  23350. }));
  23351. },
  23352. Enter: function(event) {
  23353. var latestState = latest.current.state;
  23354. !latestState.isOpen || event.which === 229 || (event.preventDefault(), dispatch({
  23355. type: InputKeyDownEnter
  23356. }));
  23357. },
  23358. PageUp: function(event) {
  23359. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23360. type: InputKeyDownPageUp
  23361. }));
  23362. },
  23363. PageDown: function(event) {
  23364. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23365. type: InputKeyDownPageDown
  23366. }));
  23367. }
  23368. };
  23369. }, [dispatch, latest]), getLabelProps = useCallback(function(labelProps) {
  23370. return _extends({
  23371. id: elementIds.labelId,
  23372. htmlFor: elementIds.inputId
  23373. }, labelProps);
  23374. }, [elementIds]), getMenuProps = useCallback(function(_temp, _temp2) {
  23375. var _extends22, _ref = _temp === void 0 ? {} : _temp, onMouseLeave = _ref.onMouseLeave, _ref$refKey = _ref.refKey, refKey = _ref$refKey === void 0 ? "ref" : _ref$refKey, ref = _ref.ref, rest2 = _objectWithoutPropertiesLoose2(_ref, _excluded$12), _ref2 = _temp2 === void 0 ? {} : _temp2, _ref2$suppressRefErro = _ref2.suppressRefError, suppressRefError = _ref2$suppressRefErro === void 0 ? !1 : _ref2$suppressRefErro;
  23376. return setGetterPropCallInfo("getMenuProps", suppressRefError, refKey, menuRef), _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, function(menuNode) {
  23377. menuRef.current = menuNode;
  23378. }), _extends22.id = elementIds.menuId, _extends22.role = "listbox", _extends22["aria-labelledby"] = rest2 && rest2["aria-label"] ? void 0 : "" + elementIds.labelId, _extends22.onMouseLeave = callAllEventHandlers(onMouseLeave, function() {
  23379. dispatch({
  23380. type: MenuMouseLeave
  23381. });
  23382. }), _extends22), rest2);
  23383. }, [dispatch, setGetterPropCallInfo, elementIds]), getItemProps = useCallback(function(_temp3) {
  23384. var _extends3, _ref4, _ref3 = _temp3 === void 0 ? {} : _temp3, itemProp = _ref3.item, indexProp = _ref3.index, _ref3$refKey = _ref3.refKey, refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey, ref = _ref3.ref, onMouseMove = _ref3.onMouseMove, onMouseDown = _ref3.onMouseDown, onClick = _ref3.onClick;
  23385. _ref3.onPress;
  23386. var disabledProp = _ref3.disabled, rest2 = _objectWithoutPropertiesLoose2(_ref3, _excluded2$1);
  23387. disabledProp !== void 0 && console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');
  23388. var _latest$current = latest.current, latestProps = _latest$current.props, latestState = _latest$current.state, _getItemAndIndex = getItemAndIndex(itemProp, indexProp, latestProps.items, "Pass either item or index to getItemProps!"), item = _getItemAndIndex[0], index = _getItemAndIndex[1], disabled = latestProps.isItemDisabled(item, index), onSelectKey = "onClick", customClickHandler = onClick, itemHandleMouseMove = function() {
  23389. mouseAndTouchTrackers.isTouchEnd || index === latestState.highlightedIndex || (shouldScrollRef.current = !1, dispatch({
  23390. type: ItemMouseMove,
  23391. index,
  23392. disabled
  23393. }));
  23394. }, itemHandleClick = function() {
  23395. dispatch({
  23396. type: ItemClick,
  23397. index
  23398. });
  23399. }, itemHandleMouseDown = function(e2) {
  23400. return e2.preventDefault();
  23401. };
  23402. return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(itemNode) {
  23403. itemNode && (itemRefs.current[elementIds.getItemId(index)] = itemNode);
  23404. }), _extends3["aria-disabled"] = disabled, _extends3["aria-selected"] = index === latestState.highlightedIndex, _extends3.id = elementIds.getItemId(index), _extends3.role = "option", _extends3), !disabled && (_ref4 = {}, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, itemHandleClick), _ref4), {
  23405. onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
  23406. onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
  23407. }, rest2);
  23408. }, [dispatch, elementIds, latest, mouseAndTouchTrackers, shouldScrollRef]), getToggleButtonProps = useCallback(function(_temp4) {
  23409. var _extends4, _ref5 = _temp4 === void 0 ? {} : _temp4, onClick = _ref5.onClick;
  23410. _ref5.onPress;
  23411. var _ref5$refKey = _ref5.refKey, refKey = _ref5$refKey === void 0 ? "ref" : _ref5$refKey, ref = _ref5.ref, rest2 = _objectWithoutPropertiesLoose2(_ref5, _excluded3), latestState = latest.current.state, toggleButtonHandleClick = function() {
  23412. dispatch({
  23413. type: ToggleButtonClick
  23414. });
  23415. };
  23416. return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function(toggleButtonNode) {
  23417. toggleButtonRef.current = toggleButtonNode;
  23418. }), _extends4["aria-controls"] = elementIds.menuId, _extends4["aria-expanded"] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest2.disabled && _extends({}, {
  23419. onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
  23420. }), rest2);
  23421. }, [dispatch, latest, elementIds]), getInputProps = useCallback(function(_temp5, _temp6) {
  23422. var _extends5, _ref6 = _temp5 === void 0 ? {} : _temp5, onKeyDown = _ref6.onKeyDown, onChange = _ref6.onChange, onInput = _ref6.onInput, onBlur = _ref6.onBlur;
  23423. _ref6.onChangeText;
  23424. var onClick = _ref6.onClick, _ref6$refKey = _ref6.refKey, refKey = _ref6$refKey === void 0 ? "ref" : _ref6$refKey, ref = _ref6.ref, rest2 = _objectWithoutPropertiesLoose2(_ref6, _excluded4), _ref7 = _temp6 === void 0 ? {} : _temp6, _ref7$suppressRefErro = _ref7.suppressRefError, suppressRefError = _ref7$suppressRefErro === void 0 ? !1 : _ref7$suppressRefErro;
  23425. setGetterPropCallInfo("getInputProps", suppressRefError, refKey, inputRef);
  23426. var latestState = latest.current.state, inputHandleKeyDown = function(event) {
  23427. var key = normalizeArrowKey(event);
  23428. key && inputKeyDownHandlers[key] && inputKeyDownHandlers[key](event);
  23429. }, inputHandleChange = function(event) {
  23430. dispatch({
  23431. type: InputChange,
  23432. inputValue: event.target.value
  23433. });
  23434. }, inputHandleBlur = function(event) {
  23435. if (environment != null && environment.document && latestState.isOpen && !mouseAndTouchTrackers.isMouseDown) {
  23436. var isBlurByTabChange = event.relatedTarget === null && environment.document.activeElement !== environment.document.body;
  23437. dispatch({
  23438. type: InputBlur,
  23439. selectItem: !isBlurByTabChange
  23440. });
  23441. }
  23442. }, inputHandleClick = function() {
  23443. dispatch({
  23444. type: InputClick
  23445. });
  23446. }, onChangeKey = "onChange", eventHandlers = {};
  23447. if (!rest2.disabled) {
  23448. var _eventHandlers;
  23449. eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
  23450. }
  23451. return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function(inputNode) {
  23452. inputRef.current = inputNode;
  23453. }), _extends5["aria-activedescendant"] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : "", _extends5["aria-autocomplete"] = "list", _extends5["aria-controls"] = elementIds.menuId, _extends5["aria-expanded"] = latestState.isOpen, _extends5["aria-labelledby"] = rest2 && rest2["aria-label"] ? void 0 : elementIds.labelId, _extends5.autoComplete = "off", _extends5.id = elementIds.inputId, _extends5.role = "combobox", _extends5.value = latestState.inputValue, _extends5), eventHandlers, rest2);
  23454. }, [dispatch, elementIds, environment, inputKeyDownHandlers, latest, mouseAndTouchTrackers, setGetterPropCallInfo]), toggleMenu = useCallback(function() {
  23455. dispatch({
  23456. type: FunctionToggleMenu
  23457. });
  23458. }, [dispatch]), closeMenu = useCallback(function() {
  23459. dispatch({
  23460. type: FunctionCloseMenu
  23461. });
  23462. }, [dispatch]), openMenu = useCallback(function() {
  23463. dispatch({
  23464. type: FunctionOpenMenu
  23465. });
  23466. }, [dispatch]), setHighlightedIndex = useCallback(function(newHighlightedIndex) {
  23467. dispatch({
  23468. type: FunctionSetHighlightedIndex,
  23469. highlightedIndex: newHighlightedIndex
  23470. });
  23471. }, [dispatch]), selectItem = useCallback(function(newSelectedItem) {
  23472. dispatch({
  23473. type: FunctionSelectItem,
  23474. selectedItem: newSelectedItem
  23475. });
  23476. }, [dispatch]), setInputValue = useCallback(function(newInputValue) {
  23477. dispatch({
  23478. type: FunctionSetInputValue,
  23479. inputValue: newInputValue
  23480. });
  23481. }, [dispatch]), reset = useCallback(function() {
  23482. dispatch({
  23483. type: FunctionReset$1
  23484. });
  23485. }, [dispatch]);
  23486. return {
  23487. // prop getters.
  23488. getItemProps,
  23489. getLabelProps,
  23490. getMenuProps,
  23491. getInputProps,
  23492. getToggleButtonProps,
  23493. // actions.
  23494. toggleMenu,
  23495. openMenu,
  23496. closeMenu,
  23497. setHighlightedIndex,
  23498. setInputValue,
  23499. selectItem,
  23500. reset,
  23501. // state.
  23502. highlightedIndex,
  23503. isOpen,
  23504. selectedItem,
  23505. inputValue
  23506. };
  23507. }
  23508. var defaultStateValues = {
  23509. activeIndex: -1,
  23510. selectedItems: []
  23511. };
  23512. function getInitialValue(props, propKey) {
  23513. return getInitialValue$1(props, propKey, defaultStateValues);
  23514. }
  23515. function getDefaultValue(props, propKey) {
  23516. return getDefaultValue$1(props, propKey, defaultStateValues);
  23517. }
  23518. function getInitialState(props) {
  23519. var activeIndex = getInitialValue(props, "activeIndex"), selectedItems = getInitialValue(props, "selectedItems");
  23520. return {
  23521. activeIndex,
  23522. selectedItems
  23523. };
  23524. }
  23525. function isKeyDownOperationPermitted(event) {
  23526. if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey)
  23527. return !1;
  23528. var element = event.target;
  23529. return !(element instanceof HTMLInputElement && // if element is a text input
  23530. element.value !== "" && // and we have text in it
  23531. // and cursor is either not at the start or is currently highlighting text.
  23532. (element.selectionStart !== 0 || element.selectionEnd !== 0));
  23533. }
  23534. function isStateEqual(prevState, newState) {
  23535. return prevState.selectedItems === newState.selectedItems && prevState.activeIndex === newState.activeIndex;
  23536. }
  23537. var propTypes = {
  23538. stateReducer: commonPropTypes.stateReducer,
  23539. itemToKey: commonPropTypes.itemToKey,
  23540. environment: commonPropTypes.environment,
  23541. selectedItems: import_prop_types3.default.array,
  23542. initialSelectedItems: import_prop_types3.default.array,
  23543. defaultSelectedItems: import_prop_types3.default.array,
  23544. getA11yStatusMessage: import_prop_types3.default.func,
  23545. activeIndex: import_prop_types3.default.number,
  23546. initialActiveIndex: import_prop_types3.default.number,
  23547. defaultActiveIndex: import_prop_types3.default.number,
  23548. onActiveIndexChange: import_prop_types3.default.func,
  23549. onSelectedItemsChange: import_prop_types3.default.func,
  23550. keyNavigationNext: import_prop_types3.default.string,
  23551. keyNavigationPrevious: import_prop_types3.default.string
  23552. }, defaultProps2 = {
  23553. itemToKey: defaultProps$3.itemToKey,
  23554. stateReducer: defaultProps$3.stateReducer,
  23555. environment: defaultProps$3.environment,
  23556. keyNavigationNext: "ArrowRight",
  23557. keyNavigationPrevious: "ArrowLeft"
  23558. }, validatePropTypes = noop4, SelectedItemClick = 0, SelectedItemKeyDownDelete = 1, SelectedItemKeyDownBackspace = 2, SelectedItemKeyDownNavigationNext = 3, SelectedItemKeyDownNavigationPrevious = 4, DropdownKeyDownNavigationPrevious = 5, DropdownKeyDownBackspace = 6, DropdownClick = 7, FunctionAddSelectedItem = 8, FunctionRemoveSelectedItem = 9, FunctionSetSelectedItems = 10, FunctionSetActiveIndex = 11, FunctionReset = 12, stateChangeTypes = Object.freeze({
  23559. __proto__: null,
  23560. DropdownClick,
  23561. DropdownKeyDownBackspace,
  23562. DropdownKeyDownNavigationPrevious,
  23563. FunctionAddSelectedItem,
  23564. FunctionRemoveSelectedItem,
  23565. FunctionReset,
  23566. FunctionSetActiveIndex,
  23567. FunctionSetSelectedItems,
  23568. SelectedItemClick,
  23569. SelectedItemKeyDownBackspace,
  23570. SelectedItemKeyDownDelete,
  23571. SelectedItemKeyDownNavigationNext,
  23572. SelectedItemKeyDownNavigationPrevious
  23573. });
  23574. function downshiftMultipleSelectionReducer(state, action) {
  23575. var type = action.type, index = action.index, props = action.props, selectedItem = action.selectedItem, activeIndex = state.activeIndex, selectedItems = state.selectedItems, changes;
  23576. switch (type) {
  23577. case SelectedItemClick:
  23578. changes = {
  23579. activeIndex: index
  23580. };
  23581. break;
  23582. case SelectedItemKeyDownNavigationPrevious:
  23583. changes = {
  23584. activeIndex: activeIndex - 1 < 0 ? 0 : activeIndex - 1
  23585. };
  23586. break;
  23587. case SelectedItemKeyDownNavigationNext:
  23588. changes = {
  23589. activeIndex: activeIndex + 1 >= selectedItems.length ? -1 : activeIndex + 1
  23590. };
  23591. break;
  23592. case SelectedItemKeyDownBackspace:
  23593. case SelectedItemKeyDownDelete: {
  23594. if (activeIndex < 0)
  23595. break;
  23596. var newActiveIndex = activeIndex;
  23597. selectedItems.length === 1 ? newActiveIndex = -1 : activeIndex === selectedItems.length - 1 && (newActiveIndex = selectedItems.length - 2), changes = _extends({
  23598. selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
  23599. }, {
  23600. activeIndex: newActiveIndex
  23601. });
  23602. break;
  23603. }
  23604. case DropdownKeyDownNavigationPrevious:
  23605. changes = {
  23606. activeIndex: selectedItems.length - 1
  23607. };
  23608. break;
  23609. case DropdownKeyDownBackspace:
  23610. changes = {
  23611. selectedItems: selectedItems.slice(0, selectedItems.length - 1)
  23612. };
  23613. break;
  23614. case FunctionAddSelectedItem:
  23615. changes = {
  23616. selectedItems: [].concat(selectedItems, [selectedItem])
  23617. };
  23618. break;
  23619. case DropdownClick:
  23620. changes = {
  23621. activeIndex: -1
  23622. };
  23623. break;
  23624. case FunctionRemoveSelectedItem: {
  23625. var _newActiveIndex = activeIndex, selectedItemIndex = selectedItems.findIndex(function(item) {
  23626. return props.itemToKey(item) === props.itemToKey(selectedItem);
  23627. });
  23628. if (selectedItemIndex < 0)
  23629. break;
  23630. selectedItems.length === 1 ? _newActiveIndex = -1 : selectedItemIndex === selectedItems.length - 1 && (_newActiveIndex = selectedItems.length - 2), changes = {
  23631. selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1)),
  23632. activeIndex: _newActiveIndex
  23633. };
  23634. break;
  23635. }
  23636. case FunctionSetSelectedItems: {
  23637. var newSelectedItems = action.selectedItems;
  23638. changes = {
  23639. selectedItems: newSelectedItems
  23640. };
  23641. break;
  23642. }
  23643. case FunctionSetActiveIndex: {
  23644. var _newActiveIndex2 = action.activeIndex;
  23645. changes = {
  23646. activeIndex: _newActiveIndex2
  23647. };
  23648. break;
  23649. }
  23650. case FunctionReset:
  23651. changes = {
  23652. activeIndex: getDefaultValue(props, "activeIndex"),
  23653. selectedItems: getDefaultValue(props, "selectedItems")
  23654. };
  23655. break;
  23656. default:
  23657. throw new Error("Reducer called without proper action type.");
  23658. }
  23659. return _extends({}, state, changes);
  23660. }
  23661. var _excluded2 = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"], _excluded22 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
  23662. useMultipleSelection.stateChangeTypes = stateChangeTypes;
  23663. function useMultipleSelection(userProps) {
  23664. userProps === void 0 && (userProps = {}), validatePropTypes(userProps, useMultipleSelection);
  23665. var props = _extends({}, defaultProps2, userProps), getA11yStatusMessage2 = props.getA11yStatusMessage, environment = props.environment, keyNavigationNext = props.keyNavigationNext, keyNavigationPrevious = props.keyNavigationPrevious, _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, props, getInitialState, isStateEqual), state = _useControlledReducer[0], dispatch = _useControlledReducer[1], activeIndex = state.activeIndex, selectedItems = state.selectedItems, isInitialMount = useIsInitialMount(), dropdownRef = useRef(null), selectedItemRefs = useRef();
  23666. selectedItemRefs.current = [];
  23667. var latest = useLatestRef({
  23668. state,
  23669. props
  23670. });
  23671. useA11yMessageStatus(getA11yStatusMessage2, state, [activeIndex, selectedItems], environment), useEffect(function() {
  23672. isInitialMount || (activeIndex === -1 && dropdownRef.current ? dropdownRef.current.focus() : selectedItemRefs.current[activeIndex] && selectedItemRefs.current[activeIndex].focus());
  23673. }, [activeIndex]), useControlPropsValidator({
  23674. props,
  23675. state
  23676. });
  23677. var setGetterPropCallInfo = useGetterPropsCalledChecker("getDropdownProps"), selectedItemKeyDownHandlers = useMemo(function() {
  23678. var _ref;
  23679. return _ref = {}, _ref[keyNavigationPrevious] = function() {
  23680. dispatch({
  23681. type: SelectedItemKeyDownNavigationPrevious
  23682. });
  23683. }, _ref[keyNavigationNext] = function() {
  23684. dispatch({
  23685. type: SelectedItemKeyDownNavigationNext
  23686. });
  23687. }, _ref.Delete = function() {
  23688. dispatch({
  23689. type: SelectedItemKeyDownDelete
  23690. });
  23691. }, _ref.Backspace = function() {
  23692. dispatch({
  23693. type: SelectedItemKeyDownBackspace
  23694. });
  23695. }, _ref;
  23696. }, [dispatch, keyNavigationNext, keyNavigationPrevious]), dropdownKeyDownHandlers = useMemo(function() {
  23697. var _ref2;
  23698. return _ref2 = {}, _ref2[keyNavigationPrevious] = function(event) {
  23699. isKeyDownOperationPermitted(event) && dispatch({
  23700. type: DropdownKeyDownNavigationPrevious
  23701. });
  23702. }, _ref2.Backspace = function(event) {
  23703. isKeyDownOperationPermitted(event) && dispatch({
  23704. type: DropdownKeyDownBackspace
  23705. });
  23706. }, _ref2;
  23707. }, [dispatch, keyNavigationPrevious]), getSelectedItemProps = useCallback(function(_temp) {
  23708. var _extends22, _ref3 = _temp === void 0 ? {} : _temp, _ref3$refKey = _ref3.refKey, refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey, ref = _ref3.ref, onClick = _ref3.onClick, onKeyDown = _ref3.onKeyDown, selectedItemProp = _ref3.selectedItem, indexProp = _ref3.index, rest2 = _objectWithoutPropertiesLoose2(_ref3, _excluded2), latestState = latest.current.state, _getItemAndIndex = getItemAndIndex(selectedItemProp, indexProp, latestState.selectedItems, "Pass either item or index to getSelectedItemProps!"), index = _getItemAndIndex[1], isFocusable = index > -1 && index === latestState.activeIndex, selectedItemHandleClick = function() {
  23709. dispatch({
  23710. type: SelectedItemClick,
  23711. index
  23712. });
  23713. }, selectedItemHandleKeyDown = function(event) {
  23714. var key = normalizeArrowKey(event);
  23715. key && selectedItemKeyDownHandlers[key] && selectedItemKeyDownHandlers[key](event);
  23716. };
  23717. return _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, function(selectedItemNode) {
  23718. selectedItemNode && selectedItemRefs.current.push(selectedItemNode);
  23719. }), _extends22.tabIndex = isFocusable ? 0 : -1, _extends22.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends22.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends22), rest2);
  23720. }, [dispatch, latest, selectedItemKeyDownHandlers]), getDropdownProps = useCallback(function(_temp2, _temp3) {
  23721. var _extends3, _ref4 = _temp2 === void 0 ? {} : _temp2, _ref4$refKey = _ref4.refKey, refKey = _ref4$refKey === void 0 ? "ref" : _ref4$refKey, ref = _ref4.ref, onKeyDown = _ref4.onKeyDown, onClick = _ref4.onClick, _ref4$preventKeyActio = _ref4.preventKeyAction, preventKeyAction = _ref4$preventKeyActio === void 0 ? !1 : _ref4$preventKeyActio, rest2 = _objectWithoutPropertiesLoose2(_ref4, _excluded22), _ref5 = _temp3 === void 0 ? {} : _temp3, _ref5$suppressRefErro = _ref5.suppressRefError, suppressRefError = _ref5$suppressRefErro === void 0 ? !1 : _ref5$suppressRefErro;
  23722. setGetterPropCallInfo("getDropdownProps", suppressRefError, refKey, dropdownRef);
  23723. var dropdownHandleKeyDown = function(event) {
  23724. var key = normalizeArrowKey(event);
  23725. key && dropdownKeyDownHandlers[key] && dropdownKeyDownHandlers[key](event);
  23726. }, dropdownHandleClick = function() {
  23727. dispatch({
  23728. type: DropdownClick
  23729. });
  23730. };
  23731. return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(dropdownNode) {
  23732. dropdownNode && (dropdownRef.current = dropdownNode);
  23733. }), _extends3), !preventKeyAction && {
  23734. onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
  23735. onClick: callAllEventHandlers(onClick, dropdownHandleClick)
  23736. }, rest2);
  23737. }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]), addSelectedItem = useCallback(function(selectedItem) {
  23738. dispatch({
  23739. type: FunctionAddSelectedItem,
  23740. selectedItem
  23741. });
  23742. }, [dispatch]), removeSelectedItem = useCallback(function(selectedItem) {
  23743. dispatch({
  23744. type: FunctionRemoveSelectedItem,
  23745. selectedItem
  23746. });
  23747. }, [dispatch]), setSelectedItems = useCallback(function(newSelectedItems) {
  23748. dispatch({
  23749. type: FunctionSetSelectedItems,
  23750. selectedItems: newSelectedItems
  23751. });
  23752. }, [dispatch]), setActiveIndex = useCallback(function(newActiveIndex) {
  23753. dispatch({
  23754. type: FunctionSetActiveIndex,
  23755. activeIndex: newActiveIndex
  23756. });
  23757. }, [dispatch]), reset = useCallback(function() {
  23758. dispatch({
  23759. type: FunctionReset
  23760. });
  23761. }, [dispatch]);
  23762. return {
  23763. getSelectedItemProps,
  23764. getDropdownProps,
  23765. addSelectedItem,
  23766. removeSelectedItem,
  23767. setSelectedItems,
  23768. setActiveIndex,
  23769. reset,
  23770. selectedItems,
  23771. activeIndex
  23772. };
  23773. }
  23774. // src/manager/components/sidebar/Search.tsx
  23775. var import_fuse = __toESM(require_fuse(), 1);
  23776. // src/manager/components/sidebar/types.ts
  23777. function isExpandType(x2) {
  23778. return !!(x2 && x2.showAll);
  23779. }
  23780. function isSearchResult(x2) {
  23781. return !!(x2 && x2.item);
  23782. }
  23783. // src/manager/components/sidebar/Search.tsx
  23784. var { document: document7 } = scope, DEFAULT_MAX_SEARCH_RESULTS = 50, options = {
  23785. shouldSort: !0,
  23786. tokenize: !0,
  23787. findAllMatches: !0,
  23788. includeScore: !0,
  23789. includeMatches: !0,
  23790. threshold: 0.2,
  23791. location: 0,
  23792. distance: 100,
  23793. maxPatternLength: 32,
  23794. minMatchCharLength: 1,
  23795. keys: [
  23796. { name: "name", weight: 0.7 },
  23797. { name: "path", weight: 0.3 }
  23798. ]
  23799. }, SearchBar = styled.div({
  23800. display: "flex",
  23801. flexDirection: "row",
  23802. columnGap: 6
  23803. }), ScreenReaderLabel = styled.label({
  23804. position: "absolute",
  23805. left: -1e4,
  23806. top: "auto",
  23807. width: 1,
  23808. height: 1,
  23809. overflow: "hidden"
  23810. }), SearchField2 = styled.div(({ theme, isMobile: isMobile2 }) => ({
  23811. display: "flex",
  23812. flexDirection: "row",
  23813. alignItems: "center",
  23814. padding: isMobile2 ? 4 : 2,
  23815. flexGrow: 1,
  23816. height: isMobile2 ? 36 : 32,
  23817. width: "100%",
  23818. boxShadow: `${theme.button.border} 0 0 0 1px inset`,
  23819. borderRadius: theme.appBorderRadius + 2,
  23820. "&:has(input:focus), &:has(input:active)": {
  23821. background: theme.background.app,
  23822. outline: `2px solid ${theme.color.secondary}`,
  23823. outlineOffset: 2
  23824. }
  23825. })), IconWrapper = styled.div(({ theme, onClick }) => ({
  23826. cursor: onClick ? "pointer" : "default",
  23827. flex: "0 0 28px",
  23828. height: "100%",
  23829. pointerEvents: onClick ? "auto" : "none",
  23830. color: theme.textMutedColor,
  23831. display: "flex",
  23832. alignItems: "center",
  23833. justifyContent: "center"
  23834. })), Input = styled.input(({ theme, isMobile: isMobile2 }) => ({
  23835. appearance: "none",
  23836. height: 28,
  23837. width: "100%",
  23838. padding: 0,
  23839. border: 0,
  23840. background: "transparent",
  23841. fontSize: isMobile2 ? "16px" : `${theme.typography.size.s1 + 1}px`,
  23842. fontFamily: "inherit",
  23843. transition: "all 150ms",
  23844. color: theme.color.defaultText,
  23845. outline: 0,
  23846. "&::placeholder": {
  23847. color: theme.textMutedColor,
  23848. opacity: 1
  23849. },
  23850. "&:valid ~ code, &:focus ~ code": {
  23851. display: "none"
  23852. },
  23853. "&:invalid ~ svg": {
  23854. display: "none"
  23855. },
  23856. "&:valid ~ svg": {
  23857. display: "block"
  23858. },
  23859. "&::-ms-clear": {
  23860. display: "none"
  23861. },
  23862. "&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration": {
  23863. display: "none"
  23864. }
  23865. })), FocusKey = styled.code(({ theme }) => ({
  23866. margin: 5,
  23867. marginTop: 6,
  23868. height: 16,
  23869. fontFamily: theme.typography.fonts.base,
  23870. lineHeight: "16px",
  23871. textAlign: "center",
  23872. fontSize: "11px",
  23873. color: theme.base === "light" ? theme.color.dark : theme.textMutedColor,
  23874. userSelect: "none",
  23875. pointerEvents: "none",
  23876. display: "flex",
  23877. alignItems: "center",
  23878. gap: 4,
  23879. flexShrink: 0
  23880. })), FocusKeyCmd = styled.span({
  23881. fontSize: "14px"
  23882. }), Actions = styled.div({
  23883. display: "flex",
  23884. alignItems: "center",
  23885. gap: 2
  23886. }), FocusContainer = styled.div({ outline: 0 }), Search = react_default.memo(function({
  23887. children,
  23888. dataset,
  23889. enableShortcuts = !0,
  23890. getLastViewed,
  23891. initialQuery = "",
  23892. searchBarContent,
  23893. searchFieldContent,
  23894. belowSearchContent
  23895. }) {
  23896. let api = useStorybookApi(), inputRef = useRef(null), [inputPlaceholder, setPlaceholder] = useState("Find components"), [allComponents, showAllComponents] = useState(!1), searchShortcut = api ? shortcutToHumanString(api.getShortcutKeys().search) : "/", makeFuse = useCallback(() => {
  23897. let list = dataset.entries.reduce((acc, [refId, { index, allStatuses }]) => {
  23898. let groupStatus = getGroupStatus(index || {}, allStatuses ?? {});
  23899. return index && acc.push(
  23900. ...Object.values(index).map((item) => {
  23901. let storyStatuses = allStatuses?.[item.id], mostCriticalStatusValue = storyStatuses ? getMostCriticalStatusValue(Object.values(storyStatuses).map((s2) => s2.value)) : null;
  23902. return {
  23903. ...searchItem(item, dataset.hash[refId]),
  23904. status: mostCriticalStatusValue ?? groupStatus[item.id] ?? null
  23905. };
  23906. })
  23907. ), acc;
  23908. }, []);
  23909. return new import_fuse.default(list, options);
  23910. }, [dataset]), getResults = useCallback(
  23911. (input) => {
  23912. let fuse = makeFuse();
  23913. if (!input)
  23914. return [];
  23915. let results = [], resultIds = /* @__PURE__ */ new Set(), distinctResults = fuse.search(input).filter(({ item }) => !(item.type === "component" || item.type === "docs" || item.type === "story") || // @ts-expect-error (non strict)
  23916. resultIds.has(item.parent) ? !1 : (resultIds.add(item.id), !0));
  23917. return distinctResults.length && (results = distinctResults.slice(0, allComponents ? 1e3 : DEFAULT_MAX_SEARCH_RESULTS), distinctResults.length > DEFAULT_MAX_SEARCH_RESULTS && !allComponents && results.push({
  23918. showAll: () => showAllComponents(!0),
  23919. totalCount: distinctResults.length,
  23920. moreCount: distinctResults.length - DEFAULT_MAX_SEARCH_RESULTS
  23921. })), results;
  23922. },
  23923. [allComponents, makeFuse]
  23924. ), onSelect = useCallback(
  23925. (selectedItem) => {
  23926. if (isSearchResult(selectedItem)) {
  23927. let { id, refId } = selectedItem.item;
  23928. api?.selectStory(id, void 0, { ref: refId !== DEFAULT_REF_ID && refId }), inputRef.current.blur(), showAllComponents(!1);
  23929. return;
  23930. }
  23931. isExpandType(selectedItem) && selectedItem.showAll();
  23932. },
  23933. [api]
  23934. ), onInputValueChange = useCallback((inputValue, stateAndHelpers) => {
  23935. showAllComponents(!1);
  23936. }, []), stateReducer2 = useCallback(
  23937. (state, changes) => {
  23938. switch (changes.type) {
  23939. case Downshift.stateChangeTypes.blurInput:
  23940. return {
  23941. ...changes,
  23942. // Prevent clearing the input on blur
  23943. inputValue: state.inputValue,
  23944. // Return to the tree view after selecting an item
  23945. isOpen: state.inputValue && !state.selectedItem
  23946. };
  23947. case Downshift.stateChangeTypes.mouseUp:
  23948. return state;
  23949. case Downshift.stateChangeTypes.keyDownEscape:
  23950. return state.inputValue ? { ...changes, inputValue: "", isOpen: !0, selectedItem: null } : { ...changes, isOpen: !1, selectedItem: null };
  23951. case Downshift.stateChangeTypes.clickItem:
  23952. case Downshift.stateChangeTypes.keyDownEnter:
  23953. return isSearchResult(changes.selectedItem) ? { ...changes, inputValue: state.inputValue } : isExpandType(changes.selectedItem) ? state : changes;
  23954. default:
  23955. return changes;
  23956. }
  23957. },
  23958. []
  23959. ), { isMobile: isMobile2 } = useLayout(), searchLandmarkRef = useRef(null), { landmarkProps } = useLandmark({ role: "search" }, searchLandmarkRef);
  23960. return (
  23961. // @ts-expect-error (non strict)
  23962. react_default.createElement(
  23963. Downshift,
  23964. {
  23965. initialInputValue: initialQuery,
  23966. stateReducer: stateReducer2,
  23967. itemToString: (result) => result?.item?.name || "",
  23968. scrollIntoView: (e2) => scrollIntoView(e2),
  23969. onSelect,
  23970. onInputValueChange
  23971. },
  23972. ({
  23973. isOpen,
  23974. openMenu,
  23975. closeMenu,
  23976. inputValue,
  23977. getInputProps,
  23978. getItemProps,
  23979. getLabelProps,
  23980. getMenuProps,
  23981. getRootProps,
  23982. highlightedIndex,
  23983. reset
  23984. }) => {
  23985. let input = inputValue ? inputValue.trim() : "", results = input ? getResults(input) : [], lastViewed = !input && getLastViewed();
  23986. lastViewed && lastViewed.length && (results = lastViewed.reduce((acc, { storyId, refId }) => {
  23987. let data = dataset.hash[refId];
  23988. if (data && data.index && data.index[storyId]) {
  23989. let story = data.index[storyId], item = story.type === "story" ? data.index[story.parent] : story;
  23990. acc.some((res) => res.item.refId === refId && res.item.id === item.id) || acc.push({ item: searchItem(item, dataset.hash[refId]), matches: [], score: 0 });
  23991. }
  23992. return acc;
  23993. }, []));
  23994. let inputId = "storybook-explorer-searchfield", inputProps = getInputProps({
  23995. id: inputId,
  23996. ref: inputRef,
  23997. required: !0,
  23998. type: "search",
  23999. placeholder: inputPlaceholder,
  24000. onFocus: () => {
  24001. openMenu(), setPlaceholder("Type to find...");
  24002. },
  24003. onBlur: () => setPlaceholder("Find components"),
  24004. onKeyDown: (e2) => {
  24005. e2.key === "Escape" && inputValue.length === 0 && inputRef.current.blur();
  24006. }
  24007. }), labelProps = getLabelProps({
  24008. htmlFor: inputId
  24009. });
  24010. return react_default.createElement(react_default.Fragment, null, react_default.createElement(ScreenReaderLabel, { ...labelProps }, "Search for components"), react_default.createElement(SearchBar, { ref: searchLandmarkRef, ...landmarkProps }, react_default.createElement(
  24011. SearchField2,
  24012. {
  24013. ...getRootProps({ refKey: "" }, { suppressRefError: !0 }),
  24014. isMobile: isMobile2,
  24015. className: "search-field"
  24016. },
  24017. react_default.createElement(IconWrapper, null, react_default.createElement(SearchIcon, null)),
  24018. react_default.createElement(Input, { ...inputProps, isMobile: isMobile2 }),
  24019. !isMobile2 && enableShortcuts && !isOpen && react_default.createElement(FocusKey, null, searchShortcut === "\u2318 K" ? react_default.createElement(react_default.Fragment, null, react_default.createElement(FocusKeyCmd, null, "\u2318"), "K") : searchShortcut),
  24020. react_default.createElement(Actions, null, input && react_default.createElement(
  24021. Button,
  24022. {
  24023. padding: "small",
  24024. variant: "ghost",
  24025. ariaLabel: "Clear search",
  24026. onClick: () => {
  24027. reset({ inputValue: "" }), closeMenu(), inputRef.current?.focus();
  24028. }
  24029. },
  24030. react_default.createElement(CloseIcon, null)
  24031. ), searchFieldContent)
  24032. ), searchBarContent), !isOpen && belowSearchContent, react_default.createElement(FocusContainer, { tabIndex: 0, id: "storybook-explorer-menu" }, children({
  24033. query: input,
  24034. results,
  24035. isNavVisible: !isOpen && document7.activeElement !== inputRef.current,
  24036. isNavReachable: !isOpen || input.length === 0,
  24037. isSearchResultRendered: isOpen,
  24038. closeMenu,
  24039. getMenuProps,
  24040. getItemProps,
  24041. highlightedIndex
  24042. })));
  24043. }
  24044. )
  24045. );
  24046. });
  24047. // src/manager/components/sidebar/SearchResults.tsx
  24048. init_react();
  24049. var { document: document8 } = scope, ResultsList = styled.ol({
  24050. listStyle: "none",
  24051. margin: 0,
  24052. padding: 0
  24053. }), ResultRow = styled.li(({ theme, isHighlighted }) => ({
  24054. width: "100%",
  24055. border: "none",
  24056. cursor: "pointer",
  24057. display: "flex",
  24058. alignItems: "start",
  24059. justifyContent: "space-between",
  24060. textAlign: "left",
  24061. color: "inherit",
  24062. fontSize: `${theme.typography.size.s2}px`,
  24063. background: isHighlighted ? theme.background.hoverable : "transparent",
  24064. minHeight: 28,
  24065. borderRadius: 4,
  24066. gap: 6,
  24067. paddingTop: 7,
  24068. paddingBottom: 7,
  24069. paddingLeft: 8,
  24070. paddingRight: 8,
  24071. "&:hover, &:focus": {
  24072. background: curriedTransparentize$1(0.93, theme.color.secondary),
  24073. outline: "none"
  24074. }
  24075. })), IconWrapper2 = styled.div({
  24076. marginTop: 2
  24077. }), ResultRowContent = styled.div({
  24078. flex: 1,
  24079. display: "flex",
  24080. flexDirection: "column"
  24081. }), Mark = styled.mark(({ theme }) => ({
  24082. background: "transparent",
  24083. color: theme.color.secondary,
  24084. "@media (forced-colors: active)": {
  24085. color: "HighlightText",
  24086. background: "Highlight"
  24087. }
  24088. })), MoreWrapper = styled.div({
  24089. marginTop: 8
  24090. }), RecentlyOpenedTitle = styled.div(({ theme }) => ({
  24091. display: "flex",
  24092. justifyContent: "space-between",
  24093. fontSize: `${theme.typography.size.s1 - 1}px`,
  24094. fontWeight: theme.typography.weight.bold,
  24095. minHeight: 28,
  24096. letterSpacing: "0.16em",
  24097. textTransform: "uppercase",
  24098. color: theme.textMutedColor,
  24099. marginBottom: 4,
  24100. alignItems: "center",
  24101. ".search-result-recentlyOpened-clear": {
  24102. visibility: "hidden"
  24103. },
  24104. "&:hover": {
  24105. ".search-result-recentlyOpened-clear": {
  24106. visibility: "visible"
  24107. }
  24108. }
  24109. })), Highlight = react_default.memo(function({
  24110. children,
  24111. match
  24112. }) {
  24113. if (!match)
  24114. return children;
  24115. let { value, indices } = match, { nodes: result } = indices.reduce(
  24116. ({ cursor, nodes }, [start, end], index, { length }) => (nodes.push(react_default.createElement("span", { key: `${index}-1` }, value.slice(cursor, start))), nodes.push(react_default.createElement(Mark, { key: `${index}-2` }, value.slice(start, end + 1))), index === length - 1 && nodes.push(react_default.createElement("span", { key: `${index}-3` }, value.slice(end + 1))), { cursor: end + 1, nodes }),
  24117. { cursor: 0, nodes: [] }
  24118. );
  24119. return react_default.createElement("span", null, result);
  24120. }), Title = styled.div({
  24121. display: "grid",
  24122. justifyContent: "start",
  24123. gridAutoColumns: "auto",
  24124. gridAutoFlow: "column",
  24125. "& > span": {
  24126. display: "block",
  24127. whiteSpace: "nowrap",
  24128. overflow: "hidden",
  24129. textOverflow: "ellipsis"
  24130. }
  24131. }), Path = styled.div(({ theme }) => ({
  24132. display: "grid",
  24133. justifyContent: "start",
  24134. gridAutoColumns: "auto",
  24135. gridAutoFlow: "column",
  24136. fontSize: `${theme.typography.size.s1 - 1}px`,
  24137. "& > span": {
  24138. display: "block",
  24139. whiteSpace: "nowrap",
  24140. overflow: "hidden",
  24141. textOverflow: "ellipsis"
  24142. },
  24143. "& > span + span": {
  24144. "&:before": {
  24145. content: "' / '"
  24146. }
  24147. }
  24148. })), Result = react_default.memo(function({ item, matches, onClick, ...props }) {
  24149. let theme = useTheme(), click = useCallback(
  24150. (event) => {
  24151. event.preventDefault(), onClick?.(event);
  24152. },
  24153. [onClick]
  24154. ), api = useStorybookApi();
  24155. useEffect(() => {
  24156. api && props.isHighlighted && item.type === "component" && api.emit(PRELOAD_ENTRIES, { ids: [item.children[0]] }, { options: { target: item.refId } });
  24157. }, [api, props.isHighlighted, item]);
  24158. let nameMatch = matches.find((match) => match.key === "name"), pathMatches = matches.filter((match) => match.key === "path"), icon = item.status ? getStatus(theme, item.status).icon : null;
  24159. return react_default.createElement(ResultRow, { ...props, onClick: click }, react_default.createElement(IconWrapper2, null, item.type === "component" && react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "14", height: "14", type: "component" }, react_default.createElement(UseSymbol, { type: "component" })), item.type === "story" && react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "14", height: "14", type: item.subtype }, react_default.createElement(UseSymbol, { type: item.subtype })), !(item.type === "component" || item.type === "story") && react_default.createElement(TypeIcon2, { viewBox: "0 0 14 14", width: "14", height: "14", type: "document" }, react_default.createElement(UseSymbol, { type: "document" }))), react_default.createElement(ResultRowContent, { className: "search-result-item--label" }, react_default.createElement(Title, null, react_default.createElement(Highlight, { match: nameMatch }, item.name)), react_default.createElement(Path, null, item.path.map((group, index) => react_default.createElement("span", { key: index }, react_default.createElement(Highlight, { match: pathMatches.find((match) => match.arrayIndex === index) }, group))))), item.status ? react_default.createElement(StatusLabel, { status: item.status }, icon) : null);
  24160. }), SearchResults = react_default.memo(function({
  24161. query,
  24162. results,
  24163. closeMenu,
  24164. getMenuProps,
  24165. getItemProps,
  24166. highlightedIndex,
  24167. isLoading = !1,
  24168. enableShortcuts = !0,
  24169. clearLastViewed
  24170. }) {
  24171. let api = useStorybookApi();
  24172. useEffect(() => {
  24173. let handleEscape = (event) => {
  24174. if (!(!enableShortcuts || isLoading || event.repeat) && matchesModifiers(!1, event) && matchesKeyCode("Escape", event)) {
  24175. if (event.target?.id === "storybook-explorer-searchfield")
  24176. return;
  24177. event.preventDefault(), closeMenu();
  24178. }
  24179. };
  24180. return document8.addEventListener("keydown", handleEscape), () => document8.removeEventListener("keydown", handleEscape);
  24181. }, [closeMenu, enableShortcuts, isLoading]);
  24182. let mouseOverHandler = useCallback((event) => {
  24183. if (!api)
  24184. return;
  24185. let currentTarget = event.currentTarget, storyId = currentTarget.getAttribute("data-id"), refId = currentTarget.getAttribute("data-refid"), item = api.resolveStory(storyId, refId === "storybook_internal" ? void 0 : refId);
  24186. item?.type === "component" && api.emit(PRELOAD_ENTRIES, {
  24187. // @ts-expect-error (TODO)
  24188. ids: [item.isLeaf ? item.id : item.children[0]],
  24189. options: { target: refId }
  24190. });
  24191. }, []), handleClearLastViewed = () => {
  24192. clearLastViewed(), closeMenu();
  24193. };
  24194. return react_default.createElement(ResultsList, { ...getMenuProps(), key: "results-list" }, results.length > 0 && !query && react_default.createElement(RecentlyOpenedTitle, { className: "search-result-recentlyOpened" }, "Recently opened", react_default.createElement(
  24195. Button,
  24196. {
  24197. padding: "small",
  24198. variant: "ghost",
  24199. className: "search-result-recentlyOpened-clear",
  24200. onClick: handleClearLastViewed,
  24201. ariaLabel: "Clear recently opened items"
  24202. },
  24203. react_default.createElement(TrashIcon, null)
  24204. )), results.length === 0 && query && react_default.createElement("li", null, react_default.createElement(NoResults2, null, react_default.createElement("strong", null, "No components found"), react_default.createElement("small", null, "Find components by name or path."))), results.map((result, index) => {
  24205. if (isExpandType(result)) {
  24206. let props = { ...results, ...getItemProps({ key: index, index, item: result }) }, { key: key2, ...rest2 } = props;
  24207. return react_default.createElement(MoreWrapper, { key: "search-result-expand" }, react_default.createElement(Button, { key: key2, ...rest2, size: "small" }, "Show ", result.moreCount, " more results"));
  24208. }
  24209. let { item } = result, key = `${item.refId}::${item.id}`;
  24210. return react_default.createElement(
  24211. Result,
  24212. {
  24213. ...result,
  24214. ...getItemProps({ key, index, item: result }),
  24215. isHighlighted: highlightedIndex === index,
  24216. key,
  24217. "data-id": result.item.id,
  24218. "data-refid": result.item.refId,
  24219. onMouseOver: mouseOverHandler,
  24220. className: "search-result-item"
  24221. }
  24222. );
  24223. }));
  24224. });
  24225. // src/manager/components/sidebar/SidebarBottom.tsx
  24226. init_react();
  24227. // src/manager/components/sidebar/TestingWidget.tsx
  24228. init_react();
  24229. // src/manager/components/sidebar/useDynamicFavicon.ts
  24230. init_react();
  24231. var STATUSES = ["active", "critical", "negative", "positive", "warning"], initialIcon, getFaviconUrl = (initialHref = "./favicon.svg", status) => {
  24232. initialIcon ??= initialHref;
  24233. let href = initialIcon + (status && STATUSES.includes(status) ? `?status=${status}` : "");
  24234. return new Promise((resolve) => {
  24235. let img = new Image();
  24236. img.onload = () => resolve({ href, status }), img.onerror = () => resolve({ href: initialIcon, status }), img.src = href;
  24237. });
  24238. }, useDynamicFavicon = (status) => {
  24239. let links = useRef(document.head.querySelectorAll("link[rel*='icon']"));
  24240. useEffect(() => {
  24241. let isMounted = !0, [element, ...others] = links.current;
  24242. if (element && !others.length)
  24243. return getFaviconUrl(element.href, status).then(
  24244. (result) => {
  24245. isMounted && result.status === status && element.dataset.status !== status && (element.href = result.href, result.status ? element.dataset.status = result.status : delete element.dataset.status);
  24246. },
  24247. () => {
  24248. isMounted && (element.href = initialIcon);
  24249. }
  24250. ), () => {
  24251. isMounted = !1, element.href = initialIcon;
  24252. };
  24253. }, [status]);
  24254. };
  24255. // src/manager/components/sidebar/TestingWidget.tsx
  24256. var DEFAULT_HEIGHT = 500, HoverCard2 = styled(Card)({
  24257. display: "flex",
  24258. flexDirection: "column-reverse",
  24259. "&:hover #testing-module-collapse-toggle": {
  24260. opacity: 1
  24261. }
  24262. }), Collapsible2 = styled.div(({ theme }) => ({
  24263. overflow: "hidden",
  24264. boxShadow: `inset 0 -1px 0 ${theme.appBorderColor}`
  24265. })), Content3 = styled.div({
  24266. display: "flex",
  24267. flexDirection: "column"
  24268. }), Bar2 = styled.div(({ onClick }) => ({
  24269. display: "flex",
  24270. width: "100%",
  24271. cursor: onClick ? "pointer" : "default",
  24272. userSelect: "none",
  24273. alignItems: "center",
  24274. justifyContent: "space-between",
  24275. overflow: "hidden",
  24276. padding: 4,
  24277. gap: 4
  24278. })), Action = styled.div({
  24279. display: "flex",
  24280. flexBasis: "100%",
  24281. containerType: "inline-size"
  24282. }), Filters = styled.div({
  24283. display: "flex",
  24284. justifyContent: "flex-end",
  24285. gap: 4
  24286. }), CollapseToggle3 = styled(ActionList.Button)({
  24287. opacity: 0,
  24288. transition: "opacity 250ms",
  24289. "&:focus, &:hover": {
  24290. opacity: 1
  24291. }
  24292. }), RunButton = ({
  24293. children,
  24294. isRunning,
  24295. onRunAll,
  24296. ...props
  24297. }) => react_default.createElement(
  24298. ActionList.Button,
  24299. {
  24300. ariaLabel: isRunning ? "Running..." : "Run tests",
  24301. tooltip: isRunning ? "Running tests..." : "Start all tests",
  24302. disabled: isRunning,
  24303. onClick: (e2) => {
  24304. e2.stopPropagation(), onRunAll();
  24305. },
  24306. ...props
  24307. },
  24308. react_default.createElement(ActionList.Icon, null, react_default.createElement(PlayAllHollowIcon, null)),
  24309. children
  24310. ), StatusButton2 = styled(ActionList.Toggle)(
  24311. { minWidth: 28, outlineOffset: -2 },
  24312. ({ pressed, status, theme }) => !pressed && (theme.base === "light" ? {
  24313. background: {
  24314. negative: theme.background.negative,
  24315. warning: theme.background.warning
  24316. }[status],
  24317. color: {
  24318. negative: theme.color.negativeText,
  24319. warning: theme.color.warningText
  24320. }[status]
  24321. } : {
  24322. background: {
  24323. negative: `${theme.color.negative}22`,
  24324. warning: `${theme.color.warning}22`
  24325. }[status],
  24326. color: {
  24327. negative: theme.color.negative,
  24328. warning: theme.color.warning
  24329. }[status]
  24330. })
  24331. ), TestProvider = styled.div(({ theme }) => ({
  24332. padding: 4,
  24333. "&:not(:last-child)": {
  24334. boxShadow: `inset 0 -1px 0 ${theme.appBorderColor}`
  24335. }
  24336. })), TestingWidget = ({
  24337. registeredTestProviders,
  24338. testProviderStates,
  24339. hasStatuses,
  24340. clearStatuses,
  24341. onRunAll,
  24342. errorCount,
  24343. errorsActive,
  24344. setErrorsActive,
  24345. warningCount,
  24346. warningsActive,
  24347. setWarningsActive,
  24348. successCount
  24349. }) => {
  24350. let timeoutRef = useRef(null), contentRef = useRef(null), [maxHeight, setMaxHeight] = useState(DEFAULT_HEIGHT), [isCollapsed, setCollapsed] = useState(!0), [isChangingCollapse, setChangingCollapse] = useState(!1), [isUpdated, setIsUpdated] = useState(!1), settingsUpdatedTimeoutRef = useRef();
  24351. useEffect(() => {
  24352. let unsubscribe = internal_fullTestProviderStore.onSettingsChanged(() => {
  24353. setIsUpdated(!0), clearTimeout(settingsUpdatedTimeoutRef.current), settingsUpdatedTimeoutRef.current = setTimeout(() => {
  24354. setIsUpdated(!1);
  24355. }, 1e3);
  24356. });
  24357. return () => {
  24358. unsubscribe(), clearTimeout(settingsUpdatedTimeoutRef.current);
  24359. };
  24360. }, []), useEffect(() => {
  24361. if (contentRef.current) {
  24362. setMaxHeight(contentRef.current?.getBoundingClientRect().height || DEFAULT_HEIGHT);
  24363. let resizeObserver = new ResizeObserver(() => {
  24364. requestAnimationFrame(() => {
  24365. if (contentRef.current && !isCollapsed) {
  24366. let height = contentRef.current?.getBoundingClientRect().height || DEFAULT_HEIGHT;
  24367. setMaxHeight(height);
  24368. }
  24369. });
  24370. });
  24371. return resizeObserver.observe(contentRef.current), () => resizeObserver.disconnect();
  24372. }
  24373. }, [isCollapsed]);
  24374. let toggleCollapsed = useCallback((event, value) => {
  24375. event?.stopPropagation(), setChangingCollapse(!0), setCollapsed((s2) => value ?? !s2), timeoutRef.current && clearTimeout(timeoutRef.current), timeoutRef.current = setTimeout(() => {
  24376. setChangingCollapse(!1);
  24377. }, 250);
  24378. }, []), isRunning = Object.values(testProviderStates).some(
  24379. (testProviderState) => testProviderState === "test-provider-state:running"
  24380. ), isCrashed = Object.values(testProviderStates).some(
  24381. (testProviderState) => testProviderState === "test-provider-state:crashed"
  24382. ), hasTestProviders = Object.values(registeredTestProviders).length > 0;
  24383. useEffect(() => {
  24384. isCrashed && isCollapsed && toggleCollapsed(void 0, !1);
  24385. }, [isCrashed, isCollapsed, toggleCollapsed]), useDynamicFavicon(
  24386. isCrashed ? "critical" : errorCount > 0 ? "negative" : warningCount > 0 ? "warning" : isRunning ? "active" : successCount > 0 ? "positive" : void 0
  24387. );
  24388. let cardRef = useRef(null), { landmarkProps } = useLandmark(
  24389. { "aria-labelledby": "storybook-testing-widget-heading", role: "region" },
  24390. cardRef
  24391. );
  24392. return !hasTestProviders && !errorCount && !warningCount ? null : react_default.createElement(
  24393. HoverCard2,
  24394. {
  24395. id: "storybook-testing-module",
  24396. "data-updated": isUpdated,
  24397. outlineAnimation: isRunning ? "spin" : "none",
  24398. outlineColor: isCrashed || isRunning && errorCount > 0 ? "negative" : isUpdated ? "positive" : void 0,
  24399. ref: cardRef,
  24400. outlineAttrs: landmarkProps
  24401. },
  24402. react_default.createElement("h2", { id: "storybook-testing-widget-heading", className: "sb-sr-only" }, "Component tests"),
  24403. react_default.createElement(Bar2, { ...hasTestProviders ? { onClick: (e2) => toggleCollapsed(e2) } : {} }, react_default.createElement(Action, null, hasTestProviders && react_default.createElement(
  24404. Optional,
  24405. {
  24406. content: react_default.createElement(RunButton, { isRunning, onRunAll }, isRunning ? "Running..." : "Run tests"),
  24407. fallback: react_default.createElement(RunButton, { isRunning, onRunAll })
  24408. }
  24409. )), react_default.createElement(Filters, null, hasTestProviders && react_default.createElement(
  24410. CollapseToggle3,
  24411. {
  24412. onClick: (e2) => toggleCollapsed(e2),
  24413. id: "testing-module-collapse-toggle",
  24414. ariaLabel: isCollapsed ? "Expand testing module" : "Collapse testing module"
  24415. },
  24416. react_default.createElement(
  24417. ChevronSmallUpIcon,
  24418. {
  24419. style: {
  24420. transform: isCollapsed ? "none" : "rotate(180deg)",
  24421. transition: "transform 250ms"
  24422. }
  24423. }
  24424. )
  24425. ), errorCount > 0 && react_default.createElement(
  24426. StatusButton2,
  24427. {
  24428. id: "errors-found-filter",
  24429. size: "medium",
  24430. variant: "ghost",
  24431. padding: errorCount < 10 ? "medium" : "small",
  24432. status: "negative",
  24433. pressed: errorsActive,
  24434. onClick: (e2) => {
  24435. e2.stopPropagation(), setErrorsActive(!errorsActive);
  24436. },
  24437. ariaLabel: `Filter main navigation to show ${errorCount} tests with errors`,
  24438. tooltip: errorsActive ? "Clear test error filter" : `Filter sidebar to show ${errorCount} tests with errors`
  24439. },
  24440. errorCount < 1e3 ? errorCount : "999+"
  24441. ), warningCount > 0 && react_default.createElement(
  24442. StatusButton2,
  24443. {
  24444. id: "warnings-found-filter",
  24445. size: "medium",
  24446. variant: "ghost",
  24447. padding: warningCount < 10 ? "medium" : "small",
  24448. status: "warning",
  24449. pressed: warningsActive,
  24450. onClick: (e2) => {
  24451. e2.stopPropagation(), setWarningsActive(!warningsActive);
  24452. },
  24453. ariaLabel: `Filter main navigation to show ${warningCount} tests with warnings`,
  24454. tooltip: warningsActive ? "Clear test warning filter" : `Filter sidebar to show ${warningCount} tests with warnings`
  24455. },
  24456. warningCount < 1e3 ? warningCount : "999+"
  24457. ), hasStatuses && react_default.createElement(
  24458. ActionList.Button,
  24459. {
  24460. id: "clear-statuses",
  24461. onClick: (e2) => {
  24462. e2.stopPropagation(), clearStatuses();
  24463. },
  24464. disabled: isRunning,
  24465. ariaLabel: isRunning ? "Can't clear statuses while tests are running" : "Clear all statuses"
  24466. },
  24467. react_default.createElement(SweepIcon, null)
  24468. ))),
  24469. hasTestProviders && react_default.createElement(
  24470. Collapsible2,
  24471. {
  24472. "data-testid": "collapse",
  24473. ...isCollapsed && { inert: "" },
  24474. style: {
  24475. transition: isChangingCollapse ? "max-height 250ms" : "max-height 0ms",
  24476. display: hasTestProviders ? "block" : "none",
  24477. maxHeight: isCollapsed ? 0 : maxHeight
  24478. }
  24479. },
  24480. react_default.createElement(Content3, { ref: contentRef }, Object.values(registeredTestProviders).map((registeredTestProvider) => {
  24481. let { render: Render, id } = registeredTestProvider;
  24482. return Render ? react_default.createElement(TestProvider, { key: id, "data-module-id": id }, react_default.createElement(Render, null)) : (once.warn(
  24483. `No render function found for test provider with id '${id}', skipping...`
  24484. ), null);
  24485. }))
  24486. )
  24487. );
  24488. };
  24489. // src/manager/components/sidebar/SidebarBottom.tsx
  24490. var SIDEBAR_BOTTOM_SPACER_ID = "sidebar-bottom-spacer", SIDEBAR_BOTTOM_WRAPPER_ID = "sidebar-bottom-wrapper", filterNone = () => !0, filterWarn = ({ statuses = {} }) => Object.values(statuses).some(({ value }) => value === "status-value:warning"), filterError = ({ statuses = {} }) => Object.values(statuses).some(({ value }) => value === "status-value:error"), filterBoth = ({ statuses = {} }) => Object.values(statuses).some(
  24491. ({ value }) => ["status-value:warning", "status-value:error"].includes(value)
  24492. ), getFilter = (warningsActive = !1, errorsActive = !1) => warningsActive && errorsActive ? filterBoth : warningsActive ? filterWarn : errorsActive ? filterError : filterNone, Spacer = styled.div({
  24493. pointerEvents: "none"
  24494. }), Content4 = styled.div(({ theme }) => ({
  24495. position: "absolute",
  24496. zIndex: 1,
  24497. bottom: 0,
  24498. left: 0,
  24499. right: 0,
  24500. padding: 12,
  24501. display: "flex",
  24502. flexDirection: "column",
  24503. gap: 12,
  24504. color: theme.color.defaultText,
  24505. fontSize: theme.typography.size.s1,
  24506. "&:empty": {
  24507. display: "none"
  24508. },
  24509. "--card-box-shadow": `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`,
  24510. // Integrators can use these to style their custom additions
  24511. "--sb-sidebar-bottom-card-background": theme.background.content,
  24512. "--sb-sidebar-bottom-card-border": `1px solid ${theme.appBorderColor}`,
  24513. "--sb-sidebar-bottom-card-border-radius": `${theme.appBorderRadius + 1}px`,
  24514. "--sb-sidebar-bottom-card-box-shadow": `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`
  24515. })), SidebarBottomBase = ({
  24516. api,
  24517. notifications = [],
  24518. errorCount,
  24519. warningCount,
  24520. successCount,
  24521. hasStatuses,
  24522. isDevelopment,
  24523. testProviderStates,
  24524. registeredTestProviders,
  24525. onRunAll
  24526. }) => {
  24527. let spacerRef = useRef(null), wrapperRef = useRef(null), [warningsActive, setWarningsActive] = useState(!1), [errorsActive, setErrorsActive] = useState(!1);
  24528. return useEffect(() => {
  24529. if (spacerRef.current && wrapperRef.current) {
  24530. let resizeObserver = new ResizeObserver(() => {
  24531. spacerRef.current && wrapperRef.current && (spacerRef.current.style.height = `${wrapperRef.current.scrollHeight}px`);
  24532. });
  24533. return resizeObserver.observe(wrapperRef.current), () => resizeObserver.disconnect();
  24534. }
  24535. }, []), useEffect(() => {
  24536. let filter = getFilter(warningCount > 0 && warningsActive, errorCount > 0 && errorsActive);
  24537. api.experimental_setFilter("sidebar-bottom-filter", filter);
  24538. }, [api, warningCount, errorCount, warningsActive, errorsActive]), !warningCount && !errorCount && Object.values(registeredTestProviders).length === 0 && notifications.length === 0 ? null : react_default.createElement(Fragment, null, react_default.createElement(Spacer, { id: SIDEBAR_BOTTOM_SPACER_ID, ref: spacerRef }), react_default.createElement(Content4, { id: SIDEBAR_BOTTOM_WRAPPER_ID, ref: wrapperRef }, react_default.createElement(NotificationList, { notifications, clearNotification: api.clearNotification }), isDevelopment && react_default.createElement(
  24539. TestingWidget,
  24540. {
  24541. registeredTestProviders,
  24542. testProviderStates,
  24543. onRunAll: () => {
  24544. onRunAll(), setErrorsActive(!1), setWarningsActive(!1);
  24545. },
  24546. hasStatuses,
  24547. clearStatuses: () => {
  24548. api.clearStatuses(), setErrorsActive(!1), setWarningsActive(!1);
  24549. },
  24550. errorCount,
  24551. errorsActive,
  24552. setErrorsActive,
  24553. warningCount,
  24554. warningsActive,
  24555. setWarningsActive,
  24556. successCount
  24557. }
  24558. )));
  24559. }, SidebarBottom = ({ isDevelopment }) => {
  24560. let api = useStorybookApi(), registeredTestProviders = api.getElements(Addon_TypesEnum.experimental_TEST_PROVIDER), { notifications } = useStorybookState(), { hasStatuses, errorCount, warningCount, successCount } = experimental_useStatusStore(
  24561. (statuses) => Object.values(statuses).reduce(
  24562. (result, storyStatuses) => (Object.values(storyStatuses).forEach((status) => {
  24563. result.hasStatuses = !0, status.value === "status-value:error" && (result.errorCount += 1), status.value === "status-value:warning" && (result.warningCount += 1), status.value === "status-value:success" && (result.successCount += 1);
  24564. }), result),
  24565. { errorCount: 0, warningCount: 0, successCount: 0, hasStatuses: !1 }
  24566. )
  24567. ), testProviderStates = experimental_useTestProviderStore();
  24568. return react_default.createElement(
  24569. SidebarBottomBase,
  24570. {
  24571. api,
  24572. notifications,
  24573. hasStatuses,
  24574. errorCount,
  24575. warningCount,
  24576. successCount,
  24577. isDevelopment,
  24578. testProviderStates,
  24579. registeredTestProviders,
  24580. onRunAll: internal_fullTestProviderStore.runAll
  24581. }
  24582. );
  24583. };
  24584. // src/manager/components/sidebar/Filter.tsx
  24585. init_react();
  24586. // src/manager/components/sidebar/FilterPanel.tsx
  24587. init_react();
  24588. // src/manager/components/sidebar/FilterPanelLink.tsx
  24589. init_react();
  24590. var MutedText = styled.span(({ theme }) => ({
  24591. color: theme.textMutedColor
  24592. })), StatusIcon2 = styled.span(({ $iconColor }) => ({
  24593. display: "contents",
  24594. color: $iconColor ?? void 0,
  24595. "> svg": {
  24596. transform: "scale(1.3)"
  24597. }
  24598. })), createFilterLink = ({
  24599. id,
  24600. type,
  24601. title: title2,
  24602. tooltip,
  24603. count,
  24604. icon,
  24605. isIncluded,
  24606. isExcluded,
  24607. onCheckboxChange,
  24608. onInvert
  24609. }) => {
  24610. let isChecked = isIncluded || isExcluded, toggleLabel = `${type} filter: ${isExcluded ? `exclude ${title2}` : title2}`, toggleTooltip = tooltip ?? `${isChecked ? "Remove" : "Add"} ${type} filter: ${title2}`, invertButtonLabel = `${isExcluded ? "Include" : "Exclude"} ${type}: ${title2}`;
  24611. return {
  24612. id: `filter-${type}-${id}`,
  24613. content: react_default.createElement(ActionList.HoverItem, { targetId: `filter-${type}-${id}` }, react_default.createElement(ActionList.Action, { as: "label", ariaLabel: !1, tabIndex: -1, tooltip: toggleTooltip }, react_default.createElement(ActionList.Icon, null, isExcluded ? react_default.createElement(DeleteIcon, null) : isIncluded ? null : icon, react_default.createElement(
  24614. Form.Checkbox,
  24615. {
  24616. checked: isChecked,
  24617. onChange: onCheckboxChange,
  24618. "data-tag": title2,
  24619. "aria-label": toggleLabel
  24620. }
  24621. )), react_default.createElement(ActionList.Text, null, react_default.createElement("span", null, title2, isExcluded && react_default.createElement(MutedText, null, " (excluded)"))), isExcluded ? react_default.createElement("s", null, count) : react_default.createElement("span", null, count)), react_default.createElement(
  24622. ActionList.Button,
  24623. {
  24624. "data-target-id": `filter-${type}-${id}`,
  24625. ariaLabel: invertButtonLabel,
  24626. onClick: onInvert
  24627. },
  24628. react_default.createElement("span", { style: { minWidth: 45 } }, isExcluded ? "Include" : "Exclude")
  24629. ))
  24630. };
  24631. };
  24632. // src/shared/constants/tags.ts
  24633. var Tag2 = {
  24634. /** Indicates that autodocs should be generated for this component */
  24635. AUTODOCS: "autodocs",
  24636. /** MDX documentation attached to a component's stories file */
  24637. ATTACHED_MDX: "attached-mdx",
  24638. /** Standalone MDX documentation not attached to stories */
  24639. UNATTACHED_MDX: "unattached-mdx",
  24640. /** Story has a play function */
  24641. PLAY_FN: "play-fn",
  24642. /** Story has a test function */
  24643. TEST_FN: "test-fn",
  24644. /** Development environment tag */
  24645. DEV: "dev",
  24646. /** Test environment tag */
  24647. TEST: "test",
  24648. /** Manifest generation tag */
  24649. MANIFEST: "manifest"
  24650. }, BUILT_IN_FILTERS = {
  24651. _docs: (entry, excluded) => excluded ? entry.type !== "docs" : entry.type === "docs",
  24652. _play: (entry, excluded) => excluded ? entry.type !== "story" || !entry.tags?.includes(Tag2.PLAY_FN) : entry.type === "story" && !!entry.tags?.includes(Tag2.PLAY_FN),
  24653. _test: (entry, excluded) => excluded ? entry.type !== "story" || entry.subtype !== "test" : entry.type === "story" && entry.subtype === "test"
  24654. }, USER_TAG_FILTER = (tag) => (entry, excluded) => excluded ? !entry.tags?.includes(tag) : !!entry.tags?.includes(tag);
  24655. // src/manager/components/sidebar/FilterPanel.utils.ts
  24656. var BUILT_IN_TAGS = /* @__PURE__ */ new Set([
  24657. "dev",
  24658. "test",
  24659. "autodocs",
  24660. "attached-mdx",
  24661. "unattached-mdx",
  24662. "play-fn",
  24663. "test-fn",
  24664. "manifest"
  24665. ]), STATUS_DISPLAY_ORDER = [
  24666. "status-value:new",
  24667. "status-value:modified",
  24668. "status-value:affected"
  24669. ], areFiltersEqual = (left, right) => left.length === right.length && (/* @__PURE__ */ new Set([...left, ...right])).size === left.length, getFilterFunction = (tag) => Object.hasOwn(BUILT_IN_FILTERS, tag) ? BUILT_IN_FILTERS[tag] : USER_TAG_FILTER(tag);
  24670. // src/manager/components/sidebar/useFilterData.tsx
  24671. init_react();
  24672. var BUILT_IN_FILTER_DEFS = [
  24673. { id: "_docs", title: "Documentation", icon: react_default.createElement(DocumentIcon, { color: color.gold }), tag: "_docs" },
  24674. { id: "_play", title: "Play", icon: react_default.createElement(PlayHollowIcon, { color: color.seafoam }), tag: "_play" },
  24675. { id: "_test", title: "Testing", icon: react_default.createElement(BeakerIcon, { color: color.green }), tag: "_test" }
  24676. ];
  24677. function useTagFilterEntries(indexJson) {
  24678. return useMemo(() => {
  24679. let entries = Object.values(indexJson.entries), userTagsCounts = entries.reduce((acc, entry) => (entry.tags?.forEach((tag) => {
  24680. BUILT_IN_TAGS.has(tag) || (acc[tag] = (acc[tag] || 0) + 1);
  24681. }), acc), {}), tagEntries = Object.entries(userTagsCounts).map(([tag, count]) => ({
  24682. id: tag,
  24683. type: "tag",
  24684. title: tag,
  24685. count,
  24686. icon: null
  24687. })), getBuiltInCount = (filterFn) => entries.filter((entry) => filterFn?.(entry)).length;
  24688. return { builtInEntries: BUILT_IN_FILTER_DEFS.map((def) => ({
  24689. id: def.id,
  24690. type: "built-in",
  24691. title: def.title,
  24692. icon: def.icon,
  24693. count: getBuiltInCount(getFilterFunction(def.tag))
  24694. })), tagEntries };
  24695. }, [indexJson.entries]);
  24696. }
  24697. function useStatusFilterEntries(allStatuses) {
  24698. return useMemo(() => {
  24699. if (!globalThis?.FEATURES?.changeDetection)
  24700. return [];
  24701. let counts = countStatusesByValue(allStatuses);
  24702. return STATUS_DISPLAY_ORDER.map((statusValue) => ({
  24703. statusValue,
  24704. shortName: statusValueShortName(statusValue),
  24705. description: statusValueDescription(statusValue),
  24706. count: counts[statusValue] ?? 0
  24707. }));
  24708. }, [allStatuses]);
  24709. }
  24710. // src/manager/components/sidebar/FilterPanel.tsx
  24711. var Wrapper7 = styled.div({
  24712. minWidth: 240,
  24713. maxWidth: 300,
  24714. maxHeight: 15.5 * 32 + 8,
  24715. // 15.5 items at 32px each + 8px padding
  24716. overflow: "hidden",
  24717. overflowY: "auto",
  24718. scrollbarWidth: "thin"
  24719. }), FilterPanel = ({
  24720. api,
  24721. indexJson,
  24722. defaultIncludedFilters,
  24723. defaultExcludedFilters,
  24724. includedFilters,
  24725. excludedFilters,
  24726. allStatuses,
  24727. includedStatusFilters,
  24728. excludedStatusFilters
  24729. }) => {
  24730. let theme = useTheme(), { builtInEntries, tagEntries } = useTagFilterEntries(indexJson), statusEntries = useStatusFilterEntries(allStatuses), toTagFilterItem = useCallback(
  24731. (entry) => {
  24732. if (entry.count === 0 && entry.type === "built-in") return null;
  24733. let isIncluded = includedFilters.includes(entry.id), isExcluded = excludedFilters.includes(entry.id), isChecked = isIncluded || isExcluded;
  24734. return {
  24735. id: entry.id,
  24736. type: entry.type,
  24737. title: entry.title,
  24738. count: entry.count,
  24739. icon: entry.icon,
  24740. isIncluded,
  24741. isExcluded,
  24742. onCheckboxChange: () => {
  24743. isChecked ? api.removeTagFilters([entry.id]) : api.addTagFilters([entry.id], !1);
  24744. },
  24745. onInvert: () => api.addTagFilters([entry.id], !isExcluded)
  24746. };
  24747. },
  24748. [api, includedFilters, excludedFilters]
  24749. ), toStatusFilterItem = useCallback(
  24750. (entry) => {
  24751. let shortName = entry.shortName === "affected" ? "related" : entry.shortName, isIncluded = includedStatusFilters.includes(entry.statusValue), isExcluded = excludedStatusFilters.includes(entry.statusValue), isChecked = isIncluded || isExcluded, { icon: statusIconEl, iconColor } = getStatus(theme, entry.statusValue), showIcon = statusIconEl && entry.statusValue !== "status-value:affected";
  24752. return {
  24753. id: shortName,
  24754. type: "status",
  24755. title: shortName.charAt(0).toUpperCase() + shortName.slice(1),
  24756. tooltip: entry.description,
  24757. count: entry.count,
  24758. icon: showIcon ? react_default.createElement(StatusIcon2, { $iconColor: iconColor }, statusIconEl) : null,
  24759. isIncluded,
  24760. isExcluded,
  24761. onCheckboxChange: () => {
  24762. isChecked ? api.removeStatusFilters([entry.statusValue]) : api.addStatusFilters([entry.statusValue], !1);
  24763. },
  24764. onInvert: () => api.addStatusFilters([entry.statusValue], !isExcluded)
  24765. };
  24766. },
  24767. [api, includedStatusFilters, excludedStatusFilters, theme]
  24768. ), builtInItems = useMemo(
  24769. () => builtInEntries.sort((a2, b2) => a2.id.localeCompare(b2.id)).map(toTagFilterItem).filter((f2) => f2 !== null),
  24770. [builtInEntries, toTagFilterItem]
  24771. ), tagItems = useMemo(
  24772. () => tagEntries.sort((a2, b2) => a2.id.localeCompare(b2.id)).map(toTagFilterItem).filter((f2) => f2 !== null),
  24773. [tagEntries, toTagFilterItem]
  24774. ), statusItems = useMemo(
  24775. () => statusEntries.map(toStatusFilterItem),
  24776. [statusEntries, toStatusFilterItem]
  24777. ), filterIds = useMemo(
  24778. () => [...builtInEntries.map((e2) => e2.id), ...tagEntries.map((e2) => e2.id)],
  24779. [builtInEntries, tagEntries]
  24780. ), setAllFilters = useCallback(
  24781. (selected) => api.setAllTagFilters(selected ? filterIds : [], []),
  24782. [api, filterIds]
  24783. ), isDefaultSelection = areFiltersEqual(includedFilters, defaultIncludedFilters) && areFiltersEqual(excludedFilters, defaultExcludedFilters), hasDefaultSelection = defaultIncludedFilters.length > 0 || defaultExcludedFilters.length > 0, isNothingSelectedYet = includedFilters.length === 0 && excludedFilters.length === 0 && includedStatusFilters.length === 0 && excludedStatusFilters.length === 0, hasItems = builtInItems.length > 0 || tagItems.length > 0;
  24784. return react_default.createElement(Wrapper7, null, hasItems && react_default.createElement(ActionList, { as: "div" }, react_default.createElement(ActionList.Item, { as: "div" }, isNothingSelectedYet ? react_default.createElement(
  24785. ActionList.Button,
  24786. {
  24787. ariaLabel: !1,
  24788. id: "select-all",
  24789. key: "select-all",
  24790. onClick: () => setAllFilters(!0)
  24791. },
  24792. react_default.createElement(BatchAcceptIcon, null),
  24793. react_default.createElement(ActionList.Text, null, "Select all")
  24794. ) : react_default.createElement(
  24795. ActionList.Button,
  24796. {
  24797. ariaLabel: !1,
  24798. id: "deselect-all",
  24799. key: "deselect-all",
  24800. onClick: async () => {
  24801. await setAllFilters(!1), await api.resetStatusFilters();
  24802. }
  24803. },
  24804. react_default.createElement(SweepIcon, null),
  24805. react_default.createElement(ActionList.Text, null, "Clear filters")
  24806. ), hasDefaultSelection && react_default.createElement(
  24807. ActionList.Button,
  24808. {
  24809. id: "reset-filters",
  24810. key: "reset-filters",
  24811. onClick: () => api.resetTagFilters(),
  24812. ariaLabel: "Reset filters",
  24813. tooltip: "Reset to default selection",
  24814. disabled: isDefaultSelection
  24815. },
  24816. react_default.createElement(UndoIcon, null)
  24817. ))), builtInItems.length > 0 && react_default.createElement(ActionList, null, builtInItems.map((item) => {
  24818. let link = createFilterLink(item);
  24819. return react_default.createElement(Fragment, { key: link.id }, link.content);
  24820. })), statusItems.length > 0 && react_default.createElement(ActionList, null, statusItems.map((item) => {
  24821. let link = createFilterLink(item);
  24822. return react_default.createElement(Fragment, { key: link.id }, link.content);
  24823. })), tagItems.length > 0 && react_default.createElement(ActionList, null, tagItems.map((item) => {
  24824. let link = createFilterLink(item);
  24825. return react_default.createElement(Fragment, { key: link.id }, link.content);
  24826. })), tagItems.length === 0 && react_default.createElement(ActionList, { as: "div" }, react_default.createElement(ActionList.Item, { as: "div" }, react_default.createElement(
  24827. ActionList.Link,
  24828. {
  24829. ariaLabel: !1,
  24830. href: api.getDocsUrl({ subpath: "writing-stories/tags#custom-tags" }),
  24831. target: "_blank"
  24832. },
  24833. react_default.createElement(ActionList.Icon, null, react_default.createElement(DocumentIcon, null)),
  24834. react_default.createElement(ActionList.Text, null, react_default.createElement("span", null, "Learn how to add tags")),
  24835. react_default.createElement(ActionList.Icon, null, react_default.createElement(ShareAltIcon, null))
  24836. ))));
  24837. };
  24838. // src/manager/components/sidebar/Filter.tsx
  24839. var StyledButton2 = styled(Button)(({ $isHighlighted, theme }) => ({
  24840. "&:focus-visible": {
  24841. outlineOffset: 4
  24842. },
  24843. ...$isHighlighted && {
  24844. background: theme.background.hoverable,
  24845. color: theme.color.secondary
  24846. }
  24847. })), TagSelected = styled(Badge)(({ theme }) => ({
  24848. position: "absolute",
  24849. top: 7,
  24850. right: 7,
  24851. transform: "translate(50%, -50%)",
  24852. display: "flex",
  24853. alignItems: "center",
  24854. justifyContent: "center",
  24855. padding: 3,
  24856. height: 6,
  24857. minWidth: 6,
  24858. lineHeight: "px",
  24859. boxShadow: `${theme.barSelectedColor} 0 0 0 1px inset`,
  24860. fontSize: theme.typography.size.s1 - 1,
  24861. background: theme.barSelectedColor,
  24862. color: theme.color.inverseText
  24863. })), filterMapper = ({ api, state }) => ({
  24864. api,
  24865. indexJson: state.internal_index,
  24866. activeFilterCount: getActiveFilterCount(state),
  24867. defaultIncludedFilters: state.defaultIncludedTagFilters,
  24868. defaultExcludedFilters: state.defaultExcludedTagFilters,
  24869. includedFilters: state.includedTagFilters,
  24870. excludedFilters: state.excludedTagFilters,
  24871. includedStatusFilters: state.includedStatusFilters ?? [],
  24872. excludedStatusFilters: state.excludedStatusFilters ?? []
  24873. }), FilterInner = ({
  24874. api,
  24875. indexJson,
  24876. activeFilterCount,
  24877. defaultIncludedFilters,
  24878. defaultExcludedFilters,
  24879. includedFilters,
  24880. excludedFilters,
  24881. includedStatusFilters,
  24882. excludedStatusFilters
  24883. }) => {
  24884. let [expanded, setExpanded] = useState(!1), allStatuses = experimental_useStatusStore(), handleToggleExpand = useCallback(
  24885. (event) => {
  24886. event.preventDefault(), setExpanded(!expanded);
  24887. },
  24888. [expanded]
  24889. );
  24890. return react_default.createElement(
  24891. PopoverProvider,
  24892. {
  24893. ariaLabel: "Tag filters",
  24894. placement: "bottom",
  24895. onVisibleChange: setExpanded,
  24896. offset: 8,
  24897. padding: 0,
  24898. popover: () => react_default.createElement(
  24899. FilterPanel,
  24900. {
  24901. api,
  24902. indexJson,
  24903. defaultIncludedFilters,
  24904. defaultExcludedFilters,
  24905. includedFilters,
  24906. excludedFilters,
  24907. allStatuses,
  24908. includedStatusFilters,
  24909. excludedStatusFilters
  24910. }
  24911. )
  24912. },
  24913. react_default.createElement(
  24914. StyledButton2,
  24915. {
  24916. key: "tags",
  24917. ariaLabel: activeFilterCount ? `${activeFilterCount} active tag ${activeFilterCount !== 1 ? "filters" : "filter"}` : "Tag filters",
  24918. ariaDescription: "Filter the items shown in a sidebar based on the tags applied to them.",
  24919. variant: "ghost",
  24920. padding: "small",
  24921. $isHighlighted: activeFilterCount > 0,
  24922. onClick: handleToggleExpand
  24923. },
  24924. react_default.createElement(FilterIcon, null),
  24925. activeFilterCount > 0 && react_default.createElement(TagSelected, null)
  24926. )
  24927. );
  24928. }, Filter = () => react_default.createElement(Consumer, { filter: filterMapper }, ({
  24929. api,
  24930. indexJson,
  24931. activeFilterCount,
  24932. defaultIncludedFilters,
  24933. defaultExcludedFilters,
  24934. includedFilters,
  24935. excludedFilters,
  24936. includedStatusFilters,
  24937. excludedStatusFilters
  24938. }) => indexJson ? react_default.createElement(
  24939. FilterInner,
  24940. {
  24941. api,
  24942. indexJson,
  24943. activeFilterCount,
  24944. defaultIncludedFilters,
  24945. defaultExcludedFilters,
  24946. includedFilters,
  24947. excludedFilters,
  24948. includedStatusFilters,
  24949. excludedStatusFilters
  24950. }
  24951. ) : null);
  24952. // src/manager/components/sidebar/ReviewChangesButton.tsx
  24953. init_react();
  24954. // src/shared/universal-store/instances.ts
  24955. var instances = /* @__PURE__ */ new Map();
  24956. // src/shared/universal-store/index.ts
  24957. var CHANNEL_EVENT_PREFIX = "UNIVERSAL_STORE:", ProgressState = {
  24958. PENDING: "PENDING",
  24959. RESOLVED: "RESOLVED",
  24960. REJECTED: "REJECTED"
  24961. }, _UniversalStore = class _UniversalStore {
  24962. constructor(options2, environmentOverrides) {
  24963. /** Enable debug logs for this store */
  24964. this.debugging = !1;
  24965. // TODO: narrow type of listeners based on event type
  24966. this.listeners = /* @__PURE__ */ new Map([["*", /* @__PURE__ */ new Set()]]);
  24967. /** Gets the current state */
  24968. this.getState = () => (this.debug("getState", { state: this.state }), this.state);
  24969. /**
  24970. * Subscribes to store events
  24971. *
  24972. * @returns A function to unsubscribe
  24973. */
  24974. this.subscribe = (eventTypeOrListener, maybeListener) => {
  24975. let subscribesToAllEvents = typeof eventTypeOrListener == "function", eventType = subscribesToAllEvents ? "*" : eventTypeOrListener, listener = subscribesToAllEvents ? eventTypeOrListener : maybeListener;
  24976. if (this.debug("subscribe", { eventType, listener }), !listener)
  24977. throw new TypeError(
  24978. `Missing first subscribe argument, or second if first is the event type, when subscribing to a UniversalStore with id '${this.id}'`
  24979. );
  24980. return this.listeners.has(eventType) || this.listeners.set(eventType, /* @__PURE__ */ new Set()), this.listeners.get(eventType).add(listener), () => {
  24981. this.debug("unsubscribe", { eventType, listener }), this.listeners.has(eventType) && (this.listeners.get(eventType).delete(listener), this.listeners.get(eventType)?.size === 0 && this.listeners.delete(eventType));
  24982. };
  24983. };
  24984. /** Sends a custom event to the other stores */
  24985. this.send = (event) => {
  24986. if (this.debug("send", { event }), this.status !== _UniversalStore.Status.READY)
  24987. throw new TypeError(
  24988. dedent`Cannot send event before store is ready. You can get the current status with store.status,
  24989. or await store.readyPromise to wait for the store to be ready before sending events.
  24990. ${JSON.stringify(
  24991. {
  24992. event,
  24993. id: this.id,
  24994. actor: this.actor,
  24995. environment: this.environment
  24996. },
  24997. null,
  24998. 2
  24999. )}`
  25000. );
  25001. this.emitToListeners(event, { actor: this.actor }), this.emitToChannel(event, { actor: this.actor });
  25002. };
  25003. if (this.debugging = options2.debug ?? !1, !_UniversalStore.isInternalConstructing)
  25004. throw new TypeError(
  25005. "UniversalStore is not constructable - use UniversalStore.create() instead"
  25006. );
  25007. if (_UniversalStore.isInternalConstructing = !1, this.id = options2.id, this.actorId = Date.now().toString(36) + Math.random().toString(36).substring(2), this.actorType = options2.leader ? _UniversalStore.ActorType.LEADER : _UniversalStore.ActorType.FOLLOWER, this.state = options2.initialState, this.channelEventName = `${CHANNEL_EVENT_PREFIX}${this.id}`, this.debug("constructor", {
  25008. options: options2,
  25009. environmentOverrides,
  25010. channelEventName: this.channelEventName
  25011. }), this.actor.type === _UniversalStore.ActorType.LEADER)
  25012. this.syncing = {
  25013. state: ProgressState.RESOLVED,
  25014. promise: Promise.resolve()
  25015. };
  25016. else {
  25017. let syncingResolve, syncingReject, syncingPromise = new Promise((resolve, reject) => {
  25018. syncingResolve = () => {
  25019. this.syncing.state === ProgressState.PENDING && (this.syncing.state = ProgressState.RESOLVED, resolve());
  25020. }, syncingReject = (reason) => {
  25021. this.syncing.state === ProgressState.PENDING && (this.syncing.state = ProgressState.REJECTED, reject(reason));
  25022. };
  25023. });
  25024. this.syncing = {
  25025. state: ProgressState.PENDING,
  25026. promise: syncingPromise,
  25027. resolve: syncingResolve,
  25028. reject: syncingReject
  25029. };
  25030. }
  25031. this.getState = this.getState.bind(this), this.setState = this.setState.bind(this), this.subscribe = this.subscribe.bind(this), this.onStateChange = this.onStateChange.bind(this), this.send = this.send.bind(this), this.emitToChannel = this.emitToChannel.bind(this), this.prepareThis = this.prepareThis.bind(this), this.emitToListeners = this.emitToListeners.bind(this), this.handleChannelEvents = this.handleChannelEvents.bind(this), this.debug = this.debug.bind(this), this.channel = environmentOverrides?.channel ?? _UniversalStore.preparation.channel, this.environment = environmentOverrides?.environment ?? _UniversalStore.preparation.environment, this.channel && this.environment ? (_UniversalStore.preparation.resolve({ channel: this.channel, environment: this.environment }), this.prepareThis({ channel: this.channel, environment: this.environment })) : _UniversalStore.preparation.promise.then(this.prepareThis);
  25032. }
  25033. static setupPreparationPromise() {
  25034. let resolveRef, rejectRef, promise = new Promise(
  25035. (resolve, reject) => {
  25036. resolveRef = (args) => {
  25037. resolve(args);
  25038. }, rejectRef = (...args) => {
  25039. reject(args);
  25040. };
  25041. }
  25042. );
  25043. _UniversalStore.preparation = {
  25044. resolve: resolveRef,
  25045. reject: rejectRef,
  25046. promise
  25047. };
  25048. }
  25049. /** The actor object representing the store instance with a unique ID and a type */
  25050. get actor() {
  25051. return Object.freeze({
  25052. id: this.actorId,
  25053. type: this.actorType,
  25054. environment: this.environment ?? _UniversalStore.Environment.UNKNOWN
  25055. });
  25056. }
  25057. /**
  25058. * The current state of the store, that signals both if the store is prepared by Storybook and
  25059. * also - in the case of a follower - if the state has been synced with the leader's state.
  25060. */
  25061. get status() {
  25062. if (!this.channel || !this.environment)
  25063. return _UniversalStore.Status.UNPREPARED;
  25064. switch (this.syncing?.state) {
  25065. case ProgressState.PENDING:
  25066. case void 0:
  25067. return _UniversalStore.Status.SYNCING;
  25068. case ProgressState.REJECTED:
  25069. return _UniversalStore.Status.ERROR;
  25070. case ProgressState.RESOLVED:
  25071. default:
  25072. return _UniversalStore.Status.READY;
  25073. }
  25074. }
  25075. /**
  25076. * A promise that resolves when the store is fully ready. A leader will be ready when the store
  25077. * has been prepared by Storybook, which is almost instantly.
  25078. *
  25079. * A follower will be ready when the state has been synced with the leader's state, within a few
  25080. * hundred milliseconds.
  25081. */
  25082. untilReady() {
  25083. return Promise.all([_UniversalStore.preparation.promise, this.syncing?.promise]);
  25084. }
  25085. /** Creates a new instance of UniversalStore */
  25086. static create(options2) {
  25087. if (!options2 || typeof options2?.id != "string")
  25088. throw new TypeError("id is required and must be a string, when creating a UniversalStore");
  25089. options2.debug && console.debug(
  25090. dedent`[UniversalStore]
  25091. create`,
  25092. { options: options2 }
  25093. );
  25094. let existing = instances.get(options2.id);
  25095. if (existing)
  25096. return console.warn(dedent`UniversalStore with id "${options2.id}" already exists in this environment, re-using existing.
  25097. You should reuse the existing instance instead of trying to create a new one.`), existing;
  25098. _UniversalStore.isInternalConstructing = !0;
  25099. let store2 = new _UniversalStore(options2);
  25100. return instances.set(options2.id, store2), store2;
  25101. }
  25102. /**
  25103. * Used by Storybook to set the channel for all instances of UniversalStore in the given
  25104. * environment.
  25105. *
  25106. * @internal
  25107. */
  25108. static __prepare(channel, environment) {
  25109. _UniversalStore.preparation.channel = channel, _UniversalStore.preparation.environment = environment, _UniversalStore.preparation.resolve({ channel, environment });
  25110. }
  25111. /**
  25112. * Updates the store's state
  25113. *
  25114. * Either a new state or a state updater function can be passed to the method.
  25115. */
  25116. setState(updater) {
  25117. let previousState = this.state, newState = typeof updater == "function" ? updater(previousState) : updater;
  25118. if (this.debug("setState", { newState, previousState, updater }), this.status !== _UniversalStore.Status.READY)
  25119. throw new TypeError(
  25120. dedent`Cannot set state before store is ready. You can get the current status with store.status,
  25121. or await store.readyPromise to wait for the store to be ready before sending events.
  25122. ${JSON.stringify(
  25123. {
  25124. newState,
  25125. id: this.id,
  25126. actor: this.actor,
  25127. environment: this.environment
  25128. },
  25129. null,
  25130. 2
  25131. )}`
  25132. );
  25133. this.state = newState;
  25134. let event = {
  25135. type: _UniversalStore.InternalEventType.SET_STATE,
  25136. payload: {
  25137. state: newState,
  25138. previousState
  25139. }
  25140. };
  25141. this.emitToChannel(event, { actor: this.actor }), this.emitToListeners(event, { actor: this.actor });
  25142. }
  25143. /**
  25144. * Subscribes to state changes
  25145. *
  25146. * @returns Unsubscribe function
  25147. */
  25148. onStateChange(listener) {
  25149. return this.debug("onStateChange", { listener }), this.subscribe(
  25150. _UniversalStore.InternalEventType.SET_STATE,
  25151. ({ payload }, eventInfo) => {
  25152. listener(payload.state, payload.previousState, eventInfo);
  25153. }
  25154. );
  25155. }
  25156. emitToChannel(event, eventInfo) {
  25157. this.debug("emitToChannel", { event, eventInfo, channel: !!this.channel }), this.channel?.emit(this.channelEventName, {
  25158. event,
  25159. eventInfo
  25160. });
  25161. }
  25162. prepareThis({
  25163. channel,
  25164. environment
  25165. }) {
  25166. this.channel = channel, this.environment = environment, this.debug("prepared", { channel: !!channel, environment }), this.channel.on(this.channelEventName, this.handleChannelEvents), this.actor.type === _UniversalStore.ActorType.LEADER ? this.emitToChannel(
  25167. { type: _UniversalStore.InternalEventType.LEADER_CREATED },
  25168. { actor: this.actor }
  25169. ) : (this.emitToChannel(
  25170. { type: _UniversalStore.InternalEventType.FOLLOWER_CREATED },
  25171. { actor: this.actor }
  25172. ), this.emitToChannel(
  25173. { type: _UniversalStore.InternalEventType.EXISTING_STATE_REQUEST },
  25174. { actor: this.actor }
  25175. ), setTimeout(() => {
  25176. this.syncing.reject(
  25177. new TypeError(
  25178. `No existing state found for follower with id: '${this.id}'. Make sure a leader with the same id exists before creating a follower.`
  25179. )
  25180. );
  25181. }, 1e3));
  25182. }
  25183. emitToListeners(event, eventInfo) {
  25184. let eventTypeListeners = this.listeners.get(event.type), everythingListeners = this.listeners.get("*");
  25185. this.debug("emitToListeners", {
  25186. event,
  25187. eventInfo,
  25188. eventTypeListeners,
  25189. everythingListeners
  25190. }), [...eventTypeListeners ?? [], ...everythingListeners ?? []].forEach(
  25191. (listener) => listener(event, eventInfo)
  25192. );
  25193. }
  25194. handleChannelEvents(channelEvent) {
  25195. let { event, eventInfo } = channelEvent;
  25196. if ([eventInfo.actor.id, eventInfo.forwardingActor?.id].includes(this.actor.id)) {
  25197. this.debug("handleChannelEvents: Ignoring event from self", { channelEvent });
  25198. return;
  25199. } else if (this.syncing?.state === ProgressState.PENDING && event.type !== _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE) {
  25200. this.debug("handleChannelEvents: Ignoring event while syncing", { channelEvent });
  25201. return;
  25202. }
  25203. if (this.debug("handleChannelEvents", { channelEvent }), this.actor.type === _UniversalStore.ActorType.LEADER) {
  25204. let shouldForwardEvent = !0;
  25205. switch (event.type) {
  25206. case _UniversalStore.InternalEventType.EXISTING_STATE_REQUEST:
  25207. shouldForwardEvent = !1;
  25208. let responseEvent = {
  25209. type: _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE,
  25210. payload: this.state
  25211. };
  25212. this.debug("handleChannelEvents: responding to existing state request", {
  25213. responseEvent
  25214. }), this.emitToChannel(responseEvent, { actor: this.actor }), this.emitToListeners(responseEvent, { actor: this.actor });
  25215. break;
  25216. case _UniversalStore.InternalEventType.LEADER_CREATED:
  25217. shouldForwardEvent = !1, this.syncing.state = ProgressState.REJECTED, this.debug("handleChannelEvents: erroring due to second leader being created", {
  25218. event
  25219. }), console.error(
  25220. dedent`Detected multiple UniversalStore leaders created with the same id "${this.id}".
  25221. Only one leader can exists at a time, your stores are now in an invalid state.
  25222. Leaders detected:
  25223. this: ${JSON.stringify(this.actor, null, 2)}
  25224. other: ${JSON.stringify(eventInfo.actor, null, 2)}`
  25225. );
  25226. break;
  25227. }
  25228. shouldForwardEvent && (this.debug("handleChannelEvents: forwarding event", { channelEvent }), this.emitToChannel(event, { actor: eventInfo.actor, forwardingActor: this.actor }));
  25229. }
  25230. if (this.actor.type === _UniversalStore.ActorType.FOLLOWER)
  25231. switch (event.type) {
  25232. case _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE:
  25233. if (this.debug("handleChannelEvents: Setting state from leader's existing state response", {
  25234. event
  25235. }), this.syncing?.state !== ProgressState.PENDING)
  25236. break;
  25237. this.syncing.resolve?.();
  25238. let setStateEvent = {
  25239. type: _UniversalStore.InternalEventType.SET_STATE,
  25240. payload: {
  25241. state: event.payload,
  25242. previousState: this.state
  25243. }
  25244. };
  25245. this.state = event.payload, this.emitToListeners(setStateEvent, eventInfo);
  25246. break;
  25247. }
  25248. switch (event.type) {
  25249. case _UniversalStore.InternalEventType.SET_STATE:
  25250. this.debug("handleChannelEvents: Setting state", { event }), this.state = event.payload.state;
  25251. break;
  25252. }
  25253. this.emitToListeners(event, { actor: eventInfo.actor });
  25254. }
  25255. debug(message, data) {
  25256. this.debugging && console.debug(
  25257. dedent`[UniversalStore::${this.id}::${this.environment ?? _UniversalStore.Environment.UNKNOWN}]
  25258. ${message}`,
  25259. JSON.stringify(
  25260. {
  25261. data,
  25262. actor: this.actor,
  25263. state: this.state,
  25264. status: this.status
  25265. },
  25266. null,
  25267. 2
  25268. )
  25269. );
  25270. }
  25271. /**
  25272. * Used to reset the static fields of the UniversalStore class when cleaning up tests
  25273. *
  25274. * @internal
  25275. */
  25276. static __reset() {
  25277. _UniversalStore.preparation.reject(new Error("reset")), _UniversalStore.setupPreparationPromise(), _UniversalStore.isInternalConstructing = !1;
  25278. }
  25279. };
  25280. /**
  25281. * Defines the possible actor types in the store system
  25282. *
  25283. * @readonly
  25284. */
  25285. _UniversalStore.ActorType = {
  25286. LEADER: "LEADER",
  25287. FOLLOWER: "FOLLOWER"
  25288. }, /**
  25289. * Defines the possible environments the store can run in
  25290. *
  25291. * @readonly
  25292. */
  25293. _UniversalStore.Environment = {
  25294. SERVER: "SERVER",
  25295. MANAGER: "MANAGER",
  25296. PREVIEW: "PREVIEW",
  25297. UNKNOWN: "UNKNOWN",
  25298. MOCK: "MOCK"
  25299. }, /**
  25300. * Internal event types used for store synchronization
  25301. *
  25302. * @readonly
  25303. */
  25304. _UniversalStore.InternalEventType = {
  25305. EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST",
  25306. EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE",
  25307. SET_STATE: "__SET_STATE",
  25308. LEADER_CREATED: "__LEADER_CREATED",
  25309. FOLLOWER_CREATED: "__FOLLOWER_CREATED"
  25310. }, _UniversalStore.Status = {
  25311. UNPREPARED: "UNPREPARED",
  25312. SYNCING: "SYNCING",
  25313. READY: "READY",
  25314. ERROR: "ERROR"
  25315. }, // This is used to check if constructor was called from the static factory create()
  25316. _UniversalStore.isInternalConstructing = !1, _UniversalStore.setupPreparationPromise();
  25317. var UniversalStore = _UniversalStore;
  25318. // src/shared/universal-store/use-universal-store-manager.ts
  25319. init_react();
  25320. var useUniversalStore = (universalStore, selector) => {
  25321. let snapshotRef = useRef(
  25322. selector ? selector(universalStore.getState()) : universalStore.getState()
  25323. ), subscribe = useCallback(
  25324. (listener) => universalStore.onStateChange((state2, previousState) => {
  25325. if (!selector) {
  25326. snapshotRef.current = state2, listener();
  25327. return;
  25328. }
  25329. let selectedState = selector(state2), selectedPreviousState = selector(previousState);
  25330. !isEqual(selectedState, selectedPreviousState) && (snapshotRef.current = selectedState, listener());
  25331. }),
  25332. [universalStore, selector]
  25333. ), getSnapshot = useCallback(() => {
  25334. let currentState = universalStore.getState(), selectedState = selector ? selector(currentState) : currentState;
  25335. return isEqual(selectedState, snapshotRef.current) || (snapshotRef.current = selectedState), snapshotRef.current;
  25336. }, [universalStore, selector]);
  25337. return [useSyncExternalStore(subscribe, getSnapshot), universalStore.setState];
  25338. };
  25339. // src/manager-api/stores/status.ts
  25340. var statusStore = createStatusStore({
  25341. universalStatusStore: UniversalStore.create({
  25342. ...UNIVERSAL_STATUS_STORE_OPTIONS,
  25343. leader: globalThis.CONFIG_TYPE === "PRODUCTION"
  25344. }),
  25345. useUniversalStore,
  25346. environment: "manager"
  25347. }), { fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore } = statusStore;
  25348. // src/manager-api/modules/statuses.ts
  25349. var computeStatusFilterFn = (includedStatusFilters, excludedStatusFilters) => (entry) => {
  25350. if (!includedStatusFilters.length && !excludedStatusFilters.length)
  25351. return !0;
  25352. let storyStatuses = (fullStatusStore.getAll() ?? {})[entry.id], storyStatusValues = storyStatuses ? Object.values(storyStatuses).map((s2) => s2.value) : [], passesInclude = !includedStatusFilters.length || includedStatusFilters.some((v2) => storyStatusValues.includes(v2)), passesExclude = !excludedStatusFilters.length || excludedStatusFilters.every((v2) => !storyStatusValues.includes(v2));
  25353. return passesInclude && passesExclude;
  25354. };
  25355. // src/manager-api/modules/tags.ts
  25356. var import_memoizerific5 = __toESM(require_memoizerific(), 1);
  25357. var getDefaultTagsFromPreset = (0, import_memoizerific5.default)(1)((presets) => {
  25358. let presetEntries = Object.entries(presets);
  25359. return {
  25360. included: presetEntries.filter(([, option]) => option.defaultFilterSelection === "include").map(([tag]) => tag),
  25361. excluded: presetEntries.filter(([, option]) => option.defaultFilterSelection === "exclude").map(([tag]) => tag)
  25362. };
  25363. });
  25364. var computeTagsFilterFn = (includedTagFilters, excludedTagFilters) => {
  25365. let computeFilterFunctions = (set) => Object.values(
  25366. set.reduce(
  25367. (acc, tag) => (Object.hasOwn(BUILT_IN_FILTERS, tag) ? acc["built-in"].push(BUILT_IN_FILTERS[tag]) : acc.user.push(USER_TAG_FILTER(tag)), acc),
  25368. { "built-in": [], user: [] }
  25369. )
  25370. ).filter((group) => group.length > 0);
  25371. return (item) => {
  25372. let included = computeFilterFunctions(includedTagFilters), excluded = computeFilterFunctions(excludedTagFilters);
  25373. return (!included.length || included.every((group) => group.some((filterFn) => filterFn(item, !1)))) && (!excluded.length || excluded.every((group) => group.every((filterFn) => filterFn(item, !0))));
  25374. };
  25375. };
  25376. // src/manager/components/sidebar/ReviewChangesButton.tsx
  25377. var Wrapper8 = styled.div({
  25378. display: "flex",
  25379. alignItems: "center",
  25380. gap: 4,
  25381. marginTop: -8
  25382. }), StyledCTA = styled(ToggleButton)({
  25383. flex: 1,
  25384. justifyContent: "flex-start"
  25385. }), StyledIcon = styled.svg(({ theme }) => ({
  25386. color: theme.fgColor.accent
  25387. })), NEW = "status-value:new", MOD = "status-value:modified", ReviewChangesButton = () => {
  25388. let api = useStorybookApi(), {
  25389. internal_index: index,
  25390. includedStatusFilters: rawIncludedStatusFilters,
  25391. excludedStatusFilters: rawExcludedStatusFilters,
  25392. includedTagFilters: rawIncludedTagFilters,
  25393. excludedTagFilters: rawExcludedTagFilters
  25394. } = useStorybookState(), allStatuses = experimental_useStatusStore(), { newCount, modifiedCount } = useMemo(() => {
  25395. if (!index)
  25396. return { newCount: 0, modifiedCount: 0 };
  25397. let includedStatusFilters2 = rawIncludedStatusFilters ?? [], excludedStatusFilters2 = rawExcludedStatusFilters ?? [], includedTagFilters = rawIncludedTagFilters ?? [], excludedTagFilters = rawExcludedTagFilters ?? [], contextualIncludedStatuses = includedStatusFilters2.filter((s2) => s2 !== NEW && s2 !== MOD), contextualExcludedStatuses = excludedStatusFilters2.filter((s2) => s2 !== NEW && s2 !== MOD), tagFilterFn = computeTagsFilterFn(includedTagFilters, excludedTagFilters), statusFilterFn = computeStatusFilterFn(
  25398. contextualIncludedStatuses,
  25399. contextualExcludedStatuses
  25400. ), next = 0, modified = 0, entries = index.entries ?? {};
  25401. for (let [storyId, statusesByType] of Object.entries(allStatuses)) {
  25402. let entry = entries[storyId];
  25403. if (!entry)
  25404. continue;
  25405. let entryWithStatuses = { ...entry, statuses: statusesByType };
  25406. if (!tagFilterFn(entryWithStatuses) || !statusFilterFn(entryWithStatuses))
  25407. continue;
  25408. let statuses = Object.values(statusesByType);
  25409. statuses.some(({ value }) => value === NEW) && (next += 1), statuses.some(({ value }) => value === MOD) && (modified += 1);
  25410. }
  25411. return { newCount: next, modifiedCount: modified };
  25412. }, [
  25413. index,
  25414. allStatuses,
  25415. rawIncludedStatusFilters,
  25416. rawExcludedStatusFilters,
  25417. rawIncludedTagFilters,
  25418. rawExcludedTagFilters
  25419. ]), includedStatusFilters = rawIncludedStatusFilters ?? [], excludedStatusFilters = rawExcludedStatusFilters ?? [], isReviewActive = includedStatusFilters.includes(NEW) && includedStatusFilters.includes(MOD);
  25420. if (!globalThis.FEATURES?.changeDetection || newCount === 0 && modifiedCount === 0)
  25421. return null;
  25422. let clearReview = () => {
  25423. let nextIncluded = includedStatusFilters.filter((s2) => s2 !== NEW && s2 !== MOD), nextExcluded = excludedStatusFilters.filter((s2) => s2 !== NEW && s2 !== MOD);
  25424. api.setAllStatusFilters(nextIncluded, nextExcluded);
  25425. }, onClick = () => {
  25426. if (isReviewActive)
  25427. clearReview();
  25428. else {
  25429. let nextIncluded = Array.from(/* @__PURE__ */ new Set([...includedStatusFilters, NEW, MOD])), nextExcluded = excludedStatusFilters.filter((s2) => s2 !== NEW && s2 !== MOD);
  25430. api.setAllStatusFilters(nextIncluded, nextExcluded);
  25431. }
  25432. }, onClearClick = (e2) => {
  25433. e2.stopPropagation(), clearReview();
  25434. }, changeKinds = newCount > 0 && modifiedCount > 0 ? "new and modified" : newCount > 0 ? "new" : "modified", label = `${isReviewActive ? "Reviewing" : "Review"} ${changeKinds} stories`;
  25435. return react_default.createElement(Wrapper8, null, react_default.createElement(
  25436. StyledCTA,
  25437. {
  25438. variant: "ghost",
  25439. padding: "small",
  25440. pressed: isReviewActive,
  25441. ariaLabel: label,
  25442. onClick
  25443. },
  25444. react_default.createElement(StyledIcon, { viewBox: "0 0 14 14", width: "14", height: "14", "aria-hidden": !0 }, react_default.createElement(UseSymbol, { type: "new" })),
  25445. label
  25446. ), isReviewActive && react_default.createElement(
  25447. Button,
  25448. {
  25449. variant: "ghost",
  25450. padding: "small",
  25451. size: "small",
  25452. onClick: onClearClick,
  25453. ariaLabel: "Clear",
  25454. tooltip: "Clear"
  25455. },
  25456. react_default.createElement(CloseIcon, null)
  25457. ));
  25458. }, ReviewChangesButton_default = ReviewChangesButton;
  25459. // src/manager/components/sidebar/useLastViewed.ts
  25460. init_react();
  25461. var import_store2 = __toESM(require_store2(), 1), save = debounce((value) => import_store2.default.set("lastViewedStoryIds", value), 1e3), useLastViewed = (selection) => {
  25462. let initialLastViewedStoryIds = useMemo(() => {
  25463. let items = import_store2.default.get("lastViewedStoryIds");
  25464. return !items || !Array.isArray(items) ? [] : items.some((item) => typeof item == "object" && item.storyId && item.refId) ? items : [];
  25465. }, [import_store2.default]), lastViewedRef = useRef(initialLastViewedStoryIds), updateLastViewed = useCallback(
  25466. (story) => {
  25467. let items = lastViewedRef.current, index = items.findIndex(
  25468. ({ storyId, refId }) => storyId === story.storyId && refId === story.refId
  25469. );
  25470. index !== 0 && (index === -1 ? lastViewedRef.current = [story, ...items] : lastViewedRef.current = [story, ...items.slice(0, index), ...items.slice(index + 1)], save(lastViewedRef.current));
  25471. },
  25472. [lastViewedRef]
  25473. );
  25474. return useEffect(() => {
  25475. selection && updateLastViewed(selection);
  25476. }, [selection]), {
  25477. getLastViewed: useCallback(() => lastViewedRef.current, [lastViewedRef]),
  25478. clearLastViewed: useCallback(() => {
  25479. lastViewedRef.current = lastViewedRef.current.slice(0, 1), save(lastViewedRef.current);
  25480. }, [lastViewedRef])
  25481. };
  25482. };
  25483. // src/manager/components/sidebar/Sidebar.tsx
  25484. var DEFAULT_REF_ID = "storybook_internal", Container11 = styled.header(({ theme }) => ({
  25485. position: "absolute",
  25486. zIndex: 1,
  25487. left: 0,
  25488. top: 0,
  25489. bottom: 0,
  25490. right: 0,
  25491. width: "100%",
  25492. height: "100%",
  25493. display: "flex",
  25494. flexDirection: "column",
  25495. background: theme.background.content,
  25496. [MEDIA_DESKTOP_BREAKPOINT]: {
  25497. background: theme.background.app
  25498. }
  25499. })), Stack = styled.div({
  25500. display: "flex",
  25501. flexDirection: "column",
  25502. gap: 16,
  25503. padding: "16px 12px 20px 12px"
  25504. }), CreateNewStoryButton = styled(Button)(({ theme, isMobile: isMobile2 }) => ({
  25505. color: theme.textMutedColor,
  25506. width: isMobile2 ? 36 : 32,
  25507. height: isMobile2 ? 36 : 32,
  25508. borderRadius: theme.appBorderRadius + 2
  25509. })), useCombination = (index, indexError, previewInitialized, allStatuses, refs) => {
  25510. let hash = useMemo(
  25511. () => ({
  25512. [DEFAULT_REF_ID]: {
  25513. index,
  25514. filteredIndex: index,
  25515. indexError,
  25516. previewInitialized,
  25517. allStatuses,
  25518. title: null,
  25519. id: DEFAULT_REF_ID,
  25520. url: "iframe.html"
  25521. },
  25522. ...refs
  25523. }),
  25524. [refs, index, indexError, previewInitialized, allStatuses]
  25525. );
  25526. return useMemo(() => ({ hash, entries: Object.entries(hash) }), [hash]);
  25527. }, isRendererReact2 = scope.STORYBOOK_RENDERER === "react", Sidebar = react_default.memo(function({
  25528. // @ts-expect-error (non strict)
  25529. storyId = null,
  25530. refId = DEFAULT_REF_ID,
  25531. index,
  25532. indexJson,
  25533. indexError,
  25534. allStatuses,
  25535. previewInitialized,
  25536. menu,
  25537. menuHighlighted = !1,
  25538. enableShortcuts = !0,
  25539. isDevelopment = scope.CONFIG_TYPE === "DEVELOPMENT",
  25540. refs = {},
  25541. onMenuClick,
  25542. showCreateStoryButton = isDevelopment && isRendererReact2
  25543. }) {
  25544. let [isFileSearchModalOpen, setIsFileSearchModalOpen] = useState(!1), selected = useMemo(() => storyId && { storyId, refId }, [storyId, refId]), dataset = useCombination(index, indexError, previewInitialized, allStatuses, refs), isLoading = !index && !indexError, hasEntries = Object.keys(indexJson?.entries ?? {}).length > 0, lastViewedProps = useLastViewed(selected), { isMobile: isMobile2 } = useLayout(), api = useStorybookApi(), { viewMode } = api.getUrlState(), headerRef = useRef(null), { landmarkProps } = useLandmark(
  25545. { "aria-labelledby": "global-site-h1", role: "banner" },
  25546. headerRef
  25547. ), skipLinkHref = viewMode !== void 0 && viewMode !== "story" && viewMode !== "docs" ? "#main-content-wrapper" : "#storybook-preview-wrapper";
  25548. return react_default.createElement(
  25549. Container11,
  25550. {
  25551. className: "container sidebar-container",
  25552. id: focusableUIElements.sidebarRegion,
  25553. ref: headerRef,
  25554. ...landmarkProps
  25555. },
  25556. react_default.createElement("h1", { id: "global-site-h1", className: "sb-sr-only" }, "Storybook"),
  25557. react_default.createElement(IconSymbols, null),
  25558. react_default.createElement(ScrollArea, { vertical: !0, offset: 3, scrollbarSize: 6, scrollPadding: "4rem" }, react_default.createElement(Stack, null, react_default.createElement("div", null, react_default.createElement(
  25559. Heading2,
  25560. {
  25561. className: "sidebar-header",
  25562. menuHighlighted,
  25563. menu,
  25564. skipLinkHref,
  25565. isLoading,
  25566. onMenuClick
  25567. }
  25568. ), !isLoading && scope.CONFIG_TYPE === "DEVELOPMENT" && scope.FEATURES?.sidebarOnboardingChecklist !== !1 && react_default.createElement(ChecklistWidget, null)), react_default.createElement(
  25569. Search,
  25570. {
  25571. dataset,
  25572. enableShortcuts,
  25573. searchBarContent: showCreateStoryButton && react_default.createElement(react_default.Fragment, null, react_default.createElement(
  25574. CreateNewStoryButton,
  25575. {
  25576. isMobile: isMobile2,
  25577. onClick: () => {
  25578. setIsFileSearchModalOpen(!0);
  25579. },
  25580. ariaLabel: "Create a new story",
  25581. variant: "outline",
  25582. padding: "small"
  25583. },
  25584. react_default.createElement(PlusIcon, null)
  25585. ), react_default.createElement(
  25586. CreateNewStoryFileModal,
  25587. {
  25588. open: isFileSearchModalOpen,
  25589. onOpenChange: setIsFileSearchModalOpen
  25590. }
  25591. )),
  25592. searchFieldContent: react_default.createElement(Filter, null),
  25593. belowSearchContent: react_default.createElement(ReviewChangesButton_default, null),
  25594. ...lastViewedProps
  25595. },
  25596. ({
  25597. query,
  25598. results,
  25599. isNavVisible,
  25600. isNavReachable,
  25601. isSearchResultRendered,
  25602. closeMenu,
  25603. getMenuProps,
  25604. getItemProps,
  25605. highlightedIndex
  25606. }) => react_default.createElement(react_default.Fragment, null, react_default.createElement(
  25607. Explorer,
  25608. {
  25609. dataset,
  25610. selected,
  25611. isLoading,
  25612. isBrowsing: isNavVisible,
  25613. isHidden: !isNavReachable,
  25614. hasEntries
  25615. }
  25616. ), isSearchResultRendered && react_default.createElement(
  25617. SearchResults,
  25618. {
  25619. query,
  25620. results,
  25621. closeMenu,
  25622. getMenuProps,
  25623. getItemProps,
  25624. highlightedIndex,
  25625. enableShortcuts,
  25626. isLoading,
  25627. clearLastViewed: lastViewedProps.clearLastViewed
  25628. }
  25629. ))
  25630. )), isMobile2 || isLoading ? null : react_default.createElement(SidebarBottom, { isDevelopment }))
  25631. );
  25632. });
  25633. // src/manager/container/Menu.tsx
  25634. init_react();
  25635. var ProgressCircle2 = styled(ProgressSpinner)(({ theme }) => ({
  25636. color: theme.color.secondary
  25637. })), useMenu = ({
  25638. api,
  25639. showToolbar,
  25640. isPanelShown,
  25641. isNavShown,
  25642. enableShortcuts
  25643. }) => {
  25644. let shortcutKeys = api.getShortcutKeys(), { progress } = useChecklist(), about = useMemo(
  25645. () => ({
  25646. id: "about",
  25647. title: "About your Storybook",
  25648. onClick: () => api.changeSettingsTab("about"),
  25649. href: "./?path=/settings/about",
  25650. internal: !0,
  25651. closeOnClick: !0,
  25652. icon: react_default.createElement(InfoIcon, null)
  25653. }),
  25654. [api]
  25655. ), guide = useMemo(
  25656. () => ({
  25657. id: "guide",
  25658. title: "Onboarding guide",
  25659. onClick: () => api.changeSettingsTab("guide"),
  25660. href: "./?path=/settings/guide",
  25661. internal: !0,
  25662. closeOnClick: !0,
  25663. icon: react_default.createElement(ListUnorderedIcon, null),
  25664. right: progress < 100 && react_default.createElement(ActionList.Button, { as: "div", readOnly: !0, padding: "none", ariaLabel: `${progress}% completed` }, react_default.createElement(ProgressCircle2, { percentage: progress, running: !1, size: 16, width: 1.5 }), progress, "%")
  25665. }),
  25666. [api, progress]
  25667. ), shortcuts = useMemo(
  25668. () => ({
  25669. id: "shortcuts",
  25670. title: "Keyboard shortcuts",
  25671. onClick: () => api.changeSettingsTab("shortcuts"),
  25672. href: "./?path=/settings/shortcuts",
  25673. internal: !0,
  25674. closeOnClick: !0,
  25675. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.shortcutsPage }) : null,
  25676. icon: react_default.createElement(CommandIcon, null)
  25677. }),
  25678. [api, enableShortcuts, shortcutKeys.shortcutsPage]
  25679. ), sidebarToggle = useMemo(
  25680. () => ({
  25681. id: "S",
  25682. title: "Show sidebar",
  25683. onClick: () => api.toggleNav(),
  25684. closeOnClick: !0,
  25685. active: isNavShown,
  25686. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.toggleNav }) : null,
  25687. icon: isNavShown ? react_default.createElement(CheckIcon, null) : react_default.createElement(react_default.Fragment, null)
  25688. }),
  25689. [api, enableShortcuts, shortcutKeys, isNavShown]
  25690. ), toolbarToogle = useMemo(
  25691. () => ({
  25692. id: "T",
  25693. title: "Show toolbar",
  25694. onClick: () => api.toggleToolbar(),
  25695. active: showToolbar,
  25696. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.toolbar }) : null,
  25697. icon: showToolbar ? react_default.createElement(CheckIcon, null) : react_default.createElement(react_default.Fragment, null)
  25698. }),
  25699. [api, enableShortcuts, shortcutKeys, showToolbar]
  25700. ), addonsToggle = useMemo(
  25701. () => ({
  25702. id: "A",
  25703. title: "Show addons panel",
  25704. onClick: () => api.togglePanel(),
  25705. active: isPanelShown,
  25706. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.togglePanel }) : null,
  25707. icon: isPanelShown ? react_default.createElement(CheckIcon, null) : react_default.createElement(react_default.Fragment, null)
  25708. }),
  25709. [api, enableShortcuts, shortcutKeys, isPanelShown]
  25710. ), up = useMemo(
  25711. () => ({
  25712. id: "up",
  25713. title: "Previous component",
  25714. onClick: () => api.jumpToComponent(-1),
  25715. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.prevComponent }) : null,
  25716. icon: react_default.createElement(react_default.Fragment, null)
  25717. }),
  25718. [api, enableShortcuts, shortcutKeys]
  25719. ), down = useMemo(
  25720. () => ({
  25721. id: "down",
  25722. title: "Next component",
  25723. onClick: () => api.jumpToComponent(1),
  25724. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.nextComponent }) : null,
  25725. icon: react_default.createElement(react_default.Fragment, null)
  25726. }),
  25727. [api, enableShortcuts, shortcutKeys]
  25728. ), prev = useMemo(
  25729. () => ({
  25730. id: "prev",
  25731. title: "Previous story",
  25732. onClick: () => api.jumpToStory(-1),
  25733. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.prevStory }) : null,
  25734. icon: react_default.createElement(react_default.Fragment, null)
  25735. }),
  25736. [api, enableShortcuts, shortcutKeys]
  25737. ), next = useMemo(
  25738. () => ({
  25739. id: "next",
  25740. title: "Next story",
  25741. onClick: () => api.jumpToStory(1),
  25742. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.nextStory }) : null,
  25743. icon: react_default.createElement(react_default.Fragment, null)
  25744. }),
  25745. [api, enableShortcuts, shortcutKeys]
  25746. ), collapse = useMemo(
  25747. () => ({
  25748. id: "collapse",
  25749. title: "Collapse all",
  25750. onClick: () => api.emit(STORIES_COLLAPSE_ALL),
  25751. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.collapseAll }) : null,
  25752. icon: react_default.createElement(react_default.Fragment, null)
  25753. }),
  25754. [api, enableShortcuts, shortcutKeys]
  25755. ), documentation = useMemo(() => ({
  25756. id: "documentation",
  25757. title: "Documentation",
  25758. closeOnClick: !0,
  25759. href: api.getDocsUrl({ versioned: !0, renderer: !0 }),
  25760. right: react_default.createElement(ActionList.Icon, null, react_default.createElement(ShareAltIcon, null)),
  25761. icon: react_default.createElement(DocumentIcon, null)
  25762. }), [api]), getAddonsShortcuts = useCallback(() => {
  25763. let addonsShortcuts = api.getAddonsShortcuts(), keys = shortcutKeys;
  25764. return Object.entries(addonsShortcuts).filter(([_2, { showInMenu }]) => showInMenu).map(([actionName, { label, action }]) => ({
  25765. id: actionName,
  25766. title: label,
  25767. onClick: () => action(),
  25768. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: keys[actionName] }) : null
  25769. }));
  25770. }, [api, enableShortcuts, shortcutKeys]);
  25771. return useMemo(
  25772. () => [
  25773. [
  25774. about,
  25775. ...scope.CONFIG_TYPE === "DEVELOPMENT" ? [guide] : [],
  25776. ...enableShortcuts ? [shortcuts] : []
  25777. ],
  25778. [sidebarToggle, toolbarToogle, addonsToggle, up, down, prev, next, collapse],
  25779. getAddonsShortcuts(),
  25780. [documentation]
  25781. ],
  25782. [
  25783. about,
  25784. guide,
  25785. documentation,
  25786. shortcuts,
  25787. sidebarToggle,
  25788. toolbarToogle,
  25789. addonsToggle,
  25790. up,
  25791. down,
  25792. prev,
  25793. next,
  25794. collapse,
  25795. getAddonsShortcuts,
  25796. enableShortcuts
  25797. ]
  25798. );
  25799. };
  25800. // src/manager/container/Sidebar.tsx
  25801. var Sidebar3 = react_default.memo(function({ onMenuClick }) {
  25802. return react_default.createElement(Consumer, { filter: ({ state, api }) => {
  25803. let {
  25804. ui: { name, url, enableShortcuts },
  25805. viewMode,
  25806. storyId,
  25807. refId,
  25808. layout: { showToolbar },
  25809. // FIXME: This is the actual `index.json` index where the `index` below
  25810. // is actually the stories hash. We should fix this up and make it consistent.
  25811. internal_index,
  25812. filteredIndex: index,
  25813. indexError,
  25814. previewInitialized,
  25815. refs
  25816. } = state, whatsNewNotificationsEnabled = state.whatsNewData?.status === "SUCCESS" && !state.disableWhatsNewNotifications;
  25817. return {
  25818. api,
  25819. title: name,
  25820. url,
  25821. indexJson: internal_index,
  25822. index,
  25823. indexError,
  25824. previewInitialized,
  25825. refs,
  25826. storyId,
  25827. refId,
  25828. viewMode,
  25829. showToolbar,
  25830. isPanelShown: api.getIsPanelShown(),
  25831. isNavShown: api.getIsNavShown(),
  25832. menuHighlighted: whatsNewNotificationsEnabled && api.isWhatsNewUnread(),
  25833. enableShortcuts
  25834. };
  25835. } }, ({ api, showToolbar, isPanelShown, isNavShown, enableShortcuts, ...state }) => {
  25836. let menu = useMenu({ api, showToolbar, isPanelShown, isNavShown, enableShortcuts }), allStatuses = experimental_useStatusStore();
  25837. return react_default.createElement(
  25838. Sidebar,
  25839. {
  25840. ...state,
  25841. menu,
  25842. onMenuClick,
  25843. allStatuses,
  25844. enableShortcuts
  25845. }
  25846. );
  25847. });
  25848. }), Sidebar_default = Sidebar3;
  25849. // src/manager/App.tsx
  25850. var App = ({ managerLayoutState, setManagerLayoutState, pages, hasTab }) => {
  25851. let { setMobileAboutOpen } = useLayout(), { enableShortcuts = !0 } = addons.getConfig();
  25852. return useEffect(() => {
  25853. document.body.setAttribute("data-shortcuts-enabled", enableShortcuts ? "true" : "false");
  25854. }, [enableShortcuts]), useEffect(() => {
  25855. let rootElement = document.getElementById("root");
  25856. if (!rootElement)
  25857. return;
  25858. let observer = new MutationObserver(() => {
  25859. let hasInert = rootElement.hasAttribute("inert");
  25860. addons.getChannel().emit(core_events_default.MANAGER_INERT_ATTRIBUTE_CHANGED, hasInert);
  25861. });
  25862. return observer.observe(rootElement, {
  25863. attributes: !0,
  25864. attributeFilter: ["inert"]
  25865. }), () => observer.disconnect();
  25866. }, []), react_default.createElement(react_default.Fragment, null, react_default.createElement(Global, { styles: createGlobal }), react_default.createElement(ManagerErrorBoundary, null, react_default.createElement(
  25867. Layout,
  25868. {
  25869. hasTab,
  25870. managerLayoutState,
  25871. setManagerLayoutState,
  25872. slotMain: react_default.createElement(Preview_default, { id: "main", withLoader: !0 }),
  25873. slotSidebar: react_default.createElement(Sidebar_default, { onMenuClick: () => setMobileAboutOpen((state) => !state) }),
  25874. slotPanel: react_default.createElement(Panel_default, null),
  25875. slotPages: pages.map(({ id, render: Content6 }) => react_default.createElement(Content6, { key: id }))
  25876. }
  25877. )));
  25878. };
  25879. // src/manager/provider.ts
  25880. var Provider2 = class {
  25881. getElements(_type) {
  25882. throw new Error("Provider.getElements() is not implemented!");
  25883. }
  25884. handleAPI(_api) {
  25885. throw new Error("Provider.handleAPI() is not implemented!");
  25886. }
  25887. getConfig() {
  25888. return console.error("Provider.getConfig() is not implemented!"), {};
  25889. }
  25890. };
  25891. // src/manager/settings/index.tsx
  25892. init_react();
  25893. // src/manager/settings/AboutPage.tsx
  25894. init_react();
  25895. // src/manager/settings/About.tsx
  25896. init_react();
  25897. var Container12 = styled.div({
  25898. display: "flex",
  25899. alignItems: "center",
  25900. flexDirection: "column",
  25901. marginTop: 40
  25902. }), Header = styled.header({
  25903. marginBottom: 32,
  25904. alignItems: "center",
  25905. display: "flex",
  25906. "> svg": {
  25907. height: 48,
  25908. width: "auto",
  25909. marginRight: 8
  25910. }
  25911. }), Footer = styled.div(({ theme }) => ({
  25912. marginBottom: 24,
  25913. display: "flex",
  25914. flexDirection: "column",
  25915. alignItems: "center",
  25916. color: theme.base === "light" ? theme.color.dark : theme.color.lightest,
  25917. fontWeight: theme.typography.weight.regular,
  25918. fontSize: theme.typography.size.s2
  25919. })), Actions2 = styled.div({
  25920. display: "flex",
  25921. flexDirection: "row",
  25922. alignItems: "center",
  25923. marginBottom: 24,
  25924. marginTop: 24,
  25925. gap: 16
  25926. }), StyledLink = styled(Link)(({ theme }) => ({
  25927. "&&": {
  25928. fontWeight: theme.typography.weight.bold,
  25929. color: theme.base === "light" ? theme.color.dark : theme.color.light
  25930. },
  25931. "&:hover": {
  25932. color: theme.base === "light" ? theme.color.darkest : theme.color.lightest
  25933. }
  25934. })), AboutScreen = ({ onNavigateToWhatsNew }) => react_default.createElement(Container12, null, react_default.createElement(Header, null, react_default.createElement(StorybookLogo, { alt: "Storybook" })), react_default.createElement(UpgradeBlock, { onNavigateToWhatsNew }), react_default.createElement(Footer, null, react_default.createElement(Actions2, null, react_default.createElement(Button, { ariaLabel: !1, asChild: !0 }, react_default.createElement("a", { href: "https://github.com/storybookjs/storybook" }, react_default.createElement(GithubIcon, null), "GitHub")), react_default.createElement(Button, { ariaLabel: !1, asChild: !0 }, react_default.createElement("a", { href: "https://storybook.js.org/docs?ref=ui" }, react_default.createElement(DocumentIcon, { style: { display: "inline", marginRight: 5 } }), "Documentation"))), react_default.createElement("div", null, "Open source software maintained by", " ", react_default.createElement(StyledLink, { href: "https://www.chromatic.com/" }, "Chromatic"), " and the", " ", react_default.createElement(StyledLink, { href: "https://github.com/storybookjs/storybook/graphs/contributors" }, "Storybook Community"))));
  25935. // src/manager/settings/AboutPage.tsx
  25936. var NotificationClearer = class extends Component {
  25937. componentDidMount() {
  25938. let { api, notificationId } = this.props;
  25939. api.clearNotification(notificationId);
  25940. }
  25941. render() {
  25942. let { children } = this.props;
  25943. return children;
  25944. }
  25945. }, AboutPage = () => {
  25946. let api = useStorybookApi(), state = useStorybookState(), onNavigateToWhatsNew = useCallback(() => {
  25947. api.changeSettingsTab("whats-new");
  25948. }, [api]);
  25949. return react_default.createElement(NotificationClearer, { api, notificationId: "update" }, react_default.createElement(
  25950. AboutScreen,
  25951. {
  25952. onNavigateToWhatsNew: state.whatsNewData?.status === "SUCCESS" ? onNavigateToWhatsNew : void 0
  25953. }
  25954. ));
  25955. };
  25956. // src/manager/settings/GuidePage.tsx
  25957. init_react();
  25958. // src/manager/settings/Checklist/Checklist.tsx
  25959. init_react();
  25960. // src/manager/components/Focus/Focus.tsx
  25961. init_react();
  25962. var FocusOutline = styled.div(
  25963. ({ theme, active = !1, outlineOffset = 0 }) => ({
  25964. width: "100%",
  25965. borderRadius: "inherit",
  25966. transition: "outline-color var(--transition-duration, 0.2s)",
  25967. outline: `2px solid ${active ? theme.color.secondary : "transparent"}`,
  25968. outlineOffset
  25969. })
  25970. ), FocusProxy = styled(FocusOutline)(({ theme, targetId }) => ({
  25971. [`&:has([data-target-id="${targetId}"]:focus-visible)`]: {
  25972. outlineColor: theme.color.secondary
  25973. }
  25974. })), FocusRing = ({
  25975. active = !1,
  25976. highlightDuration,
  25977. nodeRef,
  25978. ...props
  25979. }) => {
  25980. let [visible, setVisible] = useState(active);
  25981. return useEffect(() => {
  25982. if (highlightDuration) {
  25983. setVisible(active);
  25984. let timeout = setTimeout(setVisible, highlightDuration, !1);
  25985. return () => clearTimeout(timeout);
  25986. }
  25987. }, [active, highlightDuration]), react_default.createElement(FocusOutline, { ...props, active: highlightDuration ? visible : active, ref: nodeRef });
  25988. }, FocusTarget = ({
  25989. targetHash,
  25990. highlightDuration,
  25991. ...props
  25992. }) => {
  25993. let nodeRef = useRef(null), locationHash = useLocationHash(), [active, setActive] = useState(locationHash === targetHash);
  25994. return useEffect(() => {
  25995. let timeouts = [];
  25996. return setActive(!1), locationHash === targetHash && (timeouts.push(
  25997. setTimeout(() => {
  25998. setActive(!0), nodeRef.current?.focus({ preventScroll: !0 }), nodeRef.current?.scrollIntoView({ behavior: "smooth", block: "center" });
  25999. }, 0)
  26000. ), highlightDuration && timeouts.push(setTimeout(setActive, highlightDuration, !1))), () => timeouts.forEach(clearTimeout);
  26001. }, [locationHash, targetHash, highlightDuration]), react_default.createElement(FocusRing, { ...props, active, nodeRef, tabIndex: -1 });
  26002. }, Focus = {
  26003. Outline: FocusOutline,
  26004. Proxy: FocusProxy,
  26005. Ring: FocusRing,
  26006. Target: FocusTarget
  26007. };
  26008. // src/manager/settings/Checklist/Checklist.tsx
  26009. var Sections = styled.ol(({ theme }) => ({
  26010. listStyle: "none",
  26011. display: "flex",
  26012. flexDirection: "column",
  26013. gap: 20,
  26014. margin: 0,
  26015. padding: 0,
  26016. "& > li": {
  26017. background: theme.background.content,
  26018. border: `1px solid ${theme.base === "dark" ? theme.color.darker : theme.color.border}`,
  26019. borderRadius: 8
  26020. }
  26021. })), Items = styled.ol(({ theme }) => ({
  26022. listStyle: "none",
  26023. display: "flex",
  26024. flexDirection: "column",
  26025. margin: 0,
  26026. padding: 0,
  26027. "& > li:not(:last-child)": {
  26028. boxShadow: `inset 0 -1px 0 ${theme.base === "dark" ? theme.color.darker : theme.color.border}`
  26029. },
  26030. "& > li:last-child": {
  26031. borderBottomLeftRadius: 7,
  26032. borderBottomRightRadius: 7
  26033. }
  26034. })), SectionSummary = styled.div(
  26035. ({ theme, progress, isCollapsed, onClick }) => ({
  26036. position: "relative",
  26037. fontWeight: "bold",
  26038. display: "flex",
  26039. alignItems: "center",
  26040. gap: 10,
  26041. padding: "10px 10px 10px 15px",
  26042. borderBottom: `5px solid ${theme.base === "dark" ? theme.color.darker : theme.color.light}`,
  26043. borderBottomLeftRadius: isCollapsed ? 7 : 0,
  26044. borderBottomRightRadius: isCollapsed ? 7 : 0,
  26045. transition: "border-radius var(--transition-duration, 0.2s)",
  26046. cursor: onClick ? "pointer" : "default",
  26047. "--toggle-button-rotate": isCollapsed ? "0deg" : "180deg",
  26048. "--toggle-button-opacity": 0,
  26049. "&:hover, &:focus-visible": {
  26050. outline: "none",
  26051. "--toggle-button-opacity": 1
  26052. },
  26053. "&::after": {
  26054. pointerEvents: "none",
  26055. position: "absolute",
  26056. top: 0,
  26057. bottom: -5,
  26058. left: 0,
  26059. right: 0,
  26060. content: '""',
  26061. display: "block",
  26062. width: `${progress}%`,
  26063. borderBottom: `5px solid ${theme.color.positive}`,
  26064. borderBottomLeftRadius: "inherit",
  26065. borderBottomRightRadius: progress === 100 ? "inherit" : 0,
  26066. transition: "width var(--transition-duration, 0.2s)"
  26067. }
  26068. })
  26069. ), SectionHeading = styled.h2(({ theme }) => ({
  26070. flex: 1,
  26071. margin: 0,
  26072. fontSize: theme.typography.size.s3,
  26073. fontWeight: theme.typography.weight.bold
  26074. })), ItemSummary = styled.div(
  26075. ({ theme, isCollapsed, onClick }) => ({
  26076. fontWeight: theme.typography.weight.regular,
  26077. fontSize: theme.typography.size.s2,
  26078. display: "flex",
  26079. alignItems: "center",
  26080. minHeight: 40,
  26081. gap: 10,
  26082. padding: isCollapsed ? "6px 10px 6px 15px" : "10px 10px 10px 15px",
  26083. transition: "padding var(--transition-duration, 0.2s)",
  26084. cursor: onClick ? "pointer" : "default",
  26085. "--toggle-button-rotate": isCollapsed ? "0deg" : "180deg",
  26086. "&:focus-visible": {
  26087. outline: "none"
  26088. }
  26089. })
  26090. ), ItemHeading = styled.h3(({ theme, skipped }) => ({
  26091. flex: 1,
  26092. margin: 0,
  26093. color: skipped ? theme.textMutedColor : theme.color.defaultText,
  26094. overflow: "hidden",
  26095. textOverflow: "ellipsis",
  26096. whiteSpace: "nowrap",
  26097. fontSize: theme.typography.size.s2,
  26098. fontWeight: theme.typography.weight.bold
  26099. })), ItemContent2 = styled.div(({ theme }) => ({
  26100. display: "flex",
  26101. flexDirection: "column",
  26102. alignItems: "flex-start",
  26103. gap: 8,
  26104. padding: "0 15px 15px 41px",
  26105. fontSize: theme.typography.size.s2,
  26106. code: {
  26107. fontSize: "0.9em",
  26108. backgroundColor: theme.background.app,
  26109. borderRadius: theme.appBorderRadius,
  26110. padding: "1px 3px"
  26111. },
  26112. img: {
  26113. maxWidth: "100%",
  26114. margin: "15px auto"
  26115. },
  26116. p: {
  26117. margin: 0,
  26118. lineHeight: 1.4
  26119. },
  26120. "ol, ul": {
  26121. paddingLeft: 25,
  26122. listStyleType: "disc",
  26123. "li::marker": {
  26124. color: theme.color.mediumdark
  26125. }
  26126. }
  26127. })), StatusIcon3 = styled.div(({ theme }) => ({
  26128. position: "relative",
  26129. flex: "0 0 auto",
  26130. minHeight: 16,
  26131. minWidth: 16,
  26132. margin: 0,
  26133. background: theme.base === "dark" ? theme.color.darkest : theme.background.app,
  26134. borderRadius: 9,
  26135. outline: `1px solid ${theme.base === "dark" ? theme.color.darker : theme.color.border}`,
  26136. outlineOffset: -1
  26137. })), Checked2 = styled(StatusPassIcon)(
  26138. ({ theme, "data-visible": visible }) => ({
  26139. position: "absolute",
  26140. width: "inherit",
  26141. height: "inherit",
  26142. top: 0,
  26143. left: 0,
  26144. bottom: 0,
  26145. right: 0,
  26146. padding: 1,
  26147. borderRadius: "50%",
  26148. background: theme.color.positive,
  26149. color: theme.background.content,
  26150. opacity: visible ? 1 : 0,
  26151. transform: visible ? "scale(1)" : "scale(0.7)",
  26152. transition: "all var(--transition-duration, 0.2s)"
  26153. })
  26154. ), Skipped = styled.span(({ theme, visible }) => ({
  26155. display: "flex",
  26156. alignItems: "center",
  26157. color: theme.textMutedColor,
  26158. fontSize: "12px",
  26159. fontWeight: "bold",
  26160. overflow: "hidden",
  26161. padding: visible ? "0 10px" : 0,
  26162. opacity: visible ? 1 : 0,
  26163. width: visible ? "auto" : 0,
  26164. height: visible ? 18 : 16,
  26165. transition: "all var(--transition-duration, 0.2s)"
  26166. })), Actions3 = styled.div({
  26167. alignSelf: "flex-end",
  26168. flexDirection: "row-reverse",
  26169. display: "flex",
  26170. gap: 4
  26171. }), ToggleButton2 = styled(Button)({
  26172. opacity: "var(--toggle-button-opacity)",
  26173. transition: "opacity var(--transition-duration, 0.2s)",
  26174. "&:hover, &:focus": {
  26175. opacity: 1
  26176. },
  26177. svg: {
  26178. transform: "rotate(var(--toggle-button-rotate))",
  26179. transition: "transform var(--transition-duration, 0.2s)"
  26180. }
  26181. }), ChecklistCopyButton = ({
  26182. label,
  26183. copyContent,
  26184. onClick
  26185. }) => {
  26186. let { children: copyChildren, buttonProps: copyButtonProps } = useCopyButton({
  26187. children: label,
  26188. onCopy: onClick,
  26189. content: copyContent
  26190. });
  26191. return react_default.createElement(Button, { variant: "solid", size: "small", ...copyButtonProps }, copyChildren);
  26192. }, Checklist = ({
  26193. availableItems,
  26194. accept,
  26195. skip,
  26196. reset,
  26197. forceCollapsed = !1
  26198. }) => {
  26199. let api = useStorybookApi(), locationHash = useLocationHash(), { itemsById, sectionsById } = useMemo(
  26200. () => availableItems.reduce(
  26201. (acc, item) => {
  26202. acc.itemsById[item.id] = item;
  26203. let { sectionId: id, sectionTitle: title2 } = item;
  26204. return acc.sectionsById[id] = acc.sectionsById[id] ?? { id, title: title2, itemIds: [] }, acc.sectionsById[id].itemIds.push(item.id), acc;
  26205. },
  26206. { itemsById: {}, sectionsById: {} }
  26207. ),
  26208. [availableItems]
  26209. ), sections = useMemo(
  26210. () => Object.values(sectionsById).map(({ id, title: title2, itemIds }) => {
  26211. let items = itemIds.map((id2) => itemsById[id2]).filter(({ showOnGuidePage }) => showOnGuidePage !== !1), progress = items.reduce((acc, item) => item.isOpen ? acc : acc + 1, 0) / items.length * 100;
  26212. return { id, title: title2, items, progress };
  26213. }),
  26214. [itemsById, sectionsById]
  26215. );
  26216. return react_default.createElement(Sections, null, sections.map(({ id, title: title2, items, progress }) => {
  26217. let collapsed = forceCollapsed || progress === 100 && items.every((item) => item.id !== locationHash);
  26218. return react_default.createElement("li", { key: id }, react_default.createElement(Focus.Proxy, { targetId: `toggle-${id}` }, react_default.createElement(
  26219. Collapsible,
  26220. {
  26221. collapsed,
  26222. summary: ({ isCollapsed, toggleCollapsed, toggleProps }) => react_default.createElement(
  26223. SectionSummary,
  26224. {
  26225. progress,
  26226. isCollapsed,
  26227. onClick: toggleCollapsed
  26228. },
  26229. react_default.createElement(StatusIcon3, null, react_default.createElement(Checked2, { "data-visible": progress === 100 })),
  26230. react_default.createElement(SectionHeading, null, title2),
  26231. react_default.createElement(Actions3, null, react_default.createElement(
  26232. ToggleButton2,
  26233. {
  26234. ...toggleProps,
  26235. "data-target-id": `toggle-${id}`,
  26236. variant: "ghost",
  26237. padding: "small",
  26238. "aria-label": title2
  26239. },
  26240. react_default.createElement(ChevronSmallDownIcon, null)
  26241. ))
  26242. )
  26243. },
  26244. react_default.createElement(Items, null, items.map(
  26245. ({
  26246. content,
  26247. isOpen,
  26248. isAccepted,
  26249. isDone,
  26250. isLockedBy,
  26251. isImmutable,
  26252. isSkipped,
  26253. ...item
  26254. }) => {
  26255. let isChecked = isAccepted || isDone, isCollapsed = item.id !== locationHash, isLocked = !!isLockedBy, itemContent = content?.({ api });
  26256. return react_default.createElement(ActionList.Item, { key: item.id }, react_default.createElement(
  26257. Focus.Target,
  26258. {
  26259. targetHash: item.id,
  26260. highlightDuration: 2e3,
  26261. outlineOffset: -2
  26262. },
  26263. react_default.createElement(Focus.Proxy, { targetId: `toggle-${item.id}`, outlineOffset: -2 }, react_default.createElement(
  26264. Collapsible,
  26265. {
  26266. collapsed: isCollapsed,
  26267. summary: ({ isCollapsed: isCollapsed2, toggleCollapsed, toggleProps }) => react_default.createElement(
  26268. ItemSummary,
  26269. {
  26270. isCollapsed: isCollapsed2 || !itemContent,
  26271. onClick: itemContent ? toggleCollapsed : void 0
  26272. },
  26273. react_default.createElement(StatusIcon3, null, react_default.createElement(Checked2, { "data-visible": isChecked }), react_default.createElement(Skipped, { visible: isSkipped }, "Skipped")),
  26274. react_default.createElement(ItemHeading, { skipped: isSkipped }, item.label),
  26275. react_default.createElement(Actions3, null, itemContent && react_default.createElement(
  26276. ToggleButton2,
  26277. {
  26278. ...toggleProps,
  26279. "data-target-id": `toggle-${item.id}`,
  26280. variant: "ghost",
  26281. padding: "small",
  26282. ariaLabel: `${isCollapsed2 ? "Expand" : "Collapse"} ${item.label}`
  26283. },
  26284. react_default.createElement(ChevronSmallDownIcon, null)
  26285. ), isLocked && react_default.createElement(
  26286. Button,
  26287. {
  26288. variant: "ghost",
  26289. padding: "small",
  26290. ariaLabel: "Locked",
  26291. tooltip: `Complete \u201C${itemsById[isLockedBy].label}\u201D first`,
  26292. disabled: !0,
  26293. readOnly: !0
  26294. },
  26295. react_default.createElement(LockIcon, null)
  26296. ), isOpen && !isLocked && item.action && (item.action.copyContent ? react_default.createElement(
  26297. ChecklistCopyButton,
  26298. {
  26299. label: item.action.label,
  26300. copyContent: item.action.copyContent,
  26301. onClick: () => item.action.onClick({
  26302. api,
  26303. accept: () => accept(item.id)
  26304. })
  26305. }
  26306. ) : react_default.createElement(
  26307. Button,
  26308. {
  26309. ariaLabel: !1,
  26310. variant: "solid",
  26311. size: "small",
  26312. onClick: (e2) => {
  26313. e2.stopPropagation(), item.action?.onClick({
  26314. api,
  26315. accept: () => accept(item.id)
  26316. });
  26317. }
  26318. },
  26319. item.action.label
  26320. )), isOpen && !isLocked && !item.action && !item.subscribe && react_default.createElement(
  26321. Button,
  26322. {
  26323. ariaLabel: !1,
  26324. variant: "outline",
  26325. size: "small",
  26326. onClick: (e2) => {
  26327. e2.stopPropagation(), accept(item.id);
  26328. }
  26329. },
  26330. react_default.createElement(CheckIcon, null),
  26331. "Mark as complete"
  26332. ), isOpen && !isLocked && react_default.createElement(
  26333. Button,
  26334. {
  26335. ariaLabel: !1,
  26336. variant: "ghost",
  26337. size: "small",
  26338. onClick: (e2) => {
  26339. e2.stopPropagation(), skip(item.id);
  26340. }
  26341. },
  26342. "Skip"
  26343. ), (isAccepted && !isImmutable || isSkipped) && !isLocked && react_default.createElement(
  26344. Button,
  26345. {
  26346. ariaLabel: "Undo",
  26347. variant: "ghost",
  26348. padding: "small",
  26349. onClick: (e2) => {
  26350. e2.stopPropagation(), reset(item.id);
  26351. }
  26352. },
  26353. react_default.createElement(UndoIcon, null)
  26354. ))
  26355. )
  26356. },
  26357. itemContent && react_default.createElement(ItemContent2, null, itemContent)
  26358. ))
  26359. ));
  26360. }
  26361. ))
  26362. )));
  26363. }));
  26364. };
  26365. // src/manager/settings/Checklist/AiSetupBlock.tsx
  26366. init_react();
  26367. var AiCtaCard = styled.div(({ theme }) => ({
  26368. display: "flex",
  26369. flexDirection: "column",
  26370. padding: "10px 10px 10px 15px",
  26371. border: `1px solid ${theme.base === "dark" ? theme.color.darker : theme.color.border}`,
  26372. borderRadius: 8,
  26373. background: theme.background.content
  26374. })), AiCtaHeadingRow = styled.div({
  26375. display: "flex",
  26376. alignItems: "center",
  26377. gap: 10
  26378. }), AiCtaHeading = styled.h2(({ theme, $skipped }) => ({
  26379. flex: 1,
  26380. margin: 0,
  26381. color: $skipped ? theme.textMutedColor : theme.color.defaultText,
  26382. fontSize: theme.typography.size.s2,
  26383. fontWeight: theme.typography.weight.bold,
  26384. textWrap: "pretty"
  26385. })), AiCtaDescription = styled.p(({ theme }) => ({
  26386. margin: 0,
  26387. color: theme.color.defaultText,
  26388. fontSize: theme.typography.size.s2,
  26389. fontWeight: theme.typography.weight.regular,
  26390. marginTop: 8
  26391. })), AiCtaActions = styled.div({
  26392. display: "flex",
  26393. gap: 8,
  26394. justifyContent: "flex-end",
  26395. marginTop: 12
  26396. }), CopyButton2 = ({ api }) => {
  26397. let { children: buttonChildren, buttonProps } = useCopyButton({
  26398. children: "Copy prompt",
  26399. childrenOnCopy: react_default.createElement(react_default.Fragment, null, react_default.createElement(CheckIcon, null), " Copied!"),
  26400. content: getAiSetupPrompt(),
  26401. onCopy: () => {
  26402. api.emit(AI_PROMPT_NUDGE, { id: "setup", origin: "onboarding-guide-page" });
  26403. }
  26404. });
  26405. return react_default.createElement(Button, { variant: "solid", size: "medium", ...buttonProps }, buttonChildren);
  26406. }, AiSetupBlock = ({
  26407. item,
  26408. reset,
  26409. skip
  26410. }) => {
  26411. let api = useStorybookApi();
  26412. return !item.isDone && !item.isAccepted && !item.isCompleted ? react_default.createElement(AiCtaCard, null, react_default.createElement(AiCtaHeadingRow, null, item.isSkipped && react_default.createElement(StatusIcon3, null, react_default.createElement(Skipped, { visible: !0 }, "Skipped")), react_default.createElement(AiCtaHeading, { $skipped: item.isSkipped }, "Set up Storybook with AI"), item.isSkipped && react_default.createElement(Button, { ariaLabel: "Undo", variant: "ghost", padding: "small", onClick: () => reset(item.id) }, react_default.createElement(UndoIcon, null))), react_default.createElement(Collapsible.Content, { collapsed: item.isSkipped }, react_default.createElement(AiCtaDescription, null, "Run a prompt in your AI agent to analyze your codebase, configure decorators and mocks, write sample stories for your UI components, and verify everything works."), react_default.createElement(AiCtaActions, null, react_default.createElement(Button, { variant: "ghost", size: "medium", ariaLabel: !1, onClick: () => skip(item.id) }, "Skip"), react_default.createElement(CopyButton2, { api })))) : null;
  26413. };
  26414. // src/manager/settings/GuidePage.tsx
  26415. var Container13 = styled.div(({ theme }) => ({
  26416. display: "flex",
  26417. flexDirection: "column",
  26418. maxWidth: 600,
  26419. margin: "0 auto",
  26420. padding: "48px 20px",
  26421. gap: 32,
  26422. fontSize: theme.typography.size.s2,
  26423. "--transition-duration": "0.2s"
  26424. })), Intro = styled.div(({ theme }) => ({
  26425. display: "flex",
  26426. flexDirection: "column",
  26427. gap: 8,
  26428. "& h1": {
  26429. fontSize: theme.typography.size.m3,
  26430. fontWeight: theme.typography.weight.bold,
  26431. margin: 0
  26432. },
  26433. "& > p": {
  26434. margin: 0
  26435. }
  26436. })), GuidePage = () => {
  26437. let checklist = useChecklist(), aiSetupItem = checklist.availableItems.find((item) => item.id === "aiSetup");
  26438. return react_default.createElement(Container13, null, react_default.createElement(Intro, null, react_default.createElement("h1", null, "Guide"), react_default.createElement("p", null, "Whether you're just getting started or looking for ways to level up, this checklist will help you make the most of your Storybook.")), aiSetupItem && react_default.createElement(AiSetupBlock, { item: aiSetupItem, reset: checklist.reset, skip: checklist.skip }), react_default.createElement(Checklist, { ...checklist, forceCollapsed: aiSetupItem?.isOpen }), scope.FEATURES?.sidebarOnboardingChecklist !== !1 && react_default.createElement(react_default.Fragment, null, checklist.openItems.length === 0 ? react_default.createElement("center", null, "Your work here is done!") : checklist.widget.disable || checklist.openItems.every((item) => item.isMuted) ? react_default.createElement("center", null, "Want to see this in the sidebar?", " ", react_default.createElement(Link, { onClick: () => checklist.disable(!1) }, "Show in sidebar")) : react_default.createElement("center", null, "Don't want to see this in the sidebar?", " ", react_default.createElement(Link, { onClick: () => checklist.mute(checklist.allItems.map(({ id }) => id)) }, "Remove from sidebar"))));
  26439. };
  26440. // src/manager/settings/ShortcutsPage.tsx
  26441. init_react();
  26442. // src/manager/settings/shortcuts.tsx
  26443. init_react();
  26444. // src/manager/settings/SettingsFooter.tsx
  26445. init_react();
  26446. var Footer2 = styled.div(({ theme }) => ({
  26447. display: "flex",
  26448. paddingTop: 20,
  26449. marginTop: 20,
  26450. borderTop: `1px solid ${theme.appBorderColor}`,
  26451. fontWeight: theme.typography.weight.bold,
  26452. "& > * + *": {
  26453. marginLeft: 20
  26454. }
  26455. })), SettingsFooter = (props) => react_default.createElement(Footer2, { ...props }, react_default.createElement(Link, { secondary: !0, href: "https://storybook.js.org?ref=ui", cancel: !1, target: "_blank" }, "Docs"), react_default.createElement(Link, { secondary: !0, href: "https://github.com/storybookjs/storybook", cancel: !1, target: "_blank" }, "GitHub"), react_default.createElement(
  26456. Link,
  26457. {
  26458. secondary: !0,
  26459. href: "https://storybook.js.org/community?ref=ui#support",
  26460. cancel: !1,
  26461. target: "_blank"
  26462. },
  26463. "Support"
  26464. )), SettingsFooter_default = SettingsFooter;
  26465. // src/manager/settings/shortcuts.tsx
  26466. var Header2 = styled.header(({ theme }) => ({
  26467. marginBottom: 20,
  26468. fontSize: theme.typography.size.m3,
  26469. fontWeight: theme.typography.weight.bold,
  26470. alignItems: "center",
  26471. display: "flex"
  26472. })), HeaderItem = styled.div(({ theme }) => ({
  26473. fontWeight: theme.typography.weight.bold
  26474. })), GridHeaderRow = styled.div({
  26475. alignSelf: "flex-end",
  26476. display: "grid",
  26477. margin: "10px 0",
  26478. gridTemplateColumns: "1fr 1fr 12px",
  26479. "& > *:last-of-type": {
  26480. gridColumn: "2 / 2",
  26481. justifySelf: "flex-end",
  26482. gridRow: "1"
  26483. }
  26484. }), Row = styled.div(({ theme }) => ({
  26485. padding: "6px 0",
  26486. borderTop: `1px solid ${theme.appBorderColor}`,
  26487. display: "grid",
  26488. gridTemplateColumns: "1fr 1fr 0px"
  26489. })), GridWrapper = styled.div({
  26490. display: "grid",
  26491. gridTemplateColumns: "1fr",
  26492. gridAutoRows: "minmax(auto, auto)",
  26493. marginBottom: 20
  26494. }), Description = styled.div({
  26495. alignSelf: "center"
  26496. }), TextInput = styled(Form.Input)(
  26497. ({ valid, theme }) => valid === "error" ? {
  26498. animation: `${theme.animation.jiggle} 700ms ease-out`
  26499. } : {},
  26500. {
  26501. display: "flex",
  26502. width: 80,
  26503. flexDirection: "column",
  26504. justifySelf: "flex-end",
  26505. paddingLeft: 4,
  26506. paddingRight: 4,
  26507. textAlign: "center"
  26508. }
  26509. ), Fade = keyframes`
  26510. 0%,100% { opacity: 0; }
  26511. 50% { opacity: 1; }
  26512. `, SuccessIcon = styled(CheckIcon)(
  26513. ({ valid, theme }) => valid === "valid" ? {
  26514. color: theme.color.positive,
  26515. animation: `${Fade} 2s ease forwards`
  26516. } : {
  26517. opacity: 0
  26518. },
  26519. {
  26520. alignSelf: "center",
  26521. display: "flex",
  26522. marginLeft: 10,
  26523. height: 14,
  26524. width: 14
  26525. }
  26526. ), Container14 = styled.div(({ theme }) => ({
  26527. fontSize: theme.typography.size.s2,
  26528. padding: "3rem 20px",
  26529. maxWidth: 600,
  26530. margin: "0 auto"
  26531. })), shortcutLabels = {
  26532. fullScreen: "Go full screen",
  26533. togglePanel: "Toggle addons",
  26534. panelPosition: "Toggle addons orientation",
  26535. toggleNav: "Toggle sidebar",
  26536. toolbar: "Toggle toolbar",
  26537. search: "Focus search",
  26538. focusNav: "Focus sidebar",
  26539. focusIframe: "Focus canvas",
  26540. focusPanel: "Focus addons",
  26541. prevComponent: "Previous component",
  26542. nextComponent: "Next component",
  26543. prevStory: "Previous story",
  26544. nextStory: "Next story",
  26545. shortcutsPage: "Go to shortcuts page",
  26546. aboutPage: "Go to about page",
  26547. collapseAll: "Collapse all items on sidebar",
  26548. expandAll: "Expand all items on sidebar",
  26549. remount: "Reload story",
  26550. openInEditor: "Open story in editor",
  26551. openInIsolation: "Open story in isolation",
  26552. copyStoryLink: "Copy story link to clipboard",
  26553. goToPreviousLandmark: "Go to previous landmark",
  26554. goToNextLandmark: "Go to next landmark"
  26555. // TODO: bring this back once we want to add shortcuts for this
  26556. // copyStoryName: 'Copy story name to clipboard',
  26557. }, fixedShortcuts = ["escape"], hardcodedShortcuts = ["goToPreviousLandmark", "goToNextLandmark"];
  26558. function toShortcutState(shortcutKeys) {
  26559. let state = {};
  26560. for (let key of Object.keys(shortcutKeys).filter((k2) => !fixedShortcuts.includes(k2)))
  26561. state[key] = {
  26562. shortcut: shortcutKeys[key],
  26563. error: !1,
  26564. hardcoded: hardcodedShortcuts.includes(key)
  26565. };
  26566. return state;
  26567. }
  26568. var ShortcutsScreen = class extends Component {
  26569. constructor(props) {
  26570. super(props);
  26571. this.onKeyDown = (e2) => {
  26572. let { activeFeature, shortcutKeys } = this.state;
  26573. if (e2.key === "Backspace")
  26574. return this.restoreDefault();
  26575. let shortcut = eventToShortcut(e2);
  26576. if (!shortcut)
  26577. return !1;
  26578. let normalizedShortcut = shortcut.map(
  26579. (key) => Array.isArray(key) ? key.at(-1) : key
  26580. ), error = !!Object.entries(shortcutKeys).find(
  26581. ([feature, { shortcut: existingShortcut }]) => feature !== activeFeature && existingShortcut && shortcutMatchesShortcut(normalizedShortcut, existingShortcut)
  26582. );
  26583. return this.setState({
  26584. shortcutKeys: { ...shortcutKeys, [activeFeature]: { shortcut: normalizedShortcut, error } }
  26585. });
  26586. };
  26587. this.onFocus = (focusedInput) => () => {
  26588. let { shortcutKeys } = this.state;
  26589. this.setState({
  26590. activeFeature: focusedInput,
  26591. shortcutKeys: {
  26592. ...shortcutKeys,
  26593. [focusedInput]: { shortcut: null, error: !1 }
  26594. }
  26595. });
  26596. };
  26597. this.onBlur = async () => {
  26598. let { shortcutKeys, activeFeature } = this.state;
  26599. if (shortcutKeys[activeFeature]) {
  26600. let { shortcut, error } = shortcutKeys[activeFeature];
  26601. return !shortcut || error ? this.restoreDefault() : this.saveShortcut();
  26602. }
  26603. return !1;
  26604. };
  26605. this.saveShortcut = async () => {
  26606. let { activeFeature, shortcutKeys } = this.state, { setShortcut } = this.props;
  26607. await setShortcut(activeFeature, shortcutKeys[activeFeature].shortcut), this.setState({ successField: activeFeature });
  26608. };
  26609. this.restoreDefaults = async () => {
  26610. let { restoreAllDefaultShortcuts } = this.props, defaultShortcuts = await restoreAllDefaultShortcuts();
  26611. return this.setState({ shortcutKeys: toShortcutState(defaultShortcuts) });
  26612. };
  26613. this.restoreDefault = async () => {
  26614. let { activeFeature, shortcutKeys } = this.state, { restoreDefaultShortcut } = this.props, defaultShortcut = await restoreDefaultShortcut(activeFeature);
  26615. return this.setState({
  26616. shortcutKeys: {
  26617. ...shortcutKeys,
  26618. ...toShortcutState({ [activeFeature]: defaultShortcut })
  26619. }
  26620. });
  26621. };
  26622. this.displaySuccessMessage = (activeElement) => {
  26623. let { successField, shortcutKeys } = this.state;
  26624. return activeElement === successField && shortcutKeys[activeElement].error === !1 ? "valid" : void 0;
  26625. };
  26626. this.displayError = (activeElement) => {
  26627. let { activeFeature, shortcutKeys } = this.state;
  26628. return activeElement === activeFeature && shortcutKeys[activeElement].error === !0 ? "error" : void 0;
  26629. };
  26630. this.renderKeyInput = () => {
  26631. let { shortcutKeys, addonsShortcutLabels } = this.state;
  26632. return Object.entries(shortcutKeys).filter(
  26633. ([feature]) => shortcutLabels[feature] !== void 0 || addonsShortcutLabels && addonsShortcutLabels[feature]
  26634. ).map(
  26635. ([feature, { shortcut, hardcoded }]) => react_default.createElement(Row, { key: feature }, react_default.createElement(Description, null, shortcutLabels[feature] || addonsShortcutLabels[feature]), hardcoded ? react_default.createElement(react_default.Fragment, null, react_default.createElement(
  26636. TooltipProvider,
  26637. {
  26638. tooltip: react_default.createElement(Tooltip, { hasChrome: !0 }, "This shortcut cannot be changed."),
  26639. placement: "right"
  26640. },
  26641. react_default.createElement(
  26642. TextInput,
  26643. {
  26644. "aria-disabled": !0,
  26645. readOnly: !0,
  26646. valid: void 0,
  26647. value: shortcut ? shortcutToHumanString(shortcut) : ""
  26648. }
  26649. )
  26650. )) : react_default.createElement(
  26651. TextInput,
  26652. {
  26653. spellCheck: "false",
  26654. valid: this.displayError(feature),
  26655. className: "modalInput",
  26656. onBlur: this.onBlur,
  26657. onFocus: this.onFocus(feature),
  26658. onKeyDown: this.onKeyDown,
  26659. value: shortcut ? shortcutToHumanString(shortcut) : "",
  26660. placeholder: "Type keys",
  26661. readOnly: !0
  26662. }
  26663. ), react_default.createElement(SuccessIcon, { valid: this.displaySuccessMessage(feature) }))
  26664. );
  26665. };
  26666. this.renderKeyForm = () => react_default.createElement(GridWrapper, null, react_default.createElement(GridHeaderRow, null, react_default.createElement(HeaderItem, null, "Commands"), react_default.createElement(HeaderItem, null, "Shortcut")), this.renderKeyInput());
  26667. this.state = {
  26668. // @ts-expect-error (non strict)
  26669. activeFeature: void 0,
  26670. // @ts-expect-error (non strict)
  26671. successField: void 0,
  26672. // The initial shortcutKeys that come from props are the defaults/what was saved
  26673. // As the user interacts with the page, the state stores the temporary, unsaved shortcuts
  26674. // This object also includes the error attached to each shortcut
  26675. shortcutKeys: toShortcutState(props.shortcutKeys),
  26676. addonsShortcutLabels: props.addonsShortcutLabels
  26677. };
  26678. }
  26679. render() {
  26680. let layout = this.renderKeyForm();
  26681. return react_default.createElement(Container14, null, react_default.createElement(Header2, null, "Keyboard shortcuts"), layout, react_default.createElement(
  26682. Button,
  26683. {
  26684. ariaLabel: !1,
  26685. variant: "outline",
  26686. size: "small",
  26687. id: "restoreDefaultsHotkeys",
  26688. onClick: this.restoreDefaults
  26689. },
  26690. "Restore defaults"
  26691. ), react_default.createElement(SettingsFooter_default, null));
  26692. }
  26693. };
  26694. // src/manager/settings/ShortcutsPage.tsx
  26695. var ShortcutsPage = () => react_default.createElement(Consumer, null, ({
  26696. api: {
  26697. getShortcutKeys,
  26698. getAddonsShortcutLabels,
  26699. setShortcut,
  26700. restoreDefaultShortcut,
  26701. restoreAllDefaultShortcuts
  26702. }
  26703. }) => react_default.createElement(
  26704. ShortcutsScreen,
  26705. {
  26706. shortcutKeys: getShortcutKeys(),
  26707. addonsShortcutLabels: getAddonsShortcutLabels(),
  26708. setShortcut,
  26709. restoreDefaultShortcut,
  26710. restoreAllDefaultShortcuts
  26711. }
  26712. ));
  26713. // src/manager/settings/whats_new_page.tsx
  26714. init_react();
  26715. // src/manager/settings/whats_new.tsx
  26716. init_react();
  26717. var Centered = styled.div({
  26718. top: "50%",
  26719. position: "absolute",
  26720. transform: "translateY(-50%)",
  26721. width: "100%",
  26722. textAlign: "center"
  26723. }), LoaderWrapper2 = styled.div({
  26724. position: "relative",
  26725. height: "32px"
  26726. }), Message2 = styled.div(({ theme }) => ({
  26727. paddingTop: "12px",
  26728. color: theme.textMutedColor,
  26729. maxWidth: "295px",
  26730. margin: "0 auto",
  26731. fontSize: `${theme.typography.size.s1}px`,
  26732. lineHeight: "16px"
  26733. })), Container15 = styled.div(({ theme }) => ({
  26734. position: "absolute",
  26735. width: "100%",
  26736. height: 40,
  26737. bottom: 0,
  26738. background: theme.background.bar,
  26739. fontSize: theme.typography.size.s2,
  26740. borderTop: `1px solid ${theme.color.border}`,
  26741. padding: "0 10px 0 15px",
  26742. display: "flex",
  26743. alignItems: "center",
  26744. justifyContent: "space-between"
  26745. })), WhatsNewFooter = ({
  26746. isNotificationsEnabled,
  26747. onToggleNotifications,
  26748. copyContent
  26749. }) => {
  26750. let theme = useTheme(), { children: copyText, buttonProps: copyButtonProps } = useCopyButton({
  26751. children: "Copy Link",
  26752. content: copyContent
  26753. });
  26754. return react_default.createElement(Container15, null, react_default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10 } }, react_default.createElement(HeartIcon, { color: theme.color.mediumdark }), react_default.createElement("div", null, "Share this with your team."), react_default.createElement(Button, { size: "small", variant: "ghost", ...copyButtonProps }, copyText)), isNotificationsEnabled ? react_default.createElement(Button, { ariaLabel: !1, size: "small", variant: "ghost", onClick: onToggleNotifications }, react_default.createElement(EyeCloseIcon, null), "Hide notifications") : react_default.createElement(Button, { ariaLabel: !1, size: "small", variant: "ghost", onClick: onToggleNotifications }, react_default.createElement(EyeIcon, null), "Show notifications"));
  26755. }, Iframe = styled.iframe(
  26756. {
  26757. position: "absolute",
  26758. top: 0,
  26759. left: 0,
  26760. right: 0,
  26761. bottom: 0,
  26762. border: 0,
  26763. margin: 0,
  26764. padding: 0,
  26765. width: "100%",
  26766. height: "calc(100% - 40px)",
  26767. background: "white"
  26768. },
  26769. ({ isLoaded }) => ({ visibility: isLoaded ? "visible" : "hidden" })
  26770. ), AlertIcon2 = styled(((props) => react_default.createElement(AlertIcon, { ...props })))(({ theme }) => ({
  26771. color: theme.textMutedColor,
  26772. width: 32,
  26773. height: 32,
  26774. margin: "0 auto"
  26775. })), WhatsNewLoader = () => react_default.createElement(Centered, null, react_default.createElement(LoaderWrapper2, null, react_default.createElement(Loader, null)), react_default.createElement(Message2, null, "Loading...")), MaxWaitTimeMessaging = () => react_default.createElement(Centered, null, react_default.createElement(AlertIcon2, null), react_default.createElement(Message2, null, "The page couldn't be loaded. Check your internet connection and try again.")), PureWhatsNewScreen = ({
  26776. didHitMaxWaitTime,
  26777. isLoaded,
  26778. onLoad,
  26779. url,
  26780. copyContent,
  26781. onToggleNotifications,
  26782. isNotificationsEnabled
  26783. }) => react_default.createElement(Fragment, null, !isLoaded && !didHitMaxWaitTime && react_default.createElement(WhatsNewLoader, null), didHitMaxWaitTime ? react_default.createElement(MaxWaitTimeMessaging, null) : react_default.createElement(react_default.Fragment, null, react_default.createElement(Iframe, { isLoaded, onLoad, src: url, title: "What's new?" }), react_default.createElement(
  26784. WhatsNewFooter,
  26785. {
  26786. isNotificationsEnabled,
  26787. onToggleNotifications,
  26788. copyContent
  26789. }
  26790. ))), MAX_WAIT_TIME = 1e4, WhatsNewScreen = () => {
  26791. let api = useStorybookApi(), state = useStorybookState(), { whatsNewData } = state, [isLoaded, setLoaded] = useState(!1), [didHitMaxWaitTime, setDidHitMaxWaitTime] = useState(!1);
  26792. if (useEffect(() => {
  26793. let timer = setTimeout(() => !isLoaded && setDidHitMaxWaitTime(!0), MAX_WAIT_TIME);
  26794. return () => clearTimeout(timer);
  26795. }, [isLoaded]), whatsNewData?.status !== "SUCCESS")
  26796. return null;
  26797. let isNotificationsEnabled = !whatsNewData.disableWhatsNewNotifications;
  26798. return react_default.createElement(
  26799. PureWhatsNewScreen,
  26800. {
  26801. didHitMaxWaitTime,
  26802. isLoaded,
  26803. onLoad: () => {
  26804. api.whatsNewHasBeenRead(), setLoaded(!0);
  26805. },
  26806. url: whatsNewData.url,
  26807. isNotificationsEnabled,
  26808. copyContent: whatsNewData.blogUrl ?? whatsNewData.url,
  26809. onToggleNotifications: () => {
  26810. isNotificationsEnabled ? scope.confirm("All update notifications will no longer be shown. Are you sure?") && api.toggleWhatsNewNotifications() : api.toggleWhatsNewNotifications();
  26811. }
  26812. }
  26813. );
  26814. };
  26815. // src/manager/settings/whats_new_page.tsx
  26816. var WhatsNewPage = () => react_default.createElement(WhatsNewScreen, null);
  26817. // src/manager/settings/index.tsx
  26818. var { document: document9 } = scope, Content5 = styled(ScrollArea)(({ theme }) => ({
  26819. background: theme.background.content
  26820. })), SidebarToggle = styled.div({
  26821. // Extra specificity is necessary here
  26822. "&&:has(*)": {
  26823. order: 0,
  26824. display: "flex",
  26825. alignItems: "center",
  26826. marginLeft: 10,
  26827. marginRight: 6,
  26828. gap: 6
  26829. }
  26830. }), RouteWrapper = ({ children, path }) => react_default.createElement(Content5, { vertical: !0, horizontal: !1 }, react_default.createElement(Route, { path }, children)), Pages = ({ changeTab, onClose, enableShortcuts = !0, enableWhatsNew }) => {
  26831. react_default.useEffect(() => {
  26832. let handleEscape = (event) => {
  26833. !enableShortcuts || event.repeat || matchesModifiers(!1, event) && matchesKeyCode("Escape", event) && (event.preventDefault(), onClose());
  26834. };
  26835. return document9.addEventListener("keydown", handleEscape), () => document9.removeEventListener("keydown", handleEscape);
  26836. }, [enableShortcuts, onClose]);
  26837. let api = useStorybookApi(), toolsExtra = Object.values(api.getElements(Addon_TypesEnum.TOOLEXTRA)), tabs = useMemo(() => {
  26838. let tabsToInclude = [
  26839. {
  26840. id: "about",
  26841. title: "About",
  26842. children: react_default.createElement(RouteWrapper, { path: "about" }, react_default.createElement(AboutPage, { key: "about" }))
  26843. }
  26844. ];
  26845. return scope.CONFIG_TYPE === "DEVELOPMENT" && tabsToInclude.push({
  26846. id: "guide",
  26847. title: "Guide",
  26848. children: react_default.createElement(RouteWrapper, { path: "guide" }, react_default.createElement(GuidePage, { key: "guide" }))
  26849. }), tabsToInclude.push({
  26850. id: "shortcuts",
  26851. title: "Keyboard shortcuts",
  26852. children: react_default.createElement(RouteWrapper, { path: "shortcuts" }, react_default.createElement(ShortcutsPage, { key: "shortcuts" }))
  26853. }), enableWhatsNew && tabsToInclude.push({
  26854. id: "whats-new",
  26855. title: "What's new?",
  26856. children: react_default.createElement(RouteWrapper, { path: "whats-new" }, react_default.createElement(WhatsNewPage, { key: "whats-new" }))
  26857. }), tabsToInclude;
  26858. }, [enableWhatsNew]);
  26859. return react_default.createElement(Location, null, ({ path }) => {
  26860. let selected = tabs.find((tab) => path.includes(`settings/${tab.id}`))?.id;
  26861. return react_default.createElement(
  26862. TabsView,
  26863. {
  26864. tabs,
  26865. tools: react_default.createElement(react_default.Fragment, null, react_default.createElement(SidebarToggle, null, menuTool.render({})), toolsExtra.map((item) => react_default.createElement(react_default.Fragment, { key: item.id }, item.render({}))), react_default.createElement(
  26866. Button,
  26867. {
  26868. padding: "small",
  26869. variant: "ghost",
  26870. onClick: (e2) => (e2.preventDefault(), onClose()),
  26871. ariaLabel: "Close settings page"
  26872. },
  26873. react_default.createElement(CloseIcon, null)
  26874. )),
  26875. selected,
  26876. onSelectionChange: changeTab
  26877. }
  26878. );
  26879. });
  26880. }, SettingsPages = () => {
  26881. let api = useStorybookApi(), state = useStorybookState(), changeTab = (tab) => api.changeSettingsTab(tab);
  26882. return react_default.createElement(
  26883. Pages,
  26884. {
  26885. enableWhatsNew: state.whatsNewData?.status === "SUCCESS",
  26886. enableShortcuts: state.ui.enableShortcuts,
  26887. changeTab,
  26888. onClose: api.closeSettings
  26889. }
  26890. );
  26891. }, settingsPageAddon = {
  26892. id: "settings",
  26893. url: "/settings/",
  26894. title: "Settings",
  26895. type: types.experimental_PAGE,
  26896. render: () => react_default.createElement(Route, { path: "/settings/", startsWith: !0 }, react_default.createElement(SettingsPages, null))
  26897. };
  26898. // src/manager/index.tsx
  26899. ThemeProvider.displayName = "ThemeProvider";
  26900. q.displayName = "HelmetProvider";
  26901. var Root3 = ({ provider }) => react_default.createElement(q, { key: "helmet.Provider" }, react_default.createElement(LocationProvider, { key: "location.provider" }, react_default.createElement(Main, { provider }))), Main = ({ provider }) => {
  26902. let navigate = useNavigate();
  26903. return react_default.createElement(Location, { key: "location.consumer" }, (locationData) => react_default.createElement(
  26904. Provider,
  26905. {
  26906. key: "manager",
  26907. provider,
  26908. ...locationData,
  26909. navigate,
  26910. docsOptions: scope?.DOCS_OPTIONS || {}
  26911. },
  26912. (combo) => {
  26913. let { state, api } = combo, setManagerLayoutState = useCallback(
  26914. (sizes) => {
  26915. api.setSizes(sizes);
  26916. },
  26917. [api]
  26918. ), pages = useMemo(
  26919. () => [settingsPageAddon, ...Object.values(api.getElements(types.experimental_PAGE))],
  26920. [Object.keys(api.getElements(types.experimental_PAGE)).join()]
  26921. );
  26922. return react_default.createElement(ThemeProvider, { key: "theme.provider", theme: ensure(state.theme) }, react_default.createElement(LayoutProvider, null, react_default.createElement(
  26923. App,
  26924. {
  26925. key: "app",
  26926. pages,
  26927. managerLayoutState: {
  26928. ...state.layout,
  26929. viewMode: state.viewMode
  26930. },
  26931. hasTab: !!api.getQueryParam("tab"),
  26932. setManagerLayoutState
  26933. }
  26934. )));
  26935. }
  26936. ));
  26937. };
  26938. function renderStorybookUI(domNode, provider) {
  26939. if (!(provider instanceof Provider2))
  26940. throw new ProviderDoesNotExtendBaseProviderError();
  26941. createRoot(domNode).render(react_default.createElement(Root3, { key: "root", provider }));
  26942. }
  26943. // src/manager/runtime.tsx
  26944. var WS_DISCONNECTED_NOTIFICATION_ID = "CORE/WS_DISCONNECTED";
  26945. addons.register(
  26946. TOOLBAR_ID,
  26947. () => addons.add(TOOLBAR_ID, {
  26948. title: TOOLBAR_ID,
  26949. type: types.TOOL,
  26950. match: ({ tabId }) => !tabId,
  26951. render: () => react_default.createElement(ToolbarManager, null)
  26952. })
  26953. );
  26954. var ReactProvider = class extends Provider2 {
  26955. constructor() {
  26956. super();
  26957. this.wsDisconnected = !1;
  26958. let channel = createBrowserChannel({ page: "manager" });
  26959. addons.setChannel(channel), channel.emit(CHANNEL_CREATED), this.addons = addons, this.channel = channel, scope.__STORYBOOK_ADDONS_CHANNEL__ = channel;
  26960. }
  26961. getElements(type) {
  26962. return this.addons.getElements(type);
  26963. }
  26964. getConfig() {
  26965. return this.addons.getConfig();
  26966. }
  26967. handleAPI(api) {
  26968. this.addons.loadAddons(api), this.channel.on(CHANNEL_WS_DISCONNECT, (ev) => {
  26969. this.wsDisconnected = !0, api.addNotification({
  26970. id: WS_DISCONNECTED_NOTIFICATION_ID,
  26971. content: {
  26972. headline: ev.code === 3008 ? "Server timed out" : "Connection lost",
  26973. subHeadline: "Please restart your Storybook server and reload the page"
  26974. },
  26975. icon: react_default.createElement(FailedIcon, { color: color.negative }),
  26976. link: void 0
  26977. });
  26978. });
  26979. }
  26980. }, { document: document10 } = scope, rootEl = document10.getElementById("root");
  26981. setTimeout(() => {
  26982. renderStorybookUI(rootEl, new ReactProvider());
  26983. }, 0);