You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27452 lines
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, err) => function() {
  13. if (err) throw err[0];
  14. try {
  15. return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
  16. } catch (e2) {
  17. throw err = [e2], e2;
  18. }
  19. };
  20. var __commonJS = (cb, mod) => function() {
  21. try {
  22. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  23. } catch (e2) {
  24. throw mod = 0, e2;
  25. }
  26. };
  27. var __export = (target, all) => {
  28. for (var name in all)
  29. __defProp(target, name, { get: all[name], enumerable: !0 });
  30. }, __copyProps = (to, from, except, desc) => {
  31. if (from && typeof from == "object" || typeof from == "function")
  32. for (let key of __getOwnPropNames(from))
  33. !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  34. return to;
  35. };
  36. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  37. // If the importer is in node compatibility mode or this is not an ESM
  38. // file that has been converted to a CommonJS file using a Babel-
  39. // compatible transform (i.e. "__esModule" has not been set), then set
  40. // "default" to the CommonJS "module.exports" for node compatibility.
  41. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
  42. mod
  43. )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
  44. // global-externals:react
  45. var react_exports = {};
  46. __export(react_exports, {
  47. Children: () => Children,
  48. Component: () => Component,
  49. Fragment: () => Fragment,
  50. Profiler: () => Profiler,
  51. PureComponent: () => PureComponent,
  52. StrictMode: () => StrictMode,
  53. Suspense: () => Suspense,
  54. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: () => __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
  55. act: () => act,
  56. cloneElement: () => cloneElement,
  57. createContext: () => createContext,
  58. createElement: () => createElement,
  59. createFactory: () => createFactory,
  60. createRef: () => createRef,
  61. default: () => react_default,
  62. forwardRef: () => forwardRef,
  63. isValidElement: () => isValidElement,
  64. lazy: () => lazy,
  65. memo: () => memo,
  66. startTransition: () => startTransition,
  67. unstable_act: () => unstable_act,
  68. useCallback: () => useCallback,
  69. useContext: () => useContext,
  70. useDebugValue: () => useDebugValue,
  71. useDeferredValue: () => useDeferredValue,
  72. useEffect: () => useEffect,
  73. useId: () => useId,
  74. useImperativeHandle: () => useImperativeHandle,
  75. useInsertionEffect: () => useInsertionEffect,
  76. useLayoutEffect: () => useLayoutEffect,
  77. useMemo: () => useMemo,
  78. useReducer: () => useReducer,
  79. useRef: () => useRef,
  80. useState: () => useState,
  81. useSyncExternalStore: () => useSyncExternalStore,
  82. useTransition: () => useTransition,
  83. version: () => version
  84. });
  85. 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({
  86. "global-externals:react"() {
  87. 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__;
  88. }
  89. });
  90. // ../../node_modules/prop-types/lib/ReactPropTypesSecret.js
  91. var require_ReactPropTypesSecret = __commonJS({
  92. "../../node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
  93. "use strict";
  94. var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
  95. module.exports = ReactPropTypesSecret;
  96. }
  97. });
  98. // ../../node_modules/prop-types/factoryWithThrowingShims.js
  99. var require_factoryWithThrowingShims = __commonJS({
  100. "../../node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
  101. "use strict";
  102. var ReactPropTypesSecret = require_ReactPropTypesSecret();
  103. function emptyFunction() {
  104. }
  105. function emptyFunctionWithReset() {
  106. }
  107. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  108. module.exports = function() {
  109. function shim(props, propName, componentName, location2, propFullName, secret) {
  110. if (secret !== ReactPropTypesSecret) {
  111. var err = new Error(
  112. "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"
  113. );
  114. throw err.name = "Invariant Violation", err;
  115. }
  116. }
  117. shim.isRequired = shim;
  118. function getShim() {
  119. return shim;
  120. }
  121. var ReactPropTypes = {
  122. array: shim,
  123. bigint: shim,
  124. bool: shim,
  125. func: shim,
  126. number: shim,
  127. object: shim,
  128. string: shim,
  129. symbol: shim,
  130. any: shim,
  131. arrayOf: getShim,
  132. element: shim,
  133. elementType: shim,
  134. instanceOf: getShim,
  135. node: shim,
  136. objectOf: getShim,
  137. oneOf: getShim,
  138. oneOfType: getShim,
  139. shape: getShim,
  140. exact: getShim,
  141. checkPropTypes: emptyFunctionWithReset,
  142. resetWarningCache: emptyFunction
  143. };
  144. return ReactPropTypes.PropTypes = ReactPropTypes, ReactPropTypes;
  145. };
  146. }
  147. });
  148. // ../../node_modules/prop-types/index.js
  149. var require_prop_types = __commonJS({
  150. "../../node_modules/prop-types/index.js"(exports, module) {
  151. module.exports = require_factoryWithThrowingShims()();
  152. var ReactIs, throwOnDirectAccess;
  153. }
  154. });
  155. // ../../node_modules/react-fast-compare/index.js
  156. var require_react_fast_compare = __commonJS({
  157. "../../node_modules/react-fast-compare/index.js"(exports, module) {
  158. var hasElementType = typeof Element < "u", hasMap = typeof Map == "function", hasSet = typeof Set == "function", hasArrayBuffer = typeof ArrayBuffer == "function" && !!ArrayBuffer.isView;
  159. function equal3(a2, b2) {
  160. if (a2 === b2) return !0;
  161. if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
  162. if (a2.constructor !== b2.constructor) return !1;
  163. var length, i2, keys;
  164. if (Array.isArray(a2)) {
  165. if (length = a2.length, length != b2.length) return !1;
  166. for (i2 = length; i2-- !== 0; )
  167. if (!equal3(a2[i2], b2[i2])) return !1;
  168. return !0;
  169. }
  170. var it;
  171. if (hasMap && a2 instanceof Map && b2 instanceof Map) {
  172. if (a2.size !== b2.size) return !1;
  173. for (it = a2.entries(); !(i2 = it.next()).done; )
  174. if (!b2.has(i2.value[0])) return !1;
  175. for (it = a2.entries(); !(i2 = it.next()).done; )
  176. if (!equal3(i2.value[1], b2.get(i2.value[0]))) return !1;
  177. return !0;
  178. }
  179. if (hasSet && a2 instanceof Set && b2 instanceof Set) {
  180. if (a2.size !== b2.size) return !1;
  181. for (it = a2.entries(); !(i2 = it.next()).done; )
  182. if (!b2.has(i2.value[0])) return !1;
  183. return !0;
  184. }
  185. if (hasArrayBuffer && ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
  186. if (length = a2.length, length != b2.length) return !1;
  187. for (i2 = length; i2-- !== 0; )
  188. if (a2[i2] !== b2[i2]) return !1;
  189. return !0;
  190. }
  191. if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
  192. if (a2.valueOf !== Object.prototype.valueOf && typeof a2.valueOf == "function" && typeof b2.valueOf == "function") return a2.valueOf() === b2.valueOf();
  193. if (a2.toString !== Object.prototype.toString && typeof a2.toString == "function" && typeof b2.toString == "function") return a2.toString() === b2.toString();
  194. if (keys = Object.keys(a2), length = keys.length, length !== Object.keys(b2).length) return !1;
  195. for (i2 = length; i2-- !== 0; )
  196. if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return !1;
  197. if (hasElementType && a2 instanceof Element) return !1;
  198. for (i2 = length; i2-- !== 0; )
  199. if (!((keys[i2] === "_owner" || keys[i2] === "__v" || keys[i2] === "__o") && a2.$$typeof) && !equal3(a2[keys[i2]], b2[keys[i2]]))
  200. return !1;
  201. return !0;
  202. }
  203. return a2 !== a2 && b2 !== b2;
  204. }
  205. module.exports = function(a2, b2) {
  206. try {
  207. return equal3(a2, b2);
  208. } catch (error) {
  209. if ((error.message || "").match(/stack|recursion/i))
  210. return console.warn("react-fast-compare cannot handle circular refs"), !1;
  211. throw error;
  212. }
  213. };
  214. }
  215. });
  216. // ../../node_modules/invariant/browser.js
  217. var require_browser = __commonJS({
  218. "../../node_modules/invariant/browser.js"(exports, module) {
  219. "use strict";
  220. var invariant = function(condition, format, a2, b2, c2, d2, e2, f2) {
  221. if (!condition) {
  222. var error;
  223. if (format === void 0)
  224. error = new Error(
  225. "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."
  226. );
  227. else {
  228. var args = [a2, b2, c2, d2, e2, f2], argIndex = 0;
  229. error = new Error(
  230. format.replace(/%s/g, function() {
  231. return args[argIndex++];
  232. })
  233. ), error.name = "Invariant Violation";
  234. }
  235. throw error.framesToPop = 1, error;
  236. }
  237. };
  238. module.exports = invariant;
  239. }
  240. });
  241. // ../../node_modules/shallowequal/index.js
  242. var require_shallowequal = __commonJS({
  243. "../../node_modules/shallowequal/index.js"(exports, module) {
  244. module.exports = function(objA, objB, compare, compareContext) {
  245. var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
  246. if (ret !== void 0)
  247. return !!ret;
  248. if (objA === objB)
  249. return !0;
  250. if (typeof objA != "object" || !objA || typeof objB != "object" || !objB)
  251. return !1;
  252. var keysA = Object.keys(objA), keysB = Object.keys(objB);
  253. if (keysA.length !== keysB.length)
  254. return !1;
  255. for (var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB), idx = 0; idx < keysA.length; idx++) {
  256. var key = keysA[idx];
  257. if (!bHasOwnProperty(key))
  258. return !1;
  259. var valueA = objA[key], valueB = objB[key];
  260. if (ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0, ret === !1 || ret === void 0 && valueA !== valueB)
  261. return !1;
  262. }
  263. return !0;
  264. };
  265. }
  266. });
  267. // ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
  268. var require_use_sync_external_store_shim_production = __commonJS({
  269. "../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js"(exports) {
  270. "use strict";
  271. var React = (init_react(), __toCommonJS(react_exports));
  272. function is4(x2, y2) {
  273. return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
  274. }
  275. var objectIs = typeof Object.is == "function" ? Object.is : is4, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect2 = React.useLayoutEffect, useDebugValue2 = React.useDebugValue;
  276. function useSyncExternalStore$2(subscribe, getSnapshot) {
  277. var value = getSnapshot(), _useState = useState2({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
  278. return useLayoutEffect2(
  279. function() {
  280. inst.value = value, inst.getSnapshot = getSnapshot, checkIfSnapshotChanged(inst) && forceUpdate({ inst });
  281. },
  282. [subscribe, value, getSnapshot]
  283. ), useEffect2(
  284. function() {
  285. return checkIfSnapshotChanged(inst) && forceUpdate({ inst }), subscribe(function() {
  286. checkIfSnapshotChanged(inst) && forceUpdate({ inst });
  287. });
  288. },
  289. [subscribe]
  290. ), useDebugValue2(value), value;
  291. }
  292. function checkIfSnapshotChanged(inst) {
  293. var latestGetSnapshot = inst.getSnapshot;
  294. inst = inst.value;
  295. try {
  296. var nextValue = latestGetSnapshot();
  297. return !objectIs(inst, nextValue);
  298. } catch {
  299. return !0;
  300. }
  301. }
  302. function useSyncExternalStore$1(subscribe, getSnapshot) {
  303. return getSnapshot();
  304. }
  305. var shim = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? useSyncExternalStore$1 : useSyncExternalStore$2;
  306. exports.useSyncExternalStore = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim;
  307. }
  308. });
  309. // ../../node_modules/use-sync-external-store/shim/index.js
  310. var require_shim = __commonJS({
  311. "../../node_modules/use-sync-external-store/shim/index.js"(exports, module) {
  312. "use strict";
  313. module.exports = require_use_sync_external_store_shim_production();
  314. }
  315. });
  316. // ../../node_modules/memoizerific/memoizerific.js
  317. var require_memoizerific = __commonJS({
  318. "../../node_modules/memoizerific/memoizerific.js"(exports, module) {
  319. (function(f2) {
  320. if (typeof exports == "object" && typeof module < "u")
  321. module.exports = f2();
  322. else if (typeof define == "function" && define.amd)
  323. define([], f2);
  324. else {
  325. var g2;
  326. typeof window < "u" ? g2 = window : typeof global < "u" ? g2 = global : typeof self < "u" ? g2 = self : g2 = this, g2.memoizerific = f2();
  327. }
  328. })(function() {
  329. var define2, module2, exports2;
  330. return (function e2(t2, n3, r4) {
  331. function s2(o4, u2) {
  332. if (!n3[o4]) {
  333. if (!t2[o4]) {
  334. var a2 = typeof __require == "function" && __require;
  335. if (!u2 && a2) return a2(o4, !0);
  336. if (i2) return i2(o4, !0);
  337. var f2 = new Error("Cannot find module '" + o4 + "'");
  338. throw f2.code = "MODULE_NOT_FOUND", f2;
  339. }
  340. var l3 = n3[o4] = { exports: {} };
  341. t2[o4][0].call(l3.exports, function(e3) {
  342. var n4 = t2[o4][1][e3];
  343. return s2(n4 || e3);
  344. }, l3, l3.exports, e2, t2, n3, r4);
  345. }
  346. return n3[o4].exports;
  347. }
  348. for (var i2 = typeof __require == "function" && __require, o3 = 0; o3 < r4.length; o3++) s2(r4[o3]);
  349. return s2;
  350. })({ 1: [function(_dereq_, module3, exports3) {
  351. module3.exports = function(forceSimilar) {
  352. if (typeof Map != "function" || forceSimilar) {
  353. var Similar = _dereq_("./similar");
  354. return new Similar();
  355. } else
  356. return /* @__PURE__ */ new Map();
  357. };
  358. }, { "./similar": 2 }], 2: [function(_dereq_, module3, exports3) {
  359. function Similar() {
  360. return this.list = [], this.lastItem = void 0, this.size = 0, this;
  361. }
  362. Similar.prototype.get = function(key) {
  363. var index;
  364. if (this.lastItem && this.isEqual(this.lastItem.key, key))
  365. return this.lastItem.val;
  366. if (index = this.indexOf(key), index >= 0)
  367. return this.lastItem = this.list[index], this.list[index].val;
  368. }, Similar.prototype.set = function(key, val) {
  369. var index;
  370. 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));
  371. }, Similar.prototype.delete = function(key) {
  372. var index;
  373. if (this.lastItem && this.isEqual(this.lastItem.key, key) && (this.lastItem = void 0), index = this.indexOf(key), index >= 0)
  374. return this.size--, this.list.splice(index, 1)[0];
  375. }, Similar.prototype.has = function(key) {
  376. var index;
  377. return this.lastItem && this.isEqual(this.lastItem.key, key) ? !0 : (index = this.indexOf(key), index >= 0 ? (this.lastItem = this.list[index], !0) : !1);
  378. }, Similar.prototype.forEach = function(callback, thisArg) {
  379. var i2;
  380. for (i2 = 0; i2 < this.size; i2++)
  381. callback.call(thisArg || this, this.list[i2].val, this.list[i2].key, this);
  382. }, Similar.prototype.indexOf = function(key) {
  383. var i2;
  384. for (i2 = 0; i2 < this.size; i2++)
  385. if (this.isEqual(this.list[i2].key, key))
  386. return i2;
  387. return -1;
  388. }, Similar.prototype.isEqual = function(val1, val2) {
  389. return val1 === val2 || val1 !== val1 && val2 !== val2;
  390. }, module3.exports = Similar;
  391. }, {}], 3: [function(_dereq_, module3, exports3) {
  392. var MapOrSimilar = _dereq_("map-or-similar");
  393. module3.exports = function(limit) {
  394. var cache = new MapOrSimilar(!1), lru = [];
  395. return function(fn) {
  396. var memoizerific3 = function() {
  397. var currentCache = cache, newMap, fnResult, argsLengthMinusOne = arguments.length - 1, lruPath = Array(argsLengthMinusOne + 1), isMemoized = !0, i2;
  398. if ((memoizerific3.numArgs || memoizerific3.numArgs === 0) && memoizerific3.numArgs !== argsLengthMinusOne + 1)
  399. throw new Error("Memoizerific functions should always be called with the same number of arguments");
  400. for (i2 = 0; i2 < argsLengthMinusOne; i2++) {
  401. if (lruPath[i2] = {
  402. cacheItem: currentCache,
  403. arg: arguments[i2]
  404. }, currentCache.has(arguments[i2])) {
  405. currentCache = currentCache.get(arguments[i2]);
  406. continue;
  407. }
  408. isMemoized = !1, newMap = new MapOrSimilar(!1), currentCache.set(arguments[i2], newMap), currentCache = newMap;
  409. }
  410. 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] = {
  411. cacheItem: currentCache,
  412. arg: arguments[argsLengthMinusOne]
  413. }, isMemoized ? moveToMostRecentLru(lru, lruPath) : lru.push(lruPath), lru.length > limit && removeCachedResult(lru.shift())), memoizerific3.wasMemoized = isMemoized, memoizerific3.numArgs = argsLengthMinusOne + 1, fnResult;
  414. };
  415. return memoizerific3.limit = limit, memoizerific3.wasMemoized = !1, memoizerific3.cache = cache, memoizerific3.lru = lru, memoizerific3;
  416. };
  417. };
  418. function moveToMostRecentLru(lru, lruPath) {
  419. var lruLen = lru.length, lruPathLen = lruPath.length, isMatch, i2, ii;
  420. for (i2 = 0; i2 < lruLen; i2++) {
  421. for (isMatch = !0, ii = 0; ii < lruPathLen; ii++)
  422. if (!isEqual2(lru[i2][ii].arg, lruPath[ii].arg)) {
  423. isMatch = !1;
  424. break;
  425. }
  426. if (isMatch)
  427. break;
  428. }
  429. lru.push(lru.splice(i2, 1)[0]);
  430. }
  431. function removeCachedResult(removedLru) {
  432. var removedLruLen = removedLru.length, currentLru = removedLru[removedLruLen - 1], tmp, i2;
  433. for (currentLru.cacheItem.delete(currentLru.arg), i2 = removedLruLen - 2; i2 >= 0 && (currentLru = removedLru[i2], tmp = currentLru.cacheItem.get(currentLru.arg), !tmp || !tmp.size); i2--)
  434. currentLru.cacheItem.delete(currentLru.arg);
  435. }
  436. function isEqual2(val1, val2) {
  437. return val1 === val2 || val1 !== val1 && val2 !== val2;
  438. }
  439. }, { "map-or-similar": 1 }] }, {}, [3])(3);
  440. });
  441. }
  442. });
  443. // ../../node_modules/picocolors/picocolors.browser.js
  444. var require_picocolors_browser = __commonJS({
  445. "../../node_modules/picocolors/picocolors.browser.js"(exports, module) {
  446. var x2 = String, create4 = function() {
  447. 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 };
  448. };
  449. module.exports = create4();
  450. module.exports.createColors = create4;
  451. }
  452. });
  453. // ../../node_modules/scroll/index.js
  454. var require_scroll = __commonJS({
  455. "../../node_modules/scroll/index.js"(exports, module) {
  456. var E_NOSCROLL = new Error("Element already at target scroll position"), E_CANCELLED = new Error("Scroll cancelled"), min = Math.min, ms = Date.now;
  457. module.exports = {
  458. left: make("scrollLeft"),
  459. top: make("scrollTop")
  460. };
  461. function make(prop) {
  462. return function(el, to, opts, cb) {
  463. opts = opts || {}, typeof opts == "function" && (cb = opts, opts = {}), typeof cb != "function" && (cb = noop5);
  464. var start = ms(), from = el[prop], ease = opts.ease || inOutSine, duration = isNaN(opts.duration) ? 350 : +opts.duration, cancelled = !1;
  465. return from === to ? cb(E_NOSCROLL, el[prop]) : requestAnimationFrame(animate), cancel;
  466. function cancel() {
  467. cancelled = !0;
  468. }
  469. function animate(timestamp) {
  470. if (cancelled) return cb(E_CANCELLED, el[prop]);
  471. var now = ms(), time = min(1, (now - start) / duration), eased = ease(time);
  472. el[prop] = eased * (to - from) + from, time < 1 ? requestAnimationFrame(animate) : requestAnimationFrame(function() {
  473. cb(null, el[prop]);
  474. });
  475. }
  476. };
  477. }
  478. function inOutSine(n3) {
  479. return 0.5 * (1 - Math.cos(Math.PI * n3));
  480. }
  481. function noop5() {
  482. }
  483. }
  484. });
  485. // ../../node_modules/scrollparent/scrollparent.js
  486. var require_scrollparent = __commonJS({
  487. "../../node_modules/scrollparent/scrollparent.js"(exports, module) {
  488. (function(root2, factory) {
  489. typeof define == "function" && define.amd ? define([], factory) : typeof module == "object" && module.exports ? module.exports = factory() : root2.Scrollparent = factory();
  490. })(exports, function() {
  491. function isScrolling(node) {
  492. var overflow = getComputedStyle(node, null).getPropertyValue("overflow");
  493. return overflow.indexOf("scroll") > -1 || overflow.indexOf("auto") > -1;
  494. }
  495. function scrollParent2(node) {
  496. if (node instanceof HTMLElement || node instanceof SVGElement) {
  497. for (var current = node.parentNode; current.parentNode; ) {
  498. if (isScrolling(current))
  499. return current;
  500. current = current.parentNode;
  501. }
  502. return document.scrollingElement || document.documentElement;
  503. }
  504. }
  505. return scrollParent2;
  506. });
  507. }
  508. });
  509. // ../../node_modules/react-innertext/index.js
  510. var require_react_innertext = __commonJS({
  511. "../../node_modules/react-innertext/index.js"(exports, module) {
  512. "use strict";
  513. var hasProps = function(jsx2) {
  514. return Object.prototype.hasOwnProperty.call(jsx2, "props");
  515. }, reduceJsxToString = function(previous, current) {
  516. return previous + innerText2(current);
  517. }, innerText2 = function(jsx2) {
  518. 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) : "";
  519. };
  520. innerText2.default = innerText2;
  521. module.exports = innerText2;
  522. }
  523. });
  524. // ../../node_modules/deepmerge/dist/cjs.js
  525. var require_cjs = __commonJS({
  526. "../../node_modules/deepmerge/dist/cjs.js"(exports, module) {
  527. "use strict";
  528. var isMergeableObject = function(value) {
  529. return isNonNullObject(value) && !isSpecial(value);
  530. };
  531. function isNonNullObject(value) {
  532. return !!value && typeof value == "object";
  533. }
  534. function isSpecial(value) {
  535. var stringValue = Object.prototype.toString.call(value);
  536. return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
  537. }
  538. var canUseSymbol = typeof Symbol == "function" && Symbol.for, REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
  539. function isReactElement(value) {
  540. return value.$$typeof === REACT_ELEMENT_TYPE;
  541. }
  542. function emptyTarget(val) {
  543. return Array.isArray(val) ? [] : {};
  544. }
  545. function cloneUnlessOtherwiseSpecified(value, options2) {
  546. return options2.clone !== !1 && options2.isMergeableObject(value) ? deepmerge4(emptyTarget(value), value, options2) : value;
  547. }
  548. function defaultArrayMerge(target, source, options2) {
  549. return target.concat(source).map(function(element) {
  550. return cloneUnlessOtherwiseSpecified(element, options2);
  551. });
  552. }
  553. function getMergeFunction(key, options2) {
  554. if (!options2.customMerge)
  555. return deepmerge4;
  556. var customMerge = options2.customMerge(key);
  557. return typeof customMerge == "function" ? customMerge : deepmerge4;
  558. }
  559. function getEnumerableOwnPropertySymbols(target) {
  560. return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
  561. return Object.propertyIsEnumerable.call(target, symbol);
  562. }) : [];
  563. }
  564. function getKeys(target) {
  565. return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
  566. }
  567. function propertyIsOnObject(object, property) {
  568. try {
  569. return property in object;
  570. } catch {
  571. return !1;
  572. }
  573. }
  574. function propertyIsUnsafe(target, key) {
  575. return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
  576. }
  577. function mergeObject(target, source, options2) {
  578. var destination = {};
  579. return options2.isMergeableObject(target) && getKeys(target).forEach(function(key) {
  580. destination[key] = cloneUnlessOtherwiseSpecified(target[key], options2);
  581. }), getKeys(source).forEach(function(key) {
  582. 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));
  583. }), destination;
  584. }
  585. function deepmerge4(target, source, options2) {
  586. options2 = options2 || {}, options2.arrayMerge = options2.arrayMerge || defaultArrayMerge, options2.isMergeableObject = options2.isMergeableObject || isMergeableObject, options2.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
  587. var sourceIsArray = Array.isArray(source), targetIsArray = Array.isArray(target), sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
  588. return sourceAndTargetTypesMatch ? sourceIsArray ? options2.arrayMerge(target, source, options2) : mergeObject(target, source, options2) : cloneUnlessOtherwiseSpecified(source, options2);
  589. }
  590. deepmerge4.all = function(array, options2) {
  591. if (!Array.isArray(array))
  592. throw new Error("first argument should be an array");
  593. return array.reduce(function(prev, next) {
  594. return deepmerge4(prev, next, options2);
  595. }, {});
  596. };
  597. var deepmerge_1 = deepmerge4;
  598. module.exports = deepmerge_1;
  599. }
  600. });
  601. // ../../node_modules/downshift/node_modules/react-is/cjs/react-is.production.min.js
  602. var require_react_is_production_min = __commonJS({
  603. "../../node_modules/downshift/node_modules/react-is/cjs/react-is.production.min.js"(exports) {
  604. "use strict";
  605. var b2 = /* @__PURE__ */ Symbol.for("react.element"), c2 = /* @__PURE__ */ Symbol.for("react.portal"), d2 = /* @__PURE__ */ Symbol.for("react.fragment"), e2 = /* @__PURE__ */ Symbol.for("react.strict_mode"), f2 = /* @__PURE__ */ Symbol.for("react.profiler"), g2 = /* @__PURE__ */ Symbol.for("react.provider"), h2 = /* @__PURE__ */ Symbol.for("react.context"), k2 = /* @__PURE__ */ Symbol.for("react.server_context"), l3 = /* @__PURE__ */ Symbol.for("react.forward_ref"), m2 = /* @__PURE__ */ Symbol.for("react.suspense"), n3 = /* @__PURE__ */ Symbol.for("react.suspense_list"), p2 = /* @__PURE__ */ Symbol.for("react.memo"), q2 = /* @__PURE__ */ Symbol.for("react.lazy"), t2 = /* @__PURE__ */ Symbol.for("react.offscreen"), u2;
  606. u2 = /* @__PURE__ */ Symbol.for("react.module.reference");
  607. function v2(a2) {
  608. if (typeof a2 == "object" && a2 !== null) {
  609. var r4 = a2.$$typeof;
  610. switch (r4) {
  611. case b2:
  612. switch (a2 = a2.type, a2) {
  613. case d2:
  614. case f2:
  615. case e2:
  616. case m2:
  617. case n3:
  618. return a2;
  619. default:
  620. switch (a2 = a2 && a2.$$typeof, a2) {
  621. case k2:
  622. case h2:
  623. case l3:
  624. case q2:
  625. case p2:
  626. case g2:
  627. return a2;
  628. default:
  629. return r4;
  630. }
  631. }
  632. case c2:
  633. return r4;
  634. }
  635. }
  636. }
  637. exports.ContextConsumer = h2;
  638. exports.ContextProvider = g2;
  639. exports.Element = b2;
  640. exports.ForwardRef = l3;
  641. exports.Fragment = d2;
  642. exports.Lazy = q2;
  643. exports.Memo = p2;
  644. exports.Portal = c2;
  645. exports.Profiler = f2;
  646. exports.StrictMode = e2;
  647. exports.Suspense = m2;
  648. exports.SuspenseList = n3;
  649. exports.isAsyncMode = function() {
  650. return !1;
  651. };
  652. exports.isConcurrentMode = function() {
  653. return !1;
  654. };
  655. exports.isContextConsumer = function(a2) {
  656. return v2(a2) === h2;
  657. };
  658. exports.isContextProvider = function(a2) {
  659. return v2(a2) === g2;
  660. };
  661. exports.isElement = function(a2) {
  662. return typeof a2 == "object" && a2 !== null && a2.$$typeof === b2;
  663. };
  664. exports.isForwardRef = function(a2) {
  665. return v2(a2) === l3;
  666. };
  667. exports.isFragment = function(a2) {
  668. return v2(a2) === d2;
  669. };
  670. exports.isLazy = function(a2) {
  671. return v2(a2) === q2;
  672. };
  673. exports.isMemo = function(a2) {
  674. return v2(a2) === p2;
  675. };
  676. exports.isPortal = function(a2) {
  677. return v2(a2) === c2;
  678. };
  679. exports.isProfiler = function(a2) {
  680. return v2(a2) === f2;
  681. };
  682. exports.isStrictMode = function(a2) {
  683. return v2(a2) === e2;
  684. };
  685. exports.isSuspense = function(a2) {
  686. return v2(a2) === m2;
  687. };
  688. exports.isSuspenseList = function(a2) {
  689. return v2(a2) === n3;
  690. };
  691. exports.isValidElementType = function(a2) {
  692. 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);
  693. };
  694. exports.typeOf = v2;
  695. }
  696. });
  697. // ../../node_modules/downshift/node_modules/react-is/index.js
  698. var require_react_is = __commonJS({
  699. "../../node_modules/downshift/node_modules/react-is/index.js"(exports, module) {
  700. "use strict";
  701. module.exports = require_react_is_production_min();
  702. }
  703. });
  704. // ../../node_modules/fuse.js/dist/fuse.js
  705. var require_fuse = __commonJS({
  706. "../../node_modules/fuse.js/dist/fuse.js"(exports, module) {
  707. (function(e2, t2) {
  708. 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();
  709. })(exports, function() {
  710. return (function(e2) {
  711. var t2 = {};
  712. function r4(n3) {
  713. if (t2[n3]) return t2[n3].exports;
  714. var o3 = t2[n3] = { i: n3, l: !1, exports: {} };
  715. return e2[n3].call(o3.exports, o3, o3.exports, r4), o3.l = !0, o3.exports;
  716. }
  717. return r4.m = e2, r4.c = t2, r4.d = function(e3, t3, n3) {
  718. r4.o(e3, t3) || Object.defineProperty(e3, t3, { enumerable: !0, get: n3 });
  719. }, r4.r = function(e3) {
  720. typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e3, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e3, "__esModule", { value: !0 });
  721. }, r4.t = function(e3, t3) {
  722. if (1 & t3 && (e3 = r4(e3)), 8 & t3 || 4 & t3 && typeof e3 == "object" && e3 && e3.__esModule) return e3;
  723. var n3 = /* @__PURE__ */ Object.create(null);
  724. 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) {
  725. return e3[t4];
  726. }.bind(null, o3));
  727. return n3;
  728. }, r4.n = function(e3) {
  729. var t3 = e3 && e3.__esModule ? function() {
  730. return e3.default;
  731. } : function() {
  732. return e3;
  733. };
  734. return r4.d(t3, "a", t3), t3;
  735. }, r4.o = function(e3, t3) {
  736. return Object.prototype.hasOwnProperty.call(e3, t3);
  737. }, r4.p = "", r4(r4.s = 0);
  738. })([function(e2, t2, r4) {
  739. function n3(e3) {
  740. return (n3 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e4) {
  741. return typeof e4;
  742. } : function(e4) {
  743. return e4 && typeof Symbol == "function" && e4.constructor === Symbol && e4 !== Symbol.prototype ? "symbol" : typeof e4;
  744. })(e3);
  745. }
  746. function o3(e3, t3) {
  747. for (var r5 = 0; r5 < t3.length; r5++) {
  748. var n4 = t3[r5];
  749. n4.enumerable = n4.enumerable || !1, n4.configurable = !0, "value" in n4 && (n4.writable = !0), Object.defineProperty(e3, n4.key, n4);
  750. }
  751. }
  752. var i2 = r4(1), a2 = r4(7), s2 = a2.get, c2 = (a2.deepValue, a2.isArray), h2 = (function() {
  753. function e3(t4, r6) {
  754. 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) {
  755. return e4.score - t5.score;
  756. } : 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;
  757. (function(e4, t5) {
  758. if (!(e4 instanceof t5)) throw new TypeError("Cannot call a class as a function");
  759. })(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);
  760. }
  761. var t3, r5, a3;
  762. return t3 = e3, (r5 = [{ key: "setCollection", value: function(e4) {
  763. return this.list = e4, e4;
  764. } }, { key: "_processKeys", value: function(e4) {
  765. if (this._keyWeights = {}, this._keyNames = [], e4.length && typeof e4[0] == "string") for (var t4 = 0, r6 = e4.length; t4 < r6; t4 += 1) {
  766. var n4 = e4[t4];
  767. this._keyWeights[n4] = 1, this._keyNames.push(n4);
  768. }
  769. else {
  770. for (var o4 = null, i3 = null, a4 = 0, s3 = 0, c3 = e4.length; s3 < c3; s3 += 1) {
  771. var h3 = e4[s3];
  772. if (!h3.hasOwnProperty("name")) throw new Error('Missing "name" property in key object');
  773. var l3 = h3.name;
  774. if (this._keyNames.push(l3), !h3.hasOwnProperty("weight")) throw new Error('Missing "weight" property in key object');
  775. var u2 = h3.weight;
  776. if (u2 < 0 || u2 > 1) throw new Error('"weight" property in key must bein the range of [0, 1)');
  777. i3 = i3 == null ? u2 : Math.max(i3, u2), o4 = o4 == null ? u2 : Math.min(o4, u2), this._keyWeights[l3] = u2, a4 += u2;
  778. }
  779. if (a4 > 1) throw new Error("Total of weights cannot exceed 1");
  780. }
  781. } }, { key: "search", value: function(e4) {
  782. var t4 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { limit: !1 };
  783. this._log(`---------
  784. Search pattern: "`.concat(e4, '"'));
  785. var r6 = this._prepareSearchers(e4), n4 = r6.tokenSearchers, o4 = r6.fullSearcher, i3 = this._search(n4, o4);
  786. 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);
  787. } }, { key: "_prepareSearchers", value: function() {
  788. var e4 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", t4 = [];
  789. 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));
  790. return { tokenSearchers: t4, fullSearcher: new i2(e4, this.options) };
  791. } }, { key: "_search", value: function() {
  792. var e4 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t4 = arguments.length > 1 ? arguments[1] : void 0, r6 = this.list, n4 = {}, o4 = [];
  793. if (typeof r6[0] == "string") {
  794. 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 });
  795. return o4;
  796. }
  797. 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) {
  798. var f2 = this._keyNames[l3];
  799. this._analyze({ key: f2, value: this.options.getFn(h3, f2), record: h3, index: s3 }, { resultMap: n4, results: o4, tokenSearchers: e4, fullSearcher: t4 });
  800. }
  801. return o4;
  802. } }, { key: "_analyze", value: function(e4, t4) {
  803. 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;
  804. (function e5(t5, o5, i4, a5) {
  805. if (o5 != null) {
  806. if (typeof o5 == "string") {
  807. var s4 = !1, h4 = -1, l4 = 0;
  808. r6._log(`
  809. Key: `.concat(n4 === "" ? "--" : n4));
  810. var v3 = f2.search(o5);
  811. if (r6._log('Full text: "'.concat(o5, '", score: ').concat(v3.score)), r6.options.tokenize) {
  812. for (var d3 = o5.split(r6.options.tokenSeparator), y2 = d3.length, m2 = [], k2 = 0, b2 = u2.length; k2 < b2; k2 += 1) {
  813. var S2 = u2[k2];
  814. r6._log(`
  815. Pattern: "`.concat(S2.pattern, '"'));
  816. for (var x2 = !1, M2 = 0; M2 < y2; M2 += 1) {
  817. var _2 = d3[M2], w2 = S2.search(_2), L3 = {};
  818. 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]));
  819. }
  820. x2 && (l4 += 1);
  821. }
  822. h4 = m2[0];
  823. for (var A3 = m2.length, O2 = 1; O2 < A3; O2 += 1) h4 += m2[O2];
  824. h4 /= A3, r6._log("Token score average:", h4);
  825. }
  826. var C2 = v3.score;
  827. h4 > -1 && (C2 = (C2 + h4) / 2), r6._log("Score average:", C2);
  828. var j2 = !r6.options.tokenize || !r6.options.matchAllTokens || l4 >= u2.length;
  829. if (r6._log(`
  830. Check Matches: `.concat(j2)), (s4 || v3.isMatch) && j2) {
  831. var P3 = { key: n4, arrayIndex: t5, value: o5, score: C2 };
  832. r6.options.includeMatches && (P3.matchedIndices = v3.matchedIndices);
  833. var I2 = p2[a5];
  834. I2 ? I2.output.push(P3) : (p2[a5] = { item: i4, output: [P3] }, g2.push(p2[a5]));
  835. }
  836. } else if (c2(o5)) for (var F2 = 0, T3 = o5.length; F2 < T3; F2 += 1) e5(F2, o5[F2], i4, a5);
  837. }
  838. })(i3, a4, s3, h3);
  839. } }, { key: "_computeScore", value: function(e4) {
  840. this._log(`
  841. Computing score:
  842. `);
  843. for (var t4 = this._keyWeights, r6 = !!Object.keys(t4).length, n4 = 0, o4 = e4.length; n4 < o4; n4 += 1) {
  844. for (var i3 = e4[n4], a4 = i3.output, s3 = a4.length, c3 = 1, h3 = 0; h3 < s3; h3 += 1) {
  845. var l3 = a4[h3], u2 = l3.key, f2 = r6 ? t4[u2] : 1, v2 = l3.score === 0 && t4 && t4[u2] > 0 ? Number.EPSILON : l3.score;
  846. c3 *= Math.pow(v2, f2);
  847. }
  848. i3.score = c3, this._log(i3);
  849. }
  850. } }, { key: "_sort", value: function(e4) {
  851. this._log(`
  852. Sorting....`), e4.sort(this.options.sortFn);
  853. } }, { key: "_format", value: function(e4) {
  854. var t4 = [];
  855. if (this.options.verbose) {
  856. var r6 = [];
  857. this._log(`
  858. Output:
  859. `, JSON.stringify(e4, function(e5, t5) {
  860. if (n3(t5) === "object" && t5 !== null) {
  861. if (r6.indexOf(t5) !== -1) return;
  862. r6.push(t5);
  863. }
  864. return t5;
  865. }, 2)), r6 = null;
  866. }
  867. var o4 = [];
  868. this.options.includeMatches && o4.push(function(e5, t5) {
  869. var r7 = e5.output;
  870. t5.matches = [];
  871. for (var n4 = 0, o5 = r7.length; n4 < o5; n4 += 1) {
  872. var i4 = r7[n4];
  873. if (i4.matchedIndices.length !== 0) {
  874. var a5 = { indices: i4.matchedIndices, value: i4.value };
  875. i4.key && (a5.key = i4.key), i4.hasOwnProperty("arrayIndex") && i4.arrayIndex > -1 && (a5.arrayIndex = i4.arrayIndex), t5.matches.push(a5);
  876. }
  877. }
  878. }), this.options.includeScore && o4.push(function(e5, t5) {
  879. t5.score = e5.score;
  880. });
  881. for (var i3 = 0, a4 = e4.length; i3 < a4; i3 += 1) {
  882. var s3 = e4[i3];
  883. if (this.options.id && (s3.item = this.options.getFn(s3.item, this.options.id)[0]), o4.length) {
  884. for (var c3 = { item: s3.item }, h3 = 0, l3 = o4.length; h3 < l3; h3 += 1) o4[h3](s3, c3);
  885. t4.push(c3);
  886. } else t4.push(s3.item);
  887. }
  888. return t4;
  889. } }, { key: "_log", value: function() {
  890. var e4;
  891. this.options.verbose && (e4 = console).log.apply(e4, arguments);
  892. } }]) && o3(t3.prototype, r5), a3 && o3(t3, a3), e3;
  893. })();
  894. e2.exports = h2;
  895. }, function(e2, t2, r4) {
  896. function n3(e3, t3) {
  897. for (var r5 = 0; r5 < t3.length; r5++) {
  898. var n4 = t3[r5];
  899. n4.enumerable = n4.enumerable || !1, n4.configurable = !0, "value" in n4 && (n4.writable = !0), Object.defineProperty(e3, n4.key, n4);
  900. }
  901. }
  902. var o3 = r4(2), i2 = r4(3), a2 = r4(6), s2 = (function() {
  903. function e3(t4, r6) {
  904. 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;
  905. (function(e4, t5) {
  906. if (!(e4 instanceof t5)) throw new TypeError("Cannot call a class as a function");
  907. })(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));
  908. }
  909. var t3, r5, s3;
  910. return t3 = e3, (r5 = [{ key: "search", value: function(e4) {
  911. var t4 = this.options, r6 = t4.isCaseSensitive, n4 = t4.includeMatches;
  912. if (r6 || (e4 = e4.toLowerCase()), this.pattern === e4) {
  913. var a3 = { isMatch: !0, score: 0 };
  914. return n4 && (a3.matchedIndices = [[0, e4.length - 1]]), a3;
  915. }
  916. var s4 = this.options, c2 = s4.maxPatternLength, h2 = s4.tokenSeparator;
  917. if (this.pattern.length > c2) return o3(e4, this.pattern, h2);
  918. var l3 = this.options, u2 = l3.location, f2 = l3.distance, v2 = l3.threshold, p2 = l3.findAllMatches, d2 = l3.minMatchCharLength;
  919. return i2(e4, this.pattern, this.patternAlphabet, { location: u2, distance: f2, threshold: v2, findAllMatches: p2, minMatchCharLength: d2, includeMatches: n4 });
  920. } }]) && n3(t3.prototype, r5), s3 && n3(t3, s3), e3;
  921. })();
  922. e2.exports = s2;
  923. }, function(e2, t2) {
  924. var r4 = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;
  925. e2.exports = function(e3, t3) {
  926. 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 = [];
  927. if (a2) for (var c2 = 0, h2 = i2.length; c2 < h2; c2 += 1) {
  928. var l3 = i2[c2];
  929. s2.push([e3.indexOf(l3), l3.length - 1]);
  930. }
  931. return { score: a2 ? 0.5 : 1, isMatch: a2, matchedIndices: s2 };
  932. };
  933. }, function(e2, t2, r4) {
  934. var n3 = r4(4), o3 = r4(5);
  935. e2.exports = function(e3, t3, r5, i2) {
  936. 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;
  937. if (S2 !== -1) {
  938. var w2 = n3(t3, { errors: 0, currentLocation: S2, expectedLocation: m2, distance: h2 });
  939. if (b2 = Math.min(w2, b2), (S2 = e3.lastIndexOf(t3, m2 + x2)) !== -1) {
  940. var L3 = n3(t3, { errors: 0, currentLocation: S2, expectedLocation: m2, distance: h2 });
  941. b2 = Math.min(L3, b2);
  942. }
  943. }
  944. S2 = -1;
  945. for (var A3 = [], O2 = 1, C2 = x2 + k2, j2 = 1 << (x2 <= 31 ? x2 - 1 : 30), P3 = 0; P3 < x2; P3 += 1) {
  946. for (var I2 = 0, F2 = C2; I2 < F2; )
  947. n3(t3, { errors: P3, currentLocation: m2 + F2, expectedLocation: m2, distance: h2 }) <= b2 ? I2 = F2 : C2 = F2, F2 = Math.floor((C2 - I2) / 2 + I2);
  948. C2 = F2;
  949. var T3 = Math.max(1, m2 - F2 + 1), N2 = v2 ? k2 : Math.min(m2 + F2, k2) + x2, z2 = Array(N2 + 2);
  950. z2[N2 + 1] = (1 << P3) - 1;
  951. for (var E2 = N2; E2 >= T3; E2 -= 1) {
  952. var W2 = E2 - 1, K2 = r5[e3.charAt(W2)];
  953. 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) {
  954. if (b2 = O2, (S2 = W2) <= m2) break;
  955. T3 = Math.max(1, 2 * m2 - S2);
  956. }
  957. }
  958. if (n3(t3, { errors: P3 + 1, currentLocation: m2, expectedLocation: m2, distance: h2 }) > b2) break;
  959. A3 = z2;
  960. }
  961. var $ = { isMatch: S2 >= 0, score: O2 === 0 ? 1e-3 : O2 };
  962. return y2 && ($.matchedIndices = o3(M2, d2)), $;
  963. };
  964. }, function(e2, t2) {
  965. e2.exports = function(e3, t3) {
  966. 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);
  967. return h2 ? l3 + u2 / h2 : u2 ? 1 : l3;
  968. };
  969. }, function(e2, t2) {
  970. e2.exports = function() {
  971. 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) {
  972. var s2 = e3[i2];
  973. s2 && n3 === -1 ? n3 = i2 : s2 || n3 === -1 || ((o3 = i2 - 1) - n3 + 1 >= t3 && r4.push([n3, o3]), n3 = -1);
  974. }
  975. return e3[i2 - 1] && i2 - n3 >= t3 && r4.push([n3, i2 - 1]), r4;
  976. };
  977. }, function(e2, t2) {
  978. e2.exports = function(e3) {
  979. for (var t3 = {}, r4 = e3.length, n3 = 0; n3 < r4; n3 += 1) t3[e3.charAt(n3)] = 0;
  980. for (var o3 = 0; o3 < r4; o3 += 1) t3[e3.charAt(o3)] |= 1 << r4 - o3 - 1;
  981. return t3;
  982. };
  983. }, function(e2, t2) {
  984. var r4 = function(e3) {
  985. return Array.isArray ? Array.isArray(e3) : Object.prototype.toString.call(e3) === "[object Array]";
  986. }, n3 = function(e3) {
  987. return e3 == null ? "" : (function(e4) {
  988. if (typeof e4 == "string") return e4;
  989. var t3 = e4 + "";
  990. return t3 == "0" && 1 / e4 == -1 / 0 ? "-0" : t3;
  991. })(e3);
  992. }, o3 = function(e3) {
  993. return typeof e3 == "string";
  994. }, i2 = function(e3) {
  995. return typeof e3 == "number";
  996. };
  997. e2.exports = { get: function(e3, t3) {
  998. var a2 = [];
  999. return (function e4(t4, s2) {
  1000. if (s2) {
  1001. var c2 = s2.indexOf("."), h2 = s2, l3 = null;
  1002. c2 !== -1 && (h2 = s2.slice(0, c2), l3 = s2.slice(c2 + 1));
  1003. var u2 = t4[h2];
  1004. 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);
  1005. else l3 && e4(u2, l3);
  1006. else a2.push(n3(u2));
  1007. } else a2.push(t4);
  1008. })(e3, t3), a2;
  1009. }, isArray: r4, isString: o3, isNum: i2, toString: n3 };
  1010. }]);
  1011. });
  1012. }
  1013. });
  1014. // ../../node_modules/store2/dist/store2.js
  1015. var require_store2 = __commonJS({
  1016. "../../node_modules/store2/dist/store2.js"(exports, module) {
  1017. (function(window2, define2) {
  1018. var _2 = {
  1019. version: "2.14.4",
  1020. areas: {},
  1021. apis: {},
  1022. nsdelim: ".",
  1023. // utilities
  1024. inherit: function(api, o3) {
  1025. for (var p2 in api)
  1026. o3.hasOwnProperty(p2) || Object.defineProperty(o3, p2, Object.getOwnPropertyDescriptor(api, p2));
  1027. return o3;
  1028. },
  1029. stringify: function(d2, fn) {
  1030. return d2 === void 0 || typeof d2 == "function" ? d2 + "" : JSON.stringify(d2, fn || _2.replace);
  1031. },
  1032. parse: function(s2, fn) {
  1033. try {
  1034. return JSON.parse(s2, fn || _2.revive);
  1035. } catch {
  1036. return s2;
  1037. }
  1038. },
  1039. // extension hooks
  1040. fn: function(name, fn) {
  1041. _2.storeAPI[name] = fn;
  1042. for (var api in _2.apis)
  1043. _2.apis[api][name] = fn;
  1044. },
  1045. get: function(area, key) {
  1046. return area.getItem(key);
  1047. },
  1048. set: function(area, key, string) {
  1049. area.setItem(key, string);
  1050. },
  1051. remove: function(area, key) {
  1052. area.removeItem(key);
  1053. },
  1054. key: function(area, i2) {
  1055. return area.key(i2);
  1056. },
  1057. length: function(area) {
  1058. return area.length;
  1059. },
  1060. clear: function(area) {
  1061. area.clear();
  1062. },
  1063. // core functions
  1064. Store: function(id, area, namespace) {
  1065. var store3 = _2.inherit(_2.storeAPI, function(key, data, overwrite) {
  1066. 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();
  1067. });
  1068. store3._id = id;
  1069. try {
  1070. var testKey = "__store2_test";
  1071. area.setItem(testKey, "ok"), store3._area = area, area.removeItem(testKey);
  1072. } catch {
  1073. store3._area = _2.storage("fake");
  1074. }
  1075. 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;
  1076. },
  1077. storeAPI: {
  1078. // admin functions
  1079. area: function(id, area) {
  1080. var store3 = this[id];
  1081. return (!store3 || !store3.area) && (store3 = _2.Store(id, area, this._ns), this[id] || (this[id] = store3)), store3;
  1082. },
  1083. namespace: function(namespace, singleArea, delim) {
  1084. if (delim = delim || this._delim || _2.nsdelim, !namespace)
  1085. return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
  1086. var ns = namespace, store3 = this[ns];
  1087. if ((!store3 || !store3.namespace) && (store3 = _2.Store(this._id, this._area, this._ns + ns + delim), store3._delim = delim, this[ns] || (this[ns] = store3), !singleArea))
  1088. for (var name in _2.areas)
  1089. store3.area(name, _2.areas[name]);
  1090. return store3;
  1091. },
  1092. isFake: function(force) {
  1093. return force ? (this._real = this._area, this._area = _2.storage("fake")) : force === !1 && (this._area = this._real || this._area), this._area.name === "fake";
  1094. },
  1095. toString: function() {
  1096. return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
  1097. },
  1098. // storage functions
  1099. has: function(key) {
  1100. return this._area.has ? this._area.has(this._in(key)) : this._in(key) in this._area;
  1101. },
  1102. size: function() {
  1103. return this.keys().length;
  1104. },
  1105. each: function(fn, fill) {
  1106. for (var i2 = 0, m2 = _2.length(this._area); i2 < m2; i2++) {
  1107. var key = this._out(_2.key(this._area, i2));
  1108. if (key !== void 0 && fn.call(this, key, this.get(key), fill) === !1)
  1109. break;
  1110. m2 > _2.length(this._area) && (m2--, i2--);
  1111. }
  1112. return fill || this;
  1113. },
  1114. keys: function(fillList) {
  1115. return this.each(function(k2, v2, list) {
  1116. list.push(k2);
  1117. }, fillList || []);
  1118. },
  1119. get: function(key, alt) {
  1120. var s2 = _2.get(this._area, this._in(key)), fn;
  1121. return typeof alt == "function" && (fn = alt, alt = null), s2 !== null ? _2.parse(s2, fn) : alt ?? s2;
  1122. },
  1123. getAll: function(fillObj) {
  1124. return this.each(function(k2, v2, all) {
  1125. all[k2] = v2;
  1126. }, fillObj || {});
  1127. },
  1128. transact: function(key, fn, alt) {
  1129. var val = this.get(key, alt), ret = fn(val);
  1130. return this.set(key, ret === void 0 ? val : ret), this;
  1131. },
  1132. set: function(key, data, overwrite) {
  1133. var d2 = this.get(key), replacer;
  1134. 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);
  1135. },
  1136. setAll: function(data, overwrite) {
  1137. var changed, val;
  1138. for (var key in data)
  1139. val = data[key], this.set(key, val, overwrite) !== val && (changed = !0);
  1140. return changed;
  1141. },
  1142. add: function(key, data, replacer) {
  1143. var d2 = this.get(key);
  1144. if (d2 instanceof Array)
  1145. data = d2.concat(data);
  1146. else if (d2 !== null) {
  1147. var type = typeof d2;
  1148. if (type === typeof data && type === "object") {
  1149. for (var k2 in data)
  1150. d2[k2] = data[k2];
  1151. data = d2;
  1152. } else
  1153. data = d2 + data;
  1154. }
  1155. return _2.set(this._area, this._in(key), _2.stringify(data, replacer)), data;
  1156. },
  1157. remove: function(key, alt) {
  1158. var d2 = this.get(key, alt);
  1159. return _2.remove(this._area, this._in(key)), d2;
  1160. },
  1161. clear: function() {
  1162. return this._ns ? this.each(function(k2) {
  1163. _2.remove(this._area, this._in(k2));
  1164. }, 1) : _2.clear(this._area), this;
  1165. },
  1166. clearAll: function() {
  1167. var area = this._area;
  1168. for (var id in _2.areas)
  1169. _2.areas.hasOwnProperty(id) && (this._area = _2.areas[id], this.clear());
  1170. return this._area = area, this;
  1171. },
  1172. // internal use functions
  1173. _in: function(k2) {
  1174. return typeof k2 != "string" && (k2 = _2.stringify(k2)), this._ns ? this._ns + k2 : k2;
  1175. },
  1176. _out: function(k2) {
  1177. return this._ns ? k2 && k2.indexOf(this._ns) === 0 ? k2.substring(this._ns.length) : void 0 : (
  1178. // so each() knows to skip it
  1179. k2
  1180. );
  1181. }
  1182. },
  1183. // end _.storeAPI
  1184. storage: function(name) {
  1185. return _2.inherit(_2.storageAPI, { items: {}, name });
  1186. },
  1187. storageAPI: {
  1188. length: 0,
  1189. has: function(k2) {
  1190. return this.items.hasOwnProperty(k2);
  1191. },
  1192. key: function(i2) {
  1193. var c2 = 0;
  1194. for (var k2 in this.items)
  1195. if (this.has(k2) && i2 === c2++)
  1196. return k2;
  1197. },
  1198. setItem: function(k2, v2) {
  1199. this.has(k2) || this.length++, this.items[k2] = v2;
  1200. },
  1201. removeItem: function(k2) {
  1202. this.has(k2) && (delete this.items[k2], this.length--);
  1203. },
  1204. getItem: function(k2) {
  1205. return this.has(k2) ? this.items[k2] : null;
  1206. },
  1207. clear: function() {
  1208. for (var k2 in this.items)
  1209. this.removeItem(k2);
  1210. }
  1211. }
  1212. // end _.storageAPI
  1213. }, store2 = (
  1214. // safely set this up (throws error in IE10/32bit mode for local files)
  1215. _2.Store("local", (function() {
  1216. try {
  1217. return localStorage;
  1218. } catch {
  1219. }
  1220. })())
  1221. );
  1222. store2.local = store2, store2._ = _2, store2.area("session", (function() {
  1223. try {
  1224. return sessionStorage;
  1225. } catch {
  1226. }
  1227. })()), store2.area("page", _2.storage("page")), typeof define2 == "function" && define2.amd !== void 0 ? define2("store2", [], function() {
  1228. return store2;
  1229. }) : typeof module < "u" && module.exports ? module.exports = store2 : (window2.store && (_2.conflict = window2.store), window2.store = store2);
  1230. })(exports, exports && exports.define);
  1231. }
  1232. });
  1233. // src/manager/runtime.tsx
  1234. init_react();
  1235. // global-externals:storybook/internal/channels
  1236. var channels_default = __STORYBOOK_CHANNELS__, { Channel, HEARTBEAT_INTERVAL, HEARTBEAT_MAX_LATENCY, PostMessageTransport, WebsocketTransport, createBrowserChannel } = __STORYBOOK_CHANNELS__;
  1237. // global-externals:storybook/internal/core-events
  1238. 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__;
  1239. // ../../node_modules/@storybook/global/dist/index.mjs
  1240. var scope = (() => {
  1241. let win;
  1242. return typeof window < "u" ? win = window : typeof globalThis < "u" ? win = globalThis : typeof global < "u" ? win = global : typeof self < "u" ? win = self : win = {}, win;
  1243. })();
  1244. // global-externals:@storybook/icons
  1245. var icons_exports = {};
  1246. __export(icons_exports, {
  1247. AccessibilityAltIcon: () => AccessibilityAltIcon,
  1248. AccessibilityIcon: () => AccessibilityIcon,
  1249. AccessibilityIgnoredIcon: () => AccessibilityIgnoredIcon,
  1250. AddIcon: () => AddIcon,
  1251. AdminIcon: () => AdminIcon,
  1252. AlertAltIcon: () => AlertAltIcon,
  1253. AlertIcon: () => AlertIcon,
  1254. AlignLeftIcon: () => AlignLeftIcon,
  1255. AlignRightIcon: () => AlignRightIcon,
  1256. AppleIcon: () => AppleIcon,
  1257. ArrowBottomLeftIcon: () => ArrowBottomLeftIcon,
  1258. ArrowBottomRightIcon: () => ArrowBottomRightIcon,
  1259. ArrowDownIcon: () => ArrowDownIcon,
  1260. ArrowLeftIcon: () => ArrowLeftIcon,
  1261. ArrowRightIcon: () => ArrowRightIcon,
  1262. ArrowSolidDownIcon: () => ArrowSolidDownIcon,
  1263. ArrowSolidLeftIcon: () => ArrowSolidLeftIcon,
  1264. ArrowSolidRightIcon: () => ArrowSolidRightIcon,
  1265. ArrowSolidUpIcon: () => ArrowSolidUpIcon,
  1266. ArrowTopLeftIcon: () => ArrowTopLeftIcon,
  1267. ArrowTopRightIcon: () => ArrowTopRightIcon,
  1268. ArrowUpIcon: () => ArrowUpIcon,
  1269. AzureDevOpsIcon: () => AzureDevOpsIcon,
  1270. BackIcon: () => BackIcon,
  1271. BasketIcon: () => BasketIcon,
  1272. BatchAcceptIcon: () => BatchAcceptIcon,
  1273. BatchDenyIcon: () => BatchDenyIcon,
  1274. BeakerIcon: () => BeakerIcon,
  1275. BellIcon: () => BellIcon,
  1276. BitbucketIcon: () => BitbucketIcon,
  1277. BoldIcon: () => BoldIcon,
  1278. BookIcon: () => BookIcon,
  1279. BookmarkHollowIcon: () => BookmarkHollowIcon,
  1280. BookmarkIcon: () => BookmarkIcon,
  1281. BottomBarIcon: () => BottomBarIcon,
  1282. BottomBarToggleIcon: () => BottomBarToggleIcon,
  1283. BoxIcon: () => BoxIcon,
  1284. BranchIcon: () => BranchIcon,
  1285. BrowserIcon: () => BrowserIcon,
  1286. BugIcon: () => BugIcon,
  1287. ButtonIcon: () => ButtonIcon,
  1288. CPUIcon: () => CPUIcon,
  1289. CalendarIcon: () => CalendarIcon,
  1290. CameraIcon: () => CameraIcon,
  1291. CameraStabilizeIcon: () => CameraStabilizeIcon,
  1292. CategoryIcon: () => CategoryIcon,
  1293. CertificateIcon: () => CertificateIcon,
  1294. ChangedIcon: () => ChangedIcon,
  1295. ChatIcon: () => ChatIcon,
  1296. CheckIcon: () => CheckIcon,
  1297. ChecklistIcon: () => ChecklistIcon,
  1298. ChevronDownIcon: () => ChevronDownIcon,
  1299. ChevronLeftIcon: () => ChevronLeftIcon,
  1300. ChevronRightIcon: () => ChevronRightIcon,
  1301. ChevronSmallDownIcon: () => ChevronSmallDownIcon,
  1302. ChevronSmallLeftIcon: () => ChevronSmallLeftIcon,
  1303. ChevronSmallRightIcon: () => ChevronSmallRightIcon,
  1304. ChevronSmallUpIcon: () => ChevronSmallUpIcon,
  1305. ChevronUpIcon: () => ChevronUpIcon,
  1306. ChromaticIcon: () => ChromaticIcon,
  1307. ChromeIcon: () => ChromeIcon,
  1308. CircleHollowIcon: () => CircleHollowIcon,
  1309. CircleIcon: () => CircleIcon,
  1310. ClearIcon: () => ClearIcon,
  1311. CloseAltIcon: () => CloseAltIcon,
  1312. CloseIcon: () => CloseIcon,
  1313. CloudHollowIcon: () => CloudHollowIcon,
  1314. CloudIcon: () => CloudIcon,
  1315. CogIcon: () => CogIcon,
  1316. CollapseIcon: () => CollapseIcon,
  1317. CommandIcon: () => CommandIcon,
  1318. CommentAddIcon: () => CommentAddIcon,
  1319. CommentIcon: () => CommentIcon,
  1320. CommentsIcon: () => CommentsIcon,
  1321. CommitIcon: () => CommitIcon,
  1322. CompassIcon: () => CompassIcon,
  1323. ComponentDrivenIcon: () => ComponentDrivenIcon,
  1324. ComponentIcon: () => ComponentIcon,
  1325. ContrastIcon: () => ContrastIcon,
  1326. ContrastIgnoredIcon: () => ContrastIgnoredIcon,
  1327. ControlsIcon: () => ControlsIcon,
  1328. CopyIcon: () => CopyIcon,
  1329. CreditIcon: () => CreditIcon,
  1330. CrossIcon: () => CrossIcon,
  1331. DashboardIcon: () => DashboardIcon,
  1332. DatabaseIcon: () => DatabaseIcon,
  1333. DeleteIcon: () => DeleteIcon,
  1334. DiamondIcon: () => DiamondIcon,
  1335. DirectionIcon: () => DirectionIcon,
  1336. DiscordIcon: () => DiscordIcon,
  1337. DocChartIcon: () => DocChartIcon,
  1338. DocListIcon: () => DocListIcon,
  1339. DocumentIcon: () => DocumentIcon,
  1340. DownloadIcon: () => DownloadIcon,
  1341. DragIcon: () => DragIcon,
  1342. EditIcon: () => EditIcon,
  1343. EditorIcon: () => EditorIcon,
  1344. EllipsisIcon: () => EllipsisIcon,
  1345. EmailIcon: () => EmailIcon,
  1346. ExpandAltIcon: () => ExpandAltIcon,
  1347. ExpandIcon: () => ExpandIcon,
  1348. EyeCloseIcon: () => EyeCloseIcon,
  1349. EyeIcon: () => EyeIcon,
  1350. FaceHappyIcon: () => FaceHappyIcon,
  1351. FaceNeutralIcon: () => FaceNeutralIcon,
  1352. FaceSadIcon: () => FaceSadIcon,
  1353. FacebookIcon: () => FacebookIcon,
  1354. FailedIcon: () => FailedIcon,
  1355. FastForwardIcon: () => FastForwardIcon,
  1356. FigmaIcon: () => FigmaIcon,
  1357. FilesIcon: () => FilesIcon,
  1358. FilterIcon: () => FilterIcon,
  1359. FlagIcon: () => FlagIcon,
  1360. FolderIcon: () => FolderIcon,
  1361. FormIcon: () => FormIcon,
  1362. GDriveIcon: () => GDriveIcon,
  1363. GiftIcon: () => GiftIcon,
  1364. GithubIcon: () => GithubIcon,
  1365. GitlabIcon: () => GitlabIcon,
  1366. GlobeIcon: () => GlobeIcon,
  1367. GoogleIcon: () => GoogleIcon,
  1368. GraphBarIcon: () => GraphBarIcon,
  1369. GraphLineIcon: () => GraphLineIcon,
  1370. GraphqlIcon: () => GraphqlIcon,
  1371. GridAltIcon: () => GridAltIcon,
  1372. GridIcon: () => GridIcon,
  1373. GrowIcon: () => GrowIcon,
  1374. HeartHollowIcon: () => HeartHollowIcon,
  1375. HeartIcon: () => HeartIcon,
  1376. HomeIcon: () => HomeIcon,
  1377. HourglassIcon: () => HourglassIcon,
  1378. InfoIcon: () => InfoIcon,
  1379. ItalicIcon: () => ItalicIcon,
  1380. JumpToIcon: () => JumpToIcon,
  1381. KeyIcon: () => KeyIcon,
  1382. LightningIcon: () => LightningIcon,
  1383. LightningOffIcon: () => LightningOffIcon,
  1384. LinkBrokenIcon: () => LinkBrokenIcon,
  1385. LinkIcon: () => LinkIcon,
  1386. LinkedinIcon: () => LinkedinIcon,
  1387. LinuxIcon: () => LinuxIcon,
  1388. ListOrderedIcon: () => ListOrderedIcon,
  1389. ListUnorderedIcon: () => ListUnorderedIcon,
  1390. LocationIcon: () => LocationIcon,
  1391. LockIcon: () => LockIcon,
  1392. MarkdownIcon: () => MarkdownIcon,
  1393. MarkupIcon: () => MarkupIcon,
  1394. MediumIcon: () => MediumIcon,
  1395. MemoryIcon: () => MemoryIcon,
  1396. MenuIcon: () => MenuIcon,
  1397. MergeIcon: () => MergeIcon,
  1398. MirrorIcon: () => MirrorIcon,
  1399. MobileIcon: () => MobileIcon,
  1400. MoonIcon: () => MoonIcon,
  1401. NutIcon: () => NutIcon,
  1402. OutboxIcon: () => OutboxIcon,
  1403. OutlineIcon: () => OutlineIcon,
  1404. PaintBrushAltIcon: () => PaintBrushAltIcon,
  1405. PaintBrushIcon: () => PaintBrushIcon,
  1406. PaperClipIcon: () => PaperClipIcon,
  1407. ParagraphIcon: () => ParagraphIcon,
  1408. PassedIcon: () => PassedIcon,
  1409. PhoneIcon: () => PhoneIcon,
  1410. PhotoDragIcon: () => PhotoDragIcon,
  1411. PhotoIcon: () => PhotoIcon,
  1412. PhotoStabilizeIcon: () => PhotoStabilizeIcon,
  1413. PinAltIcon: () => PinAltIcon,
  1414. PinIcon: () => PinIcon,
  1415. PlayAllHollowIcon: () => PlayAllHollowIcon,
  1416. PlayBackIcon: () => PlayBackIcon,
  1417. PlayHollowIcon: () => PlayHollowIcon,
  1418. PlayIcon: () => PlayIcon,
  1419. PlayNextIcon: () => PlayNextIcon,
  1420. PlusIcon: () => PlusIcon,
  1421. PointerDefaultIcon: () => PointerDefaultIcon,
  1422. PointerHandIcon: () => PointerHandIcon,
  1423. PopOutIcon: () => PopOutIcon,
  1424. PowerIcon: () => PowerIcon,
  1425. PrintIcon: () => PrintIcon,
  1426. ProceedIcon: () => ProceedIcon,
  1427. ProfileIcon: () => ProfileIcon,
  1428. PullRequestIcon: () => PullRequestIcon,
  1429. QuestionIcon: () => QuestionIcon,
  1430. RSSIcon: () => RSSIcon,
  1431. RedirectIcon: () => RedirectIcon,
  1432. ReduxIcon: () => ReduxIcon,
  1433. RefreshIcon: () => RefreshIcon,
  1434. ReplyIcon: () => ReplyIcon,
  1435. RepoIcon: () => RepoIcon,
  1436. RequestChangeIcon: () => RequestChangeIcon,
  1437. RewindIcon: () => RewindIcon,
  1438. RulerIcon: () => RulerIcon,
  1439. SaveIcon: () => SaveIcon,
  1440. SearchIcon: () => SearchIcon,
  1441. ShareAltIcon: () => ShareAltIcon,
  1442. ShareIcon: () => ShareIcon,
  1443. ShieldIcon: () => ShieldIcon,
  1444. SideBySideIcon: () => SideBySideIcon,
  1445. SidebarAltIcon: () => SidebarAltIcon,
  1446. SidebarAltToggleIcon: () => SidebarAltToggleIcon,
  1447. SidebarIcon: () => SidebarIcon,
  1448. SidebarToggleIcon: () => SidebarToggleIcon,
  1449. SortDownIcon: () => SortDownIcon,
  1450. SortUpIcon: () => SortUpIcon,
  1451. SpeakerIcon: () => SpeakerIcon,
  1452. StackedIcon: () => StackedIcon,
  1453. StarHollowIcon: () => StarHollowIcon,
  1454. StarIcon: () => StarIcon,
  1455. StatusFailIcon: () => StatusFailIcon,
  1456. StatusIcon: () => StatusIcon,
  1457. StatusNewIcon: () => StatusNewIcon,
  1458. StatusPassIcon: () => StatusPassIcon,
  1459. StatusWarnIcon: () => StatusWarnIcon,
  1460. StickerIcon: () => StickerIcon,
  1461. StopAltHollowIcon: () => StopAltHollowIcon,
  1462. StopAltIcon: () => StopAltIcon,
  1463. StopIcon: () => StopIcon,
  1464. StorybookIcon: () => StorybookIcon,
  1465. StructureIcon: () => StructureIcon,
  1466. SubtractIcon: () => SubtractIcon,
  1467. SunIcon: () => SunIcon,
  1468. SupportIcon: () => SupportIcon,
  1469. SweepIcon: () => SweepIcon,
  1470. SwitchAltIcon: () => SwitchAltIcon,
  1471. SyncIcon: () => SyncIcon,
  1472. TabletIcon: () => TabletIcon,
  1473. ThumbsUpIcon: () => ThumbsUpIcon,
  1474. TimeIcon: () => TimeIcon,
  1475. TimerIcon: () => TimerIcon,
  1476. TransferIcon: () => TransferIcon,
  1477. TrashIcon: () => TrashIcon,
  1478. TwitterIcon: () => TwitterIcon,
  1479. TypeIcon: () => TypeIcon,
  1480. UbuntuIcon: () => UbuntuIcon,
  1481. UndoIcon: () => UndoIcon,
  1482. UnfoldIcon: () => UnfoldIcon,
  1483. UnlockIcon: () => UnlockIcon,
  1484. UnpinIcon: () => UnpinIcon,
  1485. UploadIcon: () => UploadIcon,
  1486. UserAddIcon: () => UserAddIcon,
  1487. UserAltIcon: () => UserAltIcon,
  1488. UserIcon: () => UserIcon,
  1489. UsersIcon: () => UsersIcon,
  1490. VSCodeIcon: () => VSCodeIcon,
  1491. VerifiedIcon: () => VerifiedIcon,
  1492. VideoIcon: () => VideoIcon,
  1493. WandIcon: () => WandIcon,
  1494. WatchIcon: () => WatchIcon,
  1495. WindowsIcon: () => WindowsIcon,
  1496. WrenchIcon: () => WrenchIcon,
  1497. XIcon: () => XIcon,
  1498. YoutubeIcon: () => YoutubeIcon,
  1499. ZoomIcon: () => ZoomIcon,
  1500. ZoomOutIcon: () => ZoomOutIcon,
  1501. ZoomResetIcon: () => ZoomResetIcon,
  1502. default: () => icons_default,
  1503. iconList: () => iconList
  1504. });
  1505. 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__;
  1506. // global-externals:storybook/manager-api
  1507. 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__;
  1508. // global-externals:storybook/theming
  1509. 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__;
  1510. // src/toolbar/components/ToolbarManager.tsx
  1511. init_react();
  1512. // global-externals:storybook/internal/components
  1513. 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__;
  1514. // src/toolbar/utils/normalize-toolbar-arg-type.ts
  1515. var defaultItemValues = {
  1516. type: "item",
  1517. value: ""
  1518. }, normalizeArgType = (key, argType) => {
  1519. let toolbar = argType.toolbar;
  1520. return toolbar ? {
  1521. ...argType,
  1522. name: argType.name || key,
  1523. description: argType.description || key,
  1524. toolbar: {
  1525. ...argType.toolbar,
  1526. items: toolbar.items.map((_item) => {
  1527. let item = typeof _item == "string" ? { value: _item, title: _item } : _item;
  1528. return item.type === "reset" && toolbar.icon && (item.icon = toolbar.icon, item.hideIcon = !0, item.value = void 0), { ...defaultItemValues, ...item };
  1529. })
  1530. }
  1531. } : null;
  1532. };
  1533. // src/toolbar/components/ToolbarMenuSelect.tsx
  1534. init_react();
  1535. // src/components/components/icon/icon.tsx
  1536. init_react();
  1537. // global-externals:storybook/internal/client-logger
  1538. var client_logger_default = __STORYBOOK_CLIENT_LOGGER__, { deprecate, logger, once, pretty } = __STORYBOOK_CLIENT_LOGGER__;
  1539. // src/components/components/icon/icon.tsx
  1540. var NEW_ICON_MAP = icons_exports, Svg = styled.svg`
  1541. display: inline-block;
  1542. shape-rendering: inherit;
  1543. vertical-align: middle;
  1544. fill: currentColor;
  1545. path {
  1546. fill: currentColor;
  1547. }
  1548. `, Icons = ({
  1549. icon,
  1550. useSymbol,
  1551. __suppressDeprecationWarning = !1,
  1552. ...props
  1553. }) => {
  1554. __suppressDeprecationWarning || deprecate(
  1555. `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`
  1556. );
  1557. let findIcon = icons[icon] || null;
  1558. if (!findIcon)
  1559. return logger.warn(
  1560. `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`
  1561. ), null;
  1562. let Icon = NEW_ICON_MAP[findIcon];
  1563. return react_default.createElement(Icon, { ...props });
  1564. }, Symbols = memo(function({ icons: keys = Object.keys(icons) }) {
  1565. return react_default.createElement(
  1566. Svg,
  1567. {
  1568. viewBox: "0 0 14 14",
  1569. style: { position: "absolute", width: 0, height: 0 },
  1570. "data-chromatic": "ignore"
  1571. },
  1572. keys.map((key) => react_default.createElement("symbol", { id: `icon--${key}`, key }, icons[key]))
  1573. );
  1574. }), icons = {
  1575. user: "UserIcon",
  1576. useralt: "UserAltIcon",
  1577. useradd: "UserAddIcon",
  1578. users: "UsersIcon",
  1579. profile: "ProfileIcon",
  1580. facehappy: "FaceHappyIcon",
  1581. faceneutral: "FaceNeutralIcon",
  1582. facesad: "FaceSadIcon",
  1583. accessibility: "AccessibilityIcon",
  1584. accessibilityalt: "AccessibilityAltIcon",
  1585. arrowup: "ChevronUpIcon",
  1586. arrowdown: "ChevronDownIcon",
  1587. arrowleft: "ChevronLeftIcon",
  1588. arrowright: "ChevronRightIcon",
  1589. arrowupalt: "ArrowUpIcon",
  1590. arrowdownalt: "ArrowDownIcon",
  1591. arrowleftalt: "ArrowLeftIcon",
  1592. arrowrightalt: "ArrowRightIcon",
  1593. expandalt: "ExpandAltIcon",
  1594. collapse: "CollapseIcon",
  1595. expand: "ExpandIcon",
  1596. unfold: "UnfoldIcon",
  1597. transfer: "TransferIcon",
  1598. redirect: "RedirectIcon",
  1599. undo: "UndoIcon",
  1600. reply: "ReplyIcon",
  1601. sync: "SyncIcon",
  1602. upload: "UploadIcon",
  1603. download: "DownloadIcon",
  1604. back: "BackIcon",
  1605. proceed: "ProceedIcon",
  1606. refresh: "RefreshIcon",
  1607. globe: "GlobeIcon",
  1608. compass: "CompassIcon",
  1609. location: "LocationIcon",
  1610. pin: "PinIcon",
  1611. time: "TimeIcon",
  1612. dashboard: "DashboardIcon",
  1613. timer: "TimerIcon",
  1614. home: "HomeIcon",
  1615. admin: "AdminIcon",
  1616. info: "InfoIcon",
  1617. question: "QuestionIcon",
  1618. support: "SupportIcon",
  1619. alert: "AlertIcon",
  1620. email: "EmailIcon",
  1621. phone: "PhoneIcon",
  1622. link: "LinkIcon",
  1623. unlink: "LinkBrokenIcon",
  1624. bell: "BellIcon",
  1625. rss: "RSSIcon",
  1626. sharealt: "ShareAltIcon",
  1627. share: "ShareIcon",
  1628. circle: "CircleIcon",
  1629. circlehollow: "CircleHollowIcon",
  1630. bookmarkhollow: "BookmarkHollowIcon",
  1631. bookmark: "BookmarkIcon",
  1632. hearthollow: "HeartHollowIcon",
  1633. heart: "HeartIcon",
  1634. starhollow: "StarHollowIcon",
  1635. star: "StarIcon",
  1636. certificate: "CertificateIcon",
  1637. verified: "VerifiedIcon",
  1638. thumbsup: "ThumbsUpIcon",
  1639. shield: "ShieldIcon",
  1640. basket: "BasketIcon",
  1641. beaker: "BeakerIcon",
  1642. hourglass: "HourglassIcon",
  1643. flag: "FlagIcon",
  1644. cloudhollow: "CloudHollowIcon",
  1645. edit: "EditIcon",
  1646. cog: "CogIcon",
  1647. nut: "NutIcon",
  1648. wrench: "WrenchIcon",
  1649. ellipsis: "EllipsisIcon",
  1650. check: "CheckIcon",
  1651. form: "FormIcon",
  1652. batchdeny: "BatchDenyIcon",
  1653. batchaccept: "BatchAcceptIcon",
  1654. controls: "ControlsIcon",
  1655. plus: "PlusIcon",
  1656. closeAlt: "CloseAltIcon",
  1657. cross: "CrossIcon",
  1658. trash: "TrashIcon",
  1659. pinalt: "PinAltIcon",
  1660. unpin: "UnpinIcon",
  1661. add: "AddIcon",
  1662. subtract: "SubtractIcon",
  1663. close: "CloseIcon",
  1664. delete: "DeleteIcon",
  1665. passed: "PassedIcon",
  1666. changed: "ChangedIcon",
  1667. failed: "FailedIcon",
  1668. clear: "ClearIcon",
  1669. comment: "CommentIcon",
  1670. commentadd: "CommentAddIcon",
  1671. requestchange: "RequestChangeIcon",
  1672. comments: "CommentsIcon",
  1673. lock: "LockIcon",
  1674. unlock: "UnlockIcon",
  1675. key: "KeyIcon",
  1676. outbox: "OutboxIcon",
  1677. credit: "CreditIcon",
  1678. button: "ButtonIcon",
  1679. type: "TypeIcon",
  1680. pointerdefault: "PointerDefaultIcon",
  1681. pointerhand: "PointerHandIcon",
  1682. browser: "BrowserIcon",
  1683. tablet: "TabletIcon",
  1684. mobile: "MobileIcon",
  1685. watch: "WatchIcon",
  1686. sidebar: "SidebarIcon",
  1687. sidebaralt: "SidebarAltIcon",
  1688. sidebaralttoggle: "SidebarAltToggleIcon",
  1689. sidebartoggle: "SidebarToggleIcon",
  1690. bottombar: "BottomBarIcon",
  1691. bottombartoggle: "BottomBarToggleIcon",
  1692. cpu: "CPUIcon",
  1693. database: "DatabaseIcon",
  1694. memory: "MemoryIcon",
  1695. structure: "StructureIcon",
  1696. box: "BoxIcon",
  1697. power: "PowerIcon",
  1698. photo: "PhotoIcon",
  1699. component: "ComponentIcon",
  1700. grid: "GridIcon",
  1701. outline: "OutlineIcon",
  1702. photodrag: "PhotoDragIcon",
  1703. search: "SearchIcon",
  1704. zoom: "ZoomIcon",
  1705. zoomout: "ZoomOutIcon",
  1706. zoomreset: "ZoomResetIcon",
  1707. eye: "EyeIcon",
  1708. eyeclose: "EyeCloseIcon",
  1709. lightning: "LightningIcon",
  1710. lightningoff: "LightningOffIcon",
  1711. contrast: "ContrastIcon",
  1712. switchalt: "SwitchAltIcon",
  1713. mirror: "MirrorIcon",
  1714. grow: "GrowIcon",
  1715. paintbrush: "PaintBrushIcon",
  1716. ruler: "RulerIcon",
  1717. stop: "StopIcon",
  1718. camera: "CameraIcon",
  1719. video: "VideoIcon",
  1720. speaker: "SpeakerIcon",
  1721. play: "PlayIcon",
  1722. playback: "PlayBackIcon",
  1723. playnext: "PlayNextIcon",
  1724. rewind: "RewindIcon",
  1725. fastforward: "FastForwardIcon",
  1726. stopalt: "StopAltIcon",
  1727. sidebyside: "SideBySideIcon",
  1728. stacked: "StackedIcon",
  1729. sun: "SunIcon",
  1730. moon: "MoonIcon",
  1731. book: "BookIcon",
  1732. document: "DocumentIcon",
  1733. copy: "CopyIcon",
  1734. category: "CategoryIcon",
  1735. folder: "FolderIcon",
  1736. print: "PrintIcon",
  1737. graphline: "GraphLineIcon",
  1738. calendar: "CalendarIcon",
  1739. graphbar: "GraphBarIcon",
  1740. menu: "MenuIcon",
  1741. menualt: "MenuIcon",
  1742. filter: "FilterIcon",
  1743. docchart: "DocChartIcon",
  1744. doclist: "DocListIcon",
  1745. markup: "MarkupIcon",
  1746. bold: "BoldIcon",
  1747. paperclip: "PaperClipIcon",
  1748. listordered: "ListOrderedIcon",
  1749. listunordered: "ListUnorderedIcon",
  1750. paragraph: "ParagraphIcon",
  1751. markdown: "MarkdownIcon",
  1752. repository: "RepoIcon",
  1753. commit: "CommitIcon",
  1754. branch: "BranchIcon",
  1755. pullrequest: "PullRequestIcon",
  1756. merge: "MergeIcon",
  1757. apple: "AppleIcon",
  1758. linux: "LinuxIcon",
  1759. ubuntu: "UbuntuIcon",
  1760. windows: "WindowsIcon",
  1761. storybook: "StorybookIcon",
  1762. azuredevops: "AzureDevOpsIcon",
  1763. bitbucket: "BitbucketIcon",
  1764. chrome: "ChromeIcon",
  1765. chromatic: "ChromaticIcon",
  1766. componentdriven: "ComponentDrivenIcon",
  1767. discord: "DiscordIcon",
  1768. facebook: "FacebookIcon",
  1769. figma: "FigmaIcon",
  1770. gdrive: "GDriveIcon",
  1771. github: "GithubIcon",
  1772. gitlab: "GitlabIcon",
  1773. google: "GoogleIcon",
  1774. graphql: "GraphqlIcon",
  1775. medium: "MediumIcon",
  1776. redux: "ReduxIcon",
  1777. twitter: "TwitterIcon",
  1778. youtube: "YoutubeIcon",
  1779. vscode: "VSCodeIcon"
  1780. };
  1781. // src/toolbar/utils/get-selected.ts
  1782. var getSelectedItem = ({ currentValue, items }) => items.find((item) => item.value === currentValue && item.type !== "reset");
  1783. // src/toolbar/constants.ts
  1784. var TOOLBAR_ID = "toolbar";
  1785. // src/toolbar/utils/register-shortcuts.ts
  1786. var registerShortcuts = async (api, id, shortcuts) => {
  1787. shortcuts.next && await api.setAddonShortcut(TOOLBAR_ID, {
  1788. label: shortcuts.next.label,
  1789. defaultShortcut: shortcuts.next.keys,
  1790. actionName: `${id}:next`,
  1791. action: shortcuts.next.action
  1792. }), shortcuts.previous && await api.setAddonShortcut(TOOLBAR_ID, {
  1793. label: shortcuts.previous.label,
  1794. defaultShortcut: shortcuts.previous.keys,
  1795. actionName: `${id}:previous`,
  1796. action: shortcuts.previous.action
  1797. }), shortcuts.reset && await api.setAddonShortcut(TOOLBAR_ID, {
  1798. label: shortcuts.reset.label,
  1799. defaultShortcut: shortcuts.reset.keys,
  1800. actionName: `${id}:reset`,
  1801. action: shortcuts.reset.action
  1802. });
  1803. };
  1804. // src/toolbar/components/ToolbarMenuSelect.tsx
  1805. var ToolbarMenuItemContainer = styled("div")({
  1806. width: "100%",
  1807. display: "flex",
  1808. alignItems: "center",
  1809. gap: 8
  1810. }), ToolbarMenuItemMiddle = styled("div")({
  1811. flex: 1
  1812. }), ToolbarMenuSelect = ({
  1813. id,
  1814. name,
  1815. description,
  1816. toolbar: {
  1817. icon: _icon,
  1818. items,
  1819. title: _title,
  1820. preventDynamicIcon,
  1821. dynamicTitle = !0,
  1822. shortcuts
  1823. }
  1824. }) => {
  1825. let api = useStorybookApi(), [globals, updateGlobals, storyGlobals] = useGlobals(), currentValue = globals[id], isOverridden = id in storyGlobals, icon = _icon, title2 = _title;
  1826. 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`);
  1827. let resetItem = items.find((item) => item.type === "reset"), resetLabel = resetItem?.title, options2 = react_default.useMemo(
  1828. () => items.filter((item) => item.type === "item").map((item) => {
  1829. let itemTitle = item.title ?? item.value ?? "Untitled", iconComponent = !item.hideIcon && item.icon ? react_default.createElement(Icons, { icon: item.icon, __suppressDeprecationWarning: !0 }) : void 0;
  1830. return item.right ? {
  1831. title: itemTitle,
  1832. value: item.value,
  1833. children: react_default.createElement(ToolbarMenuItemContainer, null, iconComponent, react_default.createElement(ToolbarMenuItemMiddle, null, item.title ?? item.value), item.right)
  1834. } : {
  1835. title: itemTitle,
  1836. value: item.value,
  1837. icon: iconComponent
  1838. };
  1839. }),
  1840. [items]
  1841. );
  1842. react_default.useEffect(() => {
  1843. if (shortcuts) {
  1844. let length = options2.length;
  1845. registerShortcuts(api, id, {
  1846. next: {
  1847. ...shortcuts.next,
  1848. action: () => {
  1849. let idx = options2.findIndex((i2) => i2.value === globals[id]), nextIdx = idx < 0 ? 0 : (idx + 1) % length;
  1850. updateGlobals({ [id]: options2[nextIdx].value });
  1851. }
  1852. },
  1853. previous: {
  1854. ...shortcuts.previous,
  1855. action: () => {
  1856. let idx = options2.findIndex((i2) => i2.value === globals[id]), previousIdx = idx < 0 ? length - 1 : (idx + length - 1) % length;
  1857. updateGlobals({ [id]: options2[previousIdx].value });
  1858. }
  1859. },
  1860. reset: {
  1861. ...shortcuts.reset,
  1862. action: () => {
  1863. updateGlobals({ [id]: void 0 });
  1864. }
  1865. }
  1866. });
  1867. }
  1868. }, [api, id, shortcuts, globals, options2, updateGlobals]);
  1869. let ariaLabel = description || title2 || name || id;
  1870. return react_default.createElement(
  1871. Select,
  1872. {
  1873. defaultOptions: [currentValue],
  1874. options: options2,
  1875. disabled: isOverridden,
  1876. ariaLabel,
  1877. tooltip: ariaLabel,
  1878. resetLabel,
  1879. onReset: resetItem ? () => updateGlobals({ [id]: resetItem?.value }) : void 0,
  1880. onSelect: (selected) => updateGlobals({ [id]: selected }),
  1881. icon: icon && react_default.createElement(Icons, { icon, __suppressDeprecationWarning: !0 }),
  1882. showSelectedOptionTitle: dynamicTitle
  1883. },
  1884. title2
  1885. );
  1886. };
  1887. // src/toolbar/components/ToolbarManager.tsx
  1888. var ToolbarManager = () => {
  1889. let globalTypes = useGlobalTypes();
  1890. 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) => {
  1891. let normalizedArgType = normalizeArgType(id, globalTypes[id]);
  1892. return normalizedArgType && react_default.createElement(ToolbarMenuSelect, { key: id, id, ...normalizedArgType });
  1893. })) : null;
  1894. };
  1895. // src/manager/index.tsx
  1896. init_react();
  1897. // global-externals:react-dom/client
  1898. var client_default = __REACT_DOM_CLIENT__, { createRoot, hydrateRoot } = __REACT_DOM_CLIENT__;
  1899. // global-externals:storybook/internal/manager-errors
  1900. var manager_errors_default = __STORYBOOK_CORE_EVENTS_MANAGER_ERRORS__, { Category, ProviderDoesNotExtendBaseProviderError, StatusTypeIdMismatchError, UncaughtManagerError } = __STORYBOOK_CORE_EVENTS_MANAGER_ERRORS__;
  1901. // global-externals:storybook/internal/router
  1902. var router_default = __STORYBOOK_ROUTER__, { BaseLocationProvider, DEEPLY_EQUAL, Link: Link2, Location, LocationProvider, Match, MemoryRouter, Route, buildArgsParam, deepDiff, getMatch, parsePath, queryFromLocation, stringifyQuery, useNavigate } = __STORYBOOK_ROUTER__;
  1903. // ../../node_modules/react-helmet-async/lib/index.module.js
  1904. init_react();
  1905. 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());
  1906. function a() {
  1907. return a = Object.assign || function(t2) {
  1908. for (var e2 = 1; e2 < arguments.length; e2++) {
  1909. var r4 = arguments[e2];
  1910. for (var n3 in r4) Object.prototype.hasOwnProperty.call(r4, n3) && (t2[n3] = r4[n3]);
  1911. }
  1912. return t2;
  1913. }, a.apply(this, arguments);
  1914. }
  1915. function s(t2, e2) {
  1916. t2.prototype = Object.create(e2.prototype), t2.prototype.constructor = t2, c(t2, e2);
  1917. }
  1918. function c(t2, e2) {
  1919. return c = Object.setPrototypeOf || function(t3, e3) {
  1920. return t3.__proto__ = e3, t3;
  1921. }, c(t2, e2);
  1922. }
  1923. function u(t2, e2) {
  1924. if (t2 == null) return {};
  1925. var r4, n3, i2 = {}, o3 = Object.keys(t2);
  1926. for (n3 = 0; n3 < o3.length; n3++) e2.indexOf(r4 = o3[n3]) >= 0 || (i2[r4] = t2[r4]);
  1927. return i2;
  1928. }
  1929. 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) {
  1930. return l[t2];
  1931. }), 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) {
  1932. return t2[m[e2]] = e2, t2;
  1933. }, {}), T = function(t2, e2) {
  1934. for (var r4 = t2.length - 1; r4 >= 0; r4 -= 1) {
  1935. var n3 = t2[r4];
  1936. if (Object.prototype.hasOwnProperty.call(n3, e2)) return n3[e2];
  1937. }
  1938. return null;
  1939. }, g = function(t2) {
  1940. var e2 = T(t2, l.TITLE), r4 = T(t2, "titleTemplate");
  1941. if (Array.isArray(e2) && (e2 = e2.join("")), r4 && e2) return r4.replace(/%s/g, function() {
  1942. return e2;
  1943. });
  1944. var n3 = T(t2, "defaultTitle");
  1945. return e2 || n3 || void 0;
  1946. }, b = function(t2) {
  1947. return T(t2, "onChangeClientState") || function() {
  1948. };
  1949. }, v = function(t2, e2) {
  1950. return e2.filter(function(e3) {
  1951. return e3[t2] !== void 0;
  1952. }).map(function(e3) {
  1953. return e3[t2];
  1954. }).reduce(function(t3, e3) {
  1955. return a({}, t3, e3);
  1956. }, {});
  1957. }, A2 = function(t2, e2) {
  1958. return e2.filter(function(t3) {
  1959. return t3[l.BASE] !== void 0;
  1960. }).map(function(t3) {
  1961. return t3[l.BASE];
  1962. }).reverse().reduce(function(e3, r4) {
  1963. if (!e3.length) for (var n3 = Object.keys(r4), i2 = 0; i2 < n3.length; i2 += 1) {
  1964. var o3 = n3[i2].toLowerCase();
  1965. if (t2.indexOf(o3) !== -1 && r4[o3]) return e3.concat(r4);
  1966. }
  1967. return e3;
  1968. }, []);
  1969. }, C = function(t2, e2, r4) {
  1970. var n3 = {};
  1971. return r4.filter(function(e3) {
  1972. 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);
  1973. }).map(function(e3) {
  1974. return e3[t2];
  1975. }).reverse().reduce(function(t3, r5) {
  1976. var i2 = {};
  1977. r5.filter(function(t4) {
  1978. for (var r6, o4 = Object.keys(t4), a2 = 0; a2 < o4.length; a2 += 1) {
  1979. var s3 = o4[a2], c3 = s3.toLowerCase();
  1980. 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);
  1981. }
  1982. if (!r6 || !t4[r6]) return !1;
  1983. var u3 = t4[r6].toLowerCase();
  1984. return n3[r6] || (n3[r6] = {}), i2[r6] || (i2[r6] = {}), !n3[r6][u3] && (i2[r6][u3] = !0, !0);
  1985. }).reverse().forEach(function(e3) {
  1986. return t3.push(e3);
  1987. });
  1988. for (var o3 = Object.keys(i2), s2 = 0; s2 < o3.length; s2 += 1) {
  1989. var c2 = o3[s2], u2 = a({}, n3[c2], i2[c2]);
  1990. n3[c2] = u2;
  1991. }
  1992. return t3;
  1993. }, []).reverse();
  1994. }, O = function(t2, e2) {
  1995. if (Array.isArray(t2) && t2.length) {
  1996. for (var r4 = 0; r4 < t2.length; r4 += 1) if (t2[r4][e2]) return !0;
  1997. }
  1998. return !1;
  1999. }, S = function(t2) {
  2000. return Array.isArray(t2) ? t2.join("") : t2;
  2001. }, E = function(t2, e2) {
  2002. return Array.isArray(t2) ? t2.reduce(function(t3, r4) {
  2003. return (function(t4, e3) {
  2004. 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;
  2005. return !1;
  2006. })(r4, e2) ? t3.priority.push(r4) : t3.default.push(r4), t3;
  2007. }, { priority: [], default: [] }) : { default: t2 };
  2008. }, I = function(t2, e2) {
  2009. var r4;
  2010. return a({}, t2, ((r4 = {})[e2] = void 0, r4));
  2011. }, P2 = [l.NOSCRIPT, l.SCRIPT, l.STYLE], w = function(t2, e2) {
  2012. 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;");
  2013. }, x = function(t2) {
  2014. return Object.keys(t2).reduce(function(e2, r4) {
  2015. var n3 = t2[r4] !== void 0 ? r4 + '="' + t2[r4] + '"' : "" + r4;
  2016. return e2 ? e2 + " " + n3 : n3;
  2017. }, "");
  2018. }, L = function(t2, e2) {
  2019. return e2 === void 0 && (e2 = {}), Object.keys(t2).reduce(function(e3, r4) {
  2020. return e3[m[r4] || r4] = t2[r4], e3;
  2021. }, e2);
  2022. }, j = function(e2, r4) {
  2023. return r4.map(function(r5, n3) {
  2024. var i2, o3 = ((i2 = { key: n3 })["data-rh"] = !0, i2);
  2025. return Object.keys(r5).forEach(function(t2) {
  2026. var e3 = m[t2] || t2;
  2027. e3 === "innerHTML" || e3 === "cssText" ? o3.dangerouslySetInnerHTML = { __html: r5.innerHTML || r5.cssText } : o3[e3] = r5[t2];
  2028. }), react_default.createElement(e2, o3);
  2029. });
  2030. }, M = function(e2, r4, n3) {
  2031. switch (e2) {
  2032. case l.TITLE:
  2033. return { toComponent: function() {
  2034. return n4 = r4.titleAttributes, (i2 = { key: e3 = r4.title })["data-rh"] = !0, o3 = L(n4, i2), [react_default.createElement(l.TITLE, o3, e3)];
  2035. var e3, n4, i2, o3;
  2036. }, toString: function() {
  2037. return (function(t2, e3, r5, n4) {
  2038. var i2 = x(r5), o3 = S(e3);
  2039. return i2 ? "<" + t2 + ' data-rh="true" ' + i2 + ">" + w(o3, n4) + "</" + t2 + ">" : "<" + t2 + ' data-rh="true">' + w(o3, n4) + "</" + t2 + ">";
  2040. })(e2, r4.title, r4.titleAttributes, n3);
  2041. } };
  2042. case "bodyAttributes":
  2043. case "htmlAttributes":
  2044. return { toComponent: function() {
  2045. return L(r4);
  2046. }, toString: function() {
  2047. return x(r4);
  2048. } };
  2049. default:
  2050. return { toComponent: function() {
  2051. return j(e2, r4);
  2052. }, toString: function() {
  2053. return (function(t2, e3, r5) {
  2054. return e3.reduce(function(e4, n4) {
  2055. var i2 = Object.keys(n4).filter(function(t3) {
  2056. return !(t3 === "innerHTML" || t3 === "cssText");
  2057. }).reduce(function(t3, e5) {
  2058. var i3 = n4[e5] === void 0 ? e5 : e5 + '="' + w(n4[e5], r5) + '"';
  2059. return t3 ? t3 + " " + i3 : i3;
  2060. }, ""), o3 = n4.innerHTML || n4.cssText || "", a2 = P2.indexOf(t2) === -1;
  2061. return e4 + "<" + t2 + ' data-rh="true" ' + i2 + (a2 ? "/>" : ">" + o3 + "</" + t2 + ">");
  2062. }, "");
  2063. })(e2, r4, n3);
  2064. } };
  2065. }
  2066. }, k = function(t2) {
  2067. 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() {
  2068. }, toString: function() {
  2069. return "";
  2070. } };
  2071. if (t2.prioritizeSeoTags) {
  2072. var g2 = (function(t3) {
  2073. var e3 = t3.linkTags, r5 = t3.scriptTags, n4 = t3.encode, i3 = E(t3.metaTags, d), o4 = E(e3, p), a3 = E(r5, f);
  2074. return { priorityMethods: { toComponent: function() {
  2075. return [].concat(j(l.META, i3.priority), j(l.LINK, o4.priority), j(l.SCRIPT, a3.priority));
  2076. }, toString: function() {
  2077. return M(l.META, i3.priority, n4) + " " + M(l.LINK, o4.priority, n4) + " " + M(l.SCRIPT, a3.priority, n4);
  2078. } }, metaTags: i3.default, linkTags: o4.default, scriptTags: a3.default };
  2079. })(t2);
  2080. T3 = g2.priorityMethods, h2 = g2.linkTags, m2 = g2.metaTags, y2 = g2.scriptTags;
  2081. }
  2082. 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) };
  2083. }, H = [], N = function(t2, e2) {
  2084. var r4 = this;
  2085. e2 === void 0 && (e2 = typeof document < "u"), this.instances = [], this.value = { setHelmet: function(t3) {
  2086. r4.context.helmet = t3;
  2087. }, helmetInstances: { get: function() {
  2088. return r4.canUseDOM ? H : r4.instances;
  2089. }, add: function(t3) {
  2090. (r4.canUseDOM ? H : r4.instances).push(t3);
  2091. }, remove: function(t3) {
  2092. var e3 = (r4.canUseDOM ? H : r4.instances).indexOf(t3);
  2093. (r4.canUseDOM ? H : r4.instances).splice(e3, 1);
  2094. } } }, this.context = t2, this.canUseDOM = e2, e2 || (t2.helmet = k({ baseTag: [], bodyAttributes: {}, encodeSpecialCharacters: !0, htmlAttributes: {}, linkTags: [], metaTags: [], noscriptTags: [], scriptTags: [], styleTags: [], title: "", titleAttributes: {} }));
  2095. }, 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) {
  2096. function r4(t2) {
  2097. var n3;
  2098. return (n3 = e2.call(this, t2) || this).helmetData = new N(n3.props.context, r4.canUseDOM), n3;
  2099. }
  2100. return s(r4, e2), r4.prototype.render = function() {
  2101. return react_default.createElement(R.Provider, { value: this.helmetData.value }, this.props.children);
  2102. }, r4;
  2103. })(Component);
  2104. 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";
  2105. var Y = function(t2, e2) {
  2106. var r4, n3 = document.head || document.querySelector(l.HEAD), i2 = n3.querySelectorAll(t2 + "[data-rh]"), o3 = [].slice.call(i2), a2 = [];
  2107. return e2 && e2.length && e2.forEach(function(e3) {
  2108. var n4 = document.createElement(t2);
  2109. 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]));
  2110. n4.setAttribute("data-rh", "true"), o3.some(function(t3, e4) {
  2111. return r4 = e4, n4.isEqualNode(t3);
  2112. }) ? o3.splice(r4, 1) : a2.push(n4);
  2113. }), o3.forEach(function(t3) {
  2114. return t3.parentNode.removeChild(t3);
  2115. }), a2.forEach(function(t3) {
  2116. return n3.appendChild(t3);
  2117. }), { oldTags: o3, newTags: a2 };
  2118. }, B = function(t2, e2) {
  2119. var r4 = document.getElementsByTagName(t2)[0];
  2120. if (r4) {
  2121. 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) {
  2122. var c2 = a2[s2], u2 = e2[c2] || "";
  2123. r4.getAttribute(c2) !== u2 && r4.setAttribute(c2, u2), i2.indexOf(c2) === -1 && i2.push(c2);
  2124. var l3 = o3.indexOf(c2);
  2125. l3 !== -1 && o3.splice(l3, 1);
  2126. }
  2127. for (var p2 = o3.length - 1; p2 >= 0; p2 -= 1) r4.removeAttribute(o3[p2]);
  2128. i2.length === o3.length ? r4.removeAttribute("data-rh") : r4.getAttribute("data-rh") !== a2.join(",") && r4.setAttribute("data-rh", a2.join(","));
  2129. }
  2130. }, K = function(t2, e2) {
  2131. 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;
  2132. B(l.BODY, t2.bodyAttributes), B(l.HTML, n3), (function(t3, e3) {
  2133. t3 !== void 0 && document.title !== t3 && (document.title = S(t3)), B(l.TITLE, e3);
  2134. })(p2, f2);
  2135. 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 = {};
  2136. Object.keys(d2).forEach(function(t3) {
  2137. var e3 = d2[t3], r5 = e3.newTags, n4 = e3.oldTags;
  2138. r5.length && (h2[t3] = r5), n4.length && (m2[t3] = d2[t3].oldTags);
  2139. }), e2 && e2(), s2(t2, h2, m2);
  2140. }, _ = null, z = (function(t2) {
  2141. function e2() {
  2142. for (var e3, r5 = arguments.length, n3 = new Array(r5), i2 = 0; i2 < r5; i2++) n3[i2] = arguments[i2];
  2143. return (e3 = t2.call.apply(t2, [this].concat(n3)) || this).rendered = !1, e3;
  2144. }
  2145. s(e2, t2);
  2146. var r4 = e2.prototype;
  2147. return r4.shouldComponentUpdate = function(t3) {
  2148. return !(0, import_shallowequal.default)(t3, this.props);
  2149. }, r4.componentDidUpdate = function() {
  2150. this.emitChange();
  2151. }, r4.componentWillUnmount = function() {
  2152. this.props.context.helmetInstances.remove(this), this.emitChange();
  2153. }, r4.emitChange = function() {
  2154. var t3, e3, r5 = this.props.context, n3 = r5.setHelmet, i2 = null, o3 = (t3 = r5.helmetInstances.get().map(function(t4) {
  2155. var e4 = a({}, t4.props);
  2156. return delete e4.context, e4;
  2157. }), { 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") });
  2158. q.canUseDOM ? (e3 = o3, _ && cancelAnimationFrame(_), e3.defer ? _ = requestAnimationFrame(function() {
  2159. K(e3, function() {
  2160. _ = null;
  2161. });
  2162. }) : (K(e3), _ = null)) : k && (i2 = k(o3)), n3(i2);
  2163. }, r4.init = function() {
  2164. this.rendered || (this.rendered = !0, this.props.context.helmetInstances.add(this), this.emitChange());
  2165. }, r4.render = function() {
  2166. return this.init(), null;
  2167. }, e2;
  2168. })(Component);
  2169. z.propTypes = { context: D.isRequired }, z.displayName = "HelmetDispatcher";
  2170. var F = ["children"], G = ["children"], W = (function(e2) {
  2171. function r4() {
  2172. return e2.apply(this, arguments) || this;
  2173. }
  2174. s(r4, e2);
  2175. var o3 = r4.prototype;
  2176. return o3.shouldComponentUpdate = function(t2) {
  2177. return !(0, import_react_fast_compare.default)(I(this.props, "helmetData"), I(t2, "helmetData"));
  2178. }, o3.mapNestedChildrenToProps = function(t2, e3) {
  2179. if (!e3) return null;
  2180. switch (t2.type) {
  2181. case l.SCRIPT:
  2182. case l.NOSCRIPT:
  2183. return { innerHTML: e3 };
  2184. case l.STYLE:
  2185. return { cssText: e3 };
  2186. default:
  2187. throw new Error("<" + t2.type + " /> elements are self-closing and can not contain children. Refer to our API for more information.");
  2188. }
  2189. }, o3.flattenArrayTypeChildren = function(t2) {
  2190. var e3, r5 = t2.child, n3 = t2.arrayTypeChildren;
  2191. return a({}, n3, ((e3 = {})[r5.type] = [].concat(n3[r5.type] || [], [a({}, t2.newChildProps, this.mapNestedChildrenToProps(r5, t2.nestedChildren))]), e3));
  2192. }, o3.mapObjectTypeChildren = function(t2) {
  2193. var e3, r5, n3 = t2.child, i2 = t2.newProps, o4 = t2.newChildProps, s2 = t2.nestedChildren;
  2194. switch (n3.type) {
  2195. case l.TITLE:
  2196. return a({}, i2, ((e3 = {})[n3.type] = s2, e3.titleAttributes = a({}, o4), e3));
  2197. case l.BODY:
  2198. return a({}, i2, { bodyAttributes: a({}, o4) });
  2199. case l.HTML:
  2200. return a({}, i2, { htmlAttributes: a({}, o4) });
  2201. default:
  2202. return a({}, i2, ((r5 = {})[n3.type] = a({}, o4), r5));
  2203. }
  2204. }, o3.mapArrayTypeChildrenToProps = function(t2, e3) {
  2205. var r5 = a({}, e3);
  2206. return Object.keys(t2).forEach(function(e4) {
  2207. var n3;
  2208. r5 = a({}, r5, ((n3 = {})[e4] = t2[e4], n3));
  2209. }), r5;
  2210. }, o3.warnOnInvalidChildren = function(t2, e3) {
  2211. return (0, import_invariant.default)(h.some(function(e4) {
  2212. return t2.type === e4;
  2213. }), 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) {
  2214. return typeof t3 != "string";
  2215. }), "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;
  2216. }, o3.mapChildrenToProps = function(e3, r5) {
  2217. var n3 = this, i2 = {};
  2218. return react_default.Children.forEach(e3, function(t2) {
  2219. if (t2 && t2.props) {
  2220. var e4 = t2.props, o4 = e4.children, a2 = u(e4, F), s2 = Object.keys(a2).reduce(function(t3, e5) {
  2221. return t3[y[e5] || e5] = a2[e5], t3;
  2222. }, {}), c2 = t2.type;
  2223. switch (typeof c2 == "symbol" ? c2 = c2.toString() : n3.warnOnInvalidChildren(t2, o4), c2) {
  2224. case l.FRAGMENT:
  2225. r5 = n3.mapChildrenToProps(o4, r5);
  2226. break;
  2227. case l.LINK:
  2228. case l.META:
  2229. case l.NOSCRIPT:
  2230. case l.SCRIPT:
  2231. case l.STYLE:
  2232. i2 = n3.flattenArrayTypeChildren({ child: t2, arrayTypeChildren: i2, newChildProps: s2, nestedChildren: o4 });
  2233. break;
  2234. default:
  2235. r5 = n3.mapObjectTypeChildren({ child: t2, newProps: r5, newChildProps: s2, nestedChildren: o4 });
  2236. }
  2237. }
  2238. }), this.mapArrayTypeChildrenToProps(i2, r5);
  2239. }, o3.render = function() {
  2240. var e3 = this.props, r5 = e3.children, n3 = u(e3, G), i2 = a({}, n3), o4 = n3.helmetData;
  2241. 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) {
  2242. return react_default.createElement(z, a({}, i2, { context: e4 }));
  2243. });
  2244. }, r4;
  2245. })(Component);
  2246. 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";
  2247. // src/manager/App.tsx
  2248. init_react();
  2249. // src/manager/components/error-boundary/ManagerErrorBoundary.tsx
  2250. init_react();
  2251. // ../../node_modules/@babel/runtime/helpers/esm/extends.js
  2252. function _extends() {
  2253. return _extends = Object.assign ? Object.assign.bind() : function(n3) {
  2254. for (var e2 = 1; e2 < arguments.length; e2++) {
  2255. var t2 = arguments[e2];
  2256. for (var r4 in t2) ({}).hasOwnProperty.call(t2, r4) && (n3[r4] = t2[r4]);
  2257. }
  2258. return n3;
  2259. }, _extends.apply(null, arguments);
  2260. }
  2261. // ../../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
  2262. function _assertThisInitialized(e2) {
  2263. if (e2 === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  2264. return e2;
  2265. }
  2266. // ../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
  2267. function _setPrototypeOf(t2, e2) {
  2268. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t3, e3) {
  2269. return t3.__proto__ = e3, t3;
  2270. }, _setPrototypeOf(t2, e2);
  2271. }
  2272. // ../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
  2273. function _inheritsLoose(t2, o3) {
  2274. t2.prototype = Object.create(o3.prototype), t2.prototype.constructor = t2, _setPrototypeOf(t2, o3);
  2275. }
  2276. // ../../node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
  2277. function _getPrototypeOf(t2) {
  2278. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t3) {
  2279. return t3.__proto__ || Object.getPrototypeOf(t3);
  2280. }, _getPrototypeOf(t2);
  2281. }
  2282. // ../../node_modules/@babel/runtime/helpers/esm/isNativeFunction.js
  2283. function _isNativeFunction(t2) {
  2284. try {
  2285. return Function.toString.call(t2).indexOf("[native code]") !== -1;
  2286. } catch {
  2287. return typeof t2 == "function";
  2288. }
  2289. }
  2290. // ../../node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js
  2291. function _isNativeReflectConstruct() {
  2292. try {
  2293. var t2 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
  2294. }));
  2295. } catch {
  2296. }
  2297. return (_isNativeReflectConstruct = function() {
  2298. return !!t2;
  2299. })();
  2300. }
  2301. // ../../node_modules/@babel/runtime/helpers/esm/construct.js
  2302. function _construct(t2, e2, r4) {
  2303. if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
  2304. var o3 = [null];
  2305. o3.push.apply(o3, e2);
  2306. var p2 = new (t2.bind.apply(t2, o3))();
  2307. return r4 && _setPrototypeOf(p2, r4.prototype), p2;
  2308. }
  2309. // ../../node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js
  2310. function _wrapNativeSuper(t2) {
  2311. var r4 = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
  2312. return _wrapNativeSuper = function(t3) {
  2313. if (t3 === null || !_isNativeFunction(t3)) return t3;
  2314. if (typeof t3 != "function") throw new TypeError("Super expression must either be null or a function");
  2315. if (r4 !== void 0) {
  2316. if (r4.has(t3)) return r4.get(t3);
  2317. r4.set(t3, Wrapper9);
  2318. }
  2319. function Wrapper9() {
  2320. return _construct(t3, arguments, _getPrototypeOf(this).constructor);
  2321. }
  2322. return Wrapper9.prototype = Object.create(t3.prototype, {
  2323. constructor: {
  2324. value: Wrapper9,
  2325. enumerable: !1,
  2326. writable: !0,
  2327. configurable: !0
  2328. }
  2329. }), _setPrototypeOf(Wrapper9, t3);
  2330. }, _wrapNativeSuper(t2);
  2331. }
  2332. // ../../node_modules/polished/dist/polished.esm.js
  2333. var PolishedError = (function(_Error) {
  2334. _inheritsLoose(PolishedError2, _Error);
  2335. function PolishedError2(code) {
  2336. var _this;
  2337. if (1)
  2338. _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;
  2339. else
  2340. for (var _len2, args, _key2; _key2 < _len2; _key2++)
  2341. ;
  2342. return _assertThisInitialized(_this);
  2343. }
  2344. return PolishedError2;
  2345. })(_wrapNativeSuper(Error));
  2346. function endsWith(string, suffix) {
  2347. return string.substr(-suffix.length) === suffix;
  2348. }
  2349. var cssRegex$1 = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
  2350. function stripUnit(value) {
  2351. if (typeof value != "string") return value;
  2352. var matchedValue = value.match(cssRegex$1);
  2353. return matchedValue ? parseFloat(value) : value;
  2354. }
  2355. var pxtoFactory = function(to) {
  2356. return function(pxval, base) {
  2357. base === void 0 && (base = "16px");
  2358. var newPxval = pxval, newBase = base;
  2359. if (typeof pxval == "string") {
  2360. if (!endsWith(pxval, "px"))
  2361. throw new PolishedError(69, to, pxval);
  2362. newPxval = stripUnit(pxval);
  2363. }
  2364. if (typeof base == "string") {
  2365. if (!endsWith(base, "px"))
  2366. throw new PolishedError(70, to, base);
  2367. newBase = stripUnit(base);
  2368. }
  2369. if (typeof newPxval == "string")
  2370. throw new PolishedError(71, pxval, to);
  2371. if (typeof newBase == "string")
  2372. throw new PolishedError(72, base, to);
  2373. return "" + newPxval / newBase + to;
  2374. };
  2375. }, pixelsto = pxtoFactory, em = pixelsto("em");
  2376. var rem = pixelsto("rem");
  2377. function colorToInt(color2) {
  2378. return Math.round(color2 * 255);
  2379. }
  2380. function convertToInt(red, green, blue) {
  2381. return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
  2382. }
  2383. function hslToRgb(hue, saturation, lightness, convert2) {
  2384. if (convert2 === void 0 && (convert2 = convertToInt), saturation === 0)
  2385. return convert2(lightness, lightness, lightness);
  2386. 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;
  2387. 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);
  2388. var lightnessModification = lightness - chroma / 2, finalRed = red + lightnessModification, finalGreen = green + lightnessModification, finalBlue = blue + lightnessModification;
  2389. return convert2(finalRed, finalGreen, finalBlue);
  2390. }
  2391. var namedColorMap = {
  2392. aliceblue: "f0f8ff",
  2393. antiquewhite: "faebd7",
  2394. aqua: "00ffff",
  2395. aquamarine: "7fffd4",
  2396. azure: "f0ffff",
  2397. beige: "f5f5dc",
  2398. bisque: "ffe4c4",
  2399. black: "000",
  2400. blanchedalmond: "ffebcd",
  2401. blue: "0000ff",
  2402. blueviolet: "8a2be2",
  2403. brown: "a52a2a",
  2404. burlywood: "deb887",
  2405. cadetblue: "5f9ea0",
  2406. chartreuse: "7fff00",
  2407. chocolate: "d2691e",
  2408. coral: "ff7f50",
  2409. cornflowerblue: "6495ed",
  2410. cornsilk: "fff8dc",
  2411. crimson: "dc143c",
  2412. cyan: "00ffff",
  2413. darkblue: "00008b",
  2414. darkcyan: "008b8b",
  2415. darkgoldenrod: "b8860b",
  2416. darkgray: "a9a9a9",
  2417. darkgreen: "006400",
  2418. darkgrey: "a9a9a9",
  2419. darkkhaki: "bdb76b",
  2420. darkmagenta: "8b008b",
  2421. darkolivegreen: "556b2f",
  2422. darkorange: "ff8c00",
  2423. darkorchid: "9932cc",
  2424. darkred: "8b0000",
  2425. darksalmon: "e9967a",
  2426. darkseagreen: "8fbc8f",
  2427. darkslateblue: "483d8b",
  2428. darkslategray: "2f4f4f",
  2429. darkslategrey: "2f4f4f",
  2430. darkturquoise: "00ced1",
  2431. darkviolet: "9400d3",
  2432. deeppink: "ff1493",
  2433. deepskyblue: "00bfff",
  2434. dimgray: "696969",
  2435. dimgrey: "696969",
  2436. dodgerblue: "1e90ff",
  2437. firebrick: "b22222",
  2438. floralwhite: "fffaf0",
  2439. forestgreen: "228b22",
  2440. fuchsia: "ff00ff",
  2441. gainsboro: "dcdcdc",
  2442. ghostwhite: "f8f8ff",
  2443. gold: "ffd700",
  2444. goldenrod: "daa520",
  2445. gray: "808080",
  2446. green: "008000",
  2447. greenyellow: "adff2f",
  2448. grey: "808080",
  2449. honeydew: "f0fff0",
  2450. hotpink: "ff69b4",
  2451. indianred: "cd5c5c",
  2452. indigo: "4b0082",
  2453. ivory: "fffff0",
  2454. khaki: "f0e68c",
  2455. lavender: "e6e6fa",
  2456. lavenderblush: "fff0f5",
  2457. lawngreen: "7cfc00",
  2458. lemonchiffon: "fffacd",
  2459. lightblue: "add8e6",
  2460. lightcoral: "f08080",
  2461. lightcyan: "e0ffff",
  2462. lightgoldenrodyellow: "fafad2",
  2463. lightgray: "d3d3d3",
  2464. lightgreen: "90ee90",
  2465. lightgrey: "d3d3d3",
  2466. lightpink: "ffb6c1",
  2467. lightsalmon: "ffa07a",
  2468. lightseagreen: "20b2aa",
  2469. lightskyblue: "87cefa",
  2470. lightslategray: "789",
  2471. lightslategrey: "789",
  2472. lightsteelblue: "b0c4de",
  2473. lightyellow: "ffffe0",
  2474. lime: "0f0",
  2475. limegreen: "32cd32",
  2476. linen: "faf0e6",
  2477. magenta: "f0f",
  2478. maroon: "800000",
  2479. mediumaquamarine: "66cdaa",
  2480. mediumblue: "0000cd",
  2481. mediumorchid: "ba55d3",
  2482. mediumpurple: "9370db",
  2483. mediumseagreen: "3cb371",
  2484. mediumslateblue: "7b68ee",
  2485. mediumspringgreen: "00fa9a",
  2486. mediumturquoise: "48d1cc",
  2487. mediumvioletred: "c71585",
  2488. midnightblue: "191970",
  2489. mintcream: "f5fffa",
  2490. mistyrose: "ffe4e1",
  2491. moccasin: "ffe4b5",
  2492. navajowhite: "ffdead",
  2493. navy: "000080",
  2494. oldlace: "fdf5e6",
  2495. olive: "808000",
  2496. olivedrab: "6b8e23",
  2497. orange: "ffa500",
  2498. orangered: "ff4500",
  2499. orchid: "da70d6",
  2500. palegoldenrod: "eee8aa",
  2501. palegreen: "98fb98",
  2502. paleturquoise: "afeeee",
  2503. palevioletred: "db7093",
  2504. papayawhip: "ffefd5",
  2505. peachpuff: "ffdab9",
  2506. peru: "cd853f",
  2507. pink: "ffc0cb",
  2508. plum: "dda0dd",
  2509. powderblue: "b0e0e6",
  2510. purple: "800080",
  2511. rebeccapurple: "639",
  2512. red: "f00",
  2513. rosybrown: "bc8f8f",
  2514. royalblue: "4169e1",
  2515. saddlebrown: "8b4513",
  2516. salmon: "fa8072",
  2517. sandybrown: "f4a460",
  2518. seagreen: "2e8b57",
  2519. seashell: "fff5ee",
  2520. sienna: "a0522d",
  2521. silver: "c0c0c0",
  2522. skyblue: "87ceeb",
  2523. slateblue: "6a5acd",
  2524. slategray: "708090",
  2525. slategrey: "708090",
  2526. snow: "fffafa",
  2527. springgreen: "00ff7f",
  2528. steelblue: "4682b4",
  2529. tan: "d2b48c",
  2530. teal: "008080",
  2531. thistle: "d8bfd8",
  2532. tomato: "ff6347",
  2533. turquoise: "40e0d0",
  2534. violet: "ee82ee",
  2535. wheat: "f5deb3",
  2536. white: "fff",
  2537. whitesmoke: "f5f5f5",
  2538. yellow: "ff0",
  2539. yellowgreen: "9acd32"
  2540. };
  2541. function nameToHex(color2) {
  2542. if (typeof color2 != "string") return color2;
  2543. var normalizedColorName = color2.toLowerCase();
  2544. return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color2;
  2545. }
  2546. 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;
  2547. function parseToRgb(color2) {
  2548. if (typeof color2 != "string")
  2549. throw new PolishedError(3);
  2550. var normalizedColor = nameToHex(color2);
  2551. if (normalizedColor.match(hexRegex))
  2552. return {
  2553. red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
  2554. green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
  2555. blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
  2556. };
  2557. if (normalizedColor.match(hexRgbaRegex)) {
  2558. var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
  2559. return {
  2560. red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
  2561. green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
  2562. blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
  2563. alpha
  2564. };
  2565. }
  2566. if (normalizedColor.match(reducedHexRegex))
  2567. return {
  2568. red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
  2569. green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
  2570. blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
  2571. };
  2572. if (normalizedColor.match(reducedRgbaHexRegex)) {
  2573. var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
  2574. return {
  2575. red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
  2576. green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
  2577. blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
  2578. alpha: _alpha
  2579. };
  2580. }
  2581. var rgbMatched = rgbRegex.exec(normalizedColor);
  2582. if (rgbMatched)
  2583. return {
  2584. red: parseInt("" + rgbMatched[1], 10),
  2585. green: parseInt("" + rgbMatched[2], 10),
  2586. blue: parseInt("" + rgbMatched[3], 10)
  2587. };
  2588. var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
  2589. if (rgbaMatched)
  2590. return {
  2591. red: parseInt("" + rgbaMatched[1], 10),
  2592. green: parseInt("" + rgbaMatched[2], 10),
  2593. blue: parseInt("" + rgbaMatched[3], 10),
  2594. alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
  2595. };
  2596. var hslMatched = hslRegex.exec(normalizedColor);
  2597. if (hslMatched) {
  2598. 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);
  2599. if (!hslRgbMatched)
  2600. throw new PolishedError(4, normalizedColor, rgbColorString);
  2601. return {
  2602. red: parseInt("" + hslRgbMatched[1], 10),
  2603. green: parseInt("" + hslRgbMatched[2], 10),
  2604. blue: parseInt("" + hslRgbMatched[3], 10)
  2605. };
  2606. }
  2607. var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
  2608. if (hslaMatched) {
  2609. 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);
  2610. if (!_hslRgbMatched)
  2611. throw new PolishedError(4, normalizedColor, _rgbColorString);
  2612. return {
  2613. red: parseInt("" + _hslRgbMatched[1], 10),
  2614. green: parseInt("" + _hslRgbMatched[2], 10),
  2615. blue: parseInt("" + _hslRgbMatched[3], 10),
  2616. alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
  2617. };
  2618. }
  2619. throw new PolishedError(5);
  2620. }
  2621. function rgbToHsl(color2) {
  2622. 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;
  2623. if (max === min)
  2624. return color2.alpha !== void 0 ? {
  2625. hue: 0,
  2626. saturation: 0,
  2627. lightness,
  2628. alpha: color2.alpha
  2629. } : {
  2630. hue: 0,
  2631. saturation: 0,
  2632. lightness
  2633. };
  2634. var hue, delta = max - min, saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
  2635. switch (max) {
  2636. case red:
  2637. hue = (green - blue) / delta + (green < blue ? 6 : 0);
  2638. break;
  2639. case green:
  2640. hue = (blue - red) / delta + 2;
  2641. break;
  2642. default:
  2643. hue = (red - green) / delta + 4;
  2644. break;
  2645. }
  2646. return hue *= 60, color2.alpha !== void 0 ? {
  2647. hue,
  2648. saturation,
  2649. lightness,
  2650. alpha: color2.alpha
  2651. } : {
  2652. hue,
  2653. saturation,
  2654. lightness
  2655. };
  2656. }
  2657. function parseToHsl(color2) {
  2658. return rgbToHsl(parseToRgb(color2));
  2659. }
  2660. var reduceHexValue = function(value) {
  2661. return value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6] ? "#" + value[1] + value[3] + value[5] : value;
  2662. }, reduceHexValue$1 = reduceHexValue;
  2663. function numberToHex(value) {
  2664. var hex = value.toString(16);
  2665. return hex.length === 1 ? "0" + hex : hex;
  2666. }
  2667. function colorToHex(color2) {
  2668. return numberToHex(Math.round(color2 * 255));
  2669. }
  2670. function convertToHex(red, green, blue) {
  2671. return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
  2672. }
  2673. function hslToHex(hue, saturation, lightness) {
  2674. return hslToRgb(hue, saturation, lightness, convertToHex);
  2675. }
  2676. function hsl(value, saturation, lightness) {
  2677. if (typeof value == "number" && typeof saturation == "number" && typeof lightness == "number")
  2678. return hslToHex(value, saturation, lightness);
  2679. if (typeof value == "object" && saturation === void 0 && lightness === void 0)
  2680. return hslToHex(value.hue, value.saturation, value.lightness);
  2681. throw new PolishedError(1);
  2682. }
  2683. function hsla(value, saturation, lightness, alpha) {
  2684. if (typeof value == "number" && typeof saturation == "number" && typeof lightness == "number" && typeof alpha == "number")
  2685. return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
  2686. if (typeof value == "object" && saturation === void 0 && lightness === void 0 && alpha === void 0)
  2687. return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
  2688. throw new PolishedError(2);
  2689. }
  2690. function rgb(value, green, blue) {
  2691. if (typeof value == "number" && typeof green == "number" && typeof blue == "number")
  2692. return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
  2693. if (typeof value == "object" && green === void 0 && blue === void 0)
  2694. return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
  2695. throw new PolishedError(6);
  2696. }
  2697. function rgba(firstValue, secondValue, thirdValue, fourthValue) {
  2698. if (typeof firstValue == "string" && typeof secondValue == "number") {
  2699. var rgbValue = parseToRgb(firstValue);
  2700. return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
  2701. } else {
  2702. if (typeof firstValue == "number" && typeof secondValue == "number" && typeof thirdValue == "number" && typeof fourthValue == "number")
  2703. return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
  2704. if (typeof firstValue == "object" && secondValue === void 0 && thirdValue === void 0 && fourthValue === void 0)
  2705. return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
  2706. }
  2707. throw new PolishedError(7);
  2708. }
  2709. var isRgb = function(color2) {
  2710. return typeof color2.red == "number" && typeof color2.green == "number" && typeof color2.blue == "number" && (typeof color2.alpha != "number" || typeof color2.alpha > "u");
  2711. }, isRgba = function(color2) {
  2712. return typeof color2.red == "number" && typeof color2.green == "number" && typeof color2.blue == "number" && typeof color2.alpha == "number";
  2713. }, isHsl = function(color2) {
  2714. return typeof color2.hue == "number" && typeof color2.saturation == "number" && typeof color2.lightness == "number" && (typeof color2.alpha != "number" || typeof color2.alpha > "u");
  2715. }, isHsla = function(color2) {
  2716. return typeof color2.hue == "number" && typeof color2.saturation == "number" && typeof color2.lightness == "number" && typeof color2.alpha == "number";
  2717. };
  2718. function toColorString(color2) {
  2719. if (typeof color2 != "object") throw new PolishedError(8);
  2720. if (isRgba(color2)) return rgba(color2);
  2721. if (isRgb(color2)) return rgb(color2);
  2722. if (isHsla(color2)) return hsla(color2);
  2723. if (isHsl(color2)) return hsl(color2);
  2724. throw new PolishedError(8);
  2725. }
  2726. function curried(f2, length, acc) {
  2727. return function() {
  2728. var combined = acc.concat(Array.prototype.slice.call(arguments));
  2729. return combined.length >= length ? f2.apply(this, combined) : curried(f2, length, combined);
  2730. };
  2731. }
  2732. function curry(f2) {
  2733. return curried(f2, f2.length, []);
  2734. }
  2735. function adjustHue(degree, color2) {
  2736. if (color2 === "transparent") return color2;
  2737. var hslColor = parseToHsl(color2);
  2738. return toColorString(_extends({}, hslColor, {
  2739. hue: hslColor.hue + parseFloat(degree)
  2740. }));
  2741. }
  2742. var curriedAdjustHue = curry(adjustHue);
  2743. function guard(lowerBoundary, upperBoundary, value) {
  2744. return Math.max(lowerBoundary, Math.min(upperBoundary, value));
  2745. }
  2746. function darken2(amount, color2) {
  2747. if (color2 === "transparent") return color2;
  2748. var hslColor = parseToHsl(color2);
  2749. return toColorString(_extends({}, hslColor, {
  2750. lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
  2751. }));
  2752. }
  2753. var curriedDarken = curry(darken2), curriedDarken$1 = curriedDarken;
  2754. function desaturate(amount, color2) {
  2755. if (color2 === "transparent") return color2;
  2756. var hslColor = parseToHsl(color2);
  2757. return toColorString(_extends({}, hslColor, {
  2758. saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
  2759. }));
  2760. }
  2761. var curriedDesaturate = curry(desaturate);
  2762. function lighten2(amount, color2) {
  2763. if (color2 === "transparent") return color2;
  2764. var hslColor = parseToHsl(color2);
  2765. return toColorString(_extends({}, hslColor, {
  2766. lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
  2767. }));
  2768. }
  2769. var curriedLighten = curry(lighten2), curriedLighten$1 = curriedLighten;
  2770. function mix(weight, color2, otherColor) {
  2771. if (color2 === "transparent") return otherColor;
  2772. if (otherColor === "transparent") return color2;
  2773. if (weight === 0) return otherColor;
  2774. var parsedColor1 = parseToRgb(color2), color1 = _extends({}, parsedColor1, {
  2775. alpha: typeof parsedColor1.alpha == "number" ? parsedColor1.alpha : 1
  2776. }), parsedColor2 = parseToRgb(otherColor), color22 = _extends({}, parsedColor2, {
  2777. alpha: typeof parsedColor2.alpha == "number" ? parsedColor2.alpha : 1
  2778. }), 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 = {
  2779. red: Math.floor(color1.red * weight1 + color22.red * weight2),
  2780. green: Math.floor(color1.green * weight1 + color22.green * weight2),
  2781. blue: Math.floor(color1.blue * weight1 + color22.blue * weight2),
  2782. alpha: color1.alpha * parseFloat(weight) + color22.alpha * (1 - parseFloat(weight))
  2783. };
  2784. return rgba(mixedColor);
  2785. }
  2786. var curriedMix = curry(mix), mix$1 = curriedMix;
  2787. function opacify(amount, color2) {
  2788. if (color2 === "transparent") return color2;
  2789. var parsedColor = parseToRgb(color2), alpha = typeof parsedColor.alpha == "number" ? parsedColor.alpha : 1, colorWithAlpha = _extends({}, parsedColor, {
  2790. alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
  2791. });
  2792. return rgba(colorWithAlpha);
  2793. }
  2794. var curriedOpacify = curry(opacify);
  2795. function saturate(amount, color2) {
  2796. if (color2 === "transparent") return color2;
  2797. var hslColor = parseToHsl(color2);
  2798. return toColorString(_extends({}, hslColor, {
  2799. saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
  2800. }));
  2801. }
  2802. var curriedSaturate = curry(saturate);
  2803. function setHue(hue, color2) {
  2804. return color2 === "transparent" ? color2 : toColorString(_extends({}, parseToHsl(color2), {
  2805. hue: parseFloat(hue)
  2806. }));
  2807. }
  2808. var curriedSetHue = curry(setHue);
  2809. function setLightness(lightness, color2) {
  2810. return color2 === "transparent" ? color2 : toColorString(_extends({}, parseToHsl(color2), {
  2811. lightness: parseFloat(lightness)
  2812. }));
  2813. }
  2814. var curriedSetLightness = curry(setLightness);
  2815. function setSaturation(saturation, color2) {
  2816. return color2 === "transparent" ? color2 : toColorString(_extends({}, parseToHsl(color2), {
  2817. saturation: parseFloat(saturation)
  2818. }));
  2819. }
  2820. var curriedSetSaturation = curry(setSaturation);
  2821. function shade(percentage, color2) {
  2822. return color2 === "transparent" ? color2 : mix$1(parseFloat(percentage), "rgb(0, 0, 0)", color2);
  2823. }
  2824. var curriedShade = curry(shade);
  2825. function tint(percentage, color2) {
  2826. return color2 === "transparent" ? color2 : mix$1(parseFloat(percentage), "rgb(255, 255, 255)", color2);
  2827. }
  2828. var curriedTint = curry(tint);
  2829. function transparentize(amount, color2) {
  2830. if (color2 === "transparent") return color2;
  2831. var parsedColor = parseToRgb(color2), alpha = typeof parsedColor.alpha == "number" ? parsedColor.alpha : 1, colorWithAlpha = _extends({}, parsedColor, {
  2832. alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
  2833. });
  2834. return rgba(colorWithAlpha);
  2835. }
  2836. var curriedTransparentize = curry(transparentize), curriedTransparentize$1 = curriedTransparentize;
  2837. // src/manager/components/error-boundary/ManagerErrorBoundary.tsx
  2838. var Container = styled.div(({ theme }) => ({
  2839. display: "flex",
  2840. justifyContent: "center",
  2841. alignItems: "center",
  2842. width: "100vw",
  2843. height: "100vh",
  2844. backgroundColor: theme.background.app,
  2845. color: theme.color.defaultText,
  2846. fontFamily: theme.typography.fonts.base
  2847. })), Content = styled.div(({ theme }) => ({
  2848. display: "flex",
  2849. flexDirection: "column",
  2850. justifyContent: "space-between",
  2851. width: "80%",
  2852. height: "80%",
  2853. padding: 20,
  2854. gap: 20,
  2855. backgroundColor: theme.background.content,
  2856. borderRadius: theme.appBorderRadius,
  2857. border: `1px solid ${theme.color.negative}`,
  2858. boxShadow: "0 0 64px rgba(0, 0, 0, 0.1)",
  2859. overflow: "auto"
  2860. })), Info = styled.div(({ theme }) => ({
  2861. display: "flex",
  2862. flexDirection: "column",
  2863. alignItems: "start",
  2864. gap: 15
  2865. })), Heading = styled.h1(({ theme }) => ({
  2866. display: "flex",
  2867. alignItems: "center",
  2868. margin: 0,
  2869. gap: 10,
  2870. fontSize: theme.typography.size.s2,
  2871. fontWeight: theme.typography.weight.bold,
  2872. color: theme.color.defaultText
  2873. })), SubHeading = styled.p(({ theme }) => ({
  2874. fontSize: theme.typography.size.s2,
  2875. color: theme.textMutedColor,
  2876. margin: 0,
  2877. lineHeight: 1.4,
  2878. textWrap: "balance"
  2879. })), ErrorWrapper = styled.div(({ theme }) => ({
  2880. display: "flex",
  2881. flexDirection: "column-reverse",
  2882. width: "100%",
  2883. flex: "0 0 auto",
  2884. border: `1px solid ${theme.appBorderColor}`,
  2885. borderRadius: theme.appBorderRadius,
  2886. pre: {
  2887. borderRadius: 0
  2888. }
  2889. })), CollapseToggle = styled.div(({ theme }) => ({
  2890. flex: "0 0 auto",
  2891. display: "flex",
  2892. alignItems: "center",
  2893. gap: 10,
  2894. height: 40,
  2895. width: "100%",
  2896. padding: "0 10px",
  2897. cursor: "pointer",
  2898. fontSize: theme.typography.size.s2,
  2899. fontWeight: theme.typography.weight.bold,
  2900. color: theme.color.defaultText,
  2901. userSelect: "none",
  2902. "&:hover": {
  2903. backgroundColor: theme.base === "light" ? "rgba(0, 0, 0, 0.02)" : "rgba(255, 255, 255, 0.03)"
  2904. },
  2905. svg: {
  2906. color: theme.textMutedColor
  2907. }
  2908. })), ErrorMessage = styled.pre(({ theme }) => ({
  2909. order: 1,
  2910. padding: "11px 15px",
  2911. margin: 0,
  2912. fontSize: theme.typography.size.s1,
  2913. color: theme.color.negativeText,
  2914. backgroundColor: curriedTransparentize$1(theme.base === "light" ? 0.95 : 0.9, theme.color.negative),
  2915. borderBottom: `1px solid ${theme.appBorderColor}`,
  2916. whiteSpace: "pre-wrap",
  2917. wordBreak: "break-word",
  2918. fontFamily: theme.typography.fonts.mono,
  2919. lineHeight: "18px"
  2920. })), ErrorStack = styled.pre(({ theme }) => ({
  2921. padding: 15,
  2922. margin: 0,
  2923. fontSize: theme.typography.size.s1,
  2924. color: theme.textMutedColor,
  2925. borderBottom: `1px solid ${theme.appBorderColor}`,
  2926. borderRadius: 0,
  2927. whiteSpace: "pre-wrap",
  2928. wordBreak: "break-word",
  2929. fontFamily: theme.typography.fonts.mono
  2930. })), 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(
  2931. Collapsible,
  2932. {
  2933. collapsed: !0,
  2934. summary: ({ isCollapsed, toggleCollapsed }) => react_default.createElement(CollapseToggle, { onClick: toggleCollapsed }, react_default.createElement(UnfoldIcon, null), isCollapsed ? "Expand error" : "Collapse error")
  2935. },
  2936. (error.stack || errorInfo?.componentStack) && react_default.createElement(ErrorStack, null, error.stack, errorInfo?.componentStack && `
  2937. Component Stack:${errorInfo.componentStack}`)
  2938. )))), ManagerErrorBoundary = class extends Component {
  2939. constructor(props) {
  2940. super(props), this.state = { hasError: !1, error: null, errorInfo: null };
  2941. }
  2942. static getDerivedStateFromError(error) {
  2943. return { hasError: !0, error };
  2944. }
  2945. componentDidCatch(error, errorInfo) {
  2946. console.error("Storybook Manager UI Error:", error), console.error("Component Stack:", errorInfo.componentStack), this.setState({ errorInfo }), typeof globalThis.sendTelemetryError == "function" && globalThis.sendTelemetryError(error);
  2947. }
  2948. render() {
  2949. let { hasError, error, errorInfo } = this.state, { children } = this.props;
  2950. return hasError && error ? react_default.createElement(ErrorFallback, { error, errorInfo }) : children;
  2951. }
  2952. };
  2953. // src/manager/components/layout/Layout.tsx
  2954. init_react();
  2955. // src/manager/constants.ts
  2956. var MEDIA_DESKTOP_BREAKPOINT = "@media (min-width: 600px)";
  2957. // src/manager/container/Notifications.tsx
  2958. init_react();
  2959. // src/manager/components/notifications/NotificationList.tsx
  2960. init_react();
  2961. // src/manager/components/layout/LayoutProvider.tsx
  2962. init_react();
  2963. // src/manager/hooks/useMedia.tsx
  2964. init_react();
  2965. function useMediaQuery(query) {
  2966. let getMatches = (queryMatch) => typeof window < "u" ? window.matchMedia(queryMatch).matches : !1, [matches, setMatches] = useState(getMatches(query));
  2967. function handleChange() {
  2968. setMatches(getMatches(query));
  2969. }
  2970. return useEffect(() => {
  2971. let matchMedia = window.matchMedia(query);
  2972. return handleChange(), matchMedia.addEventListener("change", handleChange), () => {
  2973. matchMedia.removeEventListener("change", handleChange);
  2974. };
  2975. }, [query]), matches;
  2976. }
  2977. // src/manager/components/layout/LayoutProvider.tsx
  2978. var LayoutContext = createContext({
  2979. isMobileMenuOpen: !1,
  2980. setMobileMenuOpen: () => {
  2981. },
  2982. isMobileAboutOpen: !1,
  2983. setMobileAboutOpen: () => {
  2984. },
  2985. isMobilePanelOpen: !1,
  2986. setMobilePanelOpen: () => {
  2987. },
  2988. isDesktop: !1,
  2989. isMobile: !1
  2990. }), LayoutProvider = ({ children, forceDesktop }) => {
  2991. let [isMobileMenuOpen, setMobileMenuOpen] = useState(!1), [isMobileAboutOpen, setMobileAboutOpen] = useState(!1), [isMobilePanelOpen, setMobilePanelOpen] = useState(!1), isDesktop = forceDesktop ?? useMediaQuery(`(min-width: ${600}px)`), isMobile2 = !isDesktop, contextValue = useMemo(
  2992. () => ({
  2993. isMobileMenuOpen,
  2994. setMobileMenuOpen,
  2995. isMobileAboutOpen,
  2996. setMobileAboutOpen,
  2997. isMobilePanelOpen,
  2998. setMobilePanelOpen,
  2999. isDesktop,
  3000. isMobile: isMobile2
  3001. }),
  3002. [
  3003. isMobileMenuOpen,
  3004. setMobileMenuOpen,
  3005. isMobileAboutOpen,
  3006. setMobileAboutOpen,
  3007. isMobilePanelOpen,
  3008. setMobilePanelOpen,
  3009. isDesktop,
  3010. isMobile2
  3011. ]
  3012. );
  3013. return react_default.createElement(LayoutContext.Provider, { value: contextValue }, children);
  3014. }, useLayout = () => useContext(LayoutContext);
  3015. // src/manager/components/notifications/NotificationItem.tsx
  3016. init_react();
  3017. var slideIn = keyframes({
  3018. "0%": {
  3019. opacity: 0,
  3020. transform: "translateY(30px)"
  3021. },
  3022. "100%": {
  3023. opacity: 1,
  3024. transform: "translateY(0)"
  3025. }
  3026. }), grow = keyframes({
  3027. "0%": {
  3028. width: "0%"
  3029. },
  3030. "100%": {
  3031. width: "100%"
  3032. }
  3033. }), Notification = styled.div(
  3034. ({ theme }) => ({
  3035. position: "relative",
  3036. display: "flex",
  3037. border: `1px solid ${theme.appBorderColor}`,
  3038. padding: "12px 6px 12px 12px",
  3039. borderRadius: theme.appBorderRadius + 1,
  3040. alignItems: "center",
  3041. animation: `${slideIn} 500ms`,
  3042. background: theme.base === "light" ? "hsla(203, 50%, 20%, .97)" : "hsla(203, 30%, 95%, .97)",
  3043. boxShadow: "0 2px 5px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.1)",
  3044. color: theme.color.inverseText,
  3045. textDecoration: "none",
  3046. overflow: "hidden",
  3047. [MEDIA_DESKTOP_BREAKPOINT]: {
  3048. boxShadow: `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`
  3049. }
  3050. }),
  3051. ({ duration, theme }) => duration && {
  3052. "&::after": {
  3053. content: '""',
  3054. display: "block",
  3055. position: "absolute",
  3056. bottom: 0,
  3057. left: 0,
  3058. height: 3,
  3059. background: theme.color.secondary,
  3060. animation: `${grow} ${duration}ms linear forwards reverse`
  3061. }
  3062. }
  3063. ), NotificationWithInteractiveStates = styled(Notification)({
  3064. cursor: "pointer",
  3065. border: "none",
  3066. outline: "none",
  3067. textAlign: "left",
  3068. transition: "all 150ms ease-out",
  3069. transform: "translate3d(0, 0, 0)",
  3070. "&:hover": {
  3071. transform: "translate3d(0, -3px, 0)",
  3072. 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)"
  3073. },
  3074. "&:active": {
  3075. transform: "translate3d(0, 0, 0)",
  3076. 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)"
  3077. },
  3078. "&:focus": {
  3079. 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)"
  3080. }
  3081. }), NotificationButton = NotificationWithInteractiveStates.withComponent("div"), NotificationLink = NotificationWithInteractiveStates.withComponent(Link2), NotificationIconWrapper = styled.div({
  3082. display: "flex",
  3083. marginRight: 10,
  3084. alignItems: "center",
  3085. svg: {
  3086. width: 16,
  3087. height: 16
  3088. }
  3089. }), NotificationTextWrapper = styled.div(({ theme }) => ({
  3090. width: "100%",
  3091. display: "flex",
  3092. flexDirection: "column",
  3093. color: theme.color.inverseText
  3094. })), Headline = styled.div(({ theme }) => ({
  3095. height: "100%",
  3096. alignItems: "center",
  3097. whiteSpace: "balance",
  3098. overflow: "hidden",
  3099. textOverflow: "ellipsis",
  3100. fontSize: theme.typography.size.s1,
  3101. lineHeight: "16px",
  3102. fontWeight: theme.typography.weight.bold
  3103. })), SubHeadline = styled.div(({ theme }) => ({
  3104. color: curriedTransparentize$1(0.25, theme.color.inverseText),
  3105. fontSize: theme.typography.size.s1 - 1,
  3106. lineHeight: "14px",
  3107. marginTop: 2,
  3108. whiteSpace: "balance"
  3109. })), ItemContent = ({
  3110. icon,
  3111. content: { headline, subHeadline }
  3112. }) => 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 }) => ({
  3113. width: 28,
  3114. alignSelf: "center",
  3115. marginTop: 0,
  3116. color: theme.base === "light" ? "rgba(255,255,255,0.7)" : " #999999"
  3117. })), DismissNotificationItem = ({ onDismiss }) => react_default.createElement(
  3118. DismissButtonWrapper,
  3119. {
  3120. padding: "small",
  3121. variant: "ghost",
  3122. ariaLabel: "Dismiss notification",
  3123. onClick: (e2) => {
  3124. e2.preventDefault(), e2.stopPropagation(), onDismiss();
  3125. }
  3126. },
  3127. react_default.createElement(CloseAltIcon, { size: 12 })
  3128. ), NotificationItemSpacer = styled.div({
  3129. height: 48
  3130. }), NotificationItem = ({
  3131. notification: { content, duration, link, onClear, onClick, id, icon },
  3132. onDismissNotification,
  3133. zIndex
  3134. }) => {
  3135. let onTimeout = useCallback(() => {
  3136. onDismissNotification(id), onClear && onClear({ dismissed: !1, timeout: !0 });
  3137. }, [id, onDismissNotification, onClear]), timer = useRef(null);
  3138. useEffect(() => {
  3139. if (duration)
  3140. return timer.current = setTimeout(onTimeout, duration), () => clearTimeout(timer.current);
  3141. }, [duration, onTimeout]);
  3142. let onDismiss = useCallback(() => {
  3143. clearTimeout(timer.current), onDismissNotification(id), onClear && onClear({ dismissed: !0, timeout: !1 });
  3144. }, [id, onDismissNotification, onClear]);
  3145. 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(
  3146. NotificationButton,
  3147. {
  3148. duration,
  3149. onClick: () => onClick({ onDismiss }),
  3150. style: { zIndex }
  3151. },
  3152. react_default.createElement(ItemContent, { icon, content }),
  3153. react_default.createElement(DismissNotificationItem, { onDismiss })
  3154. ) : react_default.createElement(Notification, { duration, style: { zIndex } }, react_default.createElement(ItemContent, { icon, content }), react_default.createElement(DismissNotificationItem, { onDismiss }));
  3155. }, NotificationItem_default = NotificationItem;
  3156. // src/manager/components/notifications/NotificationList.tsx
  3157. var NotificationList = ({
  3158. notifications,
  3159. clearNotification
  3160. }) => {
  3161. let { isMobile: isMobile2 } = useLayout();
  3162. return react_default.createElement(List, { isMobile: isMobile2 }, notifications && notifications.map((notification, index) => react_default.createElement(
  3163. NotificationItem_default,
  3164. {
  3165. key: notification.id,
  3166. onDismissNotification: (id) => clearNotification(id),
  3167. notification,
  3168. zIndex: notifications.length - index
  3169. }
  3170. )));
  3171. }, List = styled.div(
  3172. {
  3173. zIndex: 200,
  3174. "> * + *": {
  3175. marginTop: 12
  3176. },
  3177. "&:empty": {
  3178. display: "none"
  3179. }
  3180. },
  3181. ({ isMobile: isMobile2 }) => isMobile2 && {
  3182. position: "fixed",
  3183. bottom: 40,
  3184. margin: 20
  3185. }
  3186. );
  3187. // src/manager/container/Notifications.tsx
  3188. var mapper = ({ state, api }) => ({
  3189. notifications: state.notifications,
  3190. clearNotification: api.clearNotification
  3191. }), Notifications = (props) => react_default.createElement(Consumer, { filter: mapper }, (fromState) => react_default.createElement(NotificationList, { ...props, ...fromState }));
  3192. // src/manager/components/mobile/navigation/MobileNavigation.tsx
  3193. init_react();
  3194. // ../../node_modules/@react-aria/utils/dist/useLayoutEffect.mjs
  3195. init_react();
  3196. var $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document < "u" ? react_default.useLayoutEffect : () => {
  3197. };
  3198. // ../../node_modules/@react-aria/utils/dist/useValueEffect.mjs
  3199. init_react();
  3200. // ../../node_modules/@react-aria/utils/dist/useId.mjs
  3201. init_react();
  3202. // ../../node_modules/@react-aria/ssr/dist/SSRProvider.mjs
  3203. init_react();
  3204. var $b5e257d569688ac6$var$defaultContext = {
  3205. prefix: String(Math.round(Math.random() * 1e10)),
  3206. current: 0
  3207. }, $b5e257d569688ac6$var$SSRContext = react_default.createContext($b5e257d569688ac6$var$defaultContext), $b5e257d569688ac6$var$IsSSRContext = react_default.createContext(!1);
  3208. var $b5e257d569688ac6$var$canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), $b5e257d569688ac6$var$componentIds = /* @__PURE__ */ new WeakMap();
  3209. function $b5e257d569688ac6$var$useCounter(isDisabled = !1) {
  3210. let ctx = useContext($b5e257d569688ac6$var$SSRContext), ref = useRef(null);
  3211. if (ref.current === null && !isDisabled) {
  3212. var _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_ReactCurrentOwner, _React___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  3213. 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;
  3214. if (currentOwner) {
  3215. let prevComponentValue = $b5e257d569688ac6$var$componentIds.get(currentOwner);
  3216. prevComponentValue == null ? $b5e257d569688ac6$var$componentIds.set(currentOwner, {
  3217. id: ctx.current,
  3218. state: currentOwner.memoizedState
  3219. }) : currentOwner.memoizedState !== prevComponentValue.state && (ctx.current = prevComponentValue.id, $b5e257d569688ac6$var$componentIds.delete(currentOwner));
  3220. }
  3221. ref.current = ++ctx.current;
  3222. }
  3223. return ref.current;
  3224. }
  3225. function $b5e257d569688ac6$var$useLegacySSRSafeId(defaultId) {
  3226. let ctx = useContext($b5e257d569688ac6$var$SSRContext), counter = $b5e257d569688ac6$var$useCounter(!!defaultId), prefix = `react-aria${ctx.prefix}`;
  3227. return defaultId || `${prefix}-${counter}`;
  3228. }
  3229. function $b5e257d569688ac6$var$useModernSSRSafeId(defaultId) {
  3230. let id = react_default.useId(), [didSSR] = useState($b5e257d569688ac6$export$535bd6ca7f90a273()), prefix = didSSR ? "react-aria" : `react-aria${$b5e257d569688ac6$var$defaultContext.prefix}`;
  3231. return defaultId || `${prefix}-${id}`;
  3232. }
  3233. var $b5e257d569688ac6$export$619500959fc48b26 = typeof react_default.useId == "function" ? $b5e257d569688ac6$var$useModernSSRSafeId : $b5e257d569688ac6$var$useLegacySSRSafeId;
  3234. function $b5e257d569688ac6$var$getSnapshot() {
  3235. return !1;
  3236. }
  3237. function $b5e257d569688ac6$var$getServerSnapshot() {
  3238. return !0;
  3239. }
  3240. function $b5e257d569688ac6$var$subscribe(onStoreChange) {
  3241. return () => {
  3242. };
  3243. }
  3244. function $b5e257d569688ac6$export$535bd6ca7f90a273() {
  3245. return typeof react_default.useSyncExternalStore == "function" ? react_default.useSyncExternalStore($b5e257d569688ac6$var$subscribe, $b5e257d569688ac6$var$getSnapshot, $b5e257d569688ac6$var$getServerSnapshot) : useContext($b5e257d569688ac6$var$IsSSRContext);
  3246. }
  3247. // ../../node_modules/@react-aria/utils/dist/useId.mjs
  3248. var $bdb11010cef70236$var$canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), $bdb11010cef70236$export$d41a04c74483c6ef = /* @__PURE__ */ new Map(), $bdb11010cef70236$var$registry;
  3249. typeof FinalizationRegistry < "u" && ($bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue) => {
  3250. $bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue);
  3251. }));
  3252. function $bdb11010cef70236$export$f680877a34711e37(defaultId) {
  3253. let [value, setValue] = useState(defaultId), nextId = useRef(null), res = $b5e257d569688ac6$export$619500959fc48b26(value), cleanupRef = useRef(null);
  3254. if ($bdb11010cef70236$var$registry && $bdb11010cef70236$var$registry.register(cleanupRef, res), $bdb11010cef70236$var$canUseDOM) {
  3255. let cacheIdRef = $bdb11010cef70236$export$d41a04c74483c6ef.get(res);
  3256. cacheIdRef && !cacheIdRef.includes(nextId) ? cacheIdRef.push(nextId) : $bdb11010cef70236$export$d41a04c74483c6ef.set(res, [
  3257. nextId
  3258. ]);
  3259. }
  3260. return $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3261. let r4 = res;
  3262. return () => {
  3263. $bdb11010cef70236$var$registry && $bdb11010cef70236$var$registry.unregister(cleanupRef), $bdb11010cef70236$export$d41a04c74483c6ef.delete(r4);
  3264. };
  3265. }, [
  3266. res
  3267. ]), useEffect(() => {
  3268. let newId = nextId.current;
  3269. return newId && setValue(newId), () => {
  3270. newId && (nextId.current = null);
  3271. };
  3272. }), res;
  3273. }
  3274. function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
  3275. if (idA === idB) return idA;
  3276. let setIdsA = $bdb11010cef70236$export$d41a04c74483c6ef.get(idA);
  3277. if (setIdsA)
  3278. return setIdsA.forEach((ref) => ref.current = idB), idB;
  3279. let setIdsB = $bdb11010cef70236$export$d41a04c74483c6ef.get(idB);
  3280. return setIdsB ? (setIdsB.forEach((ref) => ref.current = idA), idA) : idB;
  3281. }
  3282. // ../../node_modules/@react-aria/utils/dist/chain.mjs
  3283. function $ff5963eb1fccf552$export$e08e3b67e392101e(...callbacks) {
  3284. return (...args) => {
  3285. for (let callback of callbacks) typeof callback == "function" && callback(...args);
  3286. };
  3287. }
  3288. // ../../node_modules/@react-aria/utils/dist/domHelpers.mjs
  3289. var $431fbd86ca7dc216$export$b204af158042fbac = (el) => {
  3290. var _el_ownerDocument;
  3291. return (_el_ownerDocument = el?.ownerDocument) !== null && _el_ownerDocument !== void 0 ? _el_ownerDocument : document;
  3292. }, $431fbd86ca7dc216$export$f21a1ffae260145a = (el) => el && "window" in el && el.window === el ? el : $431fbd86ca7dc216$export$b204af158042fbac(el).defaultView || window;
  3293. function $431fbd86ca7dc216$var$isNode(value) {
  3294. return value !== null && typeof value == "object" && "nodeType" in value && typeof value.nodeType == "number";
  3295. }
  3296. function $431fbd86ca7dc216$export$af51f0f06c0f328a(node) {
  3297. return $431fbd86ca7dc216$var$isNode(node) && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in node;
  3298. }
  3299. // ../../node_modules/@react-stately/flags/dist/import.mjs
  3300. var $f4e2df6bd15f8569$var$_shadowDOM = !1;
  3301. function $f4e2df6bd15f8569$export$98658e8c59125e6a() {
  3302. return $f4e2df6bd15f8569$var$_shadowDOM;
  3303. }
  3304. // ../../node_modules/@react-aria/utils/dist/DOMFunctions.mjs
  3305. function $d4ee10de306f2510$export$4282f70798064fe0(node, otherNode) {
  3306. if (!$f4e2df6bd15f8569$export$98658e8c59125e6a()) return otherNode && node ? node.contains(otherNode) : !1;
  3307. if (!node || !otherNode) return !1;
  3308. let currentNode = otherNode;
  3309. for (; currentNode !== null; ) {
  3310. if (currentNode === node) return !0;
  3311. currentNode.tagName === "SLOT" && currentNode.assignedSlot ? currentNode = currentNode.assignedSlot.parentNode : $431fbd86ca7dc216$export$af51f0f06c0f328a(currentNode) ? currentNode = currentNode.host : currentNode = currentNode.parentNode;
  3312. }
  3313. return !1;
  3314. }
  3315. var $d4ee10de306f2510$export$cd4e5573fbe2b576 = (doc = document) => {
  3316. var _activeElement_shadowRoot;
  3317. if (!$f4e2df6bd15f8569$export$98658e8c59125e6a()) return doc.activeElement;
  3318. let activeElement = doc.activeElement;
  3319. for (; activeElement && "shadowRoot" in activeElement && (!((_activeElement_shadowRoot = activeElement.shadowRoot) === null || _activeElement_shadowRoot === void 0) && _activeElement_shadowRoot.activeElement); ) activeElement = activeElement.shadowRoot.activeElement;
  3320. return activeElement;
  3321. };
  3322. function $d4ee10de306f2510$export$e58f029f0fbfdb29(event) {
  3323. return $f4e2df6bd15f8569$export$98658e8c59125e6a() && event.target.shadowRoot && event.composedPath ? event.composedPath()[0] : event.target;
  3324. }
  3325. // ../../node_modules/clsx/dist/clsx.mjs
  3326. function r2(e2) {
  3327. var t2, f2, n3 = "";
  3328. if (typeof e2 == "string" || typeof e2 == "number") n3 += e2;
  3329. else if (typeof e2 == "object") if (Array.isArray(e2)) {
  3330. var o3 = e2.length;
  3331. for (t2 = 0; t2 < o3; t2++) e2[t2] && (f2 = r2(e2[t2])) && (n3 && (n3 += " "), n3 += f2);
  3332. } else for (f2 in e2) e2[f2] && (n3 && (n3 += " "), n3 += f2);
  3333. return n3;
  3334. }
  3335. function clsx() {
  3336. for (var e2, t2, f2 = 0, n3 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t2 = r2(e2)) && (n3 && (n3 += " "), n3 += t2);
  3337. return n3;
  3338. }
  3339. var clsx_default = clsx;
  3340. // ../../node_modules/@react-aria/utils/dist/mergeProps.mjs
  3341. function $3ef42575df84b30b$export$9d1611c77c2fe928(...args) {
  3342. let result = {
  3343. ...args[0]
  3344. };
  3345. for (let i2 = 1; i2 < args.length; i2++) {
  3346. let props = args[i2];
  3347. for (let key in props) {
  3348. let a2 = result[key], b2 = props[key];
  3349. typeof a2 == "function" && typeof b2 == "function" && // This is a lot faster than a regex.
  3350. key[0] === "o" && key[1] === "n" && key.charCodeAt(2) >= /* 'A' */
  3351. 65 && key.charCodeAt(2) <= /* 'Z' */
  3352. 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;
  3353. }
  3354. }
  3355. return result;
  3356. }
  3357. // ../../node_modules/@react-aria/utils/dist/mergeRefs.mjs
  3358. function $5dc95899b306f630$export$c9058316764c140e(...refs) {
  3359. return refs.length === 1 && refs[0] ? refs[0] : (value) => {
  3360. let hasCleanup = !1, cleanups = refs.map((ref) => {
  3361. let cleanup = $5dc95899b306f630$var$setRef(ref, value);
  3362. return hasCleanup || (hasCleanup = typeof cleanup == "function"), cleanup;
  3363. });
  3364. if (hasCleanup) return () => {
  3365. cleanups.forEach((cleanup, i2) => {
  3366. typeof cleanup == "function" ? cleanup() : $5dc95899b306f630$var$setRef(refs[i2], null);
  3367. });
  3368. };
  3369. };
  3370. }
  3371. function $5dc95899b306f630$var$setRef(ref, value) {
  3372. if (typeof ref == "function") return ref(value);
  3373. ref != null && (ref.current = value);
  3374. }
  3375. // ../../node_modules/@react-aria/utils/dist/filterDOMProps.mjs
  3376. var $65484d02dcb7eb3e$var$DOMPropNames = /* @__PURE__ */ new Set([
  3377. "id"
  3378. ]), $65484d02dcb7eb3e$var$labelablePropNames = /* @__PURE__ */ new Set([
  3379. "aria-label",
  3380. "aria-labelledby",
  3381. "aria-describedby",
  3382. "aria-details"
  3383. ]), $65484d02dcb7eb3e$var$linkPropNames = /* @__PURE__ */ new Set([
  3384. "href",
  3385. "hrefLang",
  3386. "target",
  3387. "rel",
  3388. "download",
  3389. "ping",
  3390. "referrerPolicy"
  3391. ]), $65484d02dcb7eb3e$var$globalAttrs = /* @__PURE__ */ new Set([
  3392. "dir",
  3393. "lang",
  3394. "hidden",
  3395. "inert",
  3396. "translate"
  3397. ]), $65484d02dcb7eb3e$var$globalEvents = /* @__PURE__ */ new Set([
  3398. "onClick",
  3399. "onAuxClick",
  3400. "onContextMenu",
  3401. "onDoubleClick",
  3402. "onMouseDown",
  3403. "onMouseEnter",
  3404. "onMouseLeave",
  3405. "onMouseMove",
  3406. "onMouseOut",
  3407. "onMouseOver",
  3408. "onMouseUp",
  3409. "onTouchCancel",
  3410. "onTouchEnd",
  3411. "onTouchMove",
  3412. "onTouchStart",
  3413. "onPointerDown",
  3414. "onPointerMove",
  3415. "onPointerUp",
  3416. "onPointerCancel",
  3417. "onPointerEnter",
  3418. "onPointerLeave",
  3419. "onPointerOver",
  3420. "onPointerOut",
  3421. "onGotPointerCapture",
  3422. "onLostPointerCapture",
  3423. "onScroll",
  3424. "onWheel",
  3425. "onAnimationStart",
  3426. "onAnimationEnd",
  3427. "onAnimationIteration",
  3428. "onTransitionCancel",
  3429. "onTransitionEnd",
  3430. "onTransitionRun",
  3431. "onTransitionStart"
  3432. ]), $65484d02dcb7eb3e$var$propRe = /^(data-.*)$/;
  3433. function $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, opts = {}) {
  3434. let { labelable, isLink, global: global2, events: events2 = global2, propNames } = opts, filteredProps = {};
  3435. 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]);
  3436. return filteredProps;
  3437. }
  3438. // ../../node_modules/@react-aria/utils/dist/focusWithoutScrolling.mjs
  3439. function $7215afc6de606d6b$export$de79e2c695e052f3(element) {
  3440. if ($7215afc6de606d6b$var$supportsPreventScroll()) element.focus({
  3441. preventScroll: !0
  3442. });
  3443. else {
  3444. let scrollableElements = $7215afc6de606d6b$var$getScrollableElements(element);
  3445. element.focus(), $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements);
  3446. }
  3447. }
  3448. var $7215afc6de606d6b$var$supportsPreventScrollCached = null;
  3449. function $7215afc6de606d6b$var$supportsPreventScroll() {
  3450. if ($7215afc6de606d6b$var$supportsPreventScrollCached == null) {
  3451. $7215afc6de606d6b$var$supportsPreventScrollCached = !1;
  3452. try {
  3453. document.createElement("div").focus({
  3454. get preventScroll() {
  3455. return $7215afc6de606d6b$var$supportsPreventScrollCached = !0, !0;
  3456. }
  3457. });
  3458. } catch {
  3459. }
  3460. }
  3461. return $7215afc6de606d6b$var$supportsPreventScrollCached;
  3462. }
  3463. function $7215afc6de606d6b$var$getScrollableElements(element) {
  3464. let parent = element.parentNode, scrollableElements = [], rootScrollingElement = document.scrollingElement || document.documentElement;
  3465. for (; parent instanceof HTMLElement && parent !== rootScrollingElement; )
  3466. (parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth) && scrollableElements.push({
  3467. element: parent,
  3468. scrollTop: parent.scrollTop,
  3469. scrollLeft: parent.scrollLeft
  3470. }), parent = parent.parentNode;
  3471. return rootScrollingElement instanceof HTMLElement && scrollableElements.push({
  3472. element: rootScrollingElement,
  3473. scrollTop: rootScrollingElement.scrollTop,
  3474. scrollLeft: rootScrollingElement.scrollLeft
  3475. }), scrollableElements;
  3476. }
  3477. function $7215afc6de606d6b$var$restoreScrollPosition(scrollableElements) {
  3478. for (let { element, scrollTop, scrollLeft } of scrollableElements)
  3479. element.scrollTop = scrollTop, element.scrollLeft = scrollLeft;
  3480. }
  3481. // ../../node_modules/@react-aria/utils/dist/platform.mjs
  3482. function $c87311424ea30a05$var$testUserAgent(re2) {
  3483. var _window_navigator_userAgentData;
  3484. if (typeof window > "u" || window.navigator == null) return !1;
  3485. let brands = (_window_navigator_userAgentData = window.navigator.userAgentData) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands;
  3486. return Array.isArray(brands) && brands.some((brand) => re2.test(brand.brand)) || re2.test(window.navigator.userAgent);
  3487. }
  3488. function $c87311424ea30a05$var$testPlatform(re2) {
  3489. var _window_navigator_userAgentData;
  3490. return typeof window < "u" && window.navigator != null ? re2.test(((_window_navigator_userAgentData = window.navigator.userAgentData) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : !1;
  3491. }
  3492. function $c87311424ea30a05$var$cached(fn) {
  3493. let res = null;
  3494. return () => (res == null && (res = fn()), res);
  3495. }
  3496. var $c87311424ea30a05$export$9ac100e40613ea10 = $c87311424ea30a05$var$cached(function() {
  3497. return $c87311424ea30a05$var$testPlatform(/^Mac/i);
  3498. }), $c87311424ea30a05$export$186c6964ca17d99 = $c87311424ea30a05$var$cached(function() {
  3499. return $c87311424ea30a05$var$testPlatform(/^iPhone/i);
  3500. }), $c87311424ea30a05$export$7bef049ce92e4224 = $c87311424ea30a05$var$cached(function() {
  3501. return $c87311424ea30a05$var$testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
  3502. $c87311424ea30a05$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
  3503. }), $c87311424ea30a05$export$fedb369cb70207f1 = $c87311424ea30a05$var$cached(function() {
  3504. return $c87311424ea30a05$export$186c6964ca17d99() || $c87311424ea30a05$export$7bef049ce92e4224();
  3505. }), $c87311424ea30a05$export$e1865c3bedcd822b = $c87311424ea30a05$var$cached(function() {
  3506. return $c87311424ea30a05$export$9ac100e40613ea10() || $c87311424ea30a05$export$fedb369cb70207f1();
  3507. }), $c87311424ea30a05$export$78551043582a6a98 = $c87311424ea30a05$var$cached(function() {
  3508. return $c87311424ea30a05$var$testUserAgent(/AppleWebKit/i) && !$c87311424ea30a05$export$6446a186d09e379e();
  3509. }), $c87311424ea30a05$export$6446a186d09e379e = $c87311424ea30a05$var$cached(function() {
  3510. return $c87311424ea30a05$var$testUserAgent(/Chrome/i);
  3511. }), $c87311424ea30a05$export$a11b0059900ceec8 = $c87311424ea30a05$var$cached(function() {
  3512. return $c87311424ea30a05$var$testUserAgent(/Android/i);
  3513. }), $c87311424ea30a05$export$b7d78993b74f766d = $c87311424ea30a05$var$cached(function() {
  3514. return $c87311424ea30a05$var$testUserAgent(/Firefox/i);
  3515. });
  3516. // ../../node_modules/@react-aria/utils/dist/openLink.mjs
  3517. init_react();
  3518. var $ea8dcbcb9ea1b556$var$RouterContext = createContext({
  3519. isNative: !0,
  3520. open: $ea8dcbcb9ea1b556$var$openSyntheticLink,
  3521. useHref: (href) => href
  3522. });
  3523. function $ea8dcbcb9ea1b556$export$95185d699e05d4d7(target, modifiers2, setOpening = !0) {
  3524. var _window_event_type, _window_event;
  3525. let { metaKey, ctrlKey, altKey, shiftKey } = modifiers2;
  3526. $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);
  3527. let event = $c87311424ea30a05$export$78551043582a6a98() && $c87311424ea30a05$export$9ac100e40613ea10() && !$c87311424ea30a05$export$7bef049ce92e4224() ? new KeyboardEvent("keydown", {
  3528. keyIdentifier: "Enter",
  3529. metaKey,
  3530. ctrlKey,
  3531. altKey,
  3532. shiftKey
  3533. }) : new MouseEvent("click", {
  3534. metaKey,
  3535. ctrlKey,
  3536. altKey,
  3537. shiftKey,
  3538. detail: 1,
  3539. bubbles: !0,
  3540. cancelable: !0
  3541. });
  3542. $ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = setOpening, $7215afc6de606d6b$export$de79e2c695e052f3(target), target.dispatchEvent(event), $ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = !1;
  3543. }
  3544. $ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = !1;
  3545. function $ea8dcbcb9ea1b556$var$getSyntheticLink(target, open) {
  3546. if (target instanceof HTMLAnchorElement) open(target);
  3547. else if (target.hasAttribute("data-href")) {
  3548. let link = document.createElement("a");
  3549. 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);
  3550. }
  3551. }
  3552. function $ea8dcbcb9ea1b556$var$openSyntheticLink(target, modifiers2) {
  3553. $ea8dcbcb9ea1b556$var$getSyntheticLink(target, (link) => $ea8dcbcb9ea1b556$export$95185d699e05d4d7(link, modifiers2));
  3554. }
  3555. // ../../node_modules/@react-aria/utils/dist/runAfterTransition.mjs
  3556. var $bbed8b41f857bcc0$var$transitionsByElement = /* @__PURE__ */ new Map(), $bbed8b41f857bcc0$var$transitionCallbacks = /* @__PURE__ */ new Set();
  3557. function $bbed8b41f857bcc0$var$setupGlobalEvents() {
  3558. if (typeof window > "u") return;
  3559. function isTransitionEvent(event) {
  3560. return "propertyName" in event;
  3561. }
  3562. let onTransitionStart = (e2) => {
  3563. if (!isTransitionEvent(e2) || !e2.target) return;
  3564. let transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e2.target);
  3565. transitions || (transitions = /* @__PURE__ */ new Set(), $bbed8b41f857bcc0$var$transitionsByElement.set(e2.target, transitions), e2.target.addEventListener("transitioncancel", onTransitionEnd, {
  3566. once: !0
  3567. })), transitions.add(e2.propertyName);
  3568. }, onTransitionEnd = (e2) => {
  3569. if (!isTransitionEvent(e2) || !e2.target) return;
  3570. let properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e2.target);
  3571. 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)) {
  3572. for (let cb of $bbed8b41f857bcc0$var$transitionCallbacks) cb();
  3573. $bbed8b41f857bcc0$var$transitionCallbacks.clear();
  3574. }
  3575. };
  3576. document.body.addEventListener("transitionrun", onTransitionStart), document.body.addEventListener("transitionend", onTransitionEnd);
  3577. }
  3578. typeof document < "u" && (document.readyState !== "loading" ? $bbed8b41f857bcc0$var$setupGlobalEvents() : document.addEventListener("DOMContentLoaded", $bbed8b41f857bcc0$var$setupGlobalEvents));
  3579. function $bbed8b41f857bcc0$var$cleanupDetachedElements() {
  3580. for (let [eventTarget] of $bbed8b41f857bcc0$var$transitionsByElement)
  3581. "isConnected" in eventTarget && !eventTarget.isConnected && $bbed8b41f857bcc0$var$transitionsByElement.delete(eventTarget);
  3582. }
  3583. function $bbed8b41f857bcc0$export$24490316f764c430(fn) {
  3584. requestAnimationFrame(() => {
  3585. $bbed8b41f857bcc0$var$cleanupDetachedElements(), $bbed8b41f857bcc0$var$transitionsByElement.size === 0 ? fn() : $bbed8b41f857bcc0$var$transitionCallbacks.add(fn);
  3586. });
  3587. }
  3588. // ../../node_modules/@react-aria/utils/dist/useDrag1D.mjs
  3589. init_react();
  3590. // ../../node_modules/@react-aria/utils/dist/useGlobalListeners.mjs
  3591. init_react();
  3592. function $03deb23ff14920c4$export$4eaf04e54aa8eed6() {
  3593. let globalListeners = useRef(/* @__PURE__ */ new Map()), addGlobalListener = useCallback((eventTarget, type, listener, options2) => {
  3594. let fn = options2?.once ? (...args) => {
  3595. globalListeners.current.delete(listener), listener(...args);
  3596. } : listener;
  3597. globalListeners.current.set(listener, {
  3598. type,
  3599. eventTarget,
  3600. fn,
  3601. options: options2
  3602. }), eventTarget.addEventListener(type, fn, options2);
  3603. }, []), removeGlobalListener = useCallback((eventTarget, type, listener, options2) => {
  3604. var _globalListeners_current_get;
  3605. let fn = ((_globalListeners_current_get = globalListeners.current.get(listener)) === null || _globalListeners_current_get === void 0 ? void 0 : _globalListeners_current_get.fn) || listener;
  3606. eventTarget.removeEventListener(type, fn, options2), globalListeners.current.delete(listener);
  3607. }, []), removeAllGlobalListeners = useCallback(() => {
  3608. globalListeners.current.forEach((value, key) => {
  3609. removeGlobalListener(value.eventTarget, value.type, key, value.options);
  3610. });
  3611. }, [
  3612. removeGlobalListener
  3613. ]);
  3614. return useEffect(() => removeAllGlobalListeners, [
  3615. removeAllGlobalListeners
  3616. ]), {
  3617. addGlobalListener,
  3618. removeGlobalListener,
  3619. removeAllGlobalListeners
  3620. };
  3621. }
  3622. // ../../node_modules/@react-aria/utils/dist/useObjectRef.mjs
  3623. init_react();
  3624. function $df56164dff5785e2$export$4338b53315abf666(ref) {
  3625. let objRef = useRef(null), cleanupRef = useRef(void 0), refEffect = useCallback((instance) => {
  3626. if (typeof ref == "function") {
  3627. let refCallback = ref, refCleanup = refCallback(instance);
  3628. return () => {
  3629. typeof refCleanup == "function" ? refCleanup() : refCallback(null);
  3630. };
  3631. } else if (ref)
  3632. return ref.current = instance, () => {
  3633. ref.current = null;
  3634. };
  3635. }, [
  3636. ref
  3637. ]);
  3638. return useMemo(() => ({
  3639. get current() {
  3640. return objRef.current;
  3641. },
  3642. set current(value) {
  3643. objRef.current = value, cleanupRef.current && (cleanupRef.current(), cleanupRef.current = void 0), value != null && (cleanupRef.current = refEffect(value));
  3644. }
  3645. }), [
  3646. refEffect
  3647. ]);
  3648. }
  3649. // ../../node_modules/@react-aria/utils/dist/useEffectEvent.mjs
  3650. init_react();
  3651. 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;
  3652. function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
  3653. let ref = useRef(null);
  3654. return $8ae05eaa5c114e9c$var$useEarlyEffect(() => {
  3655. ref.current = fn;
  3656. }, [
  3657. fn
  3658. ]), useCallback((...args) => {
  3659. let f2 = ref.current;
  3660. return f2?.(...args);
  3661. }, []);
  3662. }
  3663. // ../../node_modules/@react-aria/utils/dist/useUpdateEffect.mjs
  3664. init_react();
  3665. // ../../node_modules/@react-aria/utils/dist/useUpdateLayoutEffect.mjs
  3666. init_react();
  3667. // ../../node_modules/@react-aria/utils/dist/useResizeObserver.mjs
  3668. init_react();
  3669. function $9daab02d461809db$var$hasResizeObserver() {
  3670. return typeof window.ResizeObserver < "u";
  3671. }
  3672. function $9daab02d461809db$export$683480f191c0e3ea(options2) {
  3673. let { ref, box, onResize } = options2, onResizeEvent = $8ae05eaa5c114e9c$export$7f54fc3180508a52(onResize);
  3674. useEffect(() => {
  3675. let element = ref?.current;
  3676. if (element)
  3677. if ($9daab02d461809db$var$hasResizeObserver()) {
  3678. let resizeObserverInstance = new window.ResizeObserver((entries) => {
  3679. entries.length && onResizeEvent();
  3680. });
  3681. return resizeObserverInstance.observe(element, {
  3682. box
  3683. }), () => {
  3684. element && resizeObserverInstance.unobserve(element);
  3685. };
  3686. } else
  3687. return window.addEventListener("resize", onResizeEvent, !1), () => {
  3688. window.removeEventListener("resize", onResizeEvent, !1);
  3689. };
  3690. }, [
  3691. ref,
  3692. box
  3693. ]);
  3694. }
  3695. // ../../node_modules/@react-aria/utils/dist/useSyncRef.mjs
  3696. function $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref) {
  3697. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3698. if (context && context.ref && ref)
  3699. return context.ref.current = ref.current, () => {
  3700. context.ref && (context.ref.current = null);
  3701. };
  3702. });
  3703. }
  3704. // ../../node_modules/@react-aria/utils/dist/useViewportSize.mjs
  3705. init_react();
  3706. var $5df64b3807dc15ee$var$visualViewport = typeof document < "u" && window.visualViewport;
  3707. // ../../node_modules/@react-aria/utils/dist/useDescription.mjs
  3708. init_react();
  3709. // ../../node_modules/@react-aria/utils/dist/useEvent.mjs
  3710. init_react();
  3711. // ../../node_modules/@react-aria/utils/dist/isVirtualEvent.mjs
  3712. function $6a7db85432448f7f$export$60278871457622de(event) {
  3713. return event.pointerType === "" && event.isTrusted ? !0 : $c87311424ea30a05$export$a11b0059900ceec8() && event.pointerType ? event.type === "click" && event.buttons === 1 : event.detail === 0 && !event.pointerType;
  3714. }
  3715. function $6a7db85432448f7f$export$29bf1b5f2c56cf63(event) {
  3716. 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";
  3717. }
  3718. // ../../node_modules/@react-aria/utils/dist/useDeepMemo.mjs
  3719. init_react();
  3720. // ../../node_modules/@react-aria/utils/dist/useFormReset.mjs
  3721. init_react();
  3722. // ../../node_modules/@react-aria/utils/dist/useLoadMore.mjs
  3723. init_react();
  3724. // ../../node_modules/@react-aria/utils/dist/useLoadMoreSentinel.mjs
  3725. init_react();
  3726. // ../../node_modules/@react-aria/utils/dist/inertValue.mjs
  3727. init_react();
  3728. // global-externals:react-dom
  3729. 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__;
  3730. // ../../node_modules/@react-aria/utils/dist/animation.mjs
  3731. init_react();
  3732. function $d3f049242431219c$export$6d3443f2c48bfc20(ref, isReady = !0) {
  3733. let [isEntering, setEntering] = useState(!0), isAnimationReady = isEntering && isReady;
  3734. return $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3735. if (isAnimationReady && ref.current && "getAnimations" in ref.current)
  3736. for (let animation of ref.current.getAnimations()) animation instanceof CSSTransition && animation.cancel();
  3737. }, [
  3738. ref,
  3739. isAnimationReady
  3740. ]), $d3f049242431219c$var$useAnimation(ref, isAnimationReady, useCallback(() => setEntering(!1), [])), isAnimationReady;
  3741. }
  3742. function $d3f049242431219c$export$45fda7c47f93fd48(ref, isOpen) {
  3743. let [exitState, setExitState] = useState(isOpen ? "open" : "closed");
  3744. switch (exitState) {
  3745. case "open":
  3746. isOpen || setExitState("exiting");
  3747. break;
  3748. case "closed":
  3749. case "exiting":
  3750. isOpen && setExitState("open");
  3751. break;
  3752. }
  3753. let isExiting = exitState === "exiting";
  3754. return $d3f049242431219c$var$useAnimation(ref, isExiting, useCallback(() => {
  3755. setExitState((state) => state === "exiting" ? "closed" : state);
  3756. }, [])), isExiting;
  3757. }
  3758. function $d3f049242431219c$var$useAnimation(ref, isActive, onEnd) {
  3759. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  3760. if (isActive && ref.current) {
  3761. if (!("getAnimations" in ref.current)) {
  3762. onEnd();
  3763. return;
  3764. }
  3765. let animations = ref.current.getAnimations();
  3766. if (animations.length === 0) {
  3767. onEnd();
  3768. return;
  3769. }
  3770. let canceled = !1;
  3771. return Promise.all(animations.map((a2) => a2.finished)).then(() => {
  3772. canceled || flushSync(() => {
  3773. onEnd();
  3774. });
  3775. }).catch(() => {
  3776. }), () => {
  3777. canceled = !0;
  3778. };
  3779. }
  3780. }, [
  3781. ref,
  3782. isActive,
  3783. onEnd
  3784. ]);
  3785. }
  3786. // ../../node_modules/@react-aria/utils/dist/isElementVisible.mjs
  3787. var $7d2416ea0959daaa$var$supportsCheckVisibility = typeof Element < "u" && "checkVisibility" in Element.prototype;
  3788. function $7d2416ea0959daaa$var$isStyleVisible(element) {
  3789. let windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element);
  3790. if (!(element instanceof windowObject.HTMLElement) && !(element instanceof windowObject.SVGElement)) return !1;
  3791. let { display, visibility } = element.style, isVisible = display !== "none" && visibility !== "hidden" && visibility !== "collapse";
  3792. if (isVisible) {
  3793. let { getComputedStyle: getComputedStyle2 } = element.ownerDocument.defaultView, { display: computedDisplay, visibility: computedVisibility } = getComputedStyle2(element);
  3794. isVisible = computedDisplay !== "none" && computedVisibility !== "hidden" && computedVisibility !== "collapse";
  3795. }
  3796. return isVisible;
  3797. }
  3798. function $7d2416ea0959daaa$var$isAttributeVisible(element, childElement) {
  3799. return !element.hasAttribute("hidden") && // Ignore HiddenSelect when tree walking.
  3800. !element.hasAttribute("data-react-aria-prevent-focus") && (element.nodeName === "DETAILS" && childElement && childElement.nodeName !== "SUMMARY" ? element.hasAttribute("open") : !0);
  3801. }
  3802. function $7d2416ea0959daaa$export$e989c0fffaa6b27a(element, childElement) {
  3803. return $7d2416ea0959daaa$var$supportsCheckVisibility ? element.checkVisibility({
  3804. visibilityProperty: !0
  3805. }) && !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));
  3806. }
  3807. // ../../node_modules/@react-aria/utils/dist/isFocusable.mjs
  3808. var $b4b717babfbb907b$var$focusableElements = [
  3809. "input:not([disabled]):not([type=hidden])",
  3810. "select:not([disabled])",
  3811. "textarea:not([disabled])",
  3812. "button:not([disabled])",
  3813. "a[href]",
  3814. "area[href]",
  3815. "summary",
  3816. "iframe",
  3817. "object",
  3818. "embed",
  3819. "audio[controls]",
  3820. "video[controls]",
  3821. '[contenteditable]:not([contenteditable^="false"])',
  3822. "permission"
  3823. ], $b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(":not([hidden]),") + ",[tabindex]:not([disabled]):not([hidden])";
  3824. $b4b717babfbb907b$var$focusableElements.push('[tabindex]:not([tabindex="-1"]):not([disabled])');
  3825. var $b4b717babfbb907b$var$TABBABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(':not([hidden]):not([tabindex="-1"]),');
  3826. function $b4b717babfbb907b$export$4c063cf1350e6fed(element) {
  3827. return element.matches($b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR) && $7d2416ea0959daaa$export$e989c0fffaa6b27a(element) && !$b4b717babfbb907b$var$isInert(element);
  3828. }
  3829. function $b4b717babfbb907b$var$isInert(element) {
  3830. let node = element;
  3831. for (; node != null; ) {
  3832. if (node instanceof node.ownerDocument.defaultView.HTMLElement && node.inert) return !0;
  3833. node = node.parentElement;
  3834. }
  3835. return !1;
  3836. }
  3837. // ../../node_modules/@react-stately/utils/dist/useControlledState.mjs
  3838. init_react();
  3839. 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 : () => {
  3840. };
  3841. function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
  3842. let [stateValue, setStateValue] = useState(value || defaultValue), valueRef = useRef(stateValue), isControlledRef = useRef(value !== void 0), isControlled = value !== void 0;
  3843. useEffect(() => {
  3844. let wasControlled = isControlledRef.current;
  3845. isControlledRef.current = isControlled;
  3846. }, [
  3847. isControlled
  3848. ]);
  3849. let currentValue = isControlled ? value : stateValue;
  3850. $458b0a5536c1a7cf$var$useEarlyEffect(() => {
  3851. valueRef.current = currentValue;
  3852. });
  3853. let [, forceUpdate] = useReducer(() => ({}), {}), setValue = useCallback((value2, ...args) => {
  3854. let newValue = typeof value2 == "function" ? value2(valueRef.current) : value2;
  3855. Object.is(valueRef.current, newValue) || (valueRef.current = newValue, setStateValue(newValue), forceUpdate(), onChange?.(newValue, ...args));
  3856. }, [
  3857. onChange
  3858. ]);
  3859. return [
  3860. currentValue,
  3861. setValue
  3862. ];
  3863. }
  3864. // ../../node_modules/@react-stately/utils/dist/number.mjs
  3865. function $9446cca9a3875146$export$7d15b64cf5a3a4c4(value, min = -1 / 0, max = 1 / 0) {
  3866. return Math.min(Math.max(value, min), max);
  3867. }
  3868. // ../../node_modules/@react-aria/landmark/dist/useLandmark.mjs
  3869. init_react();
  3870. var import_shim = __toESM(require_shim(), 1), $a86207c5d7f7e1fb$var$LANDMARK_API_VERSION = 1, $a86207c5d7f7e1fb$var$landmarkSymbol = /* @__PURE__ */ Symbol.for("react-aria-landmark-manager");
  3871. function $a86207c5d7f7e1fb$var$subscribe(fn) {
  3872. return document.addEventListener("react-aria-landmark-manager-change", fn), () => document.removeEventListener("react-aria-landmark-manager-change", fn);
  3873. }
  3874. function $a86207c5d7f7e1fb$var$getLandmarkManager() {
  3875. if (typeof document > "u") return null;
  3876. let instance = document[$a86207c5d7f7e1fb$var$landmarkSymbol];
  3877. 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]);
  3878. }
  3879. function $a86207c5d7f7e1fb$var$useLandmarkManager() {
  3880. return (0, import_shim.useSyncExternalStore)($a86207c5d7f7e1fb$var$subscribe, $a86207c5d7f7e1fb$var$getLandmarkManager, $a86207c5d7f7e1fb$var$getLandmarkManager);
  3881. }
  3882. var $a86207c5d7f7e1fb$var$LandmarkManager = class {
  3883. setupIfNeeded() {
  3884. this.isListening || (document.addEventListener("keydown", this.f6Handler, {
  3885. capture: !0
  3886. }), document.addEventListener("focusin", this.focusinHandler, {
  3887. capture: !0
  3888. }), document.addEventListener("focusout", this.focusoutHandler, {
  3889. capture: !0
  3890. }), this.isListening = !0);
  3891. }
  3892. teardownIfNeeded() {
  3893. !this.isListening || this.landmarks.length > 0 || this.refCount > 0 || (document.removeEventListener("keydown", this.f6Handler, {
  3894. capture: !0
  3895. }), document.removeEventListener("focusin", this.focusinHandler, {
  3896. capture: !0
  3897. }), document.removeEventListener("focusout", this.focusoutHandler, {
  3898. capture: !0
  3899. }), this.isListening = !1);
  3900. }
  3901. focusLandmark(landmark, direction) {
  3902. var _this_landmarks_find_focus, _this_landmarks_find;
  3903. (_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);
  3904. }
  3905. /**
  3906. * Return set of landmarks with a specific role.
  3907. */
  3908. getLandmarksByRole(role) {
  3909. return new Set(this.landmarks.filter((l3) => l3.role === role));
  3910. }
  3911. /**
  3912. * Return first landmark with a specific role.
  3913. */
  3914. getLandmarkByRole(role) {
  3915. return this.landmarks.find((l3) => l3.role === role);
  3916. }
  3917. addLandmark(newLandmark) {
  3918. if (this.setupIfNeeded(), this.landmarks.find((landmark) => landmark.ref === newLandmark.ref) || !newLandmark.ref.current) return;
  3919. if (this.landmarks.filter((landmark) => landmark.role === "main").length > 1, this.landmarks.length === 0) {
  3920. this.landmarks = [
  3921. newLandmark
  3922. ], this.checkLabels(newLandmark.role);
  3923. return;
  3924. }
  3925. let start = 0, end = this.landmarks.length - 1;
  3926. for (; start <= end; ) {
  3927. let mid = Math.floor((start + end) / 2), comparedPosition = newLandmark.ref.current.compareDocumentPosition(this.landmarks[mid].ref.current);
  3928. !!(comparedPosition & Node.DOCUMENT_POSITION_PRECEDING || comparedPosition & Node.DOCUMENT_POSITION_CONTAINS) ? start = mid + 1 : end = mid - 1;
  3929. }
  3930. this.landmarks.splice(start, 0, newLandmark), this.checkLabels(newLandmark.role);
  3931. }
  3932. updateLandmark(landmark) {
  3933. let index = this.landmarks.findIndex((l3) => l3.ref === landmark.ref);
  3934. index >= 0 && (this.landmarks[index] = {
  3935. ...this.landmarks[index],
  3936. ...landmark
  3937. }, this.checkLabels(this.landmarks[index].role));
  3938. }
  3939. removeLandmark(ref) {
  3940. this.landmarks = this.landmarks.filter((landmark) => landmark.ref !== ref), this.teardownIfNeeded();
  3941. }
  3942. /**
  3943. * Warn if there are 2+ landmarks with the same role but no label.
  3944. * Labels for landmarks with the same role must also be unique.
  3945. *
  3946. * See https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/.
  3947. */
  3948. checkLabels(role) {
  3949. let landmarksWithRole = this.getLandmarksByRole(role);
  3950. landmarksWithRole.size > 1 && [
  3951. ...landmarksWithRole
  3952. ].filter((landmark) => !landmark.label).length > 0;
  3953. }
  3954. /**
  3955. * Get the landmark that is the closest parent in the DOM.
  3956. * Returns undefined if no parent is a landmark.
  3957. */
  3958. closestLandmark(element) {
  3959. let landmarkMap = new Map(this.landmarks.map((l3) => [
  3960. l3.ref.current,
  3961. l3
  3962. ])), currentElement = element;
  3963. for (; currentElement && !landmarkMap.has(currentElement) && currentElement !== document.body && currentElement.parentElement; ) currentElement = currentElement.parentElement;
  3964. return landmarkMap.get(currentElement);
  3965. }
  3966. /**
  3967. * Gets the next landmark, in DOM focus order, or previous if backwards is specified.
  3968. * If last landmark, next should be the first landmark.
  3969. * If not inside a landmark, will return first landmark.
  3970. * Returns undefined if there are no landmarks.
  3971. */
  3972. getNextLandmark(element, { backward }) {
  3973. var _this_landmarks_nextLandmarkIndex_ref_current;
  3974. let currentLandmark = this.closestLandmark(element), nextLandmarkIndex = backward ? this.landmarks.length - 1 : 0;
  3975. currentLandmark && (nextLandmarkIndex = this.landmarks.indexOf(currentLandmark) + (backward ? -1 : 1));
  3976. let wrapIfNeeded = () => {
  3977. if (nextLandmarkIndex < 0) {
  3978. if (!element.dispatchEvent(new CustomEvent("react-aria-landmark-navigation", {
  3979. detail: {
  3980. direction: "backward"
  3981. },
  3982. bubbles: !0,
  3983. cancelable: !0
  3984. }))) return !0;
  3985. nextLandmarkIndex = this.landmarks.length - 1;
  3986. } else if (nextLandmarkIndex >= this.landmarks.length) {
  3987. if (!element.dispatchEvent(new CustomEvent("react-aria-landmark-navigation", {
  3988. detail: {
  3989. direction: "forward"
  3990. },
  3991. bubbles: !0,
  3992. cancelable: !0
  3993. }))) return !0;
  3994. nextLandmarkIndex = 0;
  3995. }
  3996. return nextLandmarkIndex < 0 || nextLandmarkIndex >= this.landmarks.length;
  3997. };
  3998. if (wrapIfNeeded()) return;
  3999. let i2 = nextLandmarkIndex;
  4000. 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]"); ) {
  4001. if (nextLandmarkIndex += backward ? -1 : 1, wrapIfNeeded()) return;
  4002. if (nextLandmarkIndex === i2) break;
  4003. }
  4004. return this.landmarks[nextLandmarkIndex];
  4005. }
  4006. /**
  4007. * Look at next landmark. If an element was previously focused inside, restore focus there.
  4008. * If not, focus the landmark itself.
  4009. * If no landmarks at all, or none with focusable elements, don't move focus.
  4010. */
  4011. f6Handler(e2) {
  4012. e2.key === "F6" && (e2.altKey ? this.focusMain() : this.navigate(e2.target, e2.shiftKey)) && (e2.preventDefault(), e2.stopPropagation());
  4013. }
  4014. focusMain() {
  4015. let main = this.getLandmarkByRole("main");
  4016. return main && main.ref.current && document.contains(main.ref.current) ? (this.focusLandmark(main.ref.current, "forward"), !0) : !1;
  4017. }
  4018. navigate(from, backward) {
  4019. let nextLandmark = this.getNextLandmark(from, {
  4020. backward
  4021. });
  4022. if (!nextLandmark) return !1;
  4023. if (nextLandmark.lastFocused) {
  4024. let lastFocused = nextLandmark.lastFocused;
  4025. if (document.body.contains(lastFocused))
  4026. return lastFocused.focus(), !0;
  4027. }
  4028. return nextLandmark.ref.current && document.contains(nextLandmark.ref.current) ? (this.focusLandmark(nextLandmark.ref.current, backward ? "backward" : "forward"), !0) : !1;
  4029. }
  4030. /**
  4031. * Sets lastFocused for a landmark, if focus is moved within that landmark.
  4032. * Lets the last focused landmark know it was blurred if something else is focused.
  4033. */
  4034. focusinHandler(e2) {
  4035. let currentLandmark = this.closestLandmark(e2.target);
  4036. currentLandmark && currentLandmark.ref.current !== e2.target && this.updateLandmark({
  4037. ref: currentLandmark.ref,
  4038. lastFocused: e2.target
  4039. });
  4040. let previousFocusedElement = e2.relatedTarget;
  4041. if (previousFocusedElement) {
  4042. let closestPreviousLandmark = this.closestLandmark(previousFocusedElement);
  4043. closestPreviousLandmark && closestPreviousLandmark.ref.current === previousFocusedElement && closestPreviousLandmark.blur();
  4044. }
  4045. }
  4046. /**
  4047. * Track if the focus is lost to the body. If it is, do cleanup on the landmark that last had focus.
  4048. */
  4049. focusoutHandler(e2) {
  4050. let previousFocusedElement = e2.target, nextFocusedElement = e2.relatedTarget;
  4051. if (!nextFocusedElement || nextFocusedElement === document) {
  4052. let closestPreviousLandmark = this.closestLandmark(previousFocusedElement);
  4053. closestPreviousLandmark && closestPreviousLandmark.ref.current === previousFocusedElement && closestPreviousLandmark.blur();
  4054. }
  4055. }
  4056. createLandmarkController() {
  4057. let instance = this;
  4058. return instance.refCount++, instance.setupIfNeeded(), {
  4059. navigate(direction, opts) {
  4060. let element = opts?.from || document.activeElement;
  4061. return instance.navigate(element, direction === "backward");
  4062. },
  4063. focusNext(opts) {
  4064. let element = opts?.from || document.activeElement;
  4065. return instance.navigate(element, !1);
  4066. },
  4067. focusPrevious(opts) {
  4068. let element = opts?.from || document.activeElement;
  4069. return instance.navigate(element, !0);
  4070. },
  4071. focusMain() {
  4072. return instance.focusMain();
  4073. },
  4074. dispose() {
  4075. instance && (instance.refCount--, instance.teardownIfNeeded(), instance = null);
  4076. }
  4077. };
  4078. }
  4079. registerLandmark(landmark) {
  4080. return this.landmarks.find((l3) => l3.ref === landmark.ref) ? this.updateLandmark(landmark) : this.addLandmark(landmark), () => this.removeLandmark(landmark.ref);
  4081. }
  4082. constructor() {
  4083. 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);
  4084. }
  4085. };
  4086. function $a86207c5d7f7e1fb$export$4cc632584fd87fae(props, ref) {
  4087. let { role, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, focus } = props, manager = $a86207c5d7f7e1fb$var$useLandmarkManager(), label = ariaLabel || ariaLabelledby, [isLandmarkFocused, setIsLandmarkFocused] = useState(!1), defaultFocus = useCallback(() => {
  4088. setIsLandmarkFocused(!0);
  4089. }, [
  4090. setIsLandmarkFocused
  4091. ]), blur = useCallback(() => {
  4092. setIsLandmarkFocused(!1);
  4093. }, [
  4094. setIsLandmarkFocused
  4095. ]);
  4096. return $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  4097. if (manager) return manager.registerLandmark({
  4098. ref,
  4099. label,
  4100. role,
  4101. focus: focus || defaultFocus,
  4102. blur
  4103. });
  4104. }, [
  4105. manager,
  4106. label,
  4107. ref,
  4108. role,
  4109. focus,
  4110. defaultFocus,
  4111. blur
  4112. ]), useEffect(() => {
  4113. var _ref_current;
  4114. isLandmarkFocused && ((_ref_current = ref.current) === null || _ref_current === void 0 || _ref_current.focus());
  4115. }, [
  4116. isLandmarkFocused,
  4117. ref
  4118. ]), {
  4119. landmarkProps: {
  4120. role,
  4121. tabIndex: isLandmarkFocused ? -1 : void 0,
  4122. "aria-label": ariaLabel,
  4123. "aria-labelledby": ariaLabelledby
  4124. }
  4125. };
  4126. }
  4127. // src/manager/hooks/useLandmark.ts
  4128. function useLandmark(props, ref) {
  4129. let { landmarkProps } = $a86207c5d7f7e1fb$export$4cc632584fd87fae(props, ref);
  4130. return {
  4131. landmarkProps: {
  4132. ...landmarkProps,
  4133. "data-sb-landmark": !0
  4134. }
  4135. };
  4136. }
  4137. // src/manager/components/mobile/navigation/MobileAddonsDrawer.tsx
  4138. init_react();
  4139. var MobileAddonsDrawer = ({
  4140. children,
  4141. id,
  4142. isOpen,
  4143. onOpenChange
  4144. }) => react_default.createElement(
  4145. Modal,
  4146. {
  4147. ariaLabel: "Addon panel",
  4148. transitionDuration: 300,
  4149. variant: "bottom-drawer",
  4150. height: "42vh",
  4151. id,
  4152. open: isOpen,
  4153. onOpenChange
  4154. },
  4155. children
  4156. );
  4157. // src/manager/components/mobile/navigation/MobileMenuDrawer.tsx
  4158. init_react();
  4159. // src/manager/components/mobile/about/MobileAbout.tsx
  4160. init_react();
  4161. // ../../node_modules/react-transition-state/dist/esm/hooks/useTransitionState.mjs
  4162. init_react();
  4163. // ../../node_modules/react-transition-state/dist/esm/hooks/utils.mjs
  4164. var STATUS = ["preEnter", "entering", "entered", "preExit", "exiting", "exited", "unmounted"], getState = (status) => ({
  4165. _s: status,
  4166. status: STATUS[status],
  4167. isEnter: status < 3,
  4168. isMounted: status !== 6,
  4169. isResolved: status === 2 || status > 4
  4170. }), startOrEnd = (unmounted) => unmounted ? 6 : 5, getEndStatus = (status, unmountOnExit) => {
  4171. switch (status) {
  4172. case 1:
  4173. case 0:
  4174. return 2;
  4175. case 4:
  4176. case 3:
  4177. return startOrEnd(unmountOnExit);
  4178. }
  4179. }, getTimeout = (timeout) => typeof timeout == "object" ? [timeout.enter, timeout.exit] : [timeout, timeout], nextTick = (transitState, status) => setTimeout(() => {
  4180. isNaN(document.body.offsetTop) || transitState(status + 1);
  4181. }, 0);
  4182. // ../../node_modules/react-transition-state/dist/esm/hooks/useTransitionState.mjs
  4183. var updateState = (status, setState, latestState, timeoutId, onChange) => {
  4184. clearTimeout(timeoutId.current);
  4185. let state = getState(status);
  4186. setState(state), latestState.current = state, onChange && onChange({
  4187. current: state
  4188. });
  4189. }, useTransitionState = ({
  4190. enter = !0,
  4191. exit = !0,
  4192. preEnter,
  4193. preExit,
  4194. timeout,
  4195. initialEntered,
  4196. mountOnEnter,
  4197. unmountOnExit,
  4198. onStateChange: onChange
  4199. } = {}) => {
  4200. let [state, setState] = useState(() => getState(initialEntered ? 2 : startOrEnd(mountOnEnter))), latestState = useRef(state), timeoutId = useRef(), [enterTimeout, exitTimeout] = getTimeout(timeout), endTransition = useCallback(() => {
  4201. let status = getEndStatus(latestState.current._s, unmountOnExit);
  4202. status && updateState(status, setState, latestState, timeoutId, onChange);
  4203. }, [onChange, unmountOnExit]), toggle = useCallback((toEnter) => {
  4204. let transitState = (status) => {
  4205. switch (updateState(status, setState, latestState, timeoutId, onChange), status) {
  4206. case 1:
  4207. enterTimeout >= 0 && (timeoutId.current = setTimeout(endTransition, enterTimeout));
  4208. break;
  4209. case 4:
  4210. exitTimeout >= 0 && (timeoutId.current = setTimeout(endTransition, exitTimeout));
  4211. break;
  4212. case 0:
  4213. case 3:
  4214. timeoutId.current = nextTick(transitState, status);
  4215. break;
  4216. }
  4217. }, enterStage = latestState.current.isEnter;
  4218. typeof toEnter != "boolean" && (toEnter = !enterStage), toEnter ? !enterStage && transitState(enter ? preEnter ? 0 : 1 : 2) : enterStage && transitState(exit ? preExit ? 3 : 4 : startOrEnd(unmountOnExit));
  4219. }, [endTransition, onChange, enter, exit, preEnter, preExit, enterTimeout, exitTimeout, unmountOnExit]);
  4220. return [state, toggle, endTransition];
  4221. };
  4222. // ../../node_modules/react-transition-state/dist/esm/hooks/useTransitionMap.mjs
  4223. init_react();
  4224. var updateState2 = (key, status, setStateMap, latestStateMap, timeoutId, onChange) => {
  4225. clearTimeout(timeoutId);
  4226. let state = getState(status), stateMap = new Map(latestStateMap.current);
  4227. stateMap.set(key, state), setStateMap(stateMap), latestStateMap.current = stateMap, onChange && onChange({
  4228. key,
  4229. current: state
  4230. });
  4231. }, useTransitionMap = ({
  4232. allowMultiple,
  4233. enter = !0,
  4234. exit = !0,
  4235. preEnter,
  4236. preExit,
  4237. timeout,
  4238. initialEntered,
  4239. mountOnEnter,
  4240. unmountOnExit,
  4241. onStateChange: onChange
  4242. } = {}) => {
  4243. let [stateMap, setStateMap] = useState(/* @__PURE__ */ new Map()), latestStateMap = useRef(stateMap), configMap = useRef(/* @__PURE__ */ new Map()), [enterTimeout, exitTimeout] = getTimeout(timeout), setItem = useCallback((key, config) => {
  4244. let {
  4245. initialEntered: _initialEntered = initialEntered
  4246. } = config || {}, status = _initialEntered ? 2 : startOrEnd(mountOnEnter);
  4247. updateState2(key, status, setStateMap, latestStateMap), configMap.current.set(key, {});
  4248. }, [initialEntered, mountOnEnter]), deleteItem = useCallback((key) => {
  4249. let newStateMap = new Map(latestStateMap.current);
  4250. return newStateMap.delete(key) ? (setStateMap(newStateMap), latestStateMap.current = newStateMap, configMap.current.delete(key), !0) : !1;
  4251. }, []), endTransition = useCallback((key) => {
  4252. let stateObj = latestStateMap.current.get(key);
  4253. if (!stateObj)
  4254. return;
  4255. let {
  4256. timeoutId
  4257. } = configMap.current.get(key), status = getEndStatus(stateObj._s, unmountOnExit);
  4258. status && updateState2(key, status, setStateMap, latestStateMap, timeoutId, onChange);
  4259. }, [onChange, unmountOnExit]), toggle = useCallback((key, toEnter) => {
  4260. let stateObj = latestStateMap.current.get(key);
  4261. if (!stateObj)
  4262. return;
  4263. let config = configMap.current.get(key), transitState = (status) => {
  4264. switch (updateState2(key, status, setStateMap, latestStateMap, config.timeoutId, onChange), status) {
  4265. case 1:
  4266. enterTimeout >= 0 && (config.timeoutId = setTimeout(() => endTransition(key), enterTimeout));
  4267. break;
  4268. case 4:
  4269. exitTimeout >= 0 && (config.timeoutId = setTimeout(() => endTransition(key), exitTimeout));
  4270. break;
  4271. case 0:
  4272. case 3:
  4273. config.timeoutId = nextTick(transitState, status);
  4274. break;
  4275. }
  4276. }, enterStage = stateObj.isEnter;
  4277. 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));
  4278. }, [onChange, endTransition, allowMultiple, enter, exit, preEnter, preExit, enterTimeout, exitTimeout, unmountOnExit]), toggleAll = useCallback((toEnter) => {
  4279. if (!(!allowMultiple && toEnter !== !1))
  4280. for (let key of latestStateMap.current.keys()) toggle(key, toEnter);
  4281. }, [allowMultiple, toggle]);
  4282. return {
  4283. stateMap,
  4284. toggle,
  4285. toggleAll,
  4286. endTransition,
  4287. setItem,
  4288. deleteItem
  4289. };
  4290. };
  4291. // src/manager/components/upgrade/UpgradeBlock.tsx
  4292. init_react();
  4293. var UpgradeBlock = ({ onNavigateToWhatsNew }) => {
  4294. let api = useStorybookApi(), [activeTab, setActiveTab] = useState("npm");
  4295. 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"));
  4296. }, Container2 = styled.div(({ theme }) => ({
  4297. border: "1px solid",
  4298. borderRadius: 5,
  4299. padding: 20,
  4300. marginTop: 0,
  4301. borderColor: theme.appBorderColor,
  4302. fontSize: theme.typography.size.s2,
  4303. width: "100%",
  4304. [MEDIA_DESKTOP_BREAKPOINT]: {
  4305. maxWidth: 400
  4306. }
  4307. })), Tabs2 = styled.div({
  4308. display: "flex",
  4309. gap: 2
  4310. }), Code2 = styled.pre(({ theme }) => ({
  4311. background: theme.base === "light" ? "rgba(0, 0, 0, 0.05)" : theme.appBorderColor,
  4312. fontSize: theme.typography.size.s2 - 1,
  4313. margin: "4px 0 16px"
  4314. })), ButtonTab = styled.button(({ theme, active }) => ({
  4315. all: "unset",
  4316. alignItems: "center",
  4317. gap: 10,
  4318. color: theme.color.defaultText,
  4319. fontSize: theme.typography.size.s2 - 1,
  4320. borderBottom: "2px solid transparent",
  4321. borderBottomColor: active ? theme.color.secondary : "none",
  4322. padding: "0 10px 5px",
  4323. marginBottom: "5px",
  4324. cursor: "pointer"
  4325. }));
  4326. // src/manager/components/mobile/about/MobileAbout.tsx
  4327. var MobileAbout = () => {
  4328. let { isMobileAboutOpen, setMobileAboutOpen } = useLayout(), aboutRef = useRef(null), [state, toggle] = useTransitionState({
  4329. timeout: 300,
  4330. mountOnEnter: !0,
  4331. unmountOnExit: !0
  4332. });
  4333. return useEffect(() => {
  4334. toggle(isMobileAboutOpen);
  4335. }, [isMobileAboutOpen, toggle]), state.isMounted ? react_default.createElement(
  4336. Container3,
  4337. {
  4338. ref: aboutRef,
  4339. $status: state.status,
  4340. $transitionDuration: 300
  4341. },
  4342. react_default.createElement(ScrollArea, { vertical: !0, offset: 3, scrollbarSize: 6 }, react_default.createElement(InnerArea, null, react_default.createElement(
  4343. CloseButton,
  4344. {
  4345. onClick: () => setMobileAboutOpen(!1),
  4346. ariaLabel: "Close about section",
  4347. tooltip: "Close about section",
  4348. variant: "ghost"
  4349. },
  4350. react_default.createElement(ArrowLeftIcon, null),
  4351. "Back"
  4352. ), react_default.createElement(LinkContainer, null, react_default.createElement(
  4353. LinkLine,
  4354. {
  4355. href: "https://github.com/storybookjs/storybook",
  4356. target: "_blank",
  4357. rel: "noopener noreferrer"
  4358. },
  4359. react_default.createElement(LinkLeft, null, react_default.createElement(GithubIcon, null), react_default.createElement("span", null, "Github")),
  4360. react_default.createElement(ShareAltIcon, { width: 12 })
  4361. ), react_default.createElement(
  4362. LinkLine,
  4363. {
  4364. href: "https://storybook.js.org/docs/get-started/install?ref=ui",
  4365. target: "_blank",
  4366. rel: "noopener noreferrer"
  4367. },
  4368. react_default.createElement(LinkLeft, null, react_default.createElement(StorybookIcon, null), react_default.createElement("span", null, "Documentation")),
  4369. react_default.createElement(ShareAltIcon, { width: 12 })
  4370. )), 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(
  4371. Link,
  4372. {
  4373. href: "https://github.com/storybookjs/storybook/graphs/contributors",
  4374. rel: "noopener noreferrer"
  4375. },
  4376. "Storybook Community"
  4377. ))))
  4378. ) : null;
  4379. }, slideFromRight = keyframes({
  4380. from: {
  4381. opacity: 0,
  4382. transform: "translate(20px, 0)"
  4383. },
  4384. to: {
  4385. opacity: 1,
  4386. transform: "translate(0, 0)"
  4387. }
  4388. }), slideToRight = keyframes({
  4389. from: {
  4390. opacity: 1,
  4391. transform: "translate(0, 0)"
  4392. },
  4393. to: {
  4394. opacity: 0,
  4395. transform: "translate(20px, 0)"
  4396. }
  4397. }), Container3 = styled.div(
  4398. ({ theme, $status, $transitionDuration }) => ({
  4399. position: "absolute",
  4400. width: "100%",
  4401. height: "100%",
  4402. borderRadius: "10px 10px 0 0",
  4403. top: 0,
  4404. left: 0,
  4405. zIndex: 11,
  4406. overflow: "auto",
  4407. color: theme.color.defaultText,
  4408. background: theme.background.content,
  4409. animation: $status === "exiting" ? `${slideToRight} ${$transitionDuration}ms` : `${slideFromRight} ${$transitionDuration}ms`
  4410. })
  4411. ), InnerArea = styled.div({
  4412. display: "flex",
  4413. flexDirection: "column",
  4414. gap: 20,
  4415. padding: "25px 12px 20px"
  4416. }), LinkContainer = styled.div({}), LinkLine = styled.a(({ theme }) => ({
  4417. all: "unset",
  4418. display: "flex",
  4419. alignItems: "center",
  4420. justifyContent: "space-between",
  4421. fontSize: theme.typography.size.s2 - 1,
  4422. borderBottom: `1px solid ${theme.appBorderColor}`,
  4423. cursor: "pointer",
  4424. padding: "0 10px",
  4425. "&:last-child": {
  4426. borderBottom: "none"
  4427. }
  4428. })), LinkLeft = styled.div(({ theme }) => ({
  4429. display: "flex",
  4430. alignItems: "center",
  4431. fontSize: theme.typography.size.s2 - 1,
  4432. height: 40,
  4433. gap: 5
  4434. })), BottomText = styled.div(({ theme }) => ({
  4435. fontSize: theme.typography.size.s2 - 1,
  4436. marginTop: 30
  4437. })), CloseButton = styled(Button)({
  4438. alignSelf: "start"
  4439. });
  4440. // src/manager/components/mobile/navigation/MobileMenuDrawer.tsx
  4441. var MobileMenuDrawer = ({
  4442. children,
  4443. id,
  4444. isOpen,
  4445. onOpenChange
  4446. }) => react_default.createElement(
  4447. Modal,
  4448. {
  4449. ariaLabel: "Menu",
  4450. transitionDuration: 300,
  4451. variant: "bottom-drawer",
  4452. height: "80vh",
  4453. id,
  4454. open: isOpen,
  4455. onOpenChange
  4456. },
  4457. children,
  4458. react_default.createElement(MobileAbout, null)
  4459. );
  4460. // src/manager/components/mobile/navigation/MobileNavigation.tsx
  4461. function combineIndexes(rootIndex, refs) {
  4462. let combinedIndex = { ...rootIndex || {} };
  4463. return Object.values(refs).forEach((ref) => {
  4464. ref.index && Object.assign(combinedIndex, ref.index);
  4465. }), combinedIndex;
  4466. }
  4467. var useFullStoryName = () => {
  4468. let { index, refs } = useStorybookState(), api = useStorybookApi(), currentStory = api.getCurrentStoryData();
  4469. if (!currentStory)
  4470. return "";
  4471. let combinedIndex = combineIndexes(index, refs || {}), storyLabel = currentStory.renderLabel?.(currentStory, api), fullStoryName = typeof storyLabel == "string" ? storyLabel : currentStory.name, node = combinedIndex[currentStory.id];
  4472. for (; node && "parent" in node && node.parent && combinedIndex[node.parent] && fullStoryName.length < 24; ) {
  4473. node = combinedIndex[node.parent];
  4474. let parentLabel = node.renderLabel?.(node, api);
  4475. fullStoryName = `${typeof parentLabel == "string" ? parentLabel : node.name}/${fullStoryName}`;
  4476. }
  4477. return fullStoryName;
  4478. }, MobileNavigation = ({
  4479. menu,
  4480. panel,
  4481. showPanel,
  4482. ...props
  4483. }) => {
  4484. let { isMobileMenuOpen, isMobilePanelOpen, setMobileMenuOpen, setMobilePanelOpen } = useLayout(), fullStoryName = useFullStoryName(), headingId = $bdb11010cef70236$export$f680877a34711e37(), sectionRef = useRef(null), { landmarkProps } = useLandmark(
  4485. { "aria-labelledby": headingId, role: "banner" },
  4486. sectionRef
  4487. );
  4488. return react_default.createElement(Container4, { ...props }, react_default.createElement(
  4489. MobileMenuDrawer,
  4490. {
  4491. id: "storybook-mobile-menu",
  4492. isOpen: isMobileMenuOpen,
  4493. onOpenChange: setMobileMenuOpen
  4494. },
  4495. menu
  4496. ), react_default.createElement(
  4497. MobileAddonsDrawer,
  4498. {
  4499. id: "storybook-mobile-addon-panel",
  4500. isOpen: isMobilePanelOpen,
  4501. onOpenChange: setMobilePanelOpen
  4502. },
  4503. panel
  4504. ), !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(
  4505. BottomBarButton,
  4506. {
  4507. padding: "small",
  4508. variant: "ghost",
  4509. onClick: () => setMobileMenuOpen(!isMobileMenuOpen),
  4510. ariaLabel: "Open navigation menu",
  4511. "aria-expanded": isMobileMenuOpen,
  4512. "aria-controls": "storybook-mobile-menu"
  4513. },
  4514. react_default.createElement(MenuIcon, null),
  4515. react_default.createElement(Text, null, fullStoryName)
  4516. ), react_default.createElement("span", { className: "sb-sr-only", "aria-current": "page" }, fullStoryName), showPanel && react_default.createElement(
  4517. BottomBarButton,
  4518. {
  4519. padding: "small",
  4520. variant: "ghost",
  4521. onClick: () => setMobilePanelOpen(!0),
  4522. ariaLabel: "Open addon panel",
  4523. "aria-expanded": isMobilePanelOpen,
  4524. "aria-controls": "storybook-mobile-addon-panel"
  4525. },
  4526. react_default.createElement(BottomBarToggleIcon, null)
  4527. )));
  4528. }, Container4 = styled.section(({ theme }) => ({
  4529. bottom: 0,
  4530. left: 0,
  4531. width: "100%",
  4532. zIndex: 10,
  4533. background: theme.barBg,
  4534. borderTop: `1px solid ${theme.appBorderColor}`
  4535. })), MobileBottomBar = styled.header({
  4536. display: "flex",
  4537. alignItems: "center",
  4538. justifyContent: "space-between",
  4539. width: "100%",
  4540. height: 40,
  4541. padding: "0 6px",
  4542. /* Because Popper.js's tooltip is creating extra div layers, we have to
  4543. * punch through them to configure the button to ellipsize. */
  4544. "& > *:first-child": {
  4545. /* 6px padding * 2 + 28px for the orientation button */
  4546. maxWidth: "calc(100% - 40px)",
  4547. "& > button": {
  4548. maxWidth: "100%"
  4549. },
  4550. "& > button p": {
  4551. textOverflow: "ellipsis"
  4552. }
  4553. }
  4554. }), BottomBarButton = styled(Button)({
  4555. WebkitLineClamp: 1,
  4556. flexShrink: 1,
  4557. p: {
  4558. textOverflow: "ellipsis"
  4559. }
  4560. }), Text = styled.p({
  4561. display: "-webkit-box",
  4562. WebkitLineClamp: 1,
  4563. WebkitBoxOrient: "vertical",
  4564. overflow: "hidden"
  4565. });
  4566. // src/manager/components/layout/MainAreaContainer.tsx
  4567. init_react();
  4568. var PagesInnerContainer = styled.main(({ theme }) => ({
  4569. display: "flex",
  4570. flexDirection: "column",
  4571. gridRowStart: "sidebar-start",
  4572. gridRowEnd: "-1",
  4573. gridColumnStart: "sidebar-end",
  4574. gridColumnEnd: "-1",
  4575. backgroundColor: theme.appContentBg,
  4576. zIndex: 1
  4577. })), PagesContainer = react_default.memo(function(props) {
  4578. let { children } = props, mainRef = useRef(null), { landmarkProps } = useLandmark(
  4579. { "aria-labelledby": "main-content-heading", role: "main" },
  4580. mainRef
  4581. );
  4582. 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);
  4583. }), MainInnerContainer = styled.div(({ theme, shown }) => ({
  4584. flex: 1,
  4585. position: "relative",
  4586. backgroundColor: theme.appContentBg,
  4587. display: shown ? "grid" : "none",
  4588. // This is needed to make the content container fill the available space
  4589. overflow: "auto",
  4590. [MEDIA_DESKTOP_BREAKPOINT]: {
  4591. flex: "auto",
  4592. gridArea: "content"
  4593. }
  4594. })), MainAreaContainer = react_default.memo(function({
  4595. showPages,
  4596. slotMain,
  4597. slotPages
  4598. }) {
  4599. 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)));
  4600. });
  4601. // src/manager/components/layout/PanelContainer.tsx
  4602. init_react();
  4603. // src/manager/components/layout/Drag.tsx
  4604. init_react();
  4605. // src/components/components/tooltip/TooltipNote.tsx
  4606. init_react();
  4607. var Note = styled.div(({ theme }) => ({
  4608. padding: "2px 6px",
  4609. lineHeight: "16px",
  4610. fontSize: 10,
  4611. fontWeight: theme.typography.weight.bold,
  4612. color: theme.color.lightest,
  4613. boxShadow: "0 0 5px 0 rgba(0, 0, 0, 0.3)",
  4614. borderRadius: 4,
  4615. whiteSpace: "nowrap",
  4616. pointerEvents: "none",
  4617. zIndex: -1,
  4618. background: theme.base === "light" ? "rgba(60, 60, 60, 0.9)" : "rgba(0, 0, 0, 0.95)"
  4619. })), TooltipNote2 = ({ note, ...props }) => react_default.createElement(Note, { ...props }, note);
  4620. // src/components/components/tooltip/TooltipProvider.tsx
  4621. init_react();
  4622. // ../../node_modules/@react-aria/interactions/dist/utils.mjs
  4623. init_react();
  4624. function $8a9cb279dc87e130$export$525bc4921d56d4a(nativeEvent) {
  4625. let event = nativeEvent;
  4626. return event.nativeEvent = nativeEvent, event.isDefaultPrevented = () => event.defaultPrevented, event.isPropagationStopped = () => event.cancelBubble, event.persist = () => {
  4627. }, event;
  4628. }
  4629. function $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target) {
  4630. Object.defineProperty(event, "target", {
  4631. value: target
  4632. }), Object.defineProperty(event, "currentTarget", {
  4633. value: target
  4634. });
  4635. }
  4636. function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
  4637. let stateRef = useRef({
  4638. isFocused: !1,
  4639. observer: null
  4640. });
  4641. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  4642. let state = stateRef.current;
  4643. return () => {
  4644. state.observer && (state.observer.disconnect(), state.observer = null);
  4645. };
  4646. }, []);
  4647. let dispatchBlur = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4648. onBlur?.(e2);
  4649. });
  4650. return useCallback((e2) => {
  4651. if (e2.target instanceof HTMLButtonElement || e2.target instanceof HTMLInputElement || e2.target instanceof HTMLTextAreaElement || e2.target instanceof HTMLSelectElement) {
  4652. stateRef.current.isFocused = !0;
  4653. let target = e2.target, onBlurHandler = (e3) => {
  4654. if (stateRef.current.isFocused = !1, target.disabled) {
  4655. let event = $8a9cb279dc87e130$export$525bc4921d56d4a(e3);
  4656. dispatchBlur(event);
  4657. }
  4658. stateRef.current.observer && (stateRef.current.observer.disconnect(), stateRef.current.observer = null);
  4659. };
  4660. target.addEventListener("focusout", onBlurHandler, {
  4661. once: !0
  4662. }), stateRef.current.observer = new MutationObserver(() => {
  4663. if (stateRef.current.isFocused && target.disabled) {
  4664. var _stateRef_current_observer;
  4665. (_stateRef_current_observer = stateRef.current.observer) === null || _stateRef_current_observer === void 0 || _stateRef_current_observer.disconnect();
  4666. let relatedTargetEl = target === document.activeElement ? null : document.activeElement;
  4667. target.dispatchEvent(new FocusEvent("blur", {
  4668. relatedTarget: relatedTargetEl
  4669. })), target.dispatchEvent(new FocusEvent("focusout", {
  4670. bubbles: !0,
  4671. relatedTarget: relatedTargetEl
  4672. }));
  4673. }
  4674. }), stateRef.current.observer.observe(target, {
  4675. attributes: !0,
  4676. attributeFilter: [
  4677. "disabled"
  4678. ]
  4679. });
  4680. }
  4681. }, [
  4682. dispatchBlur
  4683. ]);
  4684. }
  4685. var $8a9cb279dc87e130$export$fda7da73ab5d4c48 = !1;
  4686. function $8a9cb279dc87e130$export$cabe61c495ee3649(target) {
  4687. for (; target && !$b4b717babfbb907b$export$4c063cf1350e6fed(target); ) target = target.parentElement;
  4688. let window2 = $431fbd86ca7dc216$export$f21a1ffae260145a(target), activeElement = window2.document.activeElement;
  4689. if (!activeElement || activeElement === target) return;
  4690. $8a9cb279dc87e130$export$fda7da73ab5d4c48 = !0;
  4691. let isRefocusing = !1, onBlur = (e2) => {
  4692. (e2.target === activeElement || isRefocusing) && e2.stopImmediatePropagation();
  4693. }, onFocusOut = (e2) => {
  4694. (e2.target === activeElement || isRefocusing) && (e2.stopImmediatePropagation(), !target && !isRefocusing && (isRefocusing = !0, $7215afc6de606d6b$export$de79e2c695e052f3(activeElement), cleanup()));
  4695. }, onFocus = (e2) => {
  4696. (e2.target === target || isRefocusing) && e2.stopImmediatePropagation();
  4697. }, onFocusIn = (e2) => {
  4698. (e2.target === target || isRefocusing) && (e2.stopImmediatePropagation(), isRefocusing || (isRefocusing = !0, $7215afc6de606d6b$export$de79e2c695e052f3(activeElement), cleanup()));
  4699. };
  4700. window2.addEventListener("blur", onBlur, !0), window2.addEventListener("focusout", onFocusOut, !0), window2.addEventListener("focusin", onFocusIn, !0), window2.addEventListener("focus", onFocus, !0);
  4701. let cleanup = () => {
  4702. 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;
  4703. }, raf = requestAnimationFrame(cleanup);
  4704. return cleanup;
  4705. }
  4706. // ../../node_modules/@react-aria/interactions/dist/textSelection.mjs
  4707. var $14c0b72509d70225$var$state = "default", $14c0b72509d70225$var$savedUserSelect = "", $14c0b72509d70225$var$modifiedElementMap = /* @__PURE__ */ new WeakMap();
  4708. function $14c0b72509d70225$export$16a4697467175487(target) {
  4709. if ($c87311424ea30a05$export$fedb369cb70207f1()) {
  4710. if ($14c0b72509d70225$var$state === "default") {
  4711. let documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
  4712. $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect, documentObject.documentElement.style.webkitUserSelect = "none";
  4713. }
  4714. $14c0b72509d70225$var$state = "disabled";
  4715. } else if (target instanceof HTMLElement || target instanceof SVGElement) {
  4716. let property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
  4717. $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]), target.style[property] = "none";
  4718. }
  4719. }
  4720. function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
  4721. if ($c87311424ea30a05$export$fedb369cb70207f1()) {
  4722. if ($14c0b72509d70225$var$state !== "disabled") return;
  4723. $14c0b72509d70225$var$state = "restoring", setTimeout(() => {
  4724. $bbed8b41f857bcc0$export$24490316f764c430(() => {
  4725. if ($14c0b72509d70225$var$state === "restoring") {
  4726. let documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
  4727. documentObject.documentElement.style.webkitUserSelect === "none" && (documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || ""), $14c0b72509d70225$var$savedUserSelect = "", $14c0b72509d70225$var$state = "default";
  4728. }
  4729. });
  4730. }, 300);
  4731. } else if ((target instanceof HTMLElement || target instanceof SVGElement) && target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
  4732. let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target), property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
  4733. target.style[property] === "none" && (target.style[property] = targetOldUserSelect), target.getAttribute("style") === "" && target.removeAttribute("style"), $14c0b72509d70225$var$modifiedElementMap.delete(target);
  4734. }
  4735. }
  4736. // ../../node_modules/@react-aria/interactions/dist/context.mjs
  4737. init_react();
  4738. var $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = react_default.createContext({
  4739. register: () => {
  4740. }
  4741. });
  4742. $ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = "PressResponderContext";
  4743. // ../../node_modules/@swc/helpers/esm/_class_apply_descriptor_get.js
  4744. function _class_apply_descriptor_get(receiver, descriptor) {
  4745. return descriptor.get ? descriptor.get.call(receiver) : descriptor.value;
  4746. }
  4747. // ../../node_modules/@swc/helpers/esm/_class_extract_field_descriptor.js
  4748. function _class_extract_field_descriptor(receiver, privateMap, action) {
  4749. if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
  4750. return privateMap.get(receiver);
  4751. }
  4752. // ../../node_modules/@swc/helpers/esm/_class_private_field_get.js
  4753. function _class_private_field_get(receiver, privateMap) {
  4754. var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
  4755. return _class_apply_descriptor_get(receiver, descriptor);
  4756. }
  4757. // ../../node_modules/@swc/helpers/esm/_check_private_redeclaration.js
  4758. function _check_private_redeclaration(obj, privateCollection) {
  4759. if (privateCollection.has(obj))
  4760. throw new TypeError("Cannot initialize the same private elements twice on an object");
  4761. }
  4762. // ../../node_modules/@swc/helpers/esm/_class_private_field_init.js
  4763. function _class_private_field_init(obj, privateMap, value) {
  4764. _check_private_redeclaration(obj, privateMap), privateMap.set(obj, value);
  4765. }
  4766. // ../../node_modules/@swc/helpers/esm/_class_apply_descriptor_set.js
  4767. function _class_apply_descriptor_set(receiver, descriptor, value) {
  4768. if (descriptor.set) descriptor.set.call(receiver, value);
  4769. else {
  4770. if (!descriptor.writable)
  4771. throw new TypeError("attempted to set read only private field");
  4772. descriptor.value = value;
  4773. }
  4774. }
  4775. // ../../node_modules/@swc/helpers/esm/_class_private_field_set.js
  4776. function _class_private_field_set(receiver, privateMap, value) {
  4777. var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
  4778. return _class_apply_descriptor_set(receiver, descriptor, value), value;
  4779. }
  4780. // ../../node_modules/@react-aria/interactions/dist/usePress.mjs
  4781. init_react();
  4782. function $f6c31cce2adf654f$var$usePressResponderContext(props) {
  4783. let context = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
  4784. if (context) {
  4785. let { register, ...contextProps } = context;
  4786. props = $3ef42575df84b30b$export$9d1611c77c2fe928(contextProps, props), register();
  4787. }
  4788. return $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, props.ref), props;
  4789. }
  4790. var $f6c31cce2adf654f$var$_shouldStopPropagation = /* @__PURE__ */ new WeakMap(), $f6c31cce2adf654f$var$PressEvent = class {
  4791. continuePropagation() {
  4792. _class_private_field_set(this, $f6c31cce2adf654f$var$_shouldStopPropagation, !1);
  4793. }
  4794. get shouldStopPropagation() {
  4795. return _class_private_field_get(this, $f6c31cce2adf654f$var$_shouldStopPropagation);
  4796. }
  4797. constructor(type, pointerType, originalEvent, state) {
  4798. _class_private_field_init(this, $f6c31cce2adf654f$var$_shouldStopPropagation, {
  4799. writable: !0,
  4800. value: void 0
  4801. }), _class_private_field_set(this, $f6c31cce2adf654f$var$_shouldStopPropagation, !0);
  4802. var _state_target;
  4803. let currentTarget = (_state_target = state?.target) !== null && _state_target !== void 0 ? _state_target : originalEvent.currentTarget, rect = currentTarget?.getBoundingClientRect(), x2, y2 = 0, clientX, clientY = null;
  4804. 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;
  4805. }
  4806. }, $f6c31cce2adf654f$var$LINK_CLICKED = /* @__PURE__ */ Symbol("linkClicked"), $f6c31cce2adf654f$var$STYLE_ID = "react-aria-pressable-style", $f6c31cce2adf654f$var$PRESSABLE_ATTRIBUTE = "data-react-aria-pressable";
  4807. function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
  4808. 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({
  4809. isPressed: !1,
  4810. ignoreEmulatedMouseEvents: !1,
  4811. didFirePressStart: !1,
  4812. isTriggeringEvent: !1,
  4813. activePointerId: null,
  4814. target: null,
  4815. isOverTarget: !1,
  4816. pointerType: null,
  4817. disposables: []
  4818. }), { addGlobalListener, removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6(), triggerPressStart = $8ae05eaa5c114e9c$export$7f54fc3180508a52((originalEvent, pointerType) => {
  4819. let state = ref.current;
  4820. if (isDisabled || state.didFirePressStart) return !1;
  4821. let shouldStopPropagation = !0;
  4822. if (state.isTriggeringEvent = !0, onPressStart) {
  4823. let event = new $f6c31cce2adf654f$var$PressEvent("pressstart", pointerType, originalEvent);
  4824. onPressStart(event), shouldStopPropagation = event.shouldStopPropagation;
  4825. }
  4826. return onPressChange && onPressChange(!0), state.isTriggeringEvent = !1, state.didFirePressStart = !0, setPressed(!0), shouldStopPropagation;
  4827. }), triggerPressEnd = $8ae05eaa5c114e9c$export$7f54fc3180508a52((originalEvent, pointerType, wasPressed = !0) => {
  4828. let state = ref.current;
  4829. if (!state.didFirePressStart) return !1;
  4830. state.didFirePressStart = !1, state.isTriggeringEvent = !0;
  4831. let shouldStopPropagation = !0;
  4832. if (onPressEnd) {
  4833. let event = new $f6c31cce2adf654f$var$PressEvent("pressend", pointerType, originalEvent);
  4834. onPressEnd(event), shouldStopPropagation = event.shouldStopPropagation;
  4835. }
  4836. if (onPressChange && onPressChange(!1), setPressed(!1), onPress && wasPressed && !isDisabled) {
  4837. let event = new $f6c31cce2adf654f$var$PressEvent("press", pointerType, originalEvent);
  4838. onPress(event), shouldStopPropagation && (shouldStopPropagation = event.shouldStopPropagation);
  4839. }
  4840. return state.isTriggeringEvent = !1, shouldStopPropagation;
  4841. }), triggerPressUp = $8ae05eaa5c114e9c$export$7f54fc3180508a52((originalEvent, pointerType) => {
  4842. let state = ref.current;
  4843. if (isDisabled) return !1;
  4844. if (onPressUp) {
  4845. state.isTriggeringEvent = !0;
  4846. let event = new $f6c31cce2adf654f$var$PressEvent("pressup", pointerType, originalEvent);
  4847. return onPressUp(event), state.isTriggeringEvent = !1, event.shouldStopPropagation;
  4848. }
  4849. return !0;
  4850. }), cancel = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4851. let state = ref.current;
  4852. if (state.isPressed && state.target) {
  4853. 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);
  4854. for (let dispose of state.disposables) dispose();
  4855. state.disposables = [];
  4856. }
  4857. }), cancelOnPointerExit = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4858. shouldCancelOnPointerExit && cancel(e2);
  4859. }), triggerClick = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2) => {
  4860. isDisabled || onClick?.(e2);
  4861. }), triggerSyntheticClick = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e2, target) => {
  4862. if (!isDisabled && onClick) {
  4863. let event = new MouseEvent("click", e2);
  4864. $8a9cb279dc87e130$export$c2b7abe5d61ec696(event, target), onClick($8a9cb279dc87e130$export$525bc4921d56d4a(event));
  4865. }
  4866. }), pressProps = useMemo(() => {
  4867. let state = ref.current, pressProps2 = {
  4868. onKeyDown(e2) {
  4869. if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e2.nativeEvent, e2.currentTarget) && $d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent))) {
  4870. var _state_metaKeyEvents;
  4871. $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard($d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent), e2.key) && e2.preventDefault();
  4872. let shouldStopPropagation = !0;
  4873. if (!state.isPressed && !e2.repeat) {
  4874. state.target = e2.currentTarget, state.isPressed = !0, state.pointerType = "keyboard", shouldStopPropagation = triggerPressStart(e2, "keyboard");
  4875. let originalTarget = e2.currentTarget, pressUp = (e3) => {
  4876. $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");
  4877. };
  4878. addGlobalListener($431fbd86ca7dc216$export$b204af158042fbac(e2.currentTarget), "keyup", $ff5963eb1fccf552$export$e08e3b67e392101e(pressUp, onKeyUp), !0);
  4879. }
  4880. shouldStopPropagation && e2.stopPropagation(), e2.metaKey && $c87311424ea30a05$export$9ac100e40613ea10() && ((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 || _state_metaKeyEvents.set(e2.key, e2.nativeEvent));
  4881. } else e2.key === "Meta" && (state.metaKeyEvents = /* @__PURE__ */ new Map());
  4882. },
  4883. onClick(e2) {
  4884. if (!(e2 && !$d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent))) && e2 && e2.button === 0 && !state.isTriggeringEvent && !$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening) {
  4885. let shouldStopPropagation = !0;
  4886. if (isDisabled && e2.preventDefault(), !state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === "virtual" || $6a7db85432448f7f$export$60278871457622de(e2.nativeEvent))) {
  4887. let stopPressStart = triggerPressStart(e2, "virtual"), stopPressUp = triggerPressUp(e2, "virtual"), stopPressEnd = triggerPressEnd(e2, "virtual");
  4888. triggerClick(e2), shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
  4889. } else if (state.isPressed && state.pointerType !== "keyboard") {
  4890. 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);
  4891. shouldStopPropagation = stopPressUp && stopPressEnd, state.isOverTarget = !1, triggerClick(e2), cancel(e2);
  4892. }
  4893. state.ignoreEmulatedMouseEvents = !1, shouldStopPropagation && e2.stopPropagation();
  4894. }
  4895. }
  4896. }, onKeyUp = (e2) => {
  4897. var _state_metaKeyEvents;
  4898. if (state.isPressed && state.target && $f6c31cce2adf654f$var$isValidKeyboardEvent(e2, state.target)) {
  4899. var _state_metaKeyEvents1;
  4900. $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard($d4ee10de306f2510$export$e58f029f0fbfdb29(e2), e2.key) && e2.preventDefault();
  4901. let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e2), wasPressed = $d4ee10de306f2510$export$4282f70798064fe0(state.target, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2));
  4902. 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);
  4903. } else if (e2.key === "Meta" && (!((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0) && _state_metaKeyEvents.size)) {
  4904. var _state_target;
  4905. let events2 = state.metaKeyEvents;
  4906. state.metaKeyEvents = void 0;
  4907. for (let event of events2.values()) (_state_target = state.target) === null || _state_target === void 0 || _state_target.dispatchEvent(new KeyboardEvent("keyup", event));
  4908. }
  4909. };
  4910. if (typeof PointerEvent < "u") {
  4911. pressProps2.onPointerDown = (e2) => {
  4912. if (e2.button !== 0 || !$d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent))) return;
  4913. if ($6a7db85432448f7f$export$29bf1b5f2c56cf63(e2.nativeEvent)) {
  4914. state.pointerType = "virtual";
  4915. return;
  4916. }
  4917. state.pointerType = e2.pointerType;
  4918. let shouldStopPropagation = !0;
  4919. if (!state.isPressed) {
  4920. 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);
  4921. let target = $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent);
  4922. "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);
  4923. }
  4924. shouldStopPropagation && e2.stopPropagation();
  4925. }, pressProps2.onMouseDown = (e2) => {
  4926. if ($d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent)) && e2.button === 0) {
  4927. if (preventFocusOnPress) {
  4928. let dispose = $8a9cb279dc87e130$export$cabe61c495ee3649(e2.target);
  4929. dispose && state.disposables.push(dispose);
  4930. }
  4931. e2.stopPropagation();
  4932. }
  4933. }, pressProps2.onPointerUp = (e2) => {
  4934. !$d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent)) || state.pointerType === "virtual" || e2.button === 0 && !state.isPressed && triggerPressUp(e2, state.pointerType || e2.pointerType);
  4935. }, pressProps2.onPointerEnter = (e2) => {
  4936. e2.pointerId === state.activePointerId && state.target && !state.isOverTarget && state.pointerType != null && (state.isOverTarget = !0, triggerPressStart($f6c31cce2adf654f$var$createEvent(state.target, e2), state.pointerType));
  4937. }, pressProps2.onPointerLeave = (e2) => {
  4938. 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));
  4939. };
  4940. let onPointerUp = (e2) => {
  4941. if (e2.pointerId === state.activePointerId && state.isPressed && e2.button === 0 && state.target) {
  4942. if ($d4ee10de306f2510$export$4282f70798064fe0(state.target, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2)) && state.pointerType != null) {
  4943. let clicked = !1, timeout = setTimeout(() => {
  4944. state.isPressed && state.target instanceof HTMLElement && (clicked ? cancel(e2) : ($7215afc6de606d6b$export$de79e2c695e052f3(state.target), state.target.click()));
  4945. }, 80);
  4946. addGlobalListener(e2.currentTarget, "click", () => clicked = !0, !0), state.disposables.push(() => clearTimeout(timeout));
  4947. } else cancel(e2);
  4948. state.isOverTarget = !1;
  4949. }
  4950. }, onPointerCancel = (e2) => {
  4951. cancel(e2);
  4952. };
  4953. pressProps2.onDragStart = (e2) => {
  4954. $d4ee10de306f2510$export$4282f70798064fe0(e2.currentTarget, $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent)) && cancel(e2);
  4955. };
  4956. }
  4957. return pressProps2;
  4958. }, [
  4959. addGlobalListener,
  4960. isDisabled,
  4961. preventFocusOnPress,
  4962. removeAllGlobalListeners,
  4963. allowTextSelectionOnPress,
  4964. cancel,
  4965. cancelOnPointerExit,
  4966. triggerPressEnd,
  4967. triggerPressStart,
  4968. triggerPressUp,
  4969. triggerClick,
  4970. triggerSyntheticClick
  4971. ]);
  4972. return useEffect(() => {
  4973. if (!domRef) return;
  4974. let ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(domRef.current);
  4975. if (!ownerDocument || !ownerDocument.head || ownerDocument.getElementById($f6c31cce2adf654f$var$STYLE_ID)) return;
  4976. let style = ownerDocument.createElement("style");
  4977. style.id = $f6c31cce2adf654f$var$STYLE_ID, style.textContent = `
  4978. @layer {
  4979. [${$f6c31cce2adf654f$var$PRESSABLE_ATTRIBUTE}] {
  4980. touch-action: pan-x pan-y pinch-zoom;
  4981. }
  4982. }
  4983. `.trim(), ownerDocument.head.prepend(style);
  4984. }, [
  4985. domRef
  4986. ]), useEffect(() => {
  4987. let state = ref.current;
  4988. return () => {
  4989. var _state_target;
  4990. allowTextSelectionOnPress || $14c0b72509d70225$export$b0d6fa1ab32e3295((_state_target = state.target) !== null && _state_target !== void 0 ? _state_target : void 0);
  4991. for (let dispose of state.disposables) dispose();
  4992. state.disposables = [];
  4993. };
  4994. }, [
  4995. allowTextSelectionOnPress
  4996. ]), {
  4997. isPressed: isPressedProp || isPressed,
  4998. pressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, pressProps, {
  4999. [$f6c31cce2adf654f$var$PRESSABLE_ATTRIBUTE]: !0
  5000. })
  5001. };
  5002. }
  5003. function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
  5004. return target.tagName === "A" && target.hasAttribute("href");
  5005. }
  5006. function $f6c31cce2adf654f$var$isValidKeyboardEvent(event, currentTarget) {
  5007. let { key, code } = event, element = currentTarget, role = element.getAttribute("role");
  5008. 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
  5009. !((role === "link" || !role && $f6c31cce2adf654f$var$isHTMLAnchorLink(element)) && key !== "Enter");
  5010. }
  5011. function $f6c31cce2adf654f$var$createEvent(target, e2) {
  5012. let clientX = e2.clientX, clientY = e2.clientY;
  5013. return {
  5014. currentTarget: target,
  5015. shiftKey: e2.shiftKey,
  5016. ctrlKey: e2.ctrlKey,
  5017. metaKey: e2.metaKey,
  5018. altKey: e2.altKey,
  5019. clientX,
  5020. clientY
  5021. };
  5022. }
  5023. function $f6c31cce2adf654f$var$shouldPreventDefaultUp(target) {
  5024. return target instanceof HTMLInputElement ? !1 : target instanceof HTMLButtonElement ? target.type !== "submit" && target.type !== "reset" : !$f6c31cce2adf654f$var$isHTMLAnchorLink(target);
  5025. }
  5026. function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target, key) {
  5027. return target instanceof HTMLInputElement ? !$f6c31cce2adf654f$var$isValidInputKey(target, key) : $f6c31cce2adf654f$var$shouldPreventDefaultUp(target);
  5028. }
  5029. var $f6c31cce2adf654f$var$nonTextInputTypes = /* @__PURE__ */ new Set([
  5030. "checkbox",
  5031. "radio",
  5032. "range",
  5033. "color",
  5034. "file",
  5035. "image",
  5036. "button",
  5037. "submit",
  5038. "reset"
  5039. ]);
  5040. function $f6c31cce2adf654f$var$isValidInputKey(target, key) {
  5041. return target.type === "checkbox" || target.type === "radio" ? key === " " : $f6c31cce2adf654f$var$nonTextInputTypes.has(target.type);
  5042. }
  5043. // ../../node_modules/@react-aria/interactions/dist/useFocusVisible.mjs
  5044. init_react();
  5045. 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;
  5046. function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e2) {
  5047. for (let handler of $507fabe10e71c6fb$var$changeHandlers) handler(modality, e2);
  5048. }
  5049. function $507fabe10e71c6fb$var$isValidKey(e2) {
  5050. return !(e2.metaKey || !$c87311424ea30a05$export$9ac100e40613ea10() && e2.altKey || e2.ctrlKey || e2.key === "Control" || e2.key === "Shift" || e2.key === "Meta");
  5051. }
  5052. function $507fabe10e71c6fb$var$handleKeyboardEvent(e2) {
  5053. $507fabe10e71c6fb$var$hasEventBeforeFocus = !0, $507fabe10e71c6fb$var$isValidKey(e2) && ($507fabe10e71c6fb$var$currentModality = "keyboard", $507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e2));
  5054. }
  5055. function $507fabe10e71c6fb$var$handlePointerEvent(e2) {
  5056. $507fabe10e71c6fb$var$currentModality = "pointer", (e2.type === "mousedown" || e2.type === "pointerdown") && ($507fabe10e71c6fb$var$hasEventBeforeFocus = !0, $507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e2));
  5057. }
  5058. function $507fabe10e71c6fb$var$handleClickEvent(e2) {
  5059. $6a7db85432448f7f$export$60278871457622de(e2) && ($507fabe10e71c6fb$var$hasEventBeforeFocus = !0, $507fabe10e71c6fb$var$currentModality = "virtual");
  5060. }
  5061. function $507fabe10e71c6fb$var$handleFocusEvent(e2) {
  5062. 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);
  5063. }
  5064. function $507fabe10e71c6fb$var$handleWindowBlur() {
  5065. $8a9cb279dc87e130$export$fda7da73ab5d4c48 || ($507fabe10e71c6fb$var$hasEventBeforeFocus = !1, $507fabe10e71c6fb$var$hasBlurredWindowRecently = !0);
  5066. }
  5067. function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
  5068. if (typeof window > "u" || typeof document > "u" || $507fabe10e71c6fb$export$d90243b58daecda7.get($431fbd86ca7dc216$export$f21a1ffae260145a(element))) return;
  5069. let windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element), documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element), focus = windowObject.HTMLElement.prototype.focus;
  5070. windowObject.HTMLElement.prototype.focus = function() {
  5071. $507fabe10e71c6fb$var$hasEventBeforeFocus = !0, focus.apply(this, arguments);
  5072. }, 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", () => {
  5073. $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
  5074. }, {
  5075. once: !0
  5076. }), $507fabe10e71c6fb$export$d90243b58daecda7.set(windowObject, {
  5077. focus
  5078. });
  5079. }
  5080. var $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener) => {
  5081. let windowObject = $431fbd86ca7dc216$export$f21a1ffae260145a(element), documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element);
  5082. 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));
  5083. };
  5084. function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
  5085. let documentObject = $431fbd86ca7dc216$export$b204af158042fbac(element), loadListener;
  5086. return documentObject.readyState !== "loading" ? $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) : (loadListener = () => {
  5087. $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
  5088. }, documentObject.addEventListener("DOMContentLoaded", loadListener)), () => $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
  5089. }
  5090. typeof document < "u" && $507fabe10e71c6fb$export$2f1888112f558a7d();
  5091. function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
  5092. return $507fabe10e71c6fb$var$currentModality !== "pointer";
  5093. }
  5094. function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
  5095. return $507fabe10e71c6fb$var$currentModality;
  5096. }
  5097. // ../../node_modules/@react-aria/interactions/dist/focusSafely.mjs
  5098. function $3ad3f6e1647bc98d$export$80f3e147d781571c(element) {
  5099. let ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(element), activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
  5100. if ($507fabe10e71c6fb$export$630ff653c5ada6a9() === "virtual") {
  5101. let lastFocusedElement = activeElement;
  5102. $bbed8b41f857bcc0$export$24490316f764c430(() => {
  5103. $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument) === lastFocusedElement && element.isConnected && $7215afc6de606d6b$export$de79e2c695e052f3(element);
  5104. });
  5105. } else $7215afc6de606d6b$export$de79e2c695e052f3(element);
  5106. }
  5107. // ../../node_modules/@react-aria/interactions/dist/useFocus.mjs
  5108. init_react();
  5109. function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
  5110. let { isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange } = props, onBlur = useCallback((e2) => {
  5111. if (e2.target === e2.currentTarget)
  5112. return onBlurProp && onBlurProp(e2), onFocusChange && onFocusChange(!1), !0;
  5113. }, [
  5114. onBlurProp,
  5115. onFocusChange
  5116. ]), onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur), onFocus = useCallback((e2) => {
  5117. let ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(e2.target), activeElement = ownerDocument ? $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument) : $d4ee10de306f2510$export$cd4e5573fbe2b576();
  5118. e2.target === e2.currentTarget && activeElement === $d4ee10de306f2510$export$e58f029f0fbfdb29(e2.nativeEvent) && (onFocusProp && onFocusProp(e2), onFocusChange && onFocusChange(!0), onSyntheticFocus(e2));
  5119. }, [
  5120. onFocusChange,
  5121. onFocusProp,
  5122. onSyntheticFocus
  5123. ]);
  5124. return {
  5125. focusProps: {
  5126. onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : void 0,
  5127. onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : void 0
  5128. }
  5129. };
  5130. }
  5131. // ../../node_modules/@react-aria/interactions/dist/createEventHandler.mjs
  5132. function $93925083ecbb358c$export$48d1ea6320830260(handler) {
  5133. if (!handler) return;
  5134. let shouldStopPropagation = !0;
  5135. return (e2) => {
  5136. let event = {
  5137. ...e2,
  5138. preventDefault() {
  5139. e2.preventDefault();
  5140. },
  5141. isDefaultPrevented() {
  5142. return e2.isDefaultPrevented();
  5143. },
  5144. stopPropagation() {
  5145. shouldStopPropagation = !0;
  5146. },
  5147. continuePropagation() {
  5148. shouldStopPropagation = !1;
  5149. },
  5150. isPropagationStopped() {
  5151. return shouldStopPropagation;
  5152. }
  5153. };
  5154. handler(event), shouldStopPropagation && e2.stopPropagation();
  5155. };
  5156. }
  5157. // ../../node_modules/@react-aria/interactions/dist/useKeyboard.mjs
  5158. function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
  5159. return {
  5160. keyboardProps: props.isDisabled ? {} : {
  5161. onKeyDown: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyDown),
  5162. onKeyUp: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyUp)
  5163. }
  5164. };
  5165. }
  5166. // ../../node_modules/@react-aria/interactions/dist/useFocusable.mjs
  5167. init_react();
  5168. var $f645667febf57a63$export$f9762fab77588ecb = react_default.createContext(null);
  5169. function $f645667febf57a63$var$useFocusableContext(ref) {
  5170. let context = useContext($f645667febf57a63$export$f9762fab77588ecb) || {};
  5171. $e7801be82b4b2a53$export$4debdb1a3f0fa79e(context, ref);
  5172. let { ref: _2, ...otherProps } = context;
  5173. return otherProps;
  5174. }
  5175. var $f645667febf57a63$export$13f3202a3e5ddd5 = react_default.forwardRef(function(props, ref) {
  5176. let { children, ...otherProps } = props, objRef = $df56164dff5785e2$export$4338b53315abf666(ref), context = {
  5177. ...otherProps,
  5178. ref: objRef
  5179. };
  5180. return react_default.createElement($f645667febf57a63$export$f9762fab77588ecb.Provider, {
  5181. value: context
  5182. }, children);
  5183. });
  5184. function $f645667febf57a63$export$4c014de7c8940b4c(props, domRef) {
  5185. 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);
  5186. useEffect(() => {
  5187. autoFocusRef.current && domRef.current && $3ad3f6e1647bc98d$export$80f3e147d781571c(domRef.current), autoFocusRef.current = !1;
  5188. }, [
  5189. domRef
  5190. ]);
  5191. let tabIndex = props.excludeFromTabOrder ? -1 : 0;
  5192. return props.isDisabled && (tabIndex = void 0), {
  5193. focusableProps: $3ef42575df84b30b$export$9d1611c77c2fe928({
  5194. ...interactions,
  5195. tabIndex
  5196. }, interactionProps)
  5197. };
  5198. }
  5199. var $f645667febf57a63$export$35a3bebf7ef2d934 = forwardRef(({ children, ...props }, ref) => {
  5200. ref = $df56164dff5785e2$export$4338b53315abf666(ref);
  5201. let { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c(props, ref), child = react_default.Children.only(children);
  5202. useEffect(() => {
  5203. }, [
  5204. ref,
  5205. props.isDisabled
  5206. ]);
  5207. let childRef = parseInt(react_default.version, 10) < 19 ? child.ref : child.props.ref;
  5208. return react_default.cloneElement(child, {
  5209. ...$3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, child.props),
  5210. // @ts-ignore
  5211. ref: $5dc95899b306f630$export$c9058316764c140e(childRef, ref)
  5212. });
  5213. });
  5214. // ../../node_modules/@react-aria/interactions/dist/Pressable.mjs
  5215. init_react();
  5216. var $3b117e43dc0ca95d$export$27c701ed9e449e99 = react_default.forwardRef(({ children, ...props }, ref) => {
  5217. ref = $df56164dff5785e2$export$4338b53315abf666(ref);
  5218. let { pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
  5219. ...props,
  5220. ref
  5221. }), { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c(props, ref), child = react_default.Children.only(children);
  5222. useEffect(() => {
  5223. }, [
  5224. ref,
  5225. props.isDisabled
  5226. ]);
  5227. let childRef = parseInt(react_default.version, 10) < 19 ? child.ref : child.props.ref;
  5228. return react_default.cloneElement(child, {
  5229. ...$3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, focusableProps, child.props),
  5230. // @ts-ignore
  5231. ref: $5dc95899b306f630$export$c9058316764c140e(childRef, ref)
  5232. });
  5233. });
  5234. // ../../node_modules/@react-aria/interactions/dist/PressResponder.mjs
  5235. init_react();
  5236. var $f1ab8c75478c6f73$export$3351871ee4b288b8 = react_default.forwardRef(({ children, ...props }, ref) => {
  5237. let isRegistered = useRef(!1), prevContext = useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
  5238. ref = $df56164dff5785e2$export$4338b53315abf666(ref || prevContext?.ref);
  5239. let context = $3ef42575df84b30b$export$9d1611c77c2fe928(prevContext || {}, {
  5240. ...props,
  5241. ref,
  5242. register() {
  5243. isRegistered.current = !0, prevContext && prevContext.register();
  5244. }
  5245. });
  5246. return $e7801be82b4b2a53$export$4debdb1a3f0fa79e(prevContext, ref), useEffect(() => {
  5247. isRegistered.current || (isRegistered.current = !0);
  5248. }, []), react_default.createElement($ae1eeba8b9eafd08$export$5165eccb35aaadb5.Provider, {
  5249. value: context
  5250. }, children);
  5251. });
  5252. // ../../node_modules/@react-aria/interactions/dist/useFocusWithin.mjs
  5253. init_react();
  5254. // ../../node_modules/@react-aria/interactions/dist/useHover.mjs
  5255. init_react();
  5256. var $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = !1, $6179b936705e76d3$var$hoverCount = 0;
  5257. function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
  5258. $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = !0, setTimeout(() => {
  5259. $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = !1;
  5260. }, 50);
  5261. }
  5262. function $6179b936705e76d3$var$handleGlobalPointerEvent(e2) {
  5263. e2.pointerType === "touch" && $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
  5264. }
  5265. function $6179b936705e76d3$var$setupGlobalTouchEvents() {
  5266. if (!(typeof document > "u"))
  5267. return $6179b936705e76d3$var$hoverCount === 0 && typeof PointerEvent < "u" && document.addEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent), $6179b936705e76d3$var$hoverCount++, () => {
  5268. $6179b936705e76d3$var$hoverCount--, !($6179b936705e76d3$var$hoverCount > 0) && typeof PointerEvent < "u" && document.removeEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
  5269. };
  5270. }
  5271. function $6179b936705e76d3$export$ae780daf29e6d456(props) {
  5272. let { onHoverStart, onHoverChange, onHoverEnd, isDisabled } = props, [isHovered, setHovered] = useState(!1), state = useRef({
  5273. isHovered: !1,
  5274. ignoreEmulatedMouseEvents: !1,
  5275. pointerType: "",
  5276. target: null
  5277. }).current;
  5278. useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
  5279. let { addGlobalListener, removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6(), { hoverProps, triggerHoverEnd } = useMemo(() => {
  5280. let triggerHoverStart = (event, pointerType) => {
  5281. if (state.pointerType = pointerType, isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
  5282. state.isHovered = !0;
  5283. let target = event.currentTarget;
  5284. state.target = target, addGlobalListener($431fbd86ca7dc216$export$b204af158042fbac(event.target), "pointerover", (e2) => {
  5285. state.isHovered && state.target && !$d4ee10de306f2510$export$4282f70798064fe0(state.target, e2.target) && triggerHoverEnd2(e2, e2.pointerType);
  5286. }, {
  5287. capture: !0
  5288. }), onHoverStart && onHoverStart({
  5289. type: "hoverstart",
  5290. target,
  5291. pointerType
  5292. }), onHoverChange && onHoverChange(!0), setHovered(!0);
  5293. }, triggerHoverEnd2 = (event, pointerType) => {
  5294. let target = state.target;
  5295. state.pointerType = "", state.target = null, !(pointerType === "touch" || !state.isHovered || !target) && (state.isHovered = !1, removeAllGlobalListeners(), onHoverEnd && onHoverEnd({
  5296. type: "hoverend",
  5297. target,
  5298. pointerType
  5299. }), onHoverChange && onHoverChange(!1), setHovered(!1));
  5300. }, hoverProps2 = {};
  5301. return typeof PointerEvent < "u" && (hoverProps2.onPointerEnter = (e2) => {
  5302. $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e2.pointerType === "mouse" || triggerHoverStart(e2, e2.pointerType);
  5303. }, hoverProps2.onPointerLeave = (e2) => {
  5304. !isDisabled && e2.currentTarget.contains(e2.target) && triggerHoverEnd2(e2, e2.pointerType);
  5305. }), {
  5306. hoverProps: hoverProps2,
  5307. triggerHoverEnd: triggerHoverEnd2
  5308. };
  5309. }, [
  5310. onHoverStart,
  5311. onHoverChange,
  5312. onHoverEnd,
  5313. isDisabled,
  5314. state,
  5315. addGlobalListener,
  5316. removeAllGlobalListeners
  5317. ]);
  5318. return useEffect(() => {
  5319. isDisabled && triggerHoverEnd({
  5320. currentTarget: state.target
  5321. }, state.pointerType);
  5322. }, [
  5323. isDisabled
  5324. ]), {
  5325. hoverProps,
  5326. isHovered
  5327. };
  5328. }
  5329. // ../../node_modules/@react-aria/interactions/dist/useInteractOutside.mjs
  5330. init_react();
  5331. // ../../node_modules/@react-aria/interactions/dist/useMove.mjs
  5332. init_react();
  5333. // ../../node_modules/@react-aria/interactions/dist/useScrollWheel.mjs
  5334. init_react();
  5335. // ../../node_modules/@react-aria/interactions/dist/useLongPress.mjs
  5336. init_react();
  5337. // ../../node_modules/react-aria-components/dist/utils.mjs
  5338. init_react();
  5339. var $64fa3d84918910a7$export$c62b8e45d58ddad9 = /* @__PURE__ */ Symbol("default");
  5340. function $64fa3d84918910a7$export$2881499e37b75b9a({ values, children }) {
  5341. for (let [Context2, value] of values)
  5342. children = react_default.createElement(Context2.Provider, {
  5343. value
  5344. }, children);
  5345. return children;
  5346. }
  5347. function $64fa3d84918910a7$export$4d86445c2cf5e3(props) {
  5348. let { className, style, children, defaultClassName, defaultChildren, defaultStyle, values } = props;
  5349. return useMemo(() => {
  5350. let computedClassName, computedStyle, computedChildren;
  5351. return typeof className == "function" ? computedClassName = className({
  5352. ...values,
  5353. defaultClassName
  5354. }) : computedClassName = className, typeof style == "function" ? computedStyle = style({
  5355. ...values,
  5356. defaultStyle: defaultStyle || {}
  5357. }) : computedStyle = style, typeof children == "function" ? computedChildren = children({
  5358. ...values,
  5359. defaultChildren
  5360. }) : children == null ? computedChildren = defaultChildren : computedChildren = children, {
  5361. className: computedClassName ?? defaultClassName,
  5362. style: computedStyle || defaultStyle ? {
  5363. ...defaultStyle,
  5364. ...computedStyle
  5365. } : void 0,
  5366. children: computedChildren ?? defaultChildren,
  5367. "data-rac": ""
  5368. };
  5369. }, [
  5370. className,
  5371. style,
  5372. children,
  5373. defaultClassName,
  5374. defaultChildren,
  5375. defaultStyle,
  5376. values
  5377. ]);
  5378. }
  5379. function $64fa3d84918910a7$export$fabf2dc03a41866e(context, slot) {
  5380. let ctx = useContext(context);
  5381. if (slot === null)
  5382. return null;
  5383. if (ctx && typeof ctx == "object" && "slots" in ctx && ctx.slots) {
  5384. let slotKey = slot || $64fa3d84918910a7$export$c62b8e45d58ddad9;
  5385. if (!ctx.slots[slotKey]) {
  5386. let availableSlots = new Intl.ListFormat().format(Object.keys(ctx.slots).map((p2) => `"${p2}"`)), errorMessage = slot ? `Invalid slot "${slot}".` : "A slot prop is required.";
  5387. throw new Error(`${errorMessage} Valid slot names are ${availableSlots}.`);
  5388. }
  5389. return ctx.slots[slotKey];
  5390. }
  5391. return ctx;
  5392. }
  5393. function $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, context) {
  5394. let ctx = $64fa3d84918910a7$export$fabf2dc03a41866e(context, props.slot) || {}, { ref: contextRef, ...contextProps } = ctx, mergedRef = $df56164dff5785e2$export$4338b53315abf666(useMemo(() => $5dc95899b306f630$export$c9058316764c140e(ref, contextRef), [
  5395. ref,
  5396. contextRef
  5397. ])), mergedProps = $3ef42575df84b30b$export$9d1611c77c2fe928(contextProps, props);
  5398. return "style" in contextProps && contextProps.style && "style" in props && props.style && (typeof contextProps.style == "function" || typeof props.style == "function" ? mergedProps.style = (renderProps) => {
  5399. let contextStyle = typeof contextProps.style == "function" ? contextProps.style(renderProps) : contextProps.style, defaultStyle = {
  5400. ...renderProps.defaultStyle,
  5401. ...contextStyle
  5402. }, style = typeof props.style == "function" ? props.style({
  5403. ...renderProps,
  5404. defaultStyle
  5405. }) : props.style;
  5406. return {
  5407. ...defaultStyle,
  5408. ...style
  5409. };
  5410. } : mergedProps.style = {
  5411. ...contextProps.style,
  5412. ...props.style
  5413. }), [
  5414. mergedProps,
  5415. mergedRef
  5416. ];
  5417. }
  5418. // ../../node_modules/react-aria-components/dist/OverlayArrow.mjs
  5419. init_react();
  5420. var $44f671af83e7d9e0$export$2de4954e8ae13b9f = createContext({
  5421. placement: "bottom"
  5422. }), $44f671af83e7d9e0$export$746d02f47f4d381 = forwardRef(function(props, ref) {
  5423. [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $44f671af83e7d9e0$export$2de4954e8ae13b9f);
  5424. let placement = props.placement, style = {
  5425. position: "absolute",
  5426. transform: placement === "top" || placement === "bottom" ? "translateX(-50%)" : "translateY(-50%)"
  5427. };
  5428. placement != null && (style[placement] = "100%");
  5429. let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
  5430. ...props,
  5431. defaultClassName: "react-aria-OverlayArrow",
  5432. values: {
  5433. placement
  5434. }
  5435. });
  5436. renderProps.style && Object.keys(renderProps.style).forEach((key) => renderProps.style[key] === void 0 && delete renderProps.style[key]);
  5437. let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
  5438. return react_default.createElement("div", {
  5439. ...DOMProps,
  5440. ...renderProps,
  5441. style: {
  5442. ...style,
  5443. ...renderProps.style
  5444. },
  5445. ref,
  5446. "data-placement": placement
  5447. });
  5448. });
  5449. // ../../node_modules/@react-aria/tooltip/dist/useTooltip.mjs
  5450. function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
  5451. let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
  5452. labelable: !0
  5453. }), { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
  5454. onHoverStart: () => state?.open(!0),
  5455. onHoverEnd: () => state?.close()
  5456. });
  5457. return {
  5458. tooltipProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, hoverProps, {
  5459. role: "tooltip"
  5460. })
  5461. };
  5462. }
  5463. // ../../node_modules/@react-aria/tooltip/dist/useTooltipTrigger.mjs
  5464. init_react();
  5465. function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
  5466. let { isDisabled, trigger } = props, tooltipId = $bdb11010cef70236$export$f680877a34711e37(), isHovered = useRef(!1), isFocused = useRef(!1), handleShow = () => {
  5467. (isHovered.current || isFocused.current) && state.open(isFocused.current);
  5468. }, handleHide = (immediate) => {
  5469. !isHovered.current && !isFocused.current && state.close(immediate);
  5470. };
  5471. useEffect(() => {
  5472. let onKeyDown = (e2) => {
  5473. ref && ref.current && e2.key === "Escape" && (e2.stopPropagation(), state.close(!0));
  5474. };
  5475. if (state.isOpen)
  5476. return document.addEventListener("keydown", onKeyDown, !0), () => {
  5477. document.removeEventListener("keydown", onKeyDown, !0);
  5478. };
  5479. }, [
  5480. ref,
  5481. state
  5482. ]);
  5483. let onHoverStart = () => {
  5484. trigger !== "focus" && ($507fabe10e71c6fb$export$630ff653c5ada6a9() === "pointer" ? isHovered.current = !0 : isHovered.current = !1, handleShow());
  5485. }, onHoverEnd = () => {
  5486. trigger !== "focus" && (isFocused.current = !1, isHovered.current = !1, handleHide());
  5487. }, onPressStart = () => {
  5488. isFocused.current = !1, isHovered.current = !1, handleHide(!0);
  5489. }, onFocus = () => {
  5490. $507fabe10e71c6fb$export$b9b3dfddab17db27() && (isFocused.current = !0, handleShow());
  5491. }, onBlur = () => {
  5492. isFocused.current = !1, isHovered.current = !1, handleHide(!0);
  5493. }, { hoverProps } = $6179b936705e76d3$export$ae780daf29e6d456({
  5494. isDisabled,
  5495. onHoverStart,
  5496. onHoverEnd
  5497. }), { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c({
  5498. isDisabled,
  5499. onFocus,
  5500. onBlur
  5501. }, ref);
  5502. return {
  5503. triggerProps: {
  5504. "aria-describedby": state.isOpen ? tooltipId : void 0,
  5505. ...$3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, hoverProps, {
  5506. onPointerDown: onPressStart,
  5507. onKeyDown: onPressStart
  5508. }),
  5509. tabIndex: void 0
  5510. },
  5511. tooltipProps: {
  5512. id: tooltipId
  5513. }
  5514. };
  5515. }
  5516. // ../../node_modules/@react-aria/overlays/dist/calculatePosition.mjs
  5517. var $edcf132a9284368a$var$AXIS = {
  5518. top: "top",
  5519. bottom: "top",
  5520. left: "left",
  5521. right: "left"
  5522. }, $edcf132a9284368a$var$FLIPPED_DIRECTION = {
  5523. top: "bottom",
  5524. bottom: "top",
  5525. left: "right",
  5526. right: "left"
  5527. }, $edcf132a9284368a$var$CROSS_AXIS = {
  5528. top: "left",
  5529. left: "top"
  5530. }, $edcf132a9284368a$var$AXIS_SIZE = {
  5531. top: "height",
  5532. left: "width"
  5533. }, $edcf132a9284368a$var$TOTAL_SIZE = {
  5534. width: "totalWidth",
  5535. height: "totalHeight"
  5536. }, $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE = {}, $edcf132a9284368a$var$visualViewport = typeof document < "u" ? window.visualViewport : null;
  5537. function $edcf132a9284368a$var$getContainerDimensions(containerNode) {
  5538. let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0, scroll2 = {};
  5539. var _visualViewport_scale;
  5540. let isPinchZoomedIn = ((_visualViewport_scale = $edcf132a9284368a$var$visualViewport?.scale) !== null && _visualViewport_scale !== void 0 ? _visualViewport_scale : 1) > 1;
  5541. if (containerNode.tagName === "BODY") {
  5542. let documentElement = document.documentElement;
  5543. totalWidth = documentElement.clientWidth, totalHeight = documentElement.clientHeight;
  5544. var _visualViewport_width;
  5545. width = (_visualViewport_width = $edcf132a9284368a$var$visualViewport?.width) !== null && _visualViewport_width !== void 0 ? _visualViewport_width : totalWidth;
  5546. var _visualViewport_height;
  5547. 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);
  5548. } else
  5549. ({ width, height, top, left } = $edcf132a9284368a$var$getOffset(containerNode, !1)), scroll2.top = containerNode.scrollTop, scroll2.left = containerNode.scrollLeft, totalWidth = width, totalHeight = height;
  5550. if ($c87311424ea30a05$export$78551043582a6a98() && (containerNode.tagName === "BODY" || containerNode.tagName === "HTML") && isPinchZoomedIn) {
  5551. scroll2.top = 0, scroll2.left = 0;
  5552. var _visualViewport_pageTop;
  5553. top = (_visualViewport_pageTop = $edcf132a9284368a$var$visualViewport?.pageTop) !== null && _visualViewport_pageTop !== void 0 ? _visualViewport_pageTop : 0;
  5554. var _visualViewport_pageLeft;
  5555. left = (_visualViewport_pageLeft = $edcf132a9284368a$var$visualViewport?.pageLeft) !== null && _visualViewport_pageLeft !== void 0 ? _visualViewport_pageLeft : 0;
  5556. }
  5557. return {
  5558. width,
  5559. height,
  5560. totalWidth,
  5561. totalHeight,
  5562. scroll: scroll2,
  5563. top,
  5564. left
  5565. };
  5566. }
  5567. function $edcf132a9284368a$var$getScroll(node) {
  5568. return {
  5569. top: node.scrollTop,
  5570. left: node.scrollLeft,
  5571. width: node.scrollWidth,
  5572. height: node.scrollHeight
  5573. };
  5574. }
  5575. function $edcf132a9284368a$var$getDelta(axis, offset2, size, boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary) {
  5576. var _containerDimensions_scroll_axis;
  5577. 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]];
  5578. return startEdgeOffset < boundaryStartEdge ? boundaryStartEdge - startEdgeOffset : endEdgeOffset > boundaryEndEdge ? Math.max(boundaryEndEdge - endEdgeOffset, boundaryStartEdge - startEdgeOffset) : 0;
  5579. }
  5580. function $edcf132a9284368a$var$getMargins(node) {
  5581. let style = window.getComputedStyle(node);
  5582. return {
  5583. top: parseInt(style.marginTop, 10) || 0,
  5584. bottom: parseInt(style.marginBottom, 10) || 0,
  5585. left: parseInt(style.marginLeft, 10) || 0,
  5586. right: parseInt(style.marginRight, 10) || 0
  5587. };
  5588. }
  5589. function $edcf132a9284368a$var$parsePlacement(input) {
  5590. if ($edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input]) return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
  5591. let [placement, crossPlacement] = input.split(" "), axis = $edcf132a9284368a$var$AXIS[placement] || "right", crossAxis = $edcf132a9284368a$var$CROSS_AXIS[axis];
  5592. $edcf132a9284368a$var$AXIS[crossPlacement] || (crossPlacement = "center");
  5593. let size = $edcf132a9284368a$var$AXIS_SIZE[axis], crossSize = $edcf132a9284368a$var$AXIS_SIZE[crossAxis];
  5594. return $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input] = {
  5595. placement,
  5596. crossPlacement,
  5597. axis,
  5598. crossAxis,
  5599. size,
  5600. crossSize
  5601. }, $edcf132a9284368a$var$PARSED_PLACEMENT_CACHE[input];
  5602. }
  5603. function $edcf132a9284368a$var$computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset2, crossOffset, containerOffsetWithBoundary, isContainerPositioned, arrowSize, arrowBoundaryOffset) {
  5604. let { placement, crossPlacement, axis, crossAxis, size, crossSize } = placementInfo, position = {};
  5605. var _childOffset_crossAxis;
  5606. position[crossAxis] = (_childOffset_crossAxis = childOffset[crossAxis]) !== null && _childOffset_crossAxis !== void 0 ? _childOffset_crossAxis : 0;
  5607. var _childOffset_crossSize, _overlaySize_crossSize, _childOffset_crossSize1, _overlaySize_crossSize1;
  5608. 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;
  5609. let minPosition = childOffset[crossAxis] - overlaySize[crossSize] + arrowSize + arrowBoundaryOffset, maxPosition = childOffset[crossAxis] + childOffset[crossSize] - arrowSize - arrowBoundaryOffset;
  5610. if (position[crossAxis] = $9446cca9a3875146$export$7d15b64cf5a3a4c4(position[crossAxis], minPosition, maxPosition), placement === axis) {
  5611. let containerHeight = isContainerPositioned ? containerOffsetWithBoundary[size] : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE[size]];
  5612. position[$edcf132a9284368a$var$FLIPPED_DIRECTION[axis]] = Math.floor(containerHeight - childOffset[axis] + offset2);
  5613. } else position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset2);
  5614. return position;
  5615. }
  5616. function $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlayHeight, heightGrowthDirection) {
  5617. let containerHeight = isContainerPositioned ? containerOffsetWithBoundary.height : boundaryDimensions[$edcf132a9284368a$var$TOTAL_SIZE.height];
  5618. var _position_bottom;
  5619. 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);
  5620. var _boundaryDimensions_scroll_top, _margins_top, _margins_bottom, _boundaryDimensions_scroll_top1, _margins_top1, _margins_bottom1;
  5621. let maxHeight = heightGrowthDirection !== "top" ? (
  5622. // We want the distance between the top of the overlay to the bottom of the boundary
  5623. 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))
  5624. ) : 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));
  5625. return Math.min(boundaryDimensions.height - padding * 2, maxHeight);
  5626. }
  5627. function $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
  5628. let { placement, axis, size } = placementInfo;
  5629. var _boundaryDimensions_scroll_axis, _margins_axis;
  5630. 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);
  5631. var _margins_axis1;
  5632. 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);
  5633. }
  5634. function $edcf132a9284368a$export$6839422d1f33cee9(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip2, boundaryDimensions, containerDimensions, containerOffsetWithBoundary, offset2, crossOffset, isContainerPositioned, userSetMaxHeight, arrowSize, arrowBoundaryOffset) {
  5635. 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);
  5636. if (flip2 && scrollSize[size] > space) {
  5637. 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);
  5638. $edcf132a9284368a$var$getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset2, flippedPlacementInfo) > space && (placementInfo = flippedPlacementInfo, position = flippedPosition, normalizedOffset = offset2);
  5639. }
  5640. let heightGrowthDirection = "bottom";
  5641. 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"));
  5642. let delta = $edcf132a9284368a$var$getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, containerDimensions, padding, containerOffsetWithBoundary);
  5643. position[crossAxis] += delta;
  5644. let maxHeight = $edcf132a9284368a$var$getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, isContainerPositioned, margins, padding, overlaySize.height, heightGrowthDirection);
  5645. 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;
  5646. let arrowPosition = {}, origin = childOffset[crossAxis] - position[crossAxis] - margins[$edcf132a9284368a$var$AXIS[crossAxis]], preferredArrowPosition = origin + 0.5 * childOffset[crossSize], arrowMinPosition = arrowSize / 2 + arrowBoundaryOffset;
  5647. var _margins_left, _margins_right, _margins_top, _margins_bottom;
  5648. 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);
  5649. 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);
  5650. let crossOrigin = placement === "left" || placement === "top" ? overlaySize[size] : 0, triggerAnchorPoint = {
  5651. x: placement === "top" || placement === "bottom" ? origin : crossOrigin,
  5652. y: placement === "left" || placement === "right" ? origin : crossOrigin
  5653. };
  5654. return {
  5655. position,
  5656. maxHeight,
  5657. arrowOffsetLeft: arrowPosition.left,
  5658. arrowOffsetTop: arrowPosition.top,
  5659. placement,
  5660. triggerAnchorPoint
  5661. };
  5662. }
  5663. function $edcf132a9284368a$export$b3ceb0cbf1056d98(opts) {
  5664. 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);
  5665. if (!isViewportContainer) {
  5666. let { marginTop, marginLeft } = window.getComputedStyle(targetNode);
  5667. childOffset.top += parseInt(marginTop, 10) || 0, childOffset.left += parseInt(marginLeft, 10) || 0;
  5668. }
  5669. let overlaySize = $edcf132a9284368a$var$getOffset(overlayNode, !0), margins = $edcf132a9284368a$var$getMargins(overlayNode);
  5670. var _margins_left, _margins_right;
  5671. 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);
  5672. var _margins_top, _margins_bottom;
  5673. 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);
  5674. 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);
  5675. 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);
  5676. }
  5677. function $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale) {
  5678. let { top, left, width, height } = node.getBoundingClientRect();
  5679. return ignoreScale && node instanceof node.ownerDocument.defaultView.HTMLElement && (width = node.offsetWidth, height = node.offsetHeight), {
  5680. top,
  5681. left,
  5682. width,
  5683. height
  5684. };
  5685. }
  5686. function $edcf132a9284368a$var$getOffset(node, ignoreScale) {
  5687. let { top, left, width, height } = $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale), { scrollTop, scrollLeft, clientTop, clientLeft } = document.documentElement;
  5688. return {
  5689. top: top + scrollTop - clientTop,
  5690. left: left + scrollLeft - clientLeft,
  5691. width,
  5692. height
  5693. };
  5694. }
  5695. function $edcf132a9284368a$var$getPosition(node, parent, ignoreScale) {
  5696. let style = window.getComputedStyle(node), offset2;
  5697. if (style.position === "fixed") offset2 = $edcf132a9284368a$export$4b834cebd9e5cebe(node, ignoreScale);
  5698. else {
  5699. offset2 = $edcf132a9284368a$var$getOffset(node, ignoreScale);
  5700. let parentOffset = $edcf132a9284368a$var$getOffset(parent, ignoreScale), parentStyle = window.getComputedStyle(parent);
  5701. 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;
  5702. }
  5703. return offset2.top -= parseInt(style.marginTop, 10) || 0, offset2.left -= parseInt(style.marginLeft, 10) || 0, offset2;
  5704. }
  5705. function $edcf132a9284368a$var$getContainingBlock(node) {
  5706. let offsetParent = node.offsetParent;
  5707. if (offsetParent && offsetParent === document.body && window.getComputedStyle(offsetParent).position === "static" && !$edcf132a9284368a$var$isContainingBlock(offsetParent) && (offsetParent = document.documentElement), offsetParent == null)
  5708. for (offsetParent = node.parentElement; offsetParent && !$edcf132a9284368a$var$isContainingBlock(offsetParent); ) offsetParent = offsetParent.parentElement;
  5709. return offsetParent || document.documentElement;
  5710. }
  5711. function $edcf132a9284368a$var$isContainingBlock(node) {
  5712. let style = window.getComputedStyle(node);
  5713. 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";
  5714. }
  5715. // ../../node_modules/@react-aria/overlays/dist/useCloseOnScroll.mjs
  5716. init_react();
  5717. var $dd149f63282afbbf$export$f6211563215e3b37 = /* @__PURE__ */ new WeakMap();
  5718. function $dd149f63282afbbf$export$18fc8428861184da(opts) {
  5719. let { triggerRef, isOpen, onClose } = opts;
  5720. useEffect(() => {
  5721. if (!isOpen || onClose === null) return;
  5722. let onScroll = (e2) => {
  5723. let target = e2.target;
  5724. if (!triggerRef.current || target instanceof Node && !target.contains(triggerRef.current) || e2.target instanceof HTMLInputElement || e2.target instanceof HTMLTextAreaElement) return;
  5725. let onCloseHandler = onClose || $dd149f63282afbbf$export$f6211563215e3b37.get(triggerRef.current);
  5726. onCloseHandler && onCloseHandler();
  5727. };
  5728. return window.addEventListener("scroll", onScroll, !0), () => {
  5729. window.removeEventListener("scroll", onScroll, !0);
  5730. };
  5731. }, [
  5732. isOpen,
  5733. onClose,
  5734. triggerRef
  5735. ]);
  5736. }
  5737. // ../../node_modules/@react-aria/overlays/dist/useOverlayPosition.mjs
  5738. init_react();
  5739. // ../../node_modules/@react-aria/i18n/dist/utils.mjs
  5740. var $148a7a147e38ea7f$var$RTL_SCRIPTS = /* @__PURE__ */ new Set([
  5741. "Arab",
  5742. "Syrc",
  5743. "Samr",
  5744. "Mand",
  5745. "Thaa",
  5746. "Mend",
  5747. "Nkoo",
  5748. "Adlm",
  5749. "Rohg",
  5750. "Hebr"
  5751. ]), $148a7a147e38ea7f$var$RTL_LANGS = /* @__PURE__ */ new Set([
  5752. "ae",
  5753. "ar",
  5754. "arc",
  5755. "bcc",
  5756. "bqi",
  5757. "ckb",
  5758. "dv",
  5759. "fa",
  5760. "glk",
  5761. "he",
  5762. "ku",
  5763. "mzn",
  5764. "nqo",
  5765. "pnb",
  5766. "ps",
  5767. "sd",
  5768. "ug",
  5769. "ur",
  5770. "yi"
  5771. ]);
  5772. function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
  5773. if (Intl.Locale) {
  5774. let locale = new Intl.Locale(localeString).maximize(), textInfo = typeof locale.getTextInfo == "function" ? locale.getTextInfo() : locale.textInfo;
  5775. if (textInfo) return textInfo.direction === "rtl";
  5776. if (locale.script) return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(locale.script);
  5777. }
  5778. let lang = localeString.split("-")[0];
  5779. return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
  5780. }
  5781. // ../../node_modules/@react-aria/i18n/dist/useDefaultLocale.mjs
  5782. init_react();
  5783. var $1e5a04cdaf7d1af8$var$localeSymbol = /* @__PURE__ */ Symbol.for("react-aria.i18n.locale");
  5784. function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
  5785. let locale = typeof window < "u" && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator < "u" && (navigator.language || navigator.userLanguage) || "en-US";
  5786. try {
  5787. Intl.DateTimeFormat.supportedLocalesOf([
  5788. locale
  5789. ]);
  5790. } catch {
  5791. locale = "en-US";
  5792. }
  5793. return {
  5794. locale,
  5795. direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ? "rtl" : "ltr"
  5796. };
  5797. }
  5798. var $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5(), $1e5a04cdaf7d1af8$var$listeners = /* @__PURE__ */ new Set();
  5799. function $1e5a04cdaf7d1af8$var$updateLocale() {
  5800. $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
  5801. for (let listener of $1e5a04cdaf7d1af8$var$listeners) listener($1e5a04cdaf7d1af8$var$currentLocale);
  5802. }
  5803. function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
  5804. let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273(), [defaultLocale2, setDefaultLocale] = useState($1e5a04cdaf7d1af8$var$currentLocale);
  5805. return useEffect(() => ($1e5a04cdaf7d1af8$var$listeners.size === 0 && window.addEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale), $1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale), () => {
  5806. $1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale), $1e5a04cdaf7d1af8$var$listeners.size === 0 && window.removeEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
  5807. }), []), isSSR ? {
  5808. locale: "en-US",
  5809. direction: "ltr"
  5810. } : defaultLocale2;
  5811. }
  5812. // ../../node_modules/@react-aria/i18n/dist/context.mjs
  5813. init_react();
  5814. var $18f2051aff69b9bf$var$I18nContext = react_default.createContext(null);
  5815. function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
  5816. let defaultLocale2 = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
  5817. return useContext($18f2051aff69b9bf$var$I18nContext) || defaultLocale2;
  5818. }
  5819. // ../../node_modules/tslib/tslib.es6.mjs
  5820. var extendStatics = function(d2, b2) {
  5821. return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
  5822. d3.__proto__ = b3;
  5823. } || function(d3, b3) {
  5824. for (var p2 in b3) Object.prototype.hasOwnProperty.call(b3, p2) && (d3[p2] = b3[p2]);
  5825. }, extendStatics(d2, b2);
  5826. };
  5827. function __extends(d2, b2) {
  5828. if (typeof b2 != "function" && b2 !== null)
  5829. throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
  5830. extendStatics(d2, b2);
  5831. function __() {
  5832. this.constructor = d2;
  5833. }
  5834. d2.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
  5835. }
  5836. var __assign = function() {
  5837. return __assign = Object.assign || function(t2) {
  5838. for (var s2, i2 = 1, n3 = arguments.length; i2 < n3; i2++) {
  5839. s2 = arguments[i2];
  5840. for (var p2 in s2) Object.prototype.hasOwnProperty.call(s2, p2) && (t2[p2] = s2[p2]);
  5841. }
  5842. return t2;
  5843. }, __assign.apply(this, arguments);
  5844. };
  5845. function __rest(s2, e2) {
  5846. var t2 = {};
  5847. for (var p2 in s2) Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0 && (t2[p2] = s2[p2]);
  5848. if (s2 != null && typeof Object.getOwnPropertySymbols == "function")
  5849. for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++)
  5850. e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2]) && (t2[p2[i2]] = s2[p2[i2]]);
  5851. return t2;
  5852. }
  5853. function __spreadArray(to, from, pack) {
  5854. if (pack || arguments.length === 2) for (var i2 = 0, l3 = from.length, ar; i2 < l3; i2++)
  5855. (ar || !(i2 in from)) && (ar || (ar = Array.prototype.slice.call(from, 0, i2)), ar[i2] = from[i2]);
  5856. return to.concat(ar || Array.prototype.slice.call(from));
  5857. }
  5858. // ../../node_modules/@formatjs/fast-memoize/lib/index.js
  5859. function memoize(fn, options2) {
  5860. var cache = options2 && options2.cache ? options2.cache : cacheDefault, serializer = options2 && options2.serializer ? options2.serializer : serializerDefault, strategy = options2 && options2.strategy ? options2.strategy : strategyDefault;
  5861. return strategy(fn, {
  5862. cache,
  5863. serializer
  5864. });
  5865. }
  5866. function isPrimitive(value) {
  5867. return value == null || typeof value == "number" || typeof value == "boolean";
  5868. }
  5869. function monadic(fn, cache, serializer, arg) {
  5870. var cacheKey = isPrimitive(arg) ? arg : serializer(arg), computedValue = cache.get(cacheKey);
  5871. return typeof computedValue > "u" && (computedValue = fn.call(this, arg), cache.set(cacheKey, computedValue)), computedValue;
  5872. }
  5873. function variadic(fn, cache, serializer) {
  5874. var args = Array.prototype.slice.call(arguments, 3), cacheKey = serializer(args), computedValue = cache.get(cacheKey);
  5875. return typeof computedValue > "u" && (computedValue = fn.apply(this, args), cache.set(cacheKey, computedValue)), computedValue;
  5876. }
  5877. function assemble(fn, context, strategy, cache, serialize) {
  5878. return strategy.bind(context, fn, cache, serialize);
  5879. }
  5880. function strategyDefault(fn, options2) {
  5881. var strategy = fn.length === 1 ? monadic : variadic;
  5882. return assemble(fn, this, strategy, options2.cache.create(), options2.serializer);
  5883. }
  5884. function strategyVariadic(fn, options2) {
  5885. return assemble(fn, this, variadic, options2.cache.create(), options2.serializer);
  5886. }
  5887. function strategyMonadic(fn, options2) {
  5888. return assemble(fn, this, monadic, options2.cache.create(), options2.serializer);
  5889. }
  5890. var serializerDefault = function() {
  5891. return JSON.stringify(arguments);
  5892. }, ObjectWithoutPrototypeCache = (
  5893. /** @class */
  5894. (function() {
  5895. function ObjectWithoutPrototypeCache2() {
  5896. this.cache = /* @__PURE__ */ Object.create(null);
  5897. }
  5898. return ObjectWithoutPrototypeCache2.prototype.get = function(key) {
  5899. return this.cache[key];
  5900. }, ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
  5901. this.cache[key] = value;
  5902. }, ObjectWithoutPrototypeCache2;
  5903. })()
  5904. ), cacheDefault = {
  5905. create: function() {
  5906. return new ObjectWithoutPrototypeCache();
  5907. }
  5908. }, strategies = {
  5909. variadic: strategyVariadic,
  5910. monadic: strategyMonadic
  5911. };
  5912. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/error.js
  5913. var ErrorKind;
  5914. (function(ErrorKind2) {
  5915. 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";
  5916. })(ErrorKind || (ErrorKind = {}));
  5917. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/types.js
  5918. var TYPE;
  5919. (function(TYPE2) {
  5920. 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";
  5921. })(TYPE || (TYPE = {}));
  5922. var SKELETON_TYPE;
  5923. (function(SKELETON_TYPE2) {
  5924. SKELETON_TYPE2[SKELETON_TYPE2.number = 0] = "number", SKELETON_TYPE2[SKELETON_TYPE2.dateTime = 1] = "dateTime";
  5925. })(SKELETON_TYPE || (SKELETON_TYPE = {}));
  5926. function isLiteralElement(el) {
  5927. return el.type === TYPE.literal;
  5928. }
  5929. function isArgumentElement(el) {
  5930. return el.type === TYPE.argument;
  5931. }
  5932. function isNumberElement(el) {
  5933. return el.type === TYPE.number;
  5934. }
  5935. function isDateElement(el) {
  5936. return el.type === TYPE.date;
  5937. }
  5938. function isTimeElement(el) {
  5939. return el.type === TYPE.time;
  5940. }
  5941. function isSelectElement(el) {
  5942. return el.type === TYPE.select;
  5943. }
  5944. function isPluralElement(el) {
  5945. return el.type === TYPE.plural;
  5946. }
  5947. function isPoundElement(el) {
  5948. return el.type === TYPE.pound;
  5949. }
  5950. function isTagElement(el) {
  5951. return el.type === TYPE.tag;
  5952. }
  5953. function isNumberSkeleton(el) {
  5954. return !!(el && typeof el == "object" && el.type === SKELETON_TYPE.number);
  5955. }
  5956. function isDateTimeSkeleton(el) {
  5957. return !!(el && typeof el == "object" && el.type === SKELETON_TYPE.dateTime);
  5958. }
  5959. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/regex.generated.js
  5960. var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  5961. // ../../node_modules/@formatjs/icu-skeleton-parser/lib/date-time.js
  5962. 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;
  5963. function parseDateTimeSkeleton(skeleton) {
  5964. var result = {};
  5965. return skeleton.replace(DATE_TIME_REGEX, function(match) {
  5966. var len = match.length;
  5967. switch (match[0]) {
  5968. // Era
  5969. case "G":
  5970. result.era = len === 4 ? "long" : len === 5 ? "narrow" : "short";
  5971. break;
  5972. // Year
  5973. case "y":
  5974. result.year = len === 2 ? "2-digit" : "numeric";
  5975. break;
  5976. case "Y":
  5977. case "u":
  5978. case "U":
  5979. case "r":
  5980. throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
  5981. // Quarter
  5982. case "q":
  5983. case "Q":
  5984. throw new RangeError("`q/Q` (quarter) patterns are not supported");
  5985. // Month
  5986. case "M":
  5987. case "L":
  5988. result.month = ["numeric", "2-digit", "short", "long", "narrow"][len - 1];
  5989. break;
  5990. // Week
  5991. case "w":
  5992. case "W":
  5993. throw new RangeError("`w/W` (week) patterns are not supported");
  5994. case "d":
  5995. result.day = ["numeric", "2-digit"][len - 1];
  5996. break;
  5997. case "D":
  5998. case "F":
  5999. case "g":
  6000. throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
  6001. // Weekday
  6002. case "E":
  6003. result.weekday = len === 4 ? "long" : len === 5 ? "narrow" : "short";
  6004. break;
  6005. case "e":
  6006. if (len < 4)
  6007. throw new RangeError("`e..eee` (weekday) patterns are not supported");
  6008. result.weekday = ["short", "long", "narrow", "short"][len - 4];
  6009. break;
  6010. case "c":
  6011. if (len < 4)
  6012. throw new RangeError("`c..ccc` (weekday) patterns are not supported");
  6013. result.weekday = ["short", "long", "narrow", "short"][len - 4];
  6014. break;
  6015. // Period
  6016. case "a":
  6017. result.hour12 = !0;
  6018. break;
  6019. case "b":
  6020. // am, pm, noon, midnight
  6021. case "B":
  6022. throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
  6023. // Hour
  6024. case "h":
  6025. result.hourCycle = "h12", result.hour = ["numeric", "2-digit"][len - 1];
  6026. break;
  6027. case "H":
  6028. result.hourCycle = "h23", result.hour = ["numeric", "2-digit"][len - 1];
  6029. break;
  6030. case "K":
  6031. result.hourCycle = "h11", result.hour = ["numeric", "2-digit"][len - 1];
  6032. break;
  6033. case "k":
  6034. result.hourCycle = "h24", result.hour = ["numeric", "2-digit"][len - 1];
  6035. break;
  6036. case "j":
  6037. case "J":
  6038. case "C":
  6039. throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
  6040. // Minute
  6041. case "m":
  6042. result.minute = ["numeric", "2-digit"][len - 1];
  6043. break;
  6044. // Second
  6045. case "s":
  6046. result.second = ["numeric", "2-digit"][len - 1];
  6047. break;
  6048. case "S":
  6049. case "A":
  6050. throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
  6051. // Zone
  6052. case "z":
  6053. result.timeZoneName = len < 4 ? "short" : "long";
  6054. break;
  6055. case "Z":
  6056. // 1..3, 4, 5: The ISO8601 varios formats
  6057. case "O":
  6058. // 1, 4: milliseconds in day short, long
  6059. case "v":
  6060. // 1, 4: generic non-location format
  6061. case "V":
  6062. // 1, 2, 3, 4: time zone ID or city
  6063. case "X":
  6064. // 1, 2, 3, 4: The ISO8601 varios formats
  6065. case "x":
  6066. throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
  6067. }
  6068. return "";
  6069. }), result;
  6070. }
  6071. // ../../node_modules/@formatjs/icu-skeleton-parser/lib/regex.generated.js
  6072. var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
  6073. // ../../node_modules/@formatjs/icu-skeleton-parser/lib/number.js
  6074. function parseNumberSkeletonFromString(skeleton) {
  6075. if (skeleton.length === 0)
  6076. throw new Error("Number skeleton cannot be empty");
  6077. for (var stringTokens = skeleton.split(WHITE_SPACE_REGEX).filter(function(x2) {
  6078. return x2.length > 0;
  6079. }), tokens2 = [], _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
  6080. var stringToken = stringTokens_1[_i], stemAndOptions = stringToken.split("/");
  6081. if (stemAndOptions.length === 0)
  6082. throw new Error("Invalid number skeleton");
  6083. for (var stem = stemAndOptions[0], options2 = stemAndOptions.slice(1), _a2 = 0, options_1 = options2; _a2 < options_1.length; _a2++) {
  6084. var option = options_1[_a2];
  6085. if (option.length === 0)
  6086. throw new Error("Invalid number skeleton");
  6087. }
  6088. tokens2.push({ stem, options: options2 });
  6089. }
  6090. return tokens2;
  6091. }
  6092. function icuUnitToEcma(unit) {
  6093. return unit.replace(/^(.*?)-/, "");
  6094. }
  6095. var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g, INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g, CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
  6096. function parseSignificantPrecision(str) {
  6097. var result = {};
  6098. 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) {
  6099. 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)), "";
  6100. }), result;
  6101. }
  6102. function parseSign(str) {
  6103. switch (str) {
  6104. case "sign-auto":
  6105. return {
  6106. signDisplay: "auto"
  6107. };
  6108. case "sign-accounting":
  6109. case "()":
  6110. return {
  6111. currencySign: "accounting"
  6112. };
  6113. case "sign-always":
  6114. case "+!":
  6115. return {
  6116. signDisplay: "always"
  6117. };
  6118. case "sign-accounting-always":
  6119. case "()!":
  6120. return {
  6121. signDisplay: "always",
  6122. currencySign: "accounting"
  6123. };
  6124. case "sign-except-zero":
  6125. case "+?":
  6126. return {
  6127. signDisplay: "exceptZero"
  6128. };
  6129. case "sign-accounting-except-zero":
  6130. case "()?":
  6131. return {
  6132. signDisplay: "exceptZero",
  6133. currencySign: "accounting"
  6134. };
  6135. case "sign-never":
  6136. case "+_":
  6137. return {
  6138. signDisplay: "never"
  6139. };
  6140. }
  6141. }
  6142. function parseConciseScientificAndEngineeringStem(stem) {
  6143. var result;
  6144. if (stem[0] === "E" && stem[1] === "E" ? (result = {
  6145. notation: "engineering"
  6146. }, stem = stem.slice(2)) : stem[0] === "E" && (result = {
  6147. notation: "scientific"
  6148. }, stem = stem.slice(1)), result) {
  6149. var signDisplay = stem.slice(0, 2);
  6150. if (signDisplay === "+!" ? (result.signDisplay = "always", stem = stem.slice(2)) : signDisplay === "+?" && (result.signDisplay = "exceptZero", stem = stem.slice(2)), !CONCISE_INTEGER_WIDTH_REGEX.test(stem))
  6151. throw new Error("Malformed concise eng/scientific notation");
  6152. result.minimumIntegerDigits = stem.length;
  6153. }
  6154. return result;
  6155. }
  6156. function parseNotationOptions(opt) {
  6157. var result = {}, signOpts = parseSign(opt);
  6158. return signOpts || result;
  6159. }
  6160. function parseNumberSkeleton(tokens2) {
  6161. for (var result = {}, _i = 0, tokens_1 = tokens2; _i < tokens_1.length; _i++) {
  6162. var token = tokens_1[_i];
  6163. switch (token.stem) {
  6164. case "percent":
  6165. case "%":
  6166. result.style = "percent";
  6167. continue;
  6168. case "%x100":
  6169. result.style = "percent", result.scale = 100;
  6170. continue;
  6171. case "currency":
  6172. result.style = "currency", result.currency = token.options[0];
  6173. continue;
  6174. case "group-off":
  6175. case ",_":
  6176. result.useGrouping = !1;
  6177. continue;
  6178. case "precision-integer":
  6179. case ".":
  6180. result.maximumFractionDigits = 0;
  6181. continue;
  6182. case "measure-unit":
  6183. case "unit":
  6184. result.style = "unit", result.unit = icuUnitToEcma(token.options[0]);
  6185. continue;
  6186. case "compact-short":
  6187. case "K":
  6188. result.notation = "compact", result.compactDisplay = "short";
  6189. continue;
  6190. case "compact-long":
  6191. case "KK":
  6192. result.notation = "compact", result.compactDisplay = "long";
  6193. continue;
  6194. case "scientific":
  6195. result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt2) {
  6196. return __assign(__assign({}, all), parseNotationOptions(opt2));
  6197. }, {}));
  6198. continue;
  6199. case "engineering":
  6200. result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt2) {
  6201. return __assign(__assign({}, all), parseNotationOptions(opt2));
  6202. }, {}));
  6203. continue;
  6204. case "notation-simple":
  6205. result.notation = "standard";
  6206. continue;
  6207. // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
  6208. case "unit-width-narrow":
  6209. result.currencyDisplay = "narrowSymbol", result.unitDisplay = "narrow";
  6210. continue;
  6211. case "unit-width-short":
  6212. result.currencyDisplay = "code", result.unitDisplay = "short";
  6213. continue;
  6214. case "unit-width-full-name":
  6215. result.currencyDisplay = "name", result.unitDisplay = "long";
  6216. continue;
  6217. case "unit-width-iso-code":
  6218. result.currencyDisplay = "symbol";
  6219. continue;
  6220. case "scale":
  6221. result.scale = parseFloat(token.options[0]);
  6222. continue;
  6223. case "rounding-mode-floor":
  6224. result.roundingMode = "floor";
  6225. continue;
  6226. case "rounding-mode-ceiling":
  6227. result.roundingMode = "ceil";
  6228. continue;
  6229. case "rounding-mode-down":
  6230. result.roundingMode = "trunc";
  6231. continue;
  6232. case "rounding-mode-up":
  6233. result.roundingMode = "expand";
  6234. continue;
  6235. case "rounding-mode-half-even":
  6236. result.roundingMode = "halfEven";
  6237. continue;
  6238. case "rounding-mode-half-down":
  6239. result.roundingMode = "halfTrunc";
  6240. continue;
  6241. case "rounding-mode-half-up":
  6242. result.roundingMode = "halfExpand";
  6243. continue;
  6244. // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
  6245. case "integer-width":
  6246. if (token.options.length > 1)
  6247. throw new RangeError("integer-width stems only accept a single optional option");
  6248. token.options[0].replace(INTEGER_WIDTH_REGEX, function(_2, g1, g2, g3, g4, g5) {
  6249. if (g1)
  6250. result.minimumIntegerDigits = g2.length;
  6251. else {
  6252. if (g3 && g4)
  6253. throw new Error("We currently do not support maximum integer digits");
  6254. if (g5)
  6255. throw new Error("We currently do not support exact integer digits");
  6256. }
  6257. return "";
  6258. });
  6259. continue;
  6260. }
  6261. if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
  6262. result.minimumIntegerDigits = token.stem.length;
  6263. continue;
  6264. }
  6265. if (FRACTION_PRECISION_REGEX.test(token.stem)) {
  6266. if (token.options.length > 1)
  6267. throw new RangeError("Fraction-precision stems only accept a single optional option");
  6268. token.stem.replace(FRACTION_PRECISION_REGEX, function(_2, g1, g2, g3, g4, g5) {
  6269. 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), "";
  6270. });
  6271. var opt = token.options[0];
  6272. opt === "w" ? result = __assign(__assign({}, result), { trailingZeroDisplay: "stripIfInteger" }) : opt && (result = __assign(__assign({}, result), parseSignificantPrecision(opt)));
  6273. continue;
  6274. }
  6275. if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
  6276. result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
  6277. continue;
  6278. }
  6279. var signOpts = parseSign(token.stem);
  6280. signOpts && (result = __assign(__assign({}, result), signOpts));
  6281. var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
  6282. conciseScientificAndEngineeringOpts && (result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts));
  6283. }
  6284. return result;
  6285. }
  6286. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/time-data.generated.js
  6287. var timeData = {
  6288. "001": [
  6289. "H",
  6290. "h"
  6291. ],
  6292. 419: [
  6293. "h",
  6294. "H",
  6295. "hB",
  6296. "hb"
  6297. ],
  6298. AC: [
  6299. "H",
  6300. "h",
  6301. "hb",
  6302. "hB"
  6303. ],
  6304. AD: [
  6305. "H",
  6306. "hB"
  6307. ],
  6308. AE: [
  6309. "h",
  6310. "hB",
  6311. "hb",
  6312. "H"
  6313. ],
  6314. AF: [
  6315. "H",
  6316. "hb",
  6317. "hB",
  6318. "h"
  6319. ],
  6320. AG: [
  6321. "h",
  6322. "hb",
  6323. "H",
  6324. "hB"
  6325. ],
  6326. AI: [
  6327. "H",
  6328. "h",
  6329. "hb",
  6330. "hB"
  6331. ],
  6332. AL: [
  6333. "h",
  6334. "H",
  6335. "hB"
  6336. ],
  6337. AM: [
  6338. "H",
  6339. "hB"
  6340. ],
  6341. AO: [
  6342. "H",
  6343. "hB"
  6344. ],
  6345. AR: [
  6346. "h",
  6347. "H",
  6348. "hB",
  6349. "hb"
  6350. ],
  6351. AS: [
  6352. "h",
  6353. "H"
  6354. ],
  6355. AT: [
  6356. "H",
  6357. "hB"
  6358. ],
  6359. AU: [
  6360. "h",
  6361. "hb",
  6362. "H",
  6363. "hB"
  6364. ],
  6365. AW: [
  6366. "H",
  6367. "hB"
  6368. ],
  6369. AX: [
  6370. "H"
  6371. ],
  6372. AZ: [
  6373. "H",
  6374. "hB",
  6375. "h"
  6376. ],
  6377. BA: [
  6378. "H",
  6379. "hB",
  6380. "h"
  6381. ],
  6382. BB: [
  6383. "h",
  6384. "hb",
  6385. "H",
  6386. "hB"
  6387. ],
  6388. BD: [
  6389. "h",
  6390. "hB",
  6391. "H"
  6392. ],
  6393. BE: [
  6394. "H",
  6395. "hB"
  6396. ],
  6397. BF: [
  6398. "H",
  6399. "hB"
  6400. ],
  6401. BG: [
  6402. "H",
  6403. "hB",
  6404. "h"
  6405. ],
  6406. BH: [
  6407. "h",
  6408. "hB",
  6409. "hb",
  6410. "H"
  6411. ],
  6412. BI: [
  6413. "H",
  6414. "h"
  6415. ],
  6416. BJ: [
  6417. "H",
  6418. "hB"
  6419. ],
  6420. BL: [
  6421. "H",
  6422. "hB"
  6423. ],
  6424. BM: [
  6425. "h",
  6426. "hb",
  6427. "H",
  6428. "hB"
  6429. ],
  6430. BN: [
  6431. "hb",
  6432. "hB",
  6433. "h",
  6434. "H"
  6435. ],
  6436. BO: [
  6437. "h",
  6438. "H",
  6439. "hB",
  6440. "hb"
  6441. ],
  6442. BQ: [
  6443. "H"
  6444. ],
  6445. BR: [
  6446. "H",
  6447. "hB"
  6448. ],
  6449. BS: [
  6450. "h",
  6451. "hb",
  6452. "H",
  6453. "hB"
  6454. ],
  6455. BT: [
  6456. "h",
  6457. "H"
  6458. ],
  6459. BW: [
  6460. "H",
  6461. "h",
  6462. "hb",
  6463. "hB"
  6464. ],
  6465. BY: [
  6466. "H",
  6467. "h"
  6468. ],
  6469. BZ: [
  6470. "H",
  6471. "h",
  6472. "hb",
  6473. "hB"
  6474. ],
  6475. CA: [
  6476. "h",
  6477. "hb",
  6478. "H",
  6479. "hB"
  6480. ],
  6481. CC: [
  6482. "H",
  6483. "h",
  6484. "hb",
  6485. "hB"
  6486. ],
  6487. CD: [
  6488. "hB",
  6489. "H"
  6490. ],
  6491. CF: [
  6492. "H",
  6493. "h",
  6494. "hB"
  6495. ],
  6496. CG: [
  6497. "H",
  6498. "hB"
  6499. ],
  6500. CH: [
  6501. "H",
  6502. "hB",
  6503. "h"
  6504. ],
  6505. CI: [
  6506. "H",
  6507. "hB"
  6508. ],
  6509. CK: [
  6510. "H",
  6511. "h",
  6512. "hb",
  6513. "hB"
  6514. ],
  6515. CL: [
  6516. "h",
  6517. "H",
  6518. "hB",
  6519. "hb"
  6520. ],
  6521. CM: [
  6522. "H",
  6523. "h",
  6524. "hB"
  6525. ],
  6526. CN: [
  6527. "H",
  6528. "hB",
  6529. "hb",
  6530. "h"
  6531. ],
  6532. CO: [
  6533. "h",
  6534. "H",
  6535. "hB",
  6536. "hb"
  6537. ],
  6538. CP: [
  6539. "H"
  6540. ],
  6541. CR: [
  6542. "h",
  6543. "H",
  6544. "hB",
  6545. "hb"
  6546. ],
  6547. CU: [
  6548. "h",
  6549. "H",
  6550. "hB",
  6551. "hb"
  6552. ],
  6553. CV: [
  6554. "H",
  6555. "hB"
  6556. ],
  6557. CW: [
  6558. "H",
  6559. "hB"
  6560. ],
  6561. CX: [
  6562. "H",
  6563. "h",
  6564. "hb",
  6565. "hB"
  6566. ],
  6567. CY: [
  6568. "h",
  6569. "H",
  6570. "hb",
  6571. "hB"
  6572. ],
  6573. CZ: [
  6574. "H"
  6575. ],
  6576. DE: [
  6577. "H",
  6578. "hB"
  6579. ],
  6580. DG: [
  6581. "H",
  6582. "h",
  6583. "hb",
  6584. "hB"
  6585. ],
  6586. DJ: [
  6587. "h",
  6588. "H"
  6589. ],
  6590. DK: [
  6591. "H"
  6592. ],
  6593. DM: [
  6594. "h",
  6595. "hb",
  6596. "H",
  6597. "hB"
  6598. ],
  6599. DO: [
  6600. "h",
  6601. "H",
  6602. "hB",
  6603. "hb"
  6604. ],
  6605. DZ: [
  6606. "h",
  6607. "hB",
  6608. "hb",
  6609. "H"
  6610. ],
  6611. EA: [
  6612. "H",
  6613. "h",
  6614. "hB",
  6615. "hb"
  6616. ],
  6617. EC: [
  6618. "h",
  6619. "H",
  6620. "hB",
  6621. "hb"
  6622. ],
  6623. EE: [
  6624. "H",
  6625. "hB"
  6626. ],
  6627. EG: [
  6628. "h",
  6629. "hB",
  6630. "hb",
  6631. "H"
  6632. ],
  6633. EH: [
  6634. "h",
  6635. "hB",
  6636. "hb",
  6637. "H"
  6638. ],
  6639. ER: [
  6640. "h",
  6641. "H"
  6642. ],
  6643. ES: [
  6644. "H",
  6645. "hB",
  6646. "h",
  6647. "hb"
  6648. ],
  6649. ET: [
  6650. "hB",
  6651. "hb",
  6652. "h",
  6653. "H"
  6654. ],
  6655. FI: [
  6656. "H"
  6657. ],
  6658. FJ: [
  6659. "h",
  6660. "hb",
  6661. "H",
  6662. "hB"
  6663. ],
  6664. FK: [
  6665. "H",
  6666. "h",
  6667. "hb",
  6668. "hB"
  6669. ],
  6670. FM: [
  6671. "h",
  6672. "hb",
  6673. "H",
  6674. "hB"
  6675. ],
  6676. FO: [
  6677. "H",
  6678. "h"
  6679. ],
  6680. FR: [
  6681. "H",
  6682. "hB"
  6683. ],
  6684. GA: [
  6685. "H",
  6686. "hB"
  6687. ],
  6688. GB: [
  6689. "H",
  6690. "h",
  6691. "hb",
  6692. "hB"
  6693. ],
  6694. GD: [
  6695. "h",
  6696. "hb",
  6697. "H",
  6698. "hB"
  6699. ],
  6700. GE: [
  6701. "H",
  6702. "hB",
  6703. "h"
  6704. ],
  6705. GF: [
  6706. "H",
  6707. "hB"
  6708. ],
  6709. GG: [
  6710. "H",
  6711. "h",
  6712. "hb",
  6713. "hB"
  6714. ],
  6715. GH: [
  6716. "h",
  6717. "H"
  6718. ],
  6719. GI: [
  6720. "H",
  6721. "h",
  6722. "hb",
  6723. "hB"
  6724. ],
  6725. GL: [
  6726. "H",
  6727. "h"
  6728. ],
  6729. GM: [
  6730. "h",
  6731. "hb",
  6732. "H",
  6733. "hB"
  6734. ],
  6735. GN: [
  6736. "H",
  6737. "hB"
  6738. ],
  6739. GP: [
  6740. "H",
  6741. "hB"
  6742. ],
  6743. GQ: [
  6744. "H",
  6745. "hB",
  6746. "h",
  6747. "hb"
  6748. ],
  6749. GR: [
  6750. "h",
  6751. "H",
  6752. "hb",
  6753. "hB"
  6754. ],
  6755. GT: [
  6756. "h",
  6757. "H",
  6758. "hB",
  6759. "hb"
  6760. ],
  6761. GU: [
  6762. "h",
  6763. "hb",
  6764. "H",
  6765. "hB"
  6766. ],
  6767. GW: [
  6768. "H",
  6769. "hB"
  6770. ],
  6771. GY: [
  6772. "h",
  6773. "hb",
  6774. "H",
  6775. "hB"
  6776. ],
  6777. HK: [
  6778. "h",
  6779. "hB",
  6780. "hb",
  6781. "H"
  6782. ],
  6783. HN: [
  6784. "h",
  6785. "H",
  6786. "hB",
  6787. "hb"
  6788. ],
  6789. HR: [
  6790. "H",
  6791. "hB"
  6792. ],
  6793. HU: [
  6794. "H",
  6795. "h"
  6796. ],
  6797. IC: [
  6798. "H",
  6799. "h",
  6800. "hB",
  6801. "hb"
  6802. ],
  6803. ID: [
  6804. "H"
  6805. ],
  6806. IE: [
  6807. "H",
  6808. "h",
  6809. "hb",
  6810. "hB"
  6811. ],
  6812. IL: [
  6813. "H",
  6814. "hB"
  6815. ],
  6816. IM: [
  6817. "H",
  6818. "h",
  6819. "hb",
  6820. "hB"
  6821. ],
  6822. IN: [
  6823. "h",
  6824. "H"
  6825. ],
  6826. IO: [
  6827. "H",
  6828. "h",
  6829. "hb",
  6830. "hB"
  6831. ],
  6832. IQ: [
  6833. "h",
  6834. "hB",
  6835. "hb",
  6836. "H"
  6837. ],
  6838. IR: [
  6839. "hB",
  6840. "H"
  6841. ],
  6842. IS: [
  6843. "H"
  6844. ],
  6845. IT: [
  6846. "H",
  6847. "hB"
  6848. ],
  6849. JE: [
  6850. "H",
  6851. "h",
  6852. "hb",
  6853. "hB"
  6854. ],
  6855. JM: [
  6856. "h",
  6857. "hb",
  6858. "H",
  6859. "hB"
  6860. ],
  6861. JO: [
  6862. "h",
  6863. "hB",
  6864. "hb",
  6865. "H"
  6866. ],
  6867. JP: [
  6868. "H",
  6869. "K",
  6870. "h"
  6871. ],
  6872. KE: [
  6873. "hB",
  6874. "hb",
  6875. "H",
  6876. "h"
  6877. ],
  6878. KG: [
  6879. "H",
  6880. "h",
  6881. "hB",
  6882. "hb"
  6883. ],
  6884. KH: [
  6885. "hB",
  6886. "h",
  6887. "H",
  6888. "hb"
  6889. ],
  6890. KI: [
  6891. "h",
  6892. "hb",
  6893. "H",
  6894. "hB"
  6895. ],
  6896. KM: [
  6897. "H",
  6898. "h",
  6899. "hB",
  6900. "hb"
  6901. ],
  6902. KN: [
  6903. "h",
  6904. "hb",
  6905. "H",
  6906. "hB"
  6907. ],
  6908. KP: [
  6909. "h",
  6910. "H",
  6911. "hB",
  6912. "hb"
  6913. ],
  6914. KR: [
  6915. "h",
  6916. "H",
  6917. "hB",
  6918. "hb"
  6919. ],
  6920. KW: [
  6921. "h",
  6922. "hB",
  6923. "hb",
  6924. "H"
  6925. ],
  6926. KY: [
  6927. "h",
  6928. "hb",
  6929. "H",
  6930. "hB"
  6931. ],
  6932. KZ: [
  6933. "H",
  6934. "hB"
  6935. ],
  6936. LA: [
  6937. "H",
  6938. "hb",
  6939. "hB",
  6940. "h"
  6941. ],
  6942. LB: [
  6943. "h",
  6944. "hB",
  6945. "hb",
  6946. "H"
  6947. ],
  6948. LC: [
  6949. "h",
  6950. "hb",
  6951. "H",
  6952. "hB"
  6953. ],
  6954. LI: [
  6955. "H",
  6956. "hB",
  6957. "h"
  6958. ],
  6959. LK: [
  6960. "H",
  6961. "h",
  6962. "hB",
  6963. "hb"
  6964. ],
  6965. LR: [
  6966. "h",
  6967. "hb",
  6968. "H",
  6969. "hB"
  6970. ],
  6971. LS: [
  6972. "h",
  6973. "H"
  6974. ],
  6975. LT: [
  6976. "H",
  6977. "h",
  6978. "hb",
  6979. "hB"
  6980. ],
  6981. LU: [
  6982. "H",
  6983. "h",
  6984. "hB"
  6985. ],
  6986. LV: [
  6987. "H",
  6988. "hB",
  6989. "hb",
  6990. "h"
  6991. ],
  6992. LY: [
  6993. "h",
  6994. "hB",
  6995. "hb",
  6996. "H"
  6997. ],
  6998. MA: [
  6999. "H",
  7000. "h",
  7001. "hB",
  7002. "hb"
  7003. ],
  7004. MC: [
  7005. "H",
  7006. "hB"
  7007. ],
  7008. MD: [
  7009. "H",
  7010. "hB"
  7011. ],
  7012. ME: [
  7013. "H",
  7014. "hB",
  7015. "h"
  7016. ],
  7017. MF: [
  7018. "H",
  7019. "hB"
  7020. ],
  7021. MG: [
  7022. "H",
  7023. "h"
  7024. ],
  7025. MH: [
  7026. "h",
  7027. "hb",
  7028. "H",
  7029. "hB"
  7030. ],
  7031. MK: [
  7032. "H",
  7033. "h",
  7034. "hb",
  7035. "hB"
  7036. ],
  7037. ML: [
  7038. "H"
  7039. ],
  7040. MM: [
  7041. "hB",
  7042. "hb",
  7043. "H",
  7044. "h"
  7045. ],
  7046. MN: [
  7047. "H",
  7048. "h",
  7049. "hb",
  7050. "hB"
  7051. ],
  7052. MO: [
  7053. "h",
  7054. "hB",
  7055. "hb",
  7056. "H"
  7057. ],
  7058. MP: [
  7059. "h",
  7060. "hb",
  7061. "H",
  7062. "hB"
  7063. ],
  7064. MQ: [
  7065. "H",
  7066. "hB"
  7067. ],
  7068. MR: [
  7069. "h",
  7070. "hB",
  7071. "hb",
  7072. "H"
  7073. ],
  7074. MS: [
  7075. "H",
  7076. "h",
  7077. "hb",
  7078. "hB"
  7079. ],
  7080. MT: [
  7081. "H",
  7082. "h"
  7083. ],
  7084. MU: [
  7085. "H",
  7086. "h"
  7087. ],
  7088. MV: [
  7089. "H",
  7090. "h"
  7091. ],
  7092. MW: [
  7093. "h",
  7094. "hb",
  7095. "H",
  7096. "hB"
  7097. ],
  7098. MX: [
  7099. "h",
  7100. "H",
  7101. "hB",
  7102. "hb"
  7103. ],
  7104. MY: [
  7105. "hb",
  7106. "hB",
  7107. "h",
  7108. "H"
  7109. ],
  7110. MZ: [
  7111. "H",
  7112. "hB"
  7113. ],
  7114. NA: [
  7115. "h",
  7116. "H",
  7117. "hB",
  7118. "hb"
  7119. ],
  7120. NC: [
  7121. "H",
  7122. "hB"
  7123. ],
  7124. NE: [
  7125. "H"
  7126. ],
  7127. NF: [
  7128. "H",
  7129. "h",
  7130. "hb",
  7131. "hB"
  7132. ],
  7133. NG: [
  7134. "H",
  7135. "h",
  7136. "hb",
  7137. "hB"
  7138. ],
  7139. NI: [
  7140. "h",
  7141. "H",
  7142. "hB",
  7143. "hb"
  7144. ],
  7145. NL: [
  7146. "H",
  7147. "hB"
  7148. ],
  7149. NO: [
  7150. "H",
  7151. "h"
  7152. ],
  7153. NP: [
  7154. "H",
  7155. "h",
  7156. "hB"
  7157. ],
  7158. NR: [
  7159. "H",
  7160. "h",
  7161. "hb",
  7162. "hB"
  7163. ],
  7164. NU: [
  7165. "H",
  7166. "h",
  7167. "hb",
  7168. "hB"
  7169. ],
  7170. NZ: [
  7171. "h",
  7172. "hb",
  7173. "H",
  7174. "hB"
  7175. ],
  7176. OM: [
  7177. "h",
  7178. "hB",
  7179. "hb",
  7180. "H"
  7181. ],
  7182. PA: [
  7183. "h",
  7184. "H",
  7185. "hB",
  7186. "hb"
  7187. ],
  7188. PE: [
  7189. "h",
  7190. "H",
  7191. "hB",
  7192. "hb"
  7193. ],
  7194. PF: [
  7195. "H",
  7196. "h",
  7197. "hB"
  7198. ],
  7199. PG: [
  7200. "h",
  7201. "H"
  7202. ],
  7203. PH: [
  7204. "h",
  7205. "hB",
  7206. "hb",
  7207. "H"
  7208. ],
  7209. PK: [
  7210. "h",
  7211. "hB",
  7212. "H"
  7213. ],
  7214. PL: [
  7215. "H",
  7216. "h"
  7217. ],
  7218. PM: [
  7219. "H",
  7220. "hB"
  7221. ],
  7222. PN: [
  7223. "H",
  7224. "h",
  7225. "hb",
  7226. "hB"
  7227. ],
  7228. PR: [
  7229. "h",
  7230. "H",
  7231. "hB",
  7232. "hb"
  7233. ],
  7234. PS: [
  7235. "h",
  7236. "hB",
  7237. "hb",
  7238. "H"
  7239. ],
  7240. PT: [
  7241. "H",
  7242. "hB"
  7243. ],
  7244. PW: [
  7245. "h",
  7246. "H"
  7247. ],
  7248. PY: [
  7249. "h",
  7250. "H",
  7251. "hB",
  7252. "hb"
  7253. ],
  7254. QA: [
  7255. "h",
  7256. "hB",
  7257. "hb",
  7258. "H"
  7259. ],
  7260. RE: [
  7261. "H",
  7262. "hB"
  7263. ],
  7264. RO: [
  7265. "H",
  7266. "hB"
  7267. ],
  7268. RS: [
  7269. "H",
  7270. "hB",
  7271. "h"
  7272. ],
  7273. RU: [
  7274. "H"
  7275. ],
  7276. RW: [
  7277. "H",
  7278. "h"
  7279. ],
  7280. SA: [
  7281. "h",
  7282. "hB",
  7283. "hb",
  7284. "H"
  7285. ],
  7286. SB: [
  7287. "h",
  7288. "hb",
  7289. "H",
  7290. "hB"
  7291. ],
  7292. SC: [
  7293. "H",
  7294. "h",
  7295. "hB"
  7296. ],
  7297. SD: [
  7298. "h",
  7299. "hB",
  7300. "hb",
  7301. "H"
  7302. ],
  7303. SE: [
  7304. "H"
  7305. ],
  7306. SG: [
  7307. "h",
  7308. "hb",
  7309. "H",
  7310. "hB"
  7311. ],
  7312. SH: [
  7313. "H",
  7314. "h",
  7315. "hb",
  7316. "hB"
  7317. ],
  7318. SI: [
  7319. "H",
  7320. "hB"
  7321. ],
  7322. SJ: [
  7323. "H"
  7324. ],
  7325. SK: [
  7326. "H"
  7327. ],
  7328. SL: [
  7329. "h",
  7330. "hb",
  7331. "H",
  7332. "hB"
  7333. ],
  7334. SM: [
  7335. "H",
  7336. "h",
  7337. "hB"
  7338. ],
  7339. SN: [
  7340. "H",
  7341. "h",
  7342. "hB"
  7343. ],
  7344. SO: [
  7345. "h",
  7346. "H"
  7347. ],
  7348. SR: [
  7349. "H",
  7350. "hB"
  7351. ],
  7352. SS: [
  7353. "h",
  7354. "hb",
  7355. "H",
  7356. "hB"
  7357. ],
  7358. ST: [
  7359. "H",
  7360. "hB"
  7361. ],
  7362. SV: [
  7363. "h",
  7364. "H",
  7365. "hB",
  7366. "hb"
  7367. ],
  7368. SX: [
  7369. "H",
  7370. "h",
  7371. "hb",
  7372. "hB"
  7373. ],
  7374. SY: [
  7375. "h",
  7376. "hB",
  7377. "hb",
  7378. "H"
  7379. ],
  7380. SZ: [
  7381. "h",
  7382. "hb",
  7383. "H",
  7384. "hB"
  7385. ],
  7386. TA: [
  7387. "H",
  7388. "h",
  7389. "hb",
  7390. "hB"
  7391. ],
  7392. TC: [
  7393. "h",
  7394. "hb",
  7395. "H",
  7396. "hB"
  7397. ],
  7398. TD: [
  7399. "h",
  7400. "H",
  7401. "hB"
  7402. ],
  7403. TF: [
  7404. "H",
  7405. "h",
  7406. "hB"
  7407. ],
  7408. TG: [
  7409. "H",
  7410. "hB"
  7411. ],
  7412. TH: [
  7413. "H",
  7414. "h"
  7415. ],
  7416. TJ: [
  7417. "H",
  7418. "h"
  7419. ],
  7420. TL: [
  7421. "H",
  7422. "hB",
  7423. "hb",
  7424. "h"
  7425. ],
  7426. TM: [
  7427. "H",
  7428. "h"
  7429. ],
  7430. TN: [
  7431. "h",
  7432. "hB",
  7433. "hb",
  7434. "H"
  7435. ],
  7436. TO: [
  7437. "h",
  7438. "H"
  7439. ],
  7440. TR: [
  7441. "H",
  7442. "hB"
  7443. ],
  7444. TT: [
  7445. "h",
  7446. "hb",
  7447. "H",
  7448. "hB"
  7449. ],
  7450. TW: [
  7451. "hB",
  7452. "hb",
  7453. "h",
  7454. "H"
  7455. ],
  7456. TZ: [
  7457. "hB",
  7458. "hb",
  7459. "H",
  7460. "h"
  7461. ],
  7462. UA: [
  7463. "H",
  7464. "hB",
  7465. "h"
  7466. ],
  7467. UG: [
  7468. "hB",
  7469. "hb",
  7470. "H",
  7471. "h"
  7472. ],
  7473. UM: [
  7474. "h",
  7475. "hb",
  7476. "H",
  7477. "hB"
  7478. ],
  7479. US: [
  7480. "h",
  7481. "hb",
  7482. "H",
  7483. "hB"
  7484. ],
  7485. UY: [
  7486. "h",
  7487. "H",
  7488. "hB",
  7489. "hb"
  7490. ],
  7491. UZ: [
  7492. "H",
  7493. "hB",
  7494. "h"
  7495. ],
  7496. VA: [
  7497. "H",
  7498. "h",
  7499. "hB"
  7500. ],
  7501. VC: [
  7502. "h",
  7503. "hb",
  7504. "H",
  7505. "hB"
  7506. ],
  7507. VE: [
  7508. "h",
  7509. "H",
  7510. "hB",
  7511. "hb"
  7512. ],
  7513. VG: [
  7514. "h",
  7515. "hb",
  7516. "H",
  7517. "hB"
  7518. ],
  7519. VI: [
  7520. "h",
  7521. "hb",
  7522. "H",
  7523. "hB"
  7524. ],
  7525. VN: [
  7526. "H",
  7527. "h"
  7528. ],
  7529. VU: [
  7530. "h",
  7531. "H"
  7532. ],
  7533. WF: [
  7534. "H",
  7535. "hB"
  7536. ],
  7537. WS: [
  7538. "h",
  7539. "H"
  7540. ],
  7541. XK: [
  7542. "H",
  7543. "hB",
  7544. "h"
  7545. ],
  7546. YE: [
  7547. "h",
  7548. "hB",
  7549. "hb",
  7550. "H"
  7551. ],
  7552. YT: [
  7553. "H",
  7554. "hB"
  7555. ],
  7556. ZA: [
  7557. "H",
  7558. "h",
  7559. "hb",
  7560. "hB"
  7561. ],
  7562. ZM: [
  7563. "h",
  7564. "hb",
  7565. "H",
  7566. "hB"
  7567. ],
  7568. ZW: [
  7569. "H",
  7570. "h"
  7571. ],
  7572. "af-ZA": [
  7573. "H",
  7574. "h",
  7575. "hB",
  7576. "hb"
  7577. ],
  7578. "ar-001": [
  7579. "h",
  7580. "hB",
  7581. "hb",
  7582. "H"
  7583. ],
  7584. "ca-ES": [
  7585. "H",
  7586. "h",
  7587. "hB"
  7588. ],
  7589. "en-001": [
  7590. "h",
  7591. "hb",
  7592. "H",
  7593. "hB"
  7594. ],
  7595. "en-HK": [
  7596. "h",
  7597. "hb",
  7598. "H",
  7599. "hB"
  7600. ],
  7601. "en-IL": [
  7602. "H",
  7603. "h",
  7604. "hb",
  7605. "hB"
  7606. ],
  7607. "en-MY": [
  7608. "h",
  7609. "hb",
  7610. "H",
  7611. "hB"
  7612. ],
  7613. "es-BR": [
  7614. "H",
  7615. "h",
  7616. "hB",
  7617. "hb"
  7618. ],
  7619. "es-ES": [
  7620. "H",
  7621. "h",
  7622. "hB",
  7623. "hb"
  7624. ],
  7625. "es-GQ": [
  7626. "H",
  7627. "h",
  7628. "hB",
  7629. "hb"
  7630. ],
  7631. "fr-CA": [
  7632. "H",
  7633. "h",
  7634. "hB"
  7635. ],
  7636. "gl-ES": [
  7637. "H",
  7638. "h",
  7639. "hB"
  7640. ],
  7641. "gu-IN": [
  7642. "hB",
  7643. "hb",
  7644. "h",
  7645. "H"
  7646. ],
  7647. "hi-IN": [
  7648. "hB",
  7649. "h",
  7650. "H"
  7651. ],
  7652. "it-CH": [
  7653. "H",
  7654. "h",
  7655. "hB"
  7656. ],
  7657. "it-IT": [
  7658. "H",
  7659. "h",
  7660. "hB"
  7661. ],
  7662. "kn-IN": [
  7663. "hB",
  7664. "h",
  7665. "H"
  7666. ],
  7667. "ml-IN": [
  7668. "hB",
  7669. "h",
  7670. "H"
  7671. ],
  7672. "mr-IN": [
  7673. "hB",
  7674. "hb",
  7675. "h",
  7676. "H"
  7677. ],
  7678. "pa-IN": [
  7679. "hB",
  7680. "hb",
  7681. "h",
  7682. "H"
  7683. ],
  7684. "ta-IN": [
  7685. "hB",
  7686. "h",
  7687. "hb",
  7688. "H"
  7689. ],
  7690. "te-IN": [
  7691. "hB",
  7692. "h",
  7693. "H"
  7694. ],
  7695. "zu-ZA": [
  7696. "H",
  7697. "hB",
  7698. "hb",
  7699. "h"
  7700. ]
  7701. };
  7702. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/date-time-pattern-generator.js
  7703. function getBestPattern(skeleton, locale) {
  7704. for (var skeletonCopy = "", patternPos = 0; patternPos < skeleton.length; patternPos++) {
  7705. var patternChar = skeleton.charAt(patternPos);
  7706. if (patternChar === "j") {
  7707. for (var extraLength = 0; patternPos + 1 < skeleton.length && skeleton.charAt(patternPos + 1) === patternChar; )
  7708. extraLength++, patternPos++;
  7709. var hourLen = 1 + (extraLength & 1), dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1), dayPeriodChar = "a", hourChar = getDefaultHourSymbolFromLocale(locale);
  7710. for ((hourChar == "H" || hourChar == "k") && (dayPeriodLen = 0); dayPeriodLen-- > 0; )
  7711. skeletonCopy += dayPeriodChar;
  7712. for (; hourLen-- > 0; )
  7713. skeletonCopy = hourChar + skeletonCopy;
  7714. } else patternChar === "J" ? skeletonCopy += "H" : skeletonCopy += patternChar;
  7715. }
  7716. return skeletonCopy;
  7717. }
  7718. function getDefaultHourSymbolFromLocale(locale) {
  7719. var hourCycle = locale.hourCycle;
  7720. if (hourCycle === void 0 && // @ts-ignore hourCycle(s) is not identified yet
  7721. locale.hourCycles && // @ts-ignore
  7722. locale.hourCycles.length && (hourCycle = locale.hourCycles[0]), hourCycle)
  7723. switch (hourCycle) {
  7724. case "h24":
  7725. return "k";
  7726. case "h23":
  7727. return "H";
  7728. case "h12":
  7729. return "h";
  7730. case "h11":
  7731. return "K";
  7732. default:
  7733. throw new Error("Invalid hourCycle");
  7734. }
  7735. var languageTag = locale.language, regionTag;
  7736. languageTag !== "root" && (regionTag = locale.maximize().region);
  7737. var hourCycles = timeData[regionTag || ""] || timeData[languageTag || ""] || timeData["".concat(languageTag, "-001")] || timeData["001"];
  7738. return hourCycles[0];
  7739. }
  7740. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/parser.js
  7741. var _a, SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*")), SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
  7742. function createLocation(start, end) {
  7743. return { start, end };
  7744. }
  7745. 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) {
  7746. return typeof n3 == "number" && isFinite(n3) && Math.floor(n3) === n3 && Math.abs(n3) <= 9007199254740991;
  7747. }, REGEX_SUPPORTS_U_AND_Y = !0;
  7748. try {
  7749. 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";
  7750. } catch {
  7751. REGEX_SUPPORTS_U_AND_Y = !1;
  7752. }
  7753. var re, startsWith = hasNativeStartsWith ? (
  7754. // Native
  7755. function(s2, search, position) {
  7756. return s2.startsWith(search, position);
  7757. }
  7758. ) : (
  7759. // For IE11
  7760. function(s2, search, position) {
  7761. return s2.slice(position, position + search.length) === search;
  7762. }
  7763. ), fromCodePoint = hasNativeFromCodePoint ? String.fromCodePoint : (
  7764. // IE11
  7765. function() {
  7766. for (var codePoints = [], _i = 0; _i < arguments.length; _i++)
  7767. codePoints[_i] = arguments[_i];
  7768. for (var elements = "", length = codePoints.length, i2 = 0, code; length > i2; ) {
  7769. if (code = codePoints[i2++], code > 1114111)
  7770. throw RangeError(code + " is not a valid code point");
  7771. elements += code < 65536 ? String.fromCharCode(code) : String.fromCharCode(((code -= 65536) >> 10) + 55296, code % 1024 + 56320);
  7772. }
  7773. return elements;
  7774. }
  7775. ), fromEntries = (
  7776. // native
  7777. hasNativeFromEntries ? Object.fromEntries : (
  7778. // Ponyfill
  7779. function(entries) {
  7780. for (var obj = {}, _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  7781. var _a2 = entries_1[_i], k2 = _a2[0], v2 = _a2[1];
  7782. obj[k2] = v2;
  7783. }
  7784. return obj;
  7785. }
  7786. )
  7787. ), codePointAt = hasNativeCodePointAt ? (
  7788. // Native
  7789. function(s2, index) {
  7790. return s2.codePointAt(index);
  7791. }
  7792. ) : (
  7793. // IE 11
  7794. function(s2, index) {
  7795. var size = s2.length;
  7796. if (!(index < 0 || index >= size)) {
  7797. var first = s2.charCodeAt(index), second;
  7798. return first < 55296 || first > 56319 || index + 1 === size || (second = s2.charCodeAt(index + 1)) < 56320 || second > 57343 ? first : (first - 55296 << 10) + (second - 56320) + 65536;
  7799. }
  7800. }
  7801. ), trimStart = hasTrimStart ? (
  7802. // Native
  7803. function(s2) {
  7804. return s2.trimStart();
  7805. }
  7806. ) : (
  7807. // Ponyfill
  7808. function(s2) {
  7809. return s2.replace(SPACE_SEPARATOR_START_REGEX, "");
  7810. }
  7811. ), trimEnd = hasTrimEnd ? (
  7812. // Native
  7813. function(s2) {
  7814. return s2.trimEnd();
  7815. }
  7816. ) : (
  7817. // Ponyfill
  7818. function(s2) {
  7819. return s2.replace(SPACE_SEPARATOR_END_REGEX, "");
  7820. }
  7821. );
  7822. function RE(s2, flag) {
  7823. return new RegExp(s2, flag);
  7824. }
  7825. var matchIdentifierAtIndex;
  7826. REGEX_SUPPORTS_U_AND_Y ? (IDENTIFIER_PREFIX_RE_1 = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu"), matchIdentifierAtIndex = function(s2, index) {
  7827. var _a2;
  7828. IDENTIFIER_PREFIX_RE_1.lastIndex = index;
  7829. var match = IDENTIFIER_PREFIX_RE_1.exec(s2);
  7830. return (_a2 = match[1]) !== null && _a2 !== void 0 ? _a2 : "";
  7831. }) : matchIdentifierAtIndex = function(s2, index) {
  7832. for (var match = []; ; ) {
  7833. var c2 = codePointAt(s2, index);
  7834. if (c2 === void 0 || _isWhiteSpace(c2) || _isPatternSyntax(c2))
  7835. break;
  7836. match.push(c2), index += c2 >= 65536 ? 2 : 1;
  7837. }
  7838. return fromCodePoint.apply(void 0, match);
  7839. };
  7840. var IDENTIFIER_PREFIX_RE_1, Parser = (
  7841. /** @class */
  7842. (function() {
  7843. function Parser2(message, options2) {
  7844. 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;
  7845. }
  7846. return Parser2.prototype.parse = function() {
  7847. if (this.offset() !== 0)
  7848. throw Error("parser can only be used once");
  7849. return this.parseMessage(0, "", !1);
  7850. }, Parser2.prototype.parseMessage = function(nestingLevel, parentArgType, expectingCloseTag) {
  7851. for (var elements = []; !this.isEOF(); ) {
  7852. var char = this.char();
  7853. if (char === 123) {
  7854. var result = this.parseArgument(nestingLevel, expectingCloseTag);
  7855. if (result.err)
  7856. return result;
  7857. elements.push(result.val);
  7858. } else {
  7859. if (char === 125 && nestingLevel > 0)
  7860. break;
  7861. if (char === 35 && (parentArgType === "plural" || parentArgType === "selectordinal")) {
  7862. var position = this.clonePosition();
  7863. this.bump(), elements.push({
  7864. type: TYPE.pound,
  7865. location: createLocation(position, this.clonePosition())
  7866. });
  7867. } else if (char === 60 && !this.ignoreTag && this.peek() === 47) {
  7868. if (expectingCloseTag)
  7869. break;
  7870. return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
  7871. } else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
  7872. var result = this.parseTag(nestingLevel, parentArgType);
  7873. if (result.err)
  7874. return result;
  7875. elements.push(result.val);
  7876. } else {
  7877. var result = this.parseLiteral(nestingLevel, parentArgType);
  7878. if (result.err)
  7879. return result;
  7880. elements.push(result.val);
  7881. }
  7882. }
  7883. }
  7884. return { val: elements, err: null };
  7885. }, Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
  7886. var startPosition = this.clonePosition();
  7887. this.bump();
  7888. var tagName = this.parseTagName();
  7889. if (this.bumpSpace(), this.bumpIf("/>"))
  7890. return {
  7891. val: {
  7892. type: TYPE.literal,
  7893. value: "<".concat(tagName, "/>"),
  7894. location: createLocation(startPosition, this.clonePosition())
  7895. },
  7896. err: null
  7897. };
  7898. if (this.bumpIf(">")) {
  7899. var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, !0);
  7900. if (childrenResult.err)
  7901. return childrenResult;
  7902. var children = childrenResult.val, endTagStartPosition = this.clonePosition();
  7903. if (this.bumpIf("</")) {
  7904. if (this.isEOF() || !_isAlpha(this.char()))
  7905. return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
  7906. var closingTagNameStartPosition = this.clonePosition(), closingTagName = this.parseTagName();
  7907. return tagName !== closingTagName ? this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
  7908. val: {
  7909. type: TYPE.tag,
  7910. value: tagName,
  7911. children,
  7912. location: createLocation(startPosition, this.clonePosition())
  7913. },
  7914. err: null
  7915. } : this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition())));
  7916. } else
  7917. return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
  7918. } else
  7919. return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
  7920. }, Parser2.prototype.parseTagName = function() {
  7921. var startOffset = this.offset();
  7922. for (this.bump(); !this.isEOF() && _isPotentialElementNameChar(this.char()); )
  7923. this.bump();
  7924. return this.message.slice(startOffset, this.offset());
  7925. }, Parser2.prototype.parseLiteral = function(nestingLevel, parentArgType) {
  7926. for (var start = this.clonePosition(), value = ""; ; ) {
  7927. var parseQuoteResult = this.tryParseQuote(parentArgType);
  7928. if (parseQuoteResult) {
  7929. value += parseQuoteResult;
  7930. continue;
  7931. }
  7932. var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
  7933. if (parseUnquotedResult) {
  7934. value += parseUnquotedResult;
  7935. continue;
  7936. }
  7937. var parseLeftAngleResult = this.tryParseLeftAngleBracket();
  7938. if (parseLeftAngleResult) {
  7939. value += parseLeftAngleResult;
  7940. continue;
  7941. }
  7942. break;
  7943. }
  7944. var location2 = createLocation(start, this.clonePosition());
  7945. return {
  7946. val: { type: TYPE.literal, value, location: location2 },
  7947. err: null
  7948. };
  7949. }, Parser2.prototype.tryParseLeftAngleBracket = function() {
  7950. return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
  7951. !_isAlphaOrSlash(this.peek() || 0)) ? (this.bump(), "<") : null;
  7952. }, Parser2.prototype.tryParseQuote = function(parentArgType) {
  7953. if (this.isEOF() || this.char() !== 39)
  7954. return null;
  7955. switch (this.peek()) {
  7956. case 39:
  7957. return this.bump(), this.bump(), "'";
  7958. // '{', '<', '>', '}'
  7959. case 123:
  7960. case 60:
  7961. case 62:
  7962. case 125:
  7963. break;
  7964. case 35:
  7965. if (parentArgType === "plural" || parentArgType === "selectordinal")
  7966. break;
  7967. return null;
  7968. default:
  7969. return null;
  7970. }
  7971. this.bump();
  7972. var codePoints = [this.char()];
  7973. for (this.bump(); !this.isEOF(); ) {
  7974. var ch = this.char();
  7975. if (ch === 39)
  7976. if (this.peek() === 39)
  7977. codePoints.push(39), this.bump();
  7978. else {
  7979. this.bump();
  7980. break;
  7981. }
  7982. else
  7983. codePoints.push(ch);
  7984. this.bump();
  7985. }
  7986. return fromCodePoint.apply(void 0, codePoints);
  7987. }, Parser2.prototype.tryParseUnquoted = function(nestingLevel, parentArgType) {
  7988. if (this.isEOF())
  7989. return null;
  7990. var ch = this.char();
  7991. return ch === 60 || ch === 123 || ch === 35 && (parentArgType === "plural" || parentArgType === "selectordinal") || ch === 125 && nestingLevel > 0 ? null : (this.bump(), fromCodePoint(ch));
  7992. }, Parser2.prototype.parseArgument = function(nestingLevel, expectingCloseTag) {
  7993. var openingBracePosition = this.clonePosition();
  7994. if (this.bump(), this.bumpSpace(), this.isEOF())
  7995. return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
  7996. if (this.char() === 125)
  7997. return this.bump(), this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
  7998. var value = this.parseIdentifierIfPossible().value;
  7999. if (!value)
  8000. return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
  8001. if (this.bumpSpace(), this.isEOF())
  8002. return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
  8003. switch (this.char()) {
  8004. // Simple argument: `{name}`
  8005. case 125:
  8006. return this.bump(), {
  8007. val: {
  8008. type: TYPE.argument,
  8009. // value does not include the opening and closing braces.
  8010. value,
  8011. location: createLocation(openingBracePosition, this.clonePosition())
  8012. },
  8013. err: null
  8014. };
  8015. // Argument with options: `{name, format, ...}`
  8016. case 44:
  8017. return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())) : this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
  8018. default:
  8019. return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
  8020. }
  8021. }, Parser2.prototype.parseIdentifierIfPossible = function() {
  8022. var startingPosition = this.clonePosition(), startOffset = this.offset(), value = matchIdentifierAtIndex(this.message, startOffset), endOffset = startOffset + value.length;
  8023. this.bumpTo(endOffset);
  8024. var endPosition = this.clonePosition(), location2 = createLocation(startingPosition, endPosition);
  8025. return { value, location: location2 };
  8026. }, Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
  8027. var _a2, typeStartPosition = this.clonePosition(), argType = this.parseIdentifierIfPossible().value, typeEndPosition = this.clonePosition();
  8028. switch (argType) {
  8029. case "":
  8030. return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
  8031. case "number":
  8032. case "date":
  8033. case "time": {
  8034. this.bumpSpace();
  8035. var styleAndLocation = null;
  8036. if (this.bumpIf(",")) {
  8037. this.bumpSpace();
  8038. var styleStartPosition = this.clonePosition(), result = this.parseSimpleArgStyleIfPossible();
  8039. if (result.err)
  8040. return result;
  8041. var style = trimEnd(result.val);
  8042. if (style.length === 0)
  8043. return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
  8044. var styleLocation = createLocation(styleStartPosition, this.clonePosition());
  8045. styleAndLocation = { style, styleLocation };
  8046. }
  8047. var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
  8048. if (argCloseResult.err)
  8049. return argCloseResult;
  8050. var location_1 = createLocation(openingBracePosition, this.clonePosition());
  8051. if (styleAndLocation && startsWith(styleAndLocation?.style, "::", 0)) {
  8052. var skeleton = trimStart(styleAndLocation.style.slice(2));
  8053. if (argType === "number") {
  8054. var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
  8055. return result.err ? result : {
  8056. val: { type: TYPE.number, value, location: location_1, style: result.val },
  8057. err: null
  8058. };
  8059. } else {
  8060. if (skeleton.length === 0)
  8061. return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
  8062. var dateTimePattern = skeleton;
  8063. this.locale && (dateTimePattern = getBestPattern(skeleton, this.locale));
  8064. var style = {
  8065. type: SKELETON_TYPE.dateTime,
  8066. pattern: dateTimePattern,
  8067. location: styleAndLocation.styleLocation,
  8068. parsedOptions: this.shouldParseSkeletons ? parseDateTimeSkeleton(dateTimePattern) : {}
  8069. }, type = argType === "date" ? TYPE.date : TYPE.time;
  8070. return {
  8071. val: { type, value, location: location_1, style },
  8072. err: null
  8073. };
  8074. }
  8075. }
  8076. return {
  8077. val: {
  8078. type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
  8079. value,
  8080. location: location_1,
  8081. style: (_a2 = styleAndLocation?.style) !== null && _a2 !== void 0 ? _a2 : null
  8082. },
  8083. err: null
  8084. };
  8085. }
  8086. case "plural":
  8087. case "selectordinal":
  8088. case "select": {
  8089. var typeEndPosition_1 = this.clonePosition();
  8090. if (this.bumpSpace(), !this.bumpIf(","))
  8091. return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
  8092. this.bumpSpace();
  8093. var identifierAndLocation = this.parseIdentifierIfPossible(), pluralOffset = 0;
  8094. if (argType !== "select" && identifierAndLocation.value === "offset") {
  8095. if (!this.bumpIf(":"))
  8096. return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
  8097. this.bumpSpace();
  8098. var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
  8099. if (result.err)
  8100. return result;
  8101. this.bumpSpace(), identifierAndLocation = this.parseIdentifierIfPossible(), pluralOffset = result.val;
  8102. }
  8103. var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
  8104. if (optionsResult.err)
  8105. return optionsResult;
  8106. var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
  8107. if (argCloseResult.err)
  8108. return argCloseResult;
  8109. var location_2 = createLocation(openingBracePosition, this.clonePosition());
  8110. return argType === "select" ? {
  8111. val: {
  8112. type: TYPE.select,
  8113. value,
  8114. options: fromEntries(optionsResult.val),
  8115. location: location_2
  8116. },
  8117. err: null
  8118. } : {
  8119. val: {
  8120. type: TYPE.plural,
  8121. value,
  8122. options: fromEntries(optionsResult.val),
  8123. offset: pluralOffset,
  8124. pluralType: argType === "plural" ? "cardinal" : "ordinal",
  8125. location: location_2
  8126. },
  8127. err: null
  8128. };
  8129. }
  8130. default:
  8131. return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
  8132. }
  8133. }, Parser2.prototype.tryParseArgumentClose = function(openingBracePosition) {
  8134. return this.isEOF() || this.char() !== 125 ? this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())) : (this.bump(), { val: !0, err: null });
  8135. }, Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
  8136. for (var nestedBraces = 0, startPosition = this.clonePosition(); !this.isEOF(); ) {
  8137. var ch = this.char();
  8138. switch (ch) {
  8139. case 39: {
  8140. this.bump();
  8141. var apostrophePosition = this.clonePosition();
  8142. if (!this.bumpUntil("'"))
  8143. return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
  8144. this.bump();
  8145. break;
  8146. }
  8147. case 123: {
  8148. nestedBraces += 1, this.bump();
  8149. break;
  8150. }
  8151. case 125: {
  8152. if (nestedBraces > 0)
  8153. nestedBraces -= 1;
  8154. else
  8155. return {
  8156. val: this.message.slice(startPosition.offset, this.offset()),
  8157. err: null
  8158. };
  8159. break;
  8160. }
  8161. default:
  8162. this.bump();
  8163. break;
  8164. }
  8165. }
  8166. return {
  8167. val: this.message.slice(startPosition.offset, this.offset()),
  8168. err: null
  8169. };
  8170. }, Parser2.prototype.parseNumberSkeletonFromString = function(skeleton, location2) {
  8171. var tokens2 = [];
  8172. try {
  8173. tokens2 = parseNumberSkeletonFromString(skeleton);
  8174. } catch {
  8175. return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location2);
  8176. }
  8177. return {
  8178. val: {
  8179. type: SKELETON_TYPE.number,
  8180. tokens: tokens2,
  8181. location: location2,
  8182. parsedOptions: this.shouldParseSkeletons ? parseNumberSkeleton(tokens2) : {}
  8183. },
  8184. err: null
  8185. };
  8186. }, Parser2.prototype.tryParsePluralOrSelectOptions = function(nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
  8187. for (var _a2, hasOtherClause = !1, options2 = [], parsedSelectors = /* @__PURE__ */ new Set(), selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location; ; ) {
  8188. if (selector.length === 0) {
  8189. var startPosition = this.clonePosition();
  8190. if (parentArgType !== "select" && this.bumpIf("=")) {
  8191. var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
  8192. if (result.err)
  8193. return result;
  8194. selectorLocation = createLocation(startPosition, this.clonePosition()), selector = this.message.slice(startPosition.offset, this.offset());
  8195. } else
  8196. break;
  8197. }
  8198. if (parsedSelectors.has(selector))
  8199. return this.error(parentArgType === "select" ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
  8200. selector === "other" && (hasOtherClause = !0), this.bumpSpace();
  8201. var openingBracePosition = this.clonePosition();
  8202. if (!this.bumpIf("{"))
  8203. return this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
  8204. var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
  8205. if (fragmentResult.err)
  8206. return fragmentResult;
  8207. var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
  8208. if (argCloseResult.err)
  8209. return argCloseResult;
  8210. options2.push([
  8211. selector,
  8212. {
  8213. value: fragmentResult.val,
  8214. location: createLocation(openingBracePosition, this.clonePosition())
  8215. }
  8216. ]), parsedSelectors.add(selector), this.bumpSpace(), _a2 = this.parseIdentifierIfPossible(), selector = _a2.value, selectorLocation = _a2.location;
  8217. }
  8218. 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 };
  8219. }, Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
  8220. var sign = 1, startingPosition = this.clonePosition();
  8221. this.bumpIf("+") || this.bumpIf("-") && (sign = -1);
  8222. for (var hasDigits = !1, decimal = 0; !this.isEOF(); ) {
  8223. var ch = this.char();
  8224. if (ch >= 48 && ch <= 57)
  8225. hasDigits = !0, decimal = decimal * 10 + (ch - 48), this.bump();
  8226. else
  8227. break;
  8228. }
  8229. var location2 = createLocation(startingPosition, this.clonePosition());
  8230. return hasDigits ? (decimal *= sign, isSafeInteger(decimal) ? { val: decimal, err: null } : this.error(invalidNumberError, location2)) : this.error(expectNumberError, location2);
  8231. }, Parser2.prototype.offset = function() {
  8232. return this.position.offset;
  8233. }, Parser2.prototype.isEOF = function() {
  8234. return this.offset() === this.message.length;
  8235. }, Parser2.prototype.clonePosition = function() {
  8236. return {
  8237. offset: this.position.offset,
  8238. line: this.position.line,
  8239. column: this.position.column
  8240. };
  8241. }, Parser2.prototype.char = function() {
  8242. var offset2 = this.position.offset;
  8243. if (offset2 >= this.message.length)
  8244. throw Error("out of bound");
  8245. var code = codePointAt(this.message, offset2);
  8246. if (code === void 0)
  8247. throw Error("Offset ".concat(offset2, " is at invalid UTF-16 code unit boundary"));
  8248. return code;
  8249. }, Parser2.prototype.error = function(kind, location2) {
  8250. return {
  8251. val: null,
  8252. err: {
  8253. kind,
  8254. message: this.message,
  8255. location: location2
  8256. }
  8257. };
  8258. }, Parser2.prototype.bump = function() {
  8259. if (!this.isEOF()) {
  8260. var code = this.char();
  8261. 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);
  8262. }
  8263. }, Parser2.prototype.bumpIf = function(prefix) {
  8264. if (startsWith(this.message, prefix, this.offset())) {
  8265. for (var i2 = 0; i2 < prefix.length; i2++)
  8266. this.bump();
  8267. return !0;
  8268. }
  8269. return !1;
  8270. }, Parser2.prototype.bumpUntil = function(pattern) {
  8271. var currentOffset = this.offset(), index = this.message.indexOf(pattern, currentOffset);
  8272. return index >= 0 ? (this.bumpTo(index), !0) : (this.bumpTo(this.message.length), !1);
  8273. }, Parser2.prototype.bumpTo = function(targetOffset) {
  8274. if (this.offset() > targetOffset)
  8275. throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
  8276. for (targetOffset = Math.min(targetOffset, this.message.length); ; ) {
  8277. var offset2 = this.offset();
  8278. if (offset2 === targetOffset)
  8279. break;
  8280. if (offset2 > targetOffset)
  8281. throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
  8282. if (this.bump(), this.isEOF())
  8283. break;
  8284. }
  8285. }, Parser2.prototype.bumpSpace = function() {
  8286. for (; !this.isEOF() && _isWhiteSpace(this.char()); )
  8287. this.bump();
  8288. }, Parser2.prototype.peek = function() {
  8289. if (this.isEOF())
  8290. return null;
  8291. var code = this.char(), offset2 = this.offset(), nextCode = this.message.charCodeAt(offset2 + (code >= 65536 ? 2 : 1));
  8292. return nextCode ?? null;
  8293. }, Parser2;
  8294. })()
  8295. );
  8296. function _isAlpha(codepoint) {
  8297. return codepoint >= 97 && codepoint <= 122 || codepoint >= 65 && codepoint <= 90;
  8298. }
  8299. function _isAlphaOrSlash(codepoint) {
  8300. return _isAlpha(codepoint) || codepoint === 47;
  8301. }
  8302. function _isPotentialElementNameChar(c2) {
  8303. 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;
  8304. }
  8305. function _isWhiteSpace(c2) {
  8306. return c2 >= 9 && c2 <= 13 || c2 === 32 || c2 === 133 || c2 >= 8206 && c2 <= 8207 || c2 === 8232 || c2 === 8233;
  8307. }
  8308. function _isPatternSyntax(c2) {
  8309. 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;
  8310. }
  8311. // ../../node_modules/@formatjs/icu-messageformat-parser/lib/index.js
  8312. function pruneLocation(els) {
  8313. els.forEach(function(el) {
  8314. if (delete el.location, isSelectElement(el) || isPluralElement(el))
  8315. for (var k2 in el.options)
  8316. delete el.options[k2].location, pruneLocation(el.options[k2].value);
  8317. else isNumberElement(el) && isNumberSkeleton(el.style) || (isDateElement(el) || isTimeElement(el)) && isDateTimeSkeleton(el.style) ? delete el.style.location : isTagElement(el) && pruneLocation(el.children);
  8318. });
  8319. }
  8320. function parse(message, opts) {
  8321. opts === void 0 && (opts = {}), opts = __assign({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, opts);
  8322. var result = new Parser(message, opts).parse();
  8323. if (result.err) {
  8324. var error = SyntaxError(ErrorKind[result.err.kind]);
  8325. throw error.location = result.err.location, error.originalMessage = result.err.message, error;
  8326. }
  8327. return opts?.captureLocation || pruneLocation(result.val), result.val;
  8328. }
  8329. // ../../node_modules/intl-messageformat/lib/src/error.js
  8330. var ErrorCode;
  8331. (function(ErrorCode2) {
  8332. ErrorCode2.MISSING_VALUE = "MISSING_VALUE", ErrorCode2.INVALID_VALUE = "INVALID_VALUE", ErrorCode2.MISSING_INTL_API = "MISSING_INTL_API";
  8333. })(ErrorCode || (ErrorCode = {}));
  8334. var FormatError = (
  8335. /** @class */
  8336. (function(_super) {
  8337. __extends(FormatError2, _super);
  8338. function FormatError2(msg, code, originalMessage) {
  8339. var _this = _super.call(this, msg) || this;
  8340. return _this.code = code, _this.originalMessage = originalMessage, _this;
  8341. }
  8342. return FormatError2.prototype.toString = function() {
  8343. return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
  8344. }, FormatError2;
  8345. })(Error)
  8346. );
  8347. var InvalidValueError = (
  8348. /** @class */
  8349. (function(_super) {
  8350. __extends(InvalidValueError2, _super);
  8351. function InvalidValueError2(variableId, value, options2, originalMessage) {
  8352. return _super.call(this, 'Invalid values for "'.concat(variableId, '": "').concat(value, '". Options are "').concat(Object.keys(options2).join('", "'), '"'), ErrorCode.INVALID_VALUE, originalMessage) || this;
  8353. }
  8354. return InvalidValueError2;
  8355. })(FormatError)
  8356. );
  8357. var InvalidValueTypeError = (
  8358. /** @class */
  8359. (function(_super) {
  8360. __extends(InvalidValueTypeError2, _super);
  8361. function InvalidValueTypeError2(value, type, originalMessage) {
  8362. return _super.call(this, 'Value for "'.concat(value, '" must be of type ').concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
  8363. }
  8364. return InvalidValueTypeError2;
  8365. })(FormatError)
  8366. );
  8367. var MissingValueError = (
  8368. /** @class */
  8369. (function(_super) {
  8370. __extends(MissingValueError2, _super);
  8371. function MissingValueError2(variableId, originalMessage) {
  8372. return _super.call(this, 'The intl string context variable "'.concat(variableId, '" was not provided to the string "').concat(originalMessage, '"'), ErrorCode.MISSING_VALUE, originalMessage) || this;
  8373. }
  8374. return MissingValueError2;
  8375. })(FormatError)
  8376. );
  8377. // ../../node_modules/intl-messageformat/lib/src/formatters.js
  8378. var PART_TYPE;
  8379. (function(PART_TYPE2) {
  8380. PART_TYPE2[PART_TYPE2.literal = 0] = "literal", PART_TYPE2[PART_TYPE2.object = 1] = "object";
  8381. })(PART_TYPE || (PART_TYPE = {}));
  8382. function mergeLiteral(parts) {
  8383. return parts.length < 2 ? parts : parts.reduce(function(all, part) {
  8384. var lastPart = all[all.length - 1];
  8385. return !lastPart || lastPart.type !== PART_TYPE.literal || part.type !== PART_TYPE.literal ? all.push(part) : lastPart.value += part.value, all;
  8386. }, []);
  8387. }
  8388. function isFormatXMLElementFn(el) {
  8389. return typeof el == "function";
  8390. }
  8391. function formatToParts(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
  8392. if (els.length === 1 && isLiteralElement(els[0]))
  8393. return [
  8394. {
  8395. type: PART_TYPE.literal,
  8396. value: els[0].value
  8397. }
  8398. ];
  8399. for (var result = [], _i = 0, els_1 = els; _i < els_1.length; _i++) {
  8400. var el = els_1[_i];
  8401. if (isLiteralElement(el)) {
  8402. result.push({
  8403. type: PART_TYPE.literal,
  8404. value: el.value
  8405. });
  8406. continue;
  8407. }
  8408. if (isPoundElement(el)) {
  8409. typeof currentPluralValue == "number" && result.push({
  8410. type: PART_TYPE.literal,
  8411. value: formatters.getNumberFormat(locales).format(currentPluralValue)
  8412. });
  8413. continue;
  8414. }
  8415. var varName = el.value;
  8416. if (!(values && varName in values))
  8417. throw new MissingValueError(varName, originalMessage);
  8418. var value = values[varName];
  8419. if (isArgumentElement(el)) {
  8420. (!value || typeof value == "string" || typeof value == "number") && (value = typeof value == "string" || typeof value == "number" ? String(value) : ""), result.push({
  8421. type: typeof value == "string" ? PART_TYPE.literal : PART_TYPE.object,
  8422. value
  8423. });
  8424. continue;
  8425. }
  8426. if (isDateElement(el)) {
  8427. var style = typeof el.style == "string" ? formats.date[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
  8428. result.push({
  8429. type: PART_TYPE.literal,
  8430. value: formatters.getDateTimeFormat(locales, style).format(value)
  8431. });
  8432. continue;
  8433. }
  8434. if (isTimeElement(el)) {
  8435. var style = typeof el.style == "string" ? formats.time[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : formats.time.medium;
  8436. result.push({
  8437. type: PART_TYPE.literal,
  8438. value: formatters.getDateTimeFormat(locales, style).format(value)
  8439. });
  8440. continue;
  8441. }
  8442. if (isNumberElement(el)) {
  8443. var style = typeof el.style == "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
  8444. style && style.scale && (value = value * (style.scale || 1)), result.push({
  8445. type: PART_TYPE.literal,
  8446. value: formatters.getNumberFormat(locales, style).format(value)
  8447. });
  8448. continue;
  8449. }
  8450. if (isTagElement(el)) {
  8451. var children = el.children, value_1 = el.value, formatFn = values[value_1];
  8452. if (!isFormatXMLElementFn(formatFn))
  8453. throw new InvalidValueTypeError(value_1, "function", originalMessage);
  8454. var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue), chunks = formatFn(parts.map(function(p2) {
  8455. return p2.value;
  8456. }));
  8457. Array.isArray(chunks) || (chunks = [chunks]), result.push.apply(result, chunks.map(function(c2) {
  8458. return {
  8459. type: typeof c2 == "string" ? PART_TYPE.literal : PART_TYPE.object,
  8460. value: c2
  8461. };
  8462. }));
  8463. }
  8464. if (isSelectElement(el)) {
  8465. var opt = el.options[value] || el.options.other;
  8466. if (!opt)
  8467. throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
  8468. result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
  8469. continue;
  8470. }
  8471. if (isPluralElement(el)) {
  8472. var opt = el.options["=".concat(value)];
  8473. if (!opt) {
  8474. if (!Intl.PluralRules)
  8475. throw new FormatError(`Intl.PluralRules is not available in this environment.
  8476. Try polyfilling it using "@formatjs/intl-pluralrules"
  8477. `, ErrorCode.MISSING_INTL_API, originalMessage);
  8478. var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
  8479. opt = el.options[rule] || el.options.other;
  8480. }
  8481. if (!opt)
  8482. throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
  8483. result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
  8484. continue;
  8485. }
  8486. }
  8487. return mergeLiteral(result);
  8488. }
  8489. // ../../node_modules/intl-messageformat/lib/src/core.js
  8490. function mergeConfig(c1, c2) {
  8491. return c2 ? __assign(__assign(__assign({}, c1 || {}), c2 || {}), Object.keys(c1).reduce(function(all, k2) {
  8492. return all[k2] = __assign(__assign({}, c1[k2]), c2[k2] || {}), all;
  8493. }, {})) : c1;
  8494. }
  8495. function mergeConfigs(defaultConfig, configs) {
  8496. return configs ? Object.keys(defaultConfig).reduce(function(all, k2) {
  8497. return all[k2] = mergeConfig(defaultConfig[k2], configs[k2]), all;
  8498. }, __assign({}, defaultConfig)) : defaultConfig;
  8499. }
  8500. function createFastMemoizeCache(store2) {
  8501. return {
  8502. create: function() {
  8503. return {
  8504. get: function(key) {
  8505. return store2[key];
  8506. },
  8507. set: function(key, value) {
  8508. store2[key] = value;
  8509. }
  8510. };
  8511. }
  8512. };
  8513. }
  8514. function createDefaultFormatters(cache) {
  8515. return cache === void 0 && (cache = {
  8516. number: {},
  8517. dateTime: {},
  8518. pluralRules: {}
  8519. }), {
  8520. getNumberFormat: memoize(function() {
  8521. for (var _a2, args = [], _i = 0; _i < arguments.length; _i++)
  8522. args[_i] = arguments[_i];
  8523. return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args, !1)))();
  8524. }, {
  8525. cache: createFastMemoizeCache(cache.number),
  8526. strategy: strategies.variadic
  8527. }),
  8528. getDateTimeFormat: memoize(function() {
  8529. for (var _a2, args = [], _i = 0; _i < arguments.length; _i++)
  8530. args[_i] = arguments[_i];
  8531. return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args, !1)))();
  8532. }, {
  8533. cache: createFastMemoizeCache(cache.dateTime),
  8534. strategy: strategies.variadic
  8535. }),
  8536. getPluralRules: memoize(function() {
  8537. for (var _a2, args = [], _i = 0; _i < arguments.length; _i++)
  8538. args[_i] = arguments[_i];
  8539. return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args, !1)))();
  8540. }, {
  8541. cache: createFastMemoizeCache(cache.pluralRules),
  8542. strategy: strategies.variadic
  8543. })
  8544. };
  8545. }
  8546. var IntlMessageFormat = (
  8547. /** @class */
  8548. (function() {
  8549. function IntlMessageFormat2(message, locales, overrideFormats, opts) {
  8550. locales === void 0 && (locales = IntlMessageFormat2.defaultLocale);
  8551. var _this = this;
  8552. if (this.formatterCache = {
  8553. number: {},
  8554. dateTime: {},
  8555. pluralRules: {}
  8556. }, this.format = function(values) {
  8557. var parts = _this.formatToParts(values);
  8558. if (parts.length === 1)
  8559. return parts[0].value;
  8560. var result = parts.reduce(function(all, part) {
  8561. 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;
  8562. }, []);
  8563. return result.length <= 1 ? result[0] || "" : result;
  8564. }, this.formatToParts = function(values) {
  8565. return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, void 0, _this.message);
  8566. }, this.resolvedOptions = function() {
  8567. var _a3;
  8568. return {
  8569. locale: ((_a3 = _this.resolvedLocale) === null || _a3 === void 0 ? void 0 : _a3.toString()) || Intl.NumberFormat.supportedLocalesOf(_this.locales)[0]
  8570. };
  8571. }, this.getAst = function() {
  8572. return _this.ast;
  8573. }, this.locales = locales, this.resolvedLocale = IntlMessageFormat2.resolveLocale(locales), typeof message == "string") {
  8574. if (this.message = message, !IntlMessageFormat2.__parse)
  8575. throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
  8576. var _a2 = opts || {}, formatters = _a2.formatters, parseOpts = __rest(_a2, ["formatters"]);
  8577. this.ast = IntlMessageFormat2.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));
  8578. } else
  8579. this.ast = message;
  8580. if (!Array.isArray(this.ast))
  8581. throw new TypeError("A message must be provided as a String or AST.");
  8582. this.formats = mergeConfigs(IntlMessageFormat2.formats, overrideFormats), this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
  8583. }
  8584. return Object.defineProperty(IntlMessageFormat2, "defaultLocale", {
  8585. get: function() {
  8586. return IntlMessageFormat2.memoizedDefaultLocale || (IntlMessageFormat2.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), IntlMessageFormat2.memoizedDefaultLocale;
  8587. },
  8588. enumerable: !1,
  8589. configurable: !0
  8590. }), IntlMessageFormat2.memoizedDefaultLocale = null, IntlMessageFormat2.resolveLocale = function(locales) {
  8591. if (!(typeof Intl.Locale > "u")) {
  8592. var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
  8593. return supportedLocales.length > 0 ? new Intl.Locale(supportedLocales[0]) : new Intl.Locale(typeof locales == "string" ? locales : locales[0]);
  8594. }
  8595. }, IntlMessageFormat2.__parse = parse, IntlMessageFormat2.formats = {
  8596. number: {
  8597. integer: {
  8598. maximumFractionDigits: 0
  8599. },
  8600. currency: {
  8601. style: "currency"
  8602. },
  8603. percent: {
  8604. style: "percent"
  8605. }
  8606. },
  8607. date: {
  8608. short: {
  8609. month: "numeric",
  8610. day: "numeric",
  8611. year: "2-digit"
  8612. },
  8613. medium: {
  8614. month: "short",
  8615. day: "numeric",
  8616. year: "numeric"
  8617. },
  8618. long: {
  8619. month: "long",
  8620. day: "numeric",
  8621. year: "numeric"
  8622. },
  8623. full: {
  8624. weekday: "long",
  8625. month: "long",
  8626. day: "numeric",
  8627. year: "numeric"
  8628. }
  8629. },
  8630. time: {
  8631. short: {
  8632. hour: "numeric",
  8633. minute: "numeric"
  8634. },
  8635. medium: {
  8636. hour: "numeric",
  8637. minute: "numeric",
  8638. second: "numeric"
  8639. },
  8640. long: {
  8641. hour: "numeric",
  8642. minute: "numeric",
  8643. second: "numeric",
  8644. timeZoneName: "short"
  8645. },
  8646. full: {
  8647. hour: "numeric",
  8648. minute: "numeric",
  8649. second: "numeric",
  8650. timeZoneName: "short"
  8651. }
  8652. }
  8653. }, IntlMessageFormat2;
  8654. })()
  8655. );
  8656. // ../../node_modules/@react-aria/i18n/dist/useMessageFormatter.mjs
  8657. init_react();
  8658. // ../../node_modules/@react-aria/i18n/dist/useLocalizedStringFormatter.mjs
  8659. init_react();
  8660. // ../../node_modules/@react-aria/i18n/dist/useListFormatter.mjs
  8661. init_react();
  8662. // ../../node_modules/@internationalized/date/dist/string.mjs
  8663. var $fae977aafc393c5c$var$requiredDurationTimeGroups = [
  8664. "hours",
  8665. "minutes",
  8666. "seconds"
  8667. ], $fae977aafc393c5c$var$requiredDurationGroups = [
  8668. "years",
  8669. "months",
  8670. "weeks",
  8671. "days",
  8672. ...$fae977aafc393c5c$var$requiredDurationTimeGroups
  8673. ];
  8674. // ../../node_modules/@internationalized/date/dist/HebrewCalendar.mjs
  8675. 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;
  8676. // ../../node_modules/@react-aria/i18n/dist/useDateFormatter.mjs
  8677. init_react();
  8678. // ../../node_modules/@internationalized/number/dist/NumberFormatter.mjs
  8679. var $488c6ddbf4ef74c2$var$supportsSignDisplay = !1;
  8680. try {
  8681. $488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat("de-DE", {
  8682. signDisplay: "exceptZero"
  8683. }).resolvedOptions().signDisplay === "exceptZero";
  8684. } catch {
  8685. }
  8686. var $488c6ddbf4ef74c2$var$supportsUnit = !1;
  8687. try {
  8688. $488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat("de-DE", {
  8689. style: "unit",
  8690. unit: "degree"
  8691. }).resolvedOptions().style === "unit";
  8692. } catch {
  8693. }
  8694. // ../../node_modules/@internationalized/number/dist/NumberParser.mjs
  8695. var $6c7bd7858deea686$var$CURRENCY_SIGN_REGEX = new RegExp("^.*\\(.*\\).*$");
  8696. // ../../node_modules/@react-aria/i18n/dist/useNumberFormatter.mjs
  8697. init_react();
  8698. // ../../node_modules/@react-aria/i18n/dist/useFilter.mjs
  8699. init_react();
  8700. // ../../node_modules/@react-aria/overlays/dist/useOverlayPosition.mjs
  8701. var $2a41e45df1593e64$var$visualViewport = typeof document < "u" ? window.visualViewport : null;
  8702. function $2a41e45df1593e64$export$d39e1813b3bdd0e1(props) {
  8703. 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 = [
  8704. shouldUpdatePosition,
  8705. placement,
  8706. overlayRef.current,
  8707. targetRef.current,
  8708. arrowRef?.current,
  8709. scrollRef.current,
  8710. containerPadding,
  8711. shouldFlip,
  8712. boundaryElement,
  8713. offset2,
  8714. crossOffset,
  8715. isOpen,
  8716. direction,
  8717. maxHeight,
  8718. arrowBoundaryOffset,
  8719. arrowSize
  8720. ], lastScale = useRef($2a41e45df1593e64$var$visualViewport?.scale);
  8721. useEffect(() => {
  8722. isOpen && (lastScale.current = $2a41e45df1593e64$var$visualViewport?.scale);
  8723. }, [
  8724. isOpen
  8725. ]);
  8726. let updatePosition = useCallback(() => {
  8727. if (shouldUpdatePosition === !1 || !isOpen || !overlayRef.current || !targetRef.current || !boundaryElement || $2a41e45df1593e64$var$visualViewport?.scale !== lastScale.current) return;
  8728. let anchor = null;
  8729. if (scrollRef.current && scrollRef.current.contains(document.activeElement)) {
  8730. var _document_activeElement;
  8731. let anchorRect = (_document_activeElement = document.activeElement) === null || _document_activeElement === void 0 ? void 0 : _document_activeElement.getBoundingClientRect(), scrollRect = scrollRef.current.getBoundingClientRect();
  8732. var _anchorRect_top;
  8733. if (anchor = {
  8734. type: "top",
  8735. offset: ((_anchorRect_top = anchorRect?.top) !== null && _anchorRect_top !== void 0 ? _anchorRect_top : 0) - scrollRect.top
  8736. }, anchor.offset > scrollRect.height / 2) {
  8737. anchor.type = "bottom";
  8738. var _anchorRect_bottom;
  8739. anchor.offset = ((_anchorRect_bottom = anchorRect?.bottom) !== null && _anchorRect_bottom !== void 0 ? _anchorRect_bottom : 0) - scrollRect.bottom;
  8740. }
  8741. }
  8742. let overlay = overlayRef.current;
  8743. if (!maxHeight && overlayRef.current) {
  8744. var _window_visualViewport;
  8745. overlay.style.top = "0px", overlay.style.bottom = "";
  8746. var _window_visualViewport_height;
  8747. 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";
  8748. }
  8749. let position2 = $edcf132a9284368a$export$b3ceb0cbf1056d98({
  8750. placement: $2a41e45df1593e64$var$translateRTL(placement, direction),
  8751. overlayNode: overlayRef.current,
  8752. targetNode: targetRef.current,
  8753. scrollNode: scrollRef.current || overlayRef.current,
  8754. padding: containerPadding,
  8755. shouldFlip,
  8756. boundaryElement,
  8757. offset: offset2,
  8758. crossOffset,
  8759. maxHeight,
  8760. arrowSize: arrowSize ?? (arrowRef?.current ? $edcf132a9284368a$export$4b834cebd9e5cebe(arrowRef.current, !0).width : 0),
  8761. arrowBoundaryOffset
  8762. });
  8763. if (position2.position) {
  8764. 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) {
  8765. let anchorRect = document.activeElement.getBoundingClientRect(), scrollRect = scrollRef.current.getBoundingClientRect(), newOffset = anchorRect[anchor.type] - scrollRect[anchor.type];
  8766. scrollRef.current.scrollTop += newOffset - anchor.offset;
  8767. }
  8768. setPosition(position2);
  8769. }
  8770. }, deps);
  8771. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(updatePosition, deps), $2a41e45df1593e64$var$useResize(updatePosition), $9daab02d461809db$export$683480f191c0e3ea({
  8772. ref: overlayRef,
  8773. onResize: updatePosition
  8774. }), $9daab02d461809db$export$683480f191c0e3ea({
  8775. ref: targetRef,
  8776. onResize: updatePosition
  8777. });
  8778. let isResizing = useRef(!1);
  8779. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
  8780. let timeout, onResize = () => {
  8781. isResizing.current = !0, clearTimeout(timeout), timeout = setTimeout(() => {
  8782. isResizing.current = !1;
  8783. }, 500), updatePosition();
  8784. }, onScroll = () => {
  8785. isResizing.current && onResize();
  8786. };
  8787. return $2a41e45df1593e64$var$visualViewport?.addEventListener("resize", onResize), $2a41e45df1593e64$var$visualViewport?.addEventListener("scroll", onScroll), () => {
  8788. $2a41e45df1593e64$var$visualViewport?.removeEventListener("resize", onResize), $2a41e45df1593e64$var$visualViewport?.removeEventListener("scroll", onScroll);
  8789. };
  8790. }, [
  8791. updatePosition
  8792. ]);
  8793. let close = useCallback(() => {
  8794. isResizing.current || onClose?.();
  8795. }, [
  8796. onClose,
  8797. isResizing
  8798. ]);
  8799. $dd149f63282afbbf$export$18fc8428861184da({
  8800. triggerRef: targetRef,
  8801. isOpen,
  8802. onClose: onClose && close
  8803. });
  8804. var _position_maxHeight, _position_placement, _position_triggerAnchorPoint;
  8805. return {
  8806. overlayProps: {
  8807. style: {
  8808. position: position ? "absolute" : "fixed",
  8809. top: position ? void 0 : 0,
  8810. left: position ? void 0 : 0,
  8811. zIndex: 1e5,
  8812. ...position?.position,
  8813. maxHeight: (_position_maxHeight = position?.maxHeight) !== null && _position_maxHeight !== void 0 ? _position_maxHeight : "100vh"
  8814. }
  8815. },
  8816. placement: (_position_placement = position?.placement) !== null && _position_placement !== void 0 ? _position_placement : null,
  8817. triggerAnchorPoint: (_position_triggerAnchorPoint = position?.triggerAnchorPoint) !== null && _position_triggerAnchorPoint !== void 0 ? _position_triggerAnchorPoint : null,
  8818. arrowProps: {
  8819. "aria-hidden": "true",
  8820. role: "presentation",
  8821. style: {
  8822. left: position?.arrowOffsetLeft,
  8823. top: position?.arrowOffsetTop
  8824. }
  8825. },
  8826. updatePosition
  8827. };
  8828. }
  8829. function $2a41e45df1593e64$var$useResize(onResize) {
  8830. $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => (window.addEventListener("resize", onResize, !1), () => {
  8831. window.removeEventListener("resize", onResize, !1);
  8832. }), [
  8833. onResize
  8834. ]);
  8835. }
  8836. function $2a41e45df1593e64$var$translateRTL(position, direction) {
  8837. return direction === "rtl" ? position.replace("start", "right").replace("end", "left") : position.replace("start", "left").replace("end", "right");
  8838. }
  8839. // ../../node_modules/@react-aria/focus/dist/FocusScope.mjs
  8840. init_react();
  8841. var $9bf71ea28793e738$var$FocusContext = react_default.createContext(null);
  8842. function $9bf71ea28793e738$var$isElementInScope(element, scope2) {
  8843. return !element || !scope2 ? !1 : scope2.some((node) => node.contains(element));
  8844. }
  8845. var $9bf71ea28793e738$var$Tree = class _$9bf71ea28793e738$var$Tree {
  8846. get size() {
  8847. return this.fastMap.size;
  8848. }
  8849. getTreeNode(data) {
  8850. return this.fastMap.get(data);
  8851. }
  8852. addTreeNode(scopeRef, parent, nodeToRestore) {
  8853. let parentNode = this.fastMap.get(parent ?? null);
  8854. if (!parentNode) return;
  8855. let node = new $9bf71ea28793e738$var$TreeNode({
  8856. scopeRef
  8857. });
  8858. parentNode.addChild(node), node.parent = parentNode, this.fastMap.set(scopeRef, node), nodeToRestore && (node.nodeToRestore = nodeToRestore);
  8859. }
  8860. addNode(node) {
  8861. this.fastMap.set(node.scopeRef, node);
  8862. }
  8863. removeTreeNode(scopeRef) {
  8864. if (scopeRef === null) return;
  8865. let node = this.fastMap.get(scopeRef);
  8866. if (!node) return;
  8867. let parentNode = node.parent;
  8868. 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);
  8869. let children = node.children;
  8870. parentNode && (parentNode.removeChild(node), children.size > 0 && children.forEach((child) => parentNode && parentNode.addChild(child))), this.fastMap.delete(node.scopeRef);
  8871. }
  8872. // Pre Order Depth First
  8873. *traverse(node = this.root) {
  8874. if (node.scopeRef != null && (yield node), node.children.size > 0) for (let child of node.children) yield* this.traverse(child);
  8875. }
  8876. clone() {
  8877. var _node_parent;
  8878. let newTree = new _$9bf71ea28793e738$var$Tree();
  8879. var _node_parent_scopeRef;
  8880. 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);
  8881. return newTree;
  8882. }
  8883. constructor() {
  8884. this.fastMap = /* @__PURE__ */ new Map(), this.root = new $9bf71ea28793e738$var$TreeNode({
  8885. scopeRef: null
  8886. }), this.fastMap.set(null, this.root);
  8887. }
  8888. }, $9bf71ea28793e738$var$TreeNode = class {
  8889. addChild(node) {
  8890. this.children.add(node), node.parent = this;
  8891. }
  8892. removeChild(node) {
  8893. this.children.delete(node), node.parent = void 0;
  8894. }
  8895. constructor(props) {
  8896. this.children = /* @__PURE__ */ new Set(), this.contain = !1, this.scopeRef = props.scopeRef;
  8897. }
  8898. }, $9bf71ea28793e738$export$d06fae2ee68b101e = new $9bf71ea28793e738$var$Tree();
  8899. // ../../node_modules/@react-aria/focus/dist/useFocusRing.mjs
  8900. init_react();
  8901. // ../../node_modules/@react-aria/focus/dist/FocusRing.mjs
  8902. init_react();
  8903. // ../../node_modules/@react-aria/focus/dist/useHasTabbableChild.mjs
  8904. init_react();
  8905. // ../../node_modules/@react-aria/overlays/dist/useOverlay.mjs
  8906. init_react();
  8907. // ../../node_modules/@react-aria/overlays/dist/useOverlayTrigger.mjs
  8908. init_react();
  8909. // ../../node_modules/@react-aria/overlays/dist/usePreventScroll.mjs
  8910. var $49c51c25361d4cd2$var$visualViewport = typeof document < "u" && window.visualViewport;
  8911. // ../../node_modules/@react-aria/overlays/dist/PortalProvider.mjs
  8912. init_react();
  8913. var $96b38030c423d352$export$60d741e20e0aa309 = createContext({});
  8914. function $96b38030c423d352$export$9fc1347d4195ccb3() {
  8915. var _useContext;
  8916. return (_useContext = useContext($96b38030c423d352$export$60d741e20e0aa309)) !== null && _useContext !== void 0 ? _useContext : {};
  8917. }
  8918. // ../../node_modules/@react-aria/overlays/dist/useModal.mjs
  8919. init_react();
  8920. var $f57aed4a881a3485$var$Context = react_default.createContext(null);
  8921. function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
  8922. let { children } = props, parent = useContext($f57aed4a881a3485$var$Context), [modalCount, setModalCount] = useState(0), context = useMemo(() => ({
  8923. parent,
  8924. modalCount,
  8925. addModal() {
  8926. setModalCount((count) => count + 1), parent && parent.addModal();
  8927. },
  8928. removeModal() {
  8929. setModalCount((count) => count - 1), parent && parent.removeModal();
  8930. }
  8931. }), [
  8932. parent,
  8933. modalCount
  8934. ]);
  8935. return react_default.createElement($f57aed4a881a3485$var$Context.Provider, {
  8936. value: context
  8937. }, children);
  8938. }
  8939. function $f57aed4a881a3485$export$d9aaed4c3ece1bc0() {
  8940. let context = useContext($f57aed4a881a3485$var$Context);
  8941. return {
  8942. modalProviderProps: {
  8943. "aria-hidden": context && context.modalCount > 0 ? !0 : void 0
  8944. }
  8945. };
  8946. }
  8947. function $f57aed4a881a3485$var$OverlayContainerDOM(props) {
  8948. let { modalProviderProps } = $f57aed4a881a3485$export$d9aaed4c3ece1bc0();
  8949. return react_default.createElement("div", {
  8950. "data-overlay-container": !0,
  8951. ...props,
  8952. ...modalProviderProps
  8953. });
  8954. }
  8955. function $f57aed4a881a3485$export$bf688221f59024e5(props) {
  8956. return react_default.createElement($f57aed4a881a3485$export$178405afcd8c5eb, null, react_default.createElement($f57aed4a881a3485$var$OverlayContainerDOM, props));
  8957. }
  8958. function $f57aed4a881a3485$export$b47c3594eab58386(props) {
  8959. let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273(), { portalContainer = isSSR ? null : document.body, ...rest2 } = props, { getContainer } = $96b38030c423d352$export$9fc1347d4195ccb3();
  8960. if (!props.portalContainer && getContainer && (portalContainer = getContainer()), react_default.useEffect(() => {
  8961. if (portalContainer?.closest("[data-overlay-container]")) throw new Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.");
  8962. }, [
  8963. portalContainer
  8964. ]), !portalContainer) return null;
  8965. let contents = react_default.createElement($f57aed4a881a3485$export$bf688221f59024e5, rest2);
  8966. return react_dom_default.createPortal(contents, portalContainer);
  8967. }
  8968. // ../../node_modules/@react-aria/overlays/dist/ar-AE.mjs
  8969. var $773d5888b972f1cf$exports = {};
  8970. $773d5888b972f1cf$exports = {
  8971. dismiss: "\u062A\u062C\u0627\u0647\u0644"
  8972. };
  8973. // ../../node_modules/@react-aria/overlays/dist/bg-BG.mjs
  8974. var $d11f19852b941573$exports = {};
  8975. $d11f19852b941573$exports = {
  8976. dismiss: "\u041E\u0442\u0445\u0432\u044A\u0440\u043B\u044F\u043D\u0435"
  8977. };
  8978. // ../../node_modules/@react-aria/overlays/dist/cs-CZ.mjs
  8979. var $b983974c2ee1efb3$exports = {};
  8980. $b983974c2ee1efb3$exports = {
  8981. dismiss: "Odstranit"
  8982. };
  8983. // ../../node_modules/@react-aria/overlays/dist/da-DK.mjs
  8984. var $5809cc9d4e92de73$exports = {};
  8985. $5809cc9d4e92de73$exports = {
  8986. dismiss: "Luk"
  8987. };
  8988. // ../../node_modules/@react-aria/overlays/dist/de-DE.mjs
  8989. var $c68c2e4fc74398d1$exports = {};
  8990. $c68c2e4fc74398d1$exports = {
  8991. dismiss: "Schlie\xDFen"
  8992. };
  8993. // ../../node_modules/@react-aria/overlays/dist/el-GR.mjs
  8994. var $0898b4c153db2b77$exports = {};
  8995. $0898b4c153db2b77$exports = {
  8996. dismiss: "\u0391\u03C0\u03CC\u03C1\u03C1\u03B9\u03C8\u03B7"
  8997. };
  8998. // ../../node_modules/@react-aria/overlays/dist/en-US.mjs
  8999. var $6d74810286a15183$exports = {};
  9000. $6d74810286a15183$exports = {
  9001. dismiss: "Dismiss"
  9002. };
  9003. // ../../node_modules/@react-aria/overlays/dist/es-ES.mjs
  9004. var $309d73dc65f78055$exports = {};
  9005. $309d73dc65f78055$exports = {
  9006. dismiss: "Descartar"
  9007. };
  9008. // ../../node_modules/@react-aria/overlays/dist/et-EE.mjs
  9009. var $44ad94f7205cf593$exports = {};
  9010. $44ad94f7205cf593$exports = {
  9011. dismiss: "L\xF5peta"
  9012. };
  9013. // ../../node_modules/@react-aria/overlays/dist/fi-FI.mjs
  9014. var $7c28f5687f0779a9$exports = {};
  9015. $7c28f5687f0779a9$exports = {
  9016. dismiss: "Hylk\xE4\xE4"
  9017. };
  9018. // ../../node_modules/@react-aria/overlays/dist/fr-FR.mjs
  9019. var $e6d75df4b68bd73a$exports = {};
  9020. $e6d75df4b68bd73a$exports = {
  9021. dismiss: "Rejeter"
  9022. };
  9023. // ../../node_modules/@react-aria/overlays/dist/he-IL.mjs
  9024. var $87505c9dab186d0f$exports = {};
  9025. $87505c9dab186d0f$exports = {
  9026. dismiss: "\u05D4\u05EA\u05E2\u05DC\u05DD"
  9027. };
  9028. // ../../node_modules/@react-aria/overlays/dist/hr-HR.mjs
  9029. var $553439c3ffb3e492$exports = {};
  9030. $553439c3ffb3e492$exports = {
  9031. dismiss: "Odbaci"
  9032. };
  9033. // ../../node_modules/@react-aria/overlays/dist/hu-HU.mjs
  9034. var $74cf411061b983a2$exports = {};
  9035. $74cf411061b983a2$exports = {
  9036. dismiss: "Elutas\xEDt\xE1s"
  9037. };
  9038. // ../../node_modules/@react-aria/overlays/dist/it-IT.mjs
  9039. var $e933f298574dc435$exports = {};
  9040. $e933f298574dc435$exports = {
  9041. dismiss: "Ignora"
  9042. };
  9043. // ../../node_modules/@react-aria/overlays/dist/ja-JP.mjs
  9044. var $ac91fc9fe02f71f6$exports = {};
  9045. $ac91fc9fe02f71f6$exports = {
  9046. dismiss: "\u9589\u3058\u308B"
  9047. };
  9048. // ../../node_modules/@react-aria/overlays/dist/ko-KR.mjs
  9049. var $52b96f86422025af$exports = {};
  9050. $52b96f86422025af$exports = {
  9051. dismiss: "\uBB34\uC2DC"
  9052. };
  9053. // ../../node_modules/@react-aria/overlays/dist/lt-LT.mjs
  9054. var $c0d724c3e51dafa6$exports = {};
  9055. $c0d724c3e51dafa6$exports = {
  9056. dismiss: "Atmesti"
  9057. };
  9058. // ../../node_modules/@react-aria/overlays/dist/lv-LV.mjs
  9059. var $c92899672a3fe72e$exports = {};
  9060. $c92899672a3fe72e$exports = {
  9061. dismiss: "Ner\u0101d\u012Bt"
  9062. };
  9063. // ../../node_modules/@react-aria/overlays/dist/nb-NO.mjs
  9064. var $9f576b39d8e7a9d6$exports = {};
  9065. $9f576b39d8e7a9d6$exports = {
  9066. dismiss: "Lukk"
  9067. };
  9068. // ../../node_modules/@react-aria/overlays/dist/nl-NL.mjs
  9069. var $9d025808aeec81a7$exports = {};
  9070. $9d025808aeec81a7$exports = {
  9071. dismiss: "Negeren"
  9072. };
  9073. // ../../node_modules/@react-aria/overlays/dist/pl-PL.mjs
  9074. var $fce709921e2c0fa6$exports = {};
  9075. $fce709921e2c0fa6$exports = {
  9076. dismiss: "Zignoruj"
  9077. };
  9078. // ../../node_modules/@react-aria/overlays/dist/pt-BR.mjs
  9079. var $2599cf0c4ab37f59$exports = {};
  9080. $2599cf0c4ab37f59$exports = {
  9081. dismiss: "Descartar"
  9082. };
  9083. // ../../node_modules/@react-aria/overlays/dist/pt-PT.mjs
  9084. var $3c220ae7ef8a35fd$exports = {};
  9085. $3c220ae7ef8a35fd$exports = {
  9086. dismiss: "Dispensar"
  9087. };
  9088. // ../../node_modules/@react-aria/overlays/dist/ro-RO.mjs
  9089. var $93562b5094072f54$exports = {};
  9090. $93562b5094072f54$exports = {
  9091. dismiss: "Revocare"
  9092. };
  9093. // ../../node_modules/@react-aria/overlays/dist/ru-RU.mjs
  9094. var $cd9e2abd0d06c7b4$exports = {};
  9095. $cd9e2abd0d06c7b4$exports = {
  9096. dismiss: "\u041F\u0440\u043E\u043F\u0443\u0441\u0442\u0438\u0442\u044C"
  9097. };
  9098. // ../../node_modules/@react-aria/overlays/dist/sk-SK.mjs
  9099. var $45375701f409adf1$exports = {};
  9100. $45375701f409adf1$exports = {
  9101. dismiss: "Zru\u0161i\u0165"
  9102. };
  9103. // ../../node_modules/@react-aria/overlays/dist/sl-SI.mjs
  9104. var $27fab53a576de9dd$exports = {};
  9105. $27fab53a576de9dd$exports = {
  9106. dismiss: "Opusti"
  9107. };
  9108. // ../../node_modules/@react-aria/overlays/dist/sr-SP.mjs
  9109. var $4438748d9952e7c7$exports = {};
  9110. $4438748d9952e7c7$exports = {
  9111. dismiss: "Odbaci"
  9112. };
  9113. // ../../node_modules/@react-aria/overlays/dist/sv-SE.mjs
  9114. var $0936d7347ef4da4c$exports = {};
  9115. $0936d7347ef4da4c$exports = {
  9116. dismiss: "Avvisa"
  9117. };
  9118. // ../../node_modules/@react-aria/overlays/dist/tr-TR.mjs
  9119. var $29700c92185d38f8$exports = {};
  9120. $29700c92185d38f8$exports = {
  9121. dismiss: "Kapat"
  9122. };
  9123. // ../../node_modules/@react-aria/overlays/dist/uk-UA.mjs
  9124. var $662ccaf2be4c25b3$exports = {};
  9125. $662ccaf2be4c25b3$exports = {
  9126. dismiss: "\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438"
  9127. };
  9128. // ../../node_modules/@react-aria/overlays/dist/zh-CN.mjs
  9129. var $d80a27deda7cdb3c$exports = {};
  9130. $d80a27deda7cdb3c$exports = {
  9131. dismiss: "\u53D6\u6D88"
  9132. };
  9133. // ../../node_modules/@react-aria/overlays/dist/zh-TW.mjs
  9134. var $2b2734393847c884$exports = {};
  9135. $2b2734393847c884$exports = {
  9136. dismiss: "\u95DC\u9589"
  9137. };
  9138. // ../../node_modules/@react-aria/overlays/dist/intlStrings.mjs
  9139. var $a2f21f5f14f60553$exports = {};
  9140. $a2f21f5f14f60553$exports = {
  9141. "ar-AE": $773d5888b972f1cf$exports,
  9142. "bg-BG": $d11f19852b941573$exports,
  9143. "cs-CZ": $b983974c2ee1efb3$exports,
  9144. "da-DK": $5809cc9d4e92de73$exports,
  9145. "de-DE": $c68c2e4fc74398d1$exports,
  9146. "el-GR": $0898b4c153db2b77$exports,
  9147. "en-US": $6d74810286a15183$exports,
  9148. "es-ES": $309d73dc65f78055$exports,
  9149. "et-EE": $44ad94f7205cf593$exports,
  9150. "fi-FI": $7c28f5687f0779a9$exports,
  9151. "fr-FR": $e6d75df4b68bd73a$exports,
  9152. "he-IL": $87505c9dab186d0f$exports,
  9153. "hr-HR": $553439c3ffb3e492$exports,
  9154. "hu-HU": $74cf411061b983a2$exports,
  9155. "it-IT": $e933f298574dc435$exports,
  9156. "ja-JP": $ac91fc9fe02f71f6$exports,
  9157. "ko-KR": $52b96f86422025af$exports,
  9158. "lt-LT": $c0d724c3e51dafa6$exports,
  9159. "lv-LV": $c92899672a3fe72e$exports,
  9160. "nb-NO": $9f576b39d8e7a9d6$exports,
  9161. "nl-NL": $9d025808aeec81a7$exports,
  9162. "pl-PL": $fce709921e2c0fa6$exports,
  9163. "pt-BR": $2599cf0c4ab37f59$exports,
  9164. "pt-PT": $3c220ae7ef8a35fd$exports,
  9165. "ro-RO": $93562b5094072f54$exports,
  9166. "ru-RU": $cd9e2abd0d06c7b4$exports,
  9167. "sk-SK": $45375701f409adf1$exports,
  9168. "sl-SI": $27fab53a576de9dd$exports,
  9169. "sr-SP": $4438748d9952e7c7$exports,
  9170. "sv-SE": $0936d7347ef4da4c$exports,
  9171. "tr-TR": $29700c92185d38f8$exports,
  9172. "uk-UA": $662ccaf2be4c25b3$exports,
  9173. "zh-CN": $d80a27deda7cdb3c$exports,
  9174. "zh-TW": $2b2734393847c884$exports
  9175. };
  9176. // ../../node_modules/@react-aria/overlays/dist/DismissButton.mjs
  9177. init_react();
  9178. // ../../node_modules/@react-aria/visually-hidden/dist/VisuallyHidden.mjs
  9179. init_react();
  9180. // ../../node_modules/@react-aria/overlays/dist/ariaHideOutside.mjs
  9181. var $5e3802645cc19319$var$supportsInert = typeof HTMLElement < "u" && "inert" in HTMLElement.prototype;
  9182. // ../../node_modules/@react-aria/overlays/dist/usePopover.mjs
  9183. init_react();
  9184. // ../../node_modules/@react-aria/overlays/dist/Overlay.mjs
  9185. init_react();
  9186. var $337b884510726a0d$export$a2200b96afd16271 = react_default.createContext(null);
  9187. // ../../node_modules/@react-aria/overlays/dist/useModalOverlay.mjs
  9188. init_react();
  9189. // ../../node_modules/@react-stately/tooltip/dist/useTooltipTriggerState.mjs
  9190. init_react();
  9191. // ../../node_modules/@react-stately/overlays/dist/useOverlayTriggerState.mjs
  9192. init_react();
  9193. function $fc909762b330b746$export$61c6a8c84e605fb6(props) {
  9194. let [isOpen, setOpen] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(props.isOpen, props.defaultOpen || !1, props.onOpenChange), open = useCallback(() => {
  9195. setOpen(!0);
  9196. }, [
  9197. setOpen
  9198. ]), close = useCallback(() => {
  9199. setOpen(!1);
  9200. }, [
  9201. setOpen
  9202. ]), toggle = useCallback(() => {
  9203. setOpen(!isOpen);
  9204. }, [
  9205. setOpen,
  9206. isOpen
  9207. ]);
  9208. return {
  9209. isOpen,
  9210. setOpen,
  9211. open,
  9212. close,
  9213. toggle
  9214. };
  9215. }
  9216. // ../../node_modules/@react-stately/tooltip/dist/useTooltipTriggerState.mjs
  9217. 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;
  9218. function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
  9219. 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 = () => {
  9220. $8796f90736e175cb$var$tooltips[id] = hideTooltip;
  9221. }, closeOpenTooltips = () => {
  9222. for (let hideTooltipId in $8796f90736e175cb$var$tooltips) hideTooltipId !== id && ($8796f90736e175cb$var$tooltips[hideTooltipId](!0), delete $8796f90736e175cb$var$tooltips[hideTooltipId]);
  9223. }, showTooltip = () => {
  9224. 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);
  9225. }, hideTooltip = (immediate) => {
  9226. immediate || closeDelay <= 0 ? (closeTimeout.current && clearTimeout(closeTimeout.current), closeTimeout.current = null, closeCallback.current()) : closeTimeout.current || (closeTimeout.current = setTimeout(() => {
  9227. closeTimeout.current = null, closeCallback.current();
  9228. }, 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(() => {
  9229. delete $8796f90736e175cb$var$tooltips[id], $8796f90736e175cb$var$globalCooldownTimeout = null, $8796f90736e175cb$var$globalWarmedUp = !1;
  9230. }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay)));
  9231. }, warmupTooltip = () => {
  9232. closeOpenTooltips(), ensureTooltipEntry(), !isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp ? $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(() => {
  9233. $8796f90736e175cb$var$globalWarmUpTimeout = null, $8796f90736e175cb$var$globalWarmedUp = !0, showTooltip();
  9234. }, delay2) : isOpen || showTooltip();
  9235. };
  9236. return useEffect(() => {
  9237. closeCallback.current = close;
  9238. }, [
  9239. close
  9240. ]), useEffect(() => () => {
  9241. closeTimeout.current && clearTimeout(closeTimeout.current), $8796f90736e175cb$var$tooltips[id] && delete $8796f90736e175cb$var$tooltips[id];
  9242. }, [
  9243. id
  9244. ]), {
  9245. isOpen,
  9246. open: (immediate) => {
  9247. !immediate && delay2 > 0 && !closeTimeout.current ? warmupTooltip() : showTooltip();
  9248. },
  9249. close: hideTooltip
  9250. };
  9251. }
  9252. // ../../node_modules/react-aria-components/dist/Tooltip.mjs
  9253. init_react();
  9254. var $4e3b923658d69c60$export$7a7623236eec67fa = createContext(null), $4e3b923658d69c60$export$39ae08fa83328b12 = createContext(null);
  9255. function $4e3b923658d69c60$export$8c610744efcf8a1d(props) {
  9256. let state = $8796f90736e175cb$export$4d40659c25ecb50b(props), ref = useRef(null), { triggerProps, tooltipProps } = $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref);
  9257. return react_default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
  9258. values: [
  9259. [
  9260. $4e3b923658d69c60$export$7a7623236eec67fa,
  9261. state
  9262. ],
  9263. [
  9264. $4e3b923658d69c60$export$39ae08fa83328b12,
  9265. {
  9266. ...tooltipProps,
  9267. triggerRef: ref
  9268. }
  9269. ]
  9270. ]
  9271. }, react_default.createElement($f645667febf57a63$export$13f3202a3e5ddd5, {
  9272. ...triggerProps,
  9273. ref
  9274. }, props.children));
  9275. }
  9276. var $4e3b923658d69c60$export$28c660c63b792dea = forwardRef(function({ UNSTABLE_portalContainer, ...props }, ref) {
  9277. [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $4e3b923658d69c60$export$39ae08fa83328b12);
  9278. 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;
  9279. return !state.isOpen && !isExiting ? null : react_default.createElement($f57aed4a881a3485$export$b47c3594eab58386, {
  9280. portalContainer: UNSTABLE_portalContainer
  9281. }, react_default.createElement($4e3b923658d69c60$var$TooltipInner, {
  9282. ...props,
  9283. tooltipRef: ref,
  9284. isExiting
  9285. }));
  9286. });
  9287. function $4e3b923658d69c60$var$TooltipInner(props) {
  9288. let state = useContext($4e3b923658d69c60$export$7a7623236eec67fa), arrowRef = useRef(null), { overlayProps, arrowProps, placement, triggerAnchorPoint } = $2a41e45df1593e64$export$d39e1813b3bdd0e1({
  9289. placement: props.placement || "top",
  9290. targetRef: props.triggerRef,
  9291. overlayRef: props.tooltipRef,
  9292. arrowRef,
  9293. offset: props.offset,
  9294. crossOffset: props.crossOffset,
  9295. isOpen: state.isOpen,
  9296. arrowBoundaryOffset: props.arrowBoundaryOffset,
  9297. shouldFlip: props.shouldFlip,
  9298. containerPadding: props.containerPadding,
  9299. onClose: () => state.close(!0)
  9300. }), isEntering = $d3f049242431219c$export$6d3443f2c48bfc20(props.tooltipRef, !!placement) || props.isEntering || !1, renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
  9301. ...props,
  9302. defaultClassName: "react-aria-Tooltip",
  9303. values: {
  9304. placement,
  9305. isEntering,
  9306. isExiting: props.isExiting,
  9307. state
  9308. }
  9309. });
  9310. props = $3ef42575df84b30b$export$9d1611c77c2fe928(props, overlayProps);
  9311. let { tooltipProps } = $326e436e94273fe1$export$1c4b08e0eca38426(props, state), DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
  9312. global: !0
  9313. });
  9314. return react_default.createElement("div", {
  9315. ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, renderProps, tooltipProps),
  9316. ref: props.tooltipRef,
  9317. style: {
  9318. ...overlayProps.style,
  9319. "--trigger-anchor-point": triggerAnchorPoint ? `${triggerAnchorPoint.x}px ${triggerAnchorPoint.y}px` : void 0,
  9320. ...renderProps.style
  9321. },
  9322. "data-placement": placement ?? void 0,
  9323. "data-entering": isEntering || void 0,
  9324. "data-exiting": props.isExiting || void 0
  9325. }, react_default.createElement($44f671af83e7d9e0$export$2de4954e8ae13b9f.Provider, {
  9326. value: {
  9327. ...arrowProps,
  9328. placement,
  9329. ref: arrowRef
  9330. }
  9331. }, renderProps.children));
  9332. }
  9333. // src/components/components/shared/overlayHelpers.tsx
  9334. init_react();
  9335. var import_memoizerific = __toESM(require_memoizerific(), 1);
  9336. 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({
  9337. width: 500,
  9338. height: 500,
  9339. paddingTop: 100,
  9340. overflowY: "scroll",
  9341. background: "#eee",
  9342. position: "relative"
  9343. }), Trigger = forwardRef((props, ref) => react_default.createElement(
  9344. "button",
  9345. {
  9346. ...props,
  9347. ref,
  9348. style: {
  9349. width: 120,
  9350. height: 50,
  9351. margin: 10
  9352. }
  9353. }
  9354. ));
  9355. Trigger.displayName = "Trigger";
  9356. // src/components/components/tooltip/TooltipProvider.tsx
  9357. var TooltipProvider2 = ({
  9358. triggerOnFocusOnly = !1,
  9359. placement: placementProp = "top",
  9360. offset: offset2 = 8,
  9361. tooltip,
  9362. children,
  9363. defaultVisible,
  9364. startOpen,
  9365. delayShow = 400,
  9366. delayHide = 200,
  9367. visible,
  9368. onVisibleChange,
  9369. ...props
  9370. }) => {
  9371. let placement = convertToReactAriaPlacement2(placementProp), child = react_default.Children.only(children);
  9372. startOpen !== void 0 && deprecate("The `startOpen` prop is deprecated. Please use `defaultVisible` instead.");
  9373. let [isOpen, setIsOpen] = useState(defaultVisible ?? startOpen ?? !1), onOpenChange = useCallback(
  9374. (isOpen2) => {
  9375. setIsOpen(isOpen2), onVisibleChange?.(isOpen2);
  9376. },
  9377. [onVisibleChange]
  9378. );
  9379. return react_default.createElement(
  9380. $4e3b923658d69c60$export$8c610744efcf8a1d,
  9381. {
  9382. delay: delayShow,
  9383. closeDelay: delayHide,
  9384. isOpen: visible ?? isOpen,
  9385. onOpenChange,
  9386. trigger: triggerOnFocusOnly ? "focus" : void 0,
  9387. ...props
  9388. },
  9389. react_default.createElement($f645667febf57a63$export$35a3bebf7ef2d934, null, react_default.cloneElement(child, { "aria-describedby": null })),
  9390. react_default.createElement(
  9391. $4e3b923658d69c60$export$28c660c63b792dea,
  9392. {
  9393. "data-testid": "tooltip",
  9394. placement,
  9395. offset: offset2,
  9396. onOpenChange,
  9397. style: { outline: "none" },
  9398. ...props
  9399. },
  9400. tooltip
  9401. )
  9402. );
  9403. };
  9404. // src/manager/components/layout/Drag.tsx
  9405. var oppositePosition = {
  9406. left: "right",
  9407. right: "left",
  9408. top: "bottom",
  9409. bottom: "top"
  9410. }, Drag = forwardRef(function(props, ref) {
  9411. let {
  9412. overlapping,
  9413. position,
  9414. "aria-label": ariaLabel,
  9415. "aria-valuenow": ariaValueNow,
  9416. "aria-valuemax": ariaValueMax,
  9417. ...rest2
  9418. } = props, orientation = position === "left" || position === "right" ? "vertical" : "horizontal", tooltipNote = orientation === "vertical" ? "\u2190 \u2192 to resize" : "\u2191 \u2193 to resize";
  9419. return react_default.createElement(
  9420. TooltipProvider2,
  9421. {
  9422. triggerOnFocusOnly: !0,
  9423. placement: oppositePosition[position],
  9424. tooltip: react_default.createElement(TooltipNote2, { note: tooltipNote })
  9425. },
  9426. react_default.createElement(
  9427. DragHandle,
  9428. {
  9429. ref,
  9430. $orientation: orientation,
  9431. $overlapping: overlapping,
  9432. $position: position,
  9433. role: "separator",
  9434. tabIndex: 0,
  9435. "aria-orientation": orientation,
  9436. "aria-label": ariaLabel,
  9437. "aria-valuenow": ariaValueNow,
  9438. "aria-valuemin": 0,
  9439. "aria-valuemax": ariaValueMax,
  9440. ...rest2
  9441. }
  9442. )
  9443. );
  9444. }), DragHandle = styled.div(
  9445. ({ theme }) => ({
  9446. position: "absolute",
  9447. opacity: 0,
  9448. transition: "opacity 0.2s ease-in-out",
  9449. zIndex: 100,
  9450. "&:after": {
  9451. content: '""',
  9452. display: "block",
  9453. backgroundColor: theme.color.secondary
  9454. },
  9455. "&:hover": {
  9456. opacity: 1
  9457. }
  9458. }),
  9459. ({ theme, $orientation = "vertical" }) => ({
  9460. "&:focus-visible": {
  9461. opacity: 1,
  9462. outline: "2px solid transparent",
  9463. ...$orientation === "horizontal" ? { height: 7 } : { width: 7 },
  9464. boxShadow: `inset 0 0 0 4px ${theme.color.secondary}`,
  9465. "@media (forced-colors: active)": {
  9466. outline: "2px solid Highlight"
  9467. }
  9468. }
  9469. }),
  9470. ({ $orientation = "vertical", $overlapping = !0, $position = "left" }) => $orientation === "vertical" ? {
  9471. // This is an old code smell, where 10px matches the sidebar and 13px matches the addon panel.
  9472. // It should be tidied up at some point.
  9473. width: $overlapping ? $position === "left" ? 10 : 13 : 7,
  9474. height: "100%",
  9475. top: 0,
  9476. right: $position === "left" ? -7 : void 0,
  9477. left: $position === "right" ? -7 : void 0,
  9478. "&:after": {
  9479. width: 1,
  9480. height: "100%",
  9481. marginLeft: $position === "left" ? 3 : 6
  9482. },
  9483. "&:hover": {
  9484. cursor: "col-resize"
  9485. }
  9486. } : {
  9487. width: "100%",
  9488. height: $overlapping ? 13 : 7,
  9489. top: $position === "bottom" ? -7 : void 0,
  9490. bottom: $position === "top" ? -7 : void 0,
  9491. left: 0,
  9492. "&:after": {
  9493. width: "100%",
  9494. height: 1,
  9495. marginTop: 6
  9496. },
  9497. "&:hover": {
  9498. cursor: "row-resize"
  9499. }
  9500. }
  9501. );
  9502. // src/manager/components/layout/PanelContainer.tsx
  9503. var Container6 = styled.div(({ theme, position }) => ({
  9504. gridArea: "panel",
  9505. position: "relative",
  9506. backgroundColor: theme.appContentBg,
  9507. borderTop: position === "bottom" ? `1px solid ${theme.appBorderColor}` : void 0,
  9508. borderLeft: position === "right" ? `1px solid ${theme.appBorderColor}` : void 0
  9509. })), PanelSlot = styled.div({
  9510. height: "100%"
  9511. }), PanelContainer = react_default.memo(function(props) {
  9512. let { children, bottomPanelHeight, rightPanelWidth, panelMaxSize, panelResizerRef, position } = props, shouldHidePanelContent = position === "bottom" ? bottomPanelHeight === 0 : rightPanelWidth === 0;
  9513. return react_default.createElement(Container6, { position }, react_default.createElement(
  9514. Drag,
  9515. {
  9516. ref: panelResizerRef,
  9517. position,
  9518. overlapping: position === "bottom" ? !!bottomPanelHeight : !!rightPanelWidth,
  9519. "aria-label": "Addon panel resize handle",
  9520. "aria-valuenow": position === "bottom" ? bottomPanelHeight : rightPanelWidth,
  9521. "aria-valuemax": panelMaxSize
  9522. }
  9523. ), react_default.createElement(
  9524. PanelSlot,
  9525. {
  9526. hidden: shouldHidePanelContent ? !0 : void 0,
  9527. "aria-hidden": shouldHidePanelContent ? !0 : void 0
  9528. },
  9529. children
  9530. ));
  9531. });
  9532. // src/manager/components/layout/SidebarContainer.tsx
  9533. init_react();
  9534. var Container7 = styled.div(({ theme }) => ({
  9535. backgroundColor: theme.appBg,
  9536. gridArea: "sidebar",
  9537. position: "relative",
  9538. borderRight: `1px solid ${theme.appBorderColor}`
  9539. })), SidebarSlot = styled.div({
  9540. height: "100%"
  9541. }), SidebarContainer = react_default.memo(function(props) {
  9542. let { children, navSize, sidebarMaxWidth, sidebarResizerRef } = props, shouldHideSidebarContent = navSize === 0;
  9543. return react_default.createElement(Container7, null, react_default.createElement(
  9544. SidebarSlot,
  9545. {
  9546. hidden: shouldHideSidebarContent ? !0 : void 0,
  9547. "aria-hidden": shouldHideSidebarContent ? !0 : void 0
  9548. },
  9549. children
  9550. ), react_default.createElement(
  9551. Drag,
  9552. {
  9553. ref: sidebarResizerRef,
  9554. position: "left",
  9555. "aria-label": "Sidebar resize handle",
  9556. "aria-valuenow": navSize,
  9557. "aria-valuemax": sidebarMaxWidth
  9558. }
  9559. ));
  9560. });
  9561. // src/manager/components/layout/useDragging.ts
  9562. init_react();
  9563. var SNAP_THRESHOLD_PX = 30, STIFFNESS = 0.9, KEYBOARD_STEP_PX = 10, KEYBOARD_SHIFT_MULTIPLIER = 5, RESIZE_KEYS = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"];
  9564. function clamp(value, min, max) {
  9565. return Math.min(Math.max(value, min), max);
  9566. }
  9567. function interpolate(relativeValue, min, max) {
  9568. return min + (max - min) * relativeValue;
  9569. }
  9570. function computeSidebarMaxWidth(panelPosition, rightPanelWidth, showPanel) {
  9571. if (typeof window > "u")
  9572. return 0;
  9573. let panelWidth = showPanel ? panelPosition === "right" ? rightPanelWidth : 360 : 0;
  9574. return Math.max(window.innerWidth - 100 - panelWidth, 0);
  9575. }
  9576. function computePanelMaxSize(panelPosition, navSize) {
  9577. return typeof window > "u" ? 0 : Math.max(panelPosition === "bottom" ? window.innerHeight - 40 : window.innerWidth - 100 - navSize, 0);
  9578. }
  9579. function applyResizeKeyboard(state, sizeKey, key, step, minSize, maxSize, increaseKey, decreaseKey) {
  9580. let currentSize = state[sizeKey];
  9581. switch (key) {
  9582. case increaseKey:
  9583. return { ...state, [sizeKey]: clamp(currentSize + step, minSize, maxSize) };
  9584. case decreaseKey:
  9585. let effectivelyComputed = clamp(currentSize - step, 0, maxSize);
  9586. return { ...state, [sizeKey]: effectivelyComputed < minSize ? 0 : effectivelyComputed };
  9587. case "Home":
  9588. return { ...state, [sizeKey]: 0 };
  9589. case "End":
  9590. return { ...state, [sizeKey]: maxSize };
  9591. default:
  9592. return state;
  9593. }
  9594. }
  9595. function useDragging({
  9596. setState,
  9597. showPanel,
  9598. isDesktop,
  9599. navSize,
  9600. rightPanelWidth,
  9601. panelPosition
  9602. }) {
  9603. let panelResizerRef = useRef(null), sidebarResizerRef = useRef(null), sidebarMaxWidth = computeSidebarMaxWidth(panelPosition, rightPanelWidth, showPanel), panelMaxSize = computePanelMaxSize(panelPosition, navSize);
  9604. return useEffect(() => {
  9605. let panelResizer = panelResizerRef.current, sidebarResizer = sidebarResizerRef.current, previewIframe = document.querySelector("#storybook-preview-iframe"), draggedElement = null, onDragStart = (e2) => {
  9606. e2.preventDefault(), setState((state) => ({
  9607. ...state,
  9608. isDragging: !0
  9609. })), e2.currentTarget === panelResizer ? draggedElement = panelResizer : e2.currentTarget === sidebarResizer && (draggedElement = sidebarResizer), window.addEventListener("mousemove", onDrag), window.addEventListener("mouseup", onDragEnd), previewIframe && (previewIframe.style.pointerEvents = "none");
  9610. }, onDragEnd = () => {
  9611. setState((state) => {
  9612. if (draggedElement === sidebarResizer && state.navSize < 240 && state.navSize > 0)
  9613. return {
  9614. ...state,
  9615. isDragging: !1,
  9616. navSize: 240
  9617. };
  9618. if (draggedElement === panelResizer) {
  9619. if (state.panelPosition === "right" && state.rightPanelWidth < 270 && state.rightPanelWidth > 0)
  9620. return {
  9621. ...state,
  9622. isDragging: !1,
  9623. rightPanelWidth: 270
  9624. };
  9625. if (state.panelPosition === "bottom" && state.bottomPanelHeight < 40 && state.bottomPanelHeight > 0)
  9626. return {
  9627. ...state,
  9628. isDragging: !1,
  9629. bottomPanelHeight: 40
  9630. };
  9631. }
  9632. return {
  9633. ...state,
  9634. isDragging: !1
  9635. };
  9636. }), window.removeEventListener("mousemove", onDrag), window.removeEventListener("mouseup", onDragEnd), previewIframe?.removeAttribute("style"), draggedElement = null;
  9637. }, onDrag = (e2) => {
  9638. if (e2.buttons === 0) {
  9639. onDragEnd();
  9640. return;
  9641. }
  9642. setState((state) => {
  9643. if (draggedElement === sidebarResizer) {
  9644. let sidebarDragX = e2.clientX;
  9645. return sidebarDragX === state.navSize ? state : sidebarDragX <= SNAP_THRESHOLD_PX ? {
  9646. ...state,
  9647. navSize: 0
  9648. } : sidebarDragX <= 240 ? {
  9649. ...state,
  9650. navSize: interpolate(STIFFNESS, sidebarDragX, 240)
  9651. } : {
  9652. ...state,
  9653. navSize: clamp(
  9654. sidebarDragX,
  9655. 0,
  9656. computeSidebarMaxWidth(state.panelPosition, state.rightPanelWidth, showPanel)
  9657. )
  9658. };
  9659. }
  9660. if (draggedElement === panelResizer) {
  9661. let sizeAxisState = state.panelPosition === "bottom" ? "bottomPanelHeight" : "rightPanelWidth", panelDragSize = state.panelPosition === "bottom" ? (
  9662. // @ts-expect-error (non strict)
  9663. e2.view.innerHeight - e2.clientY
  9664. ) : (
  9665. // @ts-expect-error (non strict)
  9666. e2.view.innerWidth - e2.clientX
  9667. ), minimumSize = state.panelPosition === "bottom" ? 40 : 270;
  9668. return panelDragSize === state[sizeAxisState] ? state : panelDragSize <= SNAP_THRESHOLD_PX ? {
  9669. ...state,
  9670. [sizeAxisState]: 0
  9671. } : panelDragSize <= minimumSize ? {
  9672. ...state,
  9673. [sizeAxisState]: interpolate(STIFFNESS, panelDragSize, minimumSize)
  9674. } : {
  9675. ...state,
  9676. [sizeAxisState]: clamp(
  9677. panelDragSize,
  9678. 0,
  9679. computePanelMaxSize(state.panelPosition, state.navSize)
  9680. )
  9681. };
  9682. }
  9683. return state;
  9684. });
  9685. }, onSidebarKeyDown = (e2) => {
  9686. if (!RESIZE_KEYS.includes(e2.key))
  9687. return;
  9688. e2.preventDefault();
  9689. let step = e2.shiftKey ? KEYBOARD_STEP_PX * KEYBOARD_SHIFT_MULTIPLIER : KEYBOARD_STEP_PX;
  9690. setState(
  9691. (state) => applyResizeKeyboard(
  9692. state,
  9693. "navSize",
  9694. e2.key,
  9695. step,
  9696. 240,
  9697. computeSidebarMaxWidth(state.panelPosition, state.rightPanelWidth, showPanel),
  9698. "ArrowRight",
  9699. "ArrowLeft"
  9700. )
  9701. );
  9702. }, onPanelKeyDown = (e2) => {
  9703. if (!RESIZE_KEYS.includes(e2.key))
  9704. return;
  9705. e2.preventDefault();
  9706. let step = e2.shiftKey ? KEYBOARD_STEP_PX * KEYBOARD_SHIFT_MULTIPLIER : KEYBOARD_STEP_PX;
  9707. setState(
  9708. (state) => applyResizeKeyboard(
  9709. state,
  9710. state.panelPosition === "bottom" ? "bottomPanelHeight" : "rightPanelWidth",
  9711. e2.key,
  9712. step,
  9713. state.panelPosition === "bottom" ? 40 : 270,
  9714. computePanelMaxSize(state.panelPosition, state.navSize),
  9715. state.panelPosition === "bottom" ? "ArrowUp" : "ArrowLeft",
  9716. state.panelPosition === "bottom" ? "ArrowDown" : "ArrowRight"
  9717. )
  9718. );
  9719. };
  9720. return panelResizer?.addEventListener("mousedown", onDragStart), sidebarResizer?.addEventListener("mousedown", onDragStart), panelResizer?.addEventListener("keydown", onPanelKeyDown), sidebarResizer?.addEventListener("keydown", onSidebarKeyDown), () => {
  9721. panelResizer?.removeEventListener("mousedown", onDragStart), sidebarResizer?.removeEventListener("mousedown", onDragStart), panelResizer?.removeEventListener("keydown", onPanelKeyDown), sidebarResizer?.removeEventListener("keydown", onSidebarKeyDown), previewIframe?.removeAttribute("style");
  9722. };
  9723. }, [
  9724. // we need to rerun this effect when the panel is shown/hidden or when changing between mobile/desktop to re-attach the event listeners
  9725. showPanel,
  9726. isDesktop,
  9727. setState
  9728. ]), { panelResizerRef, sidebarResizerRef, sidebarMaxWidth, panelMaxSize };
  9729. }
  9730. // src/manager/components/layout/useLandmarkIndicator.ts
  9731. init_react();
  9732. function findActiveLandmarkElement() {
  9733. let currentElement = document.activeElement, landmarkElement = null;
  9734. for (; currentElement; ) {
  9735. if (currentElement instanceof HTMLElement && currentElement.hasAttribute("data-sb-landmark")) {
  9736. landmarkElement = currentElement;
  9737. break;
  9738. }
  9739. currentElement = currentElement.parentElement;
  9740. }
  9741. return landmarkElement;
  9742. }
  9743. function useRegionFocusAnimation() {
  9744. let theme = useTheme(), reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)"), currentAnimationRef = useRef(null);
  9745. return (elementToAnimate) => {
  9746. if (elementToAnimate && (currentAnimationRef.current && (currentAnimationRef.current.cancel(), currentAnimationRef.current = null), !reducedMotion)) {
  9747. let animation = elementToAnimate.animate(
  9748. [{ border: `2px solid ${theme.color.primary}` }, { border: "2px solid transparent" }],
  9749. {
  9750. duration: 1500,
  9751. pseudoElement: "::after"
  9752. }
  9753. );
  9754. currentAnimationRef.current = animation, animation.onfinish = () => {
  9755. currentAnimationRef.current = null;
  9756. };
  9757. }
  9758. };
  9759. }
  9760. function useLandmarkIndicator() {
  9761. let animateLandmark = useRegionFocusAnimation();
  9762. useEffect(() => {
  9763. let handleKeyDown = (e2) => {
  9764. if (e2.key !== "F6")
  9765. return;
  9766. let landmarkElement = findActiveLandmarkElement();
  9767. landmarkElement && animateLandmark(landmarkElement);
  9768. };
  9769. return document.addEventListener("keydown", handleKeyDown, { capture: !0 }), () => {
  9770. document.removeEventListener("keydown", handleKeyDown, { capture: !0 });
  9771. };
  9772. }, [animateLandmark]);
  9773. }
  9774. // src/manager/components/layout/Layout.tsx
  9775. var layoutStateIsEqual = (state, other) => state.navSize === other.navSize && state.bottomPanelHeight === other.bottomPanelHeight && state.rightPanelWidth === other.rightPanelWidth && state.panelPosition === other.panelPosition, useLayoutSyncingState = ({
  9776. api,
  9777. managerLayoutState,
  9778. setManagerLayoutState,
  9779. isDesktop,
  9780. hasTab
  9781. }) => {
  9782. let prevManagerLayoutStateRef = react_default.useRef(managerLayoutState), [internalDraggingSizeState, setInternalDraggingSizeState] = useState({
  9783. ...managerLayoutState,
  9784. isDragging: !1
  9785. });
  9786. useEffect(() => {
  9787. internalDraggingSizeState.isDragging || // don't interrupt user's drag
  9788. layoutStateIsEqual(managerLayoutState, prevManagerLayoutStateRef.current) || (prevManagerLayoutStateRef.current = managerLayoutState, setInternalDraggingSizeState((state) => ({ ...state, ...managerLayoutState })));
  9789. }, [internalDraggingSizeState.isDragging, managerLayoutState, setInternalDraggingSizeState]), useLayoutEffect(() => {
  9790. if (internalDraggingSizeState.isDragging || // wait with syncing managerLayoutState until user is done dragging
  9791. layoutStateIsEqual(managerLayoutState, internalDraggingSizeState))
  9792. return;
  9793. let nextState = {
  9794. navSize: internalDraggingSizeState.navSize,
  9795. bottomPanelHeight: internalDraggingSizeState.bottomPanelHeight,
  9796. rightPanelWidth: internalDraggingSizeState.rightPanelWidth
  9797. };
  9798. prevManagerLayoutStateRef.current = {
  9799. ...prevManagerLayoutStateRef.current,
  9800. ...nextState
  9801. }, setManagerLayoutState(nextState);
  9802. }, [internalDraggingSizeState, setManagerLayoutState]);
  9803. 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({
  9804. setState: setInternalDraggingSizeState,
  9805. isDesktop,
  9806. navSize: customisedNavSize,
  9807. showPanel: customisedShowPanel,
  9808. rightPanelWidth,
  9809. panelPosition: managerLayoutState.panelPosition
  9810. });
  9811. return {
  9812. navSize: customisedNavSize,
  9813. rightPanelWidth,
  9814. bottomPanelHeight,
  9815. panelPosition: managerLayoutState.panelPosition,
  9816. panelResizerRef,
  9817. sidebarResizerRef,
  9818. sidebarMaxWidth,
  9819. panelMaxSize,
  9820. showPages: isPagesShown,
  9821. showPanel: customisedShowPanel,
  9822. isDragging: internalDraggingSizeState.isDragging
  9823. };
  9824. }, OrderedMobileNavigation = styled(MobileNavigation)({
  9825. order: 1
  9826. }), Layout = ({ managerLayoutState, setManagerLayoutState, hasTab, ...slots }) => {
  9827. let { isDesktop, isMobile: isMobile2 } = useLayout(), api = useStorybookApi(), {
  9828. navSize,
  9829. rightPanelWidth,
  9830. bottomPanelHeight,
  9831. panelPosition,
  9832. panelResizerRef,
  9833. sidebarResizerRef,
  9834. sidebarMaxWidth,
  9835. panelMaxSize,
  9836. showPages,
  9837. showPanel
  9838. } = useLayoutSyncingState({ api, managerLayoutState, setManagerLayoutState, isDesktop, hasTab });
  9839. return useLandmarkIndicator(), react_default.createElement(
  9840. LayoutContainer,
  9841. {
  9842. panelPosition: managerLayoutState.panelPosition,
  9843. showPanel,
  9844. style: {
  9845. "--nav-width": `${navSize}px`,
  9846. "--right-panel-width": `${rightPanelWidth}px`,
  9847. "--bottom-panel-height": `${bottomPanelHeight}px`
  9848. }
  9849. },
  9850. react_default.createElement(react_default.Fragment, null, isDesktop && react_default.createElement(
  9851. SidebarContainer,
  9852. {
  9853. navSize,
  9854. sidebarMaxWidth,
  9855. sidebarResizerRef
  9856. },
  9857. slots.slotSidebar
  9858. ), isMobile2 && react_default.createElement(
  9859. OrderedMobileNavigation,
  9860. {
  9861. menu: slots.slotSidebar,
  9862. panel: slots.slotPanel,
  9863. showPanel
  9864. }
  9865. ), react_default.createElement(
  9866. MainAreaContainer,
  9867. {
  9868. showPages,
  9869. slotMain: slots.slotMain,
  9870. slotPages: slots.slotPages
  9871. }
  9872. ), isDesktop && showPanel && react_default.createElement(
  9873. PanelContainer,
  9874. {
  9875. bottomPanelHeight,
  9876. rightPanelWidth,
  9877. panelMaxSize,
  9878. panelResizerRef,
  9879. position: panelPosition
  9880. },
  9881. slots.slotPanel
  9882. ), isMobile2 && react_default.createElement(Notifications, null))
  9883. );
  9884. }, LayoutContainer = styled.div(({ panelPosition, showPanel }) => ({
  9885. width: "100%",
  9886. height: ["100vh", "100dvh"],
  9887. overflow: "hidden",
  9888. display: "flex",
  9889. flexDirection: "column",
  9890. colorScheme: "light dark",
  9891. [MEDIA_DESKTOP_BREAKPOINT]: {
  9892. display: "grid",
  9893. gap: 0,
  9894. // This uses CSS variables to prevent Emotion from generating a new CSS className for every possible value
  9895. gridTemplateColumns: `minmax(0, var(--nav-width)) minmax(${100}px, 1fr) minmax(0, var(--right-panel-width))`,
  9896. gridTemplateRows: "1fr minmax(0, var(--bottom-panel-height))",
  9897. gridTemplateAreas: showPanel ? panelPosition === "right" ? `"sidebar content panel"
  9898. "sidebar content panel"` : `"sidebar content content"
  9899. "sidebar panel panel"` : `"sidebar content content"
  9900. "sidebar content content"`
  9901. }
  9902. }));
  9903. // src/manager/container/Panel.tsx
  9904. init_react();
  9905. // global-externals:storybook/internal/types
  9906. var types_default = __STORYBOOK_TYPES__, { Addon_TypesEnum, CHANGE_DETECTION_STATUS_TYPE_ID, CoreWebpackCompiler, Feature, SupportedBuilder, SupportedFramework, SupportedLanguage, SupportedRenderer } = __STORYBOOK_TYPES__;
  9907. // src/core-events/index.ts
  9908. 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 || {});
  9909. var {
  9910. CHANNEL_WS_DISCONNECT: CHANNEL_WS_DISCONNECT2,
  9911. CHANNEL_CREATED: CHANNEL_CREATED2,
  9912. CONFIG_ERROR: CONFIG_ERROR2,
  9913. CREATE_NEW_STORYFILE_REQUEST: CREATE_NEW_STORYFILE_REQUEST2,
  9914. CREATE_NEW_STORYFILE_RESPONSE: CREATE_NEW_STORYFILE_RESPONSE2,
  9915. CURRENT_STORY_WAS_SET: CURRENT_STORY_WAS_SET2,
  9916. DOCS_PREPARED: DOCS_PREPARED2,
  9917. DOCS_RENDERED: DOCS_RENDERED2,
  9918. FILE_COMPONENT_SEARCH_REQUEST: FILE_COMPONENT_SEARCH_REQUEST2,
  9919. FILE_COMPONENT_SEARCH_RESPONSE: FILE_COMPONENT_SEARCH_RESPONSE2,
  9920. FORCE_RE_RENDER: FORCE_RE_RENDER2,
  9921. FORCE_REMOUNT: FORCE_REMOUNT2,
  9922. GLOBALS_UPDATED: GLOBALS_UPDATED2,
  9923. NAVIGATE_URL: NAVIGATE_URL2,
  9924. PLAY_FUNCTION_THREW_EXCEPTION: PLAY_FUNCTION_THREW_EXCEPTION2,
  9925. UNHANDLED_ERRORS_WHILE_PLAYING: UNHANDLED_ERRORS_WHILE_PLAYING2,
  9926. PRELOAD_ENTRIES: PRELOAD_ENTRIES2,
  9927. PREVIEW_INITIALIZED: PREVIEW_INITIALIZED2,
  9928. PREVIEW_BUILDER_PROGRESS: PREVIEW_BUILDER_PROGRESS2,
  9929. PREVIEW_KEYDOWN: PREVIEW_KEYDOWN2,
  9930. REGISTER_SUBSCRIPTION: REGISTER_SUBSCRIPTION2,
  9931. RESET_STORY_ARGS: RESET_STORY_ARGS2,
  9932. SELECT_STORY: SELECT_STORY2,
  9933. SET_CONFIG: SET_CONFIG2,
  9934. SET_CURRENT_STORY: SET_CURRENT_STORY2,
  9935. SET_FILTER: SET_FILTER2,
  9936. SET_GLOBALS: SET_GLOBALS2,
  9937. SET_INDEX: SET_INDEX2,
  9938. SET_STORIES: SET_STORIES2,
  9939. SHARED_STATE_CHANGED: SHARED_STATE_CHANGED2,
  9940. SHARED_STATE_SET: SHARED_STATE_SET2,
  9941. STORIES_COLLAPSE_ALL: STORIES_COLLAPSE_ALL2,
  9942. STORIES_EXPAND_ALL: STORIES_EXPAND_ALL2,
  9943. STORY_ARGS_UPDATED: STORY_ARGS_UPDATED2,
  9944. STORY_CHANGED: STORY_CHANGED2,
  9945. STORY_ERRORED: STORY_ERRORED2,
  9946. STORY_INDEX_INVALIDATED: STORY_INDEX_INVALIDATED2,
  9947. STORY_MISSING: STORY_MISSING2,
  9948. STORY_PREPARED: STORY_PREPARED2,
  9949. STORY_RENDER_PHASE_CHANGED: STORY_RENDER_PHASE_CHANGED2,
  9950. STORY_RENDERED: STORY_RENDERED2,
  9951. STORY_FINISHED: STORY_FINISHED2,
  9952. STORY_SPECIFIED: STORY_SPECIFIED2,
  9953. STORY_THREW_EXCEPTION: STORY_THREW_EXCEPTION2,
  9954. STORY_UNCHANGED: STORY_UNCHANGED2,
  9955. STORY_HOT_UPDATED: STORY_HOT_UPDATED2,
  9956. UPDATE_GLOBALS: UPDATE_GLOBALS2,
  9957. UPDATE_QUERY_PARAMS: UPDATE_QUERY_PARAMS2,
  9958. UPDATE_STORY_ARGS: UPDATE_STORY_ARGS2,
  9959. REQUEST_WHATS_NEW_DATA: REQUEST_WHATS_NEW_DATA2,
  9960. RESULT_WHATS_NEW_DATA: RESULT_WHATS_NEW_DATA2,
  9961. SET_WHATS_NEW_CACHE: SET_WHATS_NEW_CACHE2,
  9962. TOGGLE_WHATS_NEW_NOTIFICATIONS: TOGGLE_WHATS_NEW_NOTIFICATIONS2,
  9963. TELEMETRY_ERROR: TELEMETRY_ERROR2,
  9964. SAVE_STORY_REQUEST: SAVE_STORY_REQUEST2,
  9965. SAVE_STORY_RESPONSE: SAVE_STORY_RESPONSE2,
  9966. ARGTYPES_INFO_REQUEST: ARGTYPES_INFO_REQUEST2,
  9967. ARGTYPES_INFO_RESPONSE: ARGTYPES_INFO_RESPONSE2,
  9968. GHOST_STORIES_REQUEST: GHOST_STORIES_REQUEST2,
  9969. GHOST_STORIES_RESPONSE: GHOST_STORIES_RESPONSE2,
  9970. AI_SETUP_ANALYTICS_RESPONSE: AI_SETUP_ANALYTICS_RESPONSE2,
  9971. AI_SETUP_ANALYTICS_REQUEST: AI_SETUP_ANALYTICS_REQUEST2,
  9972. OPEN_IN_EDITOR_REQUEST: OPEN_IN_EDITOR_REQUEST2,
  9973. OPEN_IN_EDITOR_RESPONSE: OPEN_IN_EDITOR_RESPONSE2,
  9974. MANAGER_INERT_ATTRIBUTE_CHANGED: MANAGER_INERT_ATTRIBUTE_CHANGED2,
  9975. SHARE_ISOLATE_MODE: SHARE_ISOLATE_MODE2,
  9976. AI_PROMPT_NUDGE: AI_PROMPT_NUDGE2,
  9977. SIDEBAR_FILTER_CHANGED: SIDEBAR_FILTER_CHANGED2
  9978. } = events;
  9979. // ../../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
  9980. function getSymbols(object) {
  9981. return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
  9982. }
  9983. // ../../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
  9984. function getTag(value) {
  9985. return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
  9986. }
  9987. // ../../node_modules/es-toolkit/dist/compat/_internal/tags.mjs
  9988. 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]";
  9989. // ../../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
  9990. function isPlainObject(value) {
  9991. if (!value || typeof value != "object")
  9992. return !1;
  9993. let proto = Object.getPrototypeOf(value);
  9994. return proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null ? Object.prototype.toString.call(value) === "[object Object]" : !1;
  9995. }
  9996. // ../../node_modules/es-toolkit/dist/string/words.mjs
  9997. 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");
  9998. // ../../node_modules/es-toolkit/dist/compat/util/eq.mjs
  9999. function eq(value, other) {
  10000. return value === other || Number.isNaN(value) && Number.isNaN(other);
  10001. }
  10002. // ../../node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
  10003. function isEqualWith(a2, b2, areValuesEqual) {
  10004. return isEqualWithImpl(a2, b2, void 0, void 0, void 0, void 0, areValuesEqual);
  10005. }
  10006. function isEqualWithImpl(a2, b2, property, aParent, bParent, stack, areValuesEqual) {
  10007. let result = areValuesEqual(a2, b2, property, aParent, bParent, stack);
  10008. if (result !== void 0)
  10009. return result;
  10010. if (typeof a2 == typeof b2)
  10011. switch (typeof a2) {
  10012. case "bigint":
  10013. case "string":
  10014. case "boolean":
  10015. case "symbol":
  10016. case "undefined":
  10017. return a2 === b2;
  10018. case "number":
  10019. return a2 === b2 || Object.is(a2, b2);
  10020. case "function":
  10021. return a2 === b2;
  10022. case "object":
  10023. return areObjectsEqual(a2, b2, stack, areValuesEqual);
  10024. }
  10025. return areObjectsEqual(a2, b2, stack, areValuesEqual);
  10026. }
  10027. function areObjectsEqual(a2, b2, stack, areValuesEqual) {
  10028. if (Object.is(a2, b2))
  10029. return !0;
  10030. let aTag = getTag(a2), bTag = getTag(b2);
  10031. if (aTag === argumentsTag && (aTag = objectTag), bTag === argumentsTag && (bTag = objectTag), aTag !== bTag)
  10032. return !1;
  10033. switch (aTag) {
  10034. case stringTag:
  10035. return a2.toString() === b2.toString();
  10036. case numberTag: {
  10037. let x2 = a2.valueOf(), y2 = b2.valueOf();
  10038. return eq(x2, y2);
  10039. }
  10040. case booleanTag:
  10041. case dateTag:
  10042. case symbolTag:
  10043. return Object.is(a2.valueOf(), b2.valueOf());
  10044. case regexpTag:
  10045. return a2.source === b2.source && a2.flags === b2.flags;
  10046. case functionTag:
  10047. return a2 === b2;
  10048. }
  10049. stack = stack ?? /* @__PURE__ */ new Map();
  10050. let aStack = stack.get(a2), bStack = stack.get(b2);
  10051. if (aStack != null && bStack != null)
  10052. return aStack === b2;
  10053. stack.set(a2, b2), stack.set(b2, a2);
  10054. try {
  10055. switch (aTag) {
  10056. case mapTag: {
  10057. if (a2.size !== b2.size)
  10058. return !1;
  10059. for (let [key, value] of a2.entries())
  10060. if (!b2.has(key) || !isEqualWithImpl(value, b2.get(key), key, a2, b2, stack, areValuesEqual))
  10061. return !1;
  10062. return !0;
  10063. }
  10064. case setTag: {
  10065. if (a2.size !== b2.size)
  10066. return !1;
  10067. let aValues = Array.from(a2.values()), bValues = Array.from(b2.values());
  10068. for (let i2 = 0; i2 < aValues.length; i2++) {
  10069. let aValue = aValues[i2], index = bValues.findIndex((bValue) => isEqualWithImpl(aValue, bValue, void 0, a2, b2, stack, areValuesEqual));
  10070. if (index === -1)
  10071. return !1;
  10072. bValues.splice(index, 1);
  10073. }
  10074. return !0;
  10075. }
  10076. case arrayTag:
  10077. case uint8ArrayTag:
  10078. case uint8ClampedArrayTag:
  10079. case uint16ArrayTag:
  10080. case uint32ArrayTag:
  10081. case bigUint64ArrayTag:
  10082. case int8ArrayTag:
  10083. case int16ArrayTag:
  10084. case int32ArrayTag:
  10085. case bigInt64ArrayTag:
  10086. case float32ArrayTag:
  10087. case float64ArrayTag: {
  10088. if (typeof Buffer < "u" && Buffer.isBuffer(a2) !== Buffer.isBuffer(b2) || a2.length !== b2.length)
  10089. return !1;
  10090. for (let i2 = 0; i2 < a2.length; i2++)
  10091. if (!isEqualWithImpl(a2[i2], b2[i2], i2, a2, b2, stack, areValuesEqual))
  10092. return !1;
  10093. return !0;
  10094. }
  10095. case arrayBufferTag:
  10096. return a2.byteLength !== b2.byteLength ? !1 : areObjectsEqual(new Uint8Array(a2), new Uint8Array(b2), stack, areValuesEqual);
  10097. case dataViewTag:
  10098. return a2.byteLength !== b2.byteLength || a2.byteOffset !== b2.byteOffset ? !1 : areObjectsEqual(new Uint8Array(a2), new Uint8Array(b2), stack, areValuesEqual);
  10099. case errorTag:
  10100. return a2.name === b2.name && a2.message === b2.message;
  10101. case objectTag: {
  10102. if (!(areObjectsEqual(a2.constructor, b2.constructor, stack, areValuesEqual) || isPlainObject(a2) && isPlainObject(b2)))
  10103. return !1;
  10104. let aKeys = [...Object.keys(a2), ...getSymbols(a2)], bKeys = [...Object.keys(b2), ...getSymbols(b2)];
  10105. if (aKeys.length !== bKeys.length)
  10106. return !1;
  10107. for (let i2 = 0; i2 < aKeys.length; i2++) {
  10108. let propKey = aKeys[i2], aProp = a2[propKey];
  10109. if (!Object.hasOwn(b2, propKey))
  10110. return !1;
  10111. let bProp = b2[propKey];
  10112. if (!isEqualWithImpl(aProp, bProp, propKey, a2, b2, stack, areValuesEqual))
  10113. return !1;
  10114. }
  10115. return !0;
  10116. }
  10117. default:
  10118. return !1;
  10119. }
  10120. } finally {
  10121. stack.delete(a2), stack.delete(b2);
  10122. }
  10123. }
  10124. // ../../node_modules/es-toolkit/dist/function/noop.mjs
  10125. function noop() {
  10126. }
  10127. // ../../node_modules/es-toolkit/dist/predicate/isEqual.mjs
  10128. function isEqual(a2, b2) {
  10129. return isEqualWith(a2, b2, noop);
  10130. }
  10131. // global-externals:storybook/theming/create
  10132. var create_default = __STORYBOOK_THEMING_CREATE__, { create: create3, themes: themes2 } = __STORYBOOK_THEMING_CREATE__;
  10133. // src/manager-api/modules/layout.ts
  10134. var { document: document2 } = scope;
  10135. var focusableUIElements = {
  10136. addonPanel: "storybook-panel-region",
  10137. storySearchField: "storybook-explorer-searchfield",
  10138. storyListMenu: "storybook-explorer-menu",
  10139. storyPanelRoot: "storybook-panel-root",
  10140. showAddonPanel: "storybook-show-addon-panel",
  10141. sidebarRegion: "storybook-sidebar-region",
  10142. showSidebar: "storybook-show-sidebar"
  10143. };
  10144. // src/manager/components/panel/Panel.tsx
  10145. init_react();
  10146. var TabErrorBoundary = class extends Component {
  10147. constructor(props) {
  10148. super(props), this.state = { hasError: !1 };
  10149. }
  10150. static getDerivedStateFromError() {
  10151. return { hasError: !0 };
  10152. }
  10153. componentDidCatch(error, info) {
  10154. console.error("Error rendering addon panel"), console.error(error), console.error(info.componentStack);
  10155. }
  10156. render() {
  10157. let { hasError } = this.state;
  10158. if (hasError)
  10159. return react_default.createElement(
  10160. EmptyTabContent,
  10161. {
  10162. title: "This addon has errors",
  10163. description: "Check your browser logs and addon code to pinpoint what went wrong. This issue was not caused by Storybook."
  10164. }
  10165. );
  10166. let { children } = this.props;
  10167. return children;
  10168. }
  10169. }, Aside = styled.aside({
  10170. height: "100%",
  10171. display: "flex",
  10172. flexDirection: "column"
  10173. });
  10174. function renderChild(RenderProp) {
  10175. return react_default.createElement(RenderProp, { active: !0 });
  10176. }
  10177. 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" }) => {
  10178. let { isDesktop, setMobilePanelOpen } = useLayout(), emptyState = react_default.createElement(
  10179. EmptyTabContent,
  10180. {
  10181. title: "Storybook add-ons",
  10182. description: react_default.createElement(react_default.Fragment, null, "Integrate your tools with Storybook to connect workflows and unlock advanced features."),
  10183. 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")
  10184. }
  10185. ), tools = useMemo(
  10186. () => react_default.createElement(ActionsWrapper, null, isDesktop ? react_default.createElement(react_default.Fragment, null, react_default.createElement(
  10187. Button,
  10188. {
  10189. key: "position",
  10190. padding: "small",
  10191. variant: "ghost",
  10192. onClick: actions.togglePosition,
  10193. ariaLabel: panelPosition === "bottom" ? "Move addon panel to right" : "Move addon panel to bottom",
  10194. 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.",
  10195. shortcut: shortcuts.panelPosition
  10196. },
  10197. panelPosition === "bottom" ? react_default.createElement(SidebarAltIcon, null) : react_default.createElement(BottomBarIcon, null)
  10198. ), react_default.createElement(
  10199. Button,
  10200. {
  10201. key: "visibility",
  10202. padding: "small",
  10203. variant: "ghost",
  10204. onClick: actions.toggleVisibility,
  10205. ariaLabel: "Hide addon panel",
  10206. shortcut: shortcuts.togglePanel
  10207. },
  10208. react_default.createElement(CloseIcon, null)
  10209. )) : react_default.createElement(
  10210. Button,
  10211. {
  10212. padding: "small",
  10213. variant: "ghost",
  10214. onClick: () => setMobilePanelOpen(!1),
  10215. ariaLabel: "Close addon panel"
  10216. },
  10217. react_default.createElement(CloseIcon, null)
  10218. )),
  10219. [actions, isDesktop, panelPosition, setMobilePanelOpen, shortcuts]
  10220. ), asideRef = useRef(null), { landmarkProps } = useLandmark(
  10221. { "aria-labelledby": "storybook-panel-heading", role: "region" },
  10222. asideRef
  10223. );
  10224. 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(
  10225. StatelessTabsView,
  10226. {
  10227. id: focusableUIElements.storyPanelRoot,
  10228. showToolsWhenEmpty: !0,
  10229. emptyState,
  10230. selected: selectedPanel ?? void 0,
  10231. onSelectionChange: (id) => actions.onSelect(id),
  10232. tools
  10233. },
  10234. 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))),
  10235. Object.keys(panels).length ? react_default.createElement(PreRenderAddons, { panels }) : null
  10236. ));
  10237. });
  10238. AddonPanel2.displayName = "AddonPanel";
  10239. var ActionsWrapper = styled.div({
  10240. display: "flex",
  10241. alignItems: "center",
  10242. gap: 6
  10243. });
  10244. // src/manager/container/Panel.tsx
  10245. var Panel = (props) => {
  10246. let api = useStorybookApi(), state = useStorybookState(), [story, setStory] = useState(api.getCurrentStoryData());
  10247. useChannel(
  10248. {
  10249. [STORY_PREPARED2]: () => {
  10250. setStory(api.getCurrentStoryData());
  10251. }
  10252. },
  10253. []
  10254. );
  10255. let { parameters, type } = story ?? {}, panelActions = useMemo(
  10256. () => ({
  10257. onSelect: (panel) => api.setSelectedPanel(panel),
  10258. toggleVisibility: async () => {
  10259. let wasPanelShown = api.getIsPanelShown();
  10260. api.togglePanel(), wasPanelShown && await api.focusOnUIElement(focusableUIElements.showAddonPanel) === !1 && document.body.focus();
  10261. },
  10262. togglePosition: () => api.togglePanelPosition()
  10263. }),
  10264. [api]
  10265. ), panels = useMemo(() => {
  10266. let allPanels = api.getElements(Addon_TypesEnum.PANEL);
  10267. if (!allPanels || type !== "story")
  10268. return allPanels;
  10269. let filteredPanels = {};
  10270. return Object.entries(allPanels).forEach(([id, p2]) => {
  10271. let { paramKey } = p2;
  10272. paramKey && parameters && parameters[paramKey] && parameters[paramKey].disable || p2.disabled === !0 || typeof p2.disabled == "function" && p2.disabled(parameters) || (filteredPanels[id] = p2);
  10273. }), filteredPanels;
  10274. }, [api, type, parameters]);
  10275. return react_default.createElement(
  10276. AddonPanel2,
  10277. {
  10278. panels,
  10279. selectedPanel: api.getSelectedPanel(),
  10280. panelPosition: state.layout.panelPosition,
  10281. actions: panelActions,
  10282. shortcuts: api.getShortcutKeys(),
  10283. ...props
  10284. }
  10285. );
  10286. }, Panel_default = Panel;
  10287. // src/manager/container/Preview.tsx
  10288. init_react();
  10289. var import_memoizerific2 = __toESM(require_memoizerific(), 1);
  10290. // src/manager/components/preview/Preview.tsx
  10291. init_react();
  10292. // src/manager/components/preview/FramesRenderer.tsx
  10293. init_react();
  10294. // src/manager/components/preview/Viewport.tsx
  10295. init_react();
  10296. // src/viewport/useViewport.ts
  10297. init_react();
  10298. // src/viewport/constants.ts
  10299. var ADDON_ID = "storybook/viewport", PARAM_KEY = "viewport", PANEL_ID = `${ADDON_ID}/panel`, TOOL_ID = `${ADDON_ID}/tool`;
  10300. // src/viewport/defaults.ts
  10301. var MINIMAL_VIEWPORTS = {
  10302. mobile1: {
  10303. name: "Small mobile",
  10304. styles: {
  10305. height: "568px",
  10306. width: "320px"
  10307. },
  10308. type: "mobile"
  10309. },
  10310. mobile2: {
  10311. name: "Large mobile",
  10312. styles: {
  10313. height: "896px",
  10314. width: "414px"
  10315. },
  10316. type: "mobile"
  10317. },
  10318. tablet: {
  10319. name: "Tablet",
  10320. styles: {
  10321. height: "1112px",
  10322. width: "834px"
  10323. },
  10324. type: "tablet"
  10325. },
  10326. desktop: {
  10327. name: "Desktop",
  10328. styles: {
  10329. height: "1024px",
  10330. width: "1280px"
  10331. },
  10332. type: "desktop"
  10333. }
  10334. };
  10335. // src/viewport/useViewport.ts
  10336. 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) => {
  10337. let keys = Object.keys(viewports), nextIndex = (current ? keys.indexOf(current) : -1) + direction;
  10338. return nextIndex < 0 ? keys[keys.length - 1] : nextIndex >= keys.length ? keys[0] : keys[nextIndex];
  10339. }, normalizeGlobal = (value, defaultIsRotated) => typeof value == "string" ? { value, isRotated: defaultIsRotated } : { value: value?.value, isRotated: value?.isRotated ?? defaultIsRotated }, parseGlobals = (globals, storyGlobals, userGlobals, options2, lastSelectedOption, disable, viewMode) => {
  10340. if (viewMode !== "story")
  10341. return {
  10342. name: "Responsive",
  10343. type: "desktop",
  10344. width: "100%",
  10345. height: "100%",
  10346. value: "100pct-100pct",
  10347. option: void 0,
  10348. isCustom: !1,
  10349. isDefault: !0,
  10350. isLocked: !0,
  10351. isRotated: !1
  10352. };
  10353. 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) || [];
  10354. if (match) {
  10355. 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;
  10356. return {
  10357. name: selection?.name ?? "Custom",
  10358. type: selection?.type ?? "other",
  10359. width: isRotated ? height : width,
  10360. height: isRotated ? width : height,
  10361. value: match,
  10362. option: void 0,
  10363. isCustom: !0,
  10364. isDefault: !1,
  10365. isLocked,
  10366. isRotated
  10367. };
  10368. }
  10369. if (value && keys.length) {
  10370. let { name, styles: styles2, type = "other" } = options2[value] ?? options2[keys[0]];
  10371. return {
  10372. name,
  10373. type,
  10374. width: isRotated ? styles2.height : styles2.width,
  10375. height: isRotated ? styles2.width : styles2.height,
  10376. value,
  10377. option: value,
  10378. isCustom: !1,
  10379. isDefault: !1,
  10380. isLocked,
  10381. isRotated
  10382. };
  10383. }
  10384. return {
  10385. name: "Responsive",
  10386. type: "desktop",
  10387. width: "100%",
  10388. height: "100%",
  10389. value: "100pct-100pct",
  10390. option: void 0,
  10391. isCustom: !1,
  10392. isDefault: !0,
  10393. isLocked,
  10394. isRotated: !1
  10395. };
  10396. }, useViewport = () => {
  10397. 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(
  10398. globals,
  10399. storyGlobals,
  10400. userGlobals,
  10401. options2,
  10402. lastSelectedOption.current,
  10403. disable,
  10404. viewMode
  10405. ), update2 = useCallback(
  10406. (input) => updateGlobals({ [PARAM_KEY]: normalizeGlobal(input, !1) }),
  10407. [updateGlobals]
  10408. ), resize = useCallback(
  10409. (width2, height2) => {
  10410. let w2 = width2.replace(/px$/, "").replace(/%$/, "pct"), h2 = height2.replace(/px$/, "").replace(/%$/, "pct"), value2 = isRotated ? `${h2}-${w2}` : `${w2}-${h2}`;
  10411. update2({ value: value2, isRotated });
  10412. },
  10413. [update2, isRotated]
  10414. );
  10415. return useEffect(() => {
  10416. parameter && option && (Object.hasOwn(options2, option) ? lastSelectedOption.current = option : (lastSelectedOption.current = void 0, PARAM_KEY in storyGlobals || update2({ value: void 0, isRotated: !1 })));
  10417. }, [parameter, storyGlobals, options2, option, update2]), useEffect(() => {
  10418. api.setAddonShortcut(ADDON_ID, {
  10419. label: "Next viewport",
  10420. defaultShortcut: ["alt", "V"],
  10421. actionName: "next",
  10422. action: () => update2({ value: cycle(options2, lastSelectedOption.current), isRotated })
  10423. }), api.setAddonShortcut(ADDON_ID, {
  10424. label: "Previous viewport",
  10425. defaultShortcut: ["alt", "shift", "V"],
  10426. actionName: "previous",
  10427. action: () => update2({ value: cycle(options2, lastSelectedOption.current, -1), isRotated })
  10428. }), api.setAddonShortcut(ADDON_ID, {
  10429. label: "Reset viewport",
  10430. defaultShortcut: ["alt", "control", "V"],
  10431. actionName: "reset",
  10432. action: () => update2({ value: void 0, isRotated: !1 })
  10433. });
  10434. }, [api, update2, options2, isRotated]), useMemo(
  10435. () => ({
  10436. name,
  10437. type,
  10438. width,
  10439. height,
  10440. value,
  10441. option,
  10442. isCustom,
  10443. isDefault,
  10444. isLocked,
  10445. isRotated,
  10446. options: options2,
  10447. lastSelectedOption: lastSelectedOption.current,
  10448. resize,
  10449. reset: () => update2({ value: void 0, isRotated: !1 }),
  10450. rotate: () => update2({ value, isRotated: !isRotated }),
  10451. select: (value2) => update2({ value: value2, isRotated })
  10452. }),
  10453. [
  10454. name,
  10455. type,
  10456. width,
  10457. height,
  10458. value,
  10459. option,
  10460. isCustom,
  10461. isDefault,
  10462. isRotated,
  10463. isLocked,
  10464. options2,
  10465. resize,
  10466. update2
  10467. ]
  10468. );
  10469. };
  10470. // src/manager/components/preview/Iframe.tsx
  10471. init_react();
  10472. var StyledIframe = styled.iframe(({ theme }) => ({
  10473. backgroundColor: theme.background.preview,
  10474. display: "block",
  10475. boxSizing: "content-box",
  10476. height: "100%",
  10477. width: "100%",
  10478. border: "none",
  10479. transition: "background-position 0s, visibility 0s",
  10480. backgroundPosition: "-1px -1px, -1px -1px, -1px -1px, -1px -1px",
  10481. margin: "auto"
  10482. }));
  10483. function IFrame(props) {
  10484. let { active, id, title: title2, src, allowFullScreen, scale, ...rest2 } = props, iFrameRef = react_default.useRef(null);
  10485. return react_default.createElement(Zoom.IFrame, { scale, active, iFrameRef }, react_default.createElement(
  10486. StyledIframe,
  10487. {
  10488. "data-is-storybook": active ? "true" : "false",
  10489. onLoad: (e2) => e2.currentTarget.setAttribute("data-is-loaded", "true"),
  10490. id,
  10491. title: title2,
  10492. src,
  10493. allow: "clipboard-write;",
  10494. allowFullScreen,
  10495. ref: iFrameRef,
  10496. ...rest2
  10497. }
  10498. ));
  10499. }
  10500. // src/manager/components/preview/NumericInput.tsx
  10501. init_react();
  10502. var Wrapper = styled.div(
  10503. ({ after: after2, before: before2, theme }) => ({
  10504. position: "relative",
  10505. display: "flex",
  10506. alignItems: "center",
  10507. width: "100%",
  10508. height: 32,
  10509. paddingInline: 9,
  10510. fontSize: theme.typography.size.s1,
  10511. color: theme.textMutedColor,
  10512. background: theme.input.background,
  10513. boxShadow: `${theme.input.border} 0 0 0 1px inset`,
  10514. borderRadius: theme.input.borderRadius,
  10515. svg: {
  10516. display: "block"
  10517. },
  10518. input: {
  10519. width: "100%",
  10520. height: "100%",
  10521. minHeight: "100%",
  10522. flex: "1 1 auto",
  10523. paddingInline: 0,
  10524. fontSize: "inherit",
  10525. background: "transparent",
  10526. border: "none",
  10527. boxShadow: "none",
  10528. color: theme.input.color,
  10529. "&:focus, &:focus-visible": {
  10530. boxShadow: "none",
  10531. outline: "none"
  10532. }
  10533. },
  10534. "input:disabled": {
  10535. background: "transparent"
  10536. },
  10537. "input + div": {
  10538. paddingInline: 0,
  10539. fontSize: "inherit"
  10540. },
  10541. "&:has(input:focus-visible)": {
  10542. outline: `2px solid ${theme.color.secondary}`,
  10543. outlineOffset: -2
  10544. },
  10545. "&:has(input:disabled)": {
  10546. background: theme.base === "light" ? theme.color.lighter : theme.input.background,
  10547. cursor: "not-allowed"
  10548. },
  10549. ...after2 && { paddingRight: 2 },
  10550. ...before2 && { paddingLeft: 2 }
  10551. })
  10552. ), NumericInput = forwardRef(function({
  10553. label,
  10554. before: before2,
  10555. after: after2,
  10556. value,
  10557. setValue,
  10558. minValue = -1 / 0,
  10559. maxValue = 1 / 0,
  10560. step = 1,
  10561. unit: fixedUnit,
  10562. baseUnit = fixedUnit,
  10563. className,
  10564. style,
  10565. ...props
  10566. }, forwardedRef) {
  10567. let baseUnitRegex = useMemo(() => baseUnit && new RegExp(`${baseUnit}$`), [baseUnit]), inputId = $bdb11010cef70236$export$f680877a34711e37(), inputRef = useRef(null), [inputValue, setInputValue] = useState(
  10568. baseUnitRegex ? value.replace(baseUnitRegex, "") : value
  10569. ), id = props.id || inputId;
  10570. useImperativeHandle(forwardedRef, () => inputRef.current);
  10571. let parseValue = useCallback(
  10572. (value2) => {
  10573. let [, inputValue2, unit = fixedUnit || baseUnit || ""] = value2.match(/(-?\d+(?:\.\d+)?)(\%|[a-z]{1,4})?$/) || [];
  10574. return { number: Math.max(minValue, Math.min(parseFloat(inputValue2), maxValue)), unit };
  10575. },
  10576. [minValue, maxValue, fixedUnit, baseUnit]
  10577. ), updateValue = useCallback(
  10578. (value2) => {
  10579. let { number, unit } = parseValue(value2);
  10580. Number.isNaN(number) ? setInputValue(value2) : (setInputValue(`${number}${unit === baseUnit ? "" : unit}`), setValue(`${number}${unit}`));
  10581. },
  10582. [parseValue, setValue, baseUnit]
  10583. ), onChange = useCallback(
  10584. (e2) => updateValue(e2.target.value),
  10585. [updateValue]
  10586. ), setInputSelection = useCallback(() => {
  10587. requestAnimationFrame(() => {
  10588. let input = inputRef.current, index = input?.value.search(/[^-\d.]/) ?? -1;
  10589. input && index >= 0 && input.setSelectionRange(index, index);
  10590. });
  10591. }, []), updateInputValue = useCallback(
  10592. () => setInputValue(baseUnitRegex ? value.replace(baseUnitRegex, "") : value),
  10593. [value, baseUnitRegex]
  10594. );
  10595. return useEffect(() => {
  10596. inputRef.current !== document.activeElement && updateInputValue();
  10597. }, [updateInputValue]), useEffect(() => {
  10598. let handleKeyDown = (e2) => {
  10599. if (e2.key !== "ArrowUp" && e2.key !== "ArrowDown")
  10600. return;
  10601. e2.preventDefault();
  10602. let { number, unit } = parseValue(inputValue);
  10603. if (!Number.isNaN(number)) {
  10604. let delta = e2.shiftKey ? step * 10 : step;
  10605. updateValue(`${e2.key === "ArrowUp" ? number + delta : number - delta}${unit}`), setInputSelection();
  10606. }
  10607. }, input = inputRef.current;
  10608. if (input)
  10609. return input.addEventListener("keydown", handleKeyDown), () => input.removeEventListener("keydown", handleKeyDown);
  10610. }, [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(
  10611. Form.Input,
  10612. {
  10613. ...props,
  10614. id,
  10615. ref: inputRef,
  10616. value: inputValue,
  10617. suffix: fixedUnit || inputValue && baseUnit,
  10618. onChange,
  10619. onFocus: setInputSelection,
  10620. onBlur: updateInputValue
  10621. }
  10622. ), after2 && react_default.createElement("div", null, after2));
  10623. });
  10624. // src/manager/components/preview/Viewport.tsx
  10625. var ViewportWrapper = styled.div(({ active, isDefault, theme }) => ({
  10626. gridArea: "1 / 1",
  10627. alignSelf: "start",
  10628. justifySelf: "start",
  10629. display: active ? "inline-flex" : "none",
  10630. flexDirection: "column",
  10631. gap: 6,
  10632. width: "100%",
  10633. height: "100%",
  10634. paddingTop: isDefault ? 0 : 6,
  10635. paddingBottom: isDefault ? 0 : 40,
  10636. paddingInline: isDefault ? 0 : 40,
  10637. '&:has([data-size-input="width"]:focus-visible)': {
  10638. "[data-dragging]": {
  10639. borderRightColor: theme.color.secondary,
  10640. boxShadow: `4px 0 5px -2px ${theme.background.hoverable}`
  10641. }
  10642. },
  10643. '&:has([data-size-input="height"]:focus-visible)': {
  10644. "[data-dragging]": {
  10645. borderBottomColor: theme.color.secondary,
  10646. boxShadow: `0 4px 5px -2px ${theme.background.hoverable}`
  10647. }
  10648. }
  10649. })), ViewportControls = styled.div({
  10650. display: "flex",
  10651. gap: 6
  10652. }), ViewportDimensions = styled.div({
  10653. display: "flex",
  10654. gap: 2
  10655. }), FrameWrapper = styled.div(({ isDefault, "data-dragging": dragging, theme }) => ({
  10656. position: "relative",
  10657. minWidth: VIEWPORT_MIN_WIDTH,
  10658. minHeight: VIEWPORT_MIN_HEIGHT,
  10659. boxSizing: "content-box",
  10660. // we're sizing the contents, not the box itself
  10661. border: `1px solid ${theme.button.border}`,
  10662. borderWidth: isDefault ? 0 : 1,
  10663. borderRadius: isDefault ? 0 : 4,
  10664. transition: "border-color 0.2s, box-shadow 0.2s",
  10665. '&:has([data-side="right"]:hover), &[data-dragging="right"]': {
  10666. borderRightColor: theme.color.secondary,
  10667. boxShadow: `4px 0 5px -2px ${theme.background.hoverable}`,
  10668. '[data-side="right"]::after': {
  10669. opacity: 1
  10670. }
  10671. },
  10672. '&:has([data-side="bottom"]:hover), &[data-dragging="bottom"]': {
  10673. borderBottomColor: theme.color.secondary,
  10674. boxShadow: `0 4px 5px -2px ${theme.background.hoverable}`,
  10675. '[data-side="bottom"]::after': {
  10676. opacity: 1
  10677. }
  10678. },
  10679. '&:has([data-side="both"]:hover), &[data-dragging="both"]': {
  10680. boxShadow: `3px 3px 5px -2px ${theme.background.hoverable}`,
  10681. "&::after, [data-side]::after": {
  10682. opacity: 1
  10683. }
  10684. },
  10685. "&::after": {
  10686. content: '""',
  10687. display: "block",
  10688. position: "absolute",
  10689. pointerEvents: "none",
  10690. bottom: 1,
  10691. right: 1,
  10692. width: 12,
  10693. height: 12,
  10694. opacity: 0,
  10695. transition: "opacity 0.2s",
  10696. background: `linear-gradient(to top left,
  10697. rgba(0,0,0,0) 0%,
  10698. rgba(0,0,0,0) calc(25% - 1px),
  10699. ${theme.color.secondary} 25%,
  10700. rgba(0,0,0,0) calc(25% + 1px),
  10701. rgba(0,0,0,0) calc(45% - 1px),
  10702. ${theme.color.secondary} 45%,
  10703. rgba(0,0,0,0) calc(45% + 1px),
  10704. rgba(0,0,0,0) 100%)`
  10705. },
  10706. iframe: {
  10707. pointerEvents: dragging === "none" ? "auto" : "none"
  10708. }
  10709. })), DragHandle2 = styled.div(
  10710. { display: "none" },
  10711. ({ theme, isDefault }) => !isDefault && {
  10712. display: "block",
  10713. position: "absolute",
  10714. fontSize: 10,
  10715. '&[data-side="both"]': {
  10716. right: -12,
  10717. bottom: -12,
  10718. width: 25,
  10719. height: 25,
  10720. cursor: "nwse-resize"
  10721. },
  10722. '&[data-side="bottom"]': {
  10723. left: 0,
  10724. right: 13,
  10725. bottom: -12,
  10726. height: 20,
  10727. cursor: "row-resize",
  10728. "&::after": {
  10729. content: "attr(data-value)",
  10730. position: "absolute",
  10731. top: "50%",
  10732. left: "50%",
  10733. transform: "translate(-50%, -50%)",
  10734. borderRadius: 4,
  10735. backgroundColor: theme.background.hoverable,
  10736. padding: "2px 4px",
  10737. opacity: 0,
  10738. transition: "opacity 0.2s"
  10739. }
  10740. },
  10741. '&[data-side="right"]': {
  10742. top: 0,
  10743. right: -12,
  10744. bottom: 13,
  10745. width: 20,
  10746. cursor: "col-resize",
  10747. "&::after": {
  10748. content: "attr(data-value)",
  10749. position: "absolute",
  10750. top: "50%",
  10751. left: "50%",
  10752. transform: "translate(-50%, -50%)",
  10753. borderRadius: 4,
  10754. backgroundColor: theme.background.hoverable,
  10755. padding: "2px 4px",
  10756. opacity: 0,
  10757. transition: "opacity 0.2s"
  10758. }
  10759. }
  10760. }
  10761. ), ScrollEdge = styled.div({
  10762. position: "absolute",
  10763. pointerEvents: "none",
  10764. width: 0,
  10765. height: 0,
  10766. '&[data-edge="right"]': {
  10767. right: -40,
  10768. height: "100%"
  10769. },
  10770. '&[data-edge="bottom"]': {
  10771. bottom: -40,
  10772. width: "100%"
  10773. },
  10774. '&[data-edge="both"]': {
  10775. right: -40,
  10776. bottom: -40
  10777. }
  10778. }), SizeInput = styled(NumericInput)({
  10779. width: 85,
  10780. height: 28,
  10781. minHeight: 28
  10782. }), Viewport = ({
  10783. active,
  10784. id,
  10785. src,
  10786. scale
  10787. }) => {
  10788. 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);
  10789. useEffect(() => {
  10790. let onDrag = (e2) => {
  10791. if (!(!targetRef.current || !dragStart.current)) {
  10792. if (dragRefX.current && (dragSide.current === "both" || dragSide.current === "right")) {
  10793. let newWidth = Math.max(VIEWPORT_MIN_WIDTH, dragStart.current[0] + e2.clientX);
  10794. targetRef.current.style.width = `${newWidth}px`, dragRefX.current.dataset.value = `${Math.round(newWidth / scale)}`;
  10795. }
  10796. if (dragRefY.current && (dragSide.current === "both" || dragSide.current === "bottom")) {
  10797. let newHeight = Math.max(VIEWPORT_MIN_HEIGHT, dragStart.current[1] + e2.clientY);
  10798. targetRef.current.style.height = `${newHeight}px`, dragRefY.current.dataset.value = `${Math.round(newHeight / scale)}`;
  10799. }
  10800. dragScrollTarget.current && dragScrollTarget.current.scrollIntoView({ block: "center", inline: "center" });
  10801. }
  10802. }, onEnd = () => {
  10803. if (window.removeEventListener("mouseup", onEnd), window.removeEventListener("mousemove", onDrag), setDragging("none"), dragStart.current = void 0, targetRef.current) {
  10804. let { clientWidth, clientHeight, dataset } = targetRef.current, scale2 = Number(dataset.scale) || 1;
  10805. resize(`${Math.round(clientWidth / scale2)}px`, `${Math.round(clientHeight / scale2)}px`);
  10806. }
  10807. }, onStart = (e2) => {
  10808. e2.preventDefault(), window.addEventListener("mouseup", onEnd), window.addEventListener("mousemove", onDrag), dragSide.current = e2.currentTarget.dataset.side, dragStart.current = [
  10809. (targetRef.current?.clientWidth ?? 0) - e2.clientX,
  10810. (targetRef.current?.clientHeight ?? 0) - e2.clientY
  10811. ], dragScrollTarget.current = targetRef.current?.querySelector(
  10812. `[data-edge="${dragSide.current}"]`
  10813. ), setDragging(dragSide.current);
  10814. }, handles = [dragRefX.current, dragRefY.current, dragRefXY.current];
  10815. return handles.forEach((el) => el?.addEventListener("mousedown", onStart)), () => handles.forEach((el) => el?.removeEventListener("mousedown", onStart));
  10816. }, [resize, scale]);
  10817. let dimensions = useMemo(() => {
  10818. let [, nx = "", ux = "px"] = width.match(/^(\d+(?:\.\d+)?)(\%|[a-z]{1,4})?$/) || [], [, ny = "", uy = "px"] = height.match(/^(\d+(?:\.\d+)?)(\%|[a-z]{1,4})?$/) || [];
  10819. return {
  10820. frame: {
  10821. width: `calc(${width} * ${scale})`,
  10822. height: `calc(${height} * ${scale})`
  10823. },
  10824. display: {
  10825. width: `${nx || width}${ux === "px" ? "" : ux}`,
  10826. height: `${ny || height}${uy === "px" ? "" : uy}`
  10827. },
  10828. locked: {
  10829. width: !nx || !ny,
  10830. height: !nx || !ny
  10831. }
  10832. };
  10833. }, [width, height, scale]);
  10834. return react_default.createElement(ViewportWrapper, { key: id, active, isDefault }, !isDefault && react_default.createElement(ViewportControls, null, react_default.createElement(ViewportDimensions, null, react_default.createElement(
  10835. SizeInput,
  10836. {
  10837. "aria-label": "Viewport width",
  10838. "data-size-input": "width",
  10839. label: "Viewport width",
  10840. before: react_default.createElement(ActionList.Action, { size: "small", readOnly: !0, "aria-hidden": !0 }, "W"),
  10841. value: width,
  10842. minValue: 0,
  10843. setValue: (value) => resize(value, height),
  10844. disabled: dimensions.locked.width
  10845. }
  10846. ), react_default.createElement(
  10847. ActionList.Button,
  10848. {
  10849. key: "viewport-rotate",
  10850. size: "small",
  10851. padding: "small",
  10852. ariaLabel: "Rotate viewport",
  10853. onClick: rotate
  10854. },
  10855. react_default.createElement(TransferIcon, null)
  10856. ), react_default.createElement(
  10857. SizeInput,
  10858. {
  10859. "aria-label": "Viewport height",
  10860. "data-size-input": "height",
  10861. label: "Viewport height",
  10862. before: react_default.createElement(ActionList.Action, { size: "small", readOnly: !0, "aria-hidden": !0 }, "H"),
  10863. value: height,
  10864. minValue: 0,
  10865. setValue: (value) => resize(width, value),
  10866. disabled: dimensions.locked.height
  10867. }
  10868. ), isCustom && lastSelectedOption && react_default.createElement(
  10869. ActionList.Button,
  10870. {
  10871. key: "viewport-restore",
  10872. size: "small",
  10873. padding: "small",
  10874. ariaLabel: "Restore viewport",
  10875. onClick: () => select(lastSelectedOption)
  10876. },
  10877. react_default.createElement(UndoIcon, null)
  10878. ))), react_default.createElement(
  10879. FrameWrapper,
  10880. {
  10881. isDefault,
  10882. "data-dragging": dragging,
  10883. "data-scale": scale,
  10884. style: isDefault ? { height: "100%", width: "100%" } : dimensions.frame,
  10885. ref: targetRef
  10886. },
  10887. react_default.createElement(
  10888. "div",
  10889. {
  10890. style: {
  10891. height: `${1 / scale * 100}%`,
  10892. width: `${1 / scale * 100}%`,
  10893. transform: scale !== 1 ? `scale(${scale})` : "none",
  10894. transformOrigin: "top left"
  10895. }
  10896. },
  10897. react_default.createElement(IFrame, { allowFullScreen: !0, active, key: id, id, title: id, src, scale: 1 }),
  10898. !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" }))
  10899. ),
  10900. !dimensions.locked.width && react_default.createElement(
  10901. DragHandle2,
  10902. {
  10903. ref: dragRefX,
  10904. isDefault,
  10905. "data-side": "right",
  10906. "data-value": dimensions.display.width
  10907. }
  10908. ),
  10909. !dimensions.locked.height && react_default.createElement(
  10910. DragHandle2,
  10911. {
  10912. ref: dragRefY,
  10913. isDefault,
  10914. "data-side": "bottom",
  10915. "data-value": dimensions.display.height
  10916. }
  10917. ),
  10918. !dimensions.locked.width && !dimensions.locked.height && react_default.createElement(DragHandle2, { ref: dragRefXY, isDefault, "data-side": "both" })
  10919. ));
  10920. };
  10921. // src/manager/components/preview/FramesRenderer.tsx
  10922. var getActive = (refId, refs) => refId && refs[refId] ? `storybook-ref-${refId}` : "storybook-preview-iframe", SkipToSidebarLink = styled(Button)(({ theme }) => ({
  10923. display: "none",
  10924. "@media (min-width: 600px)": {
  10925. position: "absolute",
  10926. display: "block",
  10927. top: 10,
  10928. right: 15,
  10929. padding: "10px 15px",
  10930. fontSize: theme.typography.size.s1,
  10931. transform: "translateY(-100px)",
  10932. "&:focus": {
  10933. transform: "translateY(0)",
  10934. zIndex: 1
  10935. }
  10936. }
  10937. })), whenSidebarIsVisible = ({ api, state }) => ({
  10938. isFullscreen: api.getIsFullscreen(),
  10939. isNavShown: api.getIsNavShown(),
  10940. selectedStoryId: state.storyId
  10941. }), styles = {
  10942. '#root [data-is-storybook="false"]': {
  10943. display: "none"
  10944. },
  10945. '#root [data-is-storybook="true"]': {
  10946. display: "block"
  10947. }
  10948. }, FramesRenderer = ({
  10949. api,
  10950. refs,
  10951. scale,
  10952. viewMode = "story",
  10953. refId,
  10954. queryParams = {},
  10955. storyId = "*"
  10956. }) => {
  10957. 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, {});
  10958. return frames["storybook-preview-iframe"] || (frames["storybook-preview-iframe"] = api.getStoryHrefs(storyId, {
  10959. queryParams: { ...queryParams, ...version3 && { version: version3 } },
  10960. refId,
  10961. viewMode
  10962. }).previewHref), refsToLoad.forEach((ref) => {
  10963. let id = `storybook-ref-${ref.id}`;
  10964. frames[id]?.startsWith(`${ref.url.replace(/\/?$/, "/")}iframe.html`) || (frames[id] = api.getStoryHrefs(storyId, {
  10965. queryParams: { ...queryParams, ...version3 && { version: version3 } },
  10966. refId: ref.id,
  10967. viewMode
  10968. }).previewHref);
  10969. }), 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 })));
  10970. };
  10971. // src/manager/components/preview/Toolbar.tsx
  10972. init_react();
  10973. var fullScreenMapper = ({ api, state }) => ({
  10974. toggle: api.toggleFullscreen,
  10975. isFullscreen: api.getIsFullscreen(),
  10976. shortcut: api.getShortcutKeys().fullScreen,
  10977. hasPanel: Object.keys(api.getElements(Addon_TypesEnum.PANEL)).length > 0,
  10978. singleStory: state.singleStory
  10979. }), fullScreenTool = {
  10980. title: "fullscreen",
  10981. id: "fullscreen",
  10982. type: types.TOOL,
  10983. // @ts-expect-error (non strict)
  10984. match: (p2) => ["story", "docs"].includes(p2.viewMode),
  10985. render: () => {
  10986. let { isMobile: isMobile2 } = useLayout();
  10987. return isMobile2 ? null : react_default.createElement(Consumer, { filter: fullScreenMapper }, ({ toggle, isFullscreen, shortcut, hasPanel, singleStory }) => (!singleStory || singleStory && hasPanel) && react_default.createElement(
  10988. Button,
  10989. {
  10990. key: "full",
  10991. padding: "small",
  10992. variant: "ghost",
  10993. onClick: () => toggle(),
  10994. ariaLabel: isFullscreen ? "Exit full screen" : "Enter full screen",
  10995. shortcut
  10996. },
  10997. isFullscreen ? react_default.createElement(CloseIcon, null) : react_default.createElement(ExpandIcon, null)
  10998. ));
  10999. }
  11000. }, ToolbarComp = react_default.memo(function({
  11001. isShown,
  11002. tools,
  11003. toolsExtra,
  11004. tabs,
  11005. tabState
  11006. }) {
  11007. let sectionRef = useRef(null), { landmarkProps } = useLandmark(
  11008. { "aria-labelledby": "sb-preview-toolbar-title", role: "region" },
  11009. sectionRef
  11010. );
  11011. return isShown && (tabs || tools || toolsExtra) ? react_default.createElement(
  11012. StyledSection,
  11013. {
  11014. className: "sb-bar",
  11015. key: "toolbar",
  11016. "data-testid": "sb-preview-toolbar",
  11017. ref: sectionRef,
  11018. ...landmarkProps
  11019. },
  11020. react_default.createElement("h2", { id: "sb-preview-toolbar-title", className: "sb-sr-only" }, "Toolbar"),
  11021. tabs.length > 1 ? react_default.createElement(react_default.Fragment, null, react_default.createElement(TabList, { state: tabState }), react_default.createElement(Separator, null)) : null,
  11022. react_default.createElement(StyledToolbar, null, react_default.createElement(Tools, { key: "left", list: tools }), react_default.createElement(Tools, { key: "right", list: toolsExtra }))
  11023. ) : null;
  11024. }), Tools = react_default.memo(function({ list }) {
  11025. return react_default.createElement(ToolGroup, null, list.filter(Boolean).map(({ render: Render, id, ...t2 }, index) => (
  11026. // @ts-expect-error (Converted from ts-ignore)
  11027. react_default.createElement(Render, { key: id || t2.key || `f-${index}` })
  11028. )));
  11029. });
  11030. function toolbarItemHasBeenExcluded(item, entry) {
  11031. let parameters = entry?.type === "story" && entry?.prepared ? entry?.parameters : {}, toolbarItemsFromStoryParameters = "toolbar" in parameters ? parameters.toolbar : void 0, { toolbar: toolbarItemsFromAddonsConfig } = addons.getConfig(), toolbarItems = merge(
  11032. toolbarItemsFromAddonsConfig || {},
  11033. toolbarItemsFromStoryParameters || {}
  11034. );
  11035. return toolbarItems ? !!toolbarItems[item?.id]?.hidden : !1;
  11036. }
  11037. function filterToolsSide(tools, entry, viewMode, location2, path, tabId) {
  11038. let filter = (item) => item && (!item.match || item.match({
  11039. storyId: entry?.id,
  11040. refId: entry?.refId,
  11041. viewMode,
  11042. location: location2,
  11043. path,
  11044. tabId
  11045. })) && !toolbarItemHasBeenExcluded(item, entry);
  11046. return tools.filter(filter);
  11047. }
  11048. var StyledSection = styled.section(({ theme }) => ({
  11049. position: "relative",
  11050. display: "flex",
  11051. alignItems: "center",
  11052. color: theme.barTextColor,
  11053. width: "100%",
  11054. flexShrink: 0,
  11055. overflowX: "auto",
  11056. overflowY: "hidden",
  11057. boxShadow: `${theme.appBorderColor} 0 -1px 0 0 inset`,
  11058. background: theme.barBg,
  11059. scrollbarColor: `${theme.barTextColor} ${theme.barBg}`,
  11060. scrollbarWidth: "thin",
  11061. zIndex: 4
  11062. })), StyledToolbar = styled(AbstractToolbar)({
  11063. flex: 1,
  11064. display: "flex",
  11065. justifyContent: "space-between",
  11066. flexWrap: "nowrap",
  11067. flexShrink: 0,
  11068. height: 40,
  11069. marginInline: 10,
  11070. gap: 30
  11071. }), ToolGroup = styled.div({
  11072. display: "flex",
  11073. whiteSpace: "nowrap",
  11074. flexBasis: "auto",
  11075. gap: 6,
  11076. alignItems: "center"
  11077. });
  11078. // src/manager/components/preview/Wrappers.tsx
  11079. init_react();
  11080. // src/manager/components/preview/utils/components.ts
  11081. var PreviewContainer = styled.div({
  11082. display: "flex",
  11083. flexDirection: "column",
  11084. width: "100%",
  11085. height: "100%",
  11086. overflow: "hidden"
  11087. }), FrameWrap = styled.main({
  11088. overflow: "auto",
  11089. width: "100%",
  11090. zIndex: 3,
  11091. background: "transparent",
  11092. flex: 1
  11093. }), CanvasWrap = styled.div(
  11094. {
  11095. alignContent: "center",
  11096. alignItems: "center",
  11097. justifyContent: "center",
  11098. justifyItems: "center",
  11099. overflow: "auto",
  11100. gridTemplateColumns: "100%",
  11101. gridTemplateRows: "100%",
  11102. position: "relative",
  11103. minWidth: "100%",
  11104. minHeight: "100%"
  11105. },
  11106. ({ show }) => ({ display: show ? "grid" : "none" })
  11107. ), UnstyledLink = styled(Link2)({
  11108. color: "inherit",
  11109. textDecoration: "inherit",
  11110. display: "inline-block"
  11111. }), DesktopOnly = styled.span({
  11112. // Hides full screen icon at mobile breakpoint defined in app.js
  11113. "@media (max-width: 599px)": {
  11114. display: "none"
  11115. }
  11116. }), IframeWrapper = styled.div(({ theme }) => ({
  11117. alignContent: "center",
  11118. alignItems: "center",
  11119. justifyContent: "center",
  11120. justifyItems: "center",
  11121. overflow: "auto",
  11122. display: "grid",
  11123. gridTemplateColumns: "100%",
  11124. gridTemplateRows: "100%",
  11125. position: "relative",
  11126. width: "100%",
  11127. height: "100%"
  11128. })), LoaderWrapper = styled.div(({ theme }) => ({
  11129. position: "absolute",
  11130. top: 0,
  11131. left: 0,
  11132. bottom: 0,
  11133. right: 0,
  11134. background: theme.background.preview,
  11135. zIndex: 1
  11136. }));
  11137. // src/manager/components/preview/Wrappers.tsx
  11138. var ApplyWrappers = ({
  11139. wrappers,
  11140. id,
  11141. storyId,
  11142. children
  11143. }) => react_default.createElement(Fragment, null, wrappers.reduceRight(
  11144. (acc, wrapper, index) => react_default.createElement(wrapper.render, { index, children: acc, id, storyId }),
  11145. children
  11146. )), defaultWrappers = [
  11147. {
  11148. id: "iframe-wrapper",
  11149. type: Addon_TypesEnum.PREVIEW,
  11150. render: (p2) => react_default.createElement(IframeWrapper, { id: "storybook-preview-wrapper" }, p2.children)
  11151. }
  11152. ];
  11153. // src/manager/components/preview/tools/zoom.tsx
  11154. init_react();
  11155. // src/manager/components/Shortcut.tsx
  11156. init_react();
  11157. var Wrapper2 = styled.span(({ theme }) => ({
  11158. display: "inline-flex",
  11159. alignItems: "center",
  11160. justifyContent: "center",
  11161. height: 16,
  11162. fontSize: "11px",
  11163. fontWeight: theme.typography.weight.regular,
  11164. background: theme.base === "light" ? "rgba(0,0,0,0.05)" : "rgba(255,255,255,0.05)",
  11165. color: theme.base === "light" ? theme.color.dark : theme.textMutedColor,
  11166. borderRadius: 2,
  11167. userSelect: "none",
  11168. pointerEvents: "none",
  11169. padding: "0 4px"
  11170. })), Key = styled.kbd(({ theme }) => ({
  11171. padding: 0,
  11172. fontFamily: theme.typography.fonts.base,
  11173. verticalAlign: "middle",
  11174. "& + &": {
  11175. marginLeft: 6
  11176. }
  11177. })), Shortcut = ({ keys }) => react_default.createElement(Wrapper2, null, keys.map((key) => react_default.createElement(Key, { key }, shortcutToHumanString([key]))));
  11178. // src/manager/components/preview/tools/zoom.tsx
  11179. 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)({
  11180. minWidth: 48
  11181. }), ZoomResetButton = styled(ActionList.Button)(
  11182. ({ $isInitialValue }) => ({
  11183. visibility: $isInitialValue ? "hidden" : void 0
  11184. })
  11185. ), Context = createContext({ value: INITIAL_ZOOM_LEVEL, set: (v2) => {
  11186. } }), ZoomInput = styled(NumericInput)({
  11187. input: {
  11188. width: 100
  11189. }
  11190. }), ZoomConsumer = Context.Consumer, ZoomProvider = class extends Component {
  11191. constructor() {
  11192. super(...arguments);
  11193. this.state = {
  11194. value: INITIAL_ZOOM_LEVEL
  11195. };
  11196. this.set = (value) => this.setState({ value });
  11197. }
  11198. render() {
  11199. let { children, shouldScale } = this.props, { set } = this, { value } = this.state;
  11200. return react_default.createElement(Context.Provider, { value: { value: shouldScale ? value : INITIAL_ZOOM_LEVEL, set } }, children);
  11201. }
  11202. }, Zoom2 = memo(function({ value, zoomIn, zoomOut, zoomTo, zoomBy }) {
  11203. let inputRef = useRef(null);
  11204. return react_default.createElement(
  11205. PopoverProvider,
  11206. {
  11207. padding: "none",
  11208. onVisibleChange: (isVisible) => {
  11209. isVisible && requestAnimationFrame(() => inputRef.current?.select());
  11210. },
  11211. popover: react_default.createElement(react_default.Fragment, null, react_default.createElement(ActionList, null, react_default.createElement(ActionList.Item, null, react_default.createElement(
  11212. ZoomInput,
  11213. {
  11214. "aria-label": "Zoom percentage",
  11215. ref: inputRef,
  11216. unit: "%",
  11217. before: react_default.createElement(ActionList.Button, { size: "small", padding: "small", readOnly: !0, "aria-hidden": !0 }, react_default.createElement(ZoomIcon, null)),
  11218. after: react_default.createElement(
  11219. ZoomResetButton,
  11220. {
  11221. size: "small",
  11222. padding: "small",
  11223. $isInitialValue: value === INITIAL_ZOOM_LEVEL,
  11224. onClick: () => zoomTo(INITIAL_ZOOM_LEVEL),
  11225. ariaLabel: "Reset zoom",
  11226. "aria-hidden": value === INITIAL_ZOOM_LEVEL
  11227. },
  11228. react_default.createElement(UndoIcon, null)
  11229. ),
  11230. value: `${Math.round(value * 100)}%`,
  11231. minValue: 1,
  11232. maxValue: 800,
  11233. setValue: (value2) => {
  11234. let zoomLevel = parseInt(value2, 10) / 100;
  11235. Number.isNaN(zoomLevel) || zoomTo(zoomLevel);
  11236. }
  11237. }
  11238. ))), react_default.createElement(ActionList, null, react_default.createElement(ActionList.Item, null, react_default.createElement(
  11239. ActionList.Action,
  11240. {
  11241. onClick: zoomIn,
  11242. ariaLabel: "Zoom in",
  11243. disabled: value >= ZOOM_LEVELS.at(-1)
  11244. },
  11245. react_default.createElement(ActionList.Text, null, "Zoom in"),
  11246. react_default.createElement(Shortcut, { keys: ["alt", "+"] })
  11247. )), react_default.createElement(ActionList.Item, null, react_default.createElement(
  11248. ActionList.Action,
  11249. {
  11250. onClick: zoomOut,
  11251. ariaLabel: "Zoom out",
  11252. disabled: value <= ZOOM_LEVELS.at(0)
  11253. },
  11254. react_default.createElement(ActionList.Text, null, "Zoom out"),
  11255. react_default.createElement(Shortcut, { keys: ["alt", "-"] })
  11256. )), 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%"))))
  11257. },
  11258. react_default.createElement(
  11259. ZoomButton,
  11260. {
  11261. padding: "small",
  11262. variant: "ghost",
  11263. ariaLabel: "Change zoom level",
  11264. pressed: value !== INITIAL_ZOOM_LEVEL,
  11265. onKeyDown: (e2) => {
  11266. 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());
  11267. },
  11268. onWheel: (e2) => {
  11269. e2.deltaY < 0 ? zoomIn() : e2.deltaY > 0 && zoomOut(), e2.preventDefault();
  11270. }
  11271. },
  11272. Math.round(value * 100),
  11273. "%"
  11274. )
  11275. );
  11276. }), ZoomWrapper = memo(function({ set, value }) {
  11277. let api = useStorybookApi(), zoomIn = useCallback(() => {
  11278. let higherZoomLevel = ZOOM_LEVELS.find((level) => level > value);
  11279. higherZoomLevel && set(higherZoomLevel);
  11280. }, [set, value]), zoomOut = useCallback(() => {
  11281. let lowerZoomLevel = ZOOM_LEVELS.findLast((level) => level < value);
  11282. lowerZoomLevel && set(lowerZoomLevel);
  11283. }, [set, value]), zoomBy = useCallback(
  11284. (delta) => {
  11285. let min = ZOOM_LEVELS[0], max = ZOOM_LEVELS[ZOOM_LEVELS.length - 1];
  11286. set(Math.max(min, Math.min(max, value + delta)));
  11287. },
  11288. [set, value]
  11289. ), zoomTo = useCallback(
  11290. (value2) => {
  11291. set(value2);
  11292. },
  11293. [set]
  11294. );
  11295. return useEffect(() => {
  11296. api.setAddonShortcut("zoom", {
  11297. label: "Zoom to 100%",
  11298. defaultShortcut: ["alt", "0"],
  11299. actionName: "zoomReset",
  11300. action: () => zoomTo(1)
  11301. }), api.setAddonShortcut("zoom", {
  11302. label: "Zoom in",
  11303. defaultShortcut: ["alt", "="],
  11304. actionName: "zoomIn",
  11305. action: zoomIn
  11306. }), api.setAddonShortcut("zoom", {
  11307. label: "Zoom in",
  11308. defaultShortcut: ["alt", "+"],
  11309. actionName: "zoomPlus",
  11310. action: zoomIn
  11311. }), api.setAddonShortcut("zoom", {
  11312. label: "Zoom out",
  11313. defaultShortcut: ["alt", "-"],
  11314. actionName: "zoomOut",
  11315. action: zoomOut
  11316. });
  11317. }, [api, zoomIn, zoomOut, zoomTo]), react_default.createElement(Zoom2, { key: "zoom", value, zoomIn, zoomOut, zoomTo, zoomBy });
  11318. }), zoomTool = {
  11319. title: "zoom",
  11320. id: "zoom",
  11321. type: types.TOOL,
  11322. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  11323. render: () => react_default.createElement(ZoomConsumer, null, (zoomContext) => react_default.createElement(ZoomWrapper, { ...zoomContext }))
  11324. };
  11325. // src/manager/components/preview/Preview.tsx
  11326. var canvasMapper = ({ state, api }) => ({
  11327. api,
  11328. storyId: state.storyId,
  11329. refId: state.refId,
  11330. viewMode: state.viewMode,
  11331. customCanvas: api.renderPreview,
  11332. queryParams: state.customQueryParams,
  11333. getElements: api.getElements,
  11334. entry: api.getData(state.storyId, state.refId),
  11335. previewInitialized: state.previewInitialized,
  11336. refs: state.refs
  11337. }), createCanvasTab = () => ({
  11338. id: "canvas",
  11339. type: types.TAB,
  11340. title: "Canvas",
  11341. route: ({ storyId, refId }) => refId ? `/story/${refId}_${storyId}` : `/story/${storyId}`,
  11342. match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),
  11343. render: () => null
  11344. }), Preview = react_default.memo(function(props) {
  11345. let {
  11346. api,
  11347. id: previewId,
  11348. options: options2,
  11349. viewMode,
  11350. storyId,
  11351. entry = void 0,
  11352. description,
  11353. baseUrl,
  11354. withLoader = !0,
  11355. tools,
  11356. toolsExtra,
  11357. tabs,
  11358. wrappers,
  11359. tabId
  11360. } = props, tabState = useTabsState({
  11361. selected: tabId ?? "canvas",
  11362. onSelectionChange: (key) => {
  11363. api.applyQueryParams({ tab: key === "canvas" ? void 0 : key });
  11364. },
  11365. tabs: tabs.map((tab, index) => ({
  11366. id: tab.id ?? `tab-${index}`,
  11367. title: tab.title,
  11368. isDisabled: !!tab.disabled,
  11369. children: () => tab.render({ active: !0 })
  11370. }))
  11371. });
  11372. tabs.length > 1 && deprecate("Addon tabs are deprecated and will be removed in Storybook 11.");
  11373. let tabContent = tabs.find((tab) => tab.id === tabId)?.render, shouldScale = viewMode === "story", { showToolbar } = options2, customisedShowToolbar = api.getShowToolbarWithCustomisations(showToolbar), previousStoryId = useRef(storyId);
  11374. useEffect(() => {
  11375. if (entry && viewMode) {
  11376. if (storyId === previousStoryId.current)
  11377. return;
  11378. if (previousStoryId.current = storyId, viewMode.match(/docs|story/)) {
  11379. let { refId, id } = entry;
  11380. api.emit(SET_CURRENT_STORY, {
  11381. storyId: id,
  11382. viewMode,
  11383. options: { target: refId }
  11384. });
  11385. }
  11386. }
  11387. }, [entry, viewMode, storyId, api]);
  11388. let mainRef = useRef(null), { landmarkProps } = useLandmark(
  11389. { "aria-labelledby": "main-preview-heading", role: "main" },
  11390. mainRef
  11391. );
  11392. 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(
  11393. ToolbarComp,
  11394. {
  11395. key: "tools",
  11396. isShown: customisedShowToolbar,
  11397. tabs,
  11398. tabState,
  11399. tools,
  11400. toolsExtra
  11401. }
  11402. ), 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 }))))));
  11403. });
  11404. var Canvas = ({ baseUrl, withLoader, wrappers }) => react_default.createElement(Consumer, { filter: canvasMapper }, ({
  11405. api,
  11406. entry,
  11407. refs,
  11408. customCanvas,
  11409. storyId,
  11410. refId,
  11411. viewMode,
  11412. queryParams,
  11413. previewInitialized
  11414. }) => {
  11415. let id = "canvas", [progress, setProgress] = useState(void 0);
  11416. useEffect(() => {
  11417. if (scope.CONFIG_TYPE === "DEVELOPMENT")
  11418. try {
  11419. addons.getChannel().on(PREVIEW_BUILDER_PROGRESS, (options2) => {
  11420. setProgress(options2);
  11421. });
  11422. } catch {
  11423. }
  11424. }, []);
  11425. let refLoading = !!refs[refId] && !refs[refId].previewInitialized, isBuilding = !(progress?.value === 1 || progress === void 0), rootLoading = !refId && (!previewInitialized || isBuilding), isLoading = entry && refLoading || rootLoading;
  11426. 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(
  11427. FramesRenderer,
  11428. {
  11429. api,
  11430. refs,
  11431. scale,
  11432. entry,
  11433. viewMode,
  11434. refId,
  11435. queryParams,
  11436. storyId
  11437. }
  11438. ))));
  11439. });
  11440. function filterTabs(panels, parameters) {
  11441. let { previewTabs } = addons.getConfig(), parametersTabs = parameters ? parameters.previewTabs : void 0;
  11442. if (previewTabs || parametersTabs) {
  11443. let tabs = merge(previewTabs || {}, parametersTabs || {}), arrTabs = Object.keys(tabs).map((key, index) => ({
  11444. index,
  11445. ...typeof tabs[key] == "string" ? { title: tabs[key] } : tabs[key],
  11446. id: key
  11447. }));
  11448. return panels.filter((panel) => {
  11449. let t2 = arrTabs.find((tab) => tab.id === panel.id);
  11450. return t2 === void 0 || t2.id === "canvas" || !t2.hidden;
  11451. }).map((panel, index) => ({ ...panel, index })).sort((p1, p2) => {
  11452. 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;
  11453. return index_1 - index_2;
  11454. }).map((panel) => {
  11455. let t2 = arrTabs.find((tab) => tab.id === panel.id);
  11456. return t2 ? {
  11457. ...panel,
  11458. title: t2.title || panel.title,
  11459. disabled: t2.disabled,
  11460. hidden: t2.hidden
  11461. } : panel;
  11462. });
  11463. }
  11464. return panels;
  11465. }
  11466. // src/manager/components/preview/tools/addons.tsx
  11467. init_react();
  11468. var SHOW_ADDON_PANEL_BUTTON_ID = "storybook-show-addon-panel", menuMapper = ({ api, state }) => ({
  11469. isVisible: api.getIsPanelShown(),
  11470. singleStory: state.singleStory,
  11471. panelPosition: state.layout.panelPosition,
  11472. showPanel: async (forceFocus) => {
  11473. api.togglePanel(!0), api.focusOnUIElement(focusableUIElements.addonPanel, {
  11474. forceFocus,
  11475. poll: !0
  11476. });
  11477. }
  11478. }), addonsTool = {
  11479. title: "addons",
  11480. id: "addons",
  11481. type: types.TOOL,
  11482. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  11483. render: () => react_default.createElement(Consumer, { filter: menuMapper }, ({ isVisible, showPanel, singleStory, panelPosition }) => !singleStory && !isVisible && react_default.createElement(react_default.Fragment, null, react_default.createElement(
  11484. Button,
  11485. {
  11486. padding: "small",
  11487. variant: "ghost",
  11488. ariaLabel: "Show addon panel",
  11489. id: SHOW_ADDON_PANEL_BUTTON_ID,
  11490. key: "addons",
  11491. onClick: () => showPanel(!1),
  11492. onKeyDown: (e2) => {
  11493. (e2.key === "Enter" || e2.key === " ") && (e2.preventDefault(), showPanel(!0));
  11494. }
  11495. },
  11496. panelPosition === "bottom" ? react_default.createElement(BottomBarIcon, null) : react_default.createElement(SidebarAltIcon, null)
  11497. )))
  11498. };
  11499. // src/manager/components/preview/tools/menu.tsx
  11500. init_react();
  11501. var menuMapper2 = ({ api, state }) => ({
  11502. isVisible: api.getIsNavShown(),
  11503. singleStory: state.singleStory,
  11504. viewMode: state.viewMode,
  11505. showSidebar: async (forceFocus) => {
  11506. api.toggleNav(!0), api.focusOnUIElement(focusableUIElements.sidebarRegion, {
  11507. forceFocus,
  11508. poll: !0
  11509. });
  11510. }
  11511. }), menuTool = {
  11512. title: "menu",
  11513. id: "menu",
  11514. type: types.TOOL,
  11515. // @ts-expect-error (non strict)
  11516. match: ({ viewMode }) => ["story", "docs"].includes(viewMode),
  11517. render: () => react_default.createElement(Consumer, { filter: menuMapper2 }, ({ isVisible, showSidebar, singleStory }) => !singleStory && !isVisible && react_default.createElement(react_default.Fragment, null, react_default.createElement(
  11518. Button,
  11519. {
  11520. padding: "small",
  11521. variant: "ghost",
  11522. ariaLabel: "Show sidebar",
  11523. id: focusableUIElements.showSidebar,
  11524. key: "menu",
  11525. onClick: () => showSidebar(!1),
  11526. onKeyDown: (e2) => {
  11527. (e2.key === "Enter" || e2.key === " ") && (e2.preventDefault(), showSidebar(!0));
  11528. }
  11529. },
  11530. react_default.createElement(MenuIcon, null)
  11531. ), react_default.createElement(Separator, null)))
  11532. };
  11533. // src/manager/components/preview/tools/open-in-editor.tsx
  11534. init_react();
  11535. var mapper2 = ({ state, api }) => {
  11536. let { storyId, refId } = state, entry = api.getData(storyId, refId);
  11537. return {
  11538. storyId,
  11539. isCompositionStory: !!refId,
  11540. importPath: entry?.importPath
  11541. };
  11542. }, openInEditorTool = {
  11543. title: "open-in-editor",
  11544. id: "open-in-editor",
  11545. type: types.TOOL,
  11546. match: ({ viewMode, tabId }) => scope.CONFIG_TYPE === "DEVELOPMENT" && (viewMode === "story" || viewMode === "docs") && !tabId,
  11547. render: () => react_default.createElement(Consumer, { filter: mapper2 }, ({ importPath, isCompositionStory }) => {
  11548. let api = useStorybookApi();
  11549. return isCompositionStory || !importPath ? null : react_default.createElement(
  11550. Button,
  11551. {
  11552. key: "open-in-editor",
  11553. onClick: () => api.openInEditor({
  11554. file: importPath
  11555. }),
  11556. ariaLabel: "Open in editor",
  11557. padding: "small",
  11558. variant: "ghost"
  11559. },
  11560. react_default.createElement(EditorIcon, null)
  11561. );
  11562. })
  11563. };
  11564. // src/manager/components/preview/tools/remount.tsx
  11565. init_react();
  11566. var StyledAnimatedButton = styled(Button)(({ theme, animating, disabled }) => ({
  11567. opacity: disabled ? 0.5 : 1,
  11568. svg: {
  11569. animation: animating ? `${theme.animation.rotate360} 1000ms ease-out` : void 0
  11570. }
  11571. })), menuMapper3 = ({ api, state }) => {
  11572. let { storyId } = state;
  11573. return {
  11574. storyId,
  11575. remount: () => api.emit(FORCE_REMOUNT, { storyId: state.storyId }),
  11576. api
  11577. };
  11578. }, remountTool = {
  11579. title: "remount",
  11580. id: "remount",
  11581. type: types.TOOL,
  11582. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  11583. render: () => react_default.createElement(Consumer, { filter: menuMapper3 }, ({ remount, storyId, api }) => {
  11584. let [isAnimating, setIsAnimating] = useState(!1), remountComponent = () => {
  11585. storyId && remount();
  11586. };
  11587. return useEffect(() => {
  11588. let handler = () => setIsAnimating(!0);
  11589. return api.on(FORCE_REMOUNT, handler), () => api.off?.(FORCE_REMOUNT, handler);
  11590. }, [api]), react_default.createElement(
  11591. StyledAnimatedButton,
  11592. {
  11593. key: "remount",
  11594. padding: "small",
  11595. variant: "ghost",
  11596. ariaLabel: "Reload story",
  11597. onClick: remountComponent,
  11598. onAnimationEnd: () => setIsAnimating(!1),
  11599. animating: isAnimating,
  11600. disabled: !storyId
  11601. },
  11602. react_default.createElement(SyncIcon, null)
  11603. );
  11604. })
  11605. };
  11606. // src/manager/components/preview/tools/share.tsx
  11607. init_react();
  11608. // ../../node_modules/qrcode.react/lib/esm/index.js
  11609. init_react();
  11610. 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) => {
  11611. for (var prop in b2 || (b2 = {}))
  11612. __hasOwnProp2.call(b2, prop) && __defNormalProp(a2, prop, b2[prop]);
  11613. if (__getOwnPropSymbols)
  11614. for (var prop of __getOwnPropSymbols(b2))
  11615. __propIsEnum.call(b2, prop) && __defNormalProp(a2, prop, b2[prop]);
  11616. return a2;
  11617. }, __objRest = (source, exclude) => {
  11618. var target = {};
  11619. for (var prop in source)
  11620. __hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0 && (target[prop] = source[prop]);
  11621. if (source != null && __getOwnPropSymbols)
  11622. for (var prop of __getOwnPropSymbols(source))
  11623. exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop) && (target[prop] = source[prop]);
  11624. return target;
  11625. };
  11626. var qrcodegen;
  11627. ((qrcodegen2) => {
  11628. let _QrCode = class _QrCode2 {
  11629. /*-- Constructor (low level) and fields --*/
  11630. // Creates a new QR Code with the given version number,
  11631. // error correction level, data codeword bytes, and mask number.
  11632. // This is a low-level API that most users should not use directly.
  11633. // A mid-level API is the encodeSegments() function.
  11634. constructor(version3, errorCorrectionLevel, dataCodewords, msk) {
  11635. if (this.version = version3, this.errorCorrectionLevel = errorCorrectionLevel, this.modules = [], this.isFunction = [], version3 < _QrCode2.MIN_VERSION || version3 > _QrCode2.MAX_VERSION)
  11636. throw new RangeError("Version value out of range");
  11637. if (msk < -1 || msk > 7)
  11638. throw new RangeError("Mask value out of range");
  11639. this.size = version3 * 4 + 17;
  11640. let row = [];
  11641. for (let i2 = 0; i2 < this.size; i2++)
  11642. row.push(!1);
  11643. for (let i2 = 0; i2 < this.size; i2++)
  11644. this.modules.push(row.slice()), this.isFunction.push(row.slice());
  11645. this.drawFunctionPatterns();
  11646. let allCodewords = this.addEccAndInterleave(dataCodewords);
  11647. if (this.drawCodewords(allCodewords), msk == -1) {
  11648. let minPenalty = 1e9;
  11649. for (let i2 = 0; i2 < 8; i2++) {
  11650. this.applyMask(i2), this.drawFormatBits(i2);
  11651. let penalty = this.getPenaltyScore();
  11652. penalty < minPenalty && (msk = i2, minPenalty = penalty), this.applyMask(i2);
  11653. }
  11654. }
  11655. assert(0 <= msk && msk <= 7), this.mask = msk, this.applyMask(msk), this.drawFormatBits(msk), this.isFunction = [];
  11656. }
  11657. /*-- Static factory functions (high level) --*/
  11658. // Returns a QR Code representing the given Unicode text string at the given error correction level.
  11659. // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
  11660. // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
  11661. // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
  11662. // ecl argument if it can be done without increasing the version.
  11663. static encodeText(text, ecl) {
  11664. let segs = qrcodegen2.QrSegment.makeSegments(text);
  11665. return _QrCode2.encodeSegments(segs, ecl);
  11666. }
  11667. // Returns a QR Code representing the given binary data at the given error correction level.
  11668. // This function always encodes using the binary segment mode, not any text mode. The maximum number of
  11669. // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
  11670. // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
  11671. static encodeBinary(data, ecl) {
  11672. let seg = qrcodegen2.QrSegment.makeBytes(data);
  11673. return _QrCode2.encodeSegments([seg], ecl);
  11674. }
  11675. /*-- Static factory functions (mid level) --*/
  11676. // Returns a QR Code representing the given segments with the given encoding parameters.
  11677. // The smallest possible QR Code version within the given range is automatically
  11678. // chosen for the output. Iff boostEcl is true, then the ECC level of the result
  11679. // may be higher than the ecl argument if it can be done without increasing the
  11680. // version. The mask number is either between 0 to 7 (inclusive) to force that
  11681. // mask, or -1 to automatically choose an appropriate mask (which may be slow).
  11682. // This function allows the user to create a custom sequence of segments that switches
  11683. // between modes (such as alphanumeric and byte) to encode text in less space.
  11684. // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
  11685. static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = !0) {
  11686. if (!(_QrCode2.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode2.MAX_VERSION) || mask < -1 || mask > 7)
  11687. throw new RangeError("Invalid value");
  11688. let version3, dataUsedBits;
  11689. for (version3 = minVersion; ; version3++) {
  11690. let dataCapacityBits2 = _QrCode2.getNumDataCodewords(version3, ecl) * 8, usedBits = QrSegment.getTotalBits(segs, version3);
  11691. if (usedBits <= dataCapacityBits2) {
  11692. dataUsedBits = usedBits;
  11693. break;
  11694. }
  11695. if (version3 >= maxVersion)
  11696. throw new RangeError("Data too long");
  11697. }
  11698. for (let newEcl of [_QrCode2.Ecc.MEDIUM, _QrCode2.Ecc.QUARTILE, _QrCode2.Ecc.HIGH])
  11699. boostEcl && dataUsedBits <= _QrCode2.getNumDataCodewords(version3, newEcl) * 8 && (ecl = newEcl);
  11700. let bb = [];
  11701. for (let seg of segs) {
  11702. appendBits(seg.mode.modeBits, 4, bb), appendBits(seg.numChars, seg.mode.numCharCountBits(version3), bb);
  11703. for (let b2 of seg.getData())
  11704. bb.push(b2);
  11705. }
  11706. assert(bb.length == dataUsedBits);
  11707. let dataCapacityBits = _QrCode2.getNumDataCodewords(version3, ecl) * 8;
  11708. 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);
  11709. for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 253)
  11710. appendBits(padByte, 8, bb);
  11711. let dataCodewords = [];
  11712. for (; dataCodewords.length * 8 < bb.length; )
  11713. dataCodewords.push(0);
  11714. return bb.forEach((b2, i2) => dataCodewords[i2 >>> 3] |= b2 << 7 - (i2 & 7)), new _QrCode2(version3, ecl, dataCodewords, mask);
  11715. }
  11716. /*-- Accessor methods --*/
  11717. // Returns the color of the module (pixel) at the given coordinates, which is false
  11718. // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
  11719. // If the given coordinates are out of bounds, then false (light) is returned.
  11720. getModule(x2, y2) {
  11721. return 0 <= x2 && x2 < this.size && 0 <= y2 && y2 < this.size && this.modules[y2][x2];
  11722. }
  11723. // Modified to expose modules for easy access
  11724. getModules() {
  11725. return this.modules;
  11726. }
  11727. /*-- Private helper methods for constructor: Drawing function modules --*/
  11728. // Reads this object's version field, and draws and marks all function modules.
  11729. drawFunctionPatterns() {
  11730. for (let i2 = 0; i2 < this.size; i2++)
  11731. this.setFunctionModule(6, i2, i2 % 2 == 0), this.setFunctionModule(i2, 6, i2 % 2 == 0);
  11732. this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
  11733. let alignPatPos = this.getAlignmentPatternPositions(), numAlign = alignPatPos.length;
  11734. for (let i2 = 0; i2 < numAlign; i2++)
  11735. for (let j2 = 0; j2 < numAlign; j2++)
  11736. i2 == 0 && j2 == 0 || i2 == 0 && j2 == numAlign - 1 || i2 == numAlign - 1 && j2 == 0 || this.drawAlignmentPattern(alignPatPos[i2], alignPatPos[j2]);
  11737. this.drawFormatBits(0), this.drawVersion();
  11738. }
  11739. // Draws two copies of the format bits (with its own error correction code)
  11740. // based on the given mask and this object's error correction level field.
  11741. drawFormatBits(mask) {
  11742. let data = this.errorCorrectionLevel.formatBits << 3 | mask, rem2 = data;
  11743. for (let i2 = 0; i2 < 10; i2++)
  11744. rem2 = rem2 << 1 ^ (rem2 >>> 9) * 1335;
  11745. let bits = (data << 10 | rem2) ^ 21522;
  11746. assert(bits >>> 15 == 0);
  11747. for (let i2 = 0; i2 <= 5; i2++)
  11748. this.setFunctionModule(8, i2, getBit(bits, i2));
  11749. this.setFunctionModule(8, 7, getBit(bits, 6)), this.setFunctionModule(8, 8, getBit(bits, 7)), this.setFunctionModule(7, 8, getBit(bits, 8));
  11750. for (let i2 = 9; i2 < 15; i2++)
  11751. this.setFunctionModule(14 - i2, 8, getBit(bits, i2));
  11752. for (let i2 = 0; i2 < 8; i2++)
  11753. this.setFunctionModule(this.size - 1 - i2, 8, getBit(bits, i2));
  11754. for (let i2 = 8; i2 < 15; i2++)
  11755. this.setFunctionModule(8, this.size - 15 + i2, getBit(bits, i2));
  11756. this.setFunctionModule(8, this.size - 8, !0);
  11757. }
  11758. // Draws two copies of the version bits (with its own error correction code),
  11759. // based on this object's version field, iff 7 <= version <= 40.
  11760. drawVersion() {
  11761. if (this.version < 7)
  11762. return;
  11763. let rem2 = this.version;
  11764. for (let i2 = 0; i2 < 12; i2++)
  11765. rem2 = rem2 << 1 ^ (rem2 >>> 11) * 7973;
  11766. let bits = this.version << 12 | rem2;
  11767. assert(bits >>> 18 == 0);
  11768. for (let i2 = 0; i2 < 18; i2++) {
  11769. let color2 = getBit(bits, i2), a2 = this.size - 11 + i2 % 3, b2 = Math.floor(i2 / 3);
  11770. this.setFunctionModule(a2, b2, color2), this.setFunctionModule(b2, a2, color2);
  11771. }
  11772. }
  11773. // Draws a 9*9 finder pattern including the border separator,
  11774. // with the center module at (x, y). Modules can be out of bounds.
  11775. drawFinderPattern(x2, y2) {
  11776. for (let dy = -4; dy <= 4; dy++)
  11777. for (let dx = -4; dx <= 4; dx++) {
  11778. let dist = Math.max(Math.abs(dx), Math.abs(dy)), xx = x2 + dx, yy = y2 + dy;
  11779. 0 <= xx && xx < this.size && 0 <= yy && yy < this.size && this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
  11780. }
  11781. }
  11782. // Draws a 5*5 alignment pattern, with the center module
  11783. // at (x, y). All modules must be in bounds.
  11784. drawAlignmentPattern(x2, y2) {
  11785. for (let dy = -2; dy <= 2; dy++)
  11786. for (let dx = -2; dx <= 2; dx++)
  11787. this.setFunctionModule(x2 + dx, y2 + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
  11788. }
  11789. // Sets the color of a module and marks it as a function module.
  11790. // Only used by the constructor. Coordinates must be in bounds.
  11791. setFunctionModule(x2, y2, isDark) {
  11792. this.modules[y2][x2] = isDark, this.isFunction[y2][x2] = !0;
  11793. }
  11794. /*-- Private helper methods for constructor: Codewords and masking --*/
  11795. // Returns a new byte string representing the given data with the appropriate error correction
  11796. // codewords appended to it, based on this object's version and error correction level.
  11797. addEccAndInterleave(data) {
  11798. let ver = this.version, ecl = this.errorCorrectionLevel;
  11799. if (data.length != _QrCode2.getNumDataCodewords(ver, ecl))
  11800. throw new RangeError("Invalid argument");
  11801. 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);
  11802. for (let i2 = 0, k2 = 0; i2 < numBlocks; i2++) {
  11803. let dat = data.slice(k2, k2 + shortBlockLen - blockEccLen + (i2 < numShortBlocks ? 0 : 1));
  11804. k2 += dat.length;
  11805. let ecc = _QrCode2.reedSolomonComputeRemainder(dat, rsDiv);
  11806. i2 < numShortBlocks && dat.push(0), blocks.push(dat.concat(ecc));
  11807. }
  11808. let result = [];
  11809. for (let i2 = 0; i2 < blocks[0].length; i2++)
  11810. blocks.forEach((block, j2) => {
  11811. (i2 != shortBlockLen - blockEccLen || j2 >= numShortBlocks) && result.push(block[i2]);
  11812. });
  11813. return assert(result.length == rawCodewords), result;
  11814. }
  11815. // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
  11816. // data area of this QR Code. Function modules need to be marked off before this is called.
  11817. drawCodewords(data) {
  11818. if (data.length != Math.floor(_QrCode2.getNumRawDataModules(this.version) / 8))
  11819. throw new RangeError("Invalid argument");
  11820. let i2 = 0;
  11821. for (let right = this.size - 1; right >= 1; right -= 2) {
  11822. right == 6 && (right = 5);
  11823. for (let vert = 0; vert < this.size; vert++)
  11824. for (let j2 = 0; j2 < 2; j2++) {
  11825. let x2 = right - j2, y2 = (right + 1 & 2) == 0 ? this.size - 1 - vert : vert;
  11826. !this.isFunction[y2][x2] && i2 < data.length * 8 && (this.modules[y2][x2] = getBit(data[i2 >>> 3], 7 - (i2 & 7)), i2++);
  11827. }
  11828. }
  11829. assert(i2 == data.length * 8);
  11830. }
  11831. // XORs the codeword modules in this QR Code with the given mask pattern.
  11832. // The function modules must be marked and the codeword bits must be drawn
  11833. // before masking. Due to the arithmetic of XOR, calling applyMask() with
  11834. // the same mask value a second time will undo the mask. A final well-formed
  11835. // QR Code needs exactly one (not zero, two, etc.) mask applied.
  11836. applyMask(mask) {
  11837. if (mask < 0 || mask > 7)
  11838. throw new RangeError("Mask value out of range");
  11839. for (let y2 = 0; y2 < this.size; y2++)
  11840. for (let x2 = 0; x2 < this.size; x2++) {
  11841. let invert2;
  11842. switch (mask) {
  11843. case 0:
  11844. invert2 = (x2 + y2) % 2 == 0;
  11845. break;
  11846. case 1:
  11847. invert2 = y2 % 2 == 0;
  11848. break;
  11849. case 2:
  11850. invert2 = x2 % 3 == 0;
  11851. break;
  11852. case 3:
  11853. invert2 = (x2 + y2) % 3 == 0;
  11854. break;
  11855. case 4:
  11856. invert2 = (Math.floor(x2 / 3) + Math.floor(y2 / 2)) % 2 == 0;
  11857. break;
  11858. case 5:
  11859. invert2 = x2 * y2 % 2 + x2 * y2 % 3 == 0;
  11860. break;
  11861. case 6:
  11862. invert2 = (x2 * y2 % 2 + x2 * y2 % 3) % 2 == 0;
  11863. break;
  11864. case 7:
  11865. invert2 = ((x2 + y2) % 2 + x2 * y2 % 3) % 2 == 0;
  11866. break;
  11867. default:
  11868. throw new Error("Unreachable");
  11869. }
  11870. !this.isFunction[y2][x2] && invert2 && (this.modules[y2][x2] = !this.modules[y2][x2]);
  11871. }
  11872. }
  11873. // Calculates and returns the penalty score based on state of this QR Code's current modules.
  11874. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
  11875. getPenaltyScore() {
  11876. let result = 0;
  11877. for (let y2 = 0; y2 < this.size; y2++) {
  11878. let runColor = !1, runX = 0, runHistory = [0, 0, 0, 0, 0, 0, 0];
  11879. for (let x2 = 0; x2 < this.size; x2++)
  11880. 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);
  11881. result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode2.PENALTY_N3;
  11882. }
  11883. for (let x2 = 0; x2 < this.size; x2++) {
  11884. let runColor = !1, runY = 0, runHistory = [0, 0, 0, 0, 0, 0, 0];
  11885. for (let y2 = 0; y2 < this.size; y2++)
  11886. 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);
  11887. result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode2.PENALTY_N3;
  11888. }
  11889. for (let y2 = 0; y2 < this.size - 1; y2++)
  11890. for (let x2 = 0; x2 < this.size - 1; x2++) {
  11891. let color2 = this.modules[y2][x2];
  11892. color2 == this.modules[y2][x2 + 1] && color2 == this.modules[y2 + 1][x2] && color2 == this.modules[y2 + 1][x2 + 1] && (result += _QrCode2.PENALTY_N2);
  11893. }
  11894. let dark = 0;
  11895. for (let row of this.modules)
  11896. dark = row.reduce((sum, color2) => sum + (color2 ? 1 : 0), dark);
  11897. let total = this.size * this.size, k2 = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
  11898. return assert(0 <= k2 && k2 <= 9), result += k2 * _QrCode2.PENALTY_N4, assert(0 <= result && result <= 2568888), result;
  11899. }
  11900. /*-- Private helper functions --*/
  11901. // Returns an ascending list of positions of alignment patterns for this version number.
  11902. // Each position is in the range [0,177), and are used on both the x and y axes.
  11903. // This could be implemented as lookup table of 40 variable-length lists of integers.
  11904. getAlignmentPatternPositions() {
  11905. if (this.version == 1)
  11906. return [];
  11907. {
  11908. 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];
  11909. for (let pos = this.size - 7; result.length < numAlign; pos -= step)
  11910. result.splice(1, 0, pos);
  11911. return result;
  11912. }
  11913. }
  11914. // Returns the number of data bits that can be stored in a QR Code of the given version number, after
  11915. // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
  11916. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
  11917. static getNumRawDataModules(ver) {
  11918. if (ver < _QrCode2.MIN_VERSION || ver > _QrCode2.MAX_VERSION)
  11919. throw new RangeError("Version number out of range");
  11920. let result = (16 * ver + 128) * ver + 64;
  11921. if (ver >= 2) {
  11922. let numAlign = Math.floor(ver / 7) + 2;
  11923. result -= (25 * numAlign - 10) * numAlign - 55, ver >= 7 && (result -= 36);
  11924. }
  11925. return assert(208 <= result && result <= 29648), result;
  11926. }
  11927. // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
  11928. // QR Code of the given version number and error correction level, with remainder bits discarded.
  11929. // This stateless pure function could be implemented as a (40*4)-cell lookup table.
  11930. static getNumDataCodewords(ver, ecl) {
  11931. return Math.floor(_QrCode2.getNumRawDataModules(ver) / 8) - _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
  11932. }
  11933. // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
  11934. // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
  11935. static reedSolomonComputeDivisor(degree) {
  11936. if (degree < 1 || degree > 255)
  11937. throw new RangeError("Degree out of range");
  11938. let result = [];
  11939. for (let i2 = 0; i2 < degree - 1; i2++)
  11940. result.push(0);
  11941. result.push(1);
  11942. let root2 = 1;
  11943. for (let i2 = 0; i2 < degree; i2++) {
  11944. for (let j2 = 0; j2 < result.length; j2++)
  11945. result[j2] = _QrCode2.reedSolomonMultiply(result[j2], root2), j2 + 1 < result.length && (result[j2] ^= result[j2 + 1]);
  11946. root2 = _QrCode2.reedSolomonMultiply(root2, 2);
  11947. }
  11948. return result;
  11949. }
  11950. // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
  11951. static reedSolomonComputeRemainder(data, divisor) {
  11952. let result = divisor.map((_2) => 0);
  11953. for (let b2 of data) {
  11954. let factor = b2 ^ result.shift();
  11955. result.push(0), divisor.forEach((coef, i2) => result[i2] ^= _QrCode2.reedSolomonMultiply(coef, factor));
  11956. }
  11957. return result;
  11958. }
  11959. // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
  11960. // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
  11961. static reedSolomonMultiply(x2, y2) {
  11962. if (x2 >>> 8 || y2 >>> 8)
  11963. throw new RangeError("Byte out of range");
  11964. let z2 = 0;
  11965. for (let i2 = 7; i2 >= 0; i2--)
  11966. z2 = z2 << 1 ^ (z2 >>> 7) * 285, z2 ^= (y2 >>> i2 & 1) * x2;
  11967. return assert(z2 >>> 8 == 0), z2;
  11968. }
  11969. // Can only be called immediately after a light run is added, and
  11970. // returns either 0, 1, or 2. A helper function for getPenaltyScore().
  11971. finderPenaltyCountPatterns(runHistory) {
  11972. let n3 = runHistory[1];
  11973. assert(n3 <= this.size * 3);
  11974. let core = n3 > 0 && runHistory[2] == n3 && runHistory[3] == n3 * 3 && runHistory[4] == n3 && runHistory[5] == n3;
  11975. return (core && runHistory[0] >= n3 * 4 && runHistory[6] >= n3 ? 1 : 0) + (core && runHistory[6] >= n3 * 4 && runHistory[0] >= n3 ? 1 : 0);
  11976. }
  11977. // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
  11978. finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
  11979. return currentRunColor && (this.finderPenaltyAddHistory(currentRunLength, runHistory), currentRunLength = 0), currentRunLength += this.size, this.finderPenaltyAddHistory(currentRunLength, runHistory), this.finderPenaltyCountPatterns(runHistory);
  11980. }
  11981. // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
  11982. finderPenaltyAddHistory(currentRunLength, runHistory) {
  11983. runHistory[0] == 0 && (currentRunLength += this.size), runHistory.pop(), runHistory.unshift(currentRunLength);
  11984. }
  11985. };
  11986. _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 = [
  11987. // Version: (note that index 0 is for padding, and is set to an illegal value)
  11988. //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
  11989. [-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],
  11990. // Low
  11991. [-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],
  11992. // Medium
  11993. [-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],
  11994. // Quartile
  11995. [-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]
  11996. // High
  11997. ], _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
  11998. // Version: (note that index 0 is for padding, and is set to an illegal value)
  11999. //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
  12000. [-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],
  12001. // Low
  12002. [-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],
  12003. // Medium
  12004. [-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],
  12005. // Quartile
  12006. [-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]
  12007. // High
  12008. ];
  12009. let QrCode = _QrCode;
  12010. qrcodegen2.QrCode = _QrCode;
  12011. function appendBits(val, len, bb) {
  12012. if (len < 0 || len > 31 || val >>> len)
  12013. throw new RangeError("Value out of range");
  12014. for (let i2 = len - 1; i2 >= 0; i2--)
  12015. bb.push(val >>> i2 & 1);
  12016. }
  12017. function getBit(x2, i2) {
  12018. return (x2 >>> i2 & 1) != 0;
  12019. }
  12020. function assert(cond) {
  12021. if (!cond)
  12022. throw new Error("Assertion error");
  12023. }
  12024. let _QrSegment = class _QrSegment2 {
  12025. /*-- Constructor (low level) and fields --*/
  12026. // Creates a new QR Code segment with the given attributes and data.
  12027. // The character count (numChars) must agree with the mode and the bit buffer length,
  12028. // but the constraint isn't checked. The given bit buffer is cloned and stored.
  12029. constructor(mode, numChars, bitData) {
  12030. if (this.mode = mode, this.numChars = numChars, this.bitData = bitData, numChars < 0)
  12031. throw new RangeError("Invalid argument");
  12032. this.bitData = bitData.slice();
  12033. }
  12034. /*-- Static factory functions (mid level) --*/
  12035. // Returns a segment representing the given binary data encoded in
  12036. // byte mode. All input byte arrays are acceptable. Any text string
  12037. // can be converted to UTF-8 bytes and encoded as a byte mode segment.
  12038. static makeBytes(data) {
  12039. let bb = [];
  12040. for (let b2 of data)
  12041. appendBits(b2, 8, bb);
  12042. return new _QrSegment2(_QrSegment2.Mode.BYTE, data.length, bb);
  12043. }
  12044. // Returns a segment representing the given string of decimal digits encoded in numeric mode.
  12045. static makeNumeric(digits) {
  12046. if (!_QrSegment2.isNumeric(digits))
  12047. throw new RangeError("String contains non-numeric characters");
  12048. let bb = [];
  12049. for (let i2 = 0; i2 < digits.length; ) {
  12050. let n3 = Math.min(digits.length - i2, 3);
  12051. appendBits(parseInt(digits.substring(i2, i2 + n3), 10), n3 * 3 + 1, bb), i2 += n3;
  12052. }
  12053. return new _QrSegment2(_QrSegment2.Mode.NUMERIC, digits.length, bb);
  12054. }
  12055. // Returns a segment representing the given text string encoded in alphanumeric mode.
  12056. // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
  12057. // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
  12058. static makeAlphanumeric(text) {
  12059. if (!_QrSegment2.isAlphanumeric(text))
  12060. throw new RangeError("String contains unencodable characters in alphanumeric mode");
  12061. let bb = [], i2;
  12062. for (i2 = 0; i2 + 2 <= text.length; i2 += 2) {
  12063. let temp = _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i2)) * 45;
  12064. temp += _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i2 + 1)), appendBits(temp, 11, bb);
  12065. }
  12066. return i2 < text.length && appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i2)), 6, bb), new _QrSegment2(_QrSegment2.Mode.ALPHANUMERIC, text.length, bb);
  12067. }
  12068. // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
  12069. // The result may use various segment modes and switch modes to optimize the length of the bit stream.
  12070. static makeSegments(text) {
  12071. return text == "" ? [] : _QrSegment2.isNumeric(text) ? [_QrSegment2.makeNumeric(text)] : _QrSegment2.isAlphanumeric(text) ? [_QrSegment2.makeAlphanumeric(text)] : [_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))];
  12072. }
  12073. // Returns a segment representing an Extended Channel Interpretation
  12074. // (ECI) designator with the given assignment value.
  12075. static makeEci(assignVal) {
  12076. let bb = [];
  12077. if (assignVal < 0)
  12078. throw new RangeError("ECI assignment value out of range");
  12079. if (assignVal < 128)
  12080. appendBits(assignVal, 8, bb);
  12081. else if (assignVal < 16384)
  12082. appendBits(2, 2, bb), appendBits(assignVal, 14, bb);
  12083. else if (assignVal < 1e6)
  12084. appendBits(6, 3, bb), appendBits(assignVal, 21, bb);
  12085. else
  12086. throw new RangeError("ECI assignment value out of range");
  12087. return new _QrSegment2(_QrSegment2.Mode.ECI, 0, bb);
  12088. }
  12089. // Tests whether the given string can be encoded as a segment in numeric mode.
  12090. // A string is encodable iff each character is in the range 0 to 9.
  12091. static isNumeric(text) {
  12092. return _QrSegment2.NUMERIC_REGEX.test(text);
  12093. }
  12094. // Tests whether the given string can be encoded as a segment in alphanumeric mode.
  12095. // A string is encodable iff each character is in the following set: 0 to 9, A to Z
  12096. // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
  12097. static isAlphanumeric(text) {
  12098. return _QrSegment2.ALPHANUMERIC_REGEX.test(text);
  12099. }
  12100. /*-- Methods --*/
  12101. // Returns a new copy of the data bits of this segment.
  12102. getData() {
  12103. return this.bitData.slice();
  12104. }
  12105. // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
  12106. // the given version. The result is infinity if a segment has too many characters to fit its length field.
  12107. static getTotalBits(segs, version3) {
  12108. let result = 0;
  12109. for (let seg of segs) {
  12110. let ccbits = seg.mode.numCharCountBits(version3);
  12111. if (seg.numChars >= 1 << ccbits)
  12112. return 1 / 0;
  12113. result += 4 + ccbits + seg.bitData.length;
  12114. }
  12115. return result;
  12116. }
  12117. // Returns a new array of bytes representing the given string encoded in UTF-8.
  12118. static toUtf8ByteArray(str) {
  12119. str = encodeURI(str);
  12120. let result = [];
  12121. for (let i2 = 0; i2 < str.length; i2++)
  12122. str.charAt(i2) != "%" ? result.push(str.charCodeAt(i2)) : (result.push(parseInt(str.substring(i2 + 1, i2 + 3), 16)), i2 += 2);
  12123. return result;
  12124. }
  12125. };
  12126. _QrSegment.NUMERIC_REGEX = /^[0-9]*$/, _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, _QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
  12127. let QrSegment = _QrSegment;
  12128. qrcodegen2.QrSegment = _QrSegment;
  12129. })(qrcodegen || (qrcodegen = {}));
  12130. ((qrcodegen2) => {
  12131. let QrCode;
  12132. ((QrCode2) => {
  12133. let _Ecc = class {
  12134. // The QR Code can tolerate about 30% erroneous codewords
  12135. /*-- Constructor and fields --*/
  12136. constructor(ordinal, formatBits) {
  12137. this.ordinal = ordinal, this.formatBits = formatBits;
  12138. }
  12139. };
  12140. _Ecc.LOW = new _Ecc(0, 1), _Ecc.MEDIUM = new _Ecc(1, 0), _Ecc.QUARTILE = new _Ecc(2, 3), _Ecc.HIGH = new _Ecc(3, 2);
  12141. let Ecc = _Ecc;
  12142. QrCode2.Ecc = _Ecc;
  12143. })(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
  12144. })(qrcodegen || (qrcodegen = {}));
  12145. ((qrcodegen2) => {
  12146. let QrSegment;
  12147. ((QrSegment2) => {
  12148. let _Mode = class {
  12149. /*-- Constructor and fields --*/
  12150. constructor(modeBits, numBitsCharCount) {
  12151. this.modeBits = modeBits, this.numBitsCharCount = numBitsCharCount;
  12152. }
  12153. /*-- Method --*/
  12154. // (Package-private) Returns the bit width of the character count field for a segment in
  12155. // this mode in a QR Code at the given version number. The result is in the range [0, 16].
  12156. numCharCountBits(ver) {
  12157. return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
  12158. }
  12159. };
  12160. _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]);
  12161. let Mode = _Mode;
  12162. QrSegment2.Mode = _Mode;
  12163. })(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
  12164. })(qrcodegen || (qrcodegen = {}));
  12165. var qrcodegen_default = qrcodegen;
  12166. var ERROR_LEVEL_MAP = {
  12167. L: qrcodegen_default.QrCode.Ecc.LOW,
  12168. M: qrcodegen_default.QrCode.Ecc.MEDIUM,
  12169. Q: qrcodegen_default.QrCode.Ecc.QUARTILE,
  12170. H: qrcodegen_default.QrCode.Ecc.HIGH
  12171. }, 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;
  12172. function generatePath(modules, margin = 0) {
  12173. let ops = [];
  12174. return modules.forEach(function(row, y2) {
  12175. let start = null;
  12176. row.forEach(function(cell, x2) {
  12177. if (!cell && start !== null) {
  12178. ops.push(
  12179. `M${start + margin} ${y2 + margin}h${x2 - start}v1H${start + margin}z`
  12180. ), start = null;
  12181. return;
  12182. }
  12183. if (x2 === row.length - 1) {
  12184. if (!cell)
  12185. return;
  12186. start === null ? ops.push(`M${x2 + margin},${y2 + margin} h1v1H${x2 + margin}z`) : ops.push(
  12187. `M${start + margin},${y2 + margin} h${x2 + 1 - start}v1H${start + margin}z`
  12188. );
  12189. return;
  12190. }
  12191. cell && start === null && (start = x2);
  12192. });
  12193. }), ops.join("");
  12194. }
  12195. function excavateModules(modules, excavation) {
  12196. 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));
  12197. }
  12198. function getImageSettings(cells, size, margin, imageSettings) {
  12199. if (imageSettings == null)
  12200. return null;
  12201. 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;
  12202. if (imageSettings.excavate) {
  12203. let floorX = Math.floor(x2), floorY = Math.floor(y2), ceilW = Math.ceil(w2 + x2 - floorX), ceilH = Math.ceil(h2 + y2 - floorY);
  12204. excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
  12205. }
  12206. let crossOrigin = imageSettings.crossOrigin;
  12207. return { x: x2, y: y2, h: h2, w: w2, excavation, opacity, crossOrigin };
  12208. }
  12209. function getMarginSize(includeMargin, marginSize) {
  12210. return marginSize != null ? Math.max(Math.floor(marginSize), 0) : includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
  12211. }
  12212. function useQRCode({
  12213. value,
  12214. level,
  12215. minVersion,
  12216. includeMargin,
  12217. marginSize,
  12218. imageSettings,
  12219. size,
  12220. boostLevel
  12221. }) {
  12222. let qrcode = react_default.useMemo(() => {
  12223. let segments = (Array.isArray(value) ? value : [value]).reduce((accum, v2) => (accum.push(...qrcodegen_default.QrSegment.makeSegments(v2)), accum), []);
  12224. return qrcodegen_default.QrCode.encodeSegments(
  12225. segments,
  12226. ERROR_LEVEL_MAP[level],
  12227. minVersion,
  12228. void 0,
  12229. void 0,
  12230. boostLevel
  12231. );
  12232. }, [value, level, minVersion, boostLevel]), { cells, margin, numCells, calculatedImageSettings } = react_default.useMemo(() => {
  12233. let cells2 = qrcode.getModules(), margin2 = getMarginSize(includeMargin, marginSize), numCells2 = cells2.length + margin2 * 2, calculatedImageSettings2 = getImageSettings(
  12234. cells2,
  12235. size,
  12236. margin2,
  12237. imageSettings
  12238. );
  12239. return {
  12240. cells: cells2,
  12241. margin: margin2,
  12242. numCells: numCells2,
  12243. calculatedImageSettings: calculatedImageSettings2
  12244. };
  12245. }, [qrcode, size, imageSettings, includeMargin, marginSize]);
  12246. return {
  12247. qrcode,
  12248. margin,
  12249. cells,
  12250. numCells,
  12251. calculatedImageSettings
  12252. };
  12253. }
  12254. var SUPPORTS_PATH2D = (function() {
  12255. try {
  12256. new Path2D().addPath(new Path2D());
  12257. } catch {
  12258. return !1;
  12259. }
  12260. return !0;
  12261. })(), QRCodeCanvas = react_default.forwardRef(
  12262. function(props, forwardedRef) {
  12263. let _a2 = props, {
  12264. value,
  12265. size = DEFAULT_SIZE,
  12266. level = DEFAULT_LEVEL,
  12267. bgColor = DEFAULT_BGCOLOR,
  12268. fgColor = DEFAULT_FGCOLOR,
  12269. includeMargin = DEFAULT_INCLUDEMARGIN,
  12270. minVersion = DEFAULT_MINVERSION,
  12271. boostLevel,
  12272. marginSize,
  12273. imageSettings
  12274. } = _a2, _b = __objRest(_a2, [
  12275. "value",
  12276. "size",
  12277. "level",
  12278. "bgColor",
  12279. "fgColor",
  12280. "includeMargin",
  12281. "minVersion",
  12282. "boostLevel",
  12283. "marginSize",
  12284. "imageSettings"
  12285. ]), { style } = _b, otherProps = __objRest(_b, ["style"]), imgSrc = imageSettings?.src, _canvas = react_default.useRef(null), _image = react_default.useRef(null), setCanvasRef = react_default.useCallback(
  12286. (node) => {
  12287. _canvas.current = node, typeof forwardedRef == "function" ? forwardedRef(node) : forwardedRef && (forwardedRef.current = node);
  12288. },
  12289. [forwardedRef]
  12290. ), [isImgLoaded, setIsImageLoaded] = react_default.useState(!1), { margin, cells, numCells, calculatedImageSettings } = useQRCode({
  12291. value,
  12292. level,
  12293. minVersion,
  12294. boostLevel,
  12295. includeMargin,
  12296. marginSize,
  12297. imageSettings,
  12298. size
  12299. });
  12300. react_default.useEffect(() => {
  12301. if (_canvas.current != null) {
  12302. let canvas = _canvas.current, ctx = canvas.getContext("2d");
  12303. if (!ctx)
  12304. return;
  12305. let cellsToDraw = cells, image = _image.current, haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
  12306. haveImageToRender && calculatedImageSettings.excavation != null && (cellsToDraw = excavateModules(
  12307. cells,
  12308. calculatedImageSettings.excavation
  12309. ));
  12310. let pixelRatio = window.devicePixelRatio || 1;
  12311. canvas.height = canvas.width = size * pixelRatio;
  12312. let scale = size / numCells * pixelRatio;
  12313. 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) {
  12314. row.forEach(function(cell, cdx) {
  12315. cell && ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
  12316. });
  12317. }), calculatedImageSettings && (ctx.globalAlpha = calculatedImageSettings.opacity), haveImageToRender && ctx.drawImage(
  12318. image,
  12319. calculatedImageSettings.x + margin,
  12320. calculatedImageSettings.y + margin,
  12321. calculatedImageSettings.w,
  12322. calculatedImageSettings.h
  12323. );
  12324. }
  12325. }), react_default.useEffect(() => {
  12326. setIsImageLoaded(!1);
  12327. }, [imgSrc]);
  12328. let canvasStyle = __spreadValues({ height: size, width: size }, style), img = null;
  12329. return imgSrc != null && (img = react_default.createElement(
  12330. "img",
  12331. {
  12332. src: imgSrc,
  12333. key: imgSrc,
  12334. style: { display: "none" },
  12335. onLoad: () => {
  12336. setIsImageLoaded(!0);
  12337. },
  12338. ref: _image,
  12339. crossOrigin: calculatedImageSettings?.crossOrigin
  12340. }
  12341. )), react_default.createElement(react_default.Fragment, null, react_default.createElement(
  12342. "canvas",
  12343. __spreadValues({
  12344. style: canvasStyle,
  12345. height: size,
  12346. width: size,
  12347. ref: setCanvasRef,
  12348. role: "img"
  12349. }, otherProps)
  12350. ), img);
  12351. }
  12352. );
  12353. QRCodeCanvas.displayName = "QRCodeCanvas";
  12354. var QRCodeSVG = react_default.forwardRef(
  12355. function(props, forwardedRef) {
  12356. let _a2 = props, {
  12357. value,
  12358. size = DEFAULT_SIZE,
  12359. level = DEFAULT_LEVEL,
  12360. bgColor = DEFAULT_BGCOLOR,
  12361. fgColor = DEFAULT_FGCOLOR,
  12362. includeMargin = DEFAULT_INCLUDEMARGIN,
  12363. minVersion = DEFAULT_MINVERSION,
  12364. boostLevel,
  12365. title: title2,
  12366. marginSize,
  12367. imageSettings
  12368. } = _a2, otherProps = __objRest(_a2, [
  12369. "value",
  12370. "size",
  12371. "level",
  12372. "bgColor",
  12373. "fgColor",
  12374. "includeMargin",
  12375. "minVersion",
  12376. "boostLevel",
  12377. "title",
  12378. "marginSize",
  12379. "imageSettings"
  12380. ]), { margin, cells, numCells, calculatedImageSettings } = useQRCode({
  12381. value,
  12382. level,
  12383. minVersion,
  12384. boostLevel,
  12385. includeMargin,
  12386. marginSize,
  12387. imageSettings,
  12388. size
  12389. }), cellsToDraw = cells, image = null;
  12390. imageSettings != null && calculatedImageSettings != null && (calculatedImageSettings.excavation != null && (cellsToDraw = excavateModules(
  12391. cells,
  12392. calculatedImageSettings.excavation
  12393. )), image = react_default.createElement(
  12394. "image",
  12395. {
  12396. href: imageSettings.src,
  12397. height: calculatedImageSettings.h,
  12398. width: calculatedImageSettings.w,
  12399. x: calculatedImageSettings.x + margin,
  12400. y: calculatedImageSettings.y + margin,
  12401. preserveAspectRatio: "none",
  12402. opacity: calculatedImageSettings.opacity,
  12403. crossOrigin: calculatedImageSettings.crossOrigin
  12404. }
  12405. ));
  12406. let fgPath = generatePath(cellsToDraw, margin);
  12407. return react_default.createElement(
  12408. "svg",
  12409. __spreadValues({
  12410. height: size,
  12411. width: size,
  12412. viewBox: `0 0 ${numCells} ${numCells}`,
  12413. ref: forwardedRef,
  12414. role: "img"
  12415. }, otherProps),
  12416. !!title2 && react_default.createElement("title", null, title2),
  12417. react_default.createElement(
  12418. "path",
  12419. {
  12420. fill: bgColor,
  12421. d: `M0,0 h${numCells}v${numCells}H0z`,
  12422. shapeRendering: "crispEdges"
  12423. }
  12424. ),
  12425. react_default.createElement("path", { fill: fgColor, d: fgPath, shapeRendering: "crispEdges" }),
  12426. image
  12427. );
  12428. }
  12429. );
  12430. QRCodeSVG.displayName = "QRCodeSVG";
  12431. // src/manager/components/preview/tools/share.tsx
  12432. var mapper3 = ({ api, state }) => {
  12433. let { storyId, refId } = state;
  12434. return { api, refId, storyId };
  12435. }, QRContainer = styled.div(
  12436. () => ({
  12437. display: "flex",
  12438. flexDirection: "column",
  12439. padding: 8,
  12440. width: 300,
  12441. maxWidth: 300,
  12442. gap: 8
  12443. })
  12444. ), QRRow = styled.div(() => ({
  12445. display: "flex",
  12446. alignItems: "center"
  12447. })), ShareLinkInput = styled.input(({ theme }) => ({
  12448. width: "100%",
  12449. border: `1px solid ${theme.appBorderColor}`,
  12450. borderRadius: 4,
  12451. padding: "6px 8px",
  12452. fontSize: theme.typography.size.s1,
  12453. color: theme.color.defaultText,
  12454. backgroundColor: theme.background.app,
  12455. outline: "none",
  12456. textOverflow: "ellipsis",
  12457. overflow: "hidden",
  12458. whiteSpace: "nowrap",
  12459. "&:focus": {
  12460. borderColor: theme.color.secondary
  12461. }
  12462. })), QRImageContainer = styled.div(() => ({
  12463. width: 64,
  12464. height: 64,
  12465. marginRight: 12,
  12466. backgroundColor: "white",
  12467. padding: 2
  12468. }));
  12469. var QRContent = styled.div(() => ({})), QRTitle = styled.div(({ theme }) => ({
  12470. fontWeight: theme.typography.weight.bold,
  12471. fontSize: theme.typography.size.s1,
  12472. marginBottom: 4
  12473. })), QRDescription = styled.div(({ theme }) => ({
  12474. fontSize: theme.typography.size.s1,
  12475. color: theme.textMutedColor
  12476. })), isolationModeTool = {
  12477. title: "isolation mode",
  12478. id: "isolationMode",
  12479. type: types.TOOLEXTRA,
  12480. match: ({ viewMode, tabId }) => viewMode === "story" && !tabId,
  12481. render: () => react_default.createElement(Consumer, { filter: mapper3 }, ({ api, storyId, refId }) => {
  12482. if (!storyId) return null;
  12483. let originHrefs = api.getStoryHrefs(storyId, { base: "origin", refId });
  12484. return react_default.createElement(
  12485. Button,
  12486. {
  12487. padding: "small",
  12488. variant: "ghost",
  12489. ariaLabel: "Open in isolation mode",
  12490. tooltip: "Open in isolation mode",
  12491. onClick: () => {
  12492. window.open(originHrefs.previewHref, "_blank", "noopener,noreferrer"), api.emit(SHARE_ISOLATE_MODE, originHrefs.previewHref);
  12493. }
  12494. },
  12495. react_default.createElement(PopOutIcon, null)
  12496. );
  12497. })
  12498. };
  12499. // src/manager/container/Preview.tsx
  12500. var defaultTabs = [createCanvasTab()], defaultTools = [menuTool, remountTool], defaultToolsExtra = [
  12501. isolationModeTool,
  12502. zoomTool,
  12503. addonsTool,
  12504. fullScreenTool,
  12505. openInEditorTool
  12506. ], emptyTabsList = [], memoizedTabs = (0, import_memoizerific2.default)(1)(
  12507. (_2, tabElements, parameters, showTabs) => showTabs ? filterTabs([...defaultTabs, ...Object.values(tabElements)], parameters) : emptyTabsList
  12508. ), memoizedTools = (0, import_memoizerific2.default)(1)(
  12509. (_2, toolElements, filterProps) => filterToolsSide([...defaultTools, ...Object.values(toolElements)], ...filterProps)
  12510. ), memoizedExtra = (0, import_memoizerific2.default)(1)(
  12511. (_2, extraElements, filterProps) => filterToolsSide([...defaultToolsExtra, ...Object.values(extraElements)], ...filterProps)
  12512. ), memoizedWrapper = (0, import_memoizerific2.default)(1)((_2, previewElements) => [
  12513. ...defaultWrappers,
  12514. ...Object.values(previewElements)
  12515. ]), { PREVIEW_URL } = scope, splitTitleAddExtraSpace = (input) => input.split("/").join(" / ").replace(/\s\s/, " "), getDescription = (item) => {
  12516. if (item?.type === "story" || item?.type === "docs") {
  12517. let { title: title2, name } = item;
  12518. return title2 && name ? splitTitleAddExtraSpace(`${title2} - ${name} \u22C5 Storybook`) : "Storybook";
  12519. }
  12520. return item?.name ? `${item.name} \u22C5 Storybook` : "Storybook";
  12521. }, mapper4 = ({
  12522. api,
  12523. state
  12524. // @ts-expect-error (non strict)
  12525. }) => {
  12526. 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), [
  12527. entry,
  12528. viewMode,
  12529. location2,
  12530. path,
  12531. // @ts-expect-error (non strict)
  12532. tabId
  12533. ]), toolsExtra = memoizedExtra(
  12534. toolsExtraList.length,
  12535. api.getElements(Addon_TypesEnum.TOOLEXTRA),
  12536. // @ts-expect-error (non strict)
  12537. [entry, viewMode, location2, path, tabId]
  12538. );
  12539. return {
  12540. api,
  12541. entry,
  12542. options: layout,
  12543. description: getDescription(entry),
  12544. viewMode,
  12545. refs,
  12546. storyId,
  12547. baseUrl: PREVIEW_URL || "iframe.html",
  12548. queryParams: customQueryParams,
  12549. tools,
  12550. toolsExtra,
  12551. tabs: memoizedTabs(
  12552. tabsList.length,
  12553. api.getElements(Addon_TypesEnum.TAB),
  12554. entry ? entry.parameters : void 0,
  12555. layout.showTabs
  12556. ),
  12557. wrappers: memoizedWrapper(
  12558. wrapperList.length,
  12559. api.getElements(Addon_TypesEnum.PREVIEW)
  12560. ),
  12561. tabId
  12562. };
  12563. }, PreviewConnected = react_default.memo(function(props) {
  12564. return react_default.createElement(Consumer, { filter: mapper4 }, (fromState) => react_default.createElement(Preview, { ...props, ...fromState }));
  12565. }), Preview_default = PreviewConnected;
  12566. // src/manager/container/Sidebar.tsx
  12567. init_react();
  12568. // src/manager/components/sidebar/Sidebar.tsx
  12569. init_react();
  12570. // src/manager/components/sidebar/ChecklistWidget.tsx
  12571. init_react();
  12572. // src/manager/components/Optional/Optional.tsx
  12573. init_react();
  12574. var Wrapper3 = styled.div({
  12575. display: "inline-grid",
  12576. gridTemplateColumns: "max-content",
  12577. overflow: "hidden"
  12578. }), Content2 = styled.div(({ isHidden }) => ({
  12579. display: "inline-block",
  12580. gridArea: "1/1",
  12581. opacity: isHidden === null ? 0 : 1,
  12582. visibility: isHidden ? "hidden" : "visible"
  12583. })), Optional = ({
  12584. content,
  12585. fallback
  12586. }) => {
  12587. let contentRef = useRef(null), wrapperRef = useRef(null), [hidden, setHidden] = useState(null), contentWidth = useRef(contentRef.current?.offsetWidth ?? 0), wrapperWidth = useRef(wrapperRef.current?.offsetWidth ?? 0);
  12588. return useEffect(() => {
  12589. if (contentRef.current && wrapperRef.current) {
  12590. let resizeObserver = new ResizeObserver(() => {
  12591. wrapperWidth.current = wrapperRef.current?.offsetWidth || wrapperWidth.current, contentWidth.current = contentRef.current?.offsetWidth || contentWidth.current, setHidden(contentWidth.current > wrapperWidth.current);
  12592. });
  12593. return resizeObserver.observe(wrapperRef.current), () => resizeObserver.disconnect();
  12594. }
  12595. }, []), react_default.createElement(Wrapper3, { ref: wrapperRef }, react_default.createElement(Content2, { isHidden: hidden, ref: contentRef }, content), fallback && react_default.createElement(Content2, { isHidden: !hidden }, fallback));
  12596. };
  12597. // src/manager/components/Particles/Particles.tsx
  12598. init_react();
  12599. var Shape = styled.svg(({ color: color2 }) => ({
  12600. fill: color2,
  12601. position: "absolute",
  12602. inset: "0",
  12603. margin: "auto",
  12604. width: "12px",
  12605. height: "12px",
  12606. pointerEvents: "none"
  12607. })), 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(
  12608. Shape,
  12609. {
  12610. viewBox: "0 0 90 90",
  12611. xmlns: "http://www.w3.org/2000/svg",
  12612. color: "#1EA7FD",
  12613. ...props,
  12614. style: { borderRadius: 5, ...style }
  12615. },
  12616. react_default.createElement("path", { d: "M0 0h90v90H0z" })
  12617. ), 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`
  12618. to {
  12619. opacity: 0;
  12620. }
  12621. `, disperse = keyframes`
  12622. to {
  12623. transform: translate(
  12624. calc(cos(var(--angle)) * var(--distance)),
  12625. calc(sin(var(--angle)) * var(--distance))
  12626. ) rotate(var(--rotation));
  12627. }
  12628. `, slideDown = keyframes`
  12629. to {
  12630. transform: translateY(50px);
  12631. }
  12632. `, Container8 = styled.div({
  12633. position: "absolute",
  12634. display: "flex",
  12635. flexDirection: "row",
  12636. flexWrap: "wrap",
  12637. gap: 10,
  12638. "--particle-curve": "cubic-bezier(0.2, 0.56, 0, 1)",
  12639. animation: `${slideDown} 1000ms forwards cubic-bezier(0.587, -0.381, 0.583, 0.599)`,
  12640. animationDelay: "150ms",
  12641. zIndex: 999,
  12642. svg: {
  12643. width: 15,
  12644. height: 15,
  12645. animation: `${fadeToTransparent} var(--fade-duration) forwards, ${disperse} 1000ms forwards var(--particle-curve)`
  12646. }
  12647. }), 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({
  12648. anchor: Anchor
  12649. }) {
  12650. let anchorRef = useRef(null), [left, setLeft] = useState(0), [top, setTop] = useState(0), shapes = sortRandomly([Donut, L2, Slice, Square, Triangle, T2, Z]), colors = sortRandomly([
  12651. "#FF0000",
  12652. "#FF4787",
  12653. "#66BF3C",
  12654. "#1EA7FD",
  12655. "#FC521F",
  12656. "#6F2CAC",
  12657. "#FFAE00"
  12658. ]);
  12659. return useLayoutEffect(() => {
  12660. let rect = anchorRef.current?.getBoundingClientRect();
  12661. rect && (setLeft(rect.left + rect.width / 2), setTop(rect.top + rect.height / 2));
  12662. }, []), react_default.createElement("div", { ref: anchorRef }, react_default.createElement(Anchor, null), createPortal(
  12663. react_default.createElement(Container8, { style: { top: top + "px", left: left + "px" } }, shapes.map((Particle, index) => {
  12664. let angle = 360 / NUM_OF_PARTICLES * index + random(-JITTER, JITTER), distance = random(50, 80), rotation = random(-360, 360), style = {
  12665. "--angle": angle + "deg",
  12666. "--distance": distance + "px",
  12667. "--rotation": rotation + "deg",
  12668. "--fade-duration": FADE_DURATION + "ms"
  12669. };
  12670. return react_default.createElement(Particle, { key: Particle.name, style, color: colors[index] });
  12671. })),
  12672. document.getElementById("root") ?? document.body
  12673. ));
  12674. });
  12675. // src/manager/components/TextFlip.tsx
  12676. init_react();
  12677. var slideIn2 = keyframes({
  12678. from: {
  12679. transform: "translateY(var(--slide-in-from))",
  12680. opacity: 0
  12681. }
  12682. }), slideOut = keyframes({
  12683. to: {
  12684. transform: "translateY(var(--slide-out-to))",
  12685. opacity: 0
  12686. }
  12687. }), Container9 = styled.div({
  12688. display: "inline-grid",
  12689. gridTemplateColumns: "1fr",
  12690. justifyContent: "center",
  12691. alignItems: "center"
  12692. }), Placeholder2 = styled.div({
  12693. gridArea: "1 / 1",
  12694. userSelect: "none",
  12695. visibility: "hidden"
  12696. }), Text2 = styled.span(({ duration, isExiting, isEntering, reverse }) => {
  12697. let animation;
  12698. return isExiting ? animation = `${slideOut} ${duration}ms forwards` : isEntering && (animation = `${slideIn2} ${duration}ms forwards`), {
  12699. gridArea: "1 / 1",
  12700. animation,
  12701. pointerEvents: isExiting ? "none" : "auto",
  12702. userSelect: isExiting ? "none" : "text",
  12703. "--slide-in-from": reverse ? "-100%" : "100%",
  12704. "--slide-out-to": reverse ? "100%" : "-100%",
  12705. "@media (prefers-reduced-motion: reduce)": {
  12706. animation: "none",
  12707. opacity: isExiting ? 0 : 1,
  12708. transform: "translateY(0)"
  12709. }
  12710. };
  12711. }), TextFlip = ({
  12712. text,
  12713. duration = 250,
  12714. placeholder,
  12715. ...props
  12716. }) => {
  12717. let textRef = useRef(text), [staleValue, setStaleValue] = useState(text), isAnimating = text !== staleValue, reverse = isAnimating && numericCompare(staleValue, text);
  12718. return textRef.current = text, react_default.createElement(Container9, { ...props }, isAnimating && react_default.createElement(
  12719. Text2,
  12720. {
  12721. "aria-hidden": !0,
  12722. duration,
  12723. reverse,
  12724. isExiting: !0,
  12725. onAnimationEnd: () => setStaleValue(textRef.current)
  12726. },
  12727. staleValue
  12728. ), react_default.createElement(Text2, { duration, reverse, isEntering: isAnimating }, text), placeholder && react_default.createElement(Placeholder2, { "aria-hidden": !0 }, placeholder));
  12729. };
  12730. function numericCompare(a2, b2) {
  12731. let na = Number(a2), nb = Number(b2);
  12732. return Number.isNaN(na) || Number.isNaN(nb) ? a2.localeCompare(b2, void 0, { numeric: !0 }) > 0 : na > nb;
  12733. }
  12734. // src/manager/components/sidebar/useChecklist.ts
  12735. init_react();
  12736. // ../../node_modules/es-toolkit/dist/function/debounce.mjs
  12737. function debounce(func, debounceMs, { signal, edges } = {}) {
  12738. let pendingThis, pendingArgs = null, leading = edges != null && edges.includes("leading"), trailing = edges == null || edges.includes("trailing"), invoke = () => {
  12739. pendingArgs !== null && (func.apply(pendingThis, pendingArgs), pendingThis = void 0, pendingArgs = null);
  12740. }, onTimerEnd = () => {
  12741. trailing && invoke(), cancel();
  12742. }, timeoutId = null, schedule = () => {
  12743. timeoutId != null && clearTimeout(timeoutId), timeoutId = setTimeout(() => {
  12744. timeoutId = null, onTimerEnd();
  12745. }, debounceMs);
  12746. }, cancelTimer = () => {
  12747. timeoutId !== null && (clearTimeout(timeoutId), timeoutId = null);
  12748. }, cancel = () => {
  12749. cancelTimer(), pendingThis = void 0, pendingArgs = null;
  12750. }, flush = () => {
  12751. invoke();
  12752. }, debounced = function(...args) {
  12753. if (signal?.aborted)
  12754. return;
  12755. pendingThis = this, pendingArgs = args;
  12756. let isFirstCall = timeoutId == null;
  12757. schedule(), leading && isFirstCall && invoke();
  12758. };
  12759. return debounced.schedule = schedule, debounced.cancel = cancel, debounced.flush = flush, signal?.addEventListener("abort", cancel, { once: !0 }), debounced;
  12760. }
  12761. // ../../node_modules/es-toolkit/dist/function/partial.mjs
  12762. function partial(func, ...partialArgs) {
  12763. return partialImpl(func, placeholderSymbol, ...partialArgs);
  12764. }
  12765. function partialImpl(func, placeholder, ...partialArgs) {
  12766. let partialed = function(...providedArgs) {
  12767. let providedArgsIndex = 0, substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg), remainingArgs = providedArgs.slice(providedArgsIndex);
  12768. return func.apply(this, substitutedArgs.concat(remainingArgs));
  12769. };
  12770. return func.prototype && (partialed.prototype = Object.create(func.prototype)), partialed;
  12771. }
  12772. var placeholderSymbol = /* @__PURE__ */ Symbol("partial.placeholder");
  12773. partial.placeholder = placeholderSymbol;
  12774. // ../../node_modules/es-toolkit/dist/function/partialRight.mjs
  12775. function partialRight(func, ...partialArgs) {
  12776. return partialRightImpl(func, placeholderSymbol2, ...partialArgs);
  12777. }
  12778. function partialRightImpl(func, placeholder, ...partialArgs) {
  12779. let partialedRight = function(...providedArgs) {
  12780. 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);
  12781. return func.apply(this, remainingArgs.concat(substitutedArgs));
  12782. };
  12783. return func.prototype && (partialedRight.prototype = Object.create(func.prototype)), partialedRight;
  12784. }
  12785. var placeholderSymbol2 = /* @__PURE__ */ Symbol("partialRight.placeholder");
  12786. partialRight.placeholder = placeholderSymbol2;
  12787. // ../../node_modules/es-toolkit/dist/function/retry.mjs
  12788. var DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
  12789. // ../../node_modules/es-toolkit/dist/function/throttle.mjs
  12790. function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
  12791. let pendingAt = null, debounced = debounce(function(...args) {
  12792. pendingAt = Date.now(), func.apply(this, args);
  12793. }, throttleMs, { signal, edges }), throttled = function(...args) {
  12794. if (pendingAt == null && (pendingAt = Date.now()), Date.now() - pendingAt >= throttleMs) {
  12795. pendingAt = Date.now(), func.apply(this, args), debounced.cancel(), debounced.schedule();
  12796. return;
  12797. }
  12798. debounced.apply(this, args);
  12799. };
  12800. return throttled.cancel = debounced.cancel, throttled.flush = debounced.flush, throttled;
  12801. }
  12802. // src/shared/checklist-store/checklistData.tsx
  12803. init_react();
  12804. // ../addons/a11y/src/constants.ts
  12805. var ADDON_ID2 = "storybook/a11y", PANEL_ID2 = `${ADDON_ID2}/panel`;
  12806. 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`;
  12807. // ../addons/onboarding/src/constants.ts
  12808. var ADDON_ID3 = "storybook/onboarding", ADDON_ONBOARDING_CHANNEL = `${ADDON_ID3}/channel`;
  12809. // src/component-testing/constants.ts
  12810. var ADDON_ID4 = "storybook/interactions", PANEL_ID3 = `${ADDON_ID4}/panel`;
  12811. var DOCUMENTATION_LINK2 = "writing-tests/integrations/vitest-addon", DOCUMENTATION_DISCREPANCY_LINK2 = `${DOCUMENTATION_LINK2}#what-happens-when-there-are-different-test-results-in-multiple-environments`;
  12812. // ../addons/vitest/src/constants.ts
  12813. var ADDON_ID5 = "storybook/test", TEST_PROVIDER_ID = `${ADDON_ID5}/test-provider`, STORYBOOK_ADDON_TEST_CHANNEL = `${ADDON_ID5}/channel`;
  12814. var DOCUMENTATION_LINK3 = "writing-tests/integrations/vitest-addon", DOCUMENTATION_FATAL_ERROR_LINK = `${DOCUMENTATION_LINK3}#what-happens-if-vitest-itself-has-an-error`;
  12815. var storeOptions = {
  12816. id: ADDON_ID5,
  12817. initialState: {
  12818. config: {
  12819. coverage: !1,
  12820. a11y: !1
  12821. },
  12822. watching: !1,
  12823. cancelling: !1,
  12824. fatalError: void 0,
  12825. index: { entries: {}, v: 5 },
  12826. previewAnnotations: [],
  12827. currentRun: {
  12828. triggeredBy: void 0,
  12829. config: {
  12830. coverage: !1,
  12831. a11y: !1
  12832. },
  12833. componentTestStatuses: [],
  12834. a11yStatuses: [],
  12835. a11yReports: {},
  12836. reports: {},
  12837. componentTestCount: {
  12838. success: 0,
  12839. error: 0
  12840. },
  12841. a11yCount: {
  12842. success: 0,
  12843. warning: 0,
  12844. error: 0
  12845. },
  12846. storyIds: void 0,
  12847. totalTestCount: void 0,
  12848. startedAt: void 0,
  12849. finishedAt: void 0,
  12850. unhandledErrors: [],
  12851. coverageSummary: void 0
  12852. }
  12853. }
  12854. };
  12855. var STORE_CHANNEL_EVENT_NAME = `UNIVERSAL_STORE:${storeOptions.id}`;
  12856. var TRIGGER_TEST_RUN_REQUEST = `${ADDON_ID5}/trigger-test-run-request`, TRIGGER_TEST_RUN_RESPONSE = `${ADDON_ID5}/trigger-test-run-response`;
  12857. // src/storybook-error.ts
  12858. function parseErrorCode({
  12859. code,
  12860. category
  12861. }) {
  12862. let paddedCode = String(code).padStart(4, "0");
  12863. return `SB_${category}_${paddedCode}`;
  12864. }
  12865. function appendErrorRef(url) {
  12866. if (/^(?!.*storybook\.js\.org)|[?&]ref=error\b/.test(url))
  12867. return url;
  12868. try {
  12869. let urlObj = new URL(url);
  12870. return urlObj.searchParams.set("ref", "error"), urlObj.toString();
  12871. } catch {
  12872. return url;
  12873. }
  12874. }
  12875. var StorybookError = class _StorybookError extends Error {
  12876. constructor(props) {
  12877. super(
  12878. _StorybookError.getFullMessage(props),
  12879. props.cause === void 0 ? void 0 : { cause: props.cause }
  12880. );
  12881. /**
  12882. * Data associated with the error. Used to provide additional information in the error message or
  12883. * to be passed to telemetry.
  12884. */
  12885. this.data = {};
  12886. /** Flag used to easily determine if the error originates from Storybook. */
  12887. this.fromStorybook = !0;
  12888. /**
  12889. * Flag used to determine if the error is handled by us and should therefore not be shown to the
  12890. * user.
  12891. */
  12892. this.isHandledError = !1;
  12893. /**
  12894. * A collection of sub errors which relate to a parent error.
  12895. *
  12896. * Sub-errors are used to represent multiple related errors that occurred together. When a
  12897. * StorybookError with sub-errors is sent to telemetry, both the parent error and each sub-error
  12898. * are sent as separate telemetry events. This allows for better error tracking and debugging.
  12899. *
  12900. * @example
  12901. *
  12902. * ```ts
  12903. * const error1 = new SomeError();
  12904. * const error2 = new AnotherError();
  12905. * const parentError = new ParentError({
  12906. * // ... other props
  12907. * subErrors: [error1, error2],
  12908. * });
  12909. * ```
  12910. */
  12911. this.subErrors = [];
  12912. 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 ?? [];
  12913. }
  12914. get fullErrorCode() {
  12915. return parseErrorCode({ code: this.code, category: this.category });
  12916. }
  12917. /** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */
  12918. get name() {
  12919. let errorName = this._name || this.constructor.name;
  12920. return `${this.fullErrorCode} (${errorName})`;
  12921. }
  12922. set name(name) {
  12923. this._name = name;
  12924. }
  12925. /** Generates the error message along with additional documentation link (if applicable). */
  12926. static getFullMessage({
  12927. documentation,
  12928. code,
  12929. category,
  12930. message
  12931. }) {
  12932. let page;
  12933. return documentation === !0 ? page = `https://storybook.js.org/error/${parseErrorCode({ code, category })}?ref=error` : typeof documentation == "string" ? page = appendErrorRef(documentation) : Array.isArray(documentation) && (page = `
  12934. ${documentation.map((doc) => ` - ${appendErrorRef(doc)}`).join(`
  12935. `)}`), `${message}${page != null ? `
  12936. More info: ${page}
  12937. ` : ""}`;
  12938. }
  12939. };
  12940. // src/manager-errors.ts
  12941. var StatusTypeIdMismatchError2 = class extends StorybookError {
  12942. constructor(data) {
  12943. super({
  12944. name: "StatusTypeIdMismatchError",
  12945. category: "MANAGER_API" /* MANAGER_API */,
  12946. code: 1,
  12947. message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
  12948. data.status,
  12949. null,
  12950. 2
  12951. )}`
  12952. });
  12953. this.data = data;
  12954. }
  12955. };
  12956. // ../../node_modules/ts-dedent/esm/index.js
  12957. function dedent(templ) {
  12958. for (var values = [], _i = 1; _i < arguments.length; _i++)
  12959. values[_i - 1] = arguments[_i];
  12960. var strings = Array.from(typeof templ == "string" ? [templ] : templ);
  12961. strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
  12962. var indentLengths = strings.reduce(function(arr, str) {
  12963. var matches = str.match(/\n([\t ]+|(?!\s).)/g);
  12964. return matches ? arr.concat(matches.map(function(match) {
  12965. var _a2, _b;
  12966. return (_b = (_a2 = match.match(/[\t ]/g)) === null || _a2 === void 0 ? void 0 : _a2.length) !== null && _b !== void 0 ? _b : 0;
  12967. })) : arr;
  12968. }, []);
  12969. if (indentLengths.length) {
  12970. var pattern_1 = new RegExp(`
  12971. [ ]{` + Math.min.apply(Math, indentLengths) + "}", "g");
  12972. strings = strings.map(function(str) {
  12973. return str.replace(pattern_1, `
  12974. `);
  12975. });
  12976. }
  12977. strings[0] = strings[0].replace(/^\r?\n/, "");
  12978. var string = strings[0];
  12979. return values.forEach(function(value, i2) {
  12980. var endentations = string.match(/(?:^|\n)( *)$/), endentation = endentations ? endentations[1] : "", indentedValue = value;
  12981. typeof value == "string" && value.includes(`
  12982. `) && (indentedValue = String(value).split(`
  12983. `).map(function(str, i3) {
  12984. return i3 === 0 ? str : "" + endentation + str;
  12985. }).join(`
  12986. `)), string += indentedValue + strings[i2 + 1];
  12987. }), string;
  12988. }
  12989. // src/preview-errors.ts
  12990. var StatusTypeIdMismatchError3 = class extends StorybookError {
  12991. constructor(data) {
  12992. super({
  12993. name: "StatusTypeIdMismatchError",
  12994. category: "PREVIEW_API" /* PREVIEW_API */,
  12995. code: 16,
  12996. message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
  12997. data.status,
  12998. null,
  12999. 2
  13000. )}`
  13001. });
  13002. this.data = data;
  13003. }
  13004. };
  13005. // src/server-errors.ts
  13006. var import_picocolors = __toESM(require_picocolors_browser(), 1);
  13007. var StatusTypeIdMismatchError4 = class extends StorybookError {
  13008. constructor(data) {
  13009. super({
  13010. name: "StatusTypeIdMismatchError",
  13011. category: "CORE-SERVER" /* CORE_SERVER */,
  13012. code: 16,
  13013. message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(
  13014. data.status,
  13015. null,
  13016. 2
  13017. )}`
  13018. });
  13019. this.data = data;
  13020. }
  13021. };
  13022. // src/shared/status-store/index.ts
  13023. var STATUS_VALUE_PREFIX = "status-value:";
  13024. var statusValueShortName = (value) => value === "status-value:affected" ? "related" : value.slice(STATUS_VALUE_PREFIX.length), statusValueDescription = (value) => ({
  13025. "status-value:pending": "Stories with pending status",
  13026. "status-value:success": "Stories with passing tests",
  13027. "status-value:new": "Newly added stories",
  13028. "status-value:modified": "Stories closely linked to code changes",
  13029. "status-value:affected": "Stories likely to be affected by code changes",
  13030. "status-value:warning": "Stories with warnings",
  13031. "status-value:error": "Stories with failing tests",
  13032. "status-value:unknown": "Stories with unknown status"
  13033. })[value];
  13034. var UNIVERSAL_STATUS_STORE_OPTIONS = {
  13035. id: "storybook/status",
  13036. leader: !0,
  13037. initialState: {}
  13038. }, StatusStoreEventType = {
  13039. SELECT: "select"
  13040. };
  13041. function countStatusesByValue(allStatuses) {
  13042. let counts = {};
  13043. for (let statusByTypeId of Object.values(allStatuses))
  13044. for (let status of Object.values(statusByTypeId))
  13045. counts[status.value] = (counts[status.value] ?? 0) + 1;
  13046. return counts;
  13047. }
  13048. function createStatusStore({
  13049. universalStatusStore: universalStatusStore2,
  13050. useUniversalStore: useUniversalStore2,
  13051. environment
  13052. }) {
  13053. let fullStatusStore2 = {
  13054. getAll() {
  13055. return universalStatusStore2.getState();
  13056. },
  13057. set(statuses) {
  13058. universalStatusStore2.setState((state) => {
  13059. let newState = { ...state };
  13060. for (let status of statuses) {
  13061. let { storyId, typeId } = status;
  13062. newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
  13063. }
  13064. return newState;
  13065. });
  13066. },
  13067. onAllStatusChange(listener) {
  13068. return universalStatusStore2.onStateChange((state, prevState) => {
  13069. listener(state, prevState);
  13070. });
  13071. },
  13072. onSelect(listener) {
  13073. return universalStatusStore2.subscribe(StatusStoreEventType.SELECT, (event) => {
  13074. listener(event.payload);
  13075. });
  13076. },
  13077. selectStatuses: (statuses) => {
  13078. universalStatusStore2.send({ type: StatusStoreEventType.SELECT, payload: statuses });
  13079. },
  13080. unset(storyIds) {
  13081. if (!storyIds) {
  13082. universalStatusStore2.setState({});
  13083. return;
  13084. }
  13085. universalStatusStore2.setState((state) => {
  13086. let newState = { ...state };
  13087. for (let storyId of storyIds)
  13088. delete newState[storyId];
  13089. return newState;
  13090. });
  13091. },
  13092. typeId: void 0
  13093. }, getStatusStoreByTypeId2 = (typeId) => ({
  13094. getAll: fullStatusStore2.getAll,
  13095. set(statuses) {
  13096. universalStatusStore2.setState((state) => {
  13097. let newState = { ...state };
  13098. for (let status of statuses) {
  13099. let { storyId } = status;
  13100. if (status.typeId !== typeId)
  13101. switch (environment) {
  13102. case "server":
  13103. throw new StatusTypeIdMismatchError4({
  13104. status,
  13105. typeId
  13106. });
  13107. case "manager":
  13108. throw new StatusTypeIdMismatchError2({
  13109. status,
  13110. typeId
  13111. });
  13112. default:
  13113. throw new StatusTypeIdMismatchError3({
  13114. status,
  13115. typeId
  13116. });
  13117. }
  13118. newState[storyId] = { ...newState[storyId] ?? {}, [typeId]: status };
  13119. }
  13120. return newState;
  13121. });
  13122. },
  13123. onAllStatusChange: fullStatusStore2.onAllStatusChange,
  13124. onSelect(listener) {
  13125. return universalStatusStore2.subscribe(StatusStoreEventType.SELECT, (event) => {
  13126. event.payload.some((status) => status.typeId === typeId) && listener(event.payload);
  13127. });
  13128. },
  13129. unset(storyIds) {
  13130. universalStatusStore2.setState((state) => {
  13131. let newState = { ...state };
  13132. for (let storyId in newState)
  13133. if (newState[storyId]?.[typeId] && (!storyIds || storyIds?.includes(storyId))) {
  13134. let { [typeId]: omittedStatus, ...storyStatusesWithoutTypeId } = newState[storyId];
  13135. newState[storyId] = storyStatusesWithoutTypeId;
  13136. }
  13137. return newState;
  13138. });
  13139. },
  13140. typeId
  13141. });
  13142. return useUniversalStore2 ? {
  13143. getStatusStoreByTypeId: getStatusStoreByTypeId2,
  13144. fullStatusStore: fullStatusStore2,
  13145. universalStatusStore: universalStatusStore2,
  13146. useStatusStore: (selector) => useUniversalStore2(universalStatusStore2, selector)[0]
  13147. } : { getStatusStoreByTypeId: getStatusStoreByTypeId2, fullStatusStore: fullStatusStore2, universalStatusStore: universalStatusStore2 };
  13148. }
  13149. // src/cli/AddonVitestService.constants.ts
  13150. var SUPPORTED_FRAMEWORKS = [
  13151. "html-vite" /* HTML_VITE */,
  13152. "nextjs-vite" /* NEXTJS_VITE */,
  13153. "preact-vite" /* PREACT_VITE */,
  13154. "react-native-web-vite" /* REACT_NATIVE_WEB_VITE */,
  13155. "react-vite" /* REACT_VITE */,
  13156. "solid" /* SOLID */,
  13157. "svelte-vite" /* SVELTE_VITE */,
  13158. "sveltekit" /* SVELTEKIT */,
  13159. "vue3-vite" /* VUE3_VITE */,
  13160. "web-components-vite" /* WEB_COMPONENTS_VITE */,
  13161. "tanstack-react" /* TANSTACK_REACT */
  13162. ];
  13163. // src/docs-tools/shared.ts
  13164. var ADDON_ID6 = "storybook/docs", PANEL_ID4 = `${ADDON_ID6}/panel`;
  13165. var SNIPPET_RENDERED = `${ADDON_ID6}/snippet-rendered`;
  13166. // src/manager/components/TourGuide/TourGuide.tsx
  13167. init_react();
  13168. // ../../node_modules/react-joyride/dist/index.mjs
  13169. init_react();
  13170. // ../../node_modules/@gilbarbara/deep-equal/dist/index.mjs
  13171. function isOfType(type) {
  13172. return (value) => typeof value === type;
  13173. }
  13174. 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");
  13175. function equalArray(left, right) {
  13176. let { length } = left;
  13177. if (length !== right.length)
  13178. return !1;
  13179. for (let index = length; index-- !== 0; )
  13180. if (!equal(left[index], right[index]))
  13181. return !1;
  13182. return !0;
  13183. }
  13184. function equalArrayBuffer(left, right) {
  13185. if (left.byteLength !== right.byteLength)
  13186. return !1;
  13187. let view1 = new DataView(left.buffer), view2 = new DataView(right.buffer), index = left.byteLength;
  13188. for (; index--; )
  13189. if (view1.getUint8(index) !== view2.getUint8(index))
  13190. return !1;
  13191. return !0;
  13192. }
  13193. function equalMap(left, right) {
  13194. if (left.size !== right.size)
  13195. return !1;
  13196. for (let index of left.entries())
  13197. if (!right.has(index[0]))
  13198. return !1;
  13199. for (let index of left.entries())
  13200. if (!equal(index[1], right.get(index[0])))
  13201. return !1;
  13202. return !0;
  13203. }
  13204. function equalSet(left, right) {
  13205. if (left.size !== right.size)
  13206. return !1;
  13207. for (let index of left.entries())
  13208. if (!right.has(index[0]))
  13209. return !1;
  13210. return !0;
  13211. }
  13212. function equal(left, right) {
  13213. if (left === right)
  13214. return !0;
  13215. if (left && isObject(left) && right && isObject(right)) {
  13216. if (left.constructor !== right.constructor)
  13217. return !1;
  13218. if (Array.isArray(left) && Array.isArray(right))
  13219. return equalArray(left, right);
  13220. if (left instanceof Map && right instanceof Map)
  13221. return equalMap(left, right);
  13222. if (left instanceof Set && right instanceof Set)
  13223. return equalSet(left, right);
  13224. if (ArrayBuffer.isView(left) && ArrayBuffer.isView(right))
  13225. return equalArrayBuffer(left, right);
  13226. if (isRegex(left) && isRegex(right))
  13227. return left.source === right.source && left.flags === right.flags;
  13228. if (left.valueOf !== Object.prototype.valueOf)
  13229. return left.valueOf() === right.valueOf();
  13230. if (left.toString !== Object.prototype.toString)
  13231. return left.toString() === right.toString();
  13232. let leftKeys = Object.keys(left), rightKeys = Object.keys(right);
  13233. if (leftKeys.length !== rightKeys.length)
  13234. return !1;
  13235. for (let index = leftKeys.length; index-- !== 0; )
  13236. if (!Object.prototype.hasOwnProperty.call(right, leftKeys[index]))
  13237. return !1;
  13238. for (let index = leftKeys.length; index-- !== 0; ) {
  13239. let key = leftKeys[index];
  13240. if (!(key === "_owner" && left.$$typeof) && !equal(left[key], right[key]))
  13241. return !1;
  13242. }
  13243. return !0;
  13244. }
  13245. return Number.isNaN(left) && Number.isNaN(right) ? !0 : left === right;
  13246. }
  13247. // ../../node_modules/is-lite/dist/index.mjs
  13248. var objectTypes = [
  13249. "Array",
  13250. "ArrayBuffer",
  13251. "AsyncFunction",
  13252. "AsyncGenerator",
  13253. "AsyncGeneratorFunction",
  13254. "Date",
  13255. "Error",
  13256. "Function",
  13257. "Generator",
  13258. "GeneratorFunction",
  13259. "HTMLElement",
  13260. "Map",
  13261. "Object",
  13262. "Promise",
  13263. "RegExp",
  13264. "Set",
  13265. "WeakMap",
  13266. "WeakSet"
  13267. ], primitiveTypes = [
  13268. "bigint",
  13269. "boolean",
  13270. "null",
  13271. "number",
  13272. "string",
  13273. "symbol",
  13274. "undefined"
  13275. ];
  13276. function getObjectType(value) {
  13277. let objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  13278. if (/HTML\w+Element/.test(objectTypeName))
  13279. return "HTMLElement";
  13280. if (isObjectType(objectTypeName))
  13281. return objectTypeName;
  13282. }
  13283. function isObjectOfType(type) {
  13284. return (value) => getObjectType(value) === type;
  13285. }
  13286. function isObjectType(name) {
  13287. return objectTypes.includes(name);
  13288. }
  13289. function isOfType2(type) {
  13290. return (value) => typeof value === type;
  13291. }
  13292. function isPrimitiveType(name) {
  13293. return primitiveTypes.includes(name);
  13294. }
  13295. var DOM_PROPERTIES_TO_CHECK = [
  13296. "innerHTML",
  13297. "ownerDocument",
  13298. "style",
  13299. "attributes",
  13300. "nodeValue"
  13301. ];
  13302. function is(value) {
  13303. if (value === null)
  13304. return "null";
  13305. switch (typeof value) {
  13306. case "bigint":
  13307. return "bigint";
  13308. case "boolean":
  13309. return "boolean";
  13310. case "number":
  13311. return "number";
  13312. case "string":
  13313. return "string";
  13314. case "symbol":
  13315. return "symbol";
  13316. case "undefined":
  13317. return "undefined";
  13318. default:
  13319. }
  13320. if (is.array(value))
  13321. return "Array";
  13322. if (is.plainFunction(value))
  13323. return "Function";
  13324. let tagType = getObjectType(value);
  13325. return tagType || "Object";
  13326. }
  13327. is.array = Array.isArray;
  13328. is.arrayOf = (target, predicate) => !is.array(target) && !is.function(predicate) ? !1 : target.every((d2) => predicate(d2));
  13329. is.asyncGeneratorFunction = (value) => getObjectType(value) === "AsyncGeneratorFunction";
  13330. is.asyncFunction = isObjectOfType("AsyncFunction");
  13331. is.bigint = isOfType2("bigint");
  13332. is.boolean = (value) => value === !0 || value === !1;
  13333. is.date = isObjectOfType("Date");
  13334. is.defined = (value) => !is.undefined(value);
  13335. 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);
  13336. 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;
  13337. is.error = isObjectOfType("Error");
  13338. is.function = isOfType2("function");
  13339. is.generator = (value) => is.iterable(value) && is.function(value.next) && is.function(value.throw);
  13340. is.generatorFunction = isObjectOfType("GeneratorFunction");
  13341. is.instanceOf = (instance, class_) => !instance || !class_ ? !1 : Object.getPrototypeOf(instance) === class_.prototype;
  13342. is.iterable = (value) => !is.nullOrUndefined(value) && is.function(value[Symbol.iterator]);
  13343. is.map = isObjectOfType("Map");
  13344. is.nan = (value) => Number.isNaN(value);
  13345. is.null = (value) => value === null;
  13346. is.nullOrUndefined = (value) => is.null(value) || is.undefined(value);
  13347. is.number = (value) => isOfType2("number")(value) && !is.nan(value);
  13348. is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value));
  13349. is.object = (value) => !is.nullOrUndefined(value) && (is.function(value) || typeof value == "object");
  13350. is.oneOf = (target, value) => is.array(target) ? target.indexOf(value) > -1 : !1;
  13351. is.plainFunction = isObjectOfType("Function");
  13352. is.plainObject = (value) => {
  13353. if (getObjectType(value) !== "Object")
  13354. return !1;
  13355. let prototype = Object.getPrototypeOf(value);
  13356. return prototype === null || prototype === Object.getPrototypeOf({});
  13357. };
  13358. is.primitive = (value) => is.null(value) || isPrimitiveType(typeof value);
  13359. is.promise = isObjectOfType("Promise");
  13360. is.propertyOf = (target, key, predicate) => {
  13361. if (!is.object(target) || !key)
  13362. return !1;
  13363. let value = target[key];
  13364. return is.function(predicate) ? predicate(value) : is.defined(value);
  13365. };
  13366. is.regexp = isObjectOfType("RegExp");
  13367. is.set = isObjectOfType("Set");
  13368. is.string = isOfType2("string");
  13369. is.symbol = isOfType2("symbol");
  13370. is.undefined = isOfType2("undefined");
  13371. is.weakMap = isObjectOfType("WeakMap");
  13372. is.weakSet = isObjectOfType("WeakSet");
  13373. var src_default = is;
  13374. // ../../node_modules/react-joyride/node_modules/tree-changes/dist/index.mjs
  13375. function canHaveLength(...arguments_) {
  13376. return arguments_.every((d2) => src_default.string(d2) || src_default.array(d2) || src_default.plainObject(d2));
  13377. }
  13378. function checkEquality(left, right, value) {
  13379. 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;
  13380. }
  13381. function compareNumbers(previousData, data, options2) {
  13382. 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);
  13383. return src_default.undefined(actual) || (changed = changed && right === actual), src_default.undefined(previous) || (changed = changed && left === previous), changed;
  13384. }
  13385. function compareValues(previousData, data, options2) {
  13386. let { key, type, value } = options2, left = nested(previousData, key), right = nested(data, key), primary = type === "added" ? left : right, secondary = type === "added" ? right : left;
  13387. if (!src_default.nullOrUndefined(value)) {
  13388. if (src_default.defined(primary)) {
  13389. if (src_default.array(primary) || src_default.plainObject(primary))
  13390. return checkEquality(primary, secondary, value);
  13391. } else
  13392. return equal(secondary, value);
  13393. return !1;
  13394. }
  13395. 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));
  13396. }
  13397. function getIterables(previousData, data, { key } = {}) {
  13398. let left = nested(previousData, key), right = nested(data, key);
  13399. if (!isSameType(left, right))
  13400. throw new TypeError("Inputs have different types");
  13401. if (!canHaveLength(left, right))
  13402. throw new TypeError("Inputs don't have length");
  13403. return [left, right].every(src_default.plainObject) && (left = Object.keys(left), right = Object.keys(right)), [left, right];
  13404. }
  13405. function hasEntry(input) {
  13406. 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);
  13407. }
  13408. function hasExtraKeys(left, right) {
  13409. return right.some((d2) => !left.includes(d2));
  13410. }
  13411. function hasValue(input) {
  13412. return (value) => src_default.array(input) ? input.some((d2) => equal(d2, value) || src_default.array(value) && isEqualPredicate(value)(d2)) : equal(input, value);
  13413. }
  13414. function includesOrEqualsTo(previousValue, value) {
  13415. return src_default.array(previousValue) ? previousValue.some((d2) => equal(d2, value)) : equal(previousValue, value);
  13416. }
  13417. function isEqualPredicate(data) {
  13418. return (value) => data.some((d2) => equal(d2, value));
  13419. }
  13420. function isSameType(...arguments_) {
  13421. return arguments_.every(src_default.array) || arguments_.every(src_default.number) || arguments_.every(src_default.plainObject) || arguments_.every(src_default.string);
  13422. }
  13423. function nested(data, property) {
  13424. 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;
  13425. }
  13426. function treeChanges(previousData, data) {
  13427. if ([previousData, data].some(src_default.nullOrUndefined))
  13428. throw new Error("Missing required parameters");
  13429. if (![previousData, data].every((d2) => src_default.plainObject(d2) || src_default.array(d2)))
  13430. throw new Error("Expected plain objects or array");
  13431. return { added: (key, value) => {
  13432. try {
  13433. return compareValues(previousData, data, { key, type: "added", value });
  13434. } catch {
  13435. return !1;
  13436. }
  13437. }, changed: (key, actual, previous) => {
  13438. try {
  13439. let left = nested(previousData, key), right = nested(data, key), hasActual = src_default.defined(actual), hasPrevious = src_default.defined(previous);
  13440. if (hasActual || hasPrevious) {
  13441. let leftComparator = hasPrevious ? includesOrEqualsTo(previous, left) : !includesOrEqualsTo(actual, left), rightComparator = includesOrEqualsTo(actual, right);
  13442. return leftComparator && rightComparator;
  13443. }
  13444. return [left, right].every(src_default.array) || [left, right].every(src_default.plainObject) ? !equal(left, right) : left !== right;
  13445. } catch {
  13446. return !1;
  13447. }
  13448. }, changedFrom: (key, previous, actual) => {
  13449. if (!src_default.defined(key))
  13450. return !1;
  13451. try {
  13452. let left = nested(previousData, key), right = nested(data, key), hasActual = src_default.defined(actual);
  13453. return includesOrEqualsTo(previous, left) && (hasActual ? includesOrEqualsTo(actual, right) : !hasActual);
  13454. } catch {
  13455. return !1;
  13456. }
  13457. }, decreased: (key, actual, previous) => {
  13458. if (!src_default.defined(key))
  13459. return !1;
  13460. try {
  13461. return compareNumbers(previousData, data, { key, actual, previous, type: "decreased" });
  13462. } catch {
  13463. return !1;
  13464. }
  13465. }, emptied: (key) => {
  13466. try {
  13467. let [left, right] = getIterables(previousData, data, { key });
  13468. return !!left.length && !right.length;
  13469. } catch {
  13470. return !1;
  13471. }
  13472. }, filled: (key) => {
  13473. try {
  13474. let [left, right] = getIterables(previousData, data, { key });
  13475. return !left.length && !!right.length;
  13476. } catch {
  13477. return !1;
  13478. }
  13479. }, increased: (key, actual, previous) => {
  13480. if (!src_default.defined(key))
  13481. return !1;
  13482. try {
  13483. return compareNumbers(previousData, data, { key, actual, previous, type: "increased" });
  13484. } catch {
  13485. return !1;
  13486. }
  13487. }, removed: (key, value) => {
  13488. try {
  13489. return compareValues(previousData, data, { key, type: "removed", value });
  13490. } catch {
  13491. return !1;
  13492. }
  13493. } };
  13494. }
  13495. // ../../node_modules/react-joyride/dist/index.mjs
  13496. var import_scroll = __toESM(require_scroll(), 1), import_scrollparent = __toESM(require_scrollparent(), 1);
  13497. init_react();
  13498. var import_react_innertext = __toESM(require_react_innertext(), 1);
  13499. var import_deepmerge2 = __toESM(require_cjs(), 1);
  13500. var import_deepmerge3 = __toESM(require_cjs(), 1);
  13501. init_react();
  13502. init_react();
  13503. init_react();
  13504. init_react();
  13505. // ../../node_modules/react-floater/es/index.js
  13506. init_react();
  13507. var import_prop_types2 = __toESM(require_prop_types());
  13508. // ../../node_modules/popper.js/dist/esm/popper.js
  13509. var isBrowser2 = typeof window < "u" && typeof document < "u" && typeof navigator < "u", timeoutDuration = (function() {
  13510. for (var longerTimeoutBrowsers = ["Edge", "Trident", "Firefox"], i2 = 0; i2 < longerTimeoutBrowsers.length; i2 += 1)
  13511. if (isBrowser2 && navigator.userAgent.indexOf(longerTimeoutBrowsers[i2]) >= 0)
  13512. return 1;
  13513. return 0;
  13514. })();
  13515. function microtaskDebounce(fn) {
  13516. var called = !1;
  13517. return function() {
  13518. called || (called = !0, window.Promise.resolve().then(function() {
  13519. called = !1, fn();
  13520. }));
  13521. };
  13522. }
  13523. function taskDebounce(fn) {
  13524. var scheduled = !1;
  13525. return function() {
  13526. scheduled || (scheduled = !0, setTimeout(function() {
  13527. scheduled = !1, fn();
  13528. }, timeoutDuration));
  13529. };
  13530. }
  13531. var supportsMicroTasks = isBrowser2 && window.Promise, debounce2 = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  13532. function isFunction3(functionToCheck) {
  13533. var getType = {};
  13534. return functionToCheck && getType.toString.call(functionToCheck) === "[object Function]";
  13535. }
  13536. function getStyleComputedProperty(element, property) {
  13537. if (element.nodeType !== 1)
  13538. return [];
  13539. var window2 = element.ownerDocument.defaultView, css2 = window2.getComputedStyle(element, null);
  13540. return property ? css2[property] : css2;
  13541. }
  13542. function getParentNode(element) {
  13543. return element.nodeName === "HTML" ? element : element.parentNode || element.host;
  13544. }
  13545. function getScrollParent(element) {
  13546. if (!element)
  13547. return document.body;
  13548. switch (element.nodeName) {
  13549. case "HTML":
  13550. case "BODY":
  13551. return element.ownerDocument.body;
  13552. case "#document":
  13553. return element.body;
  13554. }
  13555. var _getStyleComputedProp = getStyleComputedProperty(element), overflow = _getStyleComputedProp.overflow, overflowX = _getStyleComputedProp.overflowX, overflowY = _getStyleComputedProp.overflowY;
  13556. return /(auto|scroll|overlay)/.test(overflow + overflowY + overflowX) ? element : getScrollParent(getParentNode(element));
  13557. }
  13558. function getReferenceNode(reference) {
  13559. return reference && reference.referenceNode ? reference.referenceNode : reference;
  13560. }
  13561. var isIE11 = isBrowser2 && !!(window.MSInputMethodContext && document.documentMode), isIE10 = isBrowser2 && /MSIE 10/.test(navigator.userAgent);
  13562. function isIE(version3) {
  13563. return version3 === 11 ? isIE11 : version3 === 10 ? isIE10 : isIE11 || isIE10;
  13564. }
  13565. function getOffsetParent(element) {
  13566. if (!element)
  13567. return document.documentElement;
  13568. for (var noOffsetParent = isIE(10) ? document.body : null, offsetParent = element.offsetParent || null; offsetParent === noOffsetParent && element.nextElementSibling; )
  13569. offsetParent = (element = element.nextElementSibling).offsetParent;
  13570. var nodeName = offsetParent && offsetParent.nodeName;
  13571. 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;
  13572. }
  13573. function isOffsetContainer(element) {
  13574. var nodeName = element.nodeName;
  13575. return nodeName === "BODY" ? !1 : nodeName === "HTML" || getOffsetParent(element.firstElementChild) === element;
  13576. }
  13577. function getRoot(node) {
  13578. return node.parentNode !== null ? getRoot(node.parentNode) : node;
  13579. }
  13580. function findCommonOffsetParent(element1, element2) {
  13581. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType)
  13582. return document.documentElement;
  13583. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING, start = order ? element1 : element2, end = order ? element2 : element1, range = document.createRange();
  13584. range.setStart(start, 0), range.setEnd(end, 0);
  13585. var commonAncestorContainer = range.commonAncestorContainer;
  13586. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end))
  13587. return isOffsetContainer(commonAncestorContainer) ? commonAncestorContainer : getOffsetParent(commonAncestorContainer);
  13588. var element1root = getRoot(element1);
  13589. return element1root.host ? findCommonOffsetParent(element1root.host, element2) : findCommonOffsetParent(element1, getRoot(element2).host);
  13590. }
  13591. function getScroll(element) {
  13592. var side = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "top", upperSide = side === "top" ? "scrollTop" : "scrollLeft", nodeName = element.nodeName;
  13593. if (nodeName === "BODY" || nodeName === "HTML") {
  13594. var html = element.ownerDocument.documentElement, scrollingElement = element.ownerDocument.scrollingElement || html;
  13595. return scrollingElement[upperSide];
  13596. }
  13597. return element[upperSide];
  13598. }
  13599. function includeScroll(rect, element) {
  13600. var subtract = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, scrollTop = getScroll(element, "top"), scrollLeft = getScroll(element, "left"), modifier = subtract ? -1 : 1;
  13601. return rect.top += scrollTop * modifier, rect.bottom += scrollTop * modifier, rect.left += scrollLeft * modifier, rect.right += scrollLeft * modifier, rect;
  13602. }
  13603. function getBordersSize(styles2, axis) {
  13604. var sideA = axis === "x" ? "Left" : "Top", sideB = sideA === "Left" ? "Right" : "Bottom";
  13605. return parseFloat(styles2["border" + sideA + "Width"]) + parseFloat(styles2["border" + sideB + "Width"]);
  13606. }
  13607. function getSize(axis, body, html, computedStyle) {
  13608. 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);
  13609. }
  13610. function getWindowSizes(document11) {
  13611. var body = document11.body, html = document11.documentElement, computedStyle = isIE(10) && getComputedStyle(html);
  13612. return {
  13613. height: getSize("Height", body, html, computedStyle),
  13614. width: getSize("Width", body, html, computedStyle)
  13615. };
  13616. }
  13617. var classCallCheck = function(instance, Constructor) {
  13618. if (!(instance instanceof Constructor))
  13619. throw new TypeError("Cannot call a class as a function");
  13620. }, createClass = /* @__PURE__ */ (function() {
  13621. function defineProperties(target, props) {
  13622. for (var i2 = 0; i2 < props.length; i2++) {
  13623. var descriptor = props[i2];
  13624. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
  13625. }
  13626. }
  13627. return function(Constructor, protoProps, staticProps) {
  13628. return protoProps && defineProperties(Constructor.prototype, protoProps), staticProps && defineProperties(Constructor, staticProps), Constructor;
  13629. };
  13630. })(), defineProperty = function(obj, key, value) {
  13631. return key in obj ? Object.defineProperty(obj, key, {
  13632. value,
  13633. enumerable: !0,
  13634. configurable: !0,
  13635. writable: !0
  13636. }) : obj[key] = value, obj;
  13637. }, _extends2 = Object.assign || function(target) {
  13638. for (var i2 = 1; i2 < arguments.length; i2++) {
  13639. var source = arguments[i2];
  13640. for (var key in source)
  13641. Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
  13642. }
  13643. return target;
  13644. };
  13645. function getClientRect(offsets) {
  13646. return _extends2({}, offsets, {
  13647. right: offsets.left + offsets.width,
  13648. bottom: offsets.top + offsets.height
  13649. });
  13650. }
  13651. function getBoundingClientRect(element) {
  13652. var rect = {};
  13653. try {
  13654. if (isIE(10)) {
  13655. rect = element.getBoundingClientRect();
  13656. var scrollTop = getScroll(element, "top"), scrollLeft = getScroll(element, "left");
  13657. rect.top += scrollTop, rect.left += scrollLeft, rect.bottom += scrollTop, rect.right += scrollLeft;
  13658. } else
  13659. rect = element.getBoundingClientRect();
  13660. } catch {
  13661. }
  13662. var result = {
  13663. left: rect.left,
  13664. top: rect.top,
  13665. width: rect.right - rect.left,
  13666. height: rect.bottom - rect.top
  13667. }, 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;
  13668. if (horizScrollbar || vertScrollbar) {
  13669. var styles2 = getStyleComputedProperty(element);
  13670. horizScrollbar -= getBordersSize(styles2, "x"), vertScrollbar -= getBordersSize(styles2, "y"), result.width -= horizScrollbar, result.height -= vertScrollbar;
  13671. }
  13672. return getClientRect(result);
  13673. }
  13674. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  13675. 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);
  13676. fixedPosition && isHTML && (parentRect.top = Math.max(parentRect.top, 0), parentRect.left = Math.max(parentRect.left, 0));
  13677. var offsets = getClientRect({
  13678. top: childrenRect.top - parentRect.top - borderTopWidth,
  13679. left: childrenRect.left - parentRect.left - borderLeftWidth,
  13680. width: childrenRect.width,
  13681. height: childrenRect.height
  13682. });
  13683. if (offsets.marginTop = 0, offsets.marginLeft = 0, !isIE102 && isHTML) {
  13684. var marginTop = parseFloat(styles2.marginTop), marginLeft = parseFloat(styles2.marginLeft);
  13685. offsets.top -= borderTopWidth - marginTop, offsets.bottom -= borderTopWidth - marginTop, offsets.left -= borderLeftWidth - marginLeft, offsets.right -= borderLeftWidth - marginLeft, offsets.marginTop = marginTop, offsets.marginLeft = marginLeft;
  13686. }
  13687. return (isIE102 && !fixedPosition ? parent.contains(scrollParent2) : parent === scrollParent2 && scrollParent2.nodeName !== "BODY") && (offsets = includeScroll(offsets, parent)), offsets;
  13688. }
  13689. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  13690. 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 = {
  13691. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  13692. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  13693. width,
  13694. height
  13695. };
  13696. return getClientRect(offset2);
  13697. }
  13698. function isFixed(element) {
  13699. var nodeName = element.nodeName;
  13700. if (nodeName === "BODY" || nodeName === "HTML")
  13701. return !1;
  13702. if (getStyleComputedProperty(element, "position") === "fixed")
  13703. return !0;
  13704. var parentNode = getParentNode(element);
  13705. return parentNode ? isFixed(parentNode) : !1;
  13706. }
  13707. function getFixedPositionOffsetParent(element) {
  13708. if (!element || !element.parentElement || isIE())
  13709. return document.documentElement;
  13710. for (var el = element.parentElement; el && getStyleComputedProperty(el, "transform") === "none"; )
  13711. el = el.parentElement;
  13712. return el || document.documentElement;
  13713. }
  13714. function getBoundaries(popper, reference, padding, boundariesElement) {
  13715. 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));
  13716. if (boundariesElement === "viewport")
  13717. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  13718. else {
  13719. var boundariesNode = void 0;
  13720. boundariesElement === "scrollParent" ? (boundariesNode = getScrollParent(getParentNode(reference)), boundariesNode.nodeName === "BODY" && (boundariesNode = popper.ownerDocument.documentElement)) : boundariesElement === "window" ? boundariesNode = popper.ownerDocument.documentElement : boundariesNode = boundariesElement;
  13721. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  13722. if (boundariesNode.nodeName === "HTML" && !isFixed(offsetParent)) {
  13723. var _getWindowSizes = getWindowSizes(popper.ownerDocument), height = _getWindowSizes.height, width = _getWindowSizes.width;
  13724. boundaries.top += offsets.top - offsets.marginTop, boundaries.bottom = height + offsets.top, boundaries.left += offsets.left - offsets.marginLeft, boundaries.right = width + offsets.left;
  13725. } else
  13726. boundaries = offsets;
  13727. }
  13728. padding = padding || 0;
  13729. var isPaddingNumber = typeof padding == "number";
  13730. 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;
  13731. }
  13732. function getArea(_ref) {
  13733. var width = _ref.width, height = _ref.height;
  13734. return width * height;
  13735. }
  13736. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  13737. var padding = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 0;
  13738. if (placement.indexOf("auto") === -1)
  13739. return placement;
  13740. var boundaries = getBoundaries(popper, reference, padding, boundariesElement), rects = {
  13741. top: {
  13742. width: boundaries.width,
  13743. height: refRect.top - boundaries.top
  13744. },
  13745. right: {
  13746. width: boundaries.right - refRect.right,
  13747. height: boundaries.height
  13748. },
  13749. bottom: {
  13750. width: boundaries.width,
  13751. height: boundaries.bottom - refRect.bottom
  13752. },
  13753. left: {
  13754. width: refRect.left - boundaries.left,
  13755. height: boundaries.height
  13756. }
  13757. }, sortedAreas = Object.keys(rects).map(function(key) {
  13758. return _extends2({
  13759. key
  13760. }, rects[key], {
  13761. area: getArea(rects[key])
  13762. });
  13763. }).sort(function(a2, b2) {
  13764. return b2.area - a2.area;
  13765. }), filteredAreas = sortedAreas.filter(function(_ref2) {
  13766. var width = _ref2.width, height = _ref2.height;
  13767. return width >= popper.clientWidth && height >= popper.clientHeight;
  13768. }), computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key, variation = placement.split("-")[1];
  13769. return computedPlacement + (variation ? "-" + variation : "");
  13770. }
  13771. function getReferenceOffsets(state, popper, reference) {
  13772. var fixedPosition = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  13773. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  13774. }
  13775. function getOuterSizes(element) {
  13776. 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 = {
  13777. width: element.offsetWidth + y2,
  13778. height: element.offsetHeight + x2
  13779. };
  13780. return result;
  13781. }
  13782. function getOppositePlacement(placement) {
  13783. var hash = { left: "right", right: "left", bottom: "top", top: "bottom" };
  13784. return placement.replace(/left|right|bottom|top/g, function(matched) {
  13785. return hash[matched];
  13786. });
  13787. }
  13788. function getPopperOffsets(popper, referenceOffsets, placement) {
  13789. placement = placement.split("-")[0];
  13790. var popperRect = getOuterSizes(popper), popperOffsets = {
  13791. width: popperRect.width,
  13792. height: popperRect.height
  13793. }, isHoriz = ["right", "left"].indexOf(placement) !== -1, mainSide = isHoriz ? "top" : "left", secondarySide = isHoriz ? "left" : "top", measurement = isHoriz ? "height" : "width", secondaryMeasurement = isHoriz ? "width" : "height";
  13794. 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;
  13795. }
  13796. function find(arr, check) {
  13797. return Array.prototype.find ? arr.find(check) : arr.filter(check)[0];
  13798. }
  13799. function findIndex(arr, prop, value) {
  13800. if (Array.prototype.findIndex)
  13801. return arr.findIndex(function(cur) {
  13802. return cur[prop] === value;
  13803. });
  13804. var match = find(arr, function(obj) {
  13805. return obj[prop] === value;
  13806. });
  13807. return arr.indexOf(match);
  13808. }
  13809. function runModifiers(modifiers2, data, ends) {
  13810. var modifiersToRun = ends === void 0 ? modifiers2 : modifiers2.slice(0, findIndex(modifiers2, "name", ends));
  13811. return modifiersToRun.forEach(function(modifier) {
  13812. modifier.function && console.warn("`modifier.function` is deprecated, use `modifier.fn`!");
  13813. var fn = modifier.function || modifier.fn;
  13814. modifier.enabled && isFunction3(fn) && (data.offsets.popper = getClientRect(data.offsets.popper), data.offsets.reference = getClientRect(data.offsets.reference), data = fn(data, modifier));
  13815. }), data;
  13816. }
  13817. function update() {
  13818. if (!this.state.isDestroyed) {
  13819. var data = {
  13820. instance: this,
  13821. styles: {},
  13822. arrowStyles: {},
  13823. attributes: {},
  13824. flipped: !1,
  13825. offsets: {}
  13826. };
  13827. 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));
  13828. }
  13829. }
  13830. function isModifierEnabled(modifiers2, modifierName) {
  13831. return modifiers2.some(function(_ref) {
  13832. var name = _ref.name, enabled = _ref.enabled;
  13833. return enabled && name === modifierName;
  13834. });
  13835. }
  13836. function getSupportedPropertyName(property) {
  13837. for (var prefixes = [!1, "ms", "Webkit", "Moz", "O"], upperProp = property.charAt(0).toUpperCase() + property.slice(1), i2 = 0; i2 < prefixes.length; i2++) {
  13838. var prefix = prefixes[i2], toCheck = prefix ? "" + prefix + upperProp : property;
  13839. if (typeof document.body.style[toCheck] < "u")
  13840. return toCheck;
  13841. }
  13842. return null;
  13843. }
  13844. function destroy() {
  13845. 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;
  13846. }
  13847. function getWindow(element) {
  13848. var ownerDocument = element.ownerDocument;
  13849. return ownerDocument ? ownerDocument.defaultView : window;
  13850. }
  13851. function attachToScrollParents(scrollParent2, event, callback, scrollParents) {
  13852. var isBody = scrollParent2.nodeName === "BODY", target = isBody ? scrollParent2.ownerDocument.defaultView : scrollParent2;
  13853. target.addEventListener(event, callback, { passive: !0 }), isBody || attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents), scrollParents.push(target);
  13854. }
  13855. function setupEventListeners(reference, options2, state, updateBound) {
  13856. state.updateBound = updateBound, getWindow(reference).addEventListener("resize", state.updateBound, { passive: !0 });
  13857. var scrollElement = getScrollParent(reference);
  13858. return attachToScrollParents(scrollElement, "scroll", state.updateBound, state.scrollParents), state.scrollElement = scrollElement, state.eventsEnabled = !0, state;
  13859. }
  13860. function enableEventListeners() {
  13861. this.state.eventsEnabled || (this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate));
  13862. }
  13863. function removeEventListeners(reference, state) {
  13864. return getWindow(reference).removeEventListener("resize", state.updateBound), state.scrollParents.forEach(function(target) {
  13865. target.removeEventListener("scroll", state.updateBound);
  13866. }), state.updateBound = null, state.scrollParents = [], state.scrollElement = null, state.eventsEnabled = !1, state;
  13867. }
  13868. function disableEventListeners() {
  13869. this.state.eventsEnabled && (cancelAnimationFrame(this.scheduleUpdate), this.state = removeEventListeners(this.reference, this.state));
  13870. }
  13871. function isNumeric(n3) {
  13872. return n3 !== "" && !isNaN(parseFloat(n3)) && isFinite(n3);
  13873. }
  13874. function setStyles(element, styles2) {
  13875. Object.keys(styles2).forEach(function(prop) {
  13876. var unit = "";
  13877. ["width", "height", "top", "right", "bottom", "left"].indexOf(prop) !== -1 && isNumeric(styles2[prop]) && (unit = "px"), element.style[prop] = styles2[prop] + unit;
  13878. });
  13879. }
  13880. function setAttributes(element, attributes) {
  13881. Object.keys(attributes).forEach(function(prop) {
  13882. var value = attributes[prop];
  13883. value !== !1 ? element.setAttribute(prop, attributes[prop]) : element.removeAttribute(prop);
  13884. });
  13885. }
  13886. function applyStyle(data) {
  13887. 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;
  13888. }
  13889. function applyStyleOnLoad(reference, popper, options2, modifierOptions, state) {
  13890. var referenceOffsets = getReferenceOffsets(state, popper, reference, options2.positionFixed), placement = computeAutoPlacement(options2.placement, referenceOffsets, popper, reference, options2.modifiers.flip.boundariesElement, options2.modifiers.flip.padding);
  13891. return popper.setAttribute("x-placement", placement), setStyles(popper, { position: options2.positionFixed ? "fixed" : "absolute" }), options2;
  13892. }
  13893. function getRoundedOffsets(data, shouldRound) {
  13894. var _data$offsets = data.offsets, popper = _data$offsets.popper, reference = _data$offsets.reference, round = Math.round, floor = Math.floor, noRound = function(v2) {
  13895. return v2;
  13896. }, 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;
  13897. return {
  13898. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  13899. top: verticalToInteger(popper.top),
  13900. bottom: verticalToInteger(popper.bottom),
  13901. right: horizontalToInteger(popper.right)
  13902. };
  13903. }
  13904. var isFirefox = isBrowser2 && /Firefox/i.test(navigator.userAgent);
  13905. function computeStyle(data, options2) {
  13906. var x2 = options2.x, y2 = options2.y, popper = data.offsets.popper, legacyGpuAccelerationOption = find(data.instance.modifiers, function(modifier) {
  13907. return modifier.name === "applyStyle";
  13908. }).gpuAcceleration;
  13909. legacyGpuAccelerationOption !== void 0 && console.warn("WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!");
  13910. var gpuAcceleration = legacyGpuAccelerationOption !== void 0 ? legacyGpuAccelerationOption : options2.gpuAcceleration, offsetParent = getOffsetParent(data.instance.popper), offsetParentRect = getBoundingClientRect(offsetParent), styles2 = {
  13911. position: popper.position
  13912. }, 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;
  13913. 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)
  13914. styles2[prefixedProperty] = "translate3d(" + left + "px, " + top + "px, 0)", styles2[sideA] = 0, styles2[sideB] = 0, styles2.willChange = "transform";
  13915. else {
  13916. var invertTop = sideA === "bottom" ? -1 : 1, invertLeft = sideB === "right" ? -1 : 1;
  13917. styles2[sideA] = top * invertTop, styles2[sideB] = left * invertLeft, styles2.willChange = sideA + ", " + sideB;
  13918. }
  13919. var attributes = {
  13920. "x-placement": data.placement
  13921. };
  13922. return data.attributes = _extends2({}, attributes, data.attributes), data.styles = _extends2({}, styles2, data.styles), data.arrowStyles = _extends2({}, data.offsets.arrow, data.arrowStyles), data;
  13923. }
  13924. function isModifierRequired(modifiers2, requestingName, requestedName) {
  13925. var requesting = find(modifiers2, function(_ref) {
  13926. var name = _ref.name;
  13927. return name === requestingName;
  13928. }), isRequired = !!requesting && modifiers2.some(function(modifier) {
  13929. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  13930. });
  13931. if (!isRequired) {
  13932. var _requesting = "`" + requestingName + "`", requested = "`" + requestedName + "`";
  13933. console.warn(requested + " modifier is required by " + _requesting + " modifier in order to work, be sure to include it before " + _requesting + "!");
  13934. }
  13935. return isRequired;
  13936. }
  13937. function arrow(data, options2) {
  13938. var _data$offsets$arrow;
  13939. if (!isModifierRequired(data.instance.modifiers, "arrow", "keepTogether"))
  13940. return data;
  13941. var arrowElement = options2.element;
  13942. if (typeof arrowElement == "string") {
  13943. if (arrowElement = data.instance.popper.querySelector(arrowElement), !arrowElement)
  13944. return data;
  13945. } else if (!data.instance.popper.contains(arrowElement))
  13946. return console.warn("WARNING: `arrow.element` must be child of its popper element!"), data;
  13947. 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];
  13948. 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);
  13949. 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;
  13950. 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;
  13951. }
  13952. function getOppositeVariation(variation) {
  13953. return variation === "end" ? "start" : variation === "start" ? "end" : variation;
  13954. }
  13955. 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);
  13956. function clockwise(placement) {
  13957. 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));
  13958. return counter ? arr.reverse() : arr;
  13959. }
  13960. var BEHAVIORS = {
  13961. FLIP: "flip",
  13962. CLOCKWISE: "clockwise",
  13963. COUNTERCLOCKWISE: "counterclockwise"
  13964. };
  13965. function flip(data, options2) {
  13966. if (isModifierEnabled(data.instance.modifiers, "inner") || data.flipped && data.placement === data.originalPlacement)
  13967. return data;
  13968. 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 = [];
  13969. switch (options2.behavior) {
  13970. case BEHAVIORS.FLIP:
  13971. flipOrder = [placement, placementOpposite];
  13972. break;
  13973. case BEHAVIORS.CLOCKWISE:
  13974. flipOrder = clockwise(placement);
  13975. break;
  13976. case BEHAVIORS.COUNTERCLOCKWISE:
  13977. flipOrder = clockwise(placement, !0);
  13978. break;
  13979. default:
  13980. flipOrder = options2.behavior;
  13981. }
  13982. return flipOrder.forEach(function(step, index) {
  13983. if (placement !== step || flipOrder.length === index + 1)
  13984. return data;
  13985. placement = data.placement.split("-")[0], placementOpposite = getOppositePlacement(placement);
  13986. 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;
  13987. (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"));
  13988. }), data;
  13989. }
  13990. function keepTogether(data) {
  13991. 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";
  13992. 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;
  13993. }
  13994. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  13995. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/), value = +split[1], unit = split[2];
  13996. if (!value)
  13997. return str;
  13998. if (unit.indexOf("%") === 0) {
  13999. var element = void 0;
  14000. unit === "%p" ? element = popperOffsets : element = referenceOffsets;
  14001. var rect = getClientRect(element);
  14002. return rect[measurement] / 100 * value;
  14003. } else if (unit === "vh" || unit === "vw") {
  14004. var size = void 0;
  14005. return unit === "vh" ? size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) : size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0), size / 100 * value;
  14006. } else
  14007. return value;
  14008. }
  14009. function parseOffset(offset2, popperOffsets, referenceOffsets, basePlacement) {
  14010. var offsets = [0, 0], useHeight = ["right", "left"].indexOf(basePlacement) !== -1, fragments = offset2.split(/(\+|\-)/).map(function(frag) {
  14011. return frag.trim();
  14012. }), divider = fragments.indexOf(find(fragments, function(frag) {
  14013. return frag.search(/,|\s/) !== -1;
  14014. }));
  14015. fragments[divider] && fragments[divider].indexOf(",") === -1 && console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");
  14016. 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];
  14017. return ops = ops.map(function(op, index) {
  14018. var measurement = (index === 1 ? !useHeight : useHeight) ? "height" : "width", mergeWithPrevious = !1;
  14019. return op.reduce(function(a2, b2) {
  14020. 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);
  14021. }, []).map(function(str) {
  14022. return toValue(str, measurement, popperOffsets, referenceOffsets);
  14023. });
  14024. }), ops.forEach(function(op, index) {
  14025. op.forEach(function(frag, index2) {
  14026. isNumeric(frag) && (offsets[index] += frag * (op[index2 - 1] === "-" ? -1 : 1));
  14027. });
  14028. }), offsets;
  14029. }
  14030. function offset(data, _ref) {
  14031. 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;
  14032. 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;
  14033. }
  14034. function preventOverflow(data, options2) {
  14035. var boundariesElement = options2.boundariesElement || getOffsetParent(data.instance.popper);
  14036. data.instance.reference === boundariesElement && (boundariesElement = getOffsetParent(boundariesElement));
  14037. var transformProp = getSupportedPropertyName("transform"), popperStyles = data.instance.popper.style, top = popperStyles.top, left = popperStyles.left, transform = popperStyles[transformProp];
  14038. popperStyles.top = "", popperStyles.left = "", popperStyles[transformProp] = "";
  14039. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options2.padding, boundariesElement, data.positionFixed);
  14040. popperStyles.top = top, popperStyles.left = left, popperStyles[transformProp] = transform, options2.boundaries = boundaries;
  14041. var order = options2.priority, popper = data.offsets.popper, check = {
  14042. primary: function(placement) {
  14043. var value = popper[placement];
  14044. return popper[placement] < boundaries[placement] && !options2.escapeWithReference && (value = Math.max(popper[placement], boundaries[placement])), defineProperty({}, placement, value);
  14045. },
  14046. secondary: function(placement) {
  14047. var mainSide = placement === "right" ? "left" : "top", value = popper[mainSide];
  14048. return popper[placement] > boundaries[placement] && !options2.escapeWithReference && (value = Math.min(popper[mainSide], boundaries[placement] - (placement === "right" ? popper.width : popper.height))), defineProperty({}, mainSide, value);
  14049. }
  14050. };
  14051. return order.forEach(function(placement) {
  14052. var side = ["left", "top"].indexOf(placement) !== -1 ? "primary" : "secondary";
  14053. popper = _extends2({}, popper, check[side](placement));
  14054. }), data.offsets.popper = popper, data;
  14055. }
  14056. function shift(data) {
  14057. var placement = data.placement, basePlacement = placement.split("-")[0], shiftvariation = placement.split("-")[1];
  14058. if (shiftvariation) {
  14059. 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 = {
  14060. start: defineProperty({}, side, reference[side]),
  14061. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  14062. };
  14063. data.offsets.popper = _extends2({}, popper, shiftOffsets[shiftvariation]);
  14064. }
  14065. return data;
  14066. }
  14067. function hide(data) {
  14068. if (!isModifierRequired(data.instance.modifiers, "hide", "preventOverflow"))
  14069. return data;
  14070. var refRect = data.offsets.reference, bound = find(data.instance.modifiers, function(modifier) {
  14071. return modifier.name === "preventOverflow";
  14072. }).boundaries;
  14073. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  14074. if (data.hide === !0)
  14075. return data;
  14076. data.hide = !0, data.attributes["x-out-of-boundaries"] = "";
  14077. } else {
  14078. if (data.hide === !1)
  14079. return data;
  14080. data.hide = !1, data.attributes["x-out-of-boundaries"] = !1;
  14081. }
  14082. return data;
  14083. }
  14084. function inner(data) {
  14085. 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;
  14086. return popper[isHoriz ? "left" : "top"] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? "width" : "height"] : 0), data.placement = getOppositePlacement(placement), data.offsets.popper = getClientRect(popper), data;
  14087. }
  14088. var modifiers = {
  14089. /**
  14090. * Modifier used to shift the popper on the start or end of its reference
  14091. * element.<br />
  14092. * It will read the variation of the `placement` property.<br />
  14093. * It can be one either `-end` or `-start`.
  14094. * @memberof modifiers
  14095. * @inner
  14096. */
  14097. shift: {
  14098. /** @prop {number} order=100 - Index used to define the order of execution */
  14099. order: 100,
  14100. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14101. enabled: !0,
  14102. /** @prop {ModifierFn} */
  14103. fn: shift
  14104. },
  14105. /**
  14106. * The `offset` modifier can shift your popper on both its axis.
  14107. *
  14108. * It accepts the following units:
  14109. * - `px` or unit-less, interpreted as pixels
  14110. * - `%` or `%r`, percentage relative to the length of the reference element
  14111. * - `%p`, percentage relative to the length of the popper element
  14112. * - `vw`, CSS viewport width unit
  14113. * - `vh`, CSS viewport height unit
  14114. *
  14115. * For length is intended the main axis relative to the placement of the popper.<br />
  14116. * This means that if the placement is `top` or `bottom`, the length will be the
  14117. * `width`. In case of `left` or `right`, it will be the `height`.
  14118. *
  14119. * You can provide a single value (as `Number` or `String`), or a pair of values
  14120. * as `String` divided by a comma or one (or more) white spaces.<br />
  14121. * The latter is a deprecated method because it leads to confusion and will be
  14122. * removed in v2.<br />
  14123. * Additionally, it accepts additions and subtractions between different units.
  14124. * Note that multiplications and divisions aren't supported.
  14125. *
  14126. * Valid examples are:
  14127. * ```
  14128. * 10
  14129. * '10%'
  14130. * '10, 10'
  14131. * '10%, 10'
  14132. * '10 + 10%'
  14133. * '10 - 5vh + 3%'
  14134. * '-10px + 5vh, 5px - 6%'
  14135. * ```
  14136. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  14137. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  14138. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  14139. *
  14140. * @memberof modifiers
  14141. * @inner
  14142. */
  14143. offset: {
  14144. /** @prop {number} order=200 - Index used to define the order of execution */
  14145. order: 200,
  14146. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14147. enabled: !0,
  14148. /** @prop {ModifierFn} */
  14149. fn: offset,
  14150. /** @prop {Number|String} offset=0
  14151. * The offset value as described in the modifier description
  14152. */
  14153. offset: 0
  14154. },
  14155. /**
  14156. * Modifier used to prevent the popper from being positioned outside the boundary.
  14157. *
  14158. * A scenario exists where the reference itself is not within the boundaries.<br />
  14159. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  14160. * In this case we need to decide whether the popper should either:
  14161. *
  14162. * - detach from the reference and remain "trapped" in the boundaries, or
  14163. * - if it should ignore the boundary and "escape with its reference"
  14164. *
  14165. * When `escapeWithReference` is set to`true` and reference is completely
  14166. * outside its boundaries, the popper will overflow (or completely leave)
  14167. * the boundaries in order to remain attached to the edge of the reference.
  14168. *
  14169. * @memberof modifiers
  14170. * @inner
  14171. */
  14172. preventOverflow: {
  14173. /** @prop {number} order=300 - Index used to define the order of execution */
  14174. order: 300,
  14175. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14176. enabled: !0,
  14177. /** @prop {ModifierFn} */
  14178. fn: preventOverflow,
  14179. /**
  14180. * @prop {Array} [priority=['left','right','top','bottom']]
  14181. * Popper will try to prevent overflow following these priorities by default,
  14182. * then, it could overflow on the left and on top of the `boundariesElement`
  14183. */
  14184. priority: ["left", "right", "top", "bottom"],
  14185. /**
  14186. * @prop {number} padding=5
  14187. * Amount of pixel used to define a minimum distance between the boundaries
  14188. * and the popper. This makes sure the popper always has a little padding
  14189. * between the edges of its container
  14190. */
  14191. padding: 5,
  14192. /**
  14193. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  14194. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  14195. * `viewport` or any DOM element.
  14196. */
  14197. boundariesElement: "scrollParent"
  14198. },
  14199. /**
  14200. * Modifier used to make sure the reference and its popper stay near each other
  14201. * without leaving any gap between the two. Especially useful when the arrow is
  14202. * enabled and you want to ensure that it points to its reference element.
  14203. * It cares only about the first axis. You can still have poppers with margin
  14204. * between the popper and its reference element.
  14205. * @memberof modifiers
  14206. * @inner
  14207. */
  14208. keepTogether: {
  14209. /** @prop {number} order=400 - Index used to define the order of execution */
  14210. order: 400,
  14211. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14212. enabled: !0,
  14213. /** @prop {ModifierFn} */
  14214. fn: keepTogether
  14215. },
  14216. /**
  14217. * This modifier is used to move the `arrowElement` of the popper to make
  14218. * sure it is positioned between the reference element and its popper element.
  14219. * It will read the outer size of the `arrowElement` node to detect how many
  14220. * pixels of conjunction are needed.
  14221. *
  14222. * It has no effect if no `arrowElement` is provided.
  14223. * @memberof modifiers
  14224. * @inner
  14225. */
  14226. arrow: {
  14227. /** @prop {number} order=500 - Index used to define the order of execution */
  14228. order: 500,
  14229. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14230. enabled: !0,
  14231. /** @prop {ModifierFn} */
  14232. fn: arrow,
  14233. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  14234. element: "[x-arrow]"
  14235. },
  14236. /**
  14237. * Modifier used to flip the popper's placement when it starts to overlap its
  14238. * reference element.
  14239. *
  14240. * Requires the `preventOverflow` modifier before it in order to work.
  14241. *
  14242. * **NOTE:** this modifier will interrupt the current update cycle and will
  14243. * restart it if it detects the need to flip the placement.
  14244. * @memberof modifiers
  14245. * @inner
  14246. */
  14247. flip: {
  14248. /** @prop {number} order=600 - Index used to define the order of execution */
  14249. order: 600,
  14250. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14251. enabled: !0,
  14252. /** @prop {ModifierFn} */
  14253. fn: flip,
  14254. /**
  14255. * @prop {String|Array} behavior='flip'
  14256. * The behavior used to change the popper's placement. It can be one of
  14257. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  14258. * placements (with optional variations)
  14259. */
  14260. behavior: "flip",
  14261. /**
  14262. * @prop {number} padding=5
  14263. * The popper will flip if it hits the edges of the `boundariesElement`
  14264. */
  14265. padding: 5,
  14266. /**
  14267. * @prop {String|HTMLElement} boundariesElement='viewport'
  14268. * The element which will define the boundaries of the popper position.
  14269. * The popper will never be placed outside of the defined boundaries
  14270. * (except if `keepTogether` is enabled)
  14271. */
  14272. boundariesElement: "viewport",
  14273. /**
  14274. * @prop {Boolean} flipVariations=false
  14275. * The popper will switch placement variation between `-start` and `-end` when
  14276. * the reference element overlaps its boundaries.
  14277. *
  14278. * The original placement should have a set variation.
  14279. */
  14280. flipVariations: !1,
  14281. /**
  14282. * @prop {Boolean} flipVariationsByContent=false
  14283. * The popper will switch placement variation between `-start` and `-end` when
  14284. * the popper element overlaps its reference boundaries.
  14285. *
  14286. * The original placement should have a set variation.
  14287. */
  14288. flipVariationsByContent: !1
  14289. },
  14290. /**
  14291. * Modifier used to make the popper flow toward the inner of the reference element.
  14292. * By default, when this modifier is disabled, the popper will be placed outside
  14293. * the reference element.
  14294. * @memberof modifiers
  14295. * @inner
  14296. */
  14297. inner: {
  14298. /** @prop {number} order=700 - Index used to define the order of execution */
  14299. order: 700,
  14300. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  14301. enabled: !1,
  14302. /** @prop {ModifierFn} */
  14303. fn: inner
  14304. },
  14305. /**
  14306. * Modifier used to hide the popper when its reference element is outside of the
  14307. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  14308. * be used to hide with a CSS selector the popper when its reference is
  14309. * out of boundaries.
  14310. *
  14311. * Requires the `preventOverflow` modifier before it in order to work.
  14312. * @memberof modifiers
  14313. * @inner
  14314. */
  14315. hide: {
  14316. /** @prop {number} order=800 - Index used to define the order of execution */
  14317. order: 800,
  14318. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14319. enabled: !0,
  14320. /** @prop {ModifierFn} */
  14321. fn: hide
  14322. },
  14323. /**
  14324. * Computes the style that will be applied to the popper element to gets
  14325. * properly positioned.
  14326. *
  14327. * Note that this modifier will not touch the DOM, it just prepares the styles
  14328. * so that `applyStyle` modifier can apply it. This separation is useful
  14329. * in case you need to replace `applyStyle` with a custom implementation.
  14330. *
  14331. * This modifier has `850` as `order` value to maintain backward compatibility
  14332. * with previous versions of Popper.js. Expect the modifiers ordering method
  14333. * to change in future major versions of the library.
  14334. *
  14335. * @memberof modifiers
  14336. * @inner
  14337. */
  14338. computeStyle: {
  14339. /** @prop {number} order=850 - Index used to define the order of execution */
  14340. order: 850,
  14341. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14342. enabled: !0,
  14343. /** @prop {ModifierFn} */
  14344. fn: computeStyle,
  14345. /**
  14346. * @prop {Boolean} gpuAcceleration=true
  14347. * If true, it uses the CSS 3D transformation to position the popper.
  14348. * Otherwise, it will use the `top` and `left` properties
  14349. */
  14350. gpuAcceleration: !0,
  14351. /**
  14352. * @prop {string} [x='bottom']
  14353. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  14354. * Change this if your popper should grow in a direction different from `bottom`
  14355. */
  14356. x: "bottom",
  14357. /**
  14358. * @prop {string} [x='left']
  14359. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  14360. * Change this if your popper should grow in a direction different from `right`
  14361. */
  14362. y: "right"
  14363. },
  14364. /**
  14365. * Applies the computed styles to the popper element.
  14366. *
  14367. * All the DOM manipulations are limited to this modifier. This is useful in case
  14368. * you want to integrate Popper.js inside a framework or view library and you
  14369. * want to delegate all the DOM manipulations to it.
  14370. *
  14371. * Note that if you disable this modifier, you must make sure the popper element
  14372. * has its position set to `absolute` before Popper.js can do its work!
  14373. *
  14374. * Just disable this modifier and define your own to achieve the desired effect.
  14375. *
  14376. * @memberof modifiers
  14377. * @inner
  14378. */
  14379. applyStyle: {
  14380. /** @prop {number} order=900 - Index used to define the order of execution */
  14381. order: 900,
  14382. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  14383. enabled: !0,
  14384. /** @prop {ModifierFn} */
  14385. fn: applyStyle,
  14386. /** @prop {Function} */
  14387. onLoad: applyStyleOnLoad,
  14388. /**
  14389. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  14390. * @prop {Boolean} gpuAcceleration=true
  14391. * If true, it uses the CSS 3D transformation to position the popper.
  14392. * Otherwise, it will use the `top` and `left` properties
  14393. */
  14394. gpuAcceleration: void 0
  14395. }
  14396. }, Defaults = {
  14397. /**
  14398. * Popper's placement.
  14399. * @prop {Popper.placements} placement='bottom'
  14400. */
  14401. placement: "bottom",
  14402. /**
  14403. * Set this to true if you want popper to position it self in 'fixed' mode
  14404. * @prop {Boolean} positionFixed=false
  14405. */
  14406. positionFixed: !1,
  14407. /**
  14408. * Whether events (resize, scroll) are initially enabled.
  14409. * @prop {Boolean} eventsEnabled=true
  14410. */
  14411. eventsEnabled: !0,
  14412. /**
  14413. * Set to true if you want to automatically remove the popper when
  14414. * you call the `destroy` method.
  14415. * @prop {Boolean} removeOnDestroy=false
  14416. */
  14417. removeOnDestroy: !1,
  14418. /**
  14419. * Callback called when the popper is created.<br />
  14420. * By default, it is set to no-op.<br />
  14421. * Access Popper.js instance with `data.instance`.
  14422. * @prop {onCreate}
  14423. */
  14424. onCreate: function() {
  14425. },
  14426. /**
  14427. * Callback called when the popper is updated. This callback is not called
  14428. * on the initialization/creation of the popper, but only on subsequent
  14429. * updates.<br />
  14430. * By default, it is set to no-op.<br />
  14431. * Access Popper.js instance with `data.instance`.
  14432. * @prop {onUpdate}
  14433. */
  14434. onUpdate: function() {
  14435. },
  14436. /**
  14437. * List of modifiers used to modify the offsets before they are applied to the popper.
  14438. * They provide most of the functionalities of Popper.js.
  14439. * @prop {modifiers}
  14440. */
  14441. modifiers
  14442. }, Popper = (function() {
  14443. function Popper2(reference, popper) {
  14444. var _this = this, options2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
  14445. classCallCheck(this, Popper2), this.scheduleUpdate = function() {
  14446. return requestAnimationFrame(_this.update);
  14447. }, this.update = debounce2(this.update.bind(this)), this.options = _extends2({}, Popper2.Defaults, options2), this.state = {
  14448. isDestroyed: !1,
  14449. isCreated: !1,
  14450. scrollParents: []
  14451. }, 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) {
  14452. _this.options.modifiers[name] = _extends2({}, Popper2.Defaults.modifiers[name] || {}, options2.modifiers ? options2.modifiers[name] : {});
  14453. }), this.modifiers = Object.keys(this.options.modifiers).map(function(name) {
  14454. return _extends2({
  14455. name
  14456. }, _this.options.modifiers[name]);
  14457. }).sort(function(a2, b2) {
  14458. return a2.order - b2.order;
  14459. }), this.modifiers.forEach(function(modifierOptions) {
  14460. modifierOptions.enabled && isFunction3(modifierOptions.onLoad) && modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  14461. }), this.update();
  14462. var eventsEnabled = this.options.eventsEnabled;
  14463. eventsEnabled && this.enableEventListeners(), this.state.eventsEnabled = eventsEnabled;
  14464. }
  14465. return createClass(Popper2, [{
  14466. key: "update",
  14467. value: function() {
  14468. return update.call(this);
  14469. }
  14470. }, {
  14471. key: "destroy",
  14472. value: function() {
  14473. return destroy.call(this);
  14474. }
  14475. }, {
  14476. key: "enableEventListeners",
  14477. value: function() {
  14478. return enableEventListeners.call(this);
  14479. }
  14480. }, {
  14481. key: "disableEventListeners",
  14482. value: function() {
  14483. return disableEventListeners.call(this);
  14484. }
  14485. /**
  14486. * Schedules an update. It will run on the next UI update available.
  14487. * @method scheduleUpdate
  14488. * @memberof Popper
  14489. */
  14490. /**
  14491. * Collection of utilities useful when writing custom modifiers.
  14492. * Starting from version 1.7, this method is available only if you
  14493. * include `popper-utils.js` before `popper.js`.
  14494. *
  14495. * **DEPRECATION**: This way to access PopperUtils is deprecated
  14496. * and will be removed in v2! Use the PopperUtils module directly instead.
  14497. * Due to the high instability of the methods contained in Utils, we can't
  14498. * guarantee them to follow semver. Use them at your own risk!
  14499. * @static
  14500. * @private
  14501. * @type {Object}
  14502. * @deprecated since version 1.8
  14503. * @member Utils
  14504. * @memberof Popper
  14505. */
  14506. }]), Popper2;
  14507. })();
  14508. Popper.Utils = (typeof window < "u" ? window : global).PopperUtils;
  14509. Popper.placements = placements;
  14510. Popper.Defaults = Defaults;
  14511. var popper_default = Popper;
  14512. // ../../node_modules/react-floater/es/index.js
  14513. var import_deepmerge = __toESM(require_cjs());
  14514. // ../../node_modules/react-floater/node_modules/is-lite/esm/index.js
  14515. var DOM_PROPERTIES_TO_CHECK2 = [
  14516. "innerHTML",
  14517. "ownerDocument",
  14518. "style",
  14519. "attributes",
  14520. "nodeValue"
  14521. ], objectTypes2 = [
  14522. "Array",
  14523. "ArrayBuffer",
  14524. "AsyncFunction",
  14525. "AsyncGenerator",
  14526. "AsyncGeneratorFunction",
  14527. "Date",
  14528. "Error",
  14529. "Function",
  14530. "Generator",
  14531. "GeneratorFunction",
  14532. "HTMLElement",
  14533. "Map",
  14534. "Object",
  14535. "Promise",
  14536. "RegExp",
  14537. "Set",
  14538. "WeakMap",
  14539. "WeakSet"
  14540. ], primitiveTypes2 = [
  14541. "bigint",
  14542. "boolean",
  14543. "null",
  14544. "number",
  14545. "string",
  14546. "symbol",
  14547. "undefined"
  14548. ];
  14549. function getObjectType2(value) {
  14550. var objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  14551. if (/HTML\w+Element/.test(objectTypeName))
  14552. return "HTMLElement";
  14553. if (isObjectType2(objectTypeName))
  14554. return objectTypeName;
  14555. }
  14556. function isObjectOfType2(type) {
  14557. return function(value) {
  14558. return getObjectType2(value) === type;
  14559. };
  14560. }
  14561. function isObjectType2(name) {
  14562. return objectTypes2.includes(name);
  14563. }
  14564. function isOfType3(type) {
  14565. return function(value) {
  14566. return typeof value === type;
  14567. };
  14568. }
  14569. function isPrimitiveType2(name) {
  14570. return primitiveTypes2.includes(name);
  14571. }
  14572. function is2(value) {
  14573. if (value === null)
  14574. return "null";
  14575. switch (typeof value) {
  14576. case "bigint":
  14577. return "bigint";
  14578. case "boolean":
  14579. return "boolean";
  14580. case "number":
  14581. return "number";
  14582. case "string":
  14583. return "string";
  14584. case "symbol":
  14585. return "symbol";
  14586. case "undefined":
  14587. return "undefined";
  14588. default:
  14589. }
  14590. if (is2.array(value))
  14591. return "Array";
  14592. if (is2.plainFunction(value))
  14593. return "Function";
  14594. var tagType = getObjectType2(value);
  14595. return tagType || "Object";
  14596. }
  14597. is2.array = Array.isArray;
  14598. is2.arrayOf = function(target, predicate) {
  14599. return !is2.array(target) && !is2.function(predicate) ? !1 : target.every(function(d2) {
  14600. return predicate(d2);
  14601. });
  14602. };
  14603. is2.asyncGeneratorFunction = function(value) {
  14604. return getObjectType2(value) === "AsyncGeneratorFunction";
  14605. };
  14606. is2.asyncFunction = isObjectOfType2("AsyncFunction");
  14607. is2.bigint = isOfType3("bigint");
  14608. is2.boolean = function(value) {
  14609. return value === !0 || value === !1;
  14610. };
  14611. is2.date = isObjectOfType2("Date");
  14612. is2.defined = function(value) {
  14613. return !is2.undefined(value);
  14614. };
  14615. is2.domElement = function(value) {
  14616. return is2.object(value) && !is2.plainObject(value) && value.nodeType === 1 && is2.string(value.nodeName) && DOM_PROPERTIES_TO_CHECK2.every(function(property) {
  14617. return property in value;
  14618. });
  14619. };
  14620. is2.empty = function(value) {
  14621. 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;
  14622. };
  14623. is2.error = isObjectOfType2("Error");
  14624. is2.function = isOfType3("function");
  14625. is2.generator = function(value) {
  14626. return is2.iterable(value) && is2.function(value.next) && is2.function(value.throw);
  14627. };
  14628. is2.generatorFunction = isObjectOfType2("GeneratorFunction");
  14629. is2.instanceOf = function(instance, class_) {
  14630. return !instance || !class_ ? !1 : Object.getPrototypeOf(instance) === class_.prototype;
  14631. };
  14632. is2.iterable = function(value) {
  14633. return !is2.nullOrUndefined(value) && is2.function(value[Symbol.iterator]);
  14634. };
  14635. is2.map = isObjectOfType2("Map");
  14636. is2.nan = function(value) {
  14637. return Number.isNaN(value);
  14638. };
  14639. is2.null = function(value) {
  14640. return value === null;
  14641. };
  14642. is2.nullOrUndefined = function(value) {
  14643. return is2.null(value) || is2.undefined(value);
  14644. };
  14645. is2.number = function(value) {
  14646. return isOfType3("number")(value) && !is2.nan(value);
  14647. };
  14648. is2.numericString = function(value) {
  14649. return is2.string(value) && value.length > 0 && !Number.isNaN(Number(value));
  14650. };
  14651. is2.object = function(value) {
  14652. return !is2.nullOrUndefined(value) && (is2.function(value) || typeof value == "object");
  14653. };
  14654. is2.oneOf = function(target, value) {
  14655. return is2.array(target) ? target.indexOf(value) > -1 : !1;
  14656. };
  14657. is2.plainFunction = isObjectOfType2("Function");
  14658. is2.plainObject = function(value) {
  14659. if (getObjectType2(value) !== "Object")
  14660. return !1;
  14661. var prototype = Object.getPrototypeOf(value);
  14662. return prototype === null || prototype === Object.getPrototypeOf({});
  14663. };
  14664. is2.primitive = function(value) {
  14665. return is2.null(value) || isPrimitiveType2(typeof value);
  14666. };
  14667. is2.promise = isObjectOfType2("Promise");
  14668. is2.propertyOf = function(target, key, predicate) {
  14669. if (!is2.object(target) || !key)
  14670. return !1;
  14671. var value = target[key];
  14672. return is2.function(predicate) ? predicate(value) : is2.defined(value);
  14673. };
  14674. is2.regexp = isObjectOfType2("RegExp");
  14675. is2.set = isObjectOfType2("Set");
  14676. is2.string = isOfType3("string");
  14677. is2.symbol = isOfType3("symbol");
  14678. is2.undefined = isOfType3("undefined");
  14679. is2.weakMap = isObjectOfType2("WeakMap");
  14680. is2.weakSet = isObjectOfType2("WeakSet");
  14681. var esm_default = is2;
  14682. // ../../node_modules/tree-changes/node_modules/@gilbarbara/deep-equal/esm/helpers.js
  14683. function isOfType4(type) {
  14684. return function(value) {
  14685. return typeof value === type;
  14686. };
  14687. }
  14688. var isFunction4 = isOfType4("function"), isNull3 = function(value) {
  14689. return value === null;
  14690. }, isRegex2 = function(value) {
  14691. return Object.prototype.toString.call(value).slice(8, -1) === "RegExp";
  14692. }, isObject2 = function(value) {
  14693. return !isUndefined3(value) && !isNull3(value) && (isFunction4(value) || typeof value == "object");
  14694. }, isUndefined3 = isOfType4("undefined");
  14695. // ../../node_modules/tree-changes/node_modules/@gilbarbara/deep-equal/esm/index.js
  14696. var __values = function(o3) {
  14697. var s2 = typeof Symbol == "function" && Symbol.iterator, m2 = s2 && o3[s2], i2 = 0;
  14698. if (m2) return m2.call(o3);
  14699. if (o3 && typeof o3.length == "number") return {
  14700. next: function() {
  14701. return o3 && i2 >= o3.length && (o3 = void 0), { value: o3 && o3[i2++], done: !o3 };
  14702. }
  14703. };
  14704. throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined.");
  14705. };
  14706. function equalArray2(left, right) {
  14707. var length = left.length;
  14708. if (length !== right.length)
  14709. return !1;
  14710. for (var index = length; index-- !== 0; )
  14711. if (!equal2(left[index], right[index]))
  14712. return !1;
  14713. return !0;
  14714. }
  14715. function equalArrayBuffer2(left, right) {
  14716. if (left.byteLength !== right.byteLength)
  14717. return !1;
  14718. for (var view1 = new DataView(left.buffer), view2 = new DataView(right.buffer), index = left.byteLength; index--; )
  14719. if (view1.getUint8(index) !== view2.getUint8(index))
  14720. return !1;
  14721. return !0;
  14722. }
  14723. function equalMap2(left, right) {
  14724. var e_1, _a2, e_2, _b;
  14725. if (left.size !== right.size)
  14726. return !1;
  14727. try {
  14728. for (var _c = __values(left.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
  14729. var index = _d.value;
  14730. if (!right.has(index[0]))
  14731. return !1;
  14732. }
  14733. } catch (e_1_1) {
  14734. e_1 = { error: e_1_1 };
  14735. } finally {
  14736. try {
  14737. _d && !_d.done && (_a2 = _c.return) && _a2.call(_c);
  14738. } finally {
  14739. if (e_1) throw e_1.error;
  14740. }
  14741. }
  14742. try {
  14743. for (var _e = __values(left.entries()), _f = _e.next(); !_f.done; _f = _e.next()) {
  14744. var index = _f.value;
  14745. if (!equal2(index[1], right.get(index[0])))
  14746. return !1;
  14747. }
  14748. } catch (e_2_1) {
  14749. e_2 = { error: e_2_1 };
  14750. } finally {
  14751. try {
  14752. _f && !_f.done && (_b = _e.return) && _b.call(_e);
  14753. } finally {
  14754. if (e_2) throw e_2.error;
  14755. }
  14756. }
  14757. return !0;
  14758. }
  14759. function equalSet2(left, right) {
  14760. var e_3, _a2;
  14761. if (left.size !== right.size)
  14762. return !1;
  14763. try {
  14764. for (var _b = __values(left.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
  14765. var index = _c.value;
  14766. if (!right.has(index[0]))
  14767. return !1;
  14768. }
  14769. } catch (e_3_1) {
  14770. e_3 = { error: e_3_1 };
  14771. } finally {
  14772. try {
  14773. _c && !_c.done && (_a2 = _b.return) && _a2.call(_b);
  14774. } finally {
  14775. if (e_3) throw e_3.error;
  14776. }
  14777. }
  14778. return !0;
  14779. }
  14780. function equal2(left, right) {
  14781. if (left === right)
  14782. return !0;
  14783. if (left && isObject2(left) && right && isObject2(right)) {
  14784. if (left.constructor !== right.constructor)
  14785. return !1;
  14786. if (Array.isArray(left) && Array.isArray(right))
  14787. return equalArray2(left, right);
  14788. if (left instanceof Map && right instanceof Map)
  14789. return equalMap2(left, right);
  14790. if (left instanceof Set && right instanceof Set)
  14791. return equalSet2(left, right);
  14792. if (ArrayBuffer.isView(left) && ArrayBuffer.isView(right))
  14793. return equalArrayBuffer2(left, right);
  14794. if (isRegex2(left) && isRegex2(right))
  14795. return left.source === right.source && left.flags === right.flags;
  14796. if (left.valueOf !== Object.prototype.valueOf)
  14797. return left.valueOf() === right.valueOf();
  14798. if (left.toString !== Object.prototype.toString)
  14799. return left.toString() === right.toString();
  14800. var leftKeys = Object.keys(left), rightKeys = Object.keys(right);
  14801. if (leftKeys.length !== rightKeys.length)
  14802. return !1;
  14803. for (var index = leftKeys.length; index-- !== 0; )
  14804. if (!Object.prototype.hasOwnProperty.call(right, leftKeys[index]))
  14805. return !1;
  14806. for (var index = leftKeys.length; index-- !== 0; ) {
  14807. var key = leftKeys[index];
  14808. if (!(key === "_owner" && left.$$typeof) && !equal2(left[key], right[key]))
  14809. return !1;
  14810. }
  14811. return !0;
  14812. }
  14813. return Number.isNaN(left) && Number.isNaN(right) ? !0 : left === right;
  14814. }
  14815. // ../../node_modules/tree-changes/node_modules/is-lite/esm/index.js
  14816. var DOM_PROPERTIES_TO_CHECK3 = [
  14817. "innerHTML",
  14818. "ownerDocument",
  14819. "style",
  14820. "attributes",
  14821. "nodeValue"
  14822. ], objectTypes3 = [
  14823. "Array",
  14824. "ArrayBuffer",
  14825. "AsyncFunction",
  14826. "AsyncGenerator",
  14827. "AsyncGeneratorFunction",
  14828. "Date",
  14829. "Error",
  14830. "Function",
  14831. "Generator",
  14832. "GeneratorFunction",
  14833. "HTMLElement",
  14834. "Map",
  14835. "Object",
  14836. "Promise",
  14837. "RegExp",
  14838. "Set",
  14839. "WeakMap",
  14840. "WeakSet"
  14841. ], primitiveTypes3 = [
  14842. "bigint",
  14843. "boolean",
  14844. "null",
  14845. "number",
  14846. "string",
  14847. "symbol",
  14848. "undefined"
  14849. ];
  14850. function getObjectType3(value) {
  14851. var objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
  14852. if (/HTML\w+Element/.test(objectTypeName))
  14853. return "HTMLElement";
  14854. if (isObjectType3(objectTypeName))
  14855. return objectTypeName;
  14856. }
  14857. function isObjectOfType3(type) {
  14858. return function(value) {
  14859. return getObjectType3(value) === type;
  14860. };
  14861. }
  14862. function isObjectType3(name) {
  14863. return objectTypes3.includes(name);
  14864. }
  14865. function isOfType5(type) {
  14866. return function(value) {
  14867. return typeof value === type;
  14868. };
  14869. }
  14870. function isPrimitiveType3(name) {
  14871. return primitiveTypes3.includes(name);
  14872. }
  14873. function is3(value) {
  14874. if (value === null)
  14875. return "null";
  14876. switch (typeof value) {
  14877. case "bigint":
  14878. return "bigint";
  14879. case "boolean":
  14880. return "boolean";
  14881. case "number":
  14882. return "number";
  14883. case "string":
  14884. return "string";
  14885. case "symbol":
  14886. return "symbol";
  14887. case "undefined":
  14888. return "undefined";
  14889. default:
  14890. }
  14891. if (is3.array(value))
  14892. return "Array";
  14893. if (is3.plainFunction(value))
  14894. return "Function";
  14895. var tagType = getObjectType3(value);
  14896. return tagType || "Object";
  14897. }
  14898. is3.array = Array.isArray;
  14899. is3.arrayOf = function(target, predicate) {
  14900. return !is3.array(target) && !is3.function(predicate) ? !1 : target.every(function(d2) {
  14901. return predicate(d2);
  14902. });
  14903. };
  14904. is3.asyncGeneratorFunction = function(value) {
  14905. return getObjectType3(value) === "AsyncGeneratorFunction";
  14906. };
  14907. is3.asyncFunction = isObjectOfType3("AsyncFunction");
  14908. is3.bigint = isOfType5("bigint");
  14909. is3.boolean = function(value) {
  14910. return value === !0 || value === !1;
  14911. };
  14912. is3.date = isObjectOfType3("Date");
  14913. is3.defined = function(value) {
  14914. return !is3.undefined(value);
  14915. };
  14916. is3.domElement = function(value) {
  14917. return is3.object(value) && !is3.plainObject(value) && value.nodeType === 1 && is3.string(value.nodeName) && DOM_PROPERTIES_TO_CHECK3.every(function(property) {
  14918. return property in value;
  14919. });
  14920. };
  14921. is3.empty = function(value) {
  14922. 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;
  14923. };
  14924. is3.error = isObjectOfType3("Error");
  14925. is3.function = isOfType5("function");
  14926. is3.generator = function(value) {
  14927. return is3.iterable(value) && is3.function(value.next) && is3.function(value.throw);
  14928. };
  14929. is3.generatorFunction = isObjectOfType3("GeneratorFunction");
  14930. is3.instanceOf = function(instance, class_) {
  14931. return !instance || !class_ ? !1 : Object.getPrototypeOf(instance) === class_.prototype;
  14932. };
  14933. is3.iterable = function(value) {
  14934. return !is3.nullOrUndefined(value) && is3.function(value[Symbol.iterator]);
  14935. };
  14936. is3.map = isObjectOfType3("Map");
  14937. is3.nan = function(value) {
  14938. return Number.isNaN(value);
  14939. };
  14940. is3.null = function(value) {
  14941. return value === null;
  14942. };
  14943. is3.nullOrUndefined = function(value) {
  14944. return is3.null(value) || is3.undefined(value);
  14945. };
  14946. is3.number = function(value) {
  14947. return isOfType5("number")(value) && !is3.nan(value);
  14948. };
  14949. is3.numericString = function(value) {
  14950. return is3.string(value) && value.length > 0 && !Number.isNaN(Number(value));
  14951. };
  14952. is3.object = function(value) {
  14953. return !is3.nullOrUndefined(value) && (is3.function(value) || typeof value == "object");
  14954. };
  14955. is3.oneOf = function(target, value) {
  14956. return is3.array(target) ? target.indexOf(value) > -1 : !1;
  14957. };
  14958. is3.plainFunction = isObjectOfType3("Function");
  14959. is3.plainObject = function(value) {
  14960. if (getObjectType3(value) !== "Object")
  14961. return !1;
  14962. var prototype = Object.getPrototypeOf(value);
  14963. return prototype === null || prototype === Object.getPrototypeOf({});
  14964. };
  14965. is3.primitive = function(value) {
  14966. return is3.null(value) || isPrimitiveType3(typeof value);
  14967. };
  14968. is3.promise = isObjectOfType3("Promise");
  14969. is3.propertyOf = function(target, key, predicate) {
  14970. if (!is3.object(target) || !key)
  14971. return !1;
  14972. var value = target[key];
  14973. return is3.function(predicate) ? predicate(value) : is3.defined(value);
  14974. };
  14975. is3.regexp = isObjectOfType3("RegExp");
  14976. is3.set = isObjectOfType3("Set");
  14977. is3.string = isOfType5("string");
  14978. is3.symbol = isOfType5("symbol");
  14979. is3.undefined = isOfType5("undefined");
  14980. is3.weakMap = isObjectOfType3("WeakMap");
  14981. is3.weakSet = isObjectOfType3("WeakSet");
  14982. var esm_default2 = is3;
  14983. // ../../node_modules/tree-changes/esm/helpers.js
  14984. function canHaveLength2() {
  14985. for (var arguments_ = [], _i = 0; _i < arguments.length; _i++)
  14986. arguments_[_i] = arguments[_i];
  14987. return arguments_.every(function(d2) {
  14988. return esm_default2.string(d2) || esm_default2.array(d2) || esm_default2.plainObject(d2);
  14989. });
  14990. }
  14991. function checkEquality2(left, right, value) {
  14992. 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;
  14993. }
  14994. function compareNumbers2(previousData, data, options2) {
  14995. 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);
  14996. return esm_default2.undefined(actual) || (changed = changed && right === actual), esm_default2.undefined(previous) || (changed = changed && left === previous), changed;
  14997. }
  14998. function compareValues2(previousData, data, options2) {
  14999. 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;
  15000. if (!esm_default2.nullOrUndefined(value)) {
  15001. if (esm_default2.defined(primary)) {
  15002. if (esm_default2.array(primary) || esm_default2.plainObject(primary))
  15003. return checkEquality2(primary, secondary, value);
  15004. } else
  15005. return equal2(secondary, value);
  15006. return !1;
  15007. }
  15008. 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) {
  15009. return esm_default2.primitive(d2) && esm_default2.defined(d2);
  15010. }) && (type === "added" ? !esm_default2.defined(left) && esm_default2.defined(right) : esm_default2.defined(left) && !esm_default2.defined(right));
  15011. }
  15012. function getIterables2(previousData, data, _a2) {
  15013. var _b = _a2 === void 0 ? {} : _a2, key = _b.key, left = nested2(previousData, key), right = nested2(data, key);
  15014. if (!isSameType2(left, right))
  15015. throw new TypeError("Inputs have different types");
  15016. if (!canHaveLength2(left, right))
  15017. throw new TypeError("Inputs don't have length");
  15018. return [left, right].every(esm_default2.plainObject) && (left = Object.keys(left), right = Object.keys(right)), [left, right];
  15019. }
  15020. function hasEntry2(input) {
  15021. return function(_a2) {
  15022. var key = _a2[0], value = _a2[1];
  15023. return esm_default2.array(input) ? equal2(input, value) || input.some(function(d2) {
  15024. return equal2(d2, value) || esm_default2.array(value) && isEqualPredicate2(value)(d2);
  15025. }) : esm_default2.plainObject(input) && input[key] ? !!input[key] && equal2(input[key], value) : equal2(input, value);
  15026. };
  15027. }
  15028. function hasExtraKeys2(left, right) {
  15029. return right.some(function(d2) {
  15030. return !left.includes(d2);
  15031. });
  15032. }
  15033. function hasValue2(input) {
  15034. return function(value) {
  15035. return esm_default2.array(input) ? input.some(function(d2) {
  15036. return equal2(d2, value) || esm_default2.array(value) && isEqualPredicate2(value)(d2);
  15037. }) : equal2(input, value);
  15038. };
  15039. }
  15040. function includesOrEqualsTo2(previousValue, value) {
  15041. return esm_default2.array(previousValue) ? previousValue.some(function(d2) {
  15042. return equal2(d2, value);
  15043. }) : equal2(previousValue, value);
  15044. }
  15045. function isEqualPredicate2(data) {
  15046. return function(value) {
  15047. return data.some(function(d2) {
  15048. return equal2(d2, value);
  15049. });
  15050. };
  15051. }
  15052. function isSameType2() {
  15053. for (var arguments_ = [], _i = 0; _i < arguments.length; _i++)
  15054. arguments_[_i] = arguments[_i];
  15055. return arguments_.every(esm_default2.array) || arguments_.every(esm_default2.number) || arguments_.every(esm_default2.plainObject) || arguments_.every(esm_default2.string);
  15056. }
  15057. function nested2(data, property) {
  15058. if (esm_default2.plainObject(data) || esm_default2.array(data)) {
  15059. if (esm_default2.string(property)) {
  15060. var props = property.split(".");
  15061. return props.reduce(function(acc, d2) {
  15062. return acc && acc[d2];
  15063. }, data);
  15064. }
  15065. return esm_default2.number(property) ? data[property] : data;
  15066. }
  15067. return data;
  15068. }
  15069. // ../../node_modules/tree-changes/esm/index.js
  15070. function treeChanges2(previousData, data) {
  15071. if ([previousData, data].some(esm_default2.nullOrUndefined))
  15072. throw new Error("Missing required parameters");
  15073. if (![previousData, data].every(function(d2) {
  15074. return esm_default2.plainObject(d2) || esm_default2.array(d2);
  15075. }))
  15076. throw new Error("Expected plain objects or array");
  15077. var added = function(key, value) {
  15078. try {
  15079. return compareValues2(previousData, data, { key, type: "added", value });
  15080. } catch {
  15081. return !1;
  15082. }
  15083. }, changed = function(key, actual, previous) {
  15084. try {
  15085. var left = nested2(previousData, key), right = nested2(data, key), hasActual = esm_default2.defined(actual), hasPrevious = esm_default2.defined(previous);
  15086. if (hasActual || hasPrevious) {
  15087. var leftComparator = hasPrevious ? includesOrEqualsTo2(previous, left) : !includesOrEqualsTo2(actual, left), rightComparator = includesOrEqualsTo2(actual, right);
  15088. return leftComparator && rightComparator;
  15089. }
  15090. return [left, right].every(esm_default2.array) || [left, right].every(esm_default2.plainObject) ? !equal2(left, right) : left !== right;
  15091. } catch {
  15092. return !1;
  15093. }
  15094. }, changedFrom = function(key, previous, actual) {
  15095. if (!esm_default2.defined(key))
  15096. return !1;
  15097. try {
  15098. var left = nested2(previousData, key), right = nested2(data, key), hasActual = esm_default2.defined(actual);
  15099. return includesOrEqualsTo2(previous, left) && (hasActual ? includesOrEqualsTo2(actual, right) : !hasActual);
  15100. } catch {
  15101. return !1;
  15102. }
  15103. }, changedTo = function(key, actual) {
  15104. return esm_default2.defined(key) ? changed(key, actual) : !1;
  15105. }, decreased = function(key, actual, previous) {
  15106. if (!esm_default2.defined(key))
  15107. return !1;
  15108. try {
  15109. return compareNumbers2(previousData, data, { key, actual, previous, type: "decreased" });
  15110. } catch {
  15111. return !1;
  15112. }
  15113. }, emptied = function(key) {
  15114. try {
  15115. var _a2 = getIterables2(previousData, data, { key }), left = _a2[0], right = _a2[1];
  15116. return !!left.length && !right.length;
  15117. } catch {
  15118. return !1;
  15119. }
  15120. }, filled = function(key) {
  15121. try {
  15122. var _a2 = getIterables2(previousData, data, { key }), left = _a2[0], right = _a2[1];
  15123. return !left.length && !!right.length;
  15124. } catch {
  15125. return !1;
  15126. }
  15127. }, increased = function(key, actual, previous) {
  15128. if (!esm_default2.defined(key))
  15129. return !1;
  15130. try {
  15131. return compareNumbers2(previousData, data, { key, actual, previous, type: "increased" });
  15132. } catch {
  15133. return !1;
  15134. }
  15135. }, removed = function(key, value) {
  15136. try {
  15137. return compareValues2(previousData, data, { key, type: "removed", value });
  15138. } catch {
  15139. return !1;
  15140. }
  15141. };
  15142. return { added, changed, changedFrom, changedTo, decreased, emptied, filled, increased, removed };
  15143. }
  15144. // ../../node_modules/react-floater/es/index.js
  15145. function ownKeys(e2, r4) {
  15146. var t2 = Object.keys(e2);
  15147. if (Object.getOwnPropertySymbols) {
  15148. var o3 = Object.getOwnPropertySymbols(e2);
  15149. r4 && (o3 = o3.filter(function(r5) {
  15150. return Object.getOwnPropertyDescriptor(e2, r5).enumerable;
  15151. })), t2.push.apply(t2, o3);
  15152. }
  15153. return t2;
  15154. }
  15155. function _objectSpread2(e2) {
  15156. for (var r4 = 1; r4 < arguments.length; r4++) {
  15157. var t2 = arguments[r4] != null ? arguments[r4] : {};
  15158. r4 % 2 ? ownKeys(Object(t2), !0).forEach(function(r5) {
  15159. _defineProperty(e2, r5, t2[r5]);
  15160. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys(Object(t2)).forEach(function(r5) {
  15161. Object.defineProperty(e2, r5, Object.getOwnPropertyDescriptor(t2, r5));
  15162. });
  15163. }
  15164. return e2;
  15165. }
  15166. function _classCallCheck(instance, Constructor) {
  15167. if (!(instance instanceof Constructor))
  15168. throw new TypeError("Cannot call a class as a function");
  15169. }
  15170. function _defineProperties(target, props) {
  15171. for (var i2 = 0; i2 < props.length; i2++) {
  15172. var descriptor = props[i2];
  15173. descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
  15174. }
  15175. }
  15176. function _createClass(Constructor, protoProps, staticProps) {
  15177. return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Object.defineProperty(Constructor, "prototype", {
  15178. writable: !1
  15179. }), Constructor;
  15180. }
  15181. function _defineProperty(obj, key, value) {
  15182. return key = _toPropertyKey(key), key in obj ? Object.defineProperty(obj, key, {
  15183. value,
  15184. enumerable: !0,
  15185. configurable: !0,
  15186. writable: !0
  15187. }) : obj[key] = value, obj;
  15188. }
  15189. function _inherits(subClass, superClass) {
  15190. if (typeof superClass != "function" && superClass !== null)
  15191. throw new TypeError("Super expression must either be null or a function");
  15192. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15193. constructor: {
  15194. value: subClass,
  15195. writable: !0,
  15196. configurable: !0
  15197. }
  15198. }), Object.defineProperty(subClass, "prototype", {
  15199. writable: !1
  15200. }), superClass && _setPrototypeOf2(subClass, superClass);
  15201. }
  15202. function _getPrototypeOf2(o3) {
  15203. return _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o4) {
  15204. return o4.__proto__ || Object.getPrototypeOf(o4);
  15205. }, _getPrototypeOf2(o3);
  15206. }
  15207. function _setPrototypeOf2(o3, p2) {
  15208. return _setPrototypeOf2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o4, p3) {
  15209. return o4.__proto__ = p3, o4;
  15210. }, _setPrototypeOf2(o3, p2);
  15211. }
  15212. function _isNativeReflectConstruct2() {
  15213. if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
  15214. if (typeof Proxy == "function") return !0;
  15215. try {
  15216. return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
  15217. })), !0;
  15218. } catch {
  15219. return !1;
  15220. }
  15221. }
  15222. function _objectWithoutPropertiesLoose(source, excluded) {
  15223. if (source == null) return {};
  15224. var target = {}, sourceKeys = Object.keys(source), key, i2;
  15225. for (i2 = 0; i2 < sourceKeys.length; i2++)
  15226. key = sourceKeys[i2], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
  15227. return target;
  15228. }
  15229. function _objectWithoutProperties(source, excluded) {
  15230. if (source == null) return {};
  15231. var target = _objectWithoutPropertiesLoose(source, excluded), key, i2;
  15232. if (Object.getOwnPropertySymbols) {
  15233. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  15234. for (i2 = 0; i2 < sourceSymbolKeys.length; i2++)
  15235. key = sourceSymbolKeys[i2], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
  15236. }
  15237. return target;
  15238. }
  15239. function _assertThisInitialized2(self2) {
  15240. if (self2 === void 0)
  15241. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15242. return self2;
  15243. }
  15244. function _possibleConstructorReturn(self2, call) {
  15245. if (call && (typeof call == "object" || typeof call == "function"))
  15246. return call;
  15247. if (call !== void 0)
  15248. throw new TypeError("Derived constructors may only return object or undefined");
  15249. return _assertThisInitialized2(self2);
  15250. }
  15251. function _createSuper(Derived) {
  15252. var hasNativeReflectConstruct = _isNativeReflectConstruct2();
  15253. return function() {
  15254. var Super = _getPrototypeOf2(Derived), result;
  15255. if (hasNativeReflectConstruct) {
  15256. var NewTarget = _getPrototypeOf2(this).constructor;
  15257. result = Reflect.construct(Super, arguments, NewTarget);
  15258. } else
  15259. result = Super.apply(this, arguments);
  15260. return _possibleConstructorReturn(this, result);
  15261. };
  15262. }
  15263. function _toPrimitive(input, hint) {
  15264. if (typeof input != "object" || input === null) return input;
  15265. var prim = input[Symbol.toPrimitive];
  15266. if (prim !== void 0) {
  15267. var res = prim.call(input, hint || "default");
  15268. if (typeof res != "object") return res;
  15269. throw new TypeError("@@toPrimitive must return a primitive value.");
  15270. }
  15271. return (hint === "string" ? String : Number)(input);
  15272. }
  15273. function _toPropertyKey(arg) {
  15274. var key = _toPrimitive(arg, "string");
  15275. return typeof key == "symbol" ? key : String(key);
  15276. }
  15277. 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.";
  15278. function propIsRequired(condition, props, propName, componentName) {
  15279. return typeof condition == "boolean" ? condition : typeof condition == "function" ? condition(props, propName, componentName) : condition ? !!condition : !1;
  15280. }
  15281. function propExists(props, propName) {
  15282. return Object.hasOwnProperty.call(props, propName);
  15283. }
  15284. function missingPropError(props, propName, componentName, message) {
  15285. return message ? new Error(message) : new Error("Required ".concat(props[propName], " `").concat(propName, "` was not specified in `").concat(componentName, "`."));
  15286. }
  15287. function guardAgainstInvalidArgTypes(typeValidator, message) {
  15288. if (typeof typeValidator != "function")
  15289. throw new TypeError(VALIDATOR_ARG_ERROR_MESSAGE);
  15290. if (message && typeof message != "string")
  15291. throw new TypeError(MESSAGE_ARG_ERROR_MESSAGE);
  15292. }
  15293. function isRequiredIf(typeValidator, condition, message) {
  15294. return guardAgainstInvalidArgTypes(typeValidator, message), function(props, propName, componentName) {
  15295. for (var _len = arguments.length, rest2 = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++)
  15296. rest2[_key - 3] = arguments[_key];
  15297. 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));
  15298. };
  15299. }
  15300. var STATUS2 = { INIT: "init", IDLE: "idle", OPENING: "opening", OPEN: "open", CLOSING: "closing", ERROR: "error" }, isReact16 = react_dom_default.createPortal !== void 0;
  15301. function canUseDOM() {
  15302. return !!(typeof window < "u" && window.document && window.document.createElement);
  15303. }
  15304. function isMobile() {
  15305. return "ontouchstart" in window && /Mobi/.test(navigator.userAgent);
  15306. }
  15307. function log(_ref) {
  15308. 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;
  15309. debug && title2 && data && (console.groupCollapsed("%creact-floater: ".concat(title2), "color: #9b00ff; font-weight: bold; font-size: 12px;"), Array.isArray(data) ? data.forEach(function(d2) {
  15310. esm_default.plainObject(d2) && d2.key ? logFn.apply(console, [d2.key, d2.value]) : logFn.apply(console, [d2]);
  15311. }) : logFn.apply(console, [data]), console.groupEnd());
  15312. }
  15313. function on(element, event, cb) {
  15314. var capture = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  15315. element.addEventListener(event, cb, capture);
  15316. }
  15317. function off(element, event, cb) {
  15318. var capture = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  15319. element.removeEventListener(event, cb, capture);
  15320. }
  15321. function once3(element, event, cb) {
  15322. var capture = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, _nextCB;
  15323. _nextCB = function(e2) {
  15324. cb(e2), off(element, event, _nextCB);
  15325. }, on(element, event, _nextCB, capture);
  15326. }
  15327. function noop2() {
  15328. }
  15329. var ReactFloaterPortal = (function(_React$Component) {
  15330. _inherits(ReactFloaterPortal2, _React$Component);
  15331. var _super = _createSuper(ReactFloaterPortal2);
  15332. function ReactFloaterPortal2() {
  15333. return _classCallCheck(this, ReactFloaterPortal2), _super.apply(this, arguments);
  15334. }
  15335. return _createClass(ReactFloaterPortal2, [{ key: "componentDidMount", value: function() {
  15336. canUseDOM() && (this.node || this.appendNode(), isReact16 || this.renderPortal());
  15337. } }, { key: "componentDidUpdate", value: function() {
  15338. canUseDOM() && (isReact16 || this.renderPortal());
  15339. } }, { key: "componentWillUnmount", value: function() {
  15340. !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));
  15341. } }, { key: "appendNode", value: function() {
  15342. var _this$props = this.props, id = _this$props.id, zIndex = _this$props.zIndex;
  15343. this.node || (this.node = document.createElement("div"), id && (this.node.id = id), zIndex && (this.node.style.zIndex = zIndex), document.body.appendChild(this.node));
  15344. } }, { key: "renderPortal", value: function() {
  15345. if (!canUseDOM()) return null;
  15346. var _this$props2 = this.props, children = _this$props2.children, setRef = _this$props2.setRef;
  15347. if (this.node || this.appendNode(), isReact16)
  15348. return react_dom_default.createPortal(children, this.node);
  15349. var portal = react_dom_default.unstable_renderSubtreeIntoContainer(this, children.length > 1 ? react_default.createElement("div", null, children) : children[0], this.node);
  15350. return setRef(portal), null;
  15351. } }, { key: "renderReact16", value: function() {
  15352. var _this$props3 = this.props, hasChildren = _this$props3.hasChildren, placement = _this$props3.placement, target = _this$props3.target;
  15353. return hasChildren ? this.renderPortal() : target || placement === "center" ? this.renderPortal() : null;
  15354. } }, { key: "render", value: function() {
  15355. return isReact16 ? this.renderReact16() : null;
  15356. } }]), ReactFloaterPortal2;
  15357. })(react_default.Component);
  15358. _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 });
  15359. var FloaterArrow = (function(_React$Component) {
  15360. _inherits(FloaterArrow2, _React$Component);
  15361. var _super = _createSuper(FloaterArrow2);
  15362. function FloaterArrow2() {
  15363. return _classCallCheck(this, FloaterArrow2), _super.apply(this, arguments);
  15364. }
  15365. return _createClass(FloaterArrow2, [{ key: "parentStyle", get: function() {
  15366. var _this$props = this.props, placement = _this$props.placement, styles2 = _this$props.styles, length = styles2.arrow.length, arrow2 = { pointerEvents: "none", position: "absolute", width: "100%" };
  15367. 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;
  15368. } }, { key: "render", value: function() {
  15369. 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;
  15370. 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 }))));
  15371. } }]), FloaterArrow2;
  15372. })(react_default.Component);
  15373. _defineProperty(FloaterArrow, "propTypes", { placement: import_prop_types2.default.string.isRequired, setArrowRef: import_prop_types2.default.func.isRequired, styles: import_prop_types2.default.object.isRequired });
  15374. var _excluded$1 = ["color", "height", "width"];
  15375. function FloaterCloseBtn(_ref) {
  15376. var handleClick = _ref.handleClick, styles2 = _ref.styles, color2 = styles2.color, height = styles2.height, width = styles2.width, style = _objectWithoutProperties(styles2, _excluded$1);
  15377. 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 }))));
  15378. }
  15379. FloaterCloseBtn.propTypes = { handleClick: import_prop_types2.default.func.isRequired, styles: import_prop_types2.default.object.isRequired };
  15380. function FloaterContainer(_ref) {
  15381. 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) };
  15382. 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);
  15383. }
  15384. 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 };
  15385. var Floater = (function(_React$Component) {
  15386. _inherits(Floater2, _React$Component);
  15387. var _super = _createSuper(Floater2);
  15388. function Floater2() {
  15389. return _classCallCheck(this, Floater2), _super.apply(this, arguments);
  15390. }
  15391. return _createClass(Floater2, [{ key: "style", get: function() {
  15392. 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 = {};
  15393. 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);
  15394. } }, { key: "render", value: function() {
  15395. 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"];
  15396. 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));
  15397. } }]), Floater2;
  15398. })(react_default.Component);
  15399. _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 });
  15400. var ReactFloaterWrapper = (function(_React$Component) {
  15401. _inherits(ReactFloaterWrapper2, _React$Component);
  15402. var _super = _createSuper(ReactFloaterWrapper2);
  15403. function ReactFloaterWrapper2() {
  15404. return _classCallCheck(this, ReactFloaterWrapper2), _super.apply(this, arguments);
  15405. }
  15406. return _createClass(ReactFloaterWrapper2, [{ key: "render", value: function() {
  15407. 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;
  15408. if (children)
  15409. if (react_default.Children.count(children) === 1)
  15410. if (!react_default.isValidElement(children))
  15411. element = react_default.createElement("span", null, children);
  15412. else {
  15413. var refProp = esm_default.function(children.type) ? "innerRef" : "ref";
  15414. element = react_default.cloneElement(react_default.Children.only(children), _defineProperty({}, refProp, setChildRef));
  15415. }
  15416. else
  15417. element = children;
  15418. return element ? react_default.createElement("span", { ref: setWrapperRef, style: _objectSpread2(_objectSpread2({}, styles2), style), onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, element) : null;
  15419. } }]), ReactFloaterWrapper2;
  15420. })(react_default.Component);
  15421. _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 });
  15422. var defaultOptions = { zIndex: 100 };
  15423. function getStyles(styles2) {
  15424. var options2 = (0, import_deepmerge.default)(defaultOptions, styles2.options || {});
  15425. 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 };
  15426. }
  15427. var _excluded = ["arrow", "flip", "offset"], POSITIONING_PROPS = ["position", "top", "right", "bottom", "left"], ReactFloater = (function(_React$Component) {
  15428. _inherits(ReactFloater2, _React$Component);
  15429. var _super = _createSuper(ReactFloater2);
  15430. function ReactFloater2(props) {
  15431. var _this;
  15432. return _classCallCheck(this, ReactFloater2), _this = _super.call(this, props), _defineProperty(_assertThisInitialized2(_this), "setArrowRef", function(ref) {
  15433. _this.arrowRef = ref;
  15434. }), _defineProperty(_assertThisInitialized2(_this), "setChildRef", function(ref) {
  15435. _this.childRef = ref;
  15436. }), _defineProperty(_assertThisInitialized2(_this), "setFloaterRef", function(ref) {
  15437. _this.floaterRef = ref;
  15438. }), _defineProperty(_assertThisInitialized2(_this), "setWrapperRef", function(ref) {
  15439. _this.wrapperRef = ref;
  15440. }), _defineProperty(_assertThisInitialized2(_this), "handleTransitionEnd", function() {
  15441. var status = _this.state.status, callback = _this.props.callback;
  15442. _this.wrapperPopper && _this.wrapperPopper.instance.update(), _this.setState({ status: status === STATUS2.OPENING ? STATUS2.OPEN : STATUS2.IDLE }, function() {
  15443. var newStatus = _this.state.status;
  15444. callback(newStatus === STATUS2.OPEN ? "open" : "close", _this.props);
  15445. });
  15446. }), _defineProperty(_assertThisInitialized2(_this), "handleClick", function() {
  15447. var _this$props = _this.props, event = _this$props.event, open = _this$props.open;
  15448. if (!esm_default.boolean(open)) {
  15449. var _this$state = _this.state, positionWrapper = _this$state.positionWrapper, status = _this$state.status;
  15450. (_this.event === "click" || _this.event === "hover" && positionWrapper) && (log({ title: "click", data: [{ event, status: status === STATUS2.OPEN ? "closing" : "opening" }], debug: _this.debug }), _this.toggle());
  15451. }
  15452. }), _defineProperty(_assertThisInitialized2(_this), "handleMouseEnter", function() {
  15453. var _this$props2 = _this.props, event = _this$props2.event, open = _this$props2.open;
  15454. if (!(esm_default.boolean(open) || isMobile())) {
  15455. var status = _this.state.status;
  15456. _this.event === "hover" && status === STATUS2.IDLE && (log({ title: "mouseEnter", data: [{ key: "originalEvent", value: event }], debug: _this.debug }), clearTimeout(_this.eventDelayTimeout), _this.toggle());
  15457. }
  15458. }), _defineProperty(_assertThisInitialized2(_this), "handleMouseLeave", function() {
  15459. var _this$props3 = _this.props, event = _this$props3.event, eventDelay = _this$props3.eventDelay, open = _this$props3.open;
  15460. if (!(esm_default.boolean(open) || isMobile())) {
  15461. var _this$state2 = _this.state, status = _this$state2.status, positionWrapper = _this$state2.positionWrapper;
  15462. _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() {
  15463. delete _this.eventDelayTimeout, _this.toggle();
  15464. }, eventDelay * 1e3)) : _this.toggle(STATUS2.IDLE));
  15465. }
  15466. }), _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() {
  15467. _this.popper && _this.popper.instance.update(), _this.wrapperPopper && _this.wrapperPopper.instance.update();
  15468. }), _this;
  15469. }
  15470. return _createClass(ReactFloater2, [{ key: "componentDidMount", value: function() {
  15471. if (canUseDOM()) {
  15472. var positionWrapper = this.state.positionWrapper, _this$props5 = this.props, children = _this$props5.children, open = _this$props5.open, target = _this$props5.target;
  15473. 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);
  15474. }
  15475. } }, { key: "componentDidUpdate", value: function(prevProps, prevState) {
  15476. if (canUseDOM()) {
  15477. 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;
  15478. if (prevProps.open !== open) {
  15479. var forceStatus;
  15480. esm_default.boolean(open) && (forceStatus = open ? STATUS2.OPENING : STATUS2.CLOSING), this.toggle(forceStatus);
  15481. }
  15482. (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();
  15483. }
  15484. } }, { key: "componentWillUnmount", value: function() {
  15485. canUseDOM() && (this._isMounted = !1, this.popper && this.popper.instance.destroy(), this.wrapperPopper && this.wrapperPopper.instance.destroy());
  15486. } }, { key: "initPopper", value: function() {
  15487. 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"];
  15488. if (placement === "center")
  15489. this.setState({ status: STATUS2.IDLE });
  15490. else if (target && this.floaterRef) {
  15491. var _this$options = this.options, arrow2 = _this$options.arrow, flip2 = _this$options.flip, offsetOptions = _this$options.offset, rest2 = _objectWithoutProperties(_this$options, _excluded);
  15492. 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) {
  15493. var _this2$floaterRef;
  15494. if (_this2.popper = data, !((_this2$floaterRef = _this2.floaterRef) !== null && _this2$floaterRef !== void 0 && _this2$floaterRef.isConnected)) {
  15495. _this2.setState({ needsUpdate: !0 });
  15496. return;
  15497. }
  15498. getPopper(data, "floater"), _this2._isMounted && _this2.setState({ currentPlacement: data.placement, status: STATUS2.IDLE }), placement !== data.placement && setTimeout(function() {
  15499. data.instance.update();
  15500. }, 1);
  15501. }, onUpdate: function(data) {
  15502. _this2.popper = data;
  15503. var currentPlacement = _this2.state.currentPlacement;
  15504. _this2._isMounted && data.placement !== currentPlacement && _this2.setState({ currentPlacement: data.placement });
  15505. } });
  15506. }
  15507. if (positionWrapper) {
  15508. var wrapperOffset = esm_default.undefined(wrapperOptions.offset) ? 0 : wrapperOptions.offset;
  15509. 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) {
  15510. _this2.wrapperPopper = data, _this2._isMounted && _this2.setState({ statusWrapper: STATUS2.IDLE }), getPopper(data, "wrapper"), placement !== data.placement && setTimeout(function() {
  15511. data.instance.update();
  15512. }, 1);
  15513. } });
  15514. }
  15515. } }, { key: "rebuildPopper", value: function() {
  15516. var _this3 = this;
  15517. this.floaterRefInterval = setInterval(function() {
  15518. var _this3$floaterRef;
  15519. (_this3$floaterRef = _this3.floaterRef) !== null && _this3$floaterRef !== void 0 && _this3$floaterRef.isConnected && (clearInterval(_this3.floaterRefInterval), _this3.setState({ needsUpdate: !1 }), _this3.initPopper());
  15520. }, 50);
  15521. } }, { key: "changeWrapperPosition", value: function(_ref) {
  15522. var target = _ref.target, wrapperOptions = _ref.wrapperOptions;
  15523. this.setState({ positionWrapper: wrapperOptions.position && !!target });
  15524. } }, { key: "toggle", value: function(forceStatus) {
  15525. var status = this.state.status, nextStatus = status === STATUS2.OPEN ? STATUS2.CLOSING : STATUS2.OPENING;
  15526. esm_default.undefined(forceStatus) || (nextStatus = forceStatus), this.setState({ status: nextStatus });
  15527. } }, { key: "debug", get: function() {
  15528. var debug = this.props.debug;
  15529. return debug || canUseDOM() && "ReactFloaterDebug" in window && !!window.ReactFloaterDebug;
  15530. } }, { key: "event", get: function() {
  15531. var _this$props8 = this.props, disableHoverToClick = _this$props8.disableHoverToClick, event = _this$props8.event;
  15532. return event === "hover" && isMobile() && !disableHoverToClick ? "click" : event;
  15533. } }, { key: "options", get: function() {
  15534. var options2 = this.props.options;
  15535. return (0, import_deepmerge.default)(DEFAULTS, options2 || {});
  15536. } }, { key: "styles", get: function() {
  15537. 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);
  15538. if (positionWrapper) {
  15539. var wrapperStyles;
  15540. [STATUS2.IDLE].indexOf(status) === -1 || [STATUS2.IDLE].indexOf(statusWrapper) === -1 ? wrapperStyles = nextStyles.wrapperPosition : wrapperStyles = this.wrapperPopper.styles, nextStyles.wrapper = _objectSpread2(_objectSpread2({}, nextStyles.wrapper), wrapperStyles);
  15541. }
  15542. if (this.target) {
  15543. var targetStyles = window.getComputedStyle(this.target);
  15544. this.wrapperStyles ? nextStyles.wrapper = _objectSpread2(_objectSpread2({}, nextStyles.wrapper), this.wrapperStyles) : ["relative", "static"].indexOf(targetStyles.position) === -1 && (this.wrapperStyles = {}, positionWrapper || (POSITIONING_PROPS.forEach(function(d2) {
  15545. _this4.wrapperStyles[d2] = targetStyles[d2];
  15546. }), 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"));
  15547. }
  15548. return nextStyles;
  15549. } }, { key: "target", get: function() {
  15550. if (!canUseDOM()) return null;
  15551. var target = this.props.target;
  15552. return target ? esm_default.domElement(target) ? target : document.querySelector(target) : this.childRef || this.wrapperRef;
  15553. } }, { key: "render", value: function() {
  15554. 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 = {};
  15555. 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);
  15556. } }]), ReactFloater2;
  15557. })(react_default.Component);
  15558. _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) {
  15559. return !props.content;
  15560. }), content: isRequiredIf(import_prop_types2.default.node, function(props) {
  15561. return !props.component;
  15562. }), 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 }) });
  15563. _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 } });
  15564. // ../../node_modules/react-joyride/dist/index.mjs
  15565. init_react();
  15566. init_react();
  15567. init_react();
  15568. init_react();
  15569. 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 = {
  15570. INIT: "init",
  15571. START: "start",
  15572. STOP: "stop",
  15573. RESET: "reset",
  15574. PREV: "prev",
  15575. NEXT: "next",
  15576. GO: "go",
  15577. CLOSE: "close",
  15578. SKIP: "skip",
  15579. UPDATE: "update"
  15580. }, EVENTS = {
  15581. TOUR_START: "tour:start",
  15582. STEP_BEFORE: "step:before",
  15583. BEACON: "beacon",
  15584. TOOLTIP: "tooltip",
  15585. STEP_AFTER: "step:after",
  15586. TOUR_END: "tour:end",
  15587. TOUR_STATUS: "tour:status",
  15588. TARGET_NOT_FOUND: "error:target_not_found",
  15589. ERROR: "error"
  15590. }, LIFECYCLE = {
  15591. INIT: "init",
  15592. READY: "ready",
  15593. BEACON: "beacon",
  15594. TOOLTIP: "tooltip",
  15595. COMPLETE: "complete",
  15596. ERROR: "error"
  15597. };
  15598. var STATUS3 = {
  15599. IDLE: "idle",
  15600. READY: "ready",
  15601. WAITING: "waiting",
  15602. RUNNING: "running",
  15603. PAUSED: "paused",
  15604. SKIPPED: "skipped",
  15605. FINISHED: "finished",
  15606. ERROR: "error"
  15607. };
  15608. function canUseDOM2() {
  15609. var _a2;
  15610. return !!(typeof window < "u" && ((_a2 = window.document) != null && _a2.createElement));
  15611. }
  15612. function getClientRect2(element) {
  15613. return element ? element.getBoundingClientRect() : null;
  15614. }
  15615. function getDocumentHeight(median = !1) {
  15616. let { body, documentElement } = document;
  15617. if (!body || !documentElement)
  15618. return 0;
  15619. if (median) {
  15620. let heights = [
  15621. body.scrollHeight,
  15622. body.offsetHeight,
  15623. documentElement.clientHeight,
  15624. documentElement.scrollHeight,
  15625. documentElement.offsetHeight
  15626. ].sort((a2, b2) => a2 - b2), middle = Math.floor(heights.length / 2);
  15627. return heights.length % 2 === 0 ? (heights[middle - 1] + heights[middle]) / 2 : heights[middle];
  15628. }
  15629. return Math.max(
  15630. body.scrollHeight,
  15631. body.offsetHeight,
  15632. documentElement.clientHeight,
  15633. documentElement.scrollHeight,
  15634. documentElement.offsetHeight
  15635. );
  15636. }
  15637. function getElement(element) {
  15638. if (typeof element == "string")
  15639. try {
  15640. return document.querySelector(element);
  15641. } catch {
  15642. return null;
  15643. }
  15644. return element;
  15645. }
  15646. function getStyleComputedProperty2(el) {
  15647. return !el || el.nodeType !== 1 ? null : getComputedStyle(el);
  15648. }
  15649. function getScrollParent2(element, skipFix, forListener) {
  15650. if (!element)
  15651. return scrollDocument();
  15652. let parent = (0, import_scrollparent.default)(element);
  15653. if (parent) {
  15654. if (parent.isSameNode(scrollDocument()))
  15655. return forListener ? document : scrollDocument();
  15656. if (!(parent.scrollHeight > parent.offsetHeight) && !skipFix)
  15657. return parent.style.overflow = "initial", scrollDocument();
  15658. }
  15659. return parent;
  15660. }
  15661. function hasCustomScrollParent(element, skipFix) {
  15662. if (!element)
  15663. return !1;
  15664. let parent = getScrollParent2(element, skipFix);
  15665. return parent ? !parent.isSameNode(scrollDocument()) : !1;
  15666. }
  15667. function hasCustomOffsetParent(element) {
  15668. return element.offsetParent !== document.body;
  15669. }
  15670. function hasPosition(el, type = "fixed") {
  15671. if (!el || !(el instanceof HTMLElement))
  15672. return !1;
  15673. let { nodeName } = el, styles2 = getStyleComputedProperty2(el);
  15674. return nodeName === "BODY" || nodeName === "HTML" ? !1 : styles2 && styles2.position === type ? !0 : el.parentNode ? hasPosition(el.parentNode, type) : !1;
  15675. }
  15676. function isElementVisible(element) {
  15677. var _a2;
  15678. if (!element)
  15679. return !1;
  15680. let parentElement = element;
  15681. for (; parentElement && parentElement !== document.body; ) {
  15682. if (parentElement instanceof HTMLElement) {
  15683. let { display, visibility } = getComputedStyle(parentElement);
  15684. if (display === "none" || visibility === "hidden")
  15685. return !1;
  15686. }
  15687. parentElement = (_a2 = parentElement.parentElement) != null ? _a2 : null;
  15688. }
  15689. return !0;
  15690. }
  15691. function getElementPosition(element, offset2, skipFix) {
  15692. var _a2, _b, _c;
  15693. let elementRect = getClientRect2(element), parent = getScrollParent2(element, skipFix), hasScrollParent = hasCustomScrollParent(element, skipFix), isFixedTarget = hasPosition(element), parentTop = 0, top = (_a2 = elementRect?.top) != null ? _a2 : 0;
  15694. if (hasScrollParent && isFixedTarget) {
  15695. let offsetTop = (_b = element?.offsetTop) != null ? _b : 0, parentScrollTop = (_c = parent?.scrollTop) != null ? _c : 0;
  15696. top = offsetTop - parentScrollTop;
  15697. } else parent instanceof HTMLElement && (parentTop = parent.scrollTop, !hasScrollParent && !hasPosition(element) && (top += parentTop), parent.isSameNode(scrollDocument()) || (top += scrollDocument().scrollTop));
  15698. return Math.floor(top - offset2);
  15699. }
  15700. function getScrollTo(element, offset2, skipFix) {
  15701. var _a2;
  15702. if (!element)
  15703. return 0;
  15704. let { offsetTop = 0, scrollTop = 0 } = (_a2 = (0, import_scrollparent.default)(element)) != null ? _a2 : {}, top = element.getBoundingClientRect().top + scrollTop;
  15705. offsetTop && (hasCustomScrollParent(element, skipFix) || hasCustomOffsetParent(element)) && (top -= offsetTop);
  15706. let output = Math.floor(top - offset2);
  15707. return output < 0 ? 0 : output;
  15708. }
  15709. function scrollDocument() {
  15710. var _a2;
  15711. return (_a2 = document.scrollingElement) != null ? _a2 : document.documentElement;
  15712. }
  15713. function scrollTo(value, options2) {
  15714. let { duration, element } = options2;
  15715. return new Promise((resolve, reject) => {
  15716. let { scrollTop } = element, limit = value > scrollTop ? value - scrollTop : scrollTop - value;
  15717. import_scroll.default.top(element, value, { duration: limit < 100 ? 50 : duration }, (error) => error && error.message !== "Element already at target scroll position" ? reject(error) : resolve());
  15718. });
  15719. }
  15720. var isReact162 = createPortal !== void 0;
  15721. function getBrowser(userAgent = navigator.userAgent) {
  15722. let browser = userAgent;
  15723. 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;
  15724. }
  15725. function getObjectType4(value) {
  15726. return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
  15727. }
  15728. function getReactNodeText(input, options2 = {}) {
  15729. let { defaultValue, step, steps } = options2, text = (0, import_react_innertext.default)(input);
  15730. if (text)
  15731. (text.includes("{step}") || text.includes("{steps}")) && step && steps && (text = text.replace("{step}", step.toString()).replace("{steps}", steps.toString()));
  15732. else if (isValidElement(input) && !Object.values(input.props).length && getObjectType4(input.type) === "function") {
  15733. let component = input.type({});
  15734. text = getReactNodeText(component, options2);
  15735. } else
  15736. text = (0, import_react_innertext.default)(defaultValue);
  15737. return text;
  15738. }
  15739. function hasValidKeys(object, keys) {
  15740. return !src_default.plainObject(object) || !src_default.array(keys) ? !1 : Object.keys(object).every((d2) => keys.includes(d2));
  15741. }
  15742. function hexToRGB(hex) {
  15743. 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);
  15744. return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : [];
  15745. }
  15746. function hideBeacon(step) {
  15747. return step.disableBeacon || step.placement === "center";
  15748. }
  15749. function isLegacy() {
  15750. return !["chrome", "safari", "firefox", "opera"].includes(getBrowser());
  15751. }
  15752. function log2({ data, debug = !1, title: title2, warn = !1 }) {
  15753. let logFn = warn ? console.warn || console.error : console.log;
  15754. debug && (title2 && data ? (console.groupCollapsed(
  15755. `%creact-joyride: ${title2}`,
  15756. "color: #ff0044; font-weight: bold; font-size: 12px;"
  15757. ), Array.isArray(data) ? data.forEach((d2) => {
  15758. src_default.plainObject(d2) && d2.key ? logFn.apply(console, [d2.key, d2.value]) : logFn.apply(console, [d2]);
  15759. }) : logFn.apply(console, [data]), console.groupEnd()) : console.error("Missing title or data props"));
  15760. }
  15761. function objectKeys(input) {
  15762. return Object.keys(input);
  15763. }
  15764. function omit2(input, ...filter) {
  15765. if (!src_default.plainObject(input))
  15766. throw new TypeError("Expected an object");
  15767. let output = {};
  15768. for (let key in input)
  15769. ({}).hasOwnProperty.call(input, key) && (filter.includes(key) || (output[key] = input[key]));
  15770. return output;
  15771. }
  15772. function pick2(input, ...filter) {
  15773. if (!src_default.plainObject(input))
  15774. throw new TypeError("Expected an object");
  15775. if (!filter.length)
  15776. return input;
  15777. let output = {};
  15778. for (let key in input)
  15779. ({}).hasOwnProperty.call(input, key) && filter.includes(key) && (output[key] = input[key]);
  15780. return output;
  15781. }
  15782. function replaceLocaleContent(input, step, steps) {
  15783. let replacer = (text) => text.replace("{step}", String(step)).replace("{steps}", String(steps));
  15784. if (getObjectType4(input) === "string")
  15785. return replacer(input);
  15786. if (!isValidElement(input))
  15787. return input;
  15788. let { children } = input.props;
  15789. if (getObjectType4(children) === "string" && children.includes("{step}"))
  15790. return cloneElement(input, {
  15791. children: replacer(children)
  15792. });
  15793. if (Array.isArray(children))
  15794. return cloneElement(input, {
  15795. children: children.map((child) => typeof child == "string" ? replacer(child) : replaceLocaleContent(child, step, steps))
  15796. });
  15797. if (getObjectType4(input.type) === "function" && !Object.values(input.props).length) {
  15798. let component = input.type({});
  15799. return replaceLocaleContent(component, step, steps);
  15800. }
  15801. return input;
  15802. }
  15803. function shouldScroll(options2) {
  15804. let { isFirstStep, lifecycle, previousLifecycle, scrollToFirstStep, step, target } = options2;
  15805. return !step.disableScrolling && (!isFirstStep || scrollToFirstStep || lifecycle === LIFECYCLE.TOOLTIP) && step.placement !== "center" && (!step.isFixed || !hasPosition(target)) && // fixed steps don't need to scroll
  15806. previousLifecycle !== lifecycle && [LIFECYCLE.BEACON, LIFECYCLE.TOOLTIP].includes(lifecycle);
  15807. }
  15808. var defaultFloaterProps = {
  15809. options: {
  15810. preventOverflow: {
  15811. boundariesElement: "scrollParent"
  15812. }
  15813. },
  15814. wrapperOptions: {
  15815. offset: -18,
  15816. position: !0
  15817. }
  15818. }, defaultLocale = {
  15819. back: "Back",
  15820. close: "Close",
  15821. last: "Last",
  15822. next: "Next",
  15823. nextLabelWithProgress: "Next (Step {step} of {steps})",
  15824. open: "Open the dialog",
  15825. skip: "Skip"
  15826. }, defaultStep = {
  15827. event: "click",
  15828. placement: "bottom",
  15829. offset: 10,
  15830. disableBeacon: !1,
  15831. disableCloseOnEsc: !1,
  15832. disableOverlay: !1,
  15833. disableOverlayClose: !1,
  15834. disableScrollParentFix: !1,
  15835. disableScrolling: !1,
  15836. hideBackButton: !1,
  15837. hideCloseButton: !1,
  15838. hideFooter: !1,
  15839. isFixed: !1,
  15840. locale: defaultLocale,
  15841. showProgress: !1,
  15842. showSkipButton: !1,
  15843. spotlightClicks: !1,
  15844. spotlightPadding: 10
  15845. }, defaultProps = {
  15846. continuous: !1,
  15847. debug: !1,
  15848. disableCloseOnEsc: !1,
  15849. disableOverlay: !1,
  15850. disableOverlayClose: !1,
  15851. disableScrolling: !1,
  15852. disableScrollParentFix: !1,
  15853. getHelpers: void 0,
  15854. hideBackButton: !1,
  15855. run: !0,
  15856. scrollOffset: 20,
  15857. scrollDuration: 300,
  15858. scrollToFirstStep: !1,
  15859. showSkipButton: !1,
  15860. showProgress: !1,
  15861. spotlightClicks: !1,
  15862. spotlightPadding: 10,
  15863. steps: []
  15864. }, defaultOptions2 = {
  15865. arrowColor: "#fff",
  15866. backgroundColor: "#fff",
  15867. beaconSize: 36,
  15868. overlayColor: "rgba(0, 0, 0, 0.5)",
  15869. primaryColor: "#f04",
  15870. spotlightShadow: "0 0 15px rgba(0, 0, 0, 0.5)",
  15871. textColor: "#333",
  15872. width: 380,
  15873. zIndex: 100
  15874. }, buttonBase = {
  15875. backgroundColor: "transparent",
  15876. border: 0,
  15877. borderRadius: 0,
  15878. color: "#555",
  15879. cursor: "pointer",
  15880. fontSize: 16,
  15881. lineHeight: 1,
  15882. padding: 8,
  15883. WebkitAppearance: "none"
  15884. }, spotlight = {
  15885. borderRadius: 4,
  15886. position: "absolute"
  15887. };
  15888. function getStyles2(props, step) {
  15889. var _a2, _b, _c, _d, _e;
  15890. 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;
  15891. window.innerWidth > 480 && (width = 380), "width" in options2 && (width = typeof options2.width == "number" && window.innerWidth < options2.width ? window.innerWidth - 30 : options2.width);
  15892. let overlay = {
  15893. bottom: 0,
  15894. left: 0,
  15895. overflow: "hidden",
  15896. position: "absolute",
  15897. right: 0,
  15898. top: 0,
  15899. zIndex: options2.zIndex
  15900. }, defaultStyles = {
  15901. beacon: {
  15902. ...buttonBase,
  15903. display: hideBeacon2 ? "none" : "inline-block",
  15904. height: options2.beaconSize,
  15905. position: "relative",
  15906. width: options2.beaconSize,
  15907. zIndex: options2.zIndex
  15908. },
  15909. beaconInner: {
  15910. animation: "joyride-beacon-inner 1.2s infinite ease-in-out",
  15911. backgroundColor: options2.primaryColor,
  15912. borderRadius: "50%",
  15913. display: "block",
  15914. height: "50%",
  15915. left: "50%",
  15916. opacity: 0.7,
  15917. position: "absolute",
  15918. top: "50%",
  15919. transform: "translate(-50%, -50%)",
  15920. width: "50%"
  15921. },
  15922. beaconOuter: {
  15923. animation: "joyride-beacon-outer 1.2s infinite ease-in-out",
  15924. backgroundColor: `rgba(${hexToRGB(options2.primaryColor).join(",")}, 0.2)`,
  15925. border: `2px solid ${options2.primaryColor}`,
  15926. borderRadius: "50%",
  15927. boxSizing: "border-box",
  15928. display: "block",
  15929. height: "100%",
  15930. left: 0,
  15931. opacity: 0.9,
  15932. position: "absolute",
  15933. top: 0,
  15934. transformOrigin: "center",
  15935. width: "100%"
  15936. },
  15937. tooltip: {
  15938. backgroundColor: options2.backgroundColor,
  15939. borderRadius: 5,
  15940. boxSizing: "border-box",
  15941. color: options2.textColor,
  15942. fontSize: 16,
  15943. maxWidth: "100%",
  15944. padding: 15,
  15945. position: "relative",
  15946. width
  15947. },
  15948. tooltipContainer: {
  15949. lineHeight: 1.4,
  15950. textAlign: "center"
  15951. },
  15952. tooltipTitle: {
  15953. fontSize: 18,
  15954. margin: 0
  15955. },
  15956. tooltipContent: {
  15957. padding: "20px 10px"
  15958. },
  15959. tooltipFooter: {
  15960. alignItems: "center",
  15961. display: "flex",
  15962. justifyContent: "flex-end",
  15963. marginTop: 15
  15964. },
  15965. tooltipFooterSpacer: {
  15966. flex: 1
  15967. },
  15968. buttonNext: {
  15969. ...buttonBase,
  15970. backgroundColor: options2.primaryColor,
  15971. borderRadius: 4,
  15972. color: "#fff"
  15973. },
  15974. buttonBack: {
  15975. ...buttonBase,
  15976. color: options2.primaryColor,
  15977. marginLeft: "auto",
  15978. marginRight: 5
  15979. },
  15980. buttonClose: {
  15981. ...buttonBase,
  15982. color: options2.textColor,
  15983. height: 14,
  15984. padding: 15,
  15985. position: "absolute",
  15986. right: 0,
  15987. top: 0,
  15988. width: 14
  15989. },
  15990. buttonSkip: {
  15991. ...buttonBase,
  15992. color: options2.textColor,
  15993. fontSize: 14
  15994. },
  15995. overlay: {
  15996. ...overlay,
  15997. backgroundColor: options2.overlayColor,
  15998. mixBlendMode: "hard-light"
  15999. },
  16000. overlayLegacy: {
  16001. ...overlay
  16002. },
  16003. overlayLegacyCenter: {
  16004. ...overlay,
  16005. backgroundColor: options2.overlayColor
  16006. },
  16007. spotlight: {
  16008. ...spotlight,
  16009. backgroundColor: "gray"
  16010. },
  16011. spotlightLegacy: {
  16012. ...spotlight,
  16013. boxShadow: `0 0 0 9999px ${options2.overlayColor}, ${options2.spotlightShadow}`
  16014. },
  16015. floaterStyles: {
  16016. arrow: {
  16017. color: (_e = (_d = (_c = mergedFloaterProps?.styles) == null ? void 0 : _c.arrow) == null ? void 0 : _d.color) != null ? _e : options2.arrowColor
  16018. },
  16019. options: {
  16020. zIndex: options2.zIndex + 100
  16021. }
  16022. },
  16023. options: options2
  16024. };
  16025. return (0, import_deepmerge3.default)(defaultStyles, mergedStyles);
  16026. }
  16027. function getTourProps(props) {
  16028. return pick2(
  16029. props,
  16030. "beaconComponent",
  16031. "disableCloseOnEsc",
  16032. "disableOverlay",
  16033. "disableOverlayClose",
  16034. "disableScrolling",
  16035. "disableScrollParentFix",
  16036. "floaterProps",
  16037. "hideBackButton",
  16038. "hideCloseButton",
  16039. "locale",
  16040. "showProgress",
  16041. "showSkipButton",
  16042. "spotlightClicks",
  16043. "spotlightPadding",
  16044. "styles",
  16045. "tooltipComponent"
  16046. );
  16047. }
  16048. function getMergedStep(props, currentStep) {
  16049. var _a2, _b, _c, _d, _e, _f;
  16050. let step = currentStep ?? {}, mergedStep = import_deepmerge2.default.all([defaultStep, getTourProps(props), step], {
  16051. isMergeableObject: src_default.plainObject
  16052. }), mergedStyles = getStyles2(props, mergedStep), scrollParent2 = hasCustomScrollParent(
  16053. getElement(mergedStep.target),
  16054. mergedStep.disableScrollParentFix
  16055. ), floaterProps = import_deepmerge2.default.all([
  16056. defaultFloaterProps,
  16057. (_a2 = props.floaterProps) != null ? _a2 : {},
  16058. (_b = mergedStep.floaterProps) != null ? _b : {}
  16059. ]);
  16060. 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"), {
  16061. ...mergedStep,
  16062. locale: import_deepmerge2.default.all([defaultLocale, (_f = props.locale) != null ? _f : {}, mergedStep.locale || {}]),
  16063. floaterProps,
  16064. styles: omit2(mergedStyles, "floaterStyles")
  16065. };
  16066. }
  16067. function validateStep(step, debug = !1) {
  16068. return src_default.plainObject(step) ? step.target ? !0 : (log2({
  16069. title: "validateStep",
  16070. data: "target is missing from the step",
  16071. warn: !0,
  16072. debug
  16073. }), !1) : (log2({
  16074. title: "validateStep",
  16075. data: "step must be an object",
  16076. warn: !0,
  16077. debug
  16078. }), !1);
  16079. }
  16080. function validateSteps(steps, debug = !1) {
  16081. return src_default.array(steps) ? steps.every((d2) => validateStep(d2, debug)) : (log2({
  16082. title: "validateSteps",
  16083. data: "steps must be an array",
  16084. warn: !0,
  16085. debug
  16086. }), !1);
  16087. }
  16088. var defaultState = {
  16089. action: "init",
  16090. controlled: !1,
  16091. index: 0,
  16092. lifecycle: LIFECYCLE.INIT,
  16093. origin: null,
  16094. size: 0,
  16095. status: STATUS3.IDLE
  16096. }, validKeys = objectKeys(omit2(defaultState, "controlled", "size")), Store = class {
  16097. constructor(options2) {
  16098. __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) => {
  16099. this.listener = listener;
  16100. }), __publicField(this, "setSteps", (steps2) => {
  16101. let { size, status } = this.getState(), state = {
  16102. size: steps2.length,
  16103. status
  16104. };
  16105. this.data.set("steps", steps2), status === STATUS3.WAITING && !size && steps2.length && (state.status = STATUS3.RUNNING), this.setState(state);
  16106. }), __publicField(this, "getPopper", (name) => name === "beacon" ? this.beaconPopper : this.tooltipPopper), __publicField(this, "setPopper", (name, popper) => {
  16107. name === "beacon" ? this.beaconPopper = popper : this.tooltipPopper = popper;
  16108. }), __publicField(this, "cleanupPoppers", () => {
  16109. this.beaconPopper = null, this.tooltipPopper = null;
  16110. }), __publicField(this, "close", (origin = null) => {
  16111. let { index, status } = this.getState();
  16112. status === STATUS3.RUNNING && this.setState({
  16113. ...this.getNextState({ action: ACTIONS.CLOSE, index: index + 1, origin })
  16114. });
  16115. }), __publicField(this, "go", (nextIndex) => {
  16116. let { controlled, status } = this.getState();
  16117. if (controlled || status !== STATUS3.RUNNING)
  16118. return;
  16119. let step = this.getSteps()[nextIndex];
  16120. this.setState({
  16121. ...this.getNextState({ action: ACTIONS.GO, index: nextIndex }),
  16122. status: step ? status : STATUS3.FINISHED
  16123. });
  16124. }), __publicField(this, "info", () => this.getState()), __publicField(this, "next", () => {
  16125. let { index, status } = this.getState();
  16126. status === STATUS3.RUNNING && this.setState(this.getNextState({ action: ACTIONS.NEXT, index: index + 1 }));
  16127. }), __publicField(this, "open", () => {
  16128. let { status } = this.getState();
  16129. status === STATUS3.RUNNING && this.setState({
  16130. ...this.getNextState({ action: ACTIONS.UPDATE, lifecycle: LIFECYCLE.TOOLTIP })
  16131. });
  16132. }), __publicField(this, "prev", () => {
  16133. let { index, status } = this.getState();
  16134. status === STATUS3.RUNNING && this.setState({
  16135. ...this.getNextState({ action: ACTIONS.PREV, index: index - 1 })
  16136. });
  16137. }), __publicField(this, "reset", (restart = !1) => {
  16138. let { controlled } = this.getState();
  16139. controlled || this.setState({
  16140. ...this.getNextState({ action: ACTIONS.RESET, index: 0 }),
  16141. status: restart ? STATUS3.RUNNING : STATUS3.READY
  16142. });
  16143. }), __publicField(this, "skip", () => {
  16144. let { status } = this.getState();
  16145. status === STATUS3.RUNNING && this.setState({
  16146. action: ACTIONS.SKIP,
  16147. lifecycle: LIFECYCLE.INIT,
  16148. status: STATUS3.SKIPPED
  16149. });
  16150. }), __publicField(this, "start", (nextIndex) => {
  16151. let { index, size } = this.getState();
  16152. this.setState({
  16153. ...this.getNextState(
  16154. {
  16155. action: ACTIONS.START,
  16156. index: src_default.number(nextIndex) ? nextIndex : index
  16157. },
  16158. !0
  16159. ),
  16160. status: size ? STATUS3.RUNNING : STATUS3.WAITING
  16161. });
  16162. }), __publicField(this, "stop", (advance = !1) => {
  16163. let { index, status } = this.getState();
  16164. [STATUS3.FINISHED, STATUS3.SKIPPED].includes(status) || this.setState({
  16165. ...this.getNextState({ action: ACTIONS.STOP, index: index + (advance ? 1 : 0) }),
  16166. status: STATUS3.PAUSED
  16167. });
  16168. }), __publicField(this, "update", (state) => {
  16169. var _a2, _b;
  16170. if (!hasValidKeys(state, validKeys))
  16171. throw new Error(`State is not valid. Valid keys: ${validKeys.join(", ")}`);
  16172. this.setState({
  16173. ...this.getNextState(
  16174. {
  16175. ...this.getState(),
  16176. ...state,
  16177. action: (_a2 = state.action) != null ? _a2 : ACTIONS.UPDATE,
  16178. origin: (_b = state.origin) != null ? _b : null
  16179. },
  16180. !0
  16181. )
  16182. });
  16183. });
  16184. let { continuous = !1, stepIndex, steps = [] } = options2 ?? {};
  16185. this.setState(
  16186. {
  16187. action: ACTIONS.INIT,
  16188. controlled: src_default.number(stepIndex),
  16189. continuous,
  16190. index: src_default.number(stepIndex) ? stepIndex : 0,
  16191. lifecycle: LIFECYCLE.INIT,
  16192. origin: null,
  16193. status: steps.length ? STATUS3.READY : STATUS3.IDLE
  16194. },
  16195. !0
  16196. ), this.beaconPopper = null, this.tooltipPopper = null, this.listener = null, this.setSteps(steps);
  16197. }
  16198. getState() {
  16199. return this.store.size ? {
  16200. action: this.store.get("action") || "",
  16201. controlled: this.store.get("controlled") || !1,
  16202. index: parseInt(this.store.get("index"), 10),
  16203. lifecycle: this.store.get("lifecycle") || "",
  16204. origin: this.store.get("origin") || null,
  16205. size: this.store.get("size") || 0,
  16206. status: this.store.get("status") || ""
  16207. } : { ...defaultState };
  16208. }
  16209. getNextState(state, force = !1) {
  16210. var _a2, _b, _c, _d, _e;
  16211. 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);
  16212. return {
  16213. action: (_a2 = state.action) != null ? _a2 : action,
  16214. controlled,
  16215. index: nextIndex,
  16216. lifecycle: (_b = state.lifecycle) != null ? _b : LIFECYCLE.INIT,
  16217. origin: (_c = state.origin) != null ? _c : null,
  16218. size: (_d = state.size) != null ? _d : size,
  16219. status: nextIndex === size ? STATUS3.FINISHED : (_e = state.status) != null ? _e : status
  16220. };
  16221. }
  16222. getSteps() {
  16223. let steps = this.data.get("steps");
  16224. return Array.isArray(steps) ? steps : [];
  16225. }
  16226. hasUpdatedState(oldState) {
  16227. let before2 = JSON.stringify(oldState), after2 = JSON.stringify(this.getState());
  16228. return before2 !== after2;
  16229. }
  16230. setState(nextState, initial = !1) {
  16231. let state = this.getState(), {
  16232. action,
  16233. index,
  16234. lifecycle,
  16235. origin = null,
  16236. size,
  16237. status
  16238. } = {
  16239. ...state,
  16240. ...nextState
  16241. };
  16242. 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());
  16243. }
  16244. getHelpers() {
  16245. return {
  16246. close: this.close,
  16247. go: this.go,
  16248. info: this.info,
  16249. next: this.next,
  16250. open: this.open,
  16251. prev: this.prev,
  16252. reset: this.reset,
  16253. skip: this.skip
  16254. };
  16255. }
  16256. };
  16257. function createStore(options2) {
  16258. return new Store(options2);
  16259. }
  16260. function JoyrideSpotlight({ styles: styles2 }) {
  16261. return createElement(
  16262. "div",
  16263. {
  16264. key: "JoyrideSpotlight",
  16265. className: "react-joyride__spotlight",
  16266. "data-test-id": "spotlight",
  16267. style: styles2
  16268. }
  16269. );
  16270. }
  16271. var Spotlight_default = JoyrideSpotlight, JoyrideOverlay = class extends Component {
  16272. constructor() {
  16273. super(...arguments), __publicField(this, "isActive", !1), __publicField(this, "resizeTimeout"), __publicField(this, "scrollTimeout"), __publicField(this, "scrollParent"), __publicField(this, "state", {
  16274. isScrolling: !1,
  16275. mouseOverSpotlight: !1,
  16276. showSpotlight: !0
  16277. }), __publicField(this, "hideSpotlight", () => {
  16278. let { continuous, disableOverlay, lifecycle } = this.props, hiddenLifecycles = [
  16279. LIFECYCLE.INIT,
  16280. LIFECYCLE.BEACON,
  16281. LIFECYCLE.COMPLETE,
  16282. LIFECYCLE.ERROR
  16283. ];
  16284. return disableOverlay || (continuous ? hiddenLifecycles.includes(lifecycle) : lifecycle !== LIFECYCLE.TOOLTIP);
  16285. }), __publicField(this, "handleMouseMove", (event) => {
  16286. 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;
  16287. inSpotlight !== mouseOverSpotlight && this.updateState({ mouseOverSpotlight: inSpotlight });
  16288. }), __publicField(this, "handleScroll", () => {
  16289. let { target } = this.props, element = getElement(target);
  16290. if (this.scrollParent !== document) {
  16291. let { isScrolling } = this.state;
  16292. isScrolling || this.updateState({ isScrolling: !0, showSpotlight: !1 }), clearTimeout(this.scrollTimeout), this.scrollTimeout = window.setTimeout(() => {
  16293. this.updateState({ isScrolling: !1, showSpotlight: !0 });
  16294. }, 50);
  16295. } else hasPosition(element, "sticky") && this.updateState({});
  16296. }), __publicField(this, "handleResize", () => {
  16297. clearTimeout(this.resizeTimeout), this.resizeTimeout = window.setTimeout(() => {
  16298. this.isActive && this.forceUpdate();
  16299. }, 100);
  16300. });
  16301. }
  16302. componentDidMount() {
  16303. let { debug, disableScrolling, disableScrollParentFix = !1, target } = this.props, element = getElement(target);
  16304. this.scrollParent = getScrollParent2(element ?? document.body, disableScrollParentFix, !0), this.isActive = !0, window.addEventListener("resize", this.handleResize);
  16305. }
  16306. componentDidUpdate(previousProps) {
  16307. var _a2;
  16308. let { disableScrollParentFix, lifecycle, spotlightClicks, target } = this.props, { changed } = treeChanges(previousProps, this.props);
  16309. if (changed("target") || changed("disableScrollParentFix")) {
  16310. let element = getElement(target);
  16311. this.scrollParent = getScrollParent2(element ?? document.body, disableScrollParentFix, !0);
  16312. }
  16313. changed("lifecycle", LIFECYCLE.TOOLTIP) && ((_a2 = this.scrollParent) == null || _a2.addEventListener("scroll", this.handleScroll, { passive: !0 }), setTimeout(() => {
  16314. let { isScrolling } = this.state;
  16315. isScrolling || this.updateState({ showSpotlight: !0 });
  16316. }, 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));
  16317. }
  16318. componentWillUnmount() {
  16319. var _a2;
  16320. 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);
  16321. }
  16322. get overlayStyles() {
  16323. let { mouseOverSpotlight } = this.state, { disableOverlayClose, placement, styles: styles2 } = this.props, baseStyles = styles2.overlay;
  16324. return isLegacy() && (baseStyles = placement === "center" ? styles2.overlayLegacyCenter : styles2.overlayLegacy), {
  16325. cursor: disableOverlayClose ? "default" : "pointer",
  16326. height: getDocumentHeight(),
  16327. pointerEvents: mouseOverSpotlight ? "none" : "auto",
  16328. ...baseStyles
  16329. };
  16330. }
  16331. get spotlightStyles() {
  16332. var _a2, _b, _c;
  16333. let { showSpotlight } = this.state, {
  16334. disableScrollParentFix = !1,
  16335. spotlightClicks,
  16336. spotlightPadding = 0,
  16337. styles: styles2,
  16338. target
  16339. } = this.props, element = getElement(target), elementRect = getClientRect2(element), isFixedTarget = hasPosition(element), top = getElementPosition(element, spotlightPadding, disableScrollParentFix);
  16340. return {
  16341. ...isLegacy() ? styles2.spotlightLegacy : styles2.spotlight,
  16342. height: Math.round(((_a2 = elementRect?.height) != null ? _a2 : 0) + spotlightPadding * 2),
  16343. left: Math.round(((_b = elementRect?.left) != null ? _b : 0) - spotlightPadding),
  16344. opacity: showSpotlight ? 1 : 0,
  16345. pointerEvents: spotlightClicks ? "none" : "auto",
  16346. position: isFixedTarget ? "fixed" : "absolute",
  16347. top,
  16348. transition: "opacity 0.2s",
  16349. width: Math.round(((_c = elementRect?.width) != null ? _c : 0) + spotlightPadding * 2)
  16350. };
  16351. }
  16352. updateState(state) {
  16353. this.isActive && this.setState((previousState) => ({ ...previousState, ...state }));
  16354. }
  16355. render() {
  16356. let { showSpotlight } = this.state, { onClickOverlay, placement } = this.props, { hideSpotlight, overlayStyles, spotlightStyles } = this;
  16357. if (hideSpotlight())
  16358. return null;
  16359. let spotlight2 = placement !== "center" && showSpotlight && createElement(Spotlight_default, { styles: spotlightStyles });
  16360. if (getBrowser() === "safari") {
  16361. let { mixBlendMode, zIndex, ...safariOverlay } = overlayStyles;
  16362. spotlight2 = createElement("div", { style: { ...safariOverlay } }, spotlight2), delete overlayStyles.backgroundColor;
  16363. }
  16364. return createElement(
  16365. "div",
  16366. {
  16367. className: "react-joyride__overlay",
  16368. "data-test-id": "overlay",
  16369. onClick: onClickOverlay,
  16370. role: "presentation",
  16371. style: overlayStyles
  16372. },
  16373. spotlight2
  16374. );
  16375. }
  16376. }, JoyridePortal = class extends Component {
  16377. constructor() {
  16378. super(...arguments), __publicField(this, "node", null);
  16379. }
  16380. componentDidMount() {
  16381. let { id } = this.props;
  16382. canUseDOM2() && (this.node = document.createElement("div"), this.node.id = id, document.body.appendChild(this.node), isReact162 || this.renderReact15());
  16383. }
  16384. componentDidUpdate() {
  16385. canUseDOM2() && (isReact162 || this.renderReact15());
  16386. }
  16387. componentWillUnmount() {
  16388. !canUseDOM2() || !this.node || (isReact162 || unmountComponentAtNode(this.node), this.node.parentNode === document.body && (document.body.removeChild(this.node), this.node = null));
  16389. }
  16390. renderReact15() {
  16391. if (!canUseDOM2())
  16392. return;
  16393. let { children } = this.props;
  16394. this.node && unstable_renderSubtreeIntoContainer(this, children, this.node);
  16395. }
  16396. renderReact16() {
  16397. if (!canUseDOM2() || !isReact162)
  16398. return null;
  16399. let { children } = this.props;
  16400. return this.node ? createPortal(children, this.node) : null;
  16401. }
  16402. render() {
  16403. return isReact162 ? this.renderReact16() : null;
  16404. }
  16405. }, Scope = class {
  16406. constructor(element, options2) {
  16407. if (__publicField(this, "element"), __publicField(this, "options"), __publicField(this, "canBeTabbed", (element2) => {
  16408. let { tabIndex } = element2;
  16409. return tabIndex === null || tabIndex < 0 ? !1 : this.canHaveFocus(element2);
  16410. }), __publicField(this, "canHaveFocus", (element2) => {
  16411. let validTabNodes = /input|select|textarea|button|object/, nodeName = element2.nodeName.toLowerCase();
  16412. return (validTabNodes.test(nodeName) && !element2.getAttribute("disabled") || nodeName === "a" && !!element2.getAttribute("href")) && this.isVisible(element2);
  16413. }), __publicField(this, "findValidTabElements", () => [].slice.call(this.element.querySelectorAll("*"), 0).filter(this.canBeTabbed)), __publicField(this, "handleKeyDown", (event) => {
  16414. let { code = "Tab" } = this.options;
  16415. event.code === code && this.interceptTab(event);
  16416. }), __publicField(this, "interceptTab", (event) => {
  16417. event.preventDefault();
  16418. let elements = this.findValidTabElements(), { shiftKey } = event;
  16419. if (!elements.length)
  16420. return;
  16421. let x2 = document.activeElement ? elements.indexOf(document.activeElement) : 0;
  16422. x2 === -1 || !shiftKey && x2 + 1 === elements.length ? x2 = 0 : shiftKey && x2 === 0 ? x2 = elements.length - 1 : x2 += shiftKey ? -1 : 1, elements[x2].focus();
  16423. }), __publicField(this, "isHidden", (element2) => {
  16424. let noSize = element2.offsetWidth <= 0 && element2.offsetHeight <= 0, style = window.getComputedStyle(element2);
  16425. return noSize && !element2.innerHTML ? !0 : noSize && style.getPropertyValue("overflow") !== "visible" || style.getPropertyValue("display") === "none";
  16426. }), __publicField(this, "isVisible", (element2) => {
  16427. let parentElement = element2;
  16428. for (; parentElement; )
  16429. if (parentElement instanceof HTMLElement) {
  16430. if (parentElement === document.body)
  16431. break;
  16432. if (this.isHidden(parentElement))
  16433. return !1;
  16434. parentElement = parentElement.parentNode;
  16435. }
  16436. return !0;
  16437. }), __publicField(this, "removeScope", () => {
  16438. window.removeEventListener("keydown", this.handleKeyDown);
  16439. }), __publicField(this, "checkFocus", (target) => {
  16440. document.activeElement !== target && (target.focus(), window.requestAnimationFrame(() => this.checkFocus(target)));
  16441. }), __publicField(this, "setFocus", () => {
  16442. let { selector } = this.options;
  16443. if (!selector)
  16444. return;
  16445. let target = this.element.querySelector(selector);
  16446. target && window.requestAnimationFrame(() => this.checkFocus(target));
  16447. }), !(element instanceof HTMLElement))
  16448. throw new TypeError("Invalid parameter: element must be an HTMLElement");
  16449. this.element = element, this.options = options2, window.addEventListener("keydown", this.handleKeyDown, !1), this.setFocus();
  16450. }
  16451. }, JoyrideBeacon = class extends Component {
  16452. constructor(props) {
  16453. if (super(props), __publicField(this, "beacon", null), __publicField(this, "setBeaconRef", (c2) => {
  16454. this.beacon = c2;
  16455. }), props.beaconComponent)
  16456. return;
  16457. let head = document.head || document.getElementsByTagName("head")[0], style = document.createElement("style");
  16458. style.id = "joyride-beacon-animation", props.nonce && style.setAttribute("nonce", props.nonce), style.appendChild(document.createTextNode(`
  16459. @keyframes joyride-beacon-inner {
  16460. 20% {
  16461. opacity: 0.9;
  16462. }
  16463. 90% {
  16464. opacity: 0.7;
  16465. }
  16466. }
  16467. @keyframes joyride-beacon-outer {
  16468. 0% {
  16469. transform: scale(1);
  16470. }
  16471. 45% {
  16472. opacity: 0.7;
  16473. transform: scale(0.75);
  16474. }
  16475. 100% {
  16476. opacity: 0.9;
  16477. transform: scale(1);
  16478. }
  16479. }
  16480. `)), head.appendChild(style);
  16481. }
  16482. componentDidMount() {
  16483. let { shouldFocus } = this.props;
  16484. setTimeout(() => {
  16485. src_default.domElement(this.beacon) && shouldFocus && this.beacon.focus();
  16486. }, 0);
  16487. }
  16488. componentWillUnmount() {
  16489. let style = document.getElementById("joyride-beacon-animation");
  16490. style?.parentNode && style.parentNode.removeChild(style);
  16491. }
  16492. render() {
  16493. let {
  16494. beaconComponent,
  16495. continuous,
  16496. index,
  16497. isLastStep,
  16498. locale,
  16499. onClickOrHover,
  16500. size,
  16501. step,
  16502. styles: styles2
  16503. } = this.props, title2 = getReactNodeText(locale.open), sharedProps = {
  16504. "aria-label": title2,
  16505. onClick: onClickOrHover,
  16506. onMouseEnter: onClickOrHover,
  16507. ref: this.setBeaconRef,
  16508. title: title2
  16509. }, component;
  16510. return beaconComponent ? component = createElement(
  16511. beaconComponent,
  16512. {
  16513. continuous,
  16514. index,
  16515. isLastStep,
  16516. size,
  16517. step,
  16518. ...sharedProps
  16519. }
  16520. ) : component = createElement(
  16521. "button",
  16522. {
  16523. key: "JoyrideBeacon",
  16524. className: "react-joyride__beacon",
  16525. "data-test-id": "button-beacon",
  16526. style: styles2.beacon,
  16527. type: "button",
  16528. ...sharedProps
  16529. },
  16530. createElement("span", { style: styles2.beaconInner }),
  16531. createElement("span", { style: styles2.beaconOuter })
  16532. ), component;
  16533. }
  16534. };
  16535. function JoyrideTooltipCloseButton({ styles: styles2, ...props }) {
  16536. let { color: color2, height, width, ...style } = styles2;
  16537. return react_default.createElement("button", { style, type: "button", ...props }, react_default.createElement(
  16538. "svg",
  16539. {
  16540. height: typeof height == "number" ? `${height}px` : height,
  16541. preserveAspectRatio: "xMidYMid",
  16542. version: "1.1",
  16543. viewBox: "0 0 18 18",
  16544. width: typeof width == "number" ? `${width}px` : width,
  16545. xmlns: "http://www.w3.org/2000/svg"
  16546. },
  16547. react_default.createElement("g", null, react_default.createElement(
  16548. "path",
  16549. {
  16550. 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",
  16551. fill: color2
  16552. }
  16553. ))
  16554. ));
  16555. }
  16556. var CloseButton_default = JoyrideTooltipCloseButton;
  16557. function JoyrideTooltipContainer(props) {
  16558. let { backProps, closeProps, index, isLastStep, primaryProps, skipProps, step, tooltipProps } = props, { content, hideBackButton, hideCloseButton, hideFooter, showSkipButton, styles: styles2, title: title2 } = step, output = {};
  16559. return output.primary = createElement(
  16560. "button",
  16561. {
  16562. "data-test-id": "button-primary",
  16563. style: styles2.buttonNext,
  16564. type: "button",
  16565. ...primaryProps
  16566. }
  16567. ), showSkipButton && !isLastStep && (output.skip = createElement(
  16568. "button",
  16569. {
  16570. "aria-live": "off",
  16571. "data-test-id": "button-skip",
  16572. style: styles2.buttonSkip,
  16573. type: "button",
  16574. ...skipProps
  16575. }
  16576. )), !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(
  16577. "div",
  16578. {
  16579. key: "JoyrideTooltip",
  16580. "aria-label": getReactNodeText(title2 ?? content),
  16581. className: "react-joyride__tooltip",
  16582. style: styles2.tooltip,
  16583. ...tooltipProps
  16584. },
  16585. createElement("div", { style: styles2.tooltipContainer }, title2 && createElement("h1", { "aria-label": getReactNodeText(title2), style: styles2.tooltipTitle }, title2), createElement("div", { style: styles2.tooltipContent }, content)),
  16586. !hideFooter && createElement("div", { style: styles2.tooltipFooter }, createElement("div", { style: styles2.tooltipFooterSpacer }, output.skip), output.back, output.primary),
  16587. output.close
  16588. );
  16589. }
  16590. var Container_default = JoyrideTooltipContainer, JoyrideTooltip = class extends Component {
  16591. constructor() {
  16592. super(...arguments), __publicField(this, "handleClickBack", (event) => {
  16593. event.preventDefault();
  16594. let { helpers } = this.props;
  16595. helpers.prev();
  16596. }), __publicField(this, "handleClickClose", (event) => {
  16597. event.preventDefault();
  16598. let { helpers } = this.props;
  16599. helpers.close("button_close");
  16600. }), __publicField(this, "handleClickPrimary", (event) => {
  16601. event.preventDefault();
  16602. let { continuous, helpers } = this.props;
  16603. if (!continuous) {
  16604. helpers.close("button_primary");
  16605. return;
  16606. }
  16607. helpers.next();
  16608. }), __publicField(this, "handleClickSkip", (event) => {
  16609. event.preventDefault();
  16610. let { helpers } = this.props;
  16611. helpers.skip();
  16612. }), __publicField(this, "getElementsProps", () => {
  16613. 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;
  16614. if (continuous) {
  16615. if (primary = next, primaryText = nextText, step.showProgress && !isLastStep) {
  16616. let labelWithProgress = getReactNodeText(nextLabelWithProgress, {
  16617. step: index + 1,
  16618. steps: size
  16619. });
  16620. primary = replaceLocaleContent(nextLabelWithProgress, index + 1, size), primaryText = labelWithProgress;
  16621. }
  16622. isLastStep && (primary = last, primaryText = lastText);
  16623. }
  16624. return {
  16625. backProps: {
  16626. "aria-label": backText,
  16627. children: back,
  16628. "data-action": "back",
  16629. onClick: this.handleClickBack,
  16630. role: "button",
  16631. title: backText
  16632. },
  16633. closeProps: {
  16634. "aria-label": closeText,
  16635. children: close,
  16636. "data-action": "close",
  16637. onClick: this.handleClickClose,
  16638. role: "button",
  16639. title: closeText
  16640. },
  16641. primaryProps: {
  16642. "aria-label": primaryText,
  16643. children: primary,
  16644. "data-action": "primary",
  16645. onClick: this.handleClickPrimary,
  16646. role: "button",
  16647. title: primaryText
  16648. },
  16649. skipProps: {
  16650. "aria-label": skipText,
  16651. children: skip,
  16652. "data-action": "skip",
  16653. onClick: this.handleClickSkip,
  16654. role: "button",
  16655. title: skipText
  16656. },
  16657. tooltipProps: {
  16658. "aria-modal": !0,
  16659. ref: setTooltipRef,
  16660. role: "alertdialog"
  16661. }
  16662. };
  16663. });
  16664. }
  16665. render() {
  16666. let { continuous, index, isLastStep, setTooltipRef, size, step } = this.props, { beaconComponent, tooltipComponent, ...cleanStep } = step, component;
  16667. if (tooltipComponent) {
  16668. let renderProps = {
  16669. ...this.getElementsProps(),
  16670. continuous,
  16671. index,
  16672. isLastStep,
  16673. size,
  16674. step: cleanStep,
  16675. setTooltipRef
  16676. };
  16677. component = createElement(tooltipComponent, { ...renderProps });
  16678. } else
  16679. component = createElement(
  16680. Container_default,
  16681. {
  16682. ...this.getElementsProps(),
  16683. continuous,
  16684. index,
  16685. isLastStep,
  16686. size,
  16687. step
  16688. }
  16689. );
  16690. return component;
  16691. }
  16692. }, JoyrideStep = class extends Component {
  16693. constructor() {
  16694. super(...arguments), __publicField(this, "scope", null), __publicField(this, "tooltip", null), __publicField(this, "handleClickHoverBeacon", (event) => {
  16695. let { step, store: store2 } = this.props;
  16696. event.type === "mouseenter" && step.event !== "hover" || store2.update({ lifecycle: LIFECYCLE.TOOLTIP });
  16697. }), __publicField(this, "setTooltipRef", (element) => {
  16698. this.tooltip = element;
  16699. }), __publicField(this, "setPopper", (popper, type) => {
  16700. var _a2;
  16701. let { action, lifecycle, step, store: store2 } = this.props;
  16702. type === "wrapper" ? store2.setPopper("beacon", popper) : store2.setPopper("tooltip", popper), store2.getPopper("beacon") && (store2.getPopper("tooltip") || step.placement === "center") && lifecycle === LIFECYCLE.INIT && store2.update({
  16703. action,
  16704. lifecycle: LIFECYCLE.READY
  16705. }), (_a2 = step.floaterProps) != null && _a2.getPopper && step.floaterProps.getPopper(popper, type);
  16706. }), __publicField(this, "renderTooltip", (renderProps) => {
  16707. let { continuous, helpers, index, size, step } = this.props;
  16708. return createElement(
  16709. JoyrideTooltip,
  16710. {
  16711. continuous,
  16712. helpers,
  16713. index,
  16714. isLastStep: index + 1 === size,
  16715. setTooltipRef: this.setTooltipRef,
  16716. size,
  16717. step,
  16718. ...renderProps
  16719. }
  16720. );
  16721. });
  16722. }
  16723. componentDidMount() {
  16724. let { debug, index } = this.props;
  16725. log2({
  16726. title: `step:${index}`,
  16727. data: [{ key: "props", value: this.props }],
  16728. debug
  16729. });
  16730. }
  16731. componentDidUpdate(previousProps) {
  16732. var _a2;
  16733. let {
  16734. action,
  16735. callback,
  16736. continuous,
  16737. controlled,
  16738. debug,
  16739. helpers,
  16740. index,
  16741. lifecycle,
  16742. shouldScroll: shouldScroll2,
  16743. status,
  16744. step,
  16745. store: store2
  16746. } = 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", [
  16747. ACTIONS.NEXT,
  16748. ACTIONS.PREV,
  16749. ACTIONS.SKIP,
  16750. ACTIONS.CLOSE
  16751. ]), isControlled = controlled && index === previousProps.index;
  16752. if (isAfterAction && (isInitial || isControlled) && callback({
  16753. ...state,
  16754. index: previousProps.index,
  16755. lifecycle: LIFECYCLE.COMPLETE,
  16756. step: previousProps.step,
  16757. type: EVENTS.STEP_AFTER
  16758. }), step.placement === "center" && status === STATUS3.RUNNING && changed("index") && action !== ACTIONS.START && lifecycle === LIFECYCLE.INIT && store2.update({ lifecycle: LIFECYCLE.READY }), hasStoreChanged) {
  16759. let element = getElement(step.target), elementExists = !!element;
  16760. elementExists && isElementVisible(element) ? (changedFrom("status", STATUS3.READY, STATUS3.RUNNING) || changedFrom("lifecycle", LIFECYCLE.INIT, LIFECYCLE.READY)) && callback({
  16761. ...state,
  16762. step,
  16763. type: EVENTS.STEP_BEFORE
  16764. }) : (console.warn(elementExists ? "Target not visible" : "Target not mounted", step), callback({
  16765. ...state,
  16766. type: EVENTS.TARGET_NOT_FOUND,
  16767. step
  16768. }), controlled || store2.update({ index: index + (action === ACTIONS.PREV ? -1 : 1) }));
  16769. }
  16770. changedFrom("lifecycle", LIFECYCLE.INIT, LIFECYCLE.READY) && store2.update({
  16771. lifecycle: hideBeacon(step) || skipBeacon ? LIFECYCLE.TOOLTIP : LIFECYCLE.BEACON
  16772. }), changed("index") && log2({
  16773. title: `step:${lifecycle}`,
  16774. data: [{ key: "props", value: this.props }],
  16775. debug
  16776. }), changed("lifecycle", LIFECYCLE.BEACON) && callback({
  16777. ...state,
  16778. step,
  16779. type: EVENTS.BEACON
  16780. }), changed("lifecycle", LIFECYCLE.TOOLTIP) && (callback({
  16781. ...state,
  16782. step,
  16783. type: EVENTS.TOOLTIP
  16784. }), 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());
  16785. }
  16786. componentWillUnmount() {
  16787. var _a2;
  16788. (_a2 = this.scope) == null || _a2.removeScope();
  16789. }
  16790. get open() {
  16791. let { lifecycle, step } = this.props;
  16792. return hideBeacon(step) || lifecycle === LIFECYCLE.TOOLTIP;
  16793. }
  16794. render() {
  16795. let { continuous, debug, index, nonce, shouldScroll: shouldScroll2, size, step } = this.props, target = getElement(step.target);
  16796. return !validateStep(step) || !src_default.domElement(target) ? null : createElement("div", { key: `JoyrideStep-${index}`, className: "react-joyride__step" }, createElement(
  16797. ReactFloater,
  16798. {
  16799. ...step.floaterProps,
  16800. component: this.renderTooltip,
  16801. debug,
  16802. getPopper: this.setPopper,
  16803. id: `react-joyride-step-${index}`,
  16804. open: this.open,
  16805. placement: step.placement,
  16806. target: step.target
  16807. },
  16808. createElement(
  16809. JoyrideBeacon,
  16810. {
  16811. beaconComponent: step.beaconComponent,
  16812. continuous,
  16813. index,
  16814. isLastStep: index + 1 === size,
  16815. locale: step.locale,
  16816. nonce,
  16817. onClickOrHover: this.handleClickHoverBeacon,
  16818. shouldFocus: shouldScroll2,
  16819. size,
  16820. step,
  16821. styles: step.styles
  16822. }
  16823. )
  16824. ));
  16825. }
  16826. }, Joyride = class extends Component {
  16827. constructor(props) {
  16828. super(props), __publicField(this, "helpers"), __publicField(this, "store"), __publicField(this, "callback", (data) => {
  16829. let { callback } = this.props;
  16830. src_default.function(callback) && callback(data);
  16831. }), __publicField(this, "handleKeyboard", (event) => {
  16832. let { index, lifecycle } = this.state, { steps } = this.props, step = steps[index];
  16833. lifecycle === LIFECYCLE.TOOLTIP && event.code === "Escape" && step && !step.disableCloseOnEsc && this.store.close("keyboard");
  16834. }), __publicField(this, "handleClickOverlay", () => {
  16835. let { index } = this.state, { steps } = this.props;
  16836. getMergedStep(this.props, steps[index]).disableOverlayClose || this.helpers.close("overlay");
  16837. }), __publicField(this, "syncState", (state) => {
  16838. this.setState(state);
  16839. });
  16840. let { debug, getHelpers, run = !0, stepIndex } = props;
  16841. this.store = createStore({
  16842. ...props,
  16843. controlled: run && src_default.number(stepIndex)
  16844. }), this.helpers = this.store.getHelpers();
  16845. let { addListener } = this.store;
  16846. log2({
  16847. title: "init",
  16848. data: [
  16849. { key: "props", value: this.props },
  16850. { key: "state", value: this.state }
  16851. ],
  16852. debug
  16853. }), addListener(this.syncState), getHelpers && getHelpers(this.helpers), this.state = this.store.getState();
  16854. }
  16855. componentDidMount() {
  16856. if (!canUseDOM2())
  16857. return;
  16858. let { debug, disableCloseOnEsc, run, steps } = this.props, { start } = this.store;
  16859. validateSteps(steps, debug) && run && start(), disableCloseOnEsc || document.body.addEventListener("keydown", this.handleKeyboard, { passive: !0 });
  16860. }
  16861. componentDidUpdate(previousProps, previousState) {
  16862. if (!canUseDOM2())
  16863. return;
  16864. 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);
  16865. if (stepsChanged && (validateSteps(steps, debug) ? setSteps(steps) : console.warn("Steps are not valid", steps)), changedProps("run") && (run ? start(stepIndex) : stop()), stepIndexChanged) {
  16866. let nextAction = src_default.number(previousStepIndex) && previousStepIndex < stepIndex ? ACTIONS.NEXT : ACTIONS.PREV;
  16867. action === ACTIONS.STOP && (nextAction = ACTIONS.START), [STATUS3.FINISHED, STATUS3.SKIPPED].includes(status) || update2({
  16868. action: action === ACTIONS.CLOSE ? ACTIONS.CLOSE : nextAction,
  16869. index: stepIndex,
  16870. lifecycle: LIFECYCLE.INIT
  16871. });
  16872. }
  16873. !controlled && status === STATUS3.RUNNING && index === 0 && !target && (this.store.update({ index: index + 1 }), this.callback({
  16874. ...this.state,
  16875. type: EVENTS.TARGET_NOT_FOUND,
  16876. step
  16877. }));
  16878. let callbackData = {
  16879. ...this.state,
  16880. index,
  16881. step
  16882. };
  16883. if (changed("action", [
  16884. ACTIONS.NEXT,
  16885. ACTIONS.PREV,
  16886. ACTIONS.SKIP,
  16887. ACTIONS.CLOSE
  16888. ]) && changed("status", STATUS3.PAUSED)) {
  16889. let previousStep = getMergedStep(this.props, steps[previousState.index]);
  16890. this.callback({
  16891. ...callbackData,
  16892. index: previousState.index,
  16893. lifecycle: LIFECYCLE.COMPLETE,
  16894. step: previousStep,
  16895. type: EVENTS.STEP_AFTER
  16896. });
  16897. }
  16898. if (changed("status", [STATUS3.FINISHED, STATUS3.SKIPPED])) {
  16899. let previousStep = getMergedStep(this.props, steps[previousState.index]);
  16900. controlled || this.callback({
  16901. ...callbackData,
  16902. index: previousState.index,
  16903. lifecycle: LIFECYCLE.COMPLETE,
  16904. step: previousStep,
  16905. type: EVENTS.STEP_AFTER
  16906. }), this.callback({
  16907. ...callbackData,
  16908. type: EVENTS.TOUR_END,
  16909. // Return the last step when the tour is finished
  16910. step: previousStep,
  16911. index: previousState.index
  16912. }), reset();
  16913. } else changedFrom("status", [STATUS3.IDLE, STATUS3.READY], STATUS3.RUNNING) ? this.callback({
  16914. ...callbackData,
  16915. type: EVENTS.TOUR_START
  16916. }) : (changed("status") || changed("action", ACTIONS.RESET)) && this.callback({
  16917. ...callbackData,
  16918. type: EVENTS.TOUR_STATUS
  16919. });
  16920. this.scrollToStep(previousState);
  16921. }
  16922. componentWillUnmount() {
  16923. let { disableCloseOnEsc } = this.props;
  16924. disableCloseOnEsc || document.body.removeEventListener("keydown", this.handleKeyboard);
  16925. }
  16926. scrollToStep(previousState) {
  16927. let { index, lifecycle, status } = this.state, {
  16928. debug,
  16929. disableScrollParentFix = !1,
  16930. scrollDuration,
  16931. scrollOffset = 20,
  16932. scrollToFirstStep = !1,
  16933. steps
  16934. } = this.props, step = getMergedStep(this.props, steps[index]), target = getElement(step.target), shouldScrollToStep = shouldScroll({
  16935. isFirstStep: index === 0,
  16936. lifecycle,
  16937. previousLifecycle: previousState.lifecycle,
  16938. scrollToFirstStep,
  16939. step,
  16940. target
  16941. });
  16942. if (status === STATUS3.RUNNING && shouldScrollToStep) {
  16943. let hasCustomScroll = hasCustomScrollParent(target, disableScrollParentFix), scrollParent2 = getScrollParent2(target, disableScrollParentFix), scrollY = Math.floor(getScrollTo(target, scrollOffset, disableScrollParentFix)) || 0;
  16944. log2({
  16945. title: "scrollToStep",
  16946. data: [
  16947. { key: "index", value: index },
  16948. { key: "lifecycle", value: lifecycle },
  16949. { key: "status", value: status }
  16950. ],
  16951. debug
  16952. });
  16953. let beaconPopper = this.store.getPopper("beacon"), tooltipPopper = this.store.getPopper("tooltip");
  16954. if (lifecycle === LIFECYCLE.BEACON && beaconPopper) {
  16955. let { offsets, placement } = beaconPopper;
  16956. !["bottom"].includes(placement) && !hasCustomScroll && (scrollY = Math.floor(offsets.popper.top - scrollOffset));
  16957. } else if (lifecycle === LIFECYCLE.TOOLTIP && tooltipPopper) {
  16958. let { flipped, offsets, placement } = tooltipPopper;
  16959. ["top", "right", "left"].includes(placement) && !flipped && !hasCustomScroll ? scrollY = Math.floor(offsets.popper.top - scrollOffset) : scrollY -= step.spotlightPadding;
  16960. }
  16961. scrollY = scrollY >= 0 ? scrollY : 0, status === STATUS3.RUNNING && scrollTo(scrollY, { element: scrollParent2, duration: scrollDuration }).then(
  16962. () => {
  16963. setTimeout(() => {
  16964. var _a2;
  16965. (_a2 = this.store.getPopper("tooltip")) == null || _a2.instance.update();
  16966. }, 10);
  16967. }
  16968. );
  16969. }
  16970. }
  16971. render() {
  16972. if (!canUseDOM2())
  16973. return null;
  16974. let { index, lifecycle, status } = this.state, {
  16975. continuous = !1,
  16976. debug = !1,
  16977. nonce,
  16978. scrollToFirstStep = !1,
  16979. steps
  16980. } = this.props, isRunning = status === STATUS3.RUNNING, content = {};
  16981. if (isRunning && steps[index]) {
  16982. let step = getMergedStep(this.props, steps[index]);
  16983. content.step = createElement(
  16984. JoyrideStep,
  16985. {
  16986. ...this.state,
  16987. callback: this.callback,
  16988. continuous,
  16989. debug,
  16990. helpers: this.helpers,
  16991. nonce,
  16992. shouldScroll: !step.disableScrolling && (index !== 0 || scrollToFirstStep),
  16993. step,
  16994. store: this.store
  16995. }
  16996. ), content.overlay = createElement(JoyridePortal, { id: "react-joyride-portal" }, createElement(
  16997. JoyrideOverlay,
  16998. {
  16999. ...step,
  17000. continuous,
  17001. debug,
  17002. lifecycle,
  17003. onClickOverlay: this.handleClickOverlay
  17004. }
  17005. ));
  17006. }
  17007. return createElement("div", { className: "react-joyride" }, content.step, content.overlay);
  17008. }
  17009. };
  17010. __publicField(Joyride, "defaultProps", defaultProps);
  17011. var components_default2 = Joyride;
  17012. // src/manager/components/TourGuide/HighlightElement.tsx
  17013. init_react();
  17014. var HIGHLIGHT_KEYFRAMES_ID = "storybook-highlight-element-keyframes", keyframes2 = `
  17015. @keyframes sb-highlight-pulsate {
  17016. 0% {
  17017. 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);
  17018. }
  17019. 50% {
  17020. 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);
  17021. }
  17022. 100% {
  17023. 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);
  17024. }
  17025. }
  17026. `, createOverlay = (element) => {
  17027. let overlay = document.createElement("div");
  17028. 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(() => {
  17029. updateOverlayStyles(element, overlay), element.scrollIntoView({ behavior: "smooth", block: "center" });
  17030. }), overlay;
  17031. }, updateOverlayStyles = (element, overlay) => {
  17032. let rect = element.getBoundingClientRect(), computedStyle = window.getComputedStyle(element);
  17033. 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;
  17034. }, findScrollableAncestors = (element) => {
  17035. let scrollableAncestors = [window], parent = element.parentElement;
  17036. for (; parent; ) {
  17037. let style = window.getComputedStyle(parent);
  17038. (style.overflow === "auto" || style.overflow === "scroll" || style.overflowX === "auto" || style.overflowX === "scroll" || style.overflowY === "auto" || style.overflowY === "scroll") && scrollableAncestors.push(parent), parent = parent.parentElement;
  17039. }
  17040. return scrollableAncestors;
  17041. };
  17042. function HighlightElement({
  17043. targetSelector,
  17044. pulsating = !1
  17045. }) {
  17046. return useEffect(() => {
  17047. let element = document.querySelector(targetSelector);
  17048. if (!element || !element.parentElement)
  17049. return;
  17050. let overlay = document.body.appendChild(createOverlay(element));
  17051. if (pulsating) {
  17052. if (!document.getElementById(HIGHLIGHT_KEYFRAMES_ID)) {
  17053. let style = document.createElement("style");
  17054. style.id = HIGHLIGHT_KEYFRAMES_ID, style.innerHTML = keyframes2, document.head.appendChild(style);
  17055. }
  17056. overlay.style.animation = "sb-highlight-pulsate 3s infinite", overlay.style.transformOrigin = "center", overlay.style.animationTimingFunction = "ease-in-out";
  17057. } else
  17058. overlay.style.boxShadow = "rgba(2,156,253,1) 0 0 2px 1px";
  17059. let scrollTimeout = null, handleScroll = () => {
  17060. overlay.parentElement && overlay.remove(), scrollTimeout !== null && clearTimeout(scrollTimeout), scrollTimeout = window.setTimeout(() => {
  17061. element && (updateOverlayStyles(element, overlay), overlay.style.opacity = "0", document.body.appendChild(overlay), requestAnimationFrame(() => overlay.style.opacity = "1"));
  17062. }, 150);
  17063. }, resizeObserver = new ResizeObserver(
  17064. () => overlay.parentElement && updateOverlayStyles(element, overlay)
  17065. );
  17066. resizeObserver.observe(window.document.body), resizeObserver.observe(element);
  17067. let scrollContainers = findScrollableAncestors(element);
  17068. return scrollContainers.forEach(
  17069. (el) => el.addEventListener("scroll", handleScroll, { passive: !0 })
  17070. ), scrollContainers.filter((el) => el !== window).forEach((el) => resizeObserver.observe(el)), () => {
  17071. scrollTimeout !== null && clearTimeout(scrollTimeout), overlay.parentElement && overlay.remove(), scrollContainers.forEach((el) => el.removeEventListener("scroll", handleScroll)), resizeObserver.disconnect();
  17072. };
  17073. }, [targetSelector, pulsating]), null;
  17074. }
  17075. // src/manager/components/TourGuide/TourTooltip.tsx
  17076. init_react();
  17077. var ONBOARDING_ARROW_STYLE_ID = "storybook-onboarding-arrow-style", TooltipBody = styled.div`
  17078. padding: 15px;
  17079. border-radius: 5px;
  17080. `, Wrapper4 = styled.div`
  17081. display: flex;
  17082. flex-direction: column;
  17083. align-items: flex-start;
  17084. `, TooltipHeader = styled.div`
  17085. display: flex;
  17086. align-items: center;
  17087. align-self: stretch;
  17088. justify-content: space-between;
  17089. margin: -5px -5px 5px 0;
  17090. `, TooltipTitle = styled.div`
  17091. line-height: 18px;
  17092. font-weight: 700;
  17093. font-size: 14px;
  17094. margin: 5px 5px 5px 0;
  17095. `, TooltipContent = styled.p`
  17096. font-size: 14px;
  17097. line-height: 18px;
  17098. text-align: start;
  17099. text-wrap: balance;
  17100. margin: 0;
  17101. margin-top: 5px;
  17102. `, TooltipFooter = styled.div`
  17103. display: flex;
  17104. align-items: center;
  17105. justify-content: space-between;
  17106. margin-top: 15px;
  17107. `, Count = styled.span`
  17108. font-size: 13px;
  17109. `, NextButton = styled(Button)(({ theme }) => ({
  17110. background: theme.color.lightest,
  17111. border: "none",
  17112. boxShadow: "none",
  17113. color: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary),
  17114. "&:hover, &:focus": {
  17115. background: curriedTransparentize$1(0.1, theme.color.lightest),
  17116. color: theme.base === "light" ? curriedLighten$1(0.1, theme.color.secondary) : curriedDarken$1(0.3, theme.color.secondary)
  17117. }
  17118. })), TourTooltip = ({
  17119. index,
  17120. size,
  17121. step,
  17122. closeProps,
  17123. primaryProps,
  17124. tooltipProps
  17125. }) => (useEffect(() => {
  17126. let style = document.createElement("style");
  17127. return style.id = ONBOARDING_ARROW_STYLE_ID, style.innerHTML = `
  17128. .__floater__arrow { container-type: size; }
  17129. .__floater__arrow span { background: ${color.secondary}; }
  17130. .__floater__arrow span::before, .__floater__arrow span::after {
  17131. content: '';
  17132. display: block;
  17133. width: 2px;
  17134. height: 2px;
  17135. background: ${color.secondary};
  17136. box-shadow: 0 0 0 2px ${color.secondary};
  17137. border-radius: 3px;
  17138. flex: 0 0 2px;
  17139. }
  17140. @container (min-height: 1px) {
  17141. .__floater__arrow span { flex-direction: column; }
  17142. }
  17143. `, document.head.appendChild(style), () => document.getElementById(ONBOARDING_ARROW_STYLE_ID)?.remove();
  17144. }, []), 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(
  17145. Button,
  17146. {
  17147. ...closeProps,
  17148. onClick: closeProps.onClick,
  17149. variant: "solid",
  17150. padding: "small",
  17151. ariaLabel: "Close"
  17152. },
  17153. react_default.createElement(CloseAltIcon, null)
  17154. )), 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"))));
  17155. // src/manager/components/TourGuide/TourGuide.tsx
  17156. var TourGuide = ({
  17157. step,
  17158. steps,
  17159. onNext,
  17160. onComplete,
  17161. onDismiss
  17162. }) => {
  17163. let [stepIndex, setStepIndex] = useState(step ? null : 0), theme = useTheme(), timeoutRef = useRef(void 0), updateStepIndex = useCallback((index) => {
  17164. clearTimeout(timeoutRef.current), setStepIndex((current) => index === -1 ? null : current === null || current === index ? index : (timeoutRef.current = setTimeout(setStepIndex, 300, index), null));
  17165. }, []);
  17166. useEffect(
  17167. () => step ? updateStepIndex(steps.findIndex(({ key }) => key === step)) : void 0,
  17168. [step, steps, updateStepIndex]
  17169. );
  17170. let mappedSteps = useMemo(() => steps.map((step2, index) => {
  17171. let next = () => updateStepIndex(index + 1);
  17172. return {
  17173. disableBeacon: !0,
  17174. disableOverlay: !0,
  17175. spotlightClicks: !0,
  17176. offset: 0,
  17177. ...step2,
  17178. content: react_default.createElement(react_default.Fragment, null, step2.content, step2.highlight && react_default.createElement(HighlightElement, { targetSelector: step2.highlight, pulsating: !0 })),
  17179. onNext: step2.onNext ? () => step2.onNext?.({ next }) : onNext && (() => onNext?.({ next }))
  17180. };
  17181. }), [steps, onNext, updateStepIndex]), callback = useCallback(
  17182. (data) => {
  17183. 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?.();
  17184. },
  17185. [onComplete, onDismiss, updateStepIndex]
  17186. );
  17187. return stepIndex === null ? null : react_default.createElement(
  17188. components_default2,
  17189. {
  17190. continuous: !0,
  17191. steps: mappedSteps,
  17192. stepIndex,
  17193. spotlightPadding: 0,
  17194. disableCloseOnEsc: !0,
  17195. disableOverlayClose: !0,
  17196. disableScrolling: !0,
  17197. callback,
  17198. tooltipComponent: TourTooltip,
  17199. floaterProps: {
  17200. disableAnimation: !0,
  17201. styles: {
  17202. arrow: {
  17203. length: 20,
  17204. spread: 2
  17205. },
  17206. floater: {
  17207. 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)"
  17208. }
  17209. }
  17210. },
  17211. styles: {
  17212. overlay: {
  17213. mixBlendMode: "unset",
  17214. backgroundColor: steps[stepIndex]?.target === "body" ? "rgba(27, 28, 29, 0.2)" : "none"
  17215. },
  17216. spotlight: {
  17217. backgroundColor: "none",
  17218. border: `solid 2px ${theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary)}`,
  17219. boxShadow: "0px 0px 0px 9999px rgba(27, 28, 29, 0.2)"
  17220. },
  17221. tooltip: {
  17222. width: 280,
  17223. color: theme.color.lightest,
  17224. background: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary)
  17225. },
  17226. options: {
  17227. zIndex: 9998,
  17228. primaryColor: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary),
  17229. arrowColor: theme.base === "light" ? theme.color.secondary : curriedDarken$1(0.18, theme.color.secondary)
  17230. }
  17231. }
  17232. }
  17233. );
  17234. }, root = null;
  17235. TourGuide.render = (props) => {
  17236. let container = document.getElementById("storybook-tour");
  17237. container || (container = document.createElement("div"), container.id = "storybook-tour", document.body.appendChild(container)), root = root ?? createRoot(container), root.render(
  17238. props ? react_default.createElement(ThemeProvider, { theme: convert(themes.light) }, react_default.createElement(
  17239. TourGuide,
  17240. {
  17241. ...props,
  17242. onComplete: () => {
  17243. props.onComplete?.(), root?.render(null), root = null;
  17244. },
  17245. onDismiss: () => {
  17246. props.onDismiss?.(), root?.render(null), root = null;
  17247. }
  17248. }
  17249. )) : null
  17250. );
  17251. };
  17252. // src/manager/hooks/useLocation.ts
  17253. init_react();
  17254. var LocationMonitor = {
  17255. _currentHref: globalThis.window?.location.href ?? "",
  17256. _intervalId: null,
  17257. _listeners: /* @__PURE__ */ new Set(),
  17258. start() {
  17259. this._intervalId === null && (this._intervalId = setInterval(() => {
  17260. let newLocation = globalThis.window.location;
  17261. newLocation.href !== this._currentHref && (this._currentHref = newLocation.href, this._listeners.forEach((listener) => listener(newLocation)));
  17262. }, 100));
  17263. },
  17264. stop() {
  17265. this._intervalId !== null && (clearInterval(this._intervalId), this._intervalId = null);
  17266. },
  17267. subscribe(...listeners) {
  17268. return listeners.forEach((listener) => this._listeners.add(listener)), this.start(), () => {
  17269. listeners.forEach((listener) => this._listeners.delete(listener)), this._listeners.size === 0 && this.stop();
  17270. };
  17271. }
  17272. }, useLocationHash = () => {
  17273. let [hash, setHash] = useState(globalThis.window?.location.hash ?? "");
  17274. return useEffect(() => LocationMonitor.subscribe((location2) => setHash(location2.hash)), []), hash.slice(1);
  17275. };
  17276. // src/shared/utils/ai-prompts.ts
  17277. function getAiSetupPrompt(executor = "npx storybook") {
  17278. return `Run \`${executor} ai setup\` and follow its instructions precisely.`;
  17279. }
  17280. // src/shared/checklist-store/checklistData.tsx
  17281. var CodeWrapper = styled.div(({ theme }) => ({
  17282. alignSelf: "stretch",
  17283. background: theme.background.content,
  17284. borderRadius: theme.appBorderRadius,
  17285. margin: "5px 0",
  17286. padding: 10,
  17287. fontSize: theme.typography.size.s1,
  17288. ".linenumber": {
  17289. opacity: 0.5
  17290. }
  17291. })), 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 }) => {
  17292. let check = () => condition(
  17293. Object.entries(api.getIndex()?.entries || {}).reduce(
  17294. (acc, [id, entry]) => isExample(entry.id) ? acc : Object.assign(acc, { [id]: entry }),
  17295. {}
  17296. )
  17297. );
  17298. if (check())
  17299. done();
  17300. else
  17301. return api.once(PREVIEW_INITIALIZED, () => check() && done()), api.on(STORY_INDEX_INVALIDATED, () => check() && done());
  17302. }, checklistData = {
  17303. sections: [
  17304. {
  17305. id: "basics",
  17306. title: "Storybook basics",
  17307. items: [
  17308. {
  17309. id: "aiSetup",
  17310. label: "Set up with AI",
  17311. icon: WandIcon,
  17312. available: ({ storeState }) => !!storeState.aiOptIn && storeState.items.aiSetup?.status !== "done",
  17313. criteria: "ai setup command has not been run yet",
  17314. showOnGuidePage: !1,
  17315. action: {
  17316. label: "Copy prompt",
  17317. copyContent: getAiSetupPrompt(),
  17318. onClick: ({ api }) => {
  17319. api.emit(AI_PROMPT_NUDGE, { id: "setup", origin: "onboarding-checklist-side" });
  17320. }
  17321. }
  17322. },
  17323. {
  17324. id: "guidedTour",
  17325. label: "Take the guided tour",
  17326. available: ({ index }) => !!index && "example-button--primary" in index && !!globalThis?.FEATURES?.controls && addons.experimental_getRegisteredAddons().includes(ADDON_ID3),
  17327. criteria: "Guided tour is completed",
  17328. subscribe: ({ api, accept }) => api.on(ADDON_ONBOARDING_CHANNEL, ({ step, type }) => {
  17329. type !== "dismiss" && ["6:IntentSurvey", "7:FinishedOnboarding"].includes(step) && accept();
  17330. }),
  17331. action: {
  17332. label: "Start",
  17333. onClick: ({ api }) => {
  17334. api.toggleNav(!0);
  17335. let path = api.getUrlState().path || "";
  17336. path.startsWith("/story/") ? document.location.href = `/?path=${path}&onboarding=true` : document.location.href = "/?onboarding=true";
  17337. }
  17338. }
  17339. },
  17340. {
  17341. id: "onboardingSurvey",
  17342. label: "Complete the onboarding survey",
  17343. available: () => addons.experimental_getRegisteredAddons().includes(ADDON_ID3),
  17344. afterCompletion: "immutable",
  17345. criteria: "Onboarding survey is completed",
  17346. subscribe: ({ api, accept }) => api.on(ADDON_ONBOARDING_CHANNEL, ({ type }) => type === "survey" && accept()),
  17347. action: {
  17348. label: "Open",
  17349. onClick: ({ api }) => {
  17350. let path = api.getUrlState().path || "";
  17351. document.location.href = `/?path=${path}&onboarding=survey`;
  17352. }
  17353. }
  17354. },
  17355. {
  17356. id: "renderComponent",
  17357. label: "Render your first component",
  17358. criteria: "A story finished rendering successfully",
  17359. subscribe: ({ api, done }) => api.on(
  17360. STORY_FINISHED,
  17361. ({ storyId, status }) => status === "success" && !isExample(storyId) && done()
  17362. ),
  17363. 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(
  17364. Link,
  17365. {
  17366. href: api.getDocsUrl({
  17367. subpath: "writing-stories/decorators",
  17368. renderer: !0,
  17369. ref: "guide"
  17370. }),
  17371. target: "_blank"
  17372. },
  17373. "setting up surrounding context in decorators"
  17374. ), " ", "or", " ", react_default.createElement(
  17375. Link,
  17376. {
  17377. href: api.getDocsUrl({
  17378. subpath: "configure/styling-and-css",
  17379. renderer: !0,
  17380. ref: "guide"
  17381. }),
  17382. target: "_blank"
  17383. },
  17384. "applying global styles"
  17385. ), ". 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
  17386. // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
  17387. import type { Meta, StoryObj } from '@storybook/your-framework';
  17388. import { Button } from './Button';
  17389. const meta = {
  17390. // \u{1F447} The component you're working on
  17391. component: Button,
  17392. } satisfies Meta<typeof Button>;
  17393. export default meta;
  17394. // \u{1F447} Type helper to reduce boilerplate
  17395. type Story = StoryObj<typeof meta>;
  17396. // \u{1F447} A story named Primary that renders \`<Button primary label="Button" />\`
  17397. export const Primary: Story = {
  17398. args: {
  17399. primary: true,
  17400. label: 'Button',
  17401. },
  17402. };`), react_default.createElement("p", null, react_default.createElement(
  17403. Link,
  17404. {
  17405. href: api.getDocsUrl({
  17406. subpath: "writing-stories",
  17407. renderer: !0,
  17408. ref: "guide"
  17409. }),
  17410. target: "_blank",
  17411. withArrow: !0
  17412. },
  17413. "Learn more about stories"
  17414. )))
  17415. },
  17416. {
  17417. id: "moreComponents",
  17418. label: "Add 5 components",
  17419. 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(
  17420. "img",
  17421. {
  17422. src: api.getDocsUrl({
  17423. asset: "onboarding/sidebar-components.png",
  17424. ref: "guide"
  17425. }),
  17426. alt: "Components in the sidebar"
  17427. }
  17428. ), react_default.createElement("p", null, react_default.createElement(
  17429. Link,
  17430. {
  17431. href: api.getDocsUrl({
  17432. subpath: "get-started/whats-a-story#create-a-new-story",
  17433. renderer: !0,
  17434. ref: "guide"
  17435. }),
  17436. target: "_blank",
  17437. withArrow: !0
  17438. },
  17439. "Learn how to add components without writing any code"
  17440. ))),
  17441. criteria: "At least 5 components exist in the index",
  17442. subscribe: subscribeToIndex((entries) => {
  17443. let stories = Object.values(entries).filter(
  17444. (entry) => entry.type === "story"
  17445. );
  17446. return new Set(stories.map(({ title: title2 }) => title2)).size >= 5;
  17447. })
  17448. },
  17449. {
  17450. id: "moreStories",
  17451. label: "Add 20 stories",
  17452. 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(
  17453. "img",
  17454. {
  17455. src: api.getDocsUrl({
  17456. asset: "onboarding/sidebar-many-stories.png",
  17457. ref: "guide"
  17458. }),
  17459. alt: "Stories in the sidebar"
  17460. }
  17461. ), react_default.createElement("p", null, react_default.createElement(
  17462. Link,
  17463. {
  17464. href: api.getDocsUrl({
  17465. subpath: "essentials/controls#creating-and-editing-stories-from-controls",
  17466. renderer: !0,
  17467. ref: "guide"
  17468. }),
  17469. target: "_blank",
  17470. withArrow: !0
  17471. },
  17472. "Learn how to use Controls to add stories without writing any code"
  17473. ))),
  17474. criteria: "At least 20 stories exist in the index",
  17475. subscribe: subscribeToIndex((entries) => Object.values(entries).filter(
  17476. (entry) => entry.type === "story"
  17477. ).length >= 20)
  17478. },
  17479. {
  17480. id: "whatsNewStorybook10",
  17481. label: "See what's new",
  17482. criteria: "What's New page is opened",
  17483. action: {
  17484. label: "Go",
  17485. onClick: ({ api }) => api.navigate("/settings/whats-new")
  17486. },
  17487. subscribe: ({ accept }) => LocationMonitor.subscribe((l3) => l3.search.endsWith("/settings/whats-new") && accept())
  17488. }
  17489. ]
  17490. },
  17491. {
  17492. id: "development",
  17493. title: "Development",
  17494. items: [
  17495. {
  17496. id: "controls",
  17497. label: "Change a story with Controls",
  17498. available: () => !!globalThis?.FEATURES?.controls,
  17499. criteria: "Story args are updated",
  17500. subscribe: ({ api, done }) => api.on(STORY_ARGS_UPDATED, done),
  17501. 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(
  17502. "img",
  17503. {
  17504. src: api.getDocsUrl({
  17505. asset: "api/doc-block-controls.png",
  17506. ref: "guide"
  17507. }),
  17508. alt: "Screenshot of Controls block"
  17509. }
  17510. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17511. Link,
  17512. {
  17513. href: api.getDocsUrl({
  17514. subpath: "essentials/controls",
  17515. renderer: !0,
  17516. ref: "guide"
  17517. }),
  17518. target: "_blank"
  17519. },
  17520. "Controls documentation"
  17521. ), " ", "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")))
  17522. },
  17523. {
  17524. id: "viewports",
  17525. label: "Check responsiveness with Viewports",
  17526. available: () => !!globalThis?.FEATURES?.viewport,
  17527. criteria: "Viewport global is updated",
  17528. subscribe: ({ api, done }) => api.on(UPDATE_GLOBALS, ({ globals }) => globals?.viewport && done()),
  17529. 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(
  17530. "img",
  17531. {
  17532. src: api.getDocsUrl({
  17533. asset: "onboarding/viewports-menu.png",
  17534. ref: "guide"
  17535. }),
  17536. alt: "Screenshot of Viewports menu"
  17537. }
  17538. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17539. Link,
  17540. {
  17541. href: api.getDocsUrl({
  17542. subpath: "essentials/viewport",
  17543. renderer: !0,
  17544. ref: "guide"
  17545. }),
  17546. target: "_blank"
  17547. },
  17548. "Viewports documentation"
  17549. ), " ", "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")))
  17550. },
  17551. {
  17552. id: "organizeStories",
  17553. label: "Group your components",
  17554. criteria: "A root node exists in the index",
  17555. subscribe: subscribeToIndex(
  17556. (entries) => Object.values(entries).some(({ title: title2 }) => title2.includes("/"))
  17557. ),
  17558. 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
  17559. export default {
  17560. component: Button,
  17561. - title: 'Button', // You may not have this
  17562. + title: 'Atoms/Button',
  17563. }`), react_default.createElement("p", null, "Which would look like:"), react_default.createElement(
  17564. "img",
  17565. {
  17566. src: api.getDocsUrl({
  17567. asset: "onboarding/sidebar-with-groups.png",
  17568. ref: "guide"
  17569. }),
  17570. alt: "Grouped components in the sidebar"
  17571. }
  17572. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17573. Link,
  17574. {
  17575. href: api.getDocsUrl({
  17576. subpath: "writing-stories/naming-components-and-hierarchy",
  17577. renderer: !0,
  17578. ref: "guide"
  17579. }),
  17580. target: "_blank"
  17581. },
  17582. "story organization documentation"
  17583. ), " ", "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")))
  17584. }
  17585. ]
  17586. },
  17587. {
  17588. id: "share",
  17589. title: "Share",
  17590. items: [
  17591. {
  17592. id: "shareStorybook",
  17593. label: "Share your Storybook for feedback",
  17594. available: () => addons.experimental_getRegisteredAddons(Addon_TypesEnum.TOOLEXTRA).includes("chromaui/addon-visual-tests/share-tool"),
  17595. criteria: "User has shared their Storybook",
  17596. subscribe: ({ api, done }) => {
  17597. let SHARE_PROGRESS_KEY = "chromaui/addon-visual-tests/shareProgress";
  17598. return api.on("experimental_useSharedState_setValue", (key, value) => {
  17599. key === SHARE_PROGRESS_KEY && value?.status === "complete" && done();
  17600. });
  17601. },
  17602. action: {
  17603. label: "Share",
  17604. onClick: () => document.getElementById("chromatic-share-button")?.click()
  17605. },
  17606. 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")))
  17607. },
  17608. {
  17609. id: "publishStorybook",
  17610. label: "Publish your Storybook for feedback",
  17611. available: () => !addons.experimental_getRegisteredAddons(Addon_TypesEnum.TOOLEXTRA).includes("chromaui/addon-visual-tests/share-tool"),
  17612. criteria: "User has published their Storybook",
  17613. 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(
  17614. Link,
  17615. {
  17616. href: api.getDocsUrl({
  17617. subpath: "sharing/publish-storybook",
  17618. renderer: !0,
  17619. ref: "guide"
  17620. }),
  17621. target: "_blank",
  17622. withArrow: !0
  17623. },
  17624. "publishing documentation"
  17625. )))
  17626. }
  17627. ]
  17628. },
  17629. {
  17630. id: "testing",
  17631. title: "Testing",
  17632. items: [
  17633. {
  17634. id: "installVitest",
  17635. label: "Install Vitest addon",
  17636. afterCompletion: "unavailable",
  17637. available: () => !!globalThis.STORYBOOK_FRAMEWORK && SUPPORTED_FRAMEWORKS.includes(globalThis.STORYBOOK_FRAMEWORK),
  17638. criteria: "@storybook/addon-vitest registered in .storybook/main.js|ts",
  17639. subscribe: ({ done }) => {
  17640. addons.experimental_getRegisteredAddons().includes(ADDON_ID5) && done();
  17641. },
  17642. 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(
  17643. "img",
  17644. {
  17645. src: api.getDocsUrl({
  17646. asset: "writing-tests/testing-ui-overview.png",
  17647. ref: "guide"
  17648. }),
  17649. alt: "Storybook app with story status indicators, testing widget, and addon panel annotated"
  17650. }
  17651. ), react_default.createElement("p", null, react_default.createElement(
  17652. Link,
  17653. {
  17654. href: api.getDocsUrl({
  17655. subpath: "writing-tests/integrations/vitest-addon",
  17656. renderer: !0,
  17657. ref: "guide"
  17658. }),
  17659. target: "_blank",
  17660. withArrow: !0
  17661. },
  17662. "Learn more about the Vitest addon"
  17663. )))
  17664. },
  17665. {
  17666. id: "runTests",
  17667. after: ["installVitest"],
  17668. label: "Test your components",
  17669. criteria: "Component tests are run from the test widget in the sidebar",
  17670. subscribe: ({ done }) => internal_universalTestProviderStore.onStateChange((state) => {
  17671. state["storybook/test"] === "test-provider-state:running" && (TourGuide.render(null), done());
  17672. }),
  17673. action: {
  17674. label: "Start",
  17675. onClick: ({ api }) => {
  17676. api.toggleNav(!0), TourGuide.render({
  17677. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  17678. // @ts-ignore Circular reference in Step type
  17679. steps: [
  17680. {
  17681. title: "Testing widget",
  17682. content: "Run tests right from your Storybook sidebar using the testing widget.",
  17683. placement: "right-end",
  17684. target: "#storybook-testing-module",
  17685. highlight: "#storybook-testing-module",
  17686. onNext: ({ next }) => {
  17687. let toggle = document.getElementById("testing-module-collapse-toggle");
  17688. toggle?.getAttribute("aria-label") === "Expand testing module" ? (toggle.click(), setTimeout(next, 300)) : next();
  17689. }
  17690. },
  17691. {
  17692. title: "Start a test run",
  17693. content: "Start a test run at the click of a button using Vitest.",
  17694. placement: "right",
  17695. target: '[data-module-id="storybook/test/test-provider"] button[aria-label="Start test run"]',
  17696. highlight: '[data-module-id="storybook/test/test-provider"] button[aria-label="Start test run"]',
  17697. hideNextButton: !0
  17698. }
  17699. ]
  17700. });
  17701. }
  17702. },
  17703. 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(
  17704. "img",
  17705. {
  17706. src: api.getDocsUrl({
  17707. asset: "onboarding/test-widget-with-failures.png",
  17708. ref: "guide"
  17709. }),
  17710. alt: "Test widget showing test failures"
  17711. }
  17712. ), 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(
  17713. "img",
  17714. {
  17715. src: api.getDocsUrl({
  17716. asset: "writing-tests/context-menu.png",
  17717. ref: "guide"
  17718. }),
  17719. alt: "Screenshot of story sidebar item with open menu"
  17720. }
  17721. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17722. Link,
  17723. {
  17724. href: api.getDocsUrl({
  17725. subpath: "writing-tests#component-tests",
  17726. renderer: !0,
  17727. ref: "guide"
  17728. }),
  17729. target: "_blank"
  17730. },
  17731. "component testing documentation"
  17732. ), " ", "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")))
  17733. },
  17734. {
  17735. id: "writeInteractions",
  17736. label: "Test functionality with interactions",
  17737. available: () => !!globalThis?.FEATURES?.interactions,
  17738. criteria: "At least one story with a play or test function",
  17739. subscribe: subscribeToIndex(
  17740. (entries) => Object.values(entries).some(
  17741. (entry) => entry.tags?.includes(Tag.PLAY_FN) || entry.tags?.includes(Tag.TEST_FN)
  17742. )
  17743. ),
  17744. 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
  17745. // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
  17746. import type { Meta, StoryObj } from '@storybook/your-framework';
  17747. import { expect, fn } from 'storybook/test';
  17748. import { Button } from './Button';
  17749. const meta = {
  17750. component: Button,
  17751. args: {
  17752. // \u{1F447} Provide a mock function to spy on
  17753. onClick: fn(),
  17754. },
  17755. } satisfies Meta<typeof Button>;
  17756. export default meta;
  17757. type Story = StoryObj<typeof meta>;
  17758. export const Disabled: Story = {
  17759. args: {
  17760. disabled: true,
  17761. label: 'Button',
  17762. },
  17763. play: async function({ args, canvas, userEvent }) {
  17764. const button = canvas.getByRole('button', { name: /button/i });
  17765. // \u{1F447} Simulate behavior
  17766. await userEvent.click(button);
  17767. // \u{1F447} Make assertions
  17768. await expect(button).toHaveAttribute('aria-disabled', 'true');
  17769. await expect(args.onClick).not.toHaveBeenCalled();
  17770. }
  17771. };`), 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(
  17772. "img",
  17773. {
  17774. src: api.getDocsUrl({
  17775. asset: "writing-tests/interaction-test-pass.png",
  17776. ref: "guide"
  17777. }),
  17778. alt: "Storybook with a LoginForm component and passing interactions in the Interactions panel"
  17779. }
  17780. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17781. Link,
  17782. {
  17783. href: api.getDocsUrl({
  17784. subpath: "writing-tests/interaction-testing",
  17785. renderer: !0,
  17786. ref: "guide"
  17787. }),
  17788. target: "_blank"
  17789. },
  17790. "interaction testing documentation"
  17791. ), " ", "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")))
  17792. },
  17793. {
  17794. id: "installA11y",
  17795. label: "Install Accessibility addon",
  17796. afterCompletion: "unavailable",
  17797. criteria: "@storybook/addon-a11y registered in .storybook/main.js|ts",
  17798. subscribe: ({ done }) => {
  17799. addons.experimental_getRegisteredAddons().includes(ADDON_ID2) && done();
  17800. },
  17801. 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(
  17802. Link,
  17803. {
  17804. href: api.getDocsUrl({
  17805. subpath: "writing-tests/accessibility-testing",
  17806. renderer: !0,
  17807. ref: "guide"
  17808. }),
  17809. target: "_blank",
  17810. withArrow: !0
  17811. },
  17812. "Learn more about the Accessibility addon"
  17813. )))
  17814. },
  17815. {
  17816. id: "accessibilityTests",
  17817. after: ["installA11y"],
  17818. label: "Run accessibility tests",
  17819. criteria: "Accessibility tests are run from the test widget in the sidebar",
  17820. subscribe: ({ api, done }) => api.on(
  17821. STORYBOOK_ADDON_TEST_CHANNEL,
  17822. ({ type, payload }) => type === "test-run-completed" && payload.config.a11y && done()
  17823. ),
  17824. 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(
  17825. "img",
  17826. {
  17827. src: api.getDocsUrl({
  17828. asset: "writing-tests/test-widget-a11y-enabled.png",
  17829. ref: "guide"
  17830. }),
  17831. alt: "Testing widget with accessibility activated"
  17832. }
  17833. ), react_default.createElement("p", null, "If there are any failures, you can use the Accessibility panel to debug any violations."), react_default.createElement(
  17834. "img",
  17835. {
  17836. src: api.getDocsUrl({
  17837. asset: "writing-tests/addon-a11y-debug-violations.png",
  17838. ref: "guide"
  17839. }),
  17840. alt: "Storybook app with accessibility panel open, showing violations and an interactive popover on the violating elements in the preview"
  17841. }
  17842. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17843. Link,
  17844. {
  17845. href: api.getDocsUrl({
  17846. subpath: "writing-tests/accessibility-testing",
  17847. renderer: !0,
  17848. ref: "guide"
  17849. }),
  17850. target: "_blank"
  17851. },
  17852. "accessibility testing documentation"
  17853. ), " ", "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")))
  17854. },
  17855. {
  17856. id: "installChromatic",
  17857. label: "Install Visual Tests addon",
  17858. afterCompletion: "unavailable",
  17859. available: () => !0,
  17860. // TODO check for compatibility with the project (not React Native)
  17861. criteria: "@chromatic-com/storybook registered in .storybook/main.js|ts",
  17862. subscribe: ({ done }) => {
  17863. addons.experimental_getRegisteredAddons().includes("chromaui/addon-visual-tests") && done();
  17864. },
  17865. 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(
  17866. Link,
  17867. {
  17868. href: api.getDocsUrl({
  17869. subpath: "writing-tests/visual-testing",
  17870. renderer: !0,
  17871. ref: "guide"
  17872. }),
  17873. target: "_blank",
  17874. withArrow: !0
  17875. },
  17876. "Learn more about the Visual Tests addon"
  17877. )))
  17878. },
  17879. {
  17880. id: "visualTests",
  17881. after: ["installChromatic"],
  17882. label: "Run visual tests",
  17883. criteria: "Visual tests are run from the test widget in the sidebar or the Visual Tests panel",
  17884. subscribe: ({ api, done }) => api.on("chromaui/addon-visual-tests/startBuild", done),
  17885. 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(
  17886. "img",
  17887. {
  17888. src: api.getDocsUrl({
  17889. asset: "writing-tests/test-widget-expanded-with-vta.png",
  17890. ref: "guide"
  17891. }),
  17892. alt: "Expanded testing widget, showing the Visual tests section"
  17893. }
  17894. ), 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(
  17895. "img",
  17896. {
  17897. src: api.getDocsUrl({
  17898. asset: "writing-tests/vta-run-from-panel.png",
  17899. ref: "guide"
  17900. }),
  17901. alt: "Visual tests addon panel showing a diff from the baseline"
  17902. }
  17903. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17904. Link,
  17905. {
  17906. href: api.getDocsUrl({
  17907. subpath: "writing-tests/visual-testing",
  17908. renderer: !0,
  17909. ref: "guide"
  17910. }),
  17911. target: "_blank"
  17912. },
  17913. "visual testing documentation"
  17914. ), " ", "to learn:"), react_default.createElement("ul", null, react_default.createElement("li", null, "How to automate your visual tests in CI")))
  17915. },
  17916. {
  17917. id: "coverage",
  17918. after: ["installVitest"],
  17919. label: "Generate a coverage report",
  17920. criteria: "Generate a coverage report",
  17921. subscribe: ({ api, done }) => api.on(
  17922. STORYBOOK_ADDON_TEST_CHANNEL,
  17923. ({ type, payload }) => type === "test-run-completed" && payload.config.coverage && done()
  17924. ),
  17925. 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(
  17926. "img",
  17927. {
  17928. src: api.getDocsUrl({
  17929. asset: "writing-tests/test-widget-coverage-summary.png",
  17930. ref: "guide"
  17931. }),
  17932. alt: "Test widget with coverage summary"
  17933. }
  17934. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17935. Link,
  17936. {
  17937. href: api.getDocsUrl({
  17938. subpath: "writing-tests/test-coverage",
  17939. renderer: !0,
  17940. ref: "guide"
  17941. }),
  17942. target: "_blank"
  17943. },
  17944. "test coverage documentation"
  17945. ), " ", "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")))
  17946. },
  17947. {
  17948. id: "ciTests",
  17949. label: "Automate tests in CI",
  17950. criteria: "Have a CI workflow that runs component tests, either with Vitest or Chromatic",
  17951. 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(
  17952. "img",
  17953. {
  17954. src: api.getDocsUrl({
  17955. asset: "writing-tests/test-ci-workflow-pr-status-checks.png",
  17956. ref: "guide"
  17957. }),
  17958. alt: 'GitHub pull request status checks, with a failing "UI Tests / test" check'
  17959. }
  17960. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  17961. Link,
  17962. {
  17963. href: api.getDocsUrl({
  17964. subpath: "writing-tests/in-ci",
  17965. renderer: !0,
  17966. ref: "guide"
  17967. }),
  17968. target: "_blank"
  17969. },
  17970. "testing in CI documentation"
  17971. ), " ", "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")))
  17972. }
  17973. ]
  17974. },
  17975. {
  17976. id: "document",
  17977. title: "Document",
  17978. items: [
  17979. {
  17980. id: "installDocs",
  17981. label: "Install Docs addon",
  17982. afterCompletion: "unavailable",
  17983. criteria: "@storybook/addon-docs registered in .storybook/main.js|ts",
  17984. subscribe: ({ done }) => {
  17985. addons.experimental_getRegisteredAddons().includes(ADDON_ID6) && done();
  17986. },
  17987. 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(
  17988. Link,
  17989. {
  17990. href: api.getDocsUrl({
  17991. subpath: "writing-docs",
  17992. renderer: !0,
  17993. ref: "guide"
  17994. }),
  17995. target: "_blank",
  17996. withArrow: !0
  17997. },
  17998. "Learn more about Storybook Docs"
  17999. )))
  18000. },
  18001. {
  18002. id: "autodocs",
  18003. after: ["installDocs"],
  18004. label: "Automatically document your components",
  18005. criteria: "At least one component with the autodocs tag applied",
  18006. subscribe: subscribeToIndex(
  18007. (entries) => Object.values(entries).some((entry) => entry.tags?.includes(Tag.AUTODOCS))
  18008. ),
  18009. 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
  18010. const meta = {
  18011. component: Button,
  18012. tags: ['autodocs'], // \u{1F448} Add this tag
  18013. }
  18014. 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(
  18015. "img",
  18016. {
  18017. src: api.getDocsUrl({
  18018. asset: "writing-docs/autodocs.png",
  18019. ref: "guide"
  18020. }),
  18021. alt: "Storybook autodocs page, showing a title, description, primary story, controls table, and additional stories"
  18022. }
  18023. ), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  18024. Link,
  18025. {
  18026. href: api.getDocsUrl({
  18027. subpath: "writing-docs/autodocs",
  18028. renderer: !0,
  18029. ref: "guide"
  18030. }),
  18031. target: "_blank"
  18032. },
  18033. "autodocs documentation"
  18034. ), " ", "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")))
  18035. },
  18036. {
  18037. id: "mdxDocs",
  18038. after: ["installDocs"],
  18039. label: "Custom content with MDX",
  18040. criteria: "At least one MDX page",
  18041. subscribe: subscribeToIndex(
  18042. (entries) => Object.values(entries).some((entry) => entry.type === "docs")
  18043. ),
  18044. 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(
  18045. Link,
  18046. {
  18047. href: api.getDocsUrl({
  18048. subpath: "writing-docs/doc-blocks",
  18049. renderer: !0,
  18050. ref: "guide"
  18051. }),
  18052. target: "_blank"
  18053. },
  18054. "doc blocks"
  18055. ), ") write a usage guide for your project."), react_default.createElement(CodeSnippet, { language: "jsx" }, `{ /* introduction.mdx */ }
  18056. import { Meta, Title, Subtitle } from '@storybook/addon-docs/blocks';
  18057. <Meta title="Get started" />
  18058. <Title>Get started with My Awesome Project</Title>
  18059. <Subtitle>It's really awesome</Subtitle>
  18060. My Awesome Project is designed to work with Your Awesome Project seamlessly.
  18061. Follow this guide and you'll be ready in no time.
  18062. ## Install
  18063. \`\`\`sh
  18064. npm install @my/awesome-project
  18065. \`\`\``), react_default.createElement("strong", null, "Take it further"), react_default.createElement("p", null, "Read the", " ", react_default.createElement(
  18066. Link,
  18067. {
  18068. href: api.getDocsUrl({
  18069. subpath: "writing-docs/mdx",
  18070. renderer: !0,
  18071. ref: "guide"
  18072. }),
  18073. target: "_blank"
  18074. },
  18075. "MDX documentation"
  18076. ), " ", "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")))
  18077. }
  18078. ]
  18079. }
  18080. ]
  18081. };
  18082. // src/manager/components/sidebar/useChecklist.ts
  18083. var subscriptions = /* @__PURE__ */ new Map(), useStoryIndex = () => {
  18084. let state = useStorybookState(), [index, setIndex] = useState(() => state.index), updateIndex = useMemo(() => throttle(setIndex, 500), []);
  18085. return useEffect(() => updateIndex(state.index), [state.index, updateIndex]), useEffect(() => () => updateIndex.cancel?.(), [updateIndex]), index;
  18086. }, checkAvailable = (item, itemsById, context) => {
  18087. if (item.available && !item.available(context))
  18088. return !1;
  18089. for (let afterId of item.after ?? [])
  18090. if (itemsById[afterId] && !checkAvailable(itemsById[afterId], itemsById, context))
  18091. return !1;
  18092. return !0;
  18093. }, checkSkipped = (item, itemsById, state) => {
  18094. if (state[item.id].status === "skipped")
  18095. return !0;
  18096. for (let afterId of item.after ?? [])
  18097. if (itemsById[afterId] && checkSkipped(itemsById[afterId], itemsById, state))
  18098. return !0;
  18099. return !1;
  18100. }, getAncestorIds = (item, itemsById) => !item.after || item.after.length === 0 ? [] : item.after.flatMap((afterId) => {
  18101. let afterItem = itemsById[afterId];
  18102. return afterItem ? [...getAncestorIds(afterItem, itemsById), afterId] : [];
  18103. }), checkLockedBy = (item, itemsById, state) => getAncestorIds(item, itemsById).find(
  18104. (id) => state[id].status !== "accepted" && state[id].status !== "done"
  18105. ), useChecklist = () => {
  18106. 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(
  18107. checklistData.sections.flatMap(
  18108. ({ items: items2, id: sectionId, title: sectionTitle }, sectionIndex) => items2.map(({ id, ...item }, itemIndex) => [id, { id, itemIndex, sectionId, sectionIndex, sectionTitle, ...item }])
  18109. )
  18110. ), []), allItems = useMemo(() => Object.values(itemsById).map((item) => {
  18111. 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";
  18112. return {
  18113. ...item,
  18114. isAvailable,
  18115. isOpen,
  18116. isLockedBy,
  18117. isImmutable,
  18118. isReady: isOpen && isAvailable && !isMuted && !isLockedBy,
  18119. isCompleted,
  18120. isAccepted,
  18121. isDone,
  18122. isSkipped,
  18123. isMuted
  18124. };
  18125. }), [itemsById, items, widget, api, index, checklistState]), itemCollections = useMemo(() => {
  18126. let availableItems = allItems.filter((item) => item.isAvailable), openItems = availableItems.filter((item) => item.isOpen), readyItems = openItems.filter((item) => item.isReady), nextItems = Object.values(
  18127. readyItems.reduce((acc, item) => (acc[item.sectionId] ??= [], acc[item.sectionId].push({ ...item, itemIndex: acc[item.sectionId].length }), acc), {})
  18128. ).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;
  18129. return { availableItems, openItems, readyItems, nextItems, progress };
  18130. }, [allItems]);
  18131. return useEffect(() => {
  18132. if (!(!loaded || status !== experimental_UniversalStore.Status.READY))
  18133. for (let item of allItems) {
  18134. if (!item.subscribe)
  18135. continue;
  18136. let subscribed = subscriptions.has(item.id);
  18137. if (item.isOpen && item.isAvailable && !subscribed)
  18138. subscriptions.set(
  18139. item.id,
  18140. item.subscribe({
  18141. api,
  18142. item,
  18143. accept: () => internal_checklistStore.accept(item.id),
  18144. done: () => internal_checklistStore.done(item.id),
  18145. skip: () => internal_checklistStore.skip(item.id)
  18146. })
  18147. );
  18148. else if (subscribed && !(item.isOpen && item.isAvailable)) {
  18149. let unsubscribe = subscriptions.get(item.id);
  18150. subscriptions.delete(item.id), typeof unsubscribe == "function" && unsubscribe();
  18151. }
  18152. }
  18153. }, [api, loaded, status, allItems]), useEffect(() => {
  18154. let initialize = () => setInitialized(!0), timeout = setTimeout(initialize, 1e3);
  18155. return api.once(PREVIEW_INITIALIZED, initialize), () => {
  18156. clearTimeout(timeout), api.off(PREVIEW_INITIALIZED, initialize);
  18157. };
  18158. }, [api]), useEffect(() => {
  18159. initialized && items && status === experimental_UniversalStore.Status.READY && debounceReady();
  18160. }, [initialized, items, status, debounceReady]), {
  18161. ready,
  18162. allItems,
  18163. ...itemCollections,
  18164. ...internal_checklistStore,
  18165. ...checklistState
  18166. };
  18167. };
  18168. // src/shared/useCopyButton.ts
  18169. init_react();
  18170. // ../../node_modules/@react-aria/live-announcer/dist/LiveAnnouncer.mjs
  18171. var $319e236875307eab$var$liveAnnouncer = null;
  18172. function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = 7e3) {
  18173. $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(() => {
  18174. $319e236875307eab$var$liveAnnouncer?.isAttached() && $319e236875307eab$var$liveAnnouncer?.announce(message, assertiveness, timeout);
  18175. }, 100));
  18176. }
  18177. function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
  18178. $319e236875307eab$var$liveAnnouncer && $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
  18179. }
  18180. var $319e236875307eab$var$LiveAnnouncer = class {
  18181. isAttached() {
  18182. var _this_node;
  18183. return (_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.isConnected;
  18184. }
  18185. createLog(ariaLive) {
  18186. let node = document.createElement("div");
  18187. return node.setAttribute("role", "log"), node.setAttribute("aria-live", ariaLive), node.setAttribute("aria-relevant", "additions"), node;
  18188. }
  18189. destroy() {
  18190. this.node && (document.body.removeChild(this.node), this.node = null);
  18191. }
  18192. announce(message, assertiveness = "assertive", timeout = 7e3) {
  18193. var _this_assertiveLog, _this_politeLog;
  18194. if (!this.node) return;
  18195. let node = document.createElement("div");
  18196. 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(() => {
  18197. node.remove();
  18198. }, timeout);
  18199. }
  18200. clear(assertiveness) {
  18201. this.node && ((!assertiveness || assertiveness === "assertive") && this.assertiveLog && (this.assertiveLog.innerHTML = ""), (!assertiveness || assertiveness === "polite") && this.politeLog && (this.politeLog.innerHTML = ""));
  18202. }
  18203. constructor() {
  18204. 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, {
  18205. border: 0,
  18206. clip: "rect(0 0 0 0)",
  18207. clipPath: "inset(50%)",
  18208. height: "1px",
  18209. margin: "-1px",
  18210. overflow: "hidden",
  18211. padding: 0,
  18212. position: "absolute",
  18213. width: "1px",
  18214. whiteSpace: "nowrap"
  18215. }), 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));
  18216. }
  18217. };
  18218. // src/shared/useCopyButton.ts
  18219. function useCopyButton({
  18220. children = "Copy",
  18221. childrenOnCopy = "Copied!",
  18222. content,
  18223. onCopy,
  18224. ariaLabel = !1,
  18225. ariaLabelOnCopy = !1,
  18226. duration = 3e3
  18227. }) {
  18228. let [copied, setCopied] = useState(!1), timerRef = useRef(null);
  18229. useEffect(
  18230. () => () => {
  18231. timerRef.current && clearTimeout(timerRef.current);
  18232. },
  18233. []
  18234. );
  18235. let handleClick = useCallback(
  18236. (e2) => {
  18237. timerRef.current && clearTimeout(timerRef.current);
  18238. let announcement = typeof ariaLabelOnCopy == "string" ? ariaLabelOnCopy : "Copied to clipboard";
  18239. navigator.clipboard?.writeText(content).then(() => {
  18240. onCopy?.(e2), setCopied(!0), $319e236875307eab$export$a9b970dcc4ae71a9(announcement, "polite"), timerRef.current = setTimeout(() => {
  18241. setCopied(!1), $319e236875307eab$export$d10ae4f68404609a("polite"), timerRef.current = null;
  18242. }, duration);
  18243. });
  18244. },
  18245. [content, onCopy, ariaLabelOnCopy, duration]
  18246. );
  18247. return {
  18248. // @ts-expect-error - TypeScript is not realising T is constrained identically in both interfaces.
  18249. children: copied ? childrenOnCopy : children,
  18250. buttonProps: useMemo(
  18251. () => ({
  18252. onClick: handleClick,
  18253. ariaLabel: copied ? ariaLabelOnCopy : ariaLabel
  18254. }),
  18255. [handleClick, copied, ariaLabelOnCopy, ariaLabel]
  18256. )
  18257. };
  18258. }
  18259. // src/manager/components/sidebar/ChecklistWidget.tsx
  18260. var fadeScaleIn = keyframes`
  18261. from {
  18262. opacity: 0;
  18263. transform: scale(0.7);
  18264. }
  18265. to {
  18266. opacity: 1;
  18267. transform: scale(1);
  18268. }
  18269. `, expand = keyframes`
  18270. from {
  18271. transform: scaleX(0);
  18272. }
  18273. to {
  18274. transform: scaleX(1);
  18275. }
  18276. `, useTransitionArray = (array, subset, options2) => {
  18277. let keyFnRef = useRef(options2.keyFn), { setItem, toggle, stateMap } = useTransitionMap({
  18278. allowMultiple: !0,
  18279. mountOnEnter: !0,
  18280. unmountOnExit: !0,
  18281. preEnter: !0,
  18282. ...options2
  18283. });
  18284. return useEffect(() => {
  18285. let keyFn = keyFnRef.current;
  18286. array.forEach((task) => setItem(keyFn(task)));
  18287. }, [array, setItem]), useEffect(() => {
  18288. let keyFn = keyFnRef.current;
  18289. array.forEach((task) => toggle(keyFn(task), subset.map(keyFn).includes(keyFn(task))));
  18290. }, [array, subset, toggle]), Array.from(stateMap).map(
  18291. ([key, value]) => [array.find((item) => keyFnRef.current(item) === key), value]
  18292. );
  18293. }, CollapsibleWithMargin = styled(Collapsible)(({ collapsed }) => ({
  18294. marginTop: collapsed ? 0 : 16
  18295. })), HoverCard = styled(Card)({
  18296. "&:hover #checklist-module-collapse-toggle": {
  18297. opacity: 1
  18298. }
  18299. }), CollapseToggle2 = styled(ActionList.Button)({
  18300. opacity: 0,
  18301. transition: "opacity var(--transition-duration, 0.2s)",
  18302. "&:focus, &:hover": {
  18303. opacity: 1
  18304. }
  18305. }), ProgressCircle = styled(ProgressSpinner)(({ theme }) => ({
  18306. color: theme.color.secondary
  18307. })), Checked = styled(StatusPassIcon)(({ theme }) => ({
  18308. padding: 1,
  18309. borderRadius: "50%",
  18310. background: theme.color.positive,
  18311. color: theme.background.content,
  18312. animation: `${fadeScaleIn} 500ms forwards`
  18313. })), ItemLabel = styled.span(
  18314. ({ theme, isCompleted, isSkipped }) => ({
  18315. position: "relative",
  18316. margin: "0 -2px",
  18317. padding: "0 2px",
  18318. color: isSkipped ? theme.color.mediumdark : isCompleted ? theme.base === "dark" ? theme.color.positive : theme.color.positiveText : theme.color.defaultText,
  18319. transition: "color 500ms"
  18320. }),
  18321. ({ theme, isSkipped }) => isSkipped && {
  18322. alignSelf: "flex-start",
  18323. "&:after": {
  18324. content: '""',
  18325. position: "absolute",
  18326. top: "50%",
  18327. left: 0,
  18328. width: "100%",
  18329. height: 1,
  18330. background: theme.color.mediumdark,
  18331. animation: `${expand} 500ms forwards`,
  18332. transformOrigin: "left"
  18333. }
  18334. }
  18335. ), title = (progress) => {
  18336. switch (!0) {
  18337. case progress < 50:
  18338. return "Get started";
  18339. case progress < 75:
  18340. return "Level up";
  18341. default:
  18342. return "Become an expert";
  18343. }
  18344. }, OpenGuideButton = ({
  18345. children,
  18346. afterClick
  18347. }) => {
  18348. let api = useStorybookApi();
  18349. return react_default.createElement(
  18350. ActionList.Action,
  18351. {
  18352. ariaLabel: "Open onboarding guide",
  18353. onClick: (e2) => {
  18354. e2.stopPropagation(), api.navigate("/settings/guide"), afterClick?.();
  18355. }
  18356. },
  18357. react_default.createElement(ActionList.Icon, null, react_default.createElement(ListUnorderedIcon, null)),
  18358. children
  18359. );
  18360. }, CopyButton = ({
  18361. label,
  18362. copyContent,
  18363. onClick,
  18364. ...props
  18365. }) => {
  18366. let { children: copyChildren, buttonProps: copyButtonProps } = useCopyButton({
  18367. children: label,
  18368. childrenOnCopy: react_default.createElement(react_default.Fragment, null, react_default.createElement(CheckIcon, null), " Copied!"),
  18369. onCopy: onClick,
  18370. content: copyContent
  18371. });
  18372. return react_default.createElement(ActionList.Button, { ...props, ...copyButtonProps }, copyChildren);
  18373. }, ChecklistWidget = () => {
  18374. let api = useStorybookApi(), { loaded, ready, allItems, nextItems, progress, accept, mute, items } = useChecklist(), [renderItems, setRenderItems] = useState(nextItems), [animated, setAnimated] = useState(!1);
  18375. useEffect(() => {
  18376. if (ready) {
  18377. let timeout = setTimeout(setAnimated, 1e3, !0);
  18378. return () => clearTimeout(timeout);
  18379. }
  18380. }, [ready]), useEffect(() => {
  18381. if (!animated) {
  18382. setRenderItems(nextItems);
  18383. return;
  18384. }
  18385. setRenderItems((current) => {
  18386. let animateOut = !1, prevItems = current.map((item) => {
  18387. let { status } = items[item.id], isAccepted = status === "accepted", isDone = status === "done", isSkipped = status === "skipped";
  18388. return animateOut = animateOut || isAccepted || isDone || isSkipped, { ...item, isCompleted: isAccepted || isDone, isAccepted, isDone, isSkipped };
  18389. });
  18390. return animateOut ? prevItems : nextItems;
  18391. });
  18392. let timeout = setTimeout(setRenderItems, 2e3, nextItems);
  18393. return () => clearTimeout(timeout);
  18394. }, [animated, nextItems, items]);
  18395. let hasItems = renderItems.length > 0, transitionItems = useTransitionArray(allItems, renderItems, {
  18396. keyFn: (item) => item.id,
  18397. timeout: animated ? 300 : 0
  18398. });
  18399. return api.getIsNavShown() ? react_default.createElement(CollapsibleWithMargin, { collapsed: !hasItems || !loaded }, react_default.createElement(HoverCard, { id: "storybook-checklist-widget", outlineAnimation: "rainbow" }, react_default.createElement(
  18400. Collapsible,
  18401. {
  18402. storageKey: "checklist-widget",
  18403. initialCollapsed: !hasItems,
  18404. disabled: !hasItems,
  18405. 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(
  18406. Optional,
  18407. {
  18408. content: react_default.createElement(OpenGuideButton, null, react_default.createElement("strong", null, title(progress))),
  18409. fallback: react_default.createElement(OpenGuideButton, null)
  18410. }
  18411. )), react_default.createElement(ActionList.Item, { as: "div" }, react_default.createElement(
  18412. CollapseToggle2,
  18413. {
  18414. ...toggleProps,
  18415. id: "checklist-module-collapse-toggle",
  18416. ariaLabel: `${isCollapsed ? "Expand" : "Collapse"} onboarding guide`
  18417. },
  18418. react_default.createElement(
  18419. ChevronSmallUpIcon,
  18420. {
  18421. style: {
  18422. transform: isCollapsed ? "rotate(180deg)" : "none",
  18423. transition: "transform 250ms",
  18424. willChange: "auto"
  18425. }
  18426. }
  18427. )
  18428. ), loaded && react_default.createElement(
  18429. PopoverProvider,
  18430. {
  18431. ariaLabel: "Onboarding guide menu",
  18432. padding: 0,
  18433. 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(
  18434. ActionList.Action,
  18435. {
  18436. ariaLabel: !1,
  18437. onClick: (e2) => {
  18438. e2.stopPropagation(), mute(allItems.map(({ id }) => id)), onHide();
  18439. }
  18440. },
  18441. react_default.createElement(ActionList.Icon, null, react_default.createElement(EyeCloseIcon, null)),
  18442. react_default.createElement(ActionList.Text, null, "Remove from sidebar")
  18443. )))
  18444. },
  18445. react_default.createElement(
  18446. ActionList.Button,
  18447. {
  18448. ariaLabel: `${progress}% completed`,
  18449. onClick: (e2) => e2.stopPropagation()
  18450. },
  18451. react_default.createElement(
  18452. ProgressCircle,
  18453. {
  18454. percentage: progress,
  18455. running: !1,
  18456. size: 16,
  18457. width: 1.5
  18458. }
  18459. ),
  18460. react_default.createElement(TextFlip, { text: `${progress}%`, placeholder: "00%" })
  18461. )
  18462. ))))
  18463. },
  18464. react_default.createElement(ActionList, null, transitionItems.map(
  18465. ([item, { status, isMounted }]) => isMounted && react_default.createElement(ActionList.HoverItem, { key: item.id, targetId: item.id, transitionStatus: status }, react_default.createElement(
  18466. ActionList.Action,
  18467. {
  18468. ariaLabel: `Open onboarding guide for ${item.label}`,
  18469. onClick: () => api.navigate(`/settings/guide#${item.id}`)
  18470. },
  18471. 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)),
  18472. react_default.createElement(ActionList.Text, null, react_default.createElement(ItemLabel, { isCompleted: item.isCompleted, isSkipped: item.isSkipped }, item.label))
  18473. ), item.action && (item.action.copyContent ? react_default.createElement(
  18474. CopyButton,
  18475. {
  18476. "data-target-id": item.id,
  18477. label: item.action.label,
  18478. copyContent: item.action.copyContent,
  18479. onClick: (e2) => {
  18480. e2.stopPropagation(), item.action?.onClick({
  18481. api,
  18482. accept: () => accept(item.id)
  18483. });
  18484. }
  18485. }
  18486. ) : react_default.createElement(
  18487. ActionList.Button,
  18488. {
  18489. "data-target-id": item.id,
  18490. ariaLabel: !1,
  18491. onClick: (e2) => {
  18492. e2.stopPropagation(), item.action?.onClick({
  18493. api,
  18494. accept: () => accept(item.id)
  18495. });
  18496. }
  18497. },
  18498. item.action.label
  18499. )))
  18500. ))
  18501. ))) : null;
  18502. };
  18503. // src/manager/components/sidebar/CreateNewStoryFileModal.tsx
  18504. init_react();
  18505. // src/manager/hooks/useDebounce.ts
  18506. init_react();
  18507. function useDebounce(value, delay2) {
  18508. let [debouncedValue, setDebouncedValue] = useState(value);
  18509. return useEffect(() => {
  18510. let handler = setTimeout(() => {
  18511. setDebouncedValue(value);
  18512. }, delay2);
  18513. return () => {
  18514. clearTimeout(handler);
  18515. };
  18516. }, [value, delay2]), debouncedValue;
  18517. }
  18518. // src/manager/components/sidebar/FileSearchModal.tsx
  18519. init_react();
  18520. // src/manager/hooks/useMeasure.tsx
  18521. init_react();
  18522. function useMeasure() {
  18523. let [dimensions, setDimensions] = react_default.useState({
  18524. width: null,
  18525. height: null
  18526. }), prevObserver = react_default.useRef(null);
  18527. return [react_default.useCallback((node) => {
  18528. if (prevObserver.current && (prevObserver.current.disconnect(), prevObserver.current = null), node?.nodeType === Node.ELEMENT_NODE) {
  18529. let observer = new ResizeObserver(([entry]) => {
  18530. if (entry && entry.borderBoxSize) {
  18531. let { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];
  18532. setDimensions({ width, height });
  18533. }
  18534. });
  18535. observer.observe(node), prevObserver.current = observer;
  18536. }
  18537. }, []), dimensions];
  18538. }
  18539. // src/manager/components/sidebar/FileSearchList.tsx
  18540. init_react();
  18541. // ../../node_modules/@tanstack/react-virtual/dist/esm/index.js
  18542. init_react();
  18543. // ../../node_modules/@tanstack/virtual-core/dist/esm/utils.js
  18544. function memo2(getDeps, fn, opts) {
  18545. let deps = opts.initialDeps ?? [], result;
  18546. function memoizedFunction() {
  18547. var _a2, _b, _c, _d;
  18548. let depTime;
  18549. opts.key && ((_a2 = opts.debug) != null && _a2.call(opts)) && (depTime = Date.now());
  18550. let newDeps = getDeps();
  18551. if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep)))
  18552. return result;
  18553. deps = newDeps;
  18554. let resultTime;
  18555. 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))) {
  18556. let depEndTime = Math.round((Date.now() - depTime) * 100) / 100, resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100, resultFpsPercentage = resultEndTime / 16, pad = (str, num) => {
  18557. for (str = String(str); str.length < num; )
  18558. str = " " + str;
  18559. return str;
  18560. };
  18561. console.info(
  18562. `%c\u23F1 ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,
  18563. `
  18564. font-size: .6rem;
  18565. font-weight: bold;
  18566. color: hsl(${Math.max(
  18567. 0,
  18568. Math.min(120 - 120 * resultFpsPercentage, 120)
  18569. )}deg 100% 31%);`,
  18570. opts?.key
  18571. );
  18572. }
  18573. return (_d = opts?.onChange) == null || _d.call(opts, result), result;
  18574. }
  18575. return memoizedFunction.updateDeps = (newDeps) => {
  18576. deps = newDeps;
  18577. }, memoizedFunction;
  18578. }
  18579. function notUndefined(value, msg) {
  18580. if (value === void 0)
  18581. throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
  18582. return value;
  18583. }
  18584. var approxEqual = (a2, b2) => Math.abs(a2 - b2) < 1.01, debounce3 = (targetWindow, fn, ms) => {
  18585. let timeoutId;
  18586. return function(...args) {
  18587. targetWindow.clearTimeout(timeoutId), timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
  18588. };
  18589. };
  18590. // ../../node_modules/@tanstack/virtual-core/dist/esm/index.js
  18591. var getRect = (element) => {
  18592. let { offsetWidth, offsetHeight } = element;
  18593. return { width: offsetWidth, height: offsetHeight };
  18594. }, defaultKeyExtractor = (index) => index, defaultRangeExtractor = (range) => {
  18595. let start = Math.max(range.startIndex - range.overscan, 0), end = Math.min(range.endIndex + range.overscan, range.count - 1), arr = [];
  18596. for (let i2 = start; i2 <= end; i2++)
  18597. arr.push(i2);
  18598. return arr;
  18599. }, observeElementRect = (instance, cb) => {
  18600. let element = instance.scrollElement;
  18601. if (!element)
  18602. return;
  18603. let targetWindow = instance.targetWindow;
  18604. if (!targetWindow)
  18605. return;
  18606. let handler = (rect) => {
  18607. let { width, height } = rect;
  18608. cb({ width: Math.round(width), height: Math.round(height) });
  18609. };
  18610. if (handler(getRect(element)), !targetWindow.ResizeObserver)
  18611. return () => {
  18612. };
  18613. let observer = new targetWindow.ResizeObserver((entries) => {
  18614. let run = () => {
  18615. let entry = entries[0];
  18616. if (entry?.borderBoxSize) {
  18617. let box = entry.borderBoxSize[0];
  18618. if (box) {
  18619. handler({ width: box.inlineSize, height: box.blockSize });
  18620. return;
  18621. }
  18622. }
  18623. handler(getRect(element));
  18624. };
  18625. instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
  18626. });
  18627. return observer.observe(element, { box: "border-box" }), () => {
  18628. observer.unobserve(element);
  18629. };
  18630. }, addEventListenerOptions = {
  18631. passive: !0
  18632. };
  18633. var supportsScrollend = typeof window > "u" ? !0 : "onscrollend" in window, observeElementOffset = (instance, cb) => {
  18634. let element = instance.scrollElement;
  18635. if (!element)
  18636. return;
  18637. let targetWindow = instance.targetWindow;
  18638. if (!targetWindow)
  18639. return;
  18640. let offset2 = 0, fallback = instance.options.useScrollendEvent && supportsScrollend ? () => {
  18641. } : debounce3(
  18642. targetWindow,
  18643. () => {
  18644. cb(offset2, !1);
  18645. },
  18646. instance.options.isScrollingResetDelay
  18647. ), createHandler = (isScrolling) => () => {
  18648. let { horizontal, isRtl } = instance.options;
  18649. offset2 = horizontal ? element.scrollLeft * (isRtl && -1 || 1) : element.scrollTop, fallback(), cb(offset2, isScrolling);
  18650. }, handler = createHandler(!0), endHandler = createHandler(!1);
  18651. endHandler(), element.addEventListener("scroll", handler, addEventListenerOptions);
  18652. let registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
  18653. return registerScrollendEvent && element.addEventListener("scrollend", endHandler, addEventListenerOptions), () => {
  18654. element.removeEventListener("scroll", handler), registerScrollendEvent && element.removeEventListener("scrollend", endHandler);
  18655. };
  18656. };
  18657. var measureElement = (element, entry, instance) => {
  18658. if (entry?.borderBoxSize) {
  18659. let box = entry.borderBoxSize[0];
  18660. if (box)
  18661. return Math.round(
  18662. box[instance.options.horizontal ? "inlineSize" : "blockSize"]
  18663. );
  18664. }
  18665. return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
  18666. };
  18667. var elementScroll = (offset2, {
  18668. adjustments = 0,
  18669. behavior
  18670. }, instance) => {
  18671. var _a2, _b;
  18672. let toOffset = offset2 + adjustments;
  18673. (_b = (_a2 = instance.scrollElement) == null ? void 0 : _a2.scrollTo) == null || _b.call(_a2, {
  18674. [instance.options.horizontal ? "left" : "top"]: toOffset,
  18675. behavior
  18676. });
  18677. }, Virtualizer = class {
  18678. constructor(opts) {
  18679. 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__ */ (() => {
  18680. let _ro = null, get2 = () => _ro || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : _ro = new this.targetWindow.ResizeObserver((entries) => {
  18681. entries.forEach((entry) => {
  18682. let run = () => {
  18683. this._measureElement(entry.target, entry);
  18684. };
  18685. this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
  18686. });
  18687. }));
  18688. return {
  18689. disconnect: () => {
  18690. var _a2;
  18691. (_a2 = get2()) == null || _a2.disconnect(), _ro = null;
  18692. },
  18693. observe: (target) => {
  18694. var _a2;
  18695. return (_a2 = get2()) == null ? void 0 : _a2.observe(target, { box: "border-box" });
  18696. },
  18697. unobserve: (target) => {
  18698. var _a2;
  18699. return (_a2 = get2()) == null ? void 0 : _a2.unobserve(target);
  18700. }
  18701. };
  18702. })(), this.range = null, this.setOptions = (opts2) => {
  18703. Object.entries(opts2).forEach(([key, value]) => {
  18704. typeof value > "u" && delete opts2[key];
  18705. }), this.options = {
  18706. debug: !1,
  18707. initialOffset: 0,
  18708. overscan: 1,
  18709. paddingStart: 0,
  18710. paddingEnd: 0,
  18711. scrollPaddingStart: 0,
  18712. scrollPaddingEnd: 0,
  18713. horizontal: !1,
  18714. getItemKey: defaultKeyExtractor,
  18715. rangeExtractor: defaultRangeExtractor,
  18716. onChange: () => {
  18717. },
  18718. measureElement,
  18719. initialRect: { width: 0, height: 0 },
  18720. scrollMargin: 0,
  18721. gap: 0,
  18722. indexAttribute: "data-index",
  18723. initialMeasurementsCache: [],
  18724. lanes: 1,
  18725. isScrollingResetDelay: 150,
  18726. enabled: !0,
  18727. isRtl: !1,
  18728. useScrollendEvent: !1,
  18729. useAnimationFrameWithResizeObserver: !1,
  18730. ...opts2
  18731. };
  18732. }, this.notify = (sync) => {
  18733. var _a2, _b;
  18734. (_b = (_a2 = this.options).onChange) == null || _b.call(_a2, this, sync);
  18735. }, this.maybeNotify = memo2(
  18736. () => (this.calculateRange(), [
  18737. this.isScrolling,
  18738. this.range ? this.range.startIndex : null,
  18739. this.range ? this.range.endIndex : null
  18740. ]),
  18741. (isScrolling) => {
  18742. this.notify(isScrolling);
  18743. },
  18744. {
  18745. key: !1,
  18746. debug: () => this.options.debug,
  18747. initialDeps: [
  18748. this.isScrolling,
  18749. this.range ? this.range.startIndex : null,
  18750. this.range ? this.range.endIndex : null
  18751. ]
  18752. }
  18753. ), this.cleanup = () => {
  18754. this.unsubs.filter(Boolean).forEach((d2) => d2()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
  18755. }, this._didMount = () => () => {
  18756. this.cleanup();
  18757. }, this._willUpdate = () => {
  18758. var _a2;
  18759. let scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
  18760. if (this.scrollElement !== scrollElement) {
  18761. if (this.cleanup(), !scrollElement) {
  18762. this.maybeNotify();
  18763. return;
  18764. }
  18765. 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) => {
  18766. this.observer.observe(cached);
  18767. }), this._scrollToOffset(this.getScrollOffset(), {
  18768. adjustments: void 0,
  18769. behavior: void 0
  18770. }), this.unsubs.push(
  18771. this.options.observeElementRect(this, (rect) => {
  18772. this.scrollRect = rect, this.maybeNotify();
  18773. })
  18774. ), this.unsubs.push(
  18775. this.options.observeElementOffset(this, (offset2, isScrolling) => {
  18776. this.scrollAdjustments = 0, this.scrollDirection = isScrolling ? this.getScrollOffset() < offset2 ? "forward" : "backward" : null, this.scrollOffset = offset2, this.isScrolling = isScrolling, this.maybeNotify();
  18777. })
  18778. );
  18779. }
  18780. }, 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) => {
  18781. let furthestMeasurementsFound = /* @__PURE__ */ new Map(), furthestMeasurements = /* @__PURE__ */ new Map();
  18782. for (let m2 = index - 1; m2 >= 0; m2--) {
  18783. let measurement = measurements[m2];
  18784. if (furthestMeasurementsFound.has(measurement.lane))
  18785. continue;
  18786. let previousFurthestMeasurement = furthestMeasurements.get(
  18787. measurement.lane
  18788. );
  18789. 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)
  18790. break;
  18791. }
  18792. 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;
  18793. }, this.getMeasurementOptions = memo2(
  18794. () => [
  18795. this.options.count,
  18796. this.options.paddingStart,
  18797. this.options.scrollMargin,
  18798. this.options.getItemKey,
  18799. this.options.enabled
  18800. ],
  18801. (count, paddingStart, scrollMargin, getItemKey, enabled) => (this.pendingMeasuredCacheIndexes = [], {
  18802. count,
  18803. paddingStart,
  18804. scrollMargin,
  18805. getItemKey,
  18806. enabled
  18807. }),
  18808. {
  18809. key: !1
  18810. }
  18811. ), this.getMeasurements = memo2(
  18812. () => [this.getMeasurementOptions(), this.itemSizeCache],
  18813. ({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
  18814. if (!enabled)
  18815. return this.measurementsCache = [], this.itemSizeCache.clear(), [];
  18816. this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((item) => {
  18817. this.itemSizeCache.set(item.key, item.size);
  18818. }));
  18819. let min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
  18820. this.pendingMeasuredCacheIndexes = [];
  18821. let measurements = this.measurementsCache.slice(0, min);
  18822. for (let i2 = min; i2 < count; i2++) {
  18823. 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;
  18824. measurements[i2] = {
  18825. index: i2,
  18826. start,
  18827. size,
  18828. end,
  18829. key,
  18830. lane
  18831. };
  18832. }
  18833. return this.measurementsCache = measurements, measurements;
  18834. },
  18835. {
  18836. key: !1,
  18837. debug: () => this.options.debug
  18838. }
  18839. ), this.calculateRange = memo2(
  18840. () => [
  18841. this.getMeasurements(),
  18842. this.getSize(),
  18843. this.getScrollOffset(),
  18844. this.options.lanes
  18845. ],
  18846. (measurements, outerSize, scrollOffset, lanes) => this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
  18847. measurements,
  18848. outerSize,
  18849. scrollOffset,
  18850. lanes
  18851. }) : null,
  18852. {
  18853. key: !1,
  18854. debug: () => this.options.debug
  18855. }
  18856. ), this.getVirtualIndexes = memo2(
  18857. () => {
  18858. let startIndex = null, endIndex = null, range = this.calculateRange();
  18859. return range && (startIndex = range.startIndex, endIndex = range.endIndex), this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]), [
  18860. this.options.rangeExtractor,
  18861. this.options.overscan,
  18862. this.options.count,
  18863. startIndex,
  18864. endIndex
  18865. ];
  18866. },
  18867. (rangeExtractor, overscan, count, startIndex, endIndex) => startIndex === null || endIndex === null ? [] : rangeExtractor({
  18868. startIndex,
  18869. endIndex,
  18870. overscan,
  18871. count
  18872. }),
  18873. {
  18874. key: !1,
  18875. debug: () => this.options.debug
  18876. }
  18877. ), this.indexFromElement = (node) => {
  18878. let attributeName = this.options.indexAttribute, indexStr = node.getAttribute(attributeName);
  18879. return indexStr ? parseInt(indexStr, 10) : (console.warn(
  18880. `Missing attribute name '${attributeName}={index}' on measured element.`
  18881. ), -1);
  18882. }, this._measureElement = (node, entry) => {
  18883. let index = this.indexFromElement(node), item = this.measurementsCache[index];
  18884. if (!item)
  18885. return;
  18886. let key = item.key, prevNode = this.elementsCache.get(key);
  18887. 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));
  18888. }, this.resizeItem = (index, size) => {
  18889. let item = this.measurementsCache[index];
  18890. if (!item)
  18891. return;
  18892. let itemSize = this.itemSizeCache.get(item.key) ?? item.size, delta = size - itemSize;
  18893. delta !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments) && this._scrollToOffset(this.getScrollOffset(), {
  18894. adjustments: this.scrollAdjustments += delta,
  18895. behavior: void 0
  18896. }), this.pendingMeasuredCacheIndexes.push(item.index), this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size)), this.notify(!1));
  18897. }, this.measureElement = (node) => {
  18898. if (!node) {
  18899. this.elementsCache.forEach((cached, key) => {
  18900. cached.isConnected || (this.observer.unobserve(cached), this.elementsCache.delete(key));
  18901. });
  18902. return;
  18903. }
  18904. this._measureElement(node, void 0);
  18905. }, this.getVirtualItems = memo2(
  18906. () => [this.getVirtualIndexes(), this.getMeasurements()],
  18907. (indexes, measurements) => {
  18908. let virtualItems = [];
  18909. for (let k2 = 0, len = indexes.length; k2 < len; k2++) {
  18910. let i2 = indexes[k2], measurement = measurements[i2];
  18911. virtualItems.push(measurement);
  18912. }
  18913. return virtualItems;
  18914. },
  18915. {
  18916. key: !1,
  18917. debug: () => this.options.debug
  18918. }
  18919. ), this.getVirtualItemForOffset = (offset2) => {
  18920. let measurements = this.getMeasurements();
  18921. if (measurements.length !== 0)
  18922. return notUndefined(
  18923. measurements[findNearestBinarySearch(
  18924. 0,
  18925. measurements.length - 1,
  18926. (index) => notUndefined(measurements[index]).start,
  18927. offset2
  18928. )]
  18929. );
  18930. }, this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
  18931. let size = this.getSize(), scrollOffset = this.getScrollOffset();
  18932. align === "auto" && (align = toOffset >= scrollOffset + size ? "end" : "start"), align === "center" ? toOffset += (itemSize - size) / 2 : align === "end" && (toOffset -= size);
  18933. let maxOffset = this.getTotalSize() + this.options.scrollMargin - size;
  18934. return Math.max(Math.min(maxOffset, toOffset), 0);
  18935. }, this.getOffsetForIndex = (index, align = "auto") => {
  18936. index = Math.max(0, Math.min(index, this.options.count - 1));
  18937. let item = this.measurementsCache[index];
  18938. if (!item)
  18939. return;
  18940. let size = this.getSize(), scrollOffset = this.getScrollOffset();
  18941. if (align === "auto")
  18942. if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd)
  18943. align = "end";
  18944. else if (item.start <= scrollOffset + this.options.scrollPaddingStart)
  18945. align = "start";
  18946. else
  18947. return [scrollOffset, align];
  18948. let toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
  18949. return [
  18950. this.getOffsetForAlignment(toOffset, align, item.size),
  18951. align
  18952. ];
  18953. }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
  18954. behavior === "smooth" && this.isDynamicMode() && console.warn(
  18955. "The `smooth` scroll behavior is not fully supported with dynamic size."
  18956. ), this._scrollToOffset(this.getOffsetForAlignment(toOffset, align), {
  18957. adjustments: void 0,
  18958. behavior
  18959. });
  18960. }, this.scrollToIndex = (index, { align: initialAlign = "auto", behavior } = {}) => {
  18961. behavior === "smooth" && this.isDynamicMode() && console.warn(
  18962. "The `smooth` scroll behavior is not fully supported with dynamic size."
  18963. ), index = Math.max(0, Math.min(index, this.options.count - 1));
  18964. let attempts = 0, maxAttempts = 10, tryScroll = (currentAlign) => {
  18965. if (!this.targetWindow) return;
  18966. let offsetInfo = this.getOffsetForIndex(index, currentAlign);
  18967. if (!offsetInfo) {
  18968. console.warn("Failed to get offset for index:", index);
  18969. return;
  18970. }
  18971. let [offset2, align] = offsetInfo;
  18972. this._scrollToOffset(offset2, { adjustments: void 0, behavior }), this.targetWindow.requestAnimationFrame(() => {
  18973. let currentOffset = this.getScrollOffset(), afterInfo = this.getOffsetForIndex(index, align);
  18974. if (!afterInfo) {
  18975. console.warn("Failed to get offset for index:", index);
  18976. return;
  18977. }
  18978. approxEqual(afterInfo[0], currentOffset) || scheduleRetry(align);
  18979. });
  18980. }, scheduleRetry = (align) => {
  18981. this.targetWindow && (attempts++, attempts < maxAttempts ? this.targetWindow.requestAnimationFrame(() => tryScroll(align)) : console.warn(
  18982. `Failed to scroll to index ${index} after ${maxAttempts} attempts.`
  18983. ));
  18984. };
  18985. tryScroll(initialAlign);
  18986. }, this.scrollBy = (delta, { behavior } = {}) => {
  18987. behavior === "smooth" && this.isDynamicMode() && console.warn(
  18988. "The `smooth` scroll behavior is not fully supported with dynamic size."
  18989. ), this._scrollToOffset(this.getScrollOffset() + delta, {
  18990. adjustments: void 0,
  18991. behavior
  18992. });
  18993. }, this.getTotalSize = () => {
  18994. var _a2;
  18995. let measurements = this.getMeasurements(), end;
  18996. if (measurements.length === 0)
  18997. end = this.options.paddingStart;
  18998. else if (this.options.lanes === 1)
  18999. end = ((_a2 = measurements[measurements.length - 1]) == null ? void 0 : _a2.end) ?? 0;
  19000. else {
  19001. let endByLane = Array(this.options.lanes).fill(null), endIndex = measurements.length - 1;
  19002. for (; endIndex >= 0 && endByLane.some((val) => val === null); ) {
  19003. let item = measurements[endIndex];
  19004. endByLane[item.lane] === null && (endByLane[item.lane] = item.end), endIndex--;
  19005. }
  19006. end = Math.max(...endByLane.filter((val) => val !== null));
  19007. }
  19008. return Math.max(
  19009. end - this.options.scrollMargin + this.options.paddingEnd,
  19010. 0
  19011. );
  19012. }, this._scrollToOffset = (offset2, {
  19013. adjustments,
  19014. behavior
  19015. }) => {
  19016. this.options.scrollToFn(offset2, { behavior, adjustments }, this);
  19017. }, this.measure = () => {
  19018. this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
  19019. }, this.setOptions(opts);
  19020. }
  19021. }, findNearestBinarySearch = (low, high, getCurrentValue, value) => {
  19022. for (; low <= high; ) {
  19023. let middle = (low + high) / 2 | 0, currentValue = getCurrentValue(middle);
  19024. if (currentValue < value)
  19025. low = middle + 1;
  19026. else if (currentValue > value)
  19027. high = middle - 1;
  19028. else
  19029. return middle;
  19030. }
  19031. return low > 0 ? low - 1 : 0;
  19032. };
  19033. function calculateRange({
  19034. measurements,
  19035. outerSize,
  19036. scrollOffset,
  19037. lanes
  19038. }) {
  19039. let lastIndex = measurements.length - 1, getOffset = (index) => measurements[index].start;
  19040. if (measurements.length <= lanes)
  19041. return {
  19042. startIndex: 0,
  19043. endIndex: lastIndex
  19044. };
  19045. let startIndex = findNearestBinarySearch(
  19046. 0,
  19047. lastIndex,
  19048. getOffset,
  19049. scrollOffset
  19050. ), endIndex = startIndex;
  19051. if (lanes === 1)
  19052. for (; endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize; )
  19053. endIndex++;
  19054. else if (lanes > 1) {
  19055. let endPerLane = Array(lanes).fill(0);
  19056. for (; endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize); ) {
  19057. let item = measurements[endIndex];
  19058. endPerLane[item.lane] = item.end, endIndex++;
  19059. }
  19060. let startPerLane = Array(lanes).fill(scrollOffset + outerSize);
  19061. for (; startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset); ) {
  19062. let item = measurements[startIndex];
  19063. startPerLane[item.lane] = item.start, startIndex--;
  19064. }
  19065. startIndex = Math.max(0, startIndex - startIndex % lanes), endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
  19066. }
  19067. return { startIndex, endIndex };
  19068. }
  19069. // ../../node_modules/@tanstack/react-virtual/dist/esm/index.js
  19070. var useIsomorphicLayoutEffect = typeof document < "u" ? useLayoutEffect : useEffect;
  19071. function useVirtualizerBase(options2) {
  19072. let rerender = useReducer(() => ({}), {})[1], resolvedOptions = {
  19073. ...options2,
  19074. onChange: (instance2, sync) => {
  19075. var _a2;
  19076. sync ? flushSync(rerender) : rerender(), (_a2 = options2.onChange) == null || _a2.call(options2, instance2, sync);
  19077. }
  19078. }, [instance] = useState(
  19079. () => new Virtualizer(resolvedOptions)
  19080. );
  19081. return instance.setOptions(resolvedOptions), useIsomorphicLayoutEffect(() => instance._didMount(), []), useIsomorphicLayoutEffect(() => instance._willUpdate()), instance;
  19082. }
  19083. function useVirtualizer(options2) {
  19084. return useVirtualizerBase({
  19085. observeElementRect,
  19086. observeElementOffset,
  19087. scrollToFn: elementScroll,
  19088. ...options2
  19089. });
  19090. }
  19091. // src/manager/components/sidebar/FIleSearchList.utils.tsx
  19092. init_react();
  19093. var useArrowKeyNavigation = ({
  19094. parentRef,
  19095. rowVirtualizer,
  19096. selectedItem
  19097. }) => {
  19098. useEffect(() => {
  19099. let handleArrowKeys = (event) => {
  19100. if (!parentRef.current)
  19101. return;
  19102. 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}"]`);
  19103. if (event.code === "ArrowDown" && activeElement) {
  19104. if (event.stopPropagation(), isActiveElementInput) {
  19105. getFirstElement()?.focus();
  19106. return;
  19107. }
  19108. if (rowIndex === maxIndex - 1) {
  19109. flushSync(() => {
  19110. rowVirtualizer.scrollToIndex(0, { align: "start" });
  19111. }), setTimeout(() => {
  19112. getFirstElement()?.focus();
  19113. }, 100);
  19114. return;
  19115. }
  19116. if (selectedItem === rowIndex) {
  19117. document.querySelector(
  19118. `[data-index-position="${selectedItem}_first"]`
  19119. )?.focus();
  19120. return;
  19121. }
  19122. if (selectedItem !== null && activeElement.getAttribute("data-index-position")?.includes("last")) {
  19123. document.querySelector(
  19124. `[data-index="${selectedItem + 1}"]`
  19125. )?.focus();
  19126. return;
  19127. }
  19128. activeElement.nextElementSibling?.focus();
  19129. }
  19130. if (event.code === "ArrowUp" && activeElement) {
  19131. if (isActiveElementInput) {
  19132. flushSync(() => {
  19133. rowVirtualizer.scrollToIndex(maxIndex - 1, { align: "start" });
  19134. }), setTimeout(() => {
  19135. getLastElement()?.focus();
  19136. }, 100);
  19137. return;
  19138. }
  19139. if (selectedItem !== null && activeElement.getAttribute("data-index-position")?.includes("first")) {
  19140. document.querySelector(
  19141. `[data-index="${selectedItem}"]`
  19142. )?.focus();
  19143. return;
  19144. }
  19145. activeElement.previousElementSibling?.focus();
  19146. }
  19147. };
  19148. return document.addEventListener("keydown", handleArrowKeys, { capture: !0 }), () => {
  19149. document.removeEventListener("keydown", handleArrowKeys, { capture: !0 });
  19150. };
  19151. }, [rowVirtualizer, selectedItem, parentRef]);
  19152. };
  19153. // src/manager/components/sidebar/FileList.tsx
  19154. var FileListWrapper = styled("div")(({ theme }) => ({
  19155. marginTop: "-16px",
  19156. // after element which fades out the list
  19157. "&::after": {
  19158. content: '""',
  19159. position: "fixed",
  19160. pointerEvents: "none",
  19161. bottom: 0,
  19162. left: 0,
  19163. right: 0,
  19164. height: "80px",
  19165. background: `linear-gradient(${rgba(theme.barBg, 0)} 10%, ${theme.barBg} 80%)`
  19166. }
  19167. })), FileList = styled("div")({
  19168. height: "280px",
  19169. overflow: "auto",
  19170. msOverflowStyle: "none",
  19171. scrollbarWidth: "none",
  19172. position: "relative",
  19173. "::-webkit-scrollbar": {
  19174. display: "none"
  19175. }
  19176. }), FileListLi = styled("li")(({ theme }) => ({
  19177. ":focus-visible": {
  19178. outline: "none",
  19179. ".file-list-item": {
  19180. borderRadius: "4px",
  19181. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : theme.color.mediumlight,
  19182. "> svg": {
  19183. display: "flex"
  19184. }
  19185. }
  19186. }
  19187. })), FileListItem = styled("div")({
  19188. display: "flex",
  19189. flexDirection: "column",
  19190. position: "relative"
  19191. }), FileListItemContentWrapper = styled.div(({ theme, selected, disabled, error }) => ({
  19192. display: "flex",
  19193. alignItems: "flex-start",
  19194. gap: "8px",
  19195. alignSelf: "stretch",
  19196. padding: "8px 16px",
  19197. cursor: "pointer",
  19198. borderRadius: "4px",
  19199. ...selected && {
  19200. borderRadius: "4px",
  19201. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : theme.color.mediumlight,
  19202. "> svg": {
  19203. display: "flex"
  19204. }
  19205. },
  19206. ...disabled && {
  19207. cursor: "not-allowed",
  19208. div: {
  19209. color: `${theme.textMutedColor} !important`
  19210. }
  19211. },
  19212. ...error && {
  19213. background: theme.base === "light" ? "#00000011" : "#00000033"
  19214. },
  19215. "&:hover": {
  19216. background: error ? "#00000022" : theme.base === "dark" ? "rgba(255,255,255,.1)" : theme.color.mediumlight,
  19217. "> svg": {
  19218. display: "flex"
  19219. }
  19220. }
  19221. })), FileListUl = styled("ul")({
  19222. margin: 0,
  19223. padding: "0 0 0 0",
  19224. width: "100%",
  19225. position: "relative"
  19226. }), FileListItemContent = styled("div")({
  19227. display: "flex",
  19228. flexDirection: "column",
  19229. alignItems: "flex-start",
  19230. width: "calc(100% - 50px)"
  19231. }), FileListIconWrapper = styled("div")(({ theme, error }) => ({
  19232. color: error ? theme.color.negativeText : theme.color.secondary
  19233. })), FileListItemLabel = styled("div")(({ theme, error }) => ({
  19234. color: error ? theme.color.negativeText : theme.base === "dark" ? theme.color.lighter : theme.color.darkest,
  19235. fontSize: "14px",
  19236. whiteSpace: "nowrap",
  19237. textOverflow: "ellipsis",
  19238. overflow: "hidden",
  19239. maxWidth: "100%"
  19240. })), FileListItemPath = styled("div")(({ theme }) => ({
  19241. color: theme.textMutedColor,
  19242. fontSize: "14px",
  19243. whiteSpace: "nowrap",
  19244. textOverflow: "ellipsis",
  19245. overflow: "hidden",
  19246. maxWidth: "100%"
  19247. })), FileListExport = styled("ul")({
  19248. margin: 0,
  19249. padding: 0
  19250. }), FileListItemExport = styled("li")(({ theme, error }) => ({
  19251. padding: "8px 16px 8px 58px",
  19252. display: "flex",
  19253. gap: "8px",
  19254. alignItems: "center",
  19255. justifyContent: "space-between",
  19256. fontSize: "14px",
  19257. cursor: "pointer",
  19258. borderRadius: "4px",
  19259. ":focus-visible": {
  19260. outline: "none"
  19261. },
  19262. ...error && {
  19263. background: "#F9ECEC",
  19264. color: theme.color.negativeText
  19265. },
  19266. "&:hover,:focus-visible": {
  19267. background: error ? "#F9ECEC" : theme.base === "dark" ? "rgba(255, 255, 255, 0.1)" : theme.color.mediumlight,
  19268. "> svg": {
  19269. display: "flex"
  19270. }
  19271. },
  19272. "> div > svg": {
  19273. color: error ? theme.color.negativeText : theme.color.secondary
  19274. }
  19275. })), FileListItemExportName = styled("div")({
  19276. display: "flex",
  19277. alignItems: "center",
  19278. gap: "8px",
  19279. width: "calc(100% - 20px)"
  19280. }), FileListItemExportNameContent = styled("span")(({ theme }) => ({
  19281. whiteSpace: "nowrap",
  19282. textOverflow: "ellipsis",
  19283. overflow: "hidden",
  19284. display: "inline-block",
  19285. color: theme.base === "dark" ? theme.color.lightest : theme.color.darkest
  19286. })), FileListItemExportNameContentWithExport = styled(FileListItemExportNameContent)({
  19287. maxWidth: "calc(100% - 120px)"
  19288. }), DefaultExport = styled("span")(({ theme }) => ({
  19289. display: "inline-block",
  19290. padding: `1px ${theme.appBorderRadius}px`,
  19291. borderRadius: "2px",
  19292. fontSize: "10px",
  19293. color: theme.color.defaultText,
  19294. backgroundColor: theme.base === "dark" ? "rgba(255, 255, 255, 0.1)" : "#F2F4F5"
  19295. })), NoResults = styled("div")(({ theme }) => ({
  19296. textAlign: "center",
  19297. maxWidth: "334px",
  19298. margin: "16px auto 50px auto",
  19299. fontSize: "14px",
  19300. color: theme.base === "dark" ? theme.color.lightest : "#000"
  19301. })), NoResultsDescription = styled("p")(({ theme }) => ({
  19302. margin: 0,
  19303. color: theme.textMutedColor
  19304. }));
  19305. // src/manager/components/sidebar/FileSearchListSkeleton.tsx
  19306. init_react();
  19307. var FileListItemContentWrapperSkeleton = styled("div")(({ theme }) => ({
  19308. display: "flex",
  19309. alignItems: "flex-start",
  19310. gap: "8px",
  19311. alignSelf: "stretch",
  19312. padding: "8px 16px"
  19313. })), FileListItemContentSkeleton = styled("div")({
  19314. display: "flex",
  19315. flexDirection: "column",
  19316. alignItems: "flex-start",
  19317. width: "100%",
  19318. borderRadius: "3px"
  19319. }), FileListIconWrapperSkeleton = styled.div(({ theme }) => ({
  19320. width: "14px",
  19321. height: "14px",
  19322. borderRadius: "3px",
  19323. marginTop: "1px",
  19324. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : "rgba(0,0,0,.1)",
  19325. animation: `${theme.animation.glow} 1.5s ease-in-out infinite`
  19326. })), FileListItemSkeleton = styled.div(({ theme }) => ({
  19327. height: "16px",
  19328. borderRadius: "3px",
  19329. background: theme.base === "dark" ? "rgba(255,255,255,.1)" : "rgba(0,0,0,.1)",
  19330. animation: `${theme.animation.glow} 1.5s ease-in-out infinite`,
  19331. width: "100%",
  19332. maxWidth: "100%",
  19333. "+ div": {
  19334. marginTop: "6px"
  19335. }
  19336. })), 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" } }))))));
  19337. // src/manager/components/sidebar/FileSearchList.tsx
  19338. var TreeExpandIconStyled = styled(ChevronSmallRightIcon)(({ theme }) => ({
  19339. color: theme.textMutedColor,
  19340. marginTop: 2
  19341. })), TreeCollapseIconStyled = styled(ChevronSmallDownIcon)(({ theme }) => ({
  19342. color: theme.textMutedColor,
  19343. marginTop: 2
  19344. })), FileSearchList = memo(function({
  19345. isLoading,
  19346. searchResults,
  19347. onNewStory,
  19348. errorItemId
  19349. }) {
  19350. let [selectedItem, setSelectedItem] = useState(null), parentRef = react_default.useRef(), sortedSearchResults = useMemo(() => [...searchResults ?? []].sort((a2, b2) => {
  19351. let isALowPriority = a2.exportedComponents === null || a2.exportedComponents?.length === 0, hasAStory = a2.storyFileExists, isBLowPriority = b2.exportedComponents === null || b2.exportedComponents?.length === 0, hasBStory = b2.storyFileExists;
  19352. return hasAStory && !hasBStory ? -1 : hasBStory && !hasAStory || isALowPriority && !isBLowPriority ? 1 : !isALowPriority && isBLowPriority ? -1 : 0;
  19353. }), [searchResults]), count = searchResults?.length || 0, rowVirtualizer = useVirtualizer({
  19354. count,
  19355. // @ts-expect-error (non strict)
  19356. getScrollElement: () => parentRef.current,
  19357. paddingStart: 16,
  19358. paddingEnd: 40,
  19359. estimateSize: () => 54,
  19360. overscan: 2
  19361. });
  19362. useArrowKeyNavigation({ rowVirtualizer, parentRef, selectedItem });
  19363. let handleFileItemSelection = useCallback(
  19364. ({ virtualItem, searchResult, itemId }) => {
  19365. searchResult?.exportedComponents?.length > 1 ? setSelectedItem((sItem) => sItem === virtualItem.index ? null : virtualItem.index) : searchResult?.exportedComponents?.length === 1 && onNewStory({
  19366. componentExportName: searchResult.exportedComponents[0].name,
  19367. componentFilePath: searchResult.filepath,
  19368. componentIsDefaultExport: searchResult.exportedComponents[0].default,
  19369. selectedItemId: itemId,
  19370. componentExportCount: 1
  19371. });
  19372. },
  19373. [onNewStory]
  19374. ), handleFileItemComponentSelection = useCallback(
  19375. ({ searchResult, component, id }) => {
  19376. onNewStory({
  19377. componentExportName: component.name,
  19378. componentFilePath: searchResult.filepath,
  19379. componentIsDefaultExport: component.default,
  19380. selectedItemId: id,
  19381. // @ts-expect-error (non strict)
  19382. componentExportCount: searchResult.exportedComponents.length
  19383. });
  19384. },
  19385. [onNewStory]
  19386. ), ListItem2 = useCallback(
  19387. ({
  19388. virtualItem,
  19389. selected,
  19390. searchResult,
  19391. noExports
  19392. }) => {
  19393. 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;
  19394. return react_default.createElement(
  19395. FileListItem,
  19396. {
  19397. "aria-expanded": itemSelected,
  19398. "aria-controls": `file-list-export-${virtualItem.index}`,
  19399. id: `file-list-item-wrapper-${virtualItem.index}`
  19400. },
  19401. react_default.createElement(
  19402. TooltipProvider,
  19403. {
  19404. tooltip: tooltip ? react_default.createElement(TooltipNote, { note: tooltip }) : void 0,
  19405. placement: "top-start",
  19406. delayHide: 100,
  19407. delayShow: 200
  19408. },
  19409. react_default.createElement(
  19410. FileListItemContentWrapper,
  19411. {
  19412. className: "file-list-item",
  19413. selected: itemSelected,
  19414. error: itemError,
  19415. disabled: noExports
  19416. },
  19417. itemSelected ? react_default.createElement(TreeCollapseIconStyled, { size: 14 }) : react_default.createElement(TreeExpandIconStyled, { size: 14 }),
  19418. react_default.createElement(FileListIconWrapper, { error: itemError }, react_default.createElement(ComponentIcon, null)),
  19419. react_default.createElement(FileListItemContent, null, react_default.createElement(FileListItemLabel, { error: itemError }, searchResult.filepath.split("/").at(-1)), react_default.createElement(FileListItemPath, null, searchResult.filepath))
  19420. )
  19421. ),
  19422. searchResult?.exportedComponents?.length > 1 && itemSelected && react_default.createElement(
  19423. FileListExport,
  19424. {
  19425. role: "region",
  19426. id: `file-list-export-${virtualItem.index}`,
  19427. "aria-labelledby": `file-list-item-wrapper-${virtualItem.index}`,
  19428. onClick: (e2) => {
  19429. e2.stopPropagation();
  19430. },
  19431. onKeyUp: (e2) => {
  19432. e2.key === "Enter" && e2.stopPropagation();
  19433. }
  19434. },
  19435. searchResult.exportedComponents?.map((component, itemExportId) => {
  19436. let itemExportError = errorItemId === `${searchResult.filepath}_${itemExportId}`, position = itemExportId === 0 ? "first" : (
  19437. // @ts-expect-error (non strict)
  19438. itemExportId === searchResult.exportedComponents.length - 1 ? "last" : "middle"
  19439. );
  19440. return react_default.createElement(
  19441. FileListItemExport,
  19442. {
  19443. tabIndex: 0,
  19444. "data-index-position": `${virtualItem.index}_${position}`,
  19445. key: component.name,
  19446. error: itemExportError,
  19447. onClick: () => {
  19448. handleFileItemComponentSelection({
  19449. searchResult,
  19450. component,
  19451. id: `${searchResult.filepath}_${itemExportId}`
  19452. });
  19453. },
  19454. onKeyUp: (event) => {
  19455. event.key === "Enter" && handleFileItemComponentSelection({
  19456. searchResult,
  19457. component,
  19458. id: `${searchResult.filepath}_${itemExportId}`
  19459. });
  19460. }
  19461. },
  19462. 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))
  19463. );
  19464. })
  19465. )
  19466. );
  19467. },
  19468. [handleFileItemComponentSelection, errorItemId]
  19469. );
  19470. 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(
  19471. FileListUl,
  19472. {
  19473. style: {
  19474. height: `${rowVirtualizer.getTotalSize()}px`
  19475. }
  19476. },
  19477. rowVirtualizer.getVirtualItems().map((virtualItem) => {
  19478. let searchResult = sortedSearchResults[virtualItem.index], noExports = searchResult.exportedComponents === null || searchResult.exportedComponents?.length === 0, itemProps = {};
  19479. return react_default.createElement(
  19480. FileListLi,
  19481. {
  19482. key: virtualItem.key,
  19483. "data-index": virtualItem.index,
  19484. ref: rowVirtualizer.measureElement,
  19485. onClick: () => {
  19486. handleFileItemSelection({
  19487. virtualItem,
  19488. itemId: searchResult.filepath,
  19489. searchResult
  19490. });
  19491. },
  19492. onKeyUp: (event) => {
  19493. event.key === "Enter" && handleFileItemSelection({
  19494. virtualItem,
  19495. itemId: searchResult.filepath,
  19496. searchResult
  19497. });
  19498. },
  19499. style: {
  19500. position: "absolute",
  19501. top: 0,
  19502. left: 0,
  19503. width: "100%",
  19504. transform: `translateY(${virtualItem.start}px)`
  19505. },
  19506. tabIndex: 0
  19507. },
  19508. react_default.createElement(
  19509. ListItem2,
  19510. {
  19511. ...itemProps,
  19512. key: virtualItem.index,
  19513. searchResult,
  19514. selected: selectedItem,
  19515. virtualItem,
  19516. noExports
  19517. }
  19518. )
  19519. );
  19520. })
  19521. ))) : null;
  19522. });
  19523. // src/manager/components/sidebar/FileSearchModal.tsx
  19524. var MODAL_HEIGHT = 418, ModalStyled = styled(Modal)(() => ({
  19525. boxShadow: "none",
  19526. background: "transparent",
  19527. overflow: "visible"
  19528. })), ModalChild = styled.div(({ theme, height }) => ({
  19529. backgroundColor: theme.background.bar,
  19530. borderRadius: 6,
  19531. boxShadow: "rgba(255, 255, 255, 0.05) 0 0 0 1px inset, rgba(14, 18, 22, 0.35) 0px 10px 18px -10px",
  19532. padding: "16px",
  19533. transition: "height 0.3s",
  19534. height: height ? `${height + 32}px` : "auto",
  19535. overflow: "hidden"
  19536. })), ModalContent = styled(Modal.Content)(({ theme }) => ({
  19537. margin: 0,
  19538. color: theme.color.defaultText
  19539. })), ModalInput = styled(Form.Input)(({ theme }) => ({
  19540. paddingLeft: 40,
  19541. paddingRight: 28,
  19542. fontSize: 14,
  19543. height: 40,
  19544. ...theme.base === "light" && {
  19545. color: theme.color.darkest
  19546. },
  19547. "::placeholder": {
  19548. color: theme.color.mediumdark
  19549. },
  19550. "&:invalid:not(:placeholder-shown)": {
  19551. boxShadow: `${theme.color.negative} 0 0 0 1px inset`
  19552. },
  19553. "&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration": {
  19554. display: "none"
  19555. }
  19556. })), SearchField = styled.div({
  19557. display: "flex",
  19558. flexDirection: "column",
  19559. flexGrow: 1,
  19560. position: "relative"
  19561. }), SearchIconWrapper = styled.div(({ theme }) => ({
  19562. position: "absolute",
  19563. top: 0,
  19564. left: 16,
  19565. zIndex: 1,
  19566. pointerEvents: "none",
  19567. color: theme.darkest,
  19568. display: "flex",
  19569. alignItems: "center",
  19570. height: "100%"
  19571. })), LoadingIcon = styled.div(({ theme }) => ({
  19572. position: "absolute",
  19573. top: 0,
  19574. right: 16,
  19575. zIndex: 1,
  19576. color: theme.darkest,
  19577. display: "flex",
  19578. alignItems: "center",
  19579. height: "100%",
  19580. "@keyframes spin": {
  19581. from: { transform: "rotate(0deg)" },
  19582. to: { transform: "rotate(360deg)" }
  19583. },
  19584. animation: "spin 1s linear infinite"
  19585. })), ModalError = styled(Modal.Error)({
  19586. position: "absolute",
  19587. padding: "8px 40px 8px 16px",
  19588. bottom: 0,
  19589. maxHeight: "initial",
  19590. width: "100%",
  19591. div: {
  19592. wordBreak: "break-word"
  19593. },
  19594. "> div": {
  19595. padding: 0
  19596. }
  19597. }), ModalErrorCloseIcon = styled(CloseAltIcon)({
  19598. position: "absolute",
  19599. top: 4,
  19600. right: -24,
  19601. cursor: "pointer"
  19602. }), FileSearchModal = ({
  19603. open,
  19604. onOpenChange,
  19605. fileSearchQuery,
  19606. setFileSearchQuery,
  19607. isLoading,
  19608. error,
  19609. searchResults,
  19610. onCreateNewStory,
  19611. setError
  19612. }) => {
  19613. let [modalContentRef, modalContentDimensions] = useMeasure(), [modalMaxHeight, setModalMaxHeight] = useState(modalContentDimensions.height), [, startTransition2] = useTransition(), [searchInputValue, setSearchInputValue] = useState(fileSearchQuery);
  19614. return useEffect(() => {
  19615. modalMaxHeight < modalContentDimensions.height && setModalMaxHeight(modalContentDimensions.height);
  19616. }, [modalContentDimensions.height, modalMaxHeight]), react_default.createElement(
  19617. ModalStyled,
  19618. {
  19619. ariaLabel: "Add a new story",
  19620. height: MODAL_HEIGHT,
  19621. width: 440,
  19622. open,
  19623. onOpenChange
  19624. },
  19625. 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(
  19626. ModalInput,
  19627. {
  19628. placeholder: "./components/**/*.tsx",
  19629. type: "search",
  19630. required: !0,
  19631. autoFocus: !0,
  19632. value: searchInputValue,
  19633. onChange: (e2) => {
  19634. let newValue = e2.target.value;
  19635. setSearchInputValue(newValue), startTransition2(() => {
  19636. setFileSearchQuery(newValue);
  19637. });
  19638. }
  19639. }
  19640. ), isLoading && react_default.createElement(LoadingIcon, null, react_default.createElement(SyncIcon, null))), react_default.createElement(
  19641. FileSearchList,
  19642. {
  19643. errorItemId: error?.selectedItemId,
  19644. isLoading,
  19645. searchResults,
  19646. onNewStory: onCreateNewStory
  19647. }
  19648. ))),
  19649. error && fileSearchQuery !== "" && react_default.createElement(ModalError, null, react_default.createElement("div", null, error.error), react_default.createElement(
  19650. ModalErrorCloseIcon,
  19651. {
  19652. onClick: () => {
  19653. setError(null);
  19654. }
  19655. }
  19656. ))
  19657. );
  19658. };
  19659. // src/manager/utils/trySelectStory.ts
  19660. async function trySelectStory(selectStory, storyId, attempt = 1) {
  19661. if (attempt > 10)
  19662. throw new Error("We could not select the new story. Please try again.");
  19663. try {
  19664. selectStory(storyId);
  19665. } catch {
  19666. return await new Promise((resolve) => setTimeout(resolve, 500)), trySelectStory(selectStory, storyId, attempt + 1);
  19667. }
  19668. }
  19669. // src/manager/components/sidebar/CreateNewStoryFileModal.tsx
  19670. var isRendererReact = scope.STORYBOOK_RENDERER === "react", CreateNewStoryFileModal = ({ open, onOpenChange }) => {
  19671. let [isLoading, setLoading] = useState(!1), [fileSearchQuery, setFileSearchQuery] = useState(""), fileSearchQueryDebounced = useDebounce(fileSearchQuery, 600), fileSearchQueryDeferred = useDeferredValue(fileSearchQueryDebounced), emittedValue = useRef(null), [error, setError] = useState(
  19672. null
  19673. ), api = useStorybookApi(), hasRunGhostStoriesFlow = useRef(!1), [searchResults, setSearchResults] = useState(null), handleSuccessfullyCreatedStory = useCallback(
  19674. (componentExportName) => {
  19675. api.addNotification({
  19676. id: "create-new-story-file-success",
  19677. content: {
  19678. headline: "Story file created",
  19679. subHeadline: `${componentExportName} was created`
  19680. },
  19681. duration: 8e3,
  19682. icon: react_default.createElement(CheckIcon, null)
  19683. }), onOpenChange(!1);
  19684. },
  19685. [api, onOpenChange]
  19686. ), handleStoryAlreadyExists = useCallback(() => {
  19687. api.addNotification({
  19688. id: "create-new-story-file-error",
  19689. content: {
  19690. headline: "Story already exists",
  19691. subHeadline: "Successfully navigated to existing story"
  19692. },
  19693. duration: 8e3,
  19694. icon: react_default.createElement(CheckIcon, null)
  19695. }), onOpenChange(!1);
  19696. }, [api, onOpenChange]), handleFileSearch = useCallback(() => {
  19697. setLoading(!0);
  19698. let channel = addons.getChannel(), set = (data) => {
  19699. 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);
  19700. };
  19701. return channel.on(FILE_COMPONENT_SEARCH_RESPONSE, set), fileSearchQueryDeferred !== "" && emittedValue.current !== fileSearchQueryDeferred ? (emittedValue.current = fileSearchQueryDeferred, channel.emit(FILE_COMPONENT_SEARCH_REQUEST, {
  19702. id: fileSearchQueryDeferred,
  19703. payload: {}
  19704. })) : (setSearchResults(null), setLoading(!1)), () => {
  19705. channel.off(FILE_COMPONENT_SEARCH_RESPONSE, set);
  19706. };
  19707. }, [fileSearchQueryDeferred]), handleCreateNewStory = useCallback(
  19708. async ({
  19709. componentExportName,
  19710. componentFilePath,
  19711. componentIsDefaultExport,
  19712. componentExportCount,
  19713. selectedItemId
  19714. }) => {
  19715. try {
  19716. let channel = addons.getChannel(), createNewStoryResult = await experimental_requestResponse(channel, CREATE_NEW_STORYFILE_REQUEST, CREATE_NEW_STORYFILE_RESPONSE, {
  19717. componentExportName,
  19718. componentFilePath,
  19719. componentIsDefaultExport,
  19720. componentExportCount
  19721. });
  19722. setError(null);
  19723. let storyId = createNewStoryResult.storyId;
  19724. await trySelectStory(api.selectStory, storyId), handleSuccessfullyCreatedStory(componentExportName), handleFileSearch();
  19725. } catch (e2) {
  19726. if (e2?.payload?.type === "STORY_FILE_EXISTS") {
  19727. let err = e2;
  19728. await trySelectStory(api.selectStory, err.payload.kind), handleStoryAlreadyExists();
  19729. } else
  19730. setError({ selectedItemId, error: e2?.message });
  19731. }
  19732. },
  19733. [api?.selectStory, handleSuccessfullyCreatedStory, handleFileSearch, handleStoryAlreadyExists]
  19734. );
  19735. useEffect(() => {
  19736. setError(null);
  19737. }, [fileSearchQueryDeferred]), useEffect(() => handleFileSearch(), [handleFileSearch]);
  19738. let executeGhostStoriesFlow = useCallback(async () => {
  19739. addons.getChannel().emit(GHOST_STORIES_REQUEST);
  19740. }, []);
  19741. return useEffect(() => {
  19742. open && isRendererReact && !hasRunGhostStoriesFlow.current && (hasRunGhostStoriesFlow.current = !0, executeGhostStoriesFlow());
  19743. }, [open, executeGhostStoriesFlow]), react_default.createElement(
  19744. FileSearchModal,
  19745. {
  19746. error,
  19747. fileSearchQuery,
  19748. fileSearchQueryDeferred,
  19749. onCreateNewStory: handleCreateNewStory,
  19750. isLoading,
  19751. onOpenChange,
  19752. open,
  19753. searchResults,
  19754. setError,
  19755. setFileSearchQuery
  19756. }
  19757. );
  19758. };
  19759. // src/manager/components/sidebar/Explorer.tsx
  19760. init_react();
  19761. // src/manager/components/sidebar/HighlightStyles.tsx
  19762. init_react();
  19763. var HighlightStyles = ({ refId, itemId }) => react_default.createElement(
  19764. Global,
  19765. {
  19766. styles: ({ color: color2 }) => {
  19767. let background2 = curriedTransparentize$1(0.85, color2.secondary);
  19768. return {
  19769. [`[data-ref-id="${refId}"][data-item-id="${itemId}"]:not([data-selected="true"])`]: {
  19770. '&[data-nodetype="component"], &[data-nodetype="group"]': {
  19771. background: background2,
  19772. "&:hover, &:focus": { background: background2 }
  19773. },
  19774. '&[data-nodetype="story"], &[data-nodetype="document"], &[data-nodetype="test"]': {
  19775. color: color2.defaultText,
  19776. background: background2,
  19777. "&:hover, &:focus": { background: background2 }
  19778. }
  19779. }
  19780. };
  19781. }
  19782. }
  19783. );
  19784. // src/manager/components/sidebar/Refs.tsx
  19785. init_react();
  19786. // src/shared/constants/tags.ts
  19787. var Tag2 = {
  19788. /** Indicates that autodocs should be generated for this component */
  19789. AUTODOCS: "autodocs",
  19790. /** MDX documentation attached to a component's stories file */
  19791. ATTACHED_MDX: "attached-mdx",
  19792. /** Standalone MDX documentation not attached to stories */
  19793. UNATTACHED_MDX: "unattached-mdx",
  19794. /** Story has a play function */
  19795. PLAY_FN: "play-fn",
  19796. /** Story has a test function */
  19797. TEST_FN: "test-fn",
  19798. /** Development environment tag */
  19799. DEV: "dev",
  19800. /** Test environment tag */
  19801. TEST: "test",
  19802. /** Manifest generation tag */
  19803. MANIFEST: "manifest"
  19804. }, BUILT_IN_FILTERS = {
  19805. _docs: (entry, excluded) => excluded ? entry.type !== "docs" : entry.type === "docs",
  19806. _play: (entry, excluded) => excluded ? entry.type !== "story" || !entry.tags?.includes(Tag2.PLAY_FN) : entry.type === "story" && !!entry.tags?.includes(Tag2.PLAY_FN),
  19807. _test: (entry, excluded) => excluded ? entry.type !== "story" || entry.subtype !== "test" : entry.type === "story" && entry.subtype === "test"
  19808. }, USER_TAG_FILTER = (tag) => (entry, excluded) => excluded ? !entry.tags?.includes(tag) : !!entry.tags?.includes(tag);
  19809. // src/shared/utils/story-index-filters.ts
  19810. var getActiveFilterCount = ({
  19811. includedTagFilters,
  19812. excludedTagFilters,
  19813. includedStatusFilters,
  19814. excludedStatusFilters
  19815. }) => (includedTagFilters?.length ?? 0) + (excludedTagFilters?.length ?? 0) + (includedStatusFilters?.length ?? 0) + (excludedStatusFilters?.length ?? 0);
  19816. // src/manager/utils/tree.ts
  19817. var import_memoizerific3 = __toESM(require_memoizerific(), 1);
  19818. 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)}`;
  19819. var get = (0, import_memoizerific3.default)(1e3)((id, dataset) => dataset[id]), getParent = (0, import_memoizerific3.default)(1e3)((id, dataset) => {
  19820. let item = get(id, dataset);
  19821. return item && item.type !== "root" ? get(item.parent, dataset) : void 0;
  19822. }), getParents = (0, import_memoizerific3.default)(1e3)((id, dataset) => {
  19823. let parent = getParent(id, dataset);
  19824. return parent ? [parent, ...getParents(parent.id, dataset)] : [];
  19825. }), getAncestorIds2 = (0, import_memoizerific3.default)(1e3)(
  19826. (data, id) => getParents(id, data).map((item) => item.id)
  19827. ), getDescendantIds = (0, import_memoizerific3.default)(1e3)((data, id, skipLeafs) => {
  19828. let entry = data[id];
  19829. return !entry || !("children" in entry) || !entry.children ? [] : entry.children.reduce((acc, childId) => {
  19830. let child = data[childId];
  19831. return !child || skipLeafs && (child.type === "story" || child.type === "docs") || acc.push(childId, ...getDescendantIds(data, childId, skipLeafs)), acc;
  19832. }, []);
  19833. });
  19834. function getPath(item, ref) {
  19835. let parent = item.type !== "root" && item.parent ? ref.index[item.parent] : null;
  19836. return parent ? [...getPath(parent, ref), parent.name] : ref.id === DEFAULT_REF_ID ? [] : [ref.title || ref.id];
  19837. }
  19838. var searchItem = (item, ref) => ({ ...item, refId: ref.id, path: getPath(item, ref) });
  19839. function cycle2(array, index, delta) {
  19840. let next = index + delta % array.length;
  19841. return next < 0 && (next = array.length + next), next >= array.length && (next -= array.length), next;
  19842. }
  19843. var scrollIntoView = (element, center = !1) => {
  19844. if (!element)
  19845. return;
  19846. let { top, bottom } = element.getBoundingClientRect();
  19847. if (!top || !bottom)
  19848. return;
  19849. let bottomOffset = document3?.querySelector("#sidebar-bottom-wrapper")?.getBoundingClientRect().top || globalWindow.innerHeight || document3.documentElement.clientHeight;
  19850. bottom > bottomOffset && element.scrollIntoView({ block: center ? "center" : "nearest" });
  19851. }, getStateType = (isLoading, isAuthRequired, isError2, isEmpty) => {
  19852. switch (!0) {
  19853. case isAuthRequired:
  19854. return "auth";
  19855. case isError2:
  19856. return "error";
  19857. case isLoading:
  19858. return "loading";
  19859. case isEmpty:
  19860. return "empty";
  19861. default:
  19862. return "ready";
  19863. }
  19864. }, 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);
  19865. // src/manager/components/sidebar/RefBlocks.tsx
  19866. init_react();
  19867. // src/manager/components/sidebar/Loader.tsx
  19868. init_react();
  19869. var LOADER_SEQUENCE = [0, 0, 1, 1, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3], Loadingitem = styled.div(
  19870. {
  19871. cursor: "progress",
  19872. fontSize: 13,
  19873. height: "16px",
  19874. marginTop: 4,
  19875. marginBottom: 4,
  19876. alignItems: "center",
  19877. overflow: "hidden"
  19878. },
  19879. ({ depth = 0 }) => ({
  19880. marginLeft: depth * 15,
  19881. maxWidth: 85 - depth * 5
  19882. }),
  19883. ({ theme }) => theme.animation.inlineGlow,
  19884. ({ theme }) => ({
  19885. background: theme.appBorderColor
  19886. })
  19887. ), Contained = styled.div({
  19888. display: "flex",
  19889. flexDirection: "column",
  19890. paddingLeft: 20,
  19891. paddingRight: 20
  19892. }), Loader2 = ({ size }) => {
  19893. let repeats = Math.ceil(size / LOADER_SEQUENCE.length), sequence = Array.from(Array(repeats)).fill(LOADER_SEQUENCE).flat().slice(0, size);
  19894. return react_default.createElement(Fragment, null, sequence.map((depth, index) => react_default.createElement(Loadingitem, { depth, key: index })));
  19895. };
  19896. // src/manager/components/sidebar/NoResults.tsx
  19897. var NoResults2 = styled.div(({ theme }) => ({
  19898. display: "flex",
  19899. flexDirection: "column",
  19900. textAlign: "center",
  19901. textWrap: "balance",
  19902. gap: 4,
  19903. padding: "20px 0",
  19904. lineHeight: "18px",
  19905. fontSize: `${theme.typography.size.s2}px`,
  19906. color: theme.color.defaultText,
  19907. small: {
  19908. color: theme.textMutedColor,
  19909. fontSize: `${theme.typography.size.s1}px`
  19910. },
  19911. button: {
  19912. marginTop: 8,
  19913. alignSelf: "center"
  19914. }
  19915. }));
  19916. // src/manager/components/sidebar/RefBlocks.tsx
  19917. var { window: globalWindow2 } = scope, TextStyle = styled.div(({ theme }) => ({
  19918. fontSize: theme.typography.size.s2,
  19919. lineHeight: "20px",
  19920. margin: 0
  19921. })), Text3 = styled.div(({ theme }) => ({
  19922. fontSize: theme.typography.size.s2,
  19923. lineHeight: "20px",
  19924. margin: 0,
  19925. code: {
  19926. fontSize: theme.typography.size.s1
  19927. },
  19928. ul: {
  19929. paddingLeft: 20,
  19930. marginTop: 8,
  19931. marginBottom: 8
  19932. }
  19933. })), ErrorDisplay = styled.pre(
  19934. {
  19935. boxSizing: "border-box",
  19936. borderRadius: 8,
  19937. overflow: "auto",
  19938. whiteSpace: "pre"
  19939. },
  19940. ({ isMobile: isMobile2 }) => isMobile2 ? {
  19941. maxWidth: "calc(100vw - 40px)"
  19942. } : {
  19943. minWidth: 420,
  19944. maxWidth: 640
  19945. },
  19946. ({ theme }) => ({
  19947. color: theme.color.dark
  19948. })
  19949. ), AuthBlock = ({ loginUrl, id }) => {
  19950. let [isAuthAttempted, setAuthAttempted] = useState(!1), refresh = useCallback(() => {
  19951. globalWindow2.document.location.reload();
  19952. }, []), open = useCallback((e2) => {
  19953. e2.preventDefault();
  19954. let childWindow = globalWindow2.open(loginUrl, `storybook_auth_${id}`, "resizable,scrollbars"), timer = setInterval(() => {
  19955. childWindow ? childWindow.closed && (clearInterval(timer), setAuthAttempted(!0)) : (logger.error("unable to access loginUrl window"), clearInterval(timer));
  19956. }, 1e3);
  19957. }, []);
  19958. 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")))));
  19959. }, ErrorBlock = ({ error }) => {
  19960. let { isMobile: isMobile2 } = useLayout();
  19961. 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(
  19962. PopoverProvider,
  19963. {
  19964. ariaLabel: "Error details",
  19965. hasCloseButton: !0,
  19966. offset: isMobile2 ? 0 : 8,
  19967. placement: isMobile2 ? "bottom-end" : "bottom-start",
  19968. popover: react_default.createElement(ErrorDisplay, { isMobile: isMobile2 }, react_default.createElement(ErrorFormatter, { error }))
  19969. },
  19970. react_default.createElement(Link, null, "View error ", react_default.createElement(ChevronDownIcon, null))
  19971. ), " ", react_default.createElement(Link, { href: "https://storybook.js.org/docs?ref=ui", cancel: !1, target: "_blank" }, "View docs"))));
  19972. }, FlexSpaced = styled(Spaced)({
  19973. display: "flex"
  19974. }), WideSpaced = styled(Spaced)({
  19975. flex: 1
  19976. }), EmptyBlock = ({
  19977. isMain,
  19978. hasEntries,
  19979. activeFilterCount
  19980. }) => {
  19981. let api = useStorybookApi();
  19982. 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(
  19983. Button,
  19984. {
  19985. ariaLabel: !1,
  19986. size: "small",
  19987. variant: "outline",
  19988. onClick: async () => {
  19989. await api.setAllTagFilters([], []), await api.resetStatusFilters();
  19990. }
  19991. },
  19992. react_default.createElement(SweepIcon, null),
  19993. "Clear filters"
  19994. ) : 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(
  19995. Link,
  19996. {
  19997. href: "https://storybook.js.org/docs/api/main-config/main-config-stories?ref=ui",
  19998. cancel: !1,
  19999. target: "_blank"
  20000. },
  20001. "stories glob configuration"
  20002. ), " ", "does not match any files.", " "), react_default.createElement("li", null, "You have", " ", react_default.createElement(
  20003. Link,
  20004. {
  20005. href: "https://storybook.js.org/docs/writing-stories?ref=ui",
  20006. cancel: !1,
  20007. target: "_blank"
  20008. },
  20009. "no stories defined"
  20010. ), " ", "in your story files.", " "))) : react_default.createElement(Text3, null, "This composed Storybook is empty. Perhaps no stories match your selected filters."))));
  20011. }, LoaderBlock = ({ isMain }) => react_default.createElement(Contained, null, react_default.createElement(Loader2, { size: isMain ? 17 : 5 }));
  20012. // src/manager/components/sidebar/RefIndicator.tsx
  20013. init_react();
  20014. var { document: document4, window: globalWindow3 } = scope, IndicatorPlacement = styled.div(({ theme }) => ({
  20015. height: 16,
  20016. display: "flex",
  20017. alignItems: "center",
  20018. "& > * + *": {
  20019. marginLeft: theme.layoutMargin
  20020. }
  20021. })), IndicatorClickTarget = styled(Button)(({ theme }) => ({
  20022. color: theme.textMutedColor,
  20023. svg: {
  20024. height: 14,
  20025. width: 14,
  20026. padding: 2,
  20027. transition: "all 150ms ease-out",
  20028. color: "inherit"
  20029. }
  20030. })), MessageTitle = styled.span(({ theme }) => ({
  20031. fontWeight: theme.typography.weight.bold
  20032. })), StyledMessage = styled.a(({ theme }) => ({
  20033. textDecoration: "none",
  20034. lineHeight: "16px",
  20035. padding: 15,
  20036. display: "flex",
  20037. flexDirection: "row",
  20038. alignItems: "flex-start",
  20039. color: theme.color.defaultText,
  20040. "&:not(:last-child)": {
  20041. borderBottom: `1px solid ${theme.appBorderColor}`
  20042. },
  20043. "&:hover": {
  20044. background: theme.background.hoverable,
  20045. color: theme.color.defaultText
  20046. },
  20047. "&:link, &:active, &:focus": {
  20048. color: theme.color.defaultText
  20049. },
  20050. "&:focus-visible": {
  20051. background: theme.background.hoverable,
  20052. borderRadius: 8,
  20053. boxShadow: `inset 0 0 0 2px ${theme.color.secondary}`,
  20054. outline: "none"
  20055. },
  20056. "& > *": {
  20057. flex: 1
  20058. },
  20059. "& > svg": {
  20060. marginTop: 3,
  20061. width: 16,
  20062. height: 16,
  20063. marginRight: 10,
  20064. flex: "unset"
  20065. }
  20066. })), Message = ({ href, blank = !0, children, onClick }) => react_default.createElement(StyledMessage, { href, target: blank ? "_blank" : void 0, onClick }, children), MessageWrapper = styled.div(
  20067. ({ isMobile: isMobile2 }) => ({
  20068. width: isMobile2 ? "calc(100vw - 20px)" : 280,
  20069. boxSizing: "border-box",
  20070. borderRadius: 8,
  20071. overflow: "hidden"
  20072. }),
  20073. ({ theme }) => ({
  20074. color: theme.color.dark
  20075. })
  20076. ), SubtleSelect = styled(Select)(({ theme }) => ({
  20077. background: "transparent",
  20078. color: theme.color.defaultText,
  20079. fontSize: theme.typography.size.s1,
  20080. fontWeight: theme.typography.weight.regular
  20081. })), RefIndicator = react_default.memo(
  20082. forwardRef(
  20083. ({ state, ...ref }, forwardedRef) => {
  20084. let api = useStorybookApi(), { isMobile: isMobile2 } = useLayout(), list = useMemo(() => Object.values(ref.index || {}), [ref.index]), componentCount = useMemo(
  20085. () => list.filter((v2) => v2.type === "component").length,
  20086. [list]
  20087. ), leafCount = useMemo(
  20088. () => list.filter((v2) => v2.type === "docs" || v2.type === "story").length,
  20089. [list]
  20090. ), currentVersion = useMemo(() => {
  20091. if (ref.versions)
  20092. return Object.entries(ref.versions).find(([, v2]) => v2 === ref.url)?.[0];
  20093. }, [ref.versions, ref.url]);
  20094. return react_default.createElement(IndicatorPlacement, { ref: forwardedRef }, react_default.createElement(
  20095. PopoverProvider,
  20096. {
  20097. ariaLabel: "Composed Storybook status",
  20098. placement: isMobile2 ? "bottom" : "bottom-start",
  20099. padding: 0,
  20100. 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)))
  20101. },
  20102. react_default.createElement(
  20103. IndicatorClickTarget,
  20104. {
  20105. variant: "ghost",
  20106. padding: "small",
  20107. size: "small",
  20108. "data-action": "toggle-indicator",
  20109. ariaLabel: "Extra actions"
  20110. },
  20111. react_default.createElement(GlobeIcon, null)
  20112. )
  20113. ), ref.versions && Object.keys(ref.versions).length ? react_default.createElement(react_default.Fragment, null, react_default.createElement(
  20114. SubtleSelect,
  20115. {
  20116. padding: "small",
  20117. size: "small",
  20118. ariaLabel: "Version",
  20119. tooltip: "Choose version",
  20120. defaultOptions: currentVersion,
  20121. onSelect: (item) => {
  20122. let href = ref.versions?.[item];
  20123. href && api.changeRefVersion(ref.id, href);
  20124. },
  20125. options: Object.entries(ref.versions).map(([id, href]) => ({
  20126. value: id,
  20127. title: id,
  20128. href
  20129. }))
  20130. },
  20131. "version"
  20132. )) : null);
  20133. }
  20134. )
  20135. ), ReadyMessage = ({ url, componentCount, leafCount }) => {
  20136. let theme = useTheme();
  20137. 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.")));
  20138. }, SourceCodeMessage = ({ url }) => {
  20139. let theme = useTheme();
  20140. 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")));
  20141. }, LoginRequiredMessage = ({ loginUrl, id }) => {
  20142. let theme = useTheme(), open = useCallback(
  20143. (e2) => {
  20144. e2.preventDefault();
  20145. let childWindow = globalWindow3.open(
  20146. loginUrl,
  20147. `storybook_auth_${id}`,
  20148. "resizable,scrollbars"
  20149. ), timer = setInterval(() => {
  20150. childWindow ? childWindow.closed && (clearInterval(timer), document4.location.reload()) : clearInterval(timer);
  20151. }, 1e3);
  20152. },
  20153. [id, loginUrl]
  20154. );
  20155. 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.")));
  20156. }, ReadDocsMessage = () => {
  20157. let theme = useTheme();
  20158. 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.")));
  20159. }, ErrorOccurredMessage = ({ url }) => {
  20160. let theme = useTheme();
  20161. 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.")));
  20162. }, LoadingMessage = ({ url }) => {
  20163. let theme = useTheme();
  20164. 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.")));
  20165. }, PerformanceDegradedMessage = () => {
  20166. let theme = useTheme();
  20167. 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.")));
  20168. };
  20169. // src/manager/components/sidebar/Tree.tsx
  20170. init_react();
  20171. // src/manager/utils/status.tsx
  20172. init_react();
  20173. var import_memoizerific4 = __toESM(require_memoizerific(), 1);
  20174. // src/manager/components/sidebar/IconSymbols.tsx
  20175. init_react();
  20176. var Svg2 = styled.svg`
  20177. position: absolute;
  20178. width: 0;
  20179. height: 0;
  20180. display: inline-block;
  20181. shape-rendering: inherit;
  20182. vertical-align: middle;
  20183. `, 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(
  20184. "path",
  20185. {
  20186. fillRule: "evenodd",
  20187. clipRule: "evenodd",
  20188. 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",
  20189. fill: "currentColor"
  20190. }
  20191. )), react_default.createElement("symbol", { id: COMPONENT_ID }, react_default.createElement(
  20192. "path",
  20193. {
  20194. fillRule: "evenodd",
  20195. clipRule: "evenodd",
  20196. 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",
  20197. fill: "currentColor"
  20198. }
  20199. )), react_default.createElement("symbol", { id: DOCUMENT_ID }, react_default.createElement(
  20200. "path",
  20201. {
  20202. 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",
  20203. fill: "currentColor"
  20204. }
  20205. ), react_default.createElement(
  20206. "path",
  20207. {
  20208. fillRule: "evenodd",
  20209. clipRule: "evenodd",
  20210. 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",
  20211. fill: "currentColor"
  20212. }
  20213. )), react_default.createElement("symbol", { id: STORY_ID }, react_default.createElement(
  20214. "path",
  20215. {
  20216. fillRule: "evenodd",
  20217. clipRule: "evenodd",
  20218. 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",
  20219. fill: "currentColor"
  20220. }
  20221. )), react_default.createElement("symbol", { id: TEST_ID }, react_default.createElement(
  20222. "path",
  20223. {
  20224. fillRule: "evenodd",
  20225. clipRule: "evenodd",
  20226. 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",
  20227. fill: "currentColor"
  20228. }
  20229. )), react_default.createElement("symbol", { id: SUCCESS_ID }, react_default.createElement(
  20230. "path",
  20231. {
  20232. fillRule: "evenodd",
  20233. clipRule: "evenodd",
  20234. 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",
  20235. fill: "currentColor"
  20236. }
  20237. )), react_default.createElement("symbol", { id: ERROR_ID }, react_default.createElement(
  20238. "path",
  20239. {
  20240. fillRule: "evenodd",
  20241. clipRule: "evenodd",
  20242. d: "M7 4a3 3 0 100 6 3 3 0 000-6zM3 7a4 4 0 118 0 4 4 0 01-8 0z",
  20243. fill: "currentColor"
  20244. }
  20245. )), react_default.createElement("symbol", { id: WARNING_ID }, react_default.createElement(
  20246. "path",
  20247. {
  20248. fillRule: "evenodd",
  20249. clipRule: "evenodd",
  20250. 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",
  20251. fill: "currentColor"
  20252. }
  20253. )), 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(
  20254. "path",
  20255. {
  20256. d: "M7 3.5L6.96971 3.68173C6.68873 5.36762 5.36762 6.68873 3.68173 6.96971L3.5 7",
  20257. stroke: "currentColor",
  20258. strokeLinecap: "round",
  20259. fill: "none"
  20260. }
  20261. ), react_default.createElement(
  20262. "path",
  20263. {
  20264. d: "M7 3.5L7.03029 3.68173C7.31127 5.36762 8.63238 6.68873 10.3183 6.96971L10.5 7",
  20265. stroke: "currentColor",
  20266. strokeLinecap: "round",
  20267. fill: "none"
  20268. }
  20269. ), react_default.createElement(
  20270. "path",
  20271. {
  20272. d: "M7 10.5L6.96971 10.3183C6.68873 8.63238 5.36762 7.31127 3.68173 7.03029L3.5 7",
  20273. stroke: "currentColor",
  20274. strokeLinecap: "round",
  20275. fill: "none"
  20276. }
  20277. ), react_default.createElement(
  20278. "path",
  20279. {
  20280. d: "M7 10.5L7.03029 10.3183C7.31127 8.63238 8.63238 7.31127 10.3183 7.03029L10.5 7",
  20281. stroke: "currentColor",
  20282. strokeLinecap: "round",
  20283. fill: "none"
  20284. }
  20285. ), 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;
  20286. // src/manager/utils/status.tsx
  20287. var SmallIcons = styled(CircleIcon)({
  20288. // specificity hack
  20289. "&&&": {
  20290. width: 6,
  20291. height: 6
  20292. }
  20293. }), LoadingIcons = styled(SmallIcons)(({ theme: { animation } }) => ({
  20294. // specificity hack
  20295. animation: `${animation.glow} 1.5s ease-in-out infinite`
  20296. })), statusPriority = [
  20297. "status-value:unknown",
  20298. "status-value:pending",
  20299. "status-value:success",
  20300. "status-value:affected",
  20301. "status-value:modified",
  20302. "status-value:new",
  20303. "status-value:warning",
  20304. "status-value:error"
  20305. ], getStatus = (0, import_memoizerific4.default)(10)((theme, status) => {
  20306. let defaultIconColor = theme.base === "light" ? curriedTransparentize$1(0.3, theme.color.defaultText) : curriedTransparentize$1(0.6, theme.color.defaultText);
  20307. return {
  20308. "status-value:unknown": {
  20309. icon: null,
  20310. iconColor: defaultIconColor,
  20311. textColor: null
  20312. },
  20313. "status-value:pending": {
  20314. icon: react_default.createElement(LoadingIcons, { key: "icon" }),
  20315. iconColor: defaultIconColor,
  20316. textColor: "currentColor"
  20317. },
  20318. "status-value:success": {
  20319. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "success" })),
  20320. iconColor: theme.color.positive,
  20321. textColor: "currentColor"
  20322. },
  20323. "status-value:new": {
  20324. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "new" })),
  20325. iconColor: theme.fgColor.accent,
  20326. textColor: null
  20327. },
  20328. "status-value:modified": {
  20329. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "modified" })),
  20330. iconColor: theme.fgColor.accent,
  20331. textColor: null
  20332. },
  20333. "status-value:affected": {
  20334. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "affected" })),
  20335. iconColor: theme.fgColor.accent,
  20336. textColor: null
  20337. },
  20338. "status-value:warning": {
  20339. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "warning" })),
  20340. iconColor: theme.color.warning,
  20341. textColor: theme.fgColor.warning
  20342. },
  20343. "status-value:error": {
  20344. icon: react_default.createElement("svg", { key: "icon", viewBox: "0 0 14 14", width: "14", height: "14" }, react_default.createElement(UseSymbol, { type: "error" })),
  20345. iconColor: theme.color.negative,
  20346. textColor: theme.fgColor.negative
  20347. }
  20348. }[status];
  20349. });
  20350. function getChangeDetectionStatus(statuses) {
  20351. 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);
  20352. return {
  20353. changeStatus: getMostCriticalStatusValue(changeValues),
  20354. testStatus: getMostCriticalStatusValue(testValues)
  20355. };
  20356. }
  20357. var getMostCriticalStatusValue = (statusValues) => statusPriority.reduce(
  20358. (acc, value) => statusValues.includes(value) ? value : acc,
  20359. "status-value:unknown"
  20360. );
  20361. function getGroupStatus(collapsedData, allStatuses) {
  20362. return Object.values(collapsedData).reduce((acc, item) => {
  20363. if (item.type === "group" || item.type === "component" || item.type === "story") {
  20364. let leafs = getDescendantIds(collapsedData, item.id, !1).map((id) => collapsedData[id]).filter((i2) => i2.type === "story"), combinedStatus = getMostCriticalStatusValue(
  20365. // @ts-expect-error (non strict)
  20366. leafs.flatMap((story) => Object.values(allStatuses[story.id] || {})).map((s2) => s2.value)
  20367. );
  20368. combinedStatus && (acc[item.id] = combinedStatus);
  20369. }
  20370. return acc;
  20371. }, {});
  20372. }
  20373. function getGroupDualStatus(collapsedData, allStatuses) {
  20374. return Object.values(collapsedData).reduce((acc, item) => {
  20375. if (item.type === "group" || item.type === "component" || item.type === "story") {
  20376. let allDescendantStatuses = getDescendantIds(collapsedData, item.id, !1).map((id) => collapsedData[id]).filter((i2) => i2.type === "story").flatMap(
  20377. (story) => Object.values(allStatuses[story.id] || {})
  20378. ), 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);
  20379. acc[item.id] = {
  20380. change: getMostCriticalStatusValue(changeValues),
  20381. test: getMostCriticalStatusValue(testValues)
  20382. };
  20383. }
  20384. return acc;
  20385. }, {});
  20386. }
  20387. // src/manager/components/sidebar/ContextMenu.tsx
  20388. init_react();
  20389. // src/manager/components/sidebar/StatusButton.tsx
  20390. init_react();
  20391. var withStatusColor = ({ theme, status }) => ({
  20392. color: getStatus(theme, status).iconColor ?? void 0
  20393. }), StatusLabel = styled.div(withStatusColor, {
  20394. margin: 3
  20395. }), StyledButton = styled(Button)(
  20396. withStatusColor,
  20397. ({ theme, height, width }) => ({
  20398. transition: "none",
  20399. display: "inline-flex",
  20400. alignItems: "center",
  20401. justifyContent: "center",
  20402. width: width || 28,
  20403. height: height || 28,
  20404. "&:hover": {
  20405. color: theme.color.secondary,
  20406. background: theme.base === "dark" ? curriedDarken$1(0.3, theme.color.secondary) : curriedLighten$1(0.4, theme.color.secondary)
  20407. },
  20408. '[data-selected="true"] &': {
  20409. background: theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary,
  20410. boxShadow: `0 0 5px 5px ${theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary}`,
  20411. "&:hover": {
  20412. background: theme.base === "dark" ? curriedDarken$1(0.1, theme.color.secondary) : theme.color.secondary
  20413. }
  20414. },
  20415. "&:focus": {
  20416. color: theme.color.secondary,
  20417. borderColor: theme.color.secondary,
  20418. outlineOffset: -2,
  20419. "&:not(:focus-visible)": {
  20420. borderColor: "transparent"
  20421. }
  20422. }
  20423. }),
  20424. ({ theme, selectedItem }) => selectedItem && {
  20425. "&:hover": {
  20426. boxShadow: `inset 0 0 0 2px ${theme.color.secondary}`,
  20427. background: "rgba(255, 255, 255, 0.2)"
  20428. }
  20429. }
  20430. ), StatusButton = forwardRef((props, ref) => react_default.createElement(StyledButton, { variant: "ghost", padding: "small", ...props, ref }));
  20431. StatusButton.displayName = "StatusButton";
  20432. // src/manager/components/sidebar/StatusContext.tsx
  20433. init_react();
  20434. var StatusContext = createContext({});
  20435. // src/manager/components/sidebar/ContextMenu.tsx
  20436. var empty = {
  20437. onMouseEnter: () => {
  20438. },
  20439. node: null
  20440. }, FloatingStatusButton = styled(StatusButton)({
  20441. background: "var(--tree-node-background-hover)",
  20442. boxShadow: "0 0 5px 5px var(--tree-node-background-hover)",
  20443. position: "absolute",
  20444. right: 0,
  20445. zIndex: 1,
  20446. "&:focus-visible": {
  20447. outlineOffset: -2
  20448. }
  20449. }), useContextMenu = (context, links, api) => {
  20450. 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({
  20451. children: "Copy story name",
  20452. content: exportName
  20453. }), shortcutKeys = api.getShortcutKeys(), enableShortcuts = !!shortcutKeys, topLinks = useMemo(() => {
  20454. let defaultLinks = [];
  20455. return context && "importPath" in context && context.importPath && defaultLinks.push({
  20456. id: "open-in-editor",
  20457. title: "Open in editor",
  20458. icon: react_default.createElement(EditorIcon, null),
  20459. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.openInEditor }) : null,
  20460. onClick: (e2) => {
  20461. context.importPath && (e2.preventDefault(), api.openInEditor({ file: context.importPath }));
  20462. }
  20463. }), context.type === "story" && defaultLinks.push({
  20464. id: "copy-story-name",
  20465. title: copyText,
  20466. icon: react_default.createElement(CopyIcon, null),
  20467. // TODO: bring this back once we want to add shortcuts for this
  20468. // right:
  20469. // enableShortcuts && shortcutKeys.copyStoryName ? (
  20470. // <Shortcut keys={shortcutKeys.copyStoryName} />
  20471. // ) : null,
  20472. onClick: (e2) => {
  20473. e2.preventDefault(), copyButtonProps.onClick(e2);
  20474. }
  20475. }), defaultLinks;
  20476. }, [api, context, copyText, copyButtonProps, enableShortcuts, shortcutKeys]), handlers = useMemo(() => ({
  20477. onMouseEnter: () => {
  20478. setHoverCount((c2) => c2 + 1);
  20479. },
  20480. onOpen: (event) => {
  20481. event.stopPropagation(), setIsOpen(!0);
  20482. },
  20483. onClose: () => {
  20484. setIsOpen(!1);
  20485. }
  20486. }), []), providerLinks = useMemo(() => {
  20487. let registeredTestProviders = api.getElements(Addon_TypesEnum.experimental_TEST_PROVIDER);
  20488. return hoverCount ? generateTestProviderLinks(registeredTestProviders, context) : [];
  20489. }, [api, context, hoverCount]), shouldRender = !context.refId && (providerLinks.length > 0 || links.length > 0 || topLinks.length > 0), isLeafNode = context.type === "story" || context.type === "docs", itemStatus = useMemo(() => {
  20490. let status = "status-value:unknown";
  20491. if (!context)
  20492. return status;
  20493. if (isLeafNode) {
  20494. let values = Object.values(allStatuses?.[context.id] || {}).map((s2) => s2.value);
  20495. status = getMostCriticalStatusValue(values);
  20496. }
  20497. if (!isLeafNode) {
  20498. let groupValue = groupStatus && groupStatus[context.id];
  20499. status = groupValue === "status-value:success" || groupValue === void 0 ? "status-value:unknown" : groupValue;
  20500. }
  20501. return status;
  20502. }, [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]);
  20503. return useMemo(() => globalThis.CONFIG_TYPE !== "DEVELOPMENT" ? empty : {
  20504. onMouseEnter: handlers.onMouseEnter,
  20505. node: shouldRender ? react_default.createElement(
  20506. PopoverProvider,
  20507. {
  20508. ariaLabel: "Context menu",
  20509. placement: "bottom-end",
  20510. defaultVisible: !1,
  20511. visible: isOpen,
  20512. onVisibleChange: setIsOpen,
  20513. popover: react_default.createElement(LiveContextMenu, { context, links: [...topLinks, ...links] }),
  20514. hasChrome: !0,
  20515. padding: 0
  20516. },
  20517. react_default.createElement(
  20518. FloatingStatusButton,
  20519. {
  20520. "data-displayed": isOpen ? "on" : "off",
  20521. "data-testid": "context-menu",
  20522. ariaLabel: "Open context menu",
  20523. type: "button",
  20524. status: itemStatus,
  20525. onClick: handlers.onOpen
  20526. },
  20527. MenuIcon2
  20528. )
  20529. ) : null
  20530. }, [context, handlers, isOpen, shouldRender, links, topLinks, itemStatus, MenuIcon2]);
  20531. }, LiveContextMenu = ({
  20532. context,
  20533. links,
  20534. ...rest2
  20535. }) => {
  20536. let registeredTestProviders = useStorybookApi().getElements(
  20537. Addon_TypesEnum.experimental_TEST_PROVIDER
  20538. ), providerLinks = generateTestProviderLinks(registeredTestProviders, context), all = (Array.isArray(links[0]) || links.length === 0 ? links : [links]).concat([providerLinks]);
  20539. return react_default.createElement(TooltipLinkList, { ...rest2, links: all });
  20540. };
  20541. function generateTestProviderLinks(registeredTestProviders, context) {
  20542. return Object.entries(registeredTestProviders).map(([testProviderId, state]) => {
  20543. if (!state)
  20544. return null;
  20545. let content = state.sidebarContextMenu?.({ context });
  20546. return content ? {
  20547. id: testProviderId,
  20548. content
  20549. } : null;
  20550. }).filter(Boolean);
  20551. }
  20552. // src/manager/components/sidebar/TreeNode.tsx
  20553. init_react();
  20554. // src/manager/components/sidebar/components/CollapseIcon.tsx
  20555. init_react();
  20556. var CollapseIconWrapper = styled.div(({ theme, isExpanded }) => ({
  20557. width: 8,
  20558. height: 8,
  20559. display: "flex",
  20560. justifyContent: "center",
  20561. alignItems: "center",
  20562. transform: isExpanded ? "rotateZ(90deg)" : "none",
  20563. transition: "transform .1s ease-out",
  20564. color: theme.textMutedColor
  20565. })), 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(
  20566. "path",
  20567. {
  20568. fill: "currentColor",
  20569. fillRule: "evenodd",
  20570. clipRule: "evenodd",
  20571. 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"
  20572. }
  20573. )));
  20574. // src/manager/components/sidebar/TreeNode.tsx
  20575. var TypeIcon2 = styled.svg(
  20576. ({ theme, type }) => ({
  20577. width: 14,
  20578. height: 14,
  20579. flex: "0 0 auto",
  20580. 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"
  20581. })
  20582. ), commonNodeStyles = ({
  20583. theme,
  20584. depth = 0,
  20585. isExpandable = !1
  20586. }) => ({
  20587. flex: 1,
  20588. width: "100%",
  20589. cursor: "pointer",
  20590. display: "flex",
  20591. alignItems: "start",
  20592. textAlign: "left",
  20593. textDecoration: "none",
  20594. border: "none",
  20595. color: "inherit",
  20596. fontSize: `${theme.typography.size.s2}px`,
  20597. fontWeight: "inherit",
  20598. background: "transparent",
  20599. minHeight: 28,
  20600. borderRadius: 4,
  20601. gap: 6,
  20602. paddingLeft: `${(isExpandable ? 8 : 22) + depth * 18}px`,
  20603. paddingTop: 5,
  20604. paddingBottom: 4,
  20605. paddingRight: 6,
  20606. overflowWrap: "break-word",
  20607. wordWrap: "break-word",
  20608. wordBreak: "break-word"
  20609. }), BranchNode = styled.button(commonNodeStyles), LeafNode = styled.a(commonNodeStyles), RootNode = styled.div({
  20610. display: "flex",
  20611. alignItems: "center",
  20612. justifyContent: "space-between",
  20613. marginTop: 16,
  20614. marginBottom: 4,
  20615. "&:first-of-type": {
  20616. marginTop: 0
  20617. }
  20618. }), Wrapper5 = styled.div({
  20619. display: "flex",
  20620. alignItems: "center",
  20621. gap: 6,
  20622. marginTop: 2
  20623. }), GroupNode = react_default.memo(function({
  20624. children,
  20625. isExpanded = !1,
  20626. isExpandable = !1,
  20627. ...props
  20628. }) {
  20629. 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);
  20630. }), ComponentNode = react_default.memo(
  20631. function({
  20632. theme,
  20633. children,
  20634. isExpanded = !1,
  20635. isExpandable = !1,
  20636. isSelected,
  20637. ...props
  20638. }) {
  20639. 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);
  20640. }
  20641. ), DocumentNode = react_default.memo(function({ theme, children, docsMode, ...props }) {
  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: "document" }, react_default.createElement(UseSymbol, { type: "document" }))), children);
  20643. }), StoryBranchNode = react_default.memo(
  20644. function({
  20645. theme,
  20646. children,
  20647. isExpandable = !1,
  20648. isExpanded = !1,
  20649. isSelected,
  20650. ...props
  20651. }) {
  20652. 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);
  20653. }
  20654. ), StoryLeafNode = react_default.memo(function({
  20655. theme,
  20656. children,
  20657. ...props
  20658. }) {
  20659. 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);
  20660. }), TestNode = react_default.memo(function({
  20661. theme,
  20662. children,
  20663. ...props
  20664. }) {
  20665. 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);
  20666. });
  20667. // src/manager/components/sidebar/useExpanded.ts
  20668. init_react();
  20669. // src/manager/keybinding.ts
  20670. var codeToKeyMap = {
  20671. // event.code => event.key
  20672. Space: " ",
  20673. Slash: "/",
  20674. ArrowLeft: "ArrowLeft",
  20675. ArrowUp: "ArrowUp",
  20676. ArrowRight: "ArrowRight",
  20677. ArrowDown: "ArrowDown",
  20678. Escape: "Escape",
  20679. Enter: "Enter"
  20680. }, allFalse = { alt: !1, ctrl: !1, meta: !1, shift: !1 }, matchesModifiers = (modifiers2, event) => {
  20681. let { alt, ctrl, meta, shift: shift2 } = modifiers2 === !1 ? allFalse : modifiers2;
  20682. 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);
  20683. }, matchesKeyCode = (code, event) => event.code ? event.code === code : event.key === codeToKeyMap[code];
  20684. // src/manager/components/sidebar/useExpanded.ts
  20685. var { document: document5 } = scope, initializeExpanded = ({
  20686. refId,
  20687. data,
  20688. initialExpanded,
  20689. highlightedRef,
  20690. rootIds,
  20691. selectedStoryId
  20692. }) => {
  20693. let selectedStory = selectedStoryId && data[selectedStoryId], candidates = [...rootIds];
  20694. return highlightedRef.current?.refId === refId && candidates.push(...getAncestorIds2(data, highlightedRef.current?.itemId)), selectedStory && "children" in selectedStory && selectedStory.children?.length && candidates.push(selectedStoryId), candidates.reduce(
  20695. // @ts-expect-error (non strict)
  20696. (acc, id) => Object.assign(acc, { [id]: id in initialExpanded ? initialExpanded[id] : !0 }),
  20697. {}
  20698. );
  20699. }, noop3 = () => {
  20700. }, useExpanded = ({
  20701. containerRef,
  20702. isBrowsing,
  20703. refId,
  20704. data,
  20705. initialExpanded,
  20706. rootIds,
  20707. highlightedRef,
  20708. setHighlightedItemId,
  20709. selectedStoryId,
  20710. onSelectStoryId
  20711. }) => {
  20712. let api = useStorybookApi(), [expanded, setExpanded] = useReducer(
  20713. (state, { ids, value }) => ids.reduce((acc, id) => Object.assign(acc, { [id]: value }), { ...state }),
  20714. // @ts-expect-error (non strict)
  20715. { refId, data, highlightedRef, rootIds, initialExpanded, selectedStoryId },
  20716. initializeExpanded
  20717. ), getElementByDataItemId = useCallback(
  20718. (id) => containerRef.current?.querySelector(`[data-item-id="${id}"]`),
  20719. [containerRef]
  20720. ), highlightElement = useCallback(
  20721. (element) => {
  20722. setHighlightedItemId(element.getAttribute("data-item-id")), scrollIntoView(element);
  20723. },
  20724. [setHighlightedItemId]
  20725. ), updateExpanded = useCallback(
  20726. ({ ids, value }) => {
  20727. if (setExpanded({ ids, value }), ids.length === 1) {
  20728. let element = containerRef.current?.querySelector(
  20729. `[data-item-id="${ids[0]}"][data-ref-id="${refId}"]`
  20730. );
  20731. element && highlightElement(element);
  20732. }
  20733. },
  20734. [containerRef, highlightElement, refId]
  20735. );
  20736. useEffect(() => {
  20737. setExpanded({ ids: getAncestorIds2(data, selectedStoryId), value: !0 });
  20738. }, [data, selectedStoryId]);
  20739. let collapseAll = useCallback(() => {
  20740. let ids = Object.keys(data).filter((id) => !rootIds.includes(id));
  20741. setExpanded({ ids, value: !1 });
  20742. }, [data, rootIds]), expandAll = useCallback(() => {
  20743. setExpanded({ ids: Object.keys(data), value: !0 });
  20744. }, [data]);
  20745. return useEffect(() => api ? (api.on(STORIES_COLLAPSE_ALL, collapseAll), api.on(STORIES_EXPAND_ALL, expandAll), () => {
  20746. api.off(STORIES_COLLAPSE_ALL, collapseAll), api.off(STORIES_EXPAND_ALL, expandAll);
  20747. }) : noop3, [api, collapseAll, expandAll]), useEffect(() => {
  20748. let menuElement = document5.getElementById("storybook-explorer-menu"), navigateTree = throttle((event) => {
  20749. let highlightedItemId = highlightedRef.current?.refId === refId && highlightedRef.current?.itemId;
  20750. if (!isBrowsing || !containerRef.current || !highlightedItemId || event.repeat || !matchesModifiers(!1, event))
  20751. return;
  20752. let isEnter = matchesKeyCode("Enter", event), isSpace = matchesKeyCode("Space", event), isArrowLeft = matchesKeyCode("ArrowLeft", event), isArrowRight = matchesKeyCode("ArrowRight", event);
  20753. if (!(isEnter || isSpace || isArrowLeft || isArrowRight))
  20754. return;
  20755. let highlightedElement = getElementByDataItemId(highlightedItemId);
  20756. if (!highlightedElement || highlightedElement.getAttribute("data-ref-id") !== refId)
  20757. return;
  20758. let target = event.target;
  20759. if (!isAncestor(menuElement, target) && !isAncestor(target, menuElement))
  20760. return;
  20761. if (target.hasAttribute("data-action")) {
  20762. if (isEnter || isSpace)
  20763. return;
  20764. target.blur();
  20765. }
  20766. let type = highlightedElement.getAttribute("data-nodetype");
  20767. type && (isEnter || isSpace) && ["component", "story", "document", "test"].includes(type) && onSelectStoryId(highlightedItemId);
  20768. let isExpanded = highlightedElement.getAttribute("aria-expanded");
  20769. if (isArrowLeft) {
  20770. if (isExpanded === "true") {
  20771. setExpanded({ ids: [highlightedItemId], value: !1 });
  20772. return;
  20773. }
  20774. let parentId = highlightedElement.getAttribute("data-parent-id"), parentElement = parentId && getElementByDataItemId(parentId);
  20775. if (parentElement && parentElement.getAttribute("data-highlightable") === "true") {
  20776. highlightElement(parentElement);
  20777. return;
  20778. }
  20779. setExpanded({ ids: getDescendantIds(data, highlightedItemId, !0), value: !1 });
  20780. return;
  20781. }
  20782. isArrowRight && (isExpanded === "false" ? updateExpanded({ ids: [highlightedItemId], value: !0 }) : isExpanded === "true" && updateExpanded({ ids: getDescendantIds(data, highlightedItemId, !0), value: !0 }));
  20783. }, 60);
  20784. return document5.addEventListener("keydown", navigateTree), () => document5.removeEventListener("keydown", navigateTree);
  20785. }, [
  20786. containerRef,
  20787. isBrowsing,
  20788. refId,
  20789. data,
  20790. highlightedRef,
  20791. setHighlightedItemId,
  20792. onSelectStoryId
  20793. ]), [expanded, updateExpanded];
  20794. };
  20795. // src/manager/components/sidebar/Tree.tsx
  20796. var CollapseButton = styled(Button)(({ theme }) => ({
  20797. fontSize: `${theme.typography.size.s1 - 1}px`,
  20798. fontWeight: theme.typography.weight.bold,
  20799. letterSpacing: "0.16em",
  20800. textTransform: "uppercase",
  20801. color: theme.textMutedColor,
  20802. padding: "0 8px"
  20803. })), LeafNodeStyleWrapper = styled.div(({ theme }) => ({
  20804. position: "relative",
  20805. display: "flex",
  20806. justifyContent: "space-between",
  20807. alignItems: "flex-start",
  20808. color: theme.color.defaultText,
  20809. background: "transparent",
  20810. minHeight: 28,
  20811. borderRadius: 4,
  20812. overflow: "hidden",
  20813. "--tree-node-background-hover": theme.background.content,
  20814. [MEDIA_DESKTOP_BREAKPOINT]: {
  20815. "--tree-node-background-hover": theme.background.app
  20816. },
  20817. "&:hover, &:focus": {
  20818. "--tree-node-background-hover": theme.background.hoverable,
  20819. background: "var(--tree-node-background-hover)",
  20820. outline: "none"
  20821. },
  20822. '& [data-displayed="off"]': {
  20823. visibility: "hidden"
  20824. },
  20825. '&:hover [data-displayed="off"]': {
  20826. visibility: "visible"
  20827. },
  20828. '& [data-displayed="on"] + *': {
  20829. visibility: "hidden"
  20830. },
  20831. '&:hover [data-displayed="off"] + *': {
  20832. visibility: "hidden"
  20833. },
  20834. '&[data-selected="true"]': {
  20835. color: theme.color.lightest,
  20836. background: theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary,
  20837. fontWeight: theme.typography.weight.bold,
  20838. "&&:hover, &&:focus": {
  20839. background: theme.base === "dark" ? curriedDarken$1(0.18, theme.color.secondary) : theme.color.secondary
  20840. },
  20841. svg: { color: theme.color.lightest }
  20842. },
  20843. a: { color: "currentColor" }
  20844. })), SkipToContentLink = styled(Button)(({ theme }) => ({
  20845. display: "none",
  20846. "@media (min-width: 600px)": {
  20847. display: "block",
  20848. fontSize: "10px",
  20849. overflow: "hidden",
  20850. width: 1,
  20851. height: "20px",
  20852. boxSizing: "border-box",
  20853. opacity: 0,
  20854. padding: 0,
  20855. "&:focus": {
  20856. opacity: 1,
  20857. padding: "5px 10px",
  20858. background: "white",
  20859. color: theme.color.secondary,
  20860. width: "auto"
  20861. }
  20862. }
  20863. })), StatusSlots = styled.div({
  20864. display: "flex",
  20865. alignItems: "center"
  20866. });
  20867. var getStatusLabel = (status) => status.split(":")[1].replace(/^./, (char) => char.toUpperCase()), Node2 = react_default.memo(function(props) {
  20868. let {
  20869. item,
  20870. statuses,
  20871. groupDualStatus,
  20872. refId,
  20873. docsMode,
  20874. isOrphan,
  20875. isDisplayed,
  20876. isSelected,
  20877. isFullyExpanded,
  20878. setFullyExpanded,
  20879. isExpanded,
  20880. setExpanded,
  20881. onSelectStoryId,
  20882. api,
  20883. isModifiedFilterActive
  20884. } = 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]) => ({
  20885. id: typeId,
  20886. title: status.title,
  20887. description: status.description,
  20888. "aria-label": `Test status for ${status.title}: ${status.value}`,
  20889. icon: getStatus(theme, status.value).icon,
  20890. onClick: () => {
  20891. onSelectStoryId(item.id), internal_fullStatusStore.selectStatuses([status]);
  20892. }
  20893. })) : [], [item.id, item.type, onSelectStoryId, statuses, theme]), contextMenu = useContextMenu(item, statusLinks, api);
  20894. refId !== "storybook_internal" && (contextMenu = { node: null, onMouseEnter: () => {
  20895. } });
  20896. let id = createId(item.id, refId);
  20897. if (item.type === "story" && !("children" in item && item.children) && (!("subtype" in item) || item.subtype !== "test") || item.type === "docs") {
  20898. 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);
  20899. return react_default.createElement(
  20900. LeafNodeStyleWrapper,
  20901. {
  20902. key: id,
  20903. className: "sidebar-item",
  20904. "data-selected": isSelected,
  20905. "data-ref-id": refId,
  20906. "data-item-id": item.id,
  20907. "data-parent-id": item.parent,
  20908. "data-nodetype": item.type === "docs" ? "document" : "story",
  20909. "data-highlightable": isDisplayed,
  20910. onMouseEnter: contextMenu.onMouseEnter
  20911. },
  20912. react_default.createElement(
  20913. LeafNode3,
  20914. {
  20915. style: isSelected ? {} : { color: textColor },
  20916. href: getLink(item, refId),
  20917. id,
  20918. depth: isOrphan ? item.depth : item.depth - 1,
  20919. onClick: (event) => {
  20920. event.preventDefault(), onSelectStoryId(item.id), isMobile2 && setMobileMenuOpen(!1);
  20921. },
  20922. ...item.type === "docs" && { docsMode }
  20923. },
  20924. item.renderLabel?.(item, api) || item.name
  20925. ),
  20926. isSelected && react_default.createElement(SkipToContentLink, { asChild: !0, ariaLabel: !1 }, react_default.createElement("a", { href: "#storybook-preview-wrapper" }, "Skip to content")),
  20927. contextMenu.node,
  20928. leafChangeIcon && testIcon ? react_default.createElement(StatusSlots, null, react_default.createElement(
  20929. StatusButton,
  20930. {
  20931. ariaLabel: `Change status: ${getStatusLabel(changeStatus)}`,
  20932. "data-testid": "tree-change-status-button",
  20933. type: "button",
  20934. status: changeStatus,
  20935. selectedItem: isSelected
  20936. },
  20937. leafChangeIcon
  20938. ), react_default.createElement(
  20939. StatusButton,
  20940. {
  20941. ariaLabel: `Test status: ${getStatusLabel(testStatus)}`,
  20942. "data-testid": "tree-status-button",
  20943. type: "button",
  20944. status: testStatus,
  20945. selectedItem: isSelected
  20946. },
  20947. testIcon
  20948. )) : leafChangeIcon ? react_default.createElement(
  20949. StatusButton,
  20950. {
  20951. ariaLabel: `Change status: ${getStatusLabel(changeStatus)}`,
  20952. "data-testid": "tree-change-status-button",
  20953. type: "button",
  20954. status: changeStatus,
  20955. selectedItem: isSelected
  20956. },
  20957. leafChangeIcon
  20958. ) : testIcon ? react_default.createElement(
  20959. StatusButton,
  20960. {
  20961. ariaLabel: `Test status: ${getStatusLabel(testStatus)}`,
  20962. "data-testid": "tree-status-button",
  20963. type: "button",
  20964. status: testStatus,
  20965. selectedItem: isSelected
  20966. },
  20967. testIcon
  20968. ) : null
  20969. );
  20970. }
  20971. if (item.type === "root")
  20972. return react_default.createElement(
  20973. RootNode,
  20974. {
  20975. key: id,
  20976. id,
  20977. className: "sidebar-subheading",
  20978. "data-ref-id": refId,
  20979. "data-item-id": item.id,
  20980. "data-nodetype": "root"
  20981. },
  20982. react_default.createElement(
  20983. CollapseButton,
  20984. {
  20985. variant: "ghost",
  20986. ariaLabel: isExpanded ? "Collapse" : "Expand",
  20987. "data-action": "collapse-root",
  20988. onClick: (event) => {
  20989. event.preventDefault(), setExpanded({ ids: [item.id], value: !isExpanded });
  20990. },
  20991. "aria-expanded": isExpanded
  20992. },
  20993. react_default.createElement(CollapseIcon2, { isExpanded }),
  20994. item.renderLabel?.(item, api) || item.name
  20995. ),
  20996. isExpanded && react_default.createElement(
  20997. Button,
  20998. {
  20999. padding: "small",
  21000. variant: "ghost",
  21001. className: "sidebar-subheading-action",
  21002. ariaLabel: isFullyExpanded ? "Collapse all" : "Expand all",
  21003. "data-action": "expand-all",
  21004. "data-expanded": isFullyExpanded,
  21005. onClick: (event) => {
  21006. event.preventDefault(), setFullyExpanded();
  21007. }
  21008. },
  21009. isFullyExpanded ? react_default.createElement(CollapseIcon, null) : react_default.createElement(ExpandAltIcon, null)
  21010. )
  21011. );
  21012. if (item.type === "component" || item.type === "group" || item.type === "story" && "children" in item && item.children) {
  21013. let { children = [] } = item, BranchNode2 = { component: ComponentNode, group: GroupNode, story: StoryBranchNode }[item.type], { changeStatus: localChange, testStatus: localTest } = getChangeDetectionStatus(
  21014. statuses || {}
  21015. ), groupDual = groupDualStatus?.[item.id] || {
  21016. change: "status-value:unknown",
  21017. test: "status-value:unknown"
  21018. }, 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;
  21019. return react_default.createElement(
  21020. LeafNodeStyleWrapper,
  21021. {
  21022. key: id,
  21023. className: "sidebar-item",
  21024. "data-selected": isSelected,
  21025. "data-ref-id": refId,
  21026. "data-item-id": item.id,
  21027. "data-parent-id": item.parent,
  21028. "data-nodetype": item.type,
  21029. "data-highlightable": isDisplayed,
  21030. onMouseEnter: contextMenu.onMouseEnter
  21031. },
  21032. react_default.createElement(
  21033. BranchNode2,
  21034. {
  21035. id,
  21036. style: color2 && !isSelected ? { color: color2 } : {},
  21037. "aria-controls": children.join(" "),
  21038. "aria-expanded": isExpanded,
  21039. depth: isOrphan ? item.depth : item.depth - 1,
  21040. isExpandable: children.length > 0,
  21041. isExpanded,
  21042. onClick: (event) => {
  21043. 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 });
  21044. },
  21045. onMouseEnter: () => {
  21046. (item.type === "component" || item.type === "story") && api.emit(PRELOAD_ENTRIES, {
  21047. ids: [children[0]],
  21048. options: { target: refId }
  21049. });
  21050. }
  21051. },
  21052. item.renderLabel?.(item, api) || item.name
  21053. ),
  21054. isSelected && react_default.createElement(SkipToContentLink, { asChild: !0, ariaLabel: !1 }, react_default.createElement("a", { href: "#storybook-preview-wrapper" }, "Skip to content")),
  21055. contextMenu.node,
  21056. branchChangeIcon && branchTestIcon ? react_default.createElement(StatusSlots, null, react_default.createElement(
  21057. StatusButton,
  21058. {
  21059. ariaLabel: `Change status: ${getStatusLabel(branchChange)}`,
  21060. "data-testid": "tree-change-status-button",
  21061. type: "button",
  21062. status: branchChange,
  21063. selectedItem: isSelected
  21064. },
  21065. branchChangeIcon
  21066. ), react_default.createElement(
  21067. StatusButton,
  21068. {
  21069. ariaLabel: `Test status: ${getStatusLabel(branchTest)}`,
  21070. "data-testid": "tree-status-button",
  21071. type: "button",
  21072. status: branchTest,
  21073. selectedItem: isSelected
  21074. },
  21075. branchTestIcon
  21076. )) : branchChangeIcon ? react_default.createElement(
  21077. StatusButton,
  21078. {
  21079. ariaLabel: `Change status: ${getStatusLabel(branchChange)}`,
  21080. "data-testid": "tree-change-status-button",
  21081. type: "button",
  21082. status: branchChange,
  21083. selectedItem: isSelected
  21084. },
  21085. branchChangeIcon
  21086. ) : branchTestIcon ? react_default.createElement(
  21087. StatusButton,
  21088. {
  21089. ariaLabel: `Test status: ${getStatusLabel(branchTest)}`,
  21090. "data-testid": "tree-status-button",
  21091. type: "button",
  21092. status: branchTest,
  21093. selectedItem: isSelected
  21094. },
  21095. branchTestIcon
  21096. ) : null
  21097. );
  21098. }
  21099. 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(
  21100. Object.entries(statuses || {}).filter(
  21101. ([, status]) => status.typeId !== CHANGE_DETECTION_STATUS_TYPE_ID || status.value === "status-value:new"
  21102. )
  21103. ), leafStatus = getMostCriticalStatusValue(Object.values(leafStatuses).map((s2) => s2.value)), { icon: leafIcon, textColor: leafColor } = getStatus(theme, leafStatus), leafStatusButton = leafIcon ? react_default.createElement(
  21104. StatusButton,
  21105. {
  21106. ariaLabel: `Status: ${getStatusLabel(leafStatus)}`,
  21107. "data-testid": "tree-status-button",
  21108. role: "status",
  21109. type: "button",
  21110. status: leafStatus,
  21111. selectedItem: isSelected
  21112. },
  21113. leafIcon
  21114. ) : null;
  21115. return react_default.createElement(
  21116. LeafNodeStyleWrapper,
  21117. {
  21118. key: id,
  21119. className: "sidebar-item",
  21120. "data-selected": isSelected,
  21121. "data-ref-id": refId,
  21122. "data-item-id": item.id,
  21123. "data-parent-id": item.parent,
  21124. "data-nodetype": nodeType,
  21125. "data-highlightable": isDisplayed,
  21126. onMouseEnter: contextMenu.onMouseEnter
  21127. },
  21128. react_default.createElement(
  21129. LeafNode2,
  21130. {
  21131. style: leafColor && !isSelected ? { color: leafColor } : {},
  21132. href: getLink(item, refId),
  21133. id,
  21134. depth: isOrphan ? item.depth : item.depth - 1,
  21135. onClick: (event) => {
  21136. event.preventDefault(), onSelectStoryId(item.id), isMobile2 && setMobileMenuOpen(!1);
  21137. }
  21138. },
  21139. item.renderLabel?.(item, api) || item.name
  21140. ),
  21141. isSelected && react_default.createElement(SkipToContentLink, { ariaLabel: !1, asChild: !0 }, react_default.createElement("a", { href: "#storybook-preview-wrapper" }, "Skip to content")),
  21142. contextMenu.node,
  21143. leafStatusButton
  21144. );
  21145. }), Root = react_default.memo(function({
  21146. setExpanded,
  21147. isFullyExpanded,
  21148. expandableDescendants,
  21149. ...props
  21150. }) {
  21151. let setFullyExpanded = useCallback(
  21152. () => setExpanded({ ids: expandableDescendants, value: !isFullyExpanded }),
  21153. [setExpanded, isFullyExpanded, expandableDescendants]
  21154. );
  21155. return react_default.createElement(
  21156. Node2,
  21157. {
  21158. ...props,
  21159. setExpanded,
  21160. isFullyExpanded,
  21161. setFullyExpanded
  21162. }
  21163. );
  21164. }), Tree = react_default.memo(function({
  21165. isBrowsing,
  21166. refId,
  21167. data,
  21168. allStatuses,
  21169. docsMode,
  21170. highlightedRef,
  21171. setHighlightedItemId,
  21172. selectedStoryId,
  21173. onSelectStoryId
  21174. }) {
  21175. let containerRef = useRef(null), api = useStorybookApi(), isModifiedFilterActive = (useStorybookState().includedStatusFilters ?? []).includes("status-value:modified"), [rootIds, orphanIds, initialExpanded] = useMemo(
  21176. () => Object.keys(data).reduce(
  21177. (acc, id) => {
  21178. let item = data[id];
  21179. return item.type === "root" ? acc[0].push(id) : item.parent || acc[1].push(id), item.type === "root" && item.startCollapsed && (acc[2][id] = !1), acc;
  21180. },
  21181. [[], [], {}]
  21182. ),
  21183. [data]
  21184. ), { expandableDescendants } = useMemo(() => [...orphanIds, ...rootIds].reduce(
  21185. (acc, nodeId) => (acc.expandableDescendants[nodeId] = getDescendantIds(data, nodeId, !1).filter(
  21186. (d2) => !["story", "docs"].includes(data[d2].type)
  21187. ), acc),
  21188. { orphansFirst: [], expandableDescendants: {} }
  21189. ), [data, rootIds, orphanIds]), singleStoryComponentIds = useMemo(() => Object.keys(data).filter((id) => {
  21190. let entry = data[id];
  21191. if (entry.type !== "component")
  21192. return !1;
  21193. let { children = [], name } = entry;
  21194. if (children.length !== 1)
  21195. return !1;
  21196. let onlyChild = data[children[0]];
  21197. return onlyChild.type === "docs" ? !0 : onlyChild.type === "story" && onlyChild.subtype === "story" ? isStoryHoistable(onlyChild.name, name) : !1;
  21198. }), [data]), collapsedItems = useMemo(
  21199. () => Object.keys(data).filter((id) => !singleStoryComponentIds.includes(id)),
  21200. [data, singleStoryComponentIds]
  21201. ), collapsedData = useMemo(() => singleStoryComponentIds.reduce(
  21202. (acc, id) => {
  21203. let { children, parent, name } = data[id], [childId] = children;
  21204. if (parent) {
  21205. let siblings = [...data[parent].children];
  21206. siblings[siblings.indexOf(id)] = childId, acc[parent] = { ...data[parent], children: siblings };
  21207. }
  21208. return acc[childId] = {
  21209. ...data[childId],
  21210. name,
  21211. parent,
  21212. depth: data[childId].depth - 1
  21213. }, acc;
  21214. },
  21215. { ...data }
  21216. ), [data, singleStoryComponentIds]), ancestry = useMemo(() => collapsedItems.reduce(
  21217. (acc, id) => Object.assign(acc, { [id]: getAncestorIds2(collapsedData, id) }),
  21218. {}
  21219. ), [collapsedItems, collapsedData]), [expanded, setExpanded] = useExpanded({
  21220. // @ts-expect-error (non strict)
  21221. containerRef,
  21222. isBrowsing,
  21223. refId,
  21224. data: collapsedData,
  21225. initialExpanded,
  21226. rootIds,
  21227. highlightedRef,
  21228. setHighlightedItemId,
  21229. selectedStoryId,
  21230. onSelectStoryId
  21231. }), groupStatus = useMemo(
  21232. () => getGroupStatus(collapsedData, allStatuses ?? {}),
  21233. [collapsedData, allStatuses]
  21234. ), groupDualStatus = useMemo(
  21235. () => getGroupDualStatus(collapsedData, allStatuses ?? {}),
  21236. [collapsedData, allStatuses]
  21237. ), treeItems = useMemo(() => collapsedItems.map((itemId) => {
  21238. let item = collapsedData[itemId], id = createId(itemId, refId);
  21239. if (item.type === "root") {
  21240. let descendants = expandableDescendants[item.id], isFullyExpanded = descendants.every((d2) => expanded[d2]);
  21241. return (
  21242. // @ts-expect-error (TODO)
  21243. react_default.createElement(
  21244. Root,
  21245. {
  21246. api,
  21247. key: id,
  21248. item,
  21249. refId,
  21250. collapsedData,
  21251. isOrphan: !1,
  21252. isDisplayed: !0,
  21253. isSelected: selectedStoryId === itemId,
  21254. isExpanded: !!expanded[itemId],
  21255. setExpanded,
  21256. isFullyExpanded,
  21257. expandableDescendants: descendants,
  21258. onSelectStoryId,
  21259. isModifiedFilterActive
  21260. }
  21261. )
  21262. );
  21263. }
  21264. let isDisplayed = !item.parent || ancestry[itemId].every((a2) => expanded[a2]);
  21265. return isDisplayed === !1 ? null : react_default.createElement(
  21266. Node2,
  21267. {
  21268. api,
  21269. collapsedData,
  21270. key: id,
  21271. item,
  21272. statuses: allStatuses?.[itemId] ?? {},
  21273. groupDualStatus,
  21274. refId,
  21275. docsMode,
  21276. isOrphan: orphanIds.some((oid) => itemId === oid || itemId.startsWith(`${oid}-`)),
  21277. isDisplayed,
  21278. isSelected: selectedStoryId === itemId,
  21279. isExpanded: !!expanded[itemId],
  21280. setExpanded,
  21281. onSelectStoryId,
  21282. isModifiedFilterActive
  21283. }
  21284. );
  21285. }), [
  21286. ancestry,
  21287. api,
  21288. collapsedData,
  21289. collapsedItems,
  21290. docsMode,
  21291. expandableDescendants,
  21292. expanded,
  21293. groupDualStatus,
  21294. isModifiedFilterActive,
  21295. onSelectStoryId,
  21296. orphanIds,
  21297. refId,
  21298. selectedStoryId,
  21299. setExpanded,
  21300. allStatuses
  21301. ]);
  21302. return react_default.createElement(StatusContext.Provider, { value: { data, allStatuses, groupStatus } }, react_default.createElement("div", { ref: containerRef }, treeItems));
  21303. });
  21304. // src/manager/components/sidebar/Refs.tsx
  21305. var Wrapper6 = styled.div(({ isMain }) => ({
  21306. position: "relative",
  21307. marginTop: isMain ? void 0 : 0
  21308. })), RefHead = styled.div(({ theme }) => ({
  21309. fontWeight: theme.typography.weight.bold,
  21310. fontSize: theme.typography.size.s2,
  21311. // Similar to ListItem.tsx
  21312. textDecoration: "none",
  21313. lineHeight: "16px",
  21314. display: "flex",
  21315. alignItems: "center",
  21316. justifyContent: "space-between",
  21317. background: "transparent",
  21318. width: "100%",
  21319. marginTop: 20,
  21320. paddingTop: 16,
  21321. paddingBottom: 12,
  21322. borderTop: `1px solid ${theme.appBorderColor}`,
  21323. color: theme.color.defaultText
  21324. })), RefTitle = styled.div({
  21325. textOverflow: "ellipsis",
  21326. whiteSpace: "nowrap",
  21327. flex: 1,
  21328. overflow: "hidden",
  21329. marginLeft: 2
  21330. }), CollapseButton2 = styled.button(({ theme }) => ({
  21331. all: "unset",
  21332. display: "flex",
  21333. padding: "0px 8px",
  21334. gap: 6,
  21335. alignItems: "center",
  21336. cursor: "pointer",
  21337. overflow: "hidden",
  21338. "&:focus": {
  21339. borderColor: theme.color.secondary,
  21340. "span:first-of-type": {
  21341. borderLeftColor: theme.color.secondary
  21342. }
  21343. }
  21344. })), Ref = react_default.memo(function(props) {
  21345. let storybookState = useStorybookState(), api = useStorybookApi(), {
  21346. filteredIndex: index,
  21347. id: refId,
  21348. title: title2 = refId,
  21349. isLoading: isLoadingMain,
  21350. isBrowsing,
  21351. hasEntries,
  21352. selectedStoryId,
  21353. highlightedRef,
  21354. setHighlighted,
  21355. loginUrl,
  21356. type,
  21357. expanded = !0,
  21358. indexError,
  21359. previewInitialized,
  21360. allStatuses
  21361. } = 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);
  21362. useEffect(() => {
  21363. index && selectedStoryId && index[selectedStoryId] && setExpanded(!0);
  21364. }, [index, selectedStoryId]);
  21365. let handleClick = useCallback(() => setExpanded((value) => !value), []), setHighlightedItemId = useCallback(
  21366. (itemId) => setHighlighted({ itemId, refId }),
  21367. [setHighlighted, refId]
  21368. ), onSelectStoryId = useCallback(
  21369. (storyId) => api?.selectStory(storyId, void 0, { ref: isMain ? void 0 : refId }),
  21370. [api, isMain, refId]
  21371. );
  21372. return react_default.createElement(react_default.Fragment, null, isMain || react_default.createElement(
  21373. RefHead,
  21374. {
  21375. "aria-label": `${isExpanded ? "Hide" : "Show"} ${title2} stories`,
  21376. "aria-expanded": isExpanded
  21377. },
  21378. react_default.createElement(CollapseButton2, { "data-action": "collapse-ref", onClick: handleClick }, react_default.createElement(CollapseIcon2, { isExpanded }), react_default.createElement(RefTitle, { title: title2 }, title2)),
  21379. react_default.createElement(RefIndicator, { ...props, state, ref: indicatorRef })
  21380. ), 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(
  21381. EmptyBlock,
  21382. {
  21383. isMain,
  21384. hasEntries,
  21385. activeFilterCount
  21386. }
  21387. ), state === "ready" && react_default.createElement(
  21388. Tree,
  21389. {
  21390. allStatuses,
  21391. isBrowsing,
  21392. isMain,
  21393. refId,
  21394. data: index,
  21395. docsMode: storybookState.docsOptions.docsMode,
  21396. selectedStoryId,
  21397. onSelectStoryId,
  21398. highlightedRef,
  21399. setHighlightedItemId
  21400. }
  21401. )));
  21402. });
  21403. // src/manager/components/sidebar/useHighlighted.ts
  21404. init_react();
  21405. var { document: document6, window: globalWindow4 } = scope, fromSelection = (selection) => selection ? { itemId: selection.storyId, refId: selection.refId } : null, scrollToSelector = (selector, options2 = {}, _attempt = 1) => {
  21406. let { containerRef, center = !1, attempts = 3, delay: delay2 = 500 } = options2, element = (containerRef ? containerRef.current : document6)?.querySelector(selector);
  21407. element ? scrollIntoView(element, center) : _attempt <= attempts && setTimeout(scrollToSelector, delay2, selector, options2, _attempt + 1);
  21408. }, useHighlighted = ({
  21409. containerRef,
  21410. isLoading,
  21411. isBrowsing,
  21412. selected
  21413. }) => {
  21414. let initialHighlight = fromSelection(selected), highlightedRef = useRef(initialHighlight), [highlighted, setHighlighted] = useState(initialHighlight), api = useStorybookApi(), updateHighlighted = useCallback(
  21415. (highlight) => {
  21416. highlightedRef.current = highlight, setHighlighted(highlight);
  21417. },
  21418. [highlightedRef]
  21419. ), highlightElement = useCallback(
  21420. (element, center = !1) => {
  21421. let itemId = element.getAttribute("data-item-id"), refId = element.getAttribute("data-ref-id");
  21422. !itemId || !refId || (updateHighlighted({ itemId, refId }), scrollIntoView(element, center));
  21423. },
  21424. [updateHighlighted]
  21425. );
  21426. return useEffect(() => {
  21427. let highlight = fromSelection(selected);
  21428. updateHighlighted(highlight), highlight && scrollToSelector(`[data-item-id="${highlight.itemId}"][data-ref-id="${highlight.refId}"]`, {
  21429. containerRef,
  21430. center: !0
  21431. });
  21432. }, [containerRef, selected, updateHighlighted]), useEffect(() => {
  21433. let menuElement = document6.getElementById("storybook-explorer-menu"), lastRequestId, navigateTree = (event) => {
  21434. if (isLoading || !isBrowsing || !containerRef.current || !matchesModifiers(!1, event))
  21435. return;
  21436. let isArrowUp = matchesKeyCode("ArrowUp", event), isArrowDown = matchesKeyCode("ArrowDown", event);
  21437. if (!(isArrowUp || isArrowDown))
  21438. return;
  21439. let requestId = globalWindow4.requestAnimationFrame(() => {
  21440. globalWindow4.cancelAnimationFrame(lastRequestId), lastRequestId = requestId;
  21441. let target = event.target;
  21442. if (!isAncestor(menuElement, target) && !isAncestor(target, menuElement))
  21443. return;
  21444. target.hasAttribute("data-action") && target.blur();
  21445. let highlightable = Array.from(
  21446. containerRef.current?.querySelectorAll("[data-highlightable=true]") || []
  21447. ), currentIndex = highlightable.findIndex(
  21448. (el) => el.getAttribute("data-item-id") === highlightedRef.current?.itemId && el.getAttribute("data-ref-id") === highlightedRef.current?.refId
  21449. ), nextIndex = cycle2(highlightable, currentIndex, isArrowUp ? -1 : 1), didRunAround = isArrowUp ? nextIndex === highlightable.length - 1 : nextIndex === 0;
  21450. if (highlightElement(highlightable[nextIndex], didRunAround), highlightable[nextIndex].getAttribute("data-nodetype") === "component") {
  21451. let { itemId, refId } = highlightedRef.current, item = api.resolveStory(itemId, refId === "storybook_internal" ? void 0 : refId);
  21452. item?.type === "component" && api.emit(PRELOAD_ENTRIES, {
  21453. ids: [item.children[0]],
  21454. options: { target: refId }
  21455. });
  21456. }
  21457. });
  21458. };
  21459. return document6.addEventListener("keydown", navigateTree), () => document6.removeEventListener("keydown", navigateTree);
  21460. }, [api, containerRef, isLoading, isBrowsing, highlightedRef, highlightElement]), [highlighted, updateHighlighted, highlightedRef];
  21461. };
  21462. // src/manager/components/sidebar/Explorer.tsx
  21463. var Explorer = react_default.memo(function({
  21464. hasEntries,
  21465. isLoading,
  21466. isBrowsing,
  21467. isHidden,
  21468. dataset,
  21469. selected,
  21470. ...restProps
  21471. }) {
  21472. let containerRef = useRef(null), [highlighted, setHighlighted, highlightedRef] = useHighlighted({
  21473. containerRef,
  21474. isLoading,
  21475. isBrowsing,
  21476. selected
  21477. }), { landmarkProps } = useLandmark(
  21478. { "aria-labelledby": "storybook-explorer-tree-heading", role: "navigation" },
  21479. containerRef
  21480. );
  21481. return react_default.createElement(
  21482. "nav",
  21483. {
  21484. hidden: isHidden || void 0,
  21485. "aria-hidden": isHidden || void 0,
  21486. className: isBrowsing ? void 0 : "sb-sr-only",
  21487. ref: containerRef,
  21488. id: "storybook-explorer-tree",
  21489. "data-highlighted-ref-id": highlighted?.refId,
  21490. "data-highlighted-item-id": highlighted?.itemId,
  21491. ...landmarkProps,
  21492. ...restProps
  21493. },
  21494. react_default.createElement("h2", { id: "storybook-explorer-tree-heading", className: "sb-sr-only" }, "Stories"),
  21495. highlighted && react_default.createElement(HighlightStyles, { ...highlighted }),
  21496. dataset.entries.map(([refId, ref]) => react_default.createElement(
  21497. Ref,
  21498. {
  21499. ...ref,
  21500. key: refId,
  21501. isLoading,
  21502. isBrowsing,
  21503. hasEntries,
  21504. selectedStoryId: selected?.refId === ref.id ? selected.storyId : null,
  21505. highlightedRef,
  21506. setHighlighted
  21507. }
  21508. ))
  21509. );
  21510. });
  21511. // src/manager/components/sidebar/Heading.tsx
  21512. init_react();
  21513. // src/manager/components/sidebar/Brand.tsx
  21514. init_react();
  21515. var StorybookLogoStyled = styled(StorybookLogo)(({ theme }) => ({
  21516. width: "auto",
  21517. height: "22px !important",
  21518. display: "block",
  21519. color: theme.base === "light" ? theme.color.defaultText : theme.color.lightest
  21520. })), Img2 = styled.img({
  21521. display: "block",
  21522. maxWidth: "150px !important",
  21523. maxHeight: "100px"
  21524. }), LogoLink = styled.a(({ theme }) => ({
  21525. display: "inline-flex",
  21526. alignItems: "center",
  21527. height: "100%",
  21528. margin: "-3px -4px",
  21529. padding: "2px 3px",
  21530. border: "1px solid transparent",
  21531. borderRadius: 3,
  21532. color: "inherit",
  21533. textDecoration: "none",
  21534. "&:focus-visible": {
  21535. outline: `2px solid ${theme.color.secondary}`,
  21536. outlineOffset: 2
  21537. }
  21538. })), Brand = withTheme(({ theme }) => {
  21539. let { title: title2 = "Storybook", url = "./", image, target } = theme.brand, targetValue = target || (url === "./" ? "" : "_blank");
  21540. if (image === null)
  21541. return title2 === null ? null : url ? react_default.createElement(LogoLink, { href: url, target: targetValue, dangerouslySetInnerHTML: { __html: title2 } }) : react_default.createElement("div", { dangerouslySetInnerHTML: { __html: title2 } });
  21542. let logo = image ? react_default.createElement(Img2, { src: image, alt: title2 }) : react_default.createElement(StorybookLogoStyled, { alt: title2 });
  21543. return url ? react_default.createElement(LogoLink, { title: title2, href: url, target: targetValue }, logo) : react_default.createElement("div", null, logo);
  21544. });
  21545. // src/manager/components/sidebar/Menu.tsx
  21546. init_react();
  21547. var buttonStyleAdditions = ({
  21548. highlighted,
  21549. isMobile: isMobile2,
  21550. theme
  21551. }) => css`
  21552. position: relative;
  21553. overflow: visible;
  21554. margin-top: 0;
  21555. z-index: 1;
  21556. ${isMobile2 && `
  21557. width: 36px;
  21558. height: 36px;
  21559. `}
  21560. ${highlighted && `
  21561. &:before,
  21562. &:after {
  21563. content: '';
  21564. position: absolute;
  21565. top: 6px;
  21566. right: 6px;
  21567. width: 5px;
  21568. height: 5px;
  21569. z-index: 2;
  21570. border-radius: 50%;
  21571. background: ${theme.background.app};
  21572. border: 1px solid ${theme.background.app};
  21573. box-shadow: 0 0 0 2px ${theme.background.app};
  21574. }
  21575. &:after {
  21576. background: ${theme.color.positive};
  21577. border: 1px solid rgba(0, 0, 0, 0.1);
  21578. box-shadow: 0 0 0 2px ${theme.background.app};
  21579. }
  21580. &:hover:after,
  21581. &:focus-visible:after {
  21582. box-shadow: 0 0 0 2px ${curriedTransparentize$1(0.88, theme.color.secondary)};
  21583. }
  21584. `}
  21585. `, Container10 = styled.div({
  21586. minWidth: 250
  21587. }), SidebarButton = styled(Button)(buttonStyleAdditions), SidebarToggleButton = styled(ToggleButton)(buttonStyleAdditions), MenuButtonGroup = styled.div({
  21588. display: "flex",
  21589. gap: 6
  21590. }), 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) => {
  21591. 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);
  21592. return react_default.createElement(ActionList.Item, { key: link.id, active: link.active }, react_default.createElement(
  21593. ActionList.Action,
  21594. {
  21595. asChild: !!link.href,
  21596. ariaLabel: !1,
  21597. id: `list-item-${link.id}`,
  21598. disabled: link.disabled,
  21599. onClick: (e2) => {
  21600. if (link.disabled) {
  21601. e2.preventDefault();
  21602. return;
  21603. }
  21604. link.href && link.internal && e2.preventDefault(), link.onClick?.(e2, {
  21605. id: link.id,
  21606. active: link.active,
  21607. disabled: link.disabled,
  21608. title: link.title,
  21609. href: link.href
  21610. }), link.closeOnClick && onHide();
  21611. }
  21612. },
  21613. link.href ? react_default.createElement(
  21614. "a",
  21615. {
  21616. href: link.href,
  21617. target: link.internal ? void 0 : "_blank",
  21618. rel: link.internal ? "canonical" : "noreferrer"
  21619. },
  21620. linkContent
  21621. ) : linkContent
  21622. ));
  21623. })))), SidebarMenu = ({ menu, isHighlighted, onClick }) => {
  21624. let [isTooltipVisible, setIsTooltipVisible] = useState(!1), { isMobile: isMobile2, setMobileMenuOpen } = useLayout();
  21625. return isMobile2 ? react_default.createElement(MenuButtonGroup, null, react_default.createElement(
  21626. SidebarButton,
  21627. {
  21628. padding: "small",
  21629. variant: "ghost",
  21630. ariaLabel: "About Storybook",
  21631. highlighted: !!isHighlighted,
  21632. onClick: (e2) => {
  21633. onClick?.(e2), e2.preventDefault();
  21634. },
  21635. isMobile: !0,
  21636. asChild: !0
  21637. },
  21638. react_default.createElement("a", { href: "./?path=/settings/about", rel: "canonical" }, react_default.createElement(CogIcon, null))
  21639. ), react_default.createElement(
  21640. SidebarButton,
  21641. {
  21642. padding: "small",
  21643. variant: "ghost",
  21644. ariaLabel: "Close menu",
  21645. highlighted: !1,
  21646. onClick: () => setMobileMenuOpen(!1),
  21647. isMobile: !0
  21648. },
  21649. react_default.createElement(CloseIcon, null)
  21650. )) : react_default.createElement(
  21651. PopoverProvider,
  21652. {
  21653. ariaLabel: "Storybook menu",
  21654. placement: "bottom-start",
  21655. padding: 0,
  21656. popover: ({ onHide }) => react_default.createElement(SidebarMenuList, { onHide, menu }),
  21657. onVisibleChange: setIsTooltipVisible
  21658. },
  21659. react_default.createElement(
  21660. SidebarToggleButton,
  21661. {
  21662. ariaLabel: "Settings",
  21663. pressed: isTooltipVisible,
  21664. highlighted: !!isHighlighted,
  21665. padding: "small",
  21666. variant: "ghost",
  21667. size: "medium",
  21668. isMobile: !1
  21669. },
  21670. react_default.createElement(CogIcon, null)
  21671. )
  21672. );
  21673. };
  21674. // src/manager/components/sidebar/Heading.tsx
  21675. var BrandArea = styled.div(({ theme }) => ({
  21676. fontSize: theme.typography.size.s2,
  21677. fontWeight: theme.typography.weight.bold,
  21678. color: theme.color.defaultText,
  21679. marginRight: 20,
  21680. display: "flex",
  21681. width: "100%",
  21682. alignItems: "center",
  21683. minHeight: 22,
  21684. "& > * > *": {
  21685. maxWidth: "100%"
  21686. },
  21687. "& > *": {
  21688. maxWidth: "100%",
  21689. height: "auto",
  21690. display: "block",
  21691. flex: "1 1 auto"
  21692. }
  21693. })), HeadingWrapper = styled.div({
  21694. display: "flex",
  21695. alignItems: "center",
  21696. justifyContent: "space-between",
  21697. position: "relative",
  21698. minHeight: 42,
  21699. paddingLeft: 8
  21700. }), SkipToCanvasLink = styled(Button)(({ theme }) => ({
  21701. display: "none",
  21702. "@media (min-width: 600px)": {
  21703. display: "block",
  21704. position: "absolute",
  21705. fontSize: theme.typography.size.s1,
  21706. border: 0,
  21707. width: 1,
  21708. height: 1,
  21709. padding: 0,
  21710. margin: -1,
  21711. overflow: "hidden",
  21712. clip: "rect(0, 0, 0, 0)",
  21713. whiteSpace: "nowrap",
  21714. wordWrap: "normal",
  21715. opacity: 0,
  21716. transition: "opacity 150ms ease-out",
  21717. "&:focus": {
  21718. width: "100%",
  21719. height: "inherit",
  21720. padding: "10px 15px",
  21721. margin: 0,
  21722. clip: "unset",
  21723. overflow: "unset",
  21724. opacity: 1,
  21725. zIndex: 3
  21726. }
  21727. }
  21728. })), Heading2 = ({
  21729. menuHighlighted = !1,
  21730. menu,
  21731. skipLinkHref,
  21732. isLoading,
  21733. onMenuClick,
  21734. ...props
  21735. }) => 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 }));
  21736. // src/manager/components/sidebar/Search.tsx
  21737. init_react();
  21738. // ../../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
  21739. function _objectWithoutPropertiesLoose2(r4, e2) {
  21740. if (r4 == null) return {};
  21741. var t2 = {};
  21742. for (var n3 in r4) if ({}.hasOwnProperty.call(r4, n3)) {
  21743. if (e2.indexOf(n3) !== -1) continue;
  21744. t2[n3] = r4[n3];
  21745. }
  21746. return t2;
  21747. }
  21748. // ../../node_modules/downshift/dist/downshift.esm.js
  21749. var import_prop_types3 = __toESM(require_prop_types());
  21750. init_react();
  21751. var import_react_is = __toESM(require_react_is());
  21752. // ../../node_modules/compute-scroll-into-view/dist/index.js
  21753. var t = (t2) => typeof t2 == "object" && t2 != null && t2.nodeType === 1, e = (t2, e2) => (!e2 || t2 !== "hidden") && t2 !== "visible" && t2 !== "clip", n2 = (t2, n3) => {
  21754. if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
  21755. let o3 = getComputedStyle(t2, null);
  21756. return e(o3.overflowY, n3) || e(o3.overflowX, n3) || ((t3) => {
  21757. let e2 = ((t4) => {
  21758. if (!t4.ownerDocument || !t4.ownerDocument.defaultView) return null;
  21759. try {
  21760. return t4.ownerDocument.defaultView.frameElement;
  21761. } catch {
  21762. return null;
  21763. }
  21764. })(t3);
  21765. return !!e2 && (e2.clientHeight < t3.scrollHeight || e2.clientWidth < t3.scrollWidth);
  21766. })(t2);
  21767. }
  21768. return !1;
  21769. }, 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) => {
  21770. let e2 = t2.parentElement;
  21771. return e2 ?? (t2.getRootNode().host || null);
  21772. }, r3 = (e2, r4) => {
  21773. var i2, s2, d2, h2;
  21774. if (typeof document > "u") return [];
  21775. let { scrollMode: c2, block: f2, inline: u2, boundary: a2, skipOverflowHiddenElements: g2 } = r4, p2 = typeof a2 == "function" ? a2 : (t2) => t2 !== a2;
  21776. if (!t(e2)) throw new TypeError("Invalid target");
  21777. let m2 = document.scrollingElement || document.documentElement, w2 = [], W2 = e2;
  21778. for (; t(W2) && p2(W2); ) {
  21779. if (W2 = l2(W2), W2 === m2) {
  21780. w2.push(W2);
  21781. break;
  21782. }
  21783. W2 != null && W2 === document.body && n2(W2) && !n2(document.documentElement) || W2 != null && n2(W2, g2) && w2.push(W2);
  21784. }
  21785. 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) => {
  21786. let e3 = window.getComputedStyle(t2);
  21787. return { top: parseFloat(e3.scrollMarginTop) || 0, right: parseFloat(e3.scrollMarginRight) || 0, bottom: parseFloat(e3.scrollMarginBottom) || 0, left: parseFloat(e3.scrollMarginLeft) || 0 };
  21788. })(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 = [];
  21789. for (let t2 = 0; t2 < w2.length; t2++) {
  21790. let e3 = w2[t2], { height: l3, width: r5, top: i3, right: s3, bottom: d3, left: h3 } = e3.getBoundingClientRect();
  21791. 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;
  21792. 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;
  21793. 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);
  21794. else {
  21795. 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);
  21796. let { scrollLeft: t3, scrollTop: n3 } = e3;
  21797. 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;
  21798. }
  21799. L3.push({ el: e3, top: B3, left: F3 });
  21800. }
  21801. return L3;
  21802. };
  21803. // ../../node_modules/downshift/dist/downshift.esm.js
  21804. var idCounter = 0;
  21805. function cbToCb(cb) {
  21806. return typeof cb == "function" ? cb : noop4;
  21807. }
  21808. function noop4() {
  21809. }
  21810. function scrollIntoView2(node, menuNode) {
  21811. if (node) {
  21812. var actions = r3(node, {
  21813. boundary: menuNode,
  21814. block: "nearest",
  21815. scrollMode: "if-needed"
  21816. });
  21817. actions.forEach(function(_ref) {
  21818. var el = _ref.el, top = _ref.top, left = _ref.left;
  21819. el.scrollTop = top, el.scrollLeft = left;
  21820. });
  21821. }
  21822. }
  21823. function isOrContainsNode(parent, child, environment) {
  21824. var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
  21825. return result;
  21826. }
  21827. function debounce4(fn, time) {
  21828. var timeoutId;
  21829. function cancel() {
  21830. timeoutId && clearTimeout(timeoutId);
  21831. }
  21832. function wrapper() {
  21833. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
  21834. args[_key] = arguments[_key];
  21835. cancel(), timeoutId = setTimeout(function() {
  21836. timeoutId = null, fn.apply(void 0, args);
  21837. }, time);
  21838. }
  21839. return wrapper.cancel = cancel, wrapper;
  21840. }
  21841. function callAllEventHandlers() {
  21842. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++)
  21843. fns[_key2] = arguments[_key2];
  21844. return function(event) {
  21845. for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++)
  21846. args[_key3 - 1] = arguments[_key3];
  21847. return fns.some(function(fn) {
  21848. return fn && fn.apply(void 0, [event].concat(args)), event.preventDownshiftDefault || event.hasOwnProperty("nativeEvent") && event.nativeEvent.preventDownshiftDefault;
  21849. });
  21850. };
  21851. }
  21852. function handleRefs() {
  21853. for (var _len4 = arguments.length, refs = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++)
  21854. refs[_key4] = arguments[_key4];
  21855. return function(node) {
  21856. refs.forEach(function(ref) {
  21857. typeof ref == "function" ? ref(node) : ref && (ref.current = node);
  21858. });
  21859. };
  21860. }
  21861. function generateId() {
  21862. return String(idCounter++);
  21863. }
  21864. function getA11yStatusMessage(_ref2) {
  21865. var isOpen = _ref2.isOpen, resultCount = _ref2.resultCount, previousResultCount = _ref2.previousResultCount;
  21866. 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." : "";
  21867. }
  21868. function unwrapArray(arg, defaultValue) {
  21869. return arg = Array.isArray(arg) ? (
  21870. /* istanbul ignore next (preact) */
  21871. arg[0]
  21872. ) : arg, !arg && defaultValue ? defaultValue : arg;
  21873. }
  21874. function isDOMElement(element) {
  21875. return typeof element.type == "string";
  21876. }
  21877. function getElementProps(element) {
  21878. return element.props;
  21879. }
  21880. var stateKeys = ["highlightedIndex", "inputValue", "isOpen", "selectedItem", "type"];
  21881. function pickState(state) {
  21882. state === void 0 && (state = {});
  21883. var result = {};
  21884. return stateKeys.forEach(function(k2) {
  21885. state.hasOwnProperty(k2) && (result[k2] = state[k2]);
  21886. }), result;
  21887. }
  21888. function getState2(state, props) {
  21889. return !state || !props ? state : Object.keys(state).reduce(function(prevState, key) {
  21890. return prevState[key] = isControlledProp(props, key) ? props[key] : state[key], prevState;
  21891. }, {});
  21892. }
  21893. function isControlledProp(props, key) {
  21894. return props[key] !== void 0;
  21895. }
  21896. function normalizeArrowKey(event) {
  21897. var key = event.key, keyCode = event.keyCode;
  21898. return keyCode >= 37 && keyCode <= 40 && key.indexOf("Arrow") !== 0 ? "Arrow" + key : key;
  21899. }
  21900. function getHighlightedIndex(start, offset2, items, isItemDisabled2, circular) {
  21901. circular === void 0 && (circular = !1);
  21902. var count = items.length;
  21903. if (count === 0)
  21904. return -1;
  21905. var itemsLastIndex = count - 1;
  21906. (typeof start != "number" || start < 0 || start > itemsLastIndex) && (start = offset2 > 0 ? -1 : itemsLastIndex + 1);
  21907. var current = start + offset2;
  21908. current < 0 ? current = circular ? itemsLastIndex : 0 : current > itemsLastIndex && (current = circular ? 0 : itemsLastIndex);
  21909. var highlightedIndex = getNonDisabledIndex(current, offset2 < 0, items, isItemDisabled2, circular);
  21910. return highlightedIndex === -1 ? start >= count ? -1 : start : highlightedIndex;
  21911. }
  21912. function getNonDisabledIndex(start, backwards, items, isItemDisabled2, circular) {
  21913. circular === void 0 && (circular = !1);
  21914. var count = items.length;
  21915. if (backwards) {
  21916. for (var index = start; index >= 0; index--)
  21917. if (!isItemDisabled2(items[index], index))
  21918. return index;
  21919. } else
  21920. for (var _index = start; _index < count; _index++)
  21921. if (!isItemDisabled2(items[_index], _index))
  21922. return _index;
  21923. return circular ? getNonDisabledIndex(backwards ? count - 1 : 0, backwards, items, isItemDisabled2) : -1;
  21924. }
  21925. function targetWithinDownshift(target, downshiftElements, environment, checkActiveElement) {
  21926. return checkActiveElement === void 0 && (checkActiveElement = !0), environment && downshiftElements.some(function(contextNode) {
  21927. return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
  21928. });
  21929. }
  21930. var cleanupStatus = debounce4(function(documentProp) {
  21931. getStatusDiv(documentProp).textContent = "";
  21932. }, 500);
  21933. function getStatusDiv(documentProp) {
  21934. var statusDiv = documentProp.getElementById("a11y-status-message");
  21935. 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, {
  21936. border: "0",
  21937. clip: "rect(0 0 0 0)",
  21938. height: "1px",
  21939. margin: "-1px",
  21940. overflow: "hidden",
  21941. padding: "0",
  21942. position: "absolute",
  21943. width: "1px"
  21944. }), documentProp.body.appendChild(statusDiv), statusDiv);
  21945. }
  21946. function setStatus(status, documentProp) {
  21947. if (!(!status || !documentProp)) {
  21948. var div = getStatusDiv(documentProp);
  21949. div.textContent = status, cleanupStatus(documentProp);
  21950. }
  21951. }
  21952. function cleanupStatusDiv(documentProp) {
  21953. var statusDiv = documentProp?.getElementById("a11y-status-message");
  21954. statusDiv && statusDiv.remove();
  21955. }
  21956. 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({
  21957. __proto__: null,
  21958. blurButton,
  21959. blurInput,
  21960. changeInput,
  21961. clickButton,
  21962. clickItem,
  21963. controlledPropUpdatedSelectedItem,
  21964. itemMouseEnter,
  21965. keyDownArrowDown,
  21966. keyDownArrowUp,
  21967. keyDownEnd,
  21968. keyDownEnter,
  21969. keyDownEscape,
  21970. keyDownHome,
  21971. keyDownSpaceButton,
  21972. mouseUp,
  21973. touchEnd,
  21974. unknown
  21975. }), _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() {
  21976. var Downshift2 = (function(_Component) {
  21977. function Downshift3(_props) {
  21978. var _this;
  21979. _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) {
  21980. return _this.id + "-item-" + index;
  21981. }, _this.items = [], _this.itemCount = null, _this.previousResultCount = 0, _this.timeoutIds = [], _this.internalSetTimeout = function(fn, time) {
  21982. var id = setTimeout(function() {
  21983. _this.timeoutIds = _this.timeoutIds.filter(function(i2) {
  21984. return i2 !== id;
  21985. }), fn();
  21986. }, time);
  21987. _this.timeoutIds.push(id);
  21988. }, _this.setItemCount = function(count) {
  21989. _this.itemCount = count;
  21990. }, _this.unsetItemCount = function() {
  21991. _this.itemCount = null;
  21992. }, _this.isItemDisabled = function(_item, index) {
  21993. var currentElementNode = _this.getItemNodeFromIndex(index);
  21994. return currentElementNode && currentElementNode.hasAttribute("disabled");
  21995. }, _this.setHighlightedIndex = function(highlightedIndex, otherStateToSet) {
  21996. highlightedIndex === void 0 && (highlightedIndex = _this.props.defaultHighlightedIndex), otherStateToSet === void 0 && (otherStateToSet = {}), otherStateToSet = pickState(otherStateToSet), _this.internalSetState(_extends({
  21997. highlightedIndex
  21998. }, otherStateToSet));
  21999. }, _this.clearSelection = function(cb) {
  22000. _this.internalSetState({
  22001. selectedItem: null,
  22002. inputValue: "",
  22003. highlightedIndex: _this.props.defaultHighlightedIndex,
  22004. isOpen: _this.props.defaultIsOpen
  22005. }, cb);
  22006. }, _this.selectItem = function(item, otherStateToSet, cb) {
  22007. otherStateToSet = pickState(otherStateToSet), _this.internalSetState(_extends({
  22008. isOpen: _this.props.defaultIsOpen,
  22009. highlightedIndex: _this.props.defaultHighlightedIndex,
  22010. selectedItem: item,
  22011. inputValue: _this.props.itemToString(item)
  22012. }, otherStateToSet), cb);
  22013. }, _this.selectItemAtIndex = function(itemIndex, otherStateToSet, cb) {
  22014. var item = _this.items[itemIndex];
  22015. item != null && _this.selectItem(item, otherStateToSet, cb);
  22016. }, _this.selectHighlightedItem = function(otherStateToSet, cb) {
  22017. return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
  22018. }, _this.internalSetState = function(stateToSet, cb) {
  22019. var isItemSelected, onChangeArg, onStateChangeArg = {}, isStateToSetFunction = typeof stateToSet == "function";
  22020. return !isStateToSetFunction && stateToSet.hasOwnProperty("inputValue") && _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet)), _this.setState(function(state) {
  22021. var _newStateToSet;
  22022. state = _this.getState(state);
  22023. var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
  22024. newStateToSet = _this.props.stateReducer(state, newStateToSet), isItemSelected = newStateToSet.hasOwnProperty("selectedItem");
  22025. var nextState = {};
  22026. return isItemSelected && newStateToSet.selectedItem !== state.selectedItem && (onChangeArg = newStateToSet.selectedItem), (_newStateToSet = newStateToSet).type || (_newStateToSet.type = unknown), Object.keys(newStateToSet).forEach(function(key) {
  22027. state[key] !== newStateToSet[key] && (onStateChangeArg[key] = newStateToSet[key]), key !== "type" && (newStateToSet[key], isControlledProp(_this.props, key) || (nextState[key] = newStateToSet[key]));
  22028. }), isStateToSetFunction && newStateToSet.hasOwnProperty("inputValue") && _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet)), nextState;
  22029. }, function() {
  22030. cbToCb(cb)();
  22031. var hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
  22032. 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());
  22033. });
  22034. }, _this.rootRef = function(node) {
  22035. return _this._rootNode = node;
  22036. }, _this.getRootProps = function(_temp, _temp2) {
  22037. 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;
  22038. _this.getRootProps.called = !0, _this.getRootProps.refKey = refKey, _this.getRootProps.suppressRefError = suppressRefError;
  22039. var _this$getState = _this.getState(), isOpen = _this$getState.isOpen;
  22040. 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);
  22041. }, _this.keyDownHandlers = {
  22042. ArrowDown: function(event) {
  22043. var _this2 = this;
  22044. if (event.preventDefault(), this.getState().isOpen) {
  22045. var amount = event.shiftKey ? 5 : 1;
  22046. this.moveHighlightedIndex(amount, {
  22047. type: keyDownArrowDown
  22048. });
  22049. } else
  22050. this.internalSetState({
  22051. isOpen: !0,
  22052. type: keyDownArrowDown
  22053. }, function() {
  22054. var itemCount = _this2.getItemCount();
  22055. if (itemCount > 0) {
  22056. var _this2$getState = _this2.getState(), highlightedIndex = _this2$getState.highlightedIndex, nextHighlightedIndex = getHighlightedIndex(highlightedIndex, 1, {
  22057. length: itemCount
  22058. }, _this2.isItemDisabled, !0);
  22059. _this2.setHighlightedIndex(nextHighlightedIndex, {
  22060. type: keyDownArrowDown
  22061. });
  22062. }
  22063. });
  22064. },
  22065. ArrowUp: function(event) {
  22066. var _this3 = this;
  22067. if (event.preventDefault(), this.getState().isOpen) {
  22068. var amount = event.shiftKey ? -5 : -1;
  22069. this.moveHighlightedIndex(amount, {
  22070. type: keyDownArrowUp
  22071. });
  22072. } else
  22073. this.internalSetState({
  22074. isOpen: !0,
  22075. type: keyDownArrowUp
  22076. }, function() {
  22077. var itemCount = _this3.getItemCount();
  22078. if (itemCount > 0) {
  22079. var _this3$getState = _this3.getState(), highlightedIndex = _this3$getState.highlightedIndex, nextHighlightedIndex = getHighlightedIndex(highlightedIndex, -1, {
  22080. length: itemCount
  22081. }, _this3.isItemDisabled, !0);
  22082. _this3.setHighlightedIndex(nextHighlightedIndex, {
  22083. type: keyDownArrowUp
  22084. });
  22085. }
  22086. });
  22087. },
  22088. Enter: function(event) {
  22089. if (event.which !== 229) {
  22090. var _this$getState2 = this.getState(), isOpen = _this$getState2.isOpen, highlightedIndex = _this$getState2.highlightedIndex;
  22091. if (isOpen && highlightedIndex != null) {
  22092. event.preventDefault();
  22093. var item = this.items[highlightedIndex], itemNode = this.getItemNodeFromIndex(highlightedIndex);
  22094. if (item == null || itemNode && itemNode.hasAttribute("disabled"))
  22095. return;
  22096. this.selectHighlightedItem({
  22097. type: keyDownEnter
  22098. });
  22099. }
  22100. }
  22101. },
  22102. Escape: function(event) {
  22103. event.preventDefault(), this.reset(_extends({
  22104. type: keyDownEscape
  22105. }, !this.state.isOpen && {
  22106. selectedItem: null,
  22107. inputValue: ""
  22108. }));
  22109. }
  22110. }, _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
  22111. " ": function(event) {
  22112. event.preventDefault(), this.toggleMenu({
  22113. type: keyDownSpaceButton
  22114. });
  22115. }
  22116. }), _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
  22117. Home: function(event) {
  22118. var _this$getState3 = this.getState(), isOpen = _this$getState3.isOpen;
  22119. if (isOpen) {
  22120. event.preventDefault();
  22121. var itemCount = this.getItemCount();
  22122. if (!(itemCount <= 0 || !isOpen)) {
  22123. var newHighlightedIndex = getNonDisabledIndex(0, !1, {
  22124. length: itemCount
  22125. }, this.isItemDisabled);
  22126. this.setHighlightedIndex(newHighlightedIndex, {
  22127. type: keyDownHome
  22128. });
  22129. }
  22130. }
  22131. },
  22132. End: function(event) {
  22133. var _this$getState4 = this.getState(), isOpen = _this$getState4.isOpen;
  22134. if (isOpen) {
  22135. event.preventDefault();
  22136. var itemCount = this.getItemCount();
  22137. if (!(itemCount <= 0 || !isOpen)) {
  22138. var newHighlightedIndex = getNonDisabledIndex(itemCount - 1, !0, {
  22139. length: itemCount
  22140. }, this.isItemDisabled);
  22141. this.setHighlightedIndex(newHighlightedIndex, {
  22142. type: keyDownEnd
  22143. });
  22144. }
  22145. }
  22146. }
  22147. }), _this.getToggleButtonProps = function(_temp3) {
  22148. var _ref3 = _temp3 === void 0 ? {} : _temp3, onClick = _ref3.onClick;
  22149. _ref3.onPress;
  22150. var onKeyDown = _ref3.onKeyDown, onKeyUp = _ref3.onKeyUp, onBlur = _ref3.onBlur, rest2 = _objectWithoutPropertiesLoose2(_ref3, _excluded2$3), _this$getState5 = _this.getState(), isOpen = _this$getState5.isOpen, enabledEventHandlers = {
  22151. onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
  22152. onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
  22153. onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
  22154. onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
  22155. }, eventHandlers = rest2.disabled ? {} : enabledEventHandlers;
  22156. return _extends({
  22157. type: "button",
  22158. role: "button",
  22159. "aria-label": isOpen ? "close menu" : "open menu",
  22160. "aria-haspopup": !0,
  22161. "data-toggle": !0
  22162. }, eventHandlers, rest2);
  22163. }, _this.buttonHandleKeyUp = function(event) {
  22164. event.preventDefault();
  22165. }, _this.buttonHandleKeyDown = function(event) {
  22166. var key = normalizeArrowKey(event);
  22167. _this.buttonKeyDownHandlers[key] && _this.buttonKeyDownHandlers[key].call(_this, event);
  22168. }, _this.buttonHandleClick = function(event) {
  22169. if (event.preventDefault(), _this.props.environment) {
  22170. var _this$props$environme = _this.props.environment.document, body = _this$props$environme.body, activeElement = _this$props$environme.activeElement;
  22171. body && body === activeElement && event.target.focus();
  22172. }
  22173. _this.internalSetTimeout(function() {
  22174. return _this.toggleMenu({
  22175. type: clickButton
  22176. });
  22177. });
  22178. }, _this.buttonHandleBlur = function(event) {
  22179. var blurTarget = event.target;
  22180. _this.internalSetTimeout(function() {
  22181. if (!(_this.isMouseDown || !_this.props.environment)) {
  22182. var activeElement = _this.props.environment.document.activeElement;
  22183. (activeElement == null || activeElement.id !== _this.inputId) && activeElement !== blurTarget && _this.reset({
  22184. type: blurButton
  22185. });
  22186. }
  22187. });
  22188. }, _this.getLabelProps = function(props) {
  22189. return _extends({
  22190. htmlFor: _this.inputId,
  22191. id: _this.labelId
  22192. }, props);
  22193. }, _this.getInputProps = function(_temp4) {
  22194. var _ref4 = _temp4 === void 0 ? {} : _temp4, onKeyDown = _ref4.onKeyDown, onBlur = _ref4.onBlur, onChange = _ref4.onChange, onInput = _ref4.onInput;
  22195. _ref4.onChangeText;
  22196. var rest2 = _objectWithoutPropertiesLoose2(_ref4, _excluded3$2), onChangeKey, eventHandlers = {};
  22197. onChangeKey = "onChange";
  22198. var _this$getState6 = _this.getState(), inputValue = _this$getState6.inputValue, isOpen = _this$getState6.isOpen, highlightedIndex = _this$getState6.highlightedIndex;
  22199. if (!rest2.disabled) {
  22200. var _eventHandlers;
  22201. eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
  22202. }
  22203. return _extends({
  22204. "aria-autocomplete": "list",
  22205. "aria-activedescendant": isOpen && typeof highlightedIndex == "number" && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : void 0,
  22206. "aria-controls": isOpen ? _this.menuId : void 0,
  22207. "aria-labelledby": rest2 && rest2["aria-label"] ? void 0 : _this.labelId,
  22208. // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
  22209. // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
  22210. autoComplete: "off",
  22211. value: inputValue,
  22212. id: _this.inputId
  22213. }, eventHandlers, rest2);
  22214. }, _this.inputHandleKeyDown = function(event) {
  22215. var key = normalizeArrowKey(event);
  22216. key && _this.inputKeyDownHandlers[key] && _this.inputKeyDownHandlers[key].call(_this, event);
  22217. }, _this.inputHandleChange = function(event) {
  22218. _this.internalSetState({
  22219. type: changeInput,
  22220. isOpen: !0,
  22221. inputValue: event.target.value,
  22222. highlightedIndex: _this.props.defaultHighlightedIndex
  22223. });
  22224. }, _this.inputHandleBlur = function() {
  22225. _this.internalSetTimeout(function() {
  22226. var _activeElement$datase;
  22227. if (!(_this.isMouseDown || !_this.props.environment)) {
  22228. 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);
  22229. downshiftButtonIsActive || _this.reset({
  22230. type: blurInput
  22231. });
  22232. }
  22233. });
  22234. }, _this.menuRef = function(node) {
  22235. _this._menuNode = node;
  22236. }, _this.getMenuProps = function(_temp5, _temp6) {
  22237. 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;
  22238. 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);
  22239. }, _this.getItemProps = function(_temp7) {
  22240. var _enabledEventHandlers, _ref7 = _temp7 === void 0 ? {} : _temp7, onMouseMove = _ref7.onMouseMove, onMouseDown = _ref7.onMouseDown, onClick = _ref7.onClick;
  22241. _ref7.onPress;
  22242. var index = _ref7.index, _ref7$item = _ref7.item, item = _ref7$item === void 0 ? (
  22243. /* istanbul ignore next */
  22244. void 0
  22245. ) : _ref7$item, rest2 = _objectWithoutPropertiesLoose2(_ref7, _excluded5);
  22246. index === void 0 ? (_this.items.push(item), index = _this.items.indexOf(item)) : _this.items[index] = item;
  22247. var onSelectKey = "onClick", customClickHandler = onClick, enabledEventHandlers = (_enabledEventHandlers = {
  22248. // onMouseMove is used over onMouseEnter here. onMouseMove
  22249. // is only triggered on actual mouse movement while onMouseEnter
  22250. // can fire on DOM changes, interrupting keyboard navigation
  22251. onMouseMove: callAllEventHandlers(onMouseMove, function() {
  22252. index !== _this.getState().highlightedIndex && (_this.setHighlightedIndex(index, {
  22253. type: itemMouseEnter
  22254. }), _this.avoidScrolling = !0, _this.internalSetTimeout(function() {
  22255. return _this.avoidScrolling = !1;
  22256. }, 250));
  22257. }),
  22258. onMouseDown: callAllEventHandlers(onMouseDown, function(event) {
  22259. event.preventDefault();
  22260. })
  22261. }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function() {
  22262. _this.selectItemAtIndex(index, {
  22263. type: clickItem
  22264. });
  22265. }), _enabledEventHandlers), eventHandlers = rest2.disabled ? {
  22266. onMouseDown: enabledEventHandlers.onMouseDown
  22267. } : enabledEventHandlers;
  22268. return _extends({
  22269. id: _this.getItemId(index),
  22270. role: "option",
  22271. "aria-selected": _this.getState().highlightedIndex === index
  22272. }, eventHandlers, rest2);
  22273. }, _this.clearItems = function() {
  22274. _this.items = [];
  22275. }, _this.reset = function(otherStateToSet, cb) {
  22276. otherStateToSet === void 0 && (otherStateToSet = {}), otherStateToSet = pickState(otherStateToSet), _this.internalSetState(function(_ref8) {
  22277. var selectedItem = _ref8.selectedItem;
  22278. return _extends({
  22279. isOpen: _this.props.defaultIsOpen,
  22280. highlightedIndex: _this.props.defaultHighlightedIndex,
  22281. inputValue: _this.props.itemToString(selectedItem)
  22282. }, otherStateToSet);
  22283. }, cb);
  22284. }, _this.toggleMenu = function(otherStateToSet, cb) {
  22285. otherStateToSet === void 0 && (otherStateToSet = {}), otherStateToSet = pickState(otherStateToSet), _this.internalSetState(function(_ref9) {
  22286. var isOpen = _ref9.isOpen;
  22287. return _extends({
  22288. isOpen: !isOpen
  22289. }, isOpen && {
  22290. highlightedIndex: _this.props.defaultHighlightedIndex
  22291. }, otherStateToSet);
  22292. }, function() {
  22293. var _this$getState7 = _this.getState(), isOpen = _this$getState7.isOpen, highlightedIndex = _this$getState7.highlightedIndex;
  22294. isOpen && _this.getItemCount() > 0 && typeof highlightedIndex == "number" && _this.setHighlightedIndex(highlightedIndex, otherStateToSet), cbToCb(cb)();
  22295. });
  22296. }, _this.openMenu = function(cb) {
  22297. _this.internalSetState({
  22298. isOpen: !0
  22299. }, cb);
  22300. }, _this.closeMenu = function(cb) {
  22301. _this.internalSetState({
  22302. isOpen: !1
  22303. }, cb);
  22304. }, _this.updateStatus = debounce4(function() {
  22305. var _this$props;
  22306. if ((_this$props = _this.props) != null && (_this$props = _this$props.environment) != null && _this$props.document) {
  22307. var state = _this.getState(), item = _this.items[state.highlightedIndex], resultCount = _this.getItemCount(), status = _this.props.getA11yStatusMessage(_extends({
  22308. itemToString: _this.props.itemToString,
  22309. previousResultCount: _this.previousResultCount,
  22310. resultCount,
  22311. highlightedItem: item
  22312. }, state));
  22313. _this.previousResultCount = resultCount, setStatus(status, _this.props.environment.document);
  22314. }
  22315. }, 200);
  22316. 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({
  22317. highlightedIndex: _highlightedIndex,
  22318. isOpen: _isOpen,
  22319. inputValue: _inputValue,
  22320. selectedItem: _selectedItem
  22321. });
  22322. return _state.selectedItem != null && _this.props.initialInputValue === void 0 && (_state.inputValue = _this.props.itemToString(_state.selectedItem)), _this.state = _state, _this;
  22323. }
  22324. _inheritsLoose(Downshift3, _Component);
  22325. var _proto = Downshift3.prototype;
  22326. return _proto.internalClearTimeouts = function() {
  22327. this.timeoutIds.forEach(function(id) {
  22328. clearTimeout(id);
  22329. }), this.timeoutIds = [];
  22330. }, _proto.getState = function(stateToMerge) {
  22331. return stateToMerge === void 0 && (stateToMerge = this.state), getState2(stateToMerge, this.props);
  22332. }, _proto.getItemCount = function() {
  22333. var itemCount = this.items.length;
  22334. return this.itemCount != null ? itemCount = this.itemCount : this.props.itemCount !== void 0 && (itemCount = this.props.itemCount), itemCount;
  22335. }, _proto.getItemNodeFromIndex = function(index) {
  22336. return this.props.environment ? this.props.environment.document.getElementById(this.getItemId(index)) : null;
  22337. }, _proto.scrollHighlightedItemIntoView = function() {
  22338. {
  22339. var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
  22340. this.props.scrollIntoView(node, this._menuNode);
  22341. }
  22342. }, _proto.moveHighlightedIndex = function(amount, otherStateToSet) {
  22343. var itemCount = this.getItemCount(), _this$getState8 = this.getState(), highlightedIndex = _this$getState8.highlightedIndex;
  22344. if (itemCount > 0) {
  22345. var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, amount, {
  22346. length: itemCount
  22347. }, this.isItemDisabled, !0);
  22348. this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
  22349. }
  22350. }, _proto.getStateAndHelpers = function() {
  22351. 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;
  22352. return {
  22353. // prop getters
  22354. getRootProps,
  22355. getToggleButtonProps,
  22356. getLabelProps,
  22357. getMenuProps,
  22358. getInputProps,
  22359. getItemProps,
  22360. // actions
  22361. reset,
  22362. openMenu,
  22363. closeMenu,
  22364. toggleMenu,
  22365. selectItem,
  22366. selectItemAtIndex,
  22367. selectHighlightedItem,
  22368. setHighlightedIndex,
  22369. clearSelection,
  22370. clearItems,
  22371. setItemCount,
  22372. unsetItemCount,
  22373. setState,
  22374. // props
  22375. itemToString: itemToString2,
  22376. // derived
  22377. id,
  22378. // state
  22379. highlightedIndex,
  22380. inputValue,
  22381. isOpen,
  22382. selectedItem
  22383. };
  22384. }, _proto.componentDidMount = function() {
  22385. var _this4 = this;
  22386. if (!this.props.environment)
  22387. this.cleanup = function() {
  22388. _this4.internalClearTimeouts();
  22389. };
  22390. else {
  22391. var onMouseDown = function() {
  22392. _this4.isMouseDown = !0;
  22393. }, onMouseUp = function(event) {
  22394. _this4.isMouseDown = !1;
  22395. var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment);
  22396. !contextWithinDownshift && _this4.getState().isOpen && _this4.reset({
  22397. type: mouseUp
  22398. }, function() {
  22399. return _this4.props.onOuterClick(_this4.getStateAndHelpers());
  22400. });
  22401. }, onTouchStart = function() {
  22402. _this4.isTouchMove = !1;
  22403. }, onTouchMove = function() {
  22404. _this4.isTouchMove = !0;
  22405. }, onTouchEnd = function(event) {
  22406. var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment, !1);
  22407. !_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen && _this4.reset({
  22408. type: touchEnd
  22409. }, function() {
  22410. return _this4.props.onOuterClick(_this4.getStateAndHelpers());
  22411. });
  22412. }, environment = this.props.environment;
  22413. environment.addEventListener("mousedown", onMouseDown), environment.addEventListener("mouseup", onMouseUp), environment.addEventListener("touchstart", onTouchStart), environment.addEventListener("touchmove", onTouchMove), environment.addEventListener("touchend", onTouchEnd), this.cleanup = function() {
  22414. _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);
  22415. };
  22416. }
  22417. }, _proto.shouldScroll = function(prevState, prevProps) {
  22418. 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;
  22419. return scrollWhenOpen || scrollWhenNavigating;
  22420. }, _proto.componentDidUpdate = function(prevProps, prevState) {
  22421. isControlledProp(this.props, "selectedItem") && this.props.selectedItemChanged(prevProps.selectedItem, this.props.selectedItem) && this.internalSetState({
  22422. type: controlledPropUpdatedSelectedItem,
  22423. inputValue: this.props.itemToString(this.props.selectedItem)
  22424. }), !this.avoidScrolling && this.shouldScroll(prevState, prevProps) && this.scrollHighlightedItemIntoView(), this.updateStatus();
  22425. }, _proto.componentWillUnmount = function() {
  22426. this.cleanup();
  22427. }, _proto.render = function() {
  22428. var children = unwrapArray(this.props.children, noop4);
  22429. 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;
  22430. var element = unwrapArray(children(this.getStateAndHelpers()));
  22431. if (!element)
  22432. return null;
  22433. if (this.getRootProps.called || this.props.suppressRefError)
  22434. return element;
  22435. if (isDOMElement(element))
  22436. return cloneElement(element, this.getRootProps(getElementProps(element)));
  22437. }, Downshift3;
  22438. })(Component);
  22439. return Downshift2.defaultProps = {
  22440. defaultHighlightedIndex: null,
  22441. defaultIsOpen: !1,
  22442. getA11yStatusMessage,
  22443. itemToString: function(i2) {
  22444. return i2 == null ? "" : String(i2);
  22445. },
  22446. onStateChange: noop4,
  22447. onInputValueChange: noop4,
  22448. onUserAction: noop4,
  22449. onChange: noop4,
  22450. onSelect: noop4,
  22451. onOuterClick: noop4,
  22452. selectedItemChanged: function(prevItem, item) {
  22453. return prevItem !== item;
  22454. },
  22455. environment: (
  22456. /* istanbul ignore next (ssr) */
  22457. typeof window > "u" ? void 0 : window
  22458. ),
  22459. stateReducer: function(state, stateToSet) {
  22460. return stateToSet;
  22461. },
  22462. suppressRefError: !1,
  22463. scrollIntoView: scrollIntoView2
  22464. }, Downshift2.stateChangeTypes = stateChangeTypes$3, Downshift2;
  22465. })();
  22466. var dropdownDefaultStateValues = {
  22467. highlightedIndex: -1,
  22468. isOpen: !1,
  22469. selectedItem: null,
  22470. inputValue: ""
  22471. };
  22472. function callOnChangeProps(action, state, newState) {
  22473. var props = action.props, type = action.type, changes = {};
  22474. Object.keys(state).forEach(function(key) {
  22475. invokeOnChangeHandler(key, action, state, newState), newState[key] !== state[key] && (changes[key] = newState[key]);
  22476. }), props.onStateChange && Object.keys(changes).length && props.onStateChange(_extends({
  22477. type
  22478. }, changes));
  22479. }
  22480. function invokeOnChangeHandler(key, action, state, newState) {
  22481. var props = action.props, type = action.type, handler = "on" + capitalizeString(key) + "Change";
  22482. props[handler] && newState[key] !== void 0 && newState[key] !== state[key] && props[handler](_extends({
  22483. type
  22484. }, newState));
  22485. }
  22486. function stateReducer(s2, a2) {
  22487. return a2.changes;
  22488. }
  22489. var updateA11yStatus = debounce4(function(status, document11) {
  22490. setStatus(status, document11);
  22491. }, 200), useIsomorphicLayoutEffect2 = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u" ? useLayoutEffect : useEffect, useElementIds = "useId" in react_default ? function(_ref) {
  22492. var id = _ref.id, labelId = _ref.labelId, menuId = _ref.menuId, getItemId = _ref.getItemId, toggleButtonId = _ref.toggleButtonId, inputId = _ref.inputId, reactId = "downshift-" + react_default.useId();
  22493. id || (id = reactId);
  22494. var elementIdsRef = useRef({
  22495. labelId: labelId || id + "-label",
  22496. menuId: menuId || id + "-menu",
  22497. getItemId: getItemId || function(index) {
  22498. return id + "-item-" + index;
  22499. },
  22500. toggleButtonId: toggleButtonId || id + "-toggle-button",
  22501. inputId: inputId || id + "-input"
  22502. });
  22503. return elementIdsRef.current;
  22504. } : function(_ref2) {
  22505. 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({
  22506. labelId: labelId || id + "-label",
  22507. menuId: menuId || id + "-menu",
  22508. getItemId: getItemId || function(index) {
  22509. return id + "-item-" + index;
  22510. },
  22511. toggleButtonId: toggleButtonId || id + "-toggle-button",
  22512. inputId: inputId || id + "-input"
  22513. });
  22514. return elementIdsRef.current;
  22515. };
  22516. function getItemAndIndex(itemProp, indexProp, items, errorMessage) {
  22517. var item, index;
  22518. if (itemProp === void 0) {
  22519. if (indexProp === void 0)
  22520. throw new Error(errorMessage);
  22521. item = items[indexProp], index = indexProp;
  22522. } else
  22523. index = indexProp === void 0 ? items.indexOf(itemProp) : indexProp, item = itemProp;
  22524. return [item, index];
  22525. }
  22526. function isAcceptedCharacterKey(key) {
  22527. return /^\S{1}$/.test(key);
  22528. }
  22529. function capitalizeString(string) {
  22530. return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
  22531. }
  22532. function useLatestRef(val) {
  22533. var ref = useRef(val);
  22534. return ref.current = val, ref;
  22535. }
  22536. function useEnhancedReducer(reducer, props, createInitialState, isStateEqual2) {
  22537. var prevStateRef = useRef(), actionRef = useRef(), enhancedReducer = useCallback(function(state2, action2) {
  22538. actionRef.current = action2, state2 = getState2(state2, action2.props);
  22539. var changes = reducer(state2, action2), newState = action2.props.stateReducer(state2, _extends({}, action2, {
  22540. changes
  22541. }));
  22542. return newState;
  22543. }, [reducer]), _useReducer = useReducer(enhancedReducer, props, createInitialState), state = _useReducer[0], dispatch = _useReducer[1], propsRef = useLatestRef(props), dispatchWithProps = useCallback(function(action2) {
  22544. return dispatch(_extends({
  22545. props: propsRef.current
  22546. }, action2));
  22547. }, [propsRef]), action = actionRef.current;
  22548. return useEffect(function() {
  22549. var prevState = getState2(prevStateRef.current, action?.props), shouldCallOnChangeProps = action && prevStateRef.current && !isStateEqual2(prevState, state);
  22550. shouldCallOnChangeProps && callOnChangeProps(action, prevState, state), prevStateRef.current = state;
  22551. }, [state, action, isStateEqual2]), [state, dispatchWithProps];
  22552. }
  22553. function useControlledReducer$1(reducer, props, createInitialState, isStateEqual2) {
  22554. var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual2), state = _useEnhancedReducer[0], dispatch = _useEnhancedReducer[1];
  22555. return [getState2(state, props), dispatch];
  22556. }
  22557. var defaultProps$3 = {
  22558. itemToString: function(item) {
  22559. return item ? String(item) : "";
  22560. },
  22561. itemToKey: function(item) {
  22562. return item;
  22563. },
  22564. stateReducer,
  22565. scrollIntoView: scrollIntoView2,
  22566. environment: (
  22567. /* istanbul ignore next (ssr) */
  22568. typeof window > "u" ? void 0 : window
  22569. )
  22570. };
  22571. function getDefaultValue$1(props, propKey, defaultStateValues2) {
  22572. defaultStateValues2 === void 0 && (defaultStateValues2 = dropdownDefaultStateValues);
  22573. var defaultValue = props["default" + capitalizeString(propKey)];
  22574. return defaultValue !== void 0 ? defaultValue : defaultStateValues2[propKey];
  22575. }
  22576. function getInitialValue$1(props, propKey, defaultStateValues2) {
  22577. defaultStateValues2 === void 0 && (defaultStateValues2 = dropdownDefaultStateValues);
  22578. var value = props[propKey];
  22579. if (value !== void 0)
  22580. return value;
  22581. var initialValue = props["initial" + capitalizeString(propKey)];
  22582. return initialValue !== void 0 ? initialValue : getDefaultValue$1(props, propKey, defaultStateValues2);
  22583. }
  22584. function getInitialState$2(props) {
  22585. var selectedItem = getInitialValue$1(props, "selectedItem"), isOpen = getInitialValue$1(props, "isOpen"), highlightedIndex = getInitialHighlightedIndex(props), inputValue = getInitialValue$1(props, "inputValue");
  22586. return {
  22587. highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function(item) {
  22588. return props.itemToKey(item) === props.itemToKey(selectedItem);
  22589. }) : highlightedIndex,
  22590. isOpen,
  22591. selectedItem,
  22592. inputValue
  22593. };
  22594. }
  22595. function getHighlightedIndexOnOpen(props, state, offset2) {
  22596. var items = props.items, initialHighlightedIndex = props.initialHighlightedIndex, defaultHighlightedIndex = props.defaultHighlightedIndex, isItemDisabled2 = props.isItemDisabled, itemToKey2 = props.itemToKey, selectedItem = state.selectedItem, highlightedIndex = state.highlightedIndex;
  22597. 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) {
  22598. return itemToKey2(selectedItem) === itemToKey2(item);
  22599. }) : offset2 < 0 && !isItemDisabled2(items[items.length - 1], items.length - 1) ? items.length - 1 : offset2 > 0 && !isItemDisabled2(items[0], 0) ? 0 : -1;
  22600. }
  22601. function useMouseAndTouchTracker(environment, handleBlur, downshiftElementsRefs) {
  22602. var mouseAndTouchTrackersRef = useRef({
  22603. isMouseDown: !1,
  22604. isTouchMove: !1,
  22605. isTouchEnd: !1
  22606. });
  22607. return useEffect(function() {
  22608. if (!environment)
  22609. return noop4;
  22610. var downshiftElements = downshiftElementsRefs.map(function(ref) {
  22611. return ref.current;
  22612. });
  22613. function onMouseDown() {
  22614. mouseAndTouchTrackersRef.current.isTouchEnd = !1, mouseAndTouchTrackersRef.current.isMouseDown = !0;
  22615. }
  22616. function onMouseUp(event) {
  22617. mouseAndTouchTrackersRef.current.isMouseDown = !1, targetWithinDownshift(event.target, downshiftElements, environment) || handleBlur();
  22618. }
  22619. function onTouchStart() {
  22620. mouseAndTouchTrackersRef.current.isTouchEnd = !1, mouseAndTouchTrackersRef.current.isTouchMove = !1;
  22621. }
  22622. function onTouchMove() {
  22623. mouseAndTouchTrackersRef.current.isTouchMove = !0;
  22624. }
  22625. function onTouchEnd(event) {
  22626. mouseAndTouchTrackersRef.current.isTouchEnd = !0, !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElements, environment, !1) && handleBlur();
  22627. }
  22628. return environment.addEventListener("mousedown", onMouseDown), environment.addEventListener("mouseup", onMouseUp), environment.addEventListener("touchstart", onTouchStart), environment.addEventListener("touchmove", onTouchMove), environment.addEventListener("touchend", onTouchEnd), function() {
  22629. environment.removeEventListener("mousedown", onMouseDown), environment.removeEventListener("mouseup", onMouseUp), environment.removeEventListener("touchstart", onTouchStart), environment.removeEventListener("touchmove", onTouchMove), environment.removeEventListener("touchend", onTouchEnd);
  22630. };
  22631. }, [downshiftElementsRefs, environment, handleBlur]), mouseAndTouchTrackersRef.current;
  22632. }
  22633. var useGetterPropsCalledChecker = function() {
  22634. return noop4;
  22635. };
  22636. function useA11yMessageStatus(getA11yStatusMessage2, options2, dependencyArray, environment) {
  22637. environment === void 0 && (environment = {});
  22638. var document11 = environment.document, isInitialMount = useIsInitialMount();
  22639. useEffect(function() {
  22640. if (!(!getA11yStatusMessage2 || isInitialMount || !document11)) {
  22641. var status = getA11yStatusMessage2(options2);
  22642. updateA11yStatus(status, document11);
  22643. }
  22644. }, dependencyArray), useEffect(function() {
  22645. return function() {
  22646. updateA11yStatus.cancel(), cleanupStatusDiv(document11);
  22647. };
  22648. }, [document11]);
  22649. }
  22650. function useScrollIntoView(_ref3) {
  22651. var highlightedIndex = _ref3.highlightedIndex, isOpen = _ref3.isOpen, itemRefs = _ref3.itemRefs, getItemNodeFromIndex = _ref3.getItemNodeFromIndex, menuElement = _ref3.menuElement, scrollIntoViewProp = _ref3.scrollIntoView, shouldScrollRef = useRef(!0);
  22652. return useIsomorphicLayoutEffect2(function() {
  22653. highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length || (shouldScrollRef.current === !1 ? shouldScrollRef.current = !0 : scrollIntoViewProp(getItemNodeFromIndex(highlightedIndex), menuElement));
  22654. }, [highlightedIndex]), shouldScrollRef;
  22655. }
  22656. var useControlPropsValidator = noop4;
  22657. function getChangesOnSelection(props, highlightedIndex, inputValue) {
  22658. var _props$items;
  22659. inputValue === void 0 && (inputValue = !0);
  22660. var shouldSelect = ((_props$items = props.items) == null ? void 0 : _props$items.length) && highlightedIndex >= 0;
  22661. return _extends({
  22662. isOpen: !1,
  22663. highlightedIndex: -1
  22664. }, shouldSelect && _extends({
  22665. selectedItem: props.items[highlightedIndex],
  22666. isOpen: getDefaultValue$1(props, "isOpen"),
  22667. highlightedIndex: getDefaultValue$1(props, "highlightedIndex")
  22668. }, inputValue && {
  22669. inputValue: props.itemToString(props.items[highlightedIndex])
  22670. }));
  22671. }
  22672. function isDropdownsStateEqual(prevState, newState) {
  22673. return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
  22674. }
  22675. function useIsInitialMount() {
  22676. var isInitialMountRef = react_default.useRef(!0);
  22677. return react_default.useEffect(function() {
  22678. return isInitialMountRef.current = !1, function() {
  22679. isInitialMountRef.current = !0;
  22680. };
  22681. }, []), isInitialMountRef.current;
  22682. }
  22683. function getDefaultHighlightedIndex(props) {
  22684. var highlightedIndex = getDefaultValue$1(props, "highlightedIndex");
  22685. return highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex) ? -1 : highlightedIndex;
  22686. }
  22687. function getInitialHighlightedIndex(props) {
  22688. var highlightedIndex = getInitialValue$1(props, "highlightedIndex");
  22689. return highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex) ? -1 : highlightedIndex;
  22690. }
  22691. var commonPropTypes = {
  22692. environment: import_prop_types3.default.shape({
  22693. addEventListener: import_prop_types3.default.func.isRequired,
  22694. removeEventListener: import_prop_types3.default.func.isRequired,
  22695. document: import_prop_types3.default.shape({
  22696. createElement: import_prop_types3.default.func.isRequired,
  22697. getElementById: import_prop_types3.default.func.isRequired,
  22698. activeElement: import_prop_types3.default.any.isRequired,
  22699. body: import_prop_types3.default.any.isRequired
  22700. }).isRequired,
  22701. Node: import_prop_types3.default.func.isRequired
  22702. }),
  22703. itemToString: import_prop_types3.default.func,
  22704. itemToKey: import_prop_types3.default.func,
  22705. stateReducer: import_prop_types3.default.func
  22706. }, commonDropdownPropTypes = _extends({}, commonPropTypes, {
  22707. getA11yStatusMessage: import_prop_types3.default.func,
  22708. highlightedIndex: import_prop_types3.default.number,
  22709. defaultHighlightedIndex: import_prop_types3.default.number,
  22710. initialHighlightedIndex: import_prop_types3.default.number,
  22711. isOpen: import_prop_types3.default.bool,
  22712. defaultIsOpen: import_prop_types3.default.bool,
  22713. initialIsOpen: import_prop_types3.default.bool,
  22714. selectedItem: import_prop_types3.default.any,
  22715. initialSelectedItem: import_prop_types3.default.any,
  22716. defaultSelectedItem: import_prop_types3.default.any,
  22717. id: import_prop_types3.default.string,
  22718. labelId: import_prop_types3.default.string,
  22719. menuId: import_prop_types3.default.string,
  22720. getItemId: import_prop_types3.default.func,
  22721. toggleButtonId: import_prop_types3.default.string,
  22722. onSelectedItemChange: import_prop_types3.default.func,
  22723. onHighlightedIndexChange: import_prop_types3.default.func,
  22724. onStateChange: import_prop_types3.default.func,
  22725. onIsOpenChange: import_prop_types3.default.func,
  22726. scrollIntoView: import_prop_types3.default.func
  22727. });
  22728. function downshiftCommonReducer(state, action, stateChangeTypes2) {
  22729. var type = action.type, props = action.props, changes;
  22730. switch (type) {
  22731. case stateChangeTypes2.ItemMouseMove:
  22732. changes = {
  22733. highlightedIndex: action.disabled ? -1 : action.index
  22734. };
  22735. break;
  22736. case stateChangeTypes2.MenuMouseLeave:
  22737. changes = {
  22738. highlightedIndex: -1
  22739. };
  22740. break;
  22741. case stateChangeTypes2.ToggleButtonClick:
  22742. case stateChangeTypes2.FunctionToggleMenu:
  22743. changes = {
  22744. isOpen: !state.isOpen,
  22745. highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
  22746. };
  22747. break;
  22748. case stateChangeTypes2.FunctionOpenMenu:
  22749. changes = {
  22750. isOpen: !0,
  22751. highlightedIndex: getHighlightedIndexOnOpen(props, state, 0)
  22752. };
  22753. break;
  22754. case stateChangeTypes2.FunctionCloseMenu:
  22755. changes = {
  22756. isOpen: !1
  22757. };
  22758. break;
  22759. case stateChangeTypes2.FunctionSetHighlightedIndex:
  22760. changes = {
  22761. highlightedIndex: props.isItemDisabled(props.items[action.highlightedIndex], action.highlightedIndex) ? -1 : action.highlightedIndex
  22762. };
  22763. break;
  22764. case stateChangeTypes2.FunctionSetInputValue:
  22765. changes = {
  22766. inputValue: action.inputValue
  22767. };
  22768. break;
  22769. case stateChangeTypes2.FunctionReset:
  22770. changes = {
  22771. highlightedIndex: getDefaultHighlightedIndex(props),
  22772. isOpen: getDefaultValue$1(props, "isOpen"),
  22773. selectedItem: getDefaultValue$1(props, "selectedItem"),
  22774. inputValue: getDefaultValue$1(props, "inputValue")
  22775. };
  22776. break;
  22777. default:
  22778. throw new Error("Reducer called without proper action type.");
  22779. }
  22780. return _extends({}, state, changes);
  22781. }
  22782. function getItemIndexByCharacterKey(_a2) {
  22783. 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++) {
  22784. var offsetIndex = (index + highlightedIndex + (keysSoFar.length < 2 ? 1 : 0)) % items.length, item = items[offsetIndex];
  22785. if (item !== void 0 && itemToString2(item).toLowerCase().startsWith(lowerCasedKeysSoFar) && !isItemDisabled2(item, offsetIndex))
  22786. return offsetIndex;
  22787. }
  22788. return highlightedIndex;
  22789. }
  22790. 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() {
  22791. return !1;
  22792. } }), 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({
  22793. __proto__: null,
  22794. FunctionCloseMenu: FunctionCloseMenu$1,
  22795. FunctionOpenMenu: FunctionOpenMenu$1,
  22796. FunctionReset: FunctionReset$2,
  22797. FunctionSelectItem: FunctionSelectItem$1,
  22798. FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
  22799. FunctionSetInputValue: FunctionSetInputValue$1,
  22800. FunctionToggleMenu: FunctionToggleMenu$1,
  22801. ItemClick: ItemClick$1,
  22802. ItemMouseMove: ItemMouseMove$1,
  22803. MenuMouseLeave: MenuMouseLeave$1,
  22804. ToggleButtonBlur,
  22805. ToggleButtonClick: ToggleButtonClick$1,
  22806. ToggleButtonKeyDownArrowDown,
  22807. ToggleButtonKeyDownArrowUp,
  22808. ToggleButtonKeyDownCharacter,
  22809. ToggleButtonKeyDownEnd,
  22810. ToggleButtonKeyDownEnter,
  22811. ToggleButtonKeyDownEscape,
  22812. ToggleButtonKeyDownHome,
  22813. ToggleButtonKeyDownPageDown,
  22814. ToggleButtonKeyDownPageUp,
  22815. ToggleButtonKeyDownSpaceButton
  22816. });
  22817. function downshiftSelectReducer(state, action) {
  22818. var _props$items, type = action.type, props = action.props, altKey = action.altKey, changes;
  22819. switch (type) {
  22820. case ItemClick$1:
  22821. changes = {
  22822. isOpen: getDefaultValue$1(props, "isOpen"),
  22823. highlightedIndex: getDefaultHighlightedIndex(props),
  22824. selectedItem: props.items[action.index]
  22825. };
  22826. break;
  22827. case ToggleButtonKeyDownCharacter:
  22828. {
  22829. var lowercasedKey = action.key, inputValue = "" + state.inputValue + lowercasedKey, prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.findIndex(function(item) {
  22830. return props.itemToKey(item) === props.itemToKey(state.selectedItem);
  22831. }) : state.highlightedIndex, highlightedIndex = getItemIndexByCharacterKey({
  22832. keysSoFar: inputValue,
  22833. highlightedIndex: prevHighlightedIndex,
  22834. items: props.items,
  22835. itemToString: props.itemToString,
  22836. isItemDisabled: props.isItemDisabled
  22837. });
  22838. changes = {
  22839. inputValue,
  22840. highlightedIndex,
  22841. isOpen: !0
  22842. };
  22843. }
  22844. break;
  22845. case ToggleButtonKeyDownArrowDown:
  22846. {
  22847. var _highlightedIndex = state.isOpen ? getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
  22848. changes = {
  22849. highlightedIndex: _highlightedIndex,
  22850. isOpen: !0
  22851. };
  22852. }
  22853. break;
  22854. case ToggleButtonKeyDownArrowUp:
  22855. if (state.isOpen && altKey)
  22856. changes = getChangesOnSelection(props, state.highlightedIndex, !1);
  22857. else {
  22858. var _highlightedIndex2 = state.isOpen ? getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled) : getHighlightedIndexOnOpen(props, state, -1);
  22859. changes = {
  22860. highlightedIndex: _highlightedIndex2,
  22861. isOpen: !0
  22862. };
  22863. }
  22864. break;
  22865. // only triggered when menu is open.
  22866. case ToggleButtonKeyDownEnter:
  22867. case ToggleButtonKeyDownSpaceButton:
  22868. changes = getChangesOnSelection(props, state.highlightedIndex, !1);
  22869. break;
  22870. case ToggleButtonKeyDownHome:
  22871. changes = {
  22872. highlightedIndex: getNonDisabledIndex(0, !1, props.items, props.isItemDisabled),
  22873. isOpen: !0
  22874. };
  22875. break;
  22876. case ToggleButtonKeyDownEnd:
  22877. changes = {
  22878. highlightedIndex: getNonDisabledIndex(props.items.length - 1, !0, props.items, props.isItemDisabled),
  22879. isOpen: !0
  22880. };
  22881. break;
  22882. case ToggleButtonKeyDownPageUp:
  22883. changes = {
  22884. highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled)
  22885. };
  22886. break;
  22887. case ToggleButtonKeyDownPageDown:
  22888. changes = {
  22889. highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled)
  22890. };
  22891. break;
  22892. case ToggleButtonKeyDownEscape:
  22893. changes = {
  22894. isOpen: !1,
  22895. highlightedIndex: -1
  22896. };
  22897. break;
  22898. case ToggleButtonBlur:
  22899. changes = _extends({
  22900. isOpen: !1,
  22901. highlightedIndex: -1
  22902. }, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && {
  22903. selectedItem: props.items[state.highlightedIndex]
  22904. });
  22905. break;
  22906. case FunctionSelectItem$1:
  22907. changes = {
  22908. selectedItem: action.selectedItem
  22909. };
  22910. break;
  22911. default:
  22912. return downshiftCommonReducer(state, action, stateChangeTypes$2);
  22913. }
  22914. return _extends({}, state, changes);
  22915. }
  22916. 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"];
  22917. useSelect.stateChangeTypes = stateChangeTypes$2;
  22918. function useSelect(userProps) {
  22919. userProps === void 0 && (userProps = {}), validatePropTypes$2(userProps, useSelect);
  22920. 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({
  22921. state,
  22922. props
  22923. }), getItemNodeFromIndex = useCallback(function(index) {
  22924. return itemRefs.current[elementIds.getItemId(index)];
  22925. }, [elementIds]);
  22926. useA11yMessageStatus(getA11yStatusMessage2, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
  22927. var shouldScrollRef = useScrollIntoView({
  22928. menuElement: menuRef.current,
  22929. highlightedIndex,
  22930. isOpen,
  22931. itemRefs,
  22932. scrollIntoView: scrollIntoView3,
  22933. getItemNodeFromIndex
  22934. });
  22935. useEffect(function() {
  22936. return clearTimeoutRef.current = debounce4(function(outerDispatch) {
  22937. outerDispatch({
  22938. type: FunctionSetInputValue$1,
  22939. inputValue: ""
  22940. });
  22941. }, 500), function() {
  22942. clearTimeoutRef.current.cancel();
  22943. };
  22944. }, []), useEffect(function() {
  22945. inputValue && clearTimeoutRef.current(dispatch);
  22946. }, [dispatch, inputValue]), useControlPropsValidator({
  22947. props,
  22948. state
  22949. }), useEffect(function() {
  22950. var focusOnOpen = getInitialValue$1(props, "isOpen");
  22951. focusOnOpen && toggleButtonRef.current && toggleButtonRef.current.focus();
  22952. }, []);
  22953. var mouseAndTouchTrackers = useMouseAndTouchTracker(environment, useCallback(function() {
  22954. latest.current.state.isOpen && dispatch({
  22955. type: ToggleButtonBlur
  22956. });
  22957. }, [dispatch, latest]), useMemo(function() {
  22958. return [menuRef, toggleButtonRef];
  22959. }, [menuRef.current, toggleButtonRef.current])), setGetterPropCallInfo = useGetterPropsCalledChecker("getMenuProps", "getToggleButtonProps");
  22960. useEffect(function() {
  22961. isOpen || (itemRefs.current = {});
  22962. }, [isOpen]);
  22963. var toggleButtonKeyDownHandlers = useMemo(function() {
  22964. return {
  22965. ArrowDown: function(event) {
  22966. event.preventDefault(), dispatch({
  22967. type: ToggleButtonKeyDownArrowDown,
  22968. altKey: event.altKey
  22969. });
  22970. },
  22971. ArrowUp: function(event) {
  22972. event.preventDefault(), dispatch({
  22973. type: ToggleButtonKeyDownArrowUp,
  22974. altKey: event.altKey
  22975. });
  22976. },
  22977. Home: function(event) {
  22978. event.preventDefault(), dispatch({
  22979. type: ToggleButtonKeyDownHome
  22980. });
  22981. },
  22982. End: function(event) {
  22983. event.preventDefault(), dispatch({
  22984. type: ToggleButtonKeyDownEnd
  22985. });
  22986. },
  22987. Escape: function() {
  22988. latest.current.state.isOpen && dispatch({
  22989. type: ToggleButtonKeyDownEscape
  22990. });
  22991. },
  22992. Enter: function(event) {
  22993. event.preventDefault(), dispatch({
  22994. type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
  22995. });
  22996. },
  22997. PageUp: function(event) {
  22998. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  22999. type: ToggleButtonKeyDownPageUp
  23000. }));
  23001. },
  23002. PageDown: function(event) {
  23003. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23004. type: ToggleButtonKeyDownPageDown
  23005. }));
  23006. },
  23007. " ": function(event) {
  23008. event.preventDefault();
  23009. var currentState = latest.current.state;
  23010. if (!currentState.isOpen) {
  23011. dispatch({
  23012. type: ToggleButtonClick$1
  23013. });
  23014. return;
  23015. }
  23016. currentState.inputValue ? dispatch({
  23017. type: ToggleButtonKeyDownCharacter,
  23018. key: " "
  23019. }) : dispatch({
  23020. type: ToggleButtonKeyDownSpaceButton
  23021. });
  23022. }
  23023. };
  23024. }, [dispatch, latest]), toggleMenu = useCallback(function() {
  23025. dispatch({
  23026. type: FunctionToggleMenu$1
  23027. });
  23028. }, [dispatch]), closeMenu = useCallback(function() {
  23029. dispatch({
  23030. type: FunctionCloseMenu$1
  23031. });
  23032. }, [dispatch]), openMenu = useCallback(function() {
  23033. dispatch({
  23034. type: FunctionOpenMenu$1
  23035. });
  23036. }, [dispatch]), setHighlightedIndex = useCallback(function(newHighlightedIndex) {
  23037. dispatch({
  23038. type: FunctionSetHighlightedIndex$1,
  23039. highlightedIndex: newHighlightedIndex
  23040. });
  23041. }, [dispatch]), selectItem = useCallback(function(newSelectedItem) {
  23042. dispatch({
  23043. type: FunctionSelectItem$1,
  23044. selectedItem: newSelectedItem
  23045. });
  23046. }, [dispatch]), reset = useCallback(function() {
  23047. dispatch({
  23048. type: FunctionReset$2
  23049. });
  23050. }, [dispatch]), setInputValue = useCallback(function(newInputValue) {
  23051. dispatch({
  23052. type: FunctionSetInputValue$1,
  23053. inputValue: newInputValue
  23054. });
  23055. }, [dispatch]), getLabelProps = useCallback(function(_temp) {
  23056. var _ref = _temp === void 0 ? {} : _temp, onClick = _ref.onClick, labelProps = _objectWithoutPropertiesLoose2(_ref, _excluded$2), labelHandleClick = function() {
  23057. var _toggleButtonRef$curr;
  23058. (_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
  23059. };
  23060. return _extends({
  23061. id: elementIds.labelId,
  23062. htmlFor: elementIds.toggleButtonId,
  23063. onClick: callAllEventHandlers(onClick, labelHandleClick)
  23064. }, labelProps);
  23065. }, [elementIds]), getMenuProps = useCallback(function(_temp2, _temp3) {
  23066. 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() {
  23067. dispatch({
  23068. type: MenuMouseLeave$1
  23069. });
  23070. };
  23071. return setGetterPropCallInfo("getMenuProps", suppressRefError, refKey, menuRef), _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, function(menuNode) {
  23072. menuRef.current = menuNode;
  23073. }), _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);
  23074. }, [dispatch, setGetterPropCallInfo, elementIds]), getToggleButtonProps = useCallback(function(_temp4, _temp5) {
  23075. var _extends3, _ref4 = _temp4 === void 0 ? {} : _temp4, onBlur = _ref4.onBlur, onClick = _ref4.onClick;
  23076. _ref4.onPress;
  23077. 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() {
  23078. dispatch({
  23079. type: ToggleButtonClick$1
  23080. });
  23081. }, toggleButtonHandleBlur = function() {
  23082. latestState.isOpen && !mouseAndTouchTrackers.isMouseDown && dispatch({
  23083. type: ToggleButtonBlur
  23084. });
  23085. }, toggleButtonHandleKeyDown = function(event) {
  23086. var key = normalizeArrowKey(event);
  23087. key && toggleButtonKeyDownHandlers[key] ? toggleButtonKeyDownHandlers[key](event) : isAcceptedCharacterKey(key) && dispatch({
  23088. type: ToggleButtonKeyDownCharacter,
  23089. key
  23090. });
  23091. }, toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(toggleButtonNode) {
  23092. toggleButtonRef.current = toggleButtonNode;
  23093. }), _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);
  23094. return rest2.disabled || (toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick), toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown)), setGetterPropCallInfo("getToggleButtonProps", suppressRefError, refKey, toggleButtonRef), toggleProps;
  23095. }, [dispatch, elementIds, latest, mouseAndTouchTrackers, setGetterPropCallInfo, toggleButtonKeyDownHandlers]), getItemProps = useCallback(function(_temp6) {
  23096. var _extends4, _ref6 = _temp6 === void 0 ? {} : _temp6, itemProp = _ref6.item, indexProp = _ref6.index, onMouseMove = _ref6.onMouseMove, onClick = _ref6.onClick, onMouseDown = _ref6.onMouseDown;
  23097. _ref6.onPress;
  23098. var _ref6$refKey = _ref6.refKey, refKey = _ref6$refKey === void 0 ? "ref" : _ref6$refKey, disabledProp = _ref6.disabled, ref = _ref6.ref, rest2 = _objectWithoutPropertiesLoose2(_ref6, _excluded4$1);
  23099. disabledProp !== void 0 && console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.');
  23100. 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() {
  23101. mouseAndTouchTrackers.isTouchEnd || index === latestState.highlightedIndex || (shouldScrollRef.current = !1, dispatch({
  23102. type: ItemMouseMove$1,
  23103. index,
  23104. disabled
  23105. }));
  23106. }, itemHandleClick = function() {
  23107. dispatch({
  23108. type: ItemClick$1,
  23109. index
  23110. });
  23111. }, itemHandleMouseDown = function(e2) {
  23112. return e2.preventDefault();
  23113. }, itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function(itemNode) {
  23114. itemNode && (itemRefs.current[elementIds.getItemId(index)] = itemNode);
  23115. }), _extends4["aria-disabled"] = disabled, _extends4["aria-selected"] = item === latestState.selectedItem, _extends4.id = elementIds.getItemId(index), _extends4.role = "option", _extends4), rest2);
  23116. return disabled || (itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick)), itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove), itemProps.onMouseDown = callAllEventHandlers(onMouseDown, itemHandleMouseDown), itemProps;
  23117. }, [latest, elementIds, mouseAndTouchTrackers, shouldScrollRef, dispatch]);
  23118. return {
  23119. // prop getters.
  23120. getToggleButtonProps,
  23121. getLabelProps,
  23122. getMenuProps,
  23123. getItemProps,
  23124. // actions.
  23125. toggleMenu,
  23126. openMenu,
  23127. closeMenu,
  23128. setHighlightedIndex,
  23129. selectItem,
  23130. reset,
  23131. setInputValue,
  23132. // state.
  23133. highlightedIndex,
  23134. isOpen,
  23135. selectedItem,
  23136. inputValue
  23137. };
  23138. }
  23139. 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({
  23140. __proto__: null,
  23141. ControlledPropUpdatedSelectedItem,
  23142. FunctionCloseMenu,
  23143. FunctionOpenMenu,
  23144. FunctionReset: FunctionReset$1,
  23145. FunctionSelectItem,
  23146. FunctionSetHighlightedIndex,
  23147. FunctionSetInputValue,
  23148. FunctionToggleMenu,
  23149. InputBlur,
  23150. InputChange,
  23151. InputClick,
  23152. InputKeyDownArrowDown,
  23153. InputKeyDownArrowUp,
  23154. InputKeyDownEnd,
  23155. InputKeyDownEnter,
  23156. InputKeyDownEscape,
  23157. InputKeyDownHome,
  23158. InputKeyDownPageDown,
  23159. InputKeyDownPageUp,
  23160. ItemClick,
  23161. ItemMouseMove,
  23162. MenuMouseLeave,
  23163. ToggleButtonClick
  23164. });
  23165. function getInitialState$1(props) {
  23166. var initialState = getInitialState$2(props), selectedItem = initialState.selectedItem, inputValue = initialState.inputValue;
  23167. return inputValue === "" && selectedItem && props.defaultInputValue === void 0 && props.initialInputValue === void 0 && props.inputValue === void 0 && (inputValue = props.itemToString(selectedItem)), _extends({}, initialState, {
  23168. inputValue
  23169. });
  23170. }
  23171. var propTypes$1 = _extends({}, commonDropdownPropTypes, {
  23172. items: import_prop_types3.default.array.isRequired,
  23173. isItemDisabled: import_prop_types3.default.func,
  23174. inputValue: import_prop_types3.default.string,
  23175. defaultInputValue: import_prop_types3.default.string,
  23176. initialInputValue: import_prop_types3.default.string,
  23177. inputId: import_prop_types3.default.string,
  23178. onInputValueChange: import_prop_types3.default.func
  23179. });
  23180. function useControlledReducer(reducer, props, createInitialState, isStateEqual2) {
  23181. var previousSelectedItemRef = useRef(), _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual2), state = _useEnhancedReducer[0], dispatch = _useEnhancedReducer[1], isInitialMount = useIsInitialMount();
  23182. return useEffect(function() {
  23183. if (isControlledProp(props, "selectedItem")) {
  23184. if (!isInitialMount) {
  23185. var shouldCallDispatch = props.itemToKey(props.selectedItem) !== props.itemToKey(previousSelectedItemRef.current);
  23186. shouldCallDispatch && dispatch({
  23187. type: ControlledPropUpdatedSelectedItem,
  23188. inputValue: props.itemToString(props.selectedItem)
  23189. });
  23190. }
  23191. previousSelectedItemRef.current = state.selectedItem === previousSelectedItemRef.current ? props.selectedItem : state.selectedItem;
  23192. }
  23193. }, [state.selectedItem, props.selectedItem]), [getState2(state, props), dispatch];
  23194. }
  23195. var validatePropTypes$1 = noop4, defaultProps$1 = _extends({}, defaultProps$3, {
  23196. isItemDisabled: function() {
  23197. return !1;
  23198. }
  23199. });
  23200. function downshiftUseComboboxReducer(state, action) {
  23201. var _props$items, type = action.type, props = action.props, altKey = action.altKey, changes;
  23202. switch (type) {
  23203. case ItemClick:
  23204. changes = {
  23205. isOpen: getDefaultValue$1(props, "isOpen"),
  23206. highlightedIndex: getDefaultHighlightedIndex(props),
  23207. selectedItem: props.items[action.index],
  23208. inputValue: props.itemToString(props.items[action.index])
  23209. };
  23210. break;
  23211. case InputKeyDownArrowDown:
  23212. state.isOpen ? changes = {
  23213. highlightedIndex: getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled, !0)
  23214. } : changes = {
  23215. highlightedIndex: altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1),
  23216. isOpen: props.items.length >= 0
  23217. };
  23218. break;
  23219. case InputKeyDownArrowUp:
  23220. state.isOpen ? altKey ? changes = getChangesOnSelection(props, state.highlightedIndex) : changes = {
  23221. highlightedIndex: getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled, !0)
  23222. } : changes = {
  23223. highlightedIndex: getHighlightedIndexOnOpen(props, state, -1),
  23224. isOpen: props.items.length >= 0
  23225. };
  23226. break;
  23227. case InputKeyDownEnter:
  23228. changes = getChangesOnSelection(props, state.highlightedIndex);
  23229. break;
  23230. case InputKeyDownEscape:
  23231. changes = _extends({
  23232. isOpen: !1,
  23233. highlightedIndex: -1
  23234. }, !state.isOpen && {
  23235. selectedItem: null,
  23236. inputValue: ""
  23237. });
  23238. break;
  23239. case InputKeyDownPageUp:
  23240. changes = {
  23241. highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled, !0)
  23242. };
  23243. break;
  23244. case InputKeyDownPageDown:
  23245. changes = {
  23246. highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled, !0)
  23247. };
  23248. break;
  23249. case InputKeyDownHome:
  23250. changes = {
  23251. highlightedIndex: getNonDisabledIndex(0, !1, props.items, props.isItemDisabled)
  23252. };
  23253. break;
  23254. case InputKeyDownEnd:
  23255. changes = {
  23256. highlightedIndex: getNonDisabledIndex(props.items.length - 1, !0, props.items, props.isItemDisabled)
  23257. };
  23258. break;
  23259. case InputBlur:
  23260. changes = _extends({
  23261. isOpen: !1,
  23262. highlightedIndex: -1
  23263. }, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && action.selectItem && {
  23264. selectedItem: props.items[state.highlightedIndex],
  23265. inputValue: props.itemToString(props.items[state.highlightedIndex])
  23266. });
  23267. break;
  23268. case InputChange:
  23269. changes = {
  23270. isOpen: !0,
  23271. highlightedIndex: getDefaultHighlightedIndex(props),
  23272. inputValue: action.inputValue
  23273. };
  23274. break;
  23275. case InputClick:
  23276. changes = {
  23277. isOpen: !state.isOpen,
  23278. highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
  23279. };
  23280. break;
  23281. case FunctionSelectItem:
  23282. changes = {
  23283. selectedItem: action.selectedItem,
  23284. inputValue: props.itemToString(action.selectedItem)
  23285. };
  23286. break;
  23287. case ControlledPropUpdatedSelectedItem:
  23288. changes = {
  23289. inputValue: action.inputValue
  23290. };
  23291. break;
  23292. default:
  23293. return downshiftCommonReducer(state, action, stateChangeTypes$1);
  23294. }
  23295. return _extends({}, state, changes);
  23296. }
  23297. 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"];
  23298. useCombobox.stateChangeTypes = stateChangeTypes$1;
  23299. function useCombobox(userProps) {
  23300. userProps === void 0 && (userProps = {}), validatePropTypes$1(userProps, useCombobox);
  23301. 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({
  23302. state,
  23303. props
  23304. }), getItemNodeFromIndex = useCallback(function(index) {
  23305. return itemRefs.current[elementIds.getItemId(index)];
  23306. }, [elementIds]);
  23307. useA11yMessageStatus(getA11yStatusMessage2, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
  23308. var shouldScrollRef = useScrollIntoView({
  23309. menuElement: menuRef.current,
  23310. highlightedIndex,
  23311. isOpen,
  23312. itemRefs,
  23313. scrollIntoView: scrollIntoView3,
  23314. getItemNodeFromIndex
  23315. });
  23316. useControlPropsValidator({
  23317. props,
  23318. state
  23319. }), useEffect(function() {
  23320. var focusOnOpen = getInitialValue$1(props, "isOpen");
  23321. focusOnOpen && inputRef.current && inputRef.current.focus();
  23322. }, []), useEffect(function() {
  23323. isInitialMount || (previousResultCountRef.current = items.length);
  23324. });
  23325. var mouseAndTouchTrackers = useMouseAndTouchTracker(environment, useCallback(function() {
  23326. latest.current.state.isOpen && dispatch({
  23327. type: InputBlur,
  23328. selectItem: !1
  23329. });
  23330. }, [dispatch, latest]), useMemo(function() {
  23331. return [menuRef, toggleButtonRef, inputRef];
  23332. }, [menuRef.current, toggleButtonRef.current, inputRef.current])), setGetterPropCallInfo = useGetterPropsCalledChecker("getInputProps", "getMenuProps");
  23333. useEffect(function() {
  23334. isOpen || (itemRefs.current = {});
  23335. }, [isOpen]), useEffect(function() {
  23336. var _inputRef$current;
  23337. !isOpen || !(environment != null && environment.document) || !(inputRef != null && (_inputRef$current = inputRef.current) != null && _inputRef$current.focus) || environment.document.activeElement !== inputRef.current && inputRef.current.focus();
  23338. }, [isOpen, environment]);
  23339. var inputKeyDownHandlers = useMemo(function() {
  23340. return {
  23341. ArrowDown: function(event) {
  23342. event.preventDefault(), dispatch({
  23343. type: InputKeyDownArrowDown,
  23344. altKey: event.altKey
  23345. });
  23346. },
  23347. ArrowUp: function(event) {
  23348. event.preventDefault(), dispatch({
  23349. type: InputKeyDownArrowUp,
  23350. altKey: event.altKey
  23351. });
  23352. },
  23353. Home: function(event) {
  23354. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23355. type: InputKeyDownHome
  23356. }));
  23357. },
  23358. End: function(event) {
  23359. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23360. type: InputKeyDownEnd
  23361. }));
  23362. },
  23363. Escape: function(event) {
  23364. var latestState = latest.current.state;
  23365. (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) && (event.preventDefault(), dispatch({
  23366. type: InputKeyDownEscape
  23367. }));
  23368. },
  23369. Enter: function(event) {
  23370. var latestState = latest.current.state;
  23371. !latestState.isOpen || event.which === 229 || (event.preventDefault(), dispatch({
  23372. type: InputKeyDownEnter
  23373. }));
  23374. },
  23375. PageUp: function(event) {
  23376. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23377. type: InputKeyDownPageUp
  23378. }));
  23379. },
  23380. PageDown: function(event) {
  23381. latest.current.state.isOpen && (event.preventDefault(), dispatch({
  23382. type: InputKeyDownPageDown
  23383. }));
  23384. }
  23385. };
  23386. }, [dispatch, latest]), getLabelProps = useCallback(function(labelProps) {
  23387. return _extends({
  23388. id: elementIds.labelId,
  23389. htmlFor: elementIds.inputId
  23390. }, labelProps);
  23391. }, [elementIds]), getMenuProps = useCallback(function(_temp, _temp2) {
  23392. 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;
  23393. return setGetterPropCallInfo("getMenuProps", suppressRefError, refKey, menuRef), _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, function(menuNode) {
  23394. menuRef.current = menuNode;
  23395. }), _extends22.id = elementIds.menuId, _extends22.role = "listbox", _extends22["aria-labelledby"] = rest2 && rest2["aria-label"] ? void 0 : "" + elementIds.labelId, _extends22.onMouseLeave = callAllEventHandlers(onMouseLeave, function() {
  23396. dispatch({
  23397. type: MenuMouseLeave
  23398. });
  23399. }), _extends22), rest2);
  23400. }, [dispatch, setGetterPropCallInfo, elementIds]), getItemProps = useCallback(function(_temp3) {
  23401. 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;
  23402. _ref3.onPress;
  23403. var disabledProp = _ref3.disabled, rest2 = _objectWithoutPropertiesLoose2(_ref3, _excluded2$1);
  23404. disabledProp !== void 0 && console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');
  23405. 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() {
  23406. mouseAndTouchTrackers.isTouchEnd || index === latestState.highlightedIndex || (shouldScrollRef.current = !1, dispatch({
  23407. type: ItemMouseMove,
  23408. index,
  23409. disabled
  23410. }));
  23411. }, itemHandleClick = function() {
  23412. dispatch({
  23413. type: ItemClick,
  23414. index
  23415. });
  23416. }, itemHandleMouseDown = function(e2) {
  23417. return e2.preventDefault();
  23418. };
  23419. return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(itemNode) {
  23420. itemNode && (itemRefs.current[elementIds.getItemId(index)] = itemNode);
  23421. }), _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), {
  23422. onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
  23423. onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
  23424. }, rest2);
  23425. }, [dispatch, elementIds, latest, mouseAndTouchTrackers, shouldScrollRef]), getToggleButtonProps = useCallback(function(_temp4) {
  23426. var _extends4, _ref5 = _temp4 === void 0 ? {} : _temp4, onClick = _ref5.onClick;
  23427. _ref5.onPress;
  23428. 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() {
  23429. dispatch({
  23430. type: ToggleButtonClick
  23431. });
  23432. };
  23433. return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function(toggleButtonNode) {
  23434. toggleButtonRef.current = toggleButtonNode;
  23435. }), _extends4["aria-controls"] = elementIds.menuId, _extends4["aria-expanded"] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest2.disabled && _extends({}, {
  23436. onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
  23437. }), rest2);
  23438. }, [dispatch, latest, elementIds]), getInputProps = useCallback(function(_temp5, _temp6) {
  23439. var _extends5, _ref6 = _temp5 === void 0 ? {} : _temp5, onKeyDown = _ref6.onKeyDown, onChange = _ref6.onChange, onInput = _ref6.onInput, onBlur = _ref6.onBlur;
  23440. _ref6.onChangeText;
  23441. 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;
  23442. setGetterPropCallInfo("getInputProps", suppressRefError, refKey, inputRef);
  23443. var latestState = latest.current.state, inputHandleKeyDown = function(event) {
  23444. var key = normalizeArrowKey(event);
  23445. key && inputKeyDownHandlers[key] && inputKeyDownHandlers[key](event);
  23446. }, inputHandleChange = function(event) {
  23447. dispatch({
  23448. type: InputChange,
  23449. inputValue: event.target.value
  23450. });
  23451. }, inputHandleBlur = function(event) {
  23452. if (environment != null && environment.document && latestState.isOpen && !mouseAndTouchTrackers.isMouseDown) {
  23453. var isBlurByTabChange = event.relatedTarget === null && environment.document.activeElement !== environment.document.body;
  23454. dispatch({
  23455. type: InputBlur,
  23456. selectItem: !isBlurByTabChange
  23457. });
  23458. }
  23459. }, inputHandleClick = function() {
  23460. dispatch({
  23461. type: InputClick
  23462. });
  23463. }, onChangeKey = "onChange", eventHandlers = {};
  23464. if (!rest2.disabled) {
  23465. var _eventHandlers;
  23466. eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
  23467. }
  23468. return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function(inputNode) {
  23469. inputRef.current = inputNode;
  23470. }), _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);
  23471. }, [dispatch, elementIds, environment, inputKeyDownHandlers, latest, mouseAndTouchTrackers, setGetterPropCallInfo]), toggleMenu = useCallback(function() {
  23472. dispatch({
  23473. type: FunctionToggleMenu
  23474. });
  23475. }, [dispatch]), closeMenu = useCallback(function() {
  23476. dispatch({
  23477. type: FunctionCloseMenu
  23478. });
  23479. }, [dispatch]), openMenu = useCallback(function() {
  23480. dispatch({
  23481. type: FunctionOpenMenu
  23482. });
  23483. }, [dispatch]), setHighlightedIndex = useCallback(function(newHighlightedIndex) {
  23484. dispatch({
  23485. type: FunctionSetHighlightedIndex,
  23486. highlightedIndex: newHighlightedIndex
  23487. });
  23488. }, [dispatch]), selectItem = useCallback(function(newSelectedItem) {
  23489. dispatch({
  23490. type: FunctionSelectItem,
  23491. selectedItem: newSelectedItem
  23492. });
  23493. }, [dispatch]), setInputValue = useCallback(function(newInputValue) {
  23494. dispatch({
  23495. type: FunctionSetInputValue,
  23496. inputValue: newInputValue
  23497. });
  23498. }, [dispatch]), reset = useCallback(function() {
  23499. dispatch({
  23500. type: FunctionReset$1
  23501. });
  23502. }, [dispatch]);
  23503. return {
  23504. // prop getters.
  23505. getItemProps,
  23506. getLabelProps,
  23507. getMenuProps,
  23508. getInputProps,
  23509. getToggleButtonProps,
  23510. // actions.
  23511. toggleMenu,
  23512. openMenu,
  23513. closeMenu,
  23514. setHighlightedIndex,
  23515. setInputValue,
  23516. selectItem,
  23517. reset,
  23518. // state.
  23519. highlightedIndex,
  23520. isOpen,
  23521. selectedItem,
  23522. inputValue
  23523. };
  23524. }
  23525. var defaultStateValues = {
  23526. activeIndex: -1,
  23527. selectedItems: []
  23528. };
  23529. function getInitialValue(props, propKey) {
  23530. return getInitialValue$1(props, propKey, defaultStateValues);
  23531. }
  23532. function getDefaultValue(props, propKey) {
  23533. return getDefaultValue$1(props, propKey, defaultStateValues);
  23534. }
  23535. function getInitialState(props) {
  23536. var activeIndex = getInitialValue(props, "activeIndex"), selectedItems = getInitialValue(props, "selectedItems");
  23537. return {
  23538. activeIndex,
  23539. selectedItems
  23540. };
  23541. }
  23542. function isKeyDownOperationPermitted(event) {
  23543. if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey)
  23544. return !1;
  23545. var element = event.target;
  23546. return !(element instanceof HTMLInputElement && // if element is a text input
  23547. element.value !== "" && // and we have text in it
  23548. // and cursor is either not at the start or is currently highlighting text.
  23549. (element.selectionStart !== 0 || element.selectionEnd !== 0));
  23550. }
  23551. function isStateEqual(prevState, newState) {
  23552. return prevState.selectedItems === newState.selectedItems && prevState.activeIndex === newState.activeIndex;
  23553. }
  23554. var propTypes = {
  23555. stateReducer: commonPropTypes.stateReducer,
  23556. itemToKey: commonPropTypes.itemToKey,
  23557. environment: commonPropTypes.environment,
  23558. selectedItems: import_prop_types3.default.array,
  23559. initialSelectedItems: import_prop_types3.default.array,
  23560. defaultSelectedItems: import_prop_types3.default.array,
  23561. getA11yStatusMessage: import_prop_types3.default.func,
  23562. activeIndex: import_prop_types3.default.number,
  23563. initialActiveIndex: import_prop_types3.default.number,
  23564. defaultActiveIndex: import_prop_types3.default.number,
  23565. onActiveIndexChange: import_prop_types3.default.func,
  23566. onSelectedItemsChange: import_prop_types3.default.func,
  23567. keyNavigationNext: import_prop_types3.default.string,
  23568. keyNavigationPrevious: import_prop_types3.default.string
  23569. }, defaultProps2 = {
  23570. itemToKey: defaultProps$3.itemToKey,
  23571. stateReducer: defaultProps$3.stateReducer,
  23572. environment: defaultProps$3.environment,
  23573. keyNavigationNext: "ArrowRight",
  23574. keyNavigationPrevious: "ArrowLeft"
  23575. }, 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({
  23576. __proto__: null,
  23577. DropdownClick,
  23578. DropdownKeyDownBackspace,
  23579. DropdownKeyDownNavigationPrevious,
  23580. FunctionAddSelectedItem,
  23581. FunctionRemoveSelectedItem,
  23582. FunctionReset,
  23583. FunctionSetActiveIndex,
  23584. FunctionSetSelectedItems,
  23585. SelectedItemClick,
  23586. SelectedItemKeyDownBackspace,
  23587. SelectedItemKeyDownDelete,
  23588. SelectedItemKeyDownNavigationNext,
  23589. SelectedItemKeyDownNavigationPrevious
  23590. });
  23591. function downshiftMultipleSelectionReducer(state, action) {
  23592. var type = action.type, index = action.index, props = action.props, selectedItem = action.selectedItem, activeIndex = state.activeIndex, selectedItems = state.selectedItems, changes;
  23593. switch (type) {
  23594. case SelectedItemClick:
  23595. changes = {
  23596. activeIndex: index
  23597. };
  23598. break;
  23599. case SelectedItemKeyDownNavigationPrevious:
  23600. changes = {
  23601. activeIndex: activeIndex - 1 < 0 ? 0 : activeIndex - 1
  23602. };
  23603. break;
  23604. case SelectedItemKeyDownNavigationNext:
  23605. changes = {
  23606. activeIndex: activeIndex + 1 >= selectedItems.length ? -1 : activeIndex + 1
  23607. };
  23608. break;
  23609. case SelectedItemKeyDownBackspace:
  23610. case SelectedItemKeyDownDelete: {
  23611. if (activeIndex < 0)
  23612. break;
  23613. var newActiveIndex = activeIndex;
  23614. selectedItems.length === 1 ? newActiveIndex = -1 : activeIndex === selectedItems.length - 1 && (newActiveIndex = selectedItems.length - 2), changes = _extends({
  23615. selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
  23616. }, {
  23617. activeIndex: newActiveIndex
  23618. });
  23619. break;
  23620. }
  23621. case DropdownKeyDownNavigationPrevious:
  23622. changes = {
  23623. activeIndex: selectedItems.length - 1
  23624. };
  23625. break;
  23626. case DropdownKeyDownBackspace:
  23627. changes = {
  23628. selectedItems: selectedItems.slice(0, selectedItems.length - 1)
  23629. };
  23630. break;
  23631. case FunctionAddSelectedItem:
  23632. changes = {
  23633. selectedItems: [].concat(selectedItems, [selectedItem])
  23634. };
  23635. break;
  23636. case DropdownClick:
  23637. changes = {
  23638. activeIndex: -1
  23639. };
  23640. break;
  23641. case FunctionRemoveSelectedItem: {
  23642. var _newActiveIndex = activeIndex, selectedItemIndex = selectedItems.findIndex(function(item) {
  23643. return props.itemToKey(item) === props.itemToKey(selectedItem);
  23644. });
  23645. if (selectedItemIndex < 0)
  23646. break;
  23647. selectedItems.length === 1 ? _newActiveIndex = -1 : selectedItemIndex === selectedItems.length - 1 && (_newActiveIndex = selectedItems.length - 2), changes = {
  23648. selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1)),
  23649. activeIndex: _newActiveIndex
  23650. };
  23651. break;
  23652. }
  23653. case FunctionSetSelectedItems: {
  23654. var newSelectedItems = action.selectedItems;
  23655. changes = {
  23656. selectedItems: newSelectedItems
  23657. };
  23658. break;
  23659. }
  23660. case FunctionSetActiveIndex: {
  23661. var _newActiveIndex2 = action.activeIndex;
  23662. changes = {
  23663. activeIndex: _newActiveIndex2
  23664. };
  23665. break;
  23666. }
  23667. case FunctionReset:
  23668. changes = {
  23669. activeIndex: getDefaultValue(props, "activeIndex"),
  23670. selectedItems: getDefaultValue(props, "selectedItems")
  23671. };
  23672. break;
  23673. default:
  23674. throw new Error("Reducer called without proper action type.");
  23675. }
  23676. return _extends({}, state, changes);
  23677. }
  23678. var _excluded2 = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"], _excluded22 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
  23679. useMultipleSelection.stateChangeTypes = stateChangeTypes;
  23680. function useMultipleSelection(userProps) {
  23681. userProps === void 0 && (userProps = {}), validatePropTypes(userProps, useMultipleSelection);
  23682. 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();
  23683. selectedItemRefs.current = [];
  23684. var latest = useLatestRef({
  23685. state,
  23686. props
  23687. });
  23688. useA11yMessageStatus(getA11yStatusMessage2, state, [activeIndex, selectedItems], environment), useEffect(function() {
  23689. isInitialMount || (activeIndex === -1 && dropdownRef.current ? dropdownRef.current.focus() : selectedItemRefs.current[activeIndex] && selectedItemRefs.current[activeIndex].focus());
  23690. }, [activeIndex]), useControlPropsValidator({
  23691. props,
  23692. state
  23693. });
  23694. var setGetterPropCallInfo = useGetterPropsCalledChecker("getDropdownProps"), selectedItemKeyDownHandlers = useMemo(function() {
  23695. var _ref;
  23696. return _ref = {}, _ref[keyNavigationPrevious] = function() {
  23697. dispatch({
  23698. type: SelectedItemKeyDownNavigationPrevious
  23699. });
  23700. }, _ref[keyNavigationNext] = function() {
  23701. dispatch({
  23702. type: SelectedItemKeyDownNavigationNext
  23703. });
  23704. }, _ref.Delete = function() {
  23705. dispatch({
  23706. type: SelectedItemKeyDownDelete
  23707. });
  23708. }, _ref.Backspace = function() {
  23709. dispatch({
  23710. type: SelectedItemKeyDownBackspace
  23711. });
  23712. }, _ref;
  23713. }, [dispatch, keyNavigationNext, keyNavigationPrevious]), dropdownKeyDownHandlers = useMemo(function() {
  23714. var _ref2;
  23715. return _ref2 = {}, _ref2[keyNavigationPrevious] = function(event) {
  23716. isKeyDownOperationPermitted(event) && dispatch({
  23717. type: DropdownKeyDownNavigationPrevious
  23718. });
  23719. }, _ref2.Backspace = function(event) {
  23720. isKeyDownOperationPermitted(event) && dispatch({
  23721. type: DropdownKeyDownBackspace
  23722. });
  23723. }, _ref2;
  23724. }, [dispatch, keyNavigationPrevious]), getSelectedItemProps = useCallback(function(_temp) {
  23725. 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() {
  23726. dispatch({
  23727. type: SelectedItemClick,
  23728. index
  23729. });
  23730. }, selectedItemHandleKeyDown = function(event) {
  23731. var key = normalizeArrowKey(event);
  23732. key && selectedItemKeyDownHandlers[key] && selectedItemKeyDownHandlers[key](event);
  23733. };
  23734. return _extends((_extends22 = {}, _extends22[refKey] = handleRefs(ref, function(selectedItemNode) {
  23735. selectedItemNode && selectedItemRefs.current.push(selectedItemNode);
  23736. }), _extends22.tabIndex = isFocusable ? 0 : -1, _extends22.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends22.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends22), rest2);
  23737. }, [dispatch, latest, selectedItemKeyDownHandlers]), getDropdownProps = useCallback(function(_temp2, _temp3) {
  23738. 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;
  23739. setGetterPropCallInfo("getDropdownProps", suppressRefError, refKey, dropdownRef);
  23740. var dropdownHandleKeyDown = function(event) {
  23741. var key = normalizeArrowKey(event);
  23742. key && dropdownKeyDownHandlers[key] && dropdownKeyDownHandlers[key](event);
  23743. }, dropdownHandleClick = function() {
  23744. dispatch({
  23745. type: DropdownClick
  23746. });
  23747. };
  23748. return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(dropdownNode) {
  23749. dropdownNode && (dropdownRef.current = dropdownNode);
  23750. }), _extends3), !preventKeyAction && {
  23751. onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
  23752. onClick: callAllEventHandlers(onClick, dropdownHandleClick)
  23753. }, rest2);
  23754. }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]), addSelectedItem = useCallback(function(selectedItem) {
  23755. dispatch({
  23756. type: FunctionAddSelectedItem,
  23757. selectedItem
  23758. });
  23759. }, [dispatch]), removeSelectedItem = useCallback(function(selectedItem) {
  23760. dispatch({
  23761. type: FunctionRemoveSelectedItem,
  23762. selectedItem
  23763. });
  23764. }, [dispatch]), setSelectedItems = useCallback(function(newSelectedItems) {
  23765. dispatch({
  23766. type: FunctionSetSelectedItems,
  23767. selectedItems: newSelectedItems
  23768. });
  23769. }, [dispatch]), setActiveIndex = useCallback(function(newActiveIndex) {
  23770. dispatch({
  23771. type: FunctionSetActiveIndex,
  23772. activeIndex: newActiveIndex
  23773. });
  23774. }, [dispatch]), reset = useCallback(function() {
  23775. dispatch({
  23776. type: FunctionReset
  23777. });
  23778. }, [dispatch]);
  23779. return {
  23780. getSelectedItemProps,
  23781. getDropdownProps,
  23782. addSelectedItem,
  23783. removeSelectedItem,
  23784. setSelectedItems,
  23785. setActiveIndex,
  23786. reset,
  23787. selectedItems,
  23788. activeIndex
  23789. };
  23790. }
  23791. // src/manager/components/sidebar/Search.tsx
  23792. var import_fuse = __toESM(require_fuse(), 1);
  23793. // src/manager/components/sidebar/types.ts
  23794. function isExpandType(x2) {
  23795. return !!(x2 && x2.showAll);
  23796. }
  23797. function isSearchResult(x2) {
  23798. return !!(x2 && x2.item);
  23799. }
  23800. // src/manager/components/sidebar/Search.tsx
  23801. var { document: document7 } = scope, DEFAULT_MAX_SEARCH_RESULTS = 50, options = {
  23802. shouldSort: !0,
  23803. tokenize: !0,
  23804. findAllMatches: !0,
  23805. includeScore: !0,
  23806. includeMatches: !0,
  23807. threshold: 0.2,
  23808. location: 0,
  23809. distance: 100,
  23810. maxPatternLength: 32,
  23811. minMatchCharLength: 1,
  23812. keys: [
  23813. { name: "name", weight: 0.7 },
  23814. { name: "path", weight: 0.3 }
  23815. ]
  23816. }, SearchBar = styled.div({
  23817. display: "flex",
  23818. flexDirection: "row",
  23819. columnGap: 6
  23820. }), ScreenReaderLabel = styled.label({
  23821. position: "absolute",
  23822. left: -1e4,
  23823. top: "auto",
  23824. width: 1,
  23825. height: 1,
  23826. overflow: "hidden"
  23827. }), SearchField2 = styled.div(({ theme, isMobile: isMobile2 }) => ({
  23828. display: "flex",
  23829. flexDirection: "row",
  23830. alignItems: "center",
  23831. padding: isMobile2 ? 4 : 2,
  23832. flexGrow: 1,
  23833. height: isMobile2 ? 36 : 32,
  23834. width: "100%",
  23835. boxShadow: `${theme.button.border} 0 0 0 1px inset`,
  23836. borderRadius: theme.appBorderRadius + 2,
  23837. "&:has(input:focus), &:has(input:active)": {
  23838. background: theme.background.app,
  23839. outline: `2px solid ${theme.color.secondary}`,
  23840. outlineOffset: 2
  23841. }
  23842. })), IconWrapper = styled.div(({ theme, onClick }) => ({
  23843. cursor: onClick ? "pointer" : "default",
  23844. flex: "0 0 28px",
  23845. height: "100%",
  23846. pointerEvents: onClick ? "auto" : "none",
  23847. color: theme.textMutedColor,
  23848. display: "flex",
  23849. alignItems: "center",
  23850. justifyContent: "center"
  23851. })), Input = styled.input(({ theme, isMobile: isMobile2 }) => ({
  23852. appearance: "none",
  23853. height: 28,
  23854. width: "100%",
  23855. padding: 0,
  23856. border: 0,
  23857. background: "transparent",
  23858. fontSize: isMobile2 ? "16px" : `${theme.typography.size.s1 + 1}px`,
  23859. fontFamily: "inherit",
  23860. transition: "all 150ms",
  23861. color: theme.color.defaultText,
  23862. outline: 0,
  23863. "&::placeholder": {
  23864. color: theme.textMutedColor,
  23865. opacity: 1
  23866. },
  23867. "&:valid ~ code, &:focus ~ code": {
  23868. display: "none"
  23869. },
  23870. "&:invalid ~ svg": {
  23871. display: "none"
  23872. },
  23873. "&:valid ~ svg": {
  23874. display: "block"
  23875. },
  23876. "&::-ms-clear": {
  23877. display: "none"
  23878. },
  23879. "&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration": {
  23880. display: "none"
  23881. }
  23882. })), FocusKey = styled.code(({ theme }) => ({
  23883. margin: 5,
  23884. marginTop: 6,
  23885. height: 16,
  23886. fontFamily: theme.typography.fonts.base,
  23887. lineHeight: "16px",
  23888. textAlign: "center",
  23889. fontSize: "11px",
  23890. color: theme.base === "light" ? theme.color.dark : theme.textMutedColor,
  23891. userSelect: "none",
  23892. pointerEvents: "none",
  23893. display: "flex",
  23894. alignItems: "center",
  23895. gap: 4,
  23896. flexShrink: 0
  23897. })), FocusKeyCmd = styled.span({
  23898. fontSize: "14px"
  23899. }), Actions = styled.div({
  23900. display: "flex",
  23901. alignItems: "center",
  23902. gap: 2
  23903. }), FocusContainer = styled.div({ outline: 0 }), Search = react_default.memo(function({
  23904. children,
  23905. dataset,
  23906. enableShortcuts = !0,
  23907. getLastViewed,
  23908. initialQuery = "",
  23909. searchBarContent,
  23910. searchFieldContent,
  23911. belowSearchContent
  23912. }) {
  23913. let api = useStorybookApi(), inputRef = useRef(null), [inputPlaceholder, setPlaceholder] = useState("Find components"), [allComponents, showAllComponents] = useState(!1), searchShortcut = api ? shortcutToHumanString(api.getShortcutKeys().search) : "/", makeFuse = useCallback(() => {
  23914. let list = dataset.entries.reduce((acc, [refId, { index, allStatuses }]) => {
  23915. let groupStatus = getGroupStatus(index || {}, allStatuses ?? {});
  23916. return index && acc.push(
  23917. ...Object.values(index).map((item) => {
  23918. let storyStatuses = allStatuses?.[item.id], mostCriticalStatusValue = storyStatuses ? getMostCriticalStatusValue(Object.values(storyStatuses).map((s2) => s2.value)) : null;
  23919. return {
  23920. ...searchItem(item, dataset.hash[refId]),
  23921. status: mostCriticalStatusValue ?? groupStatus[item.id] ?? null
  23922. };
  23923. })
  23924. ), acc;
  23925. }, []);
  23926. return new import_fuse.default(list, options);
  23927. }, [dataset]), getResults = useCallback(
  23928. (input) => {
  23929. let fuse = makeFuse();
  23930. if (!input)
  23931. return [];
  23932. 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)
  23933. resultIds.has(item.parent) ? !1 : (resultIds.add(item.id), !0));
  23934. return distinctResults.length && (results = distinctResults.slice(0, allComponents ? 1e3 : DEFAULT_MAX_SEARCH_RESULTS), distinctResults.length > DEFAULT_MAX_SEARCH_RESULTS && !allComponents && results.push({
  23935. showAll: () => showAllComponents(!0),
  23936. totalCount: distinctResults.length,
  23937. moreCount: distinctResults.length - DEFAULT_MAX_SEARCH_RESULTS
  23938. })), results;
  23939. },
  23940. [allComponents, makeFuse]
  23941. ), onSelect = useCallback(
  23942. (selectedItem) => {
  23943. if (isSearchResult(selectedItem)) {
  23944. let { id, refId } = selectedItem.item;
  23945. api?.selectStory(id, void 0, { ref: refId !== DEFAULT_REF_ID && refId }), inputRef.current.blur(), showAllComponents(!1);
  23946. return;
  23947. }
  23948. isExpandType(selectedItem) && selectedItem.showAll();
  23949. },
  23950. [api]
  23951. ), onInputValueChange = useCallback((inputValue, stateAndHelpers) => {
  23952. showAllComponents(!1);
  23953. }, []), stateReducer2 = useCallback(
  23954. (state, changes) => {
  23955. switch (changes.type) {
  23956. case Downshift.stateChangeTypes.blurInput:
  23957. return {
  23958. ...changes,
  23959. // Prevent clearing the input on blur
  23960. inputValue: state.inputValue,
  23961. // Return to the tree view after selecting an item
  23962. isOpen: state.inputValue && !state.selectedItem
  23963. };
  23964. case Downshift.stateChangeTypes.mouseUp:
  23965. return state;
  23966. case Downshift.stateChangeTypes.keyDownEscape:
  23967. return state.inputValue ? { ...changes, inputValue: "", isOpen: !0, selectedItem: null } : { ...changes, isOpen: !1, selectedItem: null };
  23968. case Downshift.stateChangeTypes.clickItem:
  23969. case Downshift.stateChangeTypes.keyDownEnter:
  23970. return isSearchResult(changes.selectedItem) ? { ...changes, inputValue: state.inputValue } : isExpandType(changes.selectedItem) ? state : changes;
  23971. default:
  23972. return changes;
  23973. }
  23974. },
  23975. []
  23976. ), { isMobile: isMobile2 } = useLayout(), searchLandmarkRef = useRef(null), { landmarkProps } = useLandmark({ role: "search" }, searchLandmarkRef);
  23977. return (
  23978. // @ts-expect-error (non strict)
  23979. react_default.createElement(
  23980. Downshift,
  23981. {
  23982. initialInputValue: initialQuery,
  23983. stateReducer: stateReducer2,
  23984. itemToString: (result) => result?.item?.name || "",
  23985. scrollIntoView: (e2) => scrollIntoView(e2),
  23986. onSelect,
  23987. onInputValueChange
  23988. },
  23989. ({
  23990. isOpen,
  23991. openMenu,
  23992. closeMenu,
  23993. inputValue,
  23994. getInputProps,
  23995. getItemProps,
  23996. getLabelProps,
  23997. getMenuProps,
  23998. getRootProps,
  23999. highlightedIndex,
  24000. reset
  24001. }) => {
  24002. let input = inputValue ? inputValue.trim() : "", results = input ? getResults(input) : [], lastViewed = !input && getLastViewed();
  24003. lastViewed && lastViewed.length && (results = lastViewed.reduce((acc, { storyId, refId }) => {
  24004. let data = dataset.hash[refId];
  24005. if (data && data.index && data.index[storyId]) {
  24006. let story = data.index[storyId], item = story.type === "story" ? data.index[story.parent] : story;
  24007. acc.some((res) => res.item.refId === refId && res.item.id === item.id) || acc.push({ item: searchItem(item, dataset.hash[refId]), matches: [], score: 0 });
  24008. }
  24009. return acc;
  24010. }, []));
  24011. let inputId = "storybook-explorer-searchfield", inputProps = getInputProps({
  24012. id: inputId,
  24013. ref: inputRef,
  24014. required: !0,
  24015. type: "search",
  24016. placeholder: inputPlaceholder,
  24017. onFocus: () => {
  24018. openMenu(), setPlaceholder("Type to find...");
  24019. },
  24020. onBlur: () => setPlaceholder("Find components"),
  24021. onKeyDown: (e2) => {
  24022. e2.key === "Escape" && inputValue.length === 0 && inputRef.current.blur();
  24023. }
  24024. }), labelProps = getLabelProps({
  24025. htmlFor: inputId
  24026. });
  24027. 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(
  24028. SearchField2,
  24029. {
  24030. ...getRootProps({ refKey: "" }, { suppressRefError: !0 }),
  24031. isMobile: isMobile2,
  24032. className: "search-field"
  24033. },
  24034. react_default.createElement(IconWrapper, null, react_default.createElement(SearchIcon, null)),
  24035. react_default.createElement(Input, { ...inputProps, isMobile: isMobile2 }),
  24036. !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),
  24037. react_default.createElement(Actions, null, input && react_default.createElement(
  24038. Button,
  24039. {
  24040. padding: "small",
  24041. variant: "ghost",
  24042. ariaLabel: "Clear search",
  24043. onClick: () => {
  24044. reset({ inputValue: "" }), closeMenu(), inputRef.current?.focus();
  24045. }
  24046. },
  24047. react_default.createElement(CloseIcon, null)
  24048. ), searchFieldContent)
  24049. ), searchBarContent), !isOpen && belowSearchContent, react_default.createElement(FocusContainer, { tabIndex: 0, id: "storybook-explorer-menu" }, children({
  24050. query: input,
  24051. results,
  24052. isNavVisible: !isOpen && document7.activeElement !== inputRef.current,
  24053. isNavReachable: !isOpen || input.length === 0,
  24054. isSearchResultRendered: isOpen,
  24055. closeMenu,
  24056. getMenuProps,
  24057. getItemProps,
  24058. highlightedIndex
  24059. })));
  24060. }
  24061. )
  24062. );
  24063. });
  24064. // src/manager/components/sidebar/SearchResults.tsx
  24065. init_react();
  24066. var { document: document8 } = scope, ResultsList = styled.ol({
  24067. listStyle: "none",
  24068. margin: 0,
  24069. padding: 0
  24070. }), ResultRow = styled.li(({ theme, isHighlighted }) => ({
  24071. width: "100%",
  24072. border: "none",
  24073. cursor: "pointer",
  24074. display: "flex",
  24075. alignItems: "start",
  24076. justifyContent: "space-between",
  24077. textAlign: "left",
  24078. color: "inherit",
  24079. fontSize: `${theme.typography.size.s2}px`,
  24080. background: isHighlighted ? theme.background.hoverable : "transparent",
  24081. minHeight: 28,
  24082. borderRadius: 4,
  24083. gap: 6,
  24084. paddingTop: 7,
  24085. paddingBottom: 7,
  24086. paddingLeft: 8,
  24087. paddingRight: 8,
  24088. "&:hover, &:focus": {
  24089. background: curriedTransparentize$1(0.93, theme.color.secondary),
  24090. outline: "none"
  24091. }
  24092. })), IconWrapper2 = styled.div({
  24093. marginTop: 2
  24094. }), ResultRowContent = styled.div({
  24095. flex: 1,
  24096. display: "flex",
  24097. flexDirection: "column"
  24098. }), Mark = styled.mark(({ theme }) => ({
  24099. background: "transparent",
  24100. color: theme.color.secondary,
  24101. "@media (forced-colors: active)": {
  24102. color: "HighlightText",
  24103. background: "Highlight"
  24104. }
  24105. })), MoreWrapper = styled.div({
  24106. marginTop: 8
  24107. }), RecentlyOpenedTitle = styled.div(({ theme }) => ({
  24108. display: "flex",
  24109. justifyContent: "space-between",
  24110. fontSize: `${theme.typography.size.s1 - 1}px`,
  24111. fontWeight: theme.typography.weight.bold,
  24112. minHeight: 28,
  24113. letterSpacing: "0.16em",
  24114. textTransform: "uppercase",
  24115. color: theme.textMutedColor,
  24116. marginBottom: 4,
  24117. alignItems: "center",
  24118. ".search-result-recentlyOpened-clear": {
  24119. visibility: "hidden"
  24120. },
  24121. "&:hover": {
  24122. ".search-result-recentlyOpened-clear": {
  24123. visibility: "visible"
  24124. }
  24125. }
  24126. })), Highlight = react_default.memo(function({
  24127. children,
  24128. match
  24129. }) {
  24130. if (!match)
  24131. return children;
  24132. let { value, indices } = match, { nodes: result } = indices.reduce(
  24133. ({ 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 }),
  24134. { cursor: 0, nodes: [] }
  24135. );
  24136. return react_default.createElement("span", null, result);
  24137. }), Title = styled.div({
  24138. display: "grid",
  24139. justifyContent: "start",
  24140. gridAutoColumns: "auto",
  24141. gridAutoFlow: "column",
  24142. "& > span": {
  24143. display: "block",
  24144. whiteSpace: "nowrap",
  24145. overflow: "hidden",
  24146. textOverflow: "ellipsis"
  24147. }
  24148. }), Path = styled.div(({ theme }) => ({
  24149. display: "grid",
  24150. justifyContent: "start",
  24151. gridAutoColumns: "auto",
  24152. gridAutoFlow: "column",
  24153. fontSize: `${theme.typography.size.s1 - 1}px`,
  24154. "& > span": {
  24155. display: "block",
  24156. whiteSpace: "nowrap",
  24157. overflow: "hidden",
  24158. textOverflow: "ellipsis"
  24159. },
  24160. "& > span + span": {
  24161. "&:before": {
  24162. content: "' / '"
  24163. }
  24164. }
  24165. })), Result = react_default.memo(function({ item, matches, onClick, ...props }) {
  24166. let theme = useTheme(), click = useCallback(
  24167. (event) => {
  24168. event.preventDefault(), onClick?.(event);
  24169. },
  24170. [onClick]
  24171. ), api = useStorybookApi();
  24172. useEffect(() => {
  24173. api && props.isHighlighted && item.type === "component" && api.emit(PRELOAD_ENTRIES, { ids: [item.children[0]] }, { options: { target: item.refId } });
  24174. }, [api, props.isHighlighted, item]);
  24175. let nameMatch = matches.find((match) => match.key === "name"), pathMatches = matches.filter((match) => match.key === "path"), icon = item.status ? getStatus(theme, item.status).icon : null;
  24176. 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);
  24177. }), SearchResults = react_default.memo(function({
  24178. query,
  24179. results,
  24180. closeMenu,
  24181. getMenuProps,
  24182. getItemProps,
  24183. highlightedIndex,
  24184. isLoading = !1,
  24185. enableShortcuts = !0,
  24186. clearLastViewed
  24187. }) {
  24188. let api = useStorybookApi();
  24189. useEffect(() => {
  24190. let handleEscape = (event) => {
  24191. if (!(!enableShortcuts || isLoading || event.repeat) && matchesModifiers(!1, event) && matchesKeyCode("Escape", event)) {
  24192. if (event.target?.id === "storybook-explorer-searchfield")
  24193. return;
  24194. event.preventDefault(), closeMenu();
  24195. }
  24196. };
  24197. return document8.addEventListener("keydown", handleEscape), () => document8.removeEventListener("keydown", handleEscape);
  24198. }, [closeMenu, enableShortcuts, isLoading]);
  24199. let mouseOverHandler = useCallback((event) => {
  24200. if (!api)
  24201. return;
  24202. let currentTarget = event.currentTarget, storyId = currentTarget.getAttribute("data-id"), refId = currentTarget.getAttribute("data-refid"), item = api.resolveStory(storyId, refId === "storybook_internal" ? void 0 : refId);
  24203. item?.type === "component" && api.emit(PRELOAD_ENTRIES, {
  24204. // @ts-expect-error (TODO)
  24205. ids: [item.isLeaf ? item.id : item.children[0]],
  24206. options: { target: refId }
  24207. });
  24208. }, []), handleClearLastViewed = () => {
  24209. clearLastViewed(), closeMenu();
  24210. };
  24211. 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(
  24212. Button,
  24213. {
  24214. padding: "small",
  24215. variant: "ghost",
  24216. className: "search-result-recentlyOpened-clear",
  24217. onClick: handleClearLastViewed,
  24218. ariaLabel: "Clear recently opened items"
  24219. },
  24220. react_default.createElement(TrashIcon, null)
  24221. )), 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) => {
  24222. if (isExpandType(result)) {
  24223. let props = { ...results, ...getItemProps({ key: index, index, item: result }) }, { key: key2, ...rest2 } = props;
  24224. return react_default.createElement(MoreWrapper, { key: "search-result-expand" }, react_default.createElement(Button, { key: key2, ...rest2, size: "small" }, "Show ", result.moreCount, " more results"));
  24225. }
  24226. let { item } = result, key = `${item.refId}::${item.id}`;
  24227. return react_default.createElement(
  24228. Result,
  24229. {
  24230. ...result,
  24231. ...getItemProps({ key, index, item: result }),
  24232. isHighlighted: highlightedIndex === index,
  24233. key,
  24234. "data-id": result.item.id,
  24235. "data-refid": result.item.refId,
  24236. onMouseOver: mouseOverHandler,
  24237. className: "search-result-item"
  24238. }
  24239. );
  24240. }));
  24241. });
  24242. // src/manager/components/sidebar/SidebarBottom.tsx
  24243. init_react();
  24244. // src/manager/components/sidebar/TestingWidget.tsx
  24245. init_react();
  24246. // src/manager/components/sidebar/useDynamicFavicon.ts
  24247. init_react();
  24248. var STATUSES = ["active", "critical", "negative", "positive", "warning"], initialIcon, getFaviconUrl = (initialHref = "./favicon.svg", status) => {
  24249. initialIcon ??= initialHref;
  24250. let href = initialIcon + (status && STATUSES.includes(status) ? `?status=${status}` : "");
  24251. return new Promise((resolve) => {
  24252. let img = new Image();
  24253. img.onload = () => resolve({ href, status }), img.onerror = () => resolve({ href: initialIcon, status }), img.src = href;
  24254. });
  24255. }, useDynamicFavicon = (status) => {
  24256. let links = useRef(document.head.querySelectorAll("link[rel*='icon']"));
  24257. useEffect(() => {
  24258. let isMounted = !0, [element, ...others] = links.current;
  24259. if (element && !others.length)
  24260. return getFaviconUrl(element.href, status).then(
  24261. (result) => {
  24262. isMounted && result.status === status && element.dataset.status !== status && (element.href = result.href, result.status ? element.dataset.status = result.status : delete element.dataset.status);
  24263. },
  24264. () => {
  24265. isMounted && (element.href = initialIcon);
  24266. }
  24267. ), () => {
  24268. isMounted = !1, element.href = initialIcon;
  24269. };
  24270. }, [status]);
  24271. };
  24272. // src/manager/components/sidebar/TestingWidget.tsx
  24273. var DEFAULT_HEIGHT = 500, HoverCard2 = styled(Card)({
  24274. display: "flex",
  24275. flexDirection: "column-reverse",
  24276. "&:hover #testing-module-collapse-toggle": {
  24277. opacity: 1
  24278. }
  24279. }), Collapsible2 = styled.div(({ theme }) => ({
  24280. overflow: "hidden",
  24281. boxShadow: `inset 0 -1px 0 ${theme.appBorderColor}`
  24282. })), Content3 = styled.div({
  24283. display: "flex",
  24284. flexDirection: "column"
  24285. }), Bar2 = styled.div(({ onClick }) => ({
  24286. display: "flex",
  24287. width: "100%",
  24288. cursor: onClick ? "pointer" : "default",
  24289. userSelect: "none",
  24290. alignItems: "center",
  24291. justifyContent: "space-between",
  24292. overflow: "hidden",
  24293. padding: 4,
  24294. gap: 4
  24295. })), Action = styled.div({
  24296. display: "flex",
  24297. flexBasis: "100%",
  24298. containerType: "inline-size"
  24299. }), Filters = styled.div({
  24300. display: "flex",
  24301. justifyContent: "flex-end",
  24302. gap: 4
  24303. }), CollapseToggle3 = styled(ActionList.Button)({
  24304. opacity: 0,
  24305. transition: "opacity 250ms",
  24306. "&:focus, &:hover": {
  24307. opacity: 1
  24308. }
  24309. }), RunButton = ({
  24310. children,
  24311. isRunning,
  24312. onRunAll,
  24313. ...props
  24314. }) => react_default.createElement(
  24315. ActionList.Button,
  24316. {
  24317. ariaLabel: isRunning ? "Running..." : "Run tests",
  24318. tooltip: isRunning ? "Running tests..." : "Start all tests",
  24319. disabled: isRunning,
  24320. onClick: (e2) => {
  24321. e2.stopPropagation(), onRunAll();
  24322. },
  24323. ...props
  24324. },
  24325. react_default.createElement(ActionList.Icon, null, react_default.createElement(PlayAllHollowIcon, null)),
  24326. children
  24327. ), StatusButton2 = styled(ActionList.Toggle)(
  24328. { minWidth: 28, outlineOffset: -2 },
  24329. ({ pressed, status, theme }) => !pressed && (theme.base === "light" ? {
  24330. background: {
  24331. negative: theme.background.negative,
  24332. warning: theme.background.warning
  24333. }[status],
  24334. color: {
  24335. negative: theme.color.negativeText,
  24336. warning: theme.color.warningText
  24337. }[status]
  24338. } : {
  24339. background: {
  24340. negative: `${theme.color.negative}22`,
  24341. warning: `${theme.color.warning}22`
  24342. }[status],
  24343. color: {
  24344. negative: theme.color.negative,
  24345. warning: theme.color.warning
  24346. }[status]
  24347. })
  24348. ), TestProvider = styled.div(({ theme }) => ({
  24349. padding: 4,
  24350. "&:not(:last-child)": {
  24351. boxShadow: `inset 0 -1px 0 ${theme.appBorderColor}`
  24352. }
  24353. })), TestingWidget = ({
  24354. registeredTestProviders,
  24355. testProviderStates,
  24356. hasStatuses,
  24357. clearStatuses,
  24358. onRunAll,
  24359. errorCount,
  24360. errorsActive,
  24361. setErrorsActive,
  24362. warningCount,
  24363. warningsActive,
  24364. setWarningsActive,
  24365. successCount
  24366. }) => {
  24367. 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();
  24368. useEffect(() => {
  24369. let unsubscribe = internal_fullTestProviderStore.onSettingsChanged(() => {
  24370. setIsUpdated(!0), clearTimeout(settingsUpdatedTimeoutRef.current), settingsUpdatedTimeoutRef.current = setTimeout(() => {
  24371. setIsUpdated(!1);
  24372. }, 1e3);
  24373. });
  24374. return () => {
  24375. unsubscribe(), clearTimeout(settingsUpdatedTimeoutRef.current);
  24376. };
  24377. }, []), useEffect(() => {
  24378. if (contentRef.current) {
  24379. setMaxHeight(contentRef.current?.getBoundingClientRect().height || DEFAULT_HEIGHT);
  24380. let resizeObserver = new ResizeObserver(() => {
  24381. requestAnimationFrame(() => {
  24382. if (contentRef.current && !isCollapsed) {
  24383. let height = contentRef.current?.getBoundingClientRect().height || DEFAULT_HEIGHT;
  24384. setMaxHeight(height);
  24385. }
  24386. });
  24387. });
  24388. return resizeObserver.observe(contentRef.current), () => resizeObserver.disconnect();
  24389. }
  24390. }, [isCollapsed]);
  24391. let toggleCollapsed = useCallback((event, value) => {
  24392. event?.stopPropagation(), setChangingCollapse(!0), setCollapsed((s2) => value ?? !s2), timeoutRef.current && clearTimeout(timeoutRef.current), timeoutRef.current = setTimeout(() => {
  24393. setChangingCollapse(!1);
  24394. }, 250);
  24395. }, []), isRunning = Object.values(testProviderStates).some(
  24396. (testProviderState) => testProviderState === "test-provider-state:running"
  24397. ), isCrashed = Object.values(testProviderStates).some(
  24398. (testProviderState) => testProviderState === "test-provider-state:crashed"
  24399. ), hasTestProviders = Object.values(registeredTestProviders).length > 0;
  24400. useEffect(() => {
  24401. isCrashed && isCollapsed && toggleCollapsed(void 0, !1);
  24402. }, [isCrashed, isCollapsed, toggleCollapsed]), useDynamicFavicon(
  24403. isCrashed ? "critical" : errorCount > 0 ? "negative" : warningCount > 0 ? "warning" : isRunning ? "active" : successCount > 0 ? "positive" : void 0
  24404. );
  24405. let cardRef = useRef(null), { landmarkProps } = useLandmark(
  24406. { "aria-labelledby": "storybook-testing-widget-heading", role: "region" },
  24407. cardRef
  24408. );
  24409. return !hasTestProviders && !errorCount && !warningCount ? null : react_default.createElement(
  24410. HoverCard2,
  24411. {
  24412. id: "storybook-testing-module",
  24413. "data-updated": isUpdated,
  24414. outlineAnimation: isRunning ? "spin" : "none",
  24415. outlineColor: isCrashed || isRunning && errorCount > 0 ? "negative" : isUpdated ? "positive" : void 0,
  24416. ref: cardRef,
  24417. outlineAttrs: landmarkProps
  24418. },
  24419. react_default.createElement("h2", { id: "storybook-testing-widget-heading", className: "sb-sr-only" }, "Component tests"),
  24420. react_default.createElement(Bar2, { ...hasTestProviders ? { onClick: (e2) => toggleCollapsed(e2) } : {} }, react_default.createElement(Action, null, hasTestProviders && react_default.createElement(
  24421. Optional,
  24422. {
  24423. content: react_default.createElement(RunButton, { isRunning, onRunAll }, isRunning ? "Running..." : "Run tests"),
  24424. fallback: react_default.createElement(RunButton, { isRunning, onRunAll })
  24425. }
  24426. )), react_default.createElement(Filters, null, hasTestProviders && react_default.createElement(
  24427. CollapseToggle3,
  24428. {
  24429. onClick: (e2) => toggleCollapsed(e2),
  24430. id: "testing-module-collapse-toggle",
  24431. ariaLabel: isCollapsed ? "Expand testing module" : "Collapse testing module"
  24432. },
  24433. react_default.createElement(
  24434. ChevronSmallUpIcon,
  24435. {
  24436. style: {
  24437. transform: isCollapsed ? "none" : "rotate(180deg)",
  24438. transition: "transform 250ms"
  24439. }
  24440. }
  24441. )
  24442. ), errorCount > 0 && react_default.createElement(
  24443. StatusButton2,
  24444. {
  24445. id: "errors-found-filter",
  24446. size: "medium",
  24447. variant: "ghost",
  24448. padding: errorCount < 10 ? "medium" : "small",
  24449. status: "negative",
  24450. pressed: errorsActive,
  24451. onClick: (e2) => {
  24452. e2.stopPropagation(), setErrorsActive(!errorsActive);
  24453. },
  24454. ariaLabel: `Filter main navigation to show ${errorCount} tests with errors`,
  24455. tooltip: errorsActive ? "Clear test error filter" : `Filter sidebar to show ${errorCount} tests with errors`
  24456. },
  24457. errorCount < 1e3 ? errorCount : "999+"
  24458. ), warningCount > 0 && react_default.createElement(
  24459. StatusButton2,
  24460. {
  24461. id: "warnings-found-filter",
  24462. size: "medium",
  24463. variant: "ghost",
  24464. padding: warningCount < 10 ? "medium" : "small",
  24465. status: "warning",
  24466. pressed: warningsActive,
  24467. onClick: (e2) => {
  24468. e2.stopPropagation(), setWarningsActive(!warningsActive);
  24469. },
  24470. ariaLabel: `Filter main navigation to show ${warningCount} tests with warnings`,
  24471. tooltip: warningsActive ? "Clear test warning filter" : `Filter sidebar to show ${warningCount} tests with warnings`
  24472. },
  24473. warningCount < 1e3 ? warningCount : "999+"
  24474. ), hasStatuses && react_default.createElement(
  24475. ActionList.Button,
  24476. {
  24477. id: "clear-statuses",
  24478. onClick: (e2) => {
  24479. e2.stopPropagation(), clearStatuses();
  24480. },
  24481. disabled: isRunning,
  24482. ariaLabel: isRunning ? "Can't clear statuses while tests are running" : "Clear all statuses"
  24483. },
  24484. react_default.createElement(SweepIcon, null)
  24485. ))),
  24486. hasTestProviders && react_default.createElement(
  24487. Collapsible2,
  24488. {
  24489. "data-testid": "collapse",
  24490. ...isCollapsed && { inert: "" },
  24491. style: {
  24492. transition: isChangingCollapse ? "max-height 250ms" : "max-height 0ms",
  24493. display: hasTestProviders ? "block" : "none",
  24494. maxHeight: isCollapsed ? 0 : maxHeight
  24495. }
  24496. },
  24497. react_default.createElement(Content3, { ref: contentRef }, Object.values(registeredTestProviders).map((registeredTestProvider) => {
  24498. let { render: Render, id } = registeredTestProvider;
  24499. return Render ? react_default.createElement(TestProvider, { key: id, "data-module-id": id }, react_default.createElement(Render, null)) : (once.warn(
  24500. `No render function found for test provider with id '${id}', skipping...`
  24501. ), null);
  24502. }))
  24503. )
  24504. );
  24505. };
  24506. // src/manager/components/sidebar/SidebarBottom.tsx
  24507. 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(
  24508. ({ value }) => ["status-value:warning", "status-value:error"].includes(value)
  24509. ), getFilter = (warningsActive = !1, errorsActive = !1) => warningsActive && errorsActive ? filterBoth : warningsActive ? filterWarn : errorsActive ? filterError : filterNone, Spacer = styled.div({
  24510. pointerEvents: "none"
  24511. }), Content4 = styled.div(({ theme }) => ({
  24512. position: "absolute",
  24513. zIndex: 1,
  24514. bottom: 0,
  24515. left: 0,
  24516. right: 0,
  24517. padding: 12,
  24518. display: "flex",
  24519. flexDirection: "column",
  24520. gap: 12,
  24521. color: theme.color.defaultText,
  24522. fontSize: theme.typography.size.s1,
  24523. "&:empty": {
  24524. display: "none"
  24525. },
  24526. "--card-box-shadow": `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`,
  24527. // Integrators can use these to style their custom additions
  24528. "--sb-sidebar-bottom-card-background": theme.background.content,
  24529. "--sb-sidebar-bottom-card-border": `1px solid ${theme.appBorderColor}`,
  24530. "--sb-sidebar-bottom-card-border-radius": `${theme.appBorderRadius + 1}px`,
  24531. "--sb-sidebar-bottom-card-box-shadow": `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`
  24532. })), SidebarBottomBase = ({
  24533. api,
  24534. notifications = [],
  24535. errorCount,
  24536. warningCount,
  24537. successCount,
  24538. hasStatuses,
  24539. isDevelopment,
  24540. testProviderStates,
  24541. registeredTestProviders,
  24542. onRunAll
  24543. }) => {
  24544. let spacerRef = useRef(null), wrapperRef = useRef(null), [warningsActive, setWarningsActive] = useState(!1), [errorsActive, setErrorsActive] = useState(!1);
  24545. return useEffect(() => {
  24546. if (spacerRef.current && wrapperRef.current) {
  24547. let resizeObserver = new ResizeObserver(() => {
  24548. spacerRef.current && wrapperRef.current && (spacerRef.current.style.height = `${wrapperRef.current.scrollHeight}px`);
  24549. });
  24550. return resizeObserver.observe(wrapperRef.current), () => resizeObserver.disconnect();
  24551. }
  24552. }, []), useEffect(() => {
  24553. let filter = getFilter(warningCount > 0 && warningsActive, errorCount > 0 && errorsActive);
  24554. api.experimental_setFilter("sidebar-bottom-filter", filter);
  24555. }, [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(
  24556. TestingWidget,
  24557. {
  24558. registeredTestProviders,
  24559. testProviderStates,
  24560. onRunAll: () => {
  24561. onRunAll(), setErrorsActive(!1), setWarningsActive(!1);
  24562. },
  24563. hasStatuses,
  24564. clearStatuses: () => {
  24565. api.clearStatuses(), setErrorsActive(!1), setWarningsActive(!1);
  24566. },
  24567. errorCount,
  24568. errorsActive,
  24569. setErrorsActive,
  24570. warningCount,
  24571. warningsActive,
  24572. setWarningsActive,
  24573. successCount
  24574. }
  24575. )));
  24576. }, SidebarBottom = ({ isDevelopment }) => {
  24577. let api = useStorybookApi(), registeredTestProviders = api.getElements(Addon_TypesEnum.experimental_TEST_PROVIDER), { notifications } = useStorybookState(), { hasStatuses, errorCount, warningCount, successCount } = experimental_useStatusStore(
  24578. (statuses) => Object.values(statuses).reduce(
  24579. (result, storyStatuses) => (Object.values(storyStatuses).forEach((status) => {
  24580. 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);
  24581. }), result),
  24582. { errorCount: 0, warningCount: 0, successCount: 0, hasStatuses: !1 }
  24583. )
  24584. ), testProviderStates = experimental_useTestProviderStore();
  24585. return react_default.createElement(
  24586. SidebarBottomBase,
  24587. {
  24588. api,
  24589. notifications,
  24590. hasStatuses,
  24591. errorCount,
  24592. warningCount,
  24593. successCount,
  24594. isDevelopment,
  24595. testProviderStates,
  24596. registeredTestProviders,
  24597. onRunAll: internal_fullTestProviderStore.runAll
  24598. }
  24599. );
  24600. };
  24601. // src/manager/components/sidebar/Filter.tsx
  24602. init_react();
  24603. // src/manager/components/sidebar/FilterPanel.tsx
  24604. init_react();
  24605. // src/manager/components/sidebar/FilterPanelLink.tsx
  24606. init_react();
  24607. var MutedText = styled.span(({ theme }) => ({
  24608. color: theme.textMutedColor
  24609. })), StatusIcon2 = styled.span(({ $iconColor }) => ({
  24610. display: "contents",
  24611. color: $iconColor ?? void 0,
  24612. "> svg": {
  24613. transform: "scale(1.3)"
  24614. }
  24615. })), createFilterLink = ({
  24616. id,
  24617. type,
  24618. title: title2,
  24619. tooltip,
  24620. count,
  24621. icon,
  24622. isIncluded,
  24623. isExcluded,
  24624. onCheckboxChange,
  24625. onInvert
  24626. }) => {
  24627. 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}`;
  24628. return {
  24629. id: `filter-${type}-${id}`,
  24630. 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(
  24631. Form.Checkbox,
  24632. {
  24633. checked: isChecked,
  24634. onChange: onCheckboxChange,
  24635. "data-tag": title2,
  24636. "aria-label": toggleLabel
  24637. }
  24638. )), 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(
  24639. ActionList.Button,
  24640. {
  24641. "data-target-id": `filter-${type}-${id}`,
  24642. ariaLabel: invertButtonLabel,
  24643. onClick: onInvert
  24644. },
  24645. react_default.createElement("span", { style: { minWidth: 45 } }, isExcluded ? "Include" : "Exclude")
  24646. ))
  24647. };
  24648. };
  24649. // src/manager/components/sidebar/FilterPanel.utils.ts
  24650. var BUILT_IN_TAGS = /* @__PURE__ */ new Set([
  24651. "dev",
  24652. "test",
  24653. "autodocs",
  24654. "attached-mdx",
  24655. "unattached-mdx",
  24656. "play-fn",
  24657. "test-fn",
  24658. "manifest"
  24659. ]), STATUS_DISPLAY_ORDER = [
  24660. "status-value:new",
  24661. "status-value:modified",
  24662. "status-value:affected"
  24663. ], 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);
  24664. // src/manager/components/sidebar/useFilterData.tsx
  24665. init_react();
  24666. var BUILT_IN_FILTER_DEFS = [
  24667. { id: "_docs", title: "Documentation", icon: react_default.createElement(DocumentIcon, { color: color.gold }), tag: "_docs" },
  24668. { id: "_play", title: "Play", icon: react_default.createElement(PlayHollowIcon, { color: color.seafoam }), tag: "_play" },
  24669. { id: "_test", title: "Testing", icon: react_default.createElement(BeakerIcon, { color: color.green }), tag: "_test" }
  24670. ];
  24671. function useTagFilterEntries(indexJson) {
  24672. return useMemo(() => {
  24673. let entries = Object.values(indexJson.entries), userTagsCounts = entries.reduce((acc, entry) => (entry.tags?.forEach((tag) => {
  24674. BUILT_IN_TAGS.has(tag) || (acc[tag] = (acc[tag] || 0) + 1);
  24675. }), acc), {}), tagEntries = Object.entries(userTagsCounts).map(([tag, count]) => ({
  24676. id: tag,
  24677. type: "tag",
  24678. title: tag,
  24679. count,
  24680. icon: null
  24681. })), getBuiltInCount = (filterFn) => entries.filter((entry) => filterFn?.(entry)).length;
  24682. return { builtInEntries: BUILT_IN_FILTER_DEFS.map((def) => ({
  24683. id: def.id,
  24684. type: "built-in",
  24685. title: def.title,
  24686. icon: def.icon,
  24687. count: getBuiltInCount(getFilterFunction(def.tag))
  24688. })), tagEntries };
  24689. }, [indexJson.entries]);
  24690. }
  24691. function useStatusFilterEntries(allStatuses) {
  24692. return useMemo(() => {
  24693. if (!globalThis?.FEATURES?.changeDetection)
  24694. return [];
  24695. let counts = countStatusesByValue(allStatuses);
  24696. return STATUS_DISPLAY_ORDER.map((statusValue) => ({
  24697. statusValue,
  24698. shortName: statusValueShortName(statusValue),
  24699. description: statusValueDescription(statusValue),
  24700. count: counts[statusValue] ?? 0
  24701. }));
  24702. }, [allStatuses]);
  24703. }
  24704. // src/manager/components/sidebar/FilterPanel.tsx
  24705. var Wrapper7 = styled.div({
  24706. minWidth: 240,
  24707. maxWidth: 300,
  24708. maxHeight: 15.5 * 32 + 8,
  24709. // 15.5 items at 32px each + 8px padding
  24710. overflow: "hidden",
  24711. overflowY: "auto",
  24712. scrollbarWidth: "thin"
  24713. }), FilterPanel = ({
  24714. api,
  24715. indexJson,
  24716. defaultIncludedFilters,
  24717. defaultExcludedFilters,
  24718. includedFilters,
  24719. excludedFilters,
  24720. allStatuses,
  24721. includedStatusFilters,
  24722. excludedStatusFilters
  24723. }) => {
  24724. let theme = useTheme(), { builtInEntries, tagEntries } = useTagFilterEntries(indexJson), statusEntries = useStatusFilterEntries(allStatuses), toTagFilterItem = useCallback(
  24725. (entry) => {
  24726. if (entry.count === 0 && entry.type === "built-in") return null;
  24727. let isIncluded = includedFilters.includes(entry.id), isExcluded = excludedFilters.includes(entry.id), isChecked = isIncluded || isExcluded;
  24728. return {
  24729. id: entry.id,
  24730. type: entry.type,
  24731. title: entry.title,
  24732. count: entry.count,
  24733. icon: entry.icon,
  24734. isIncluded,
  24735. isExcluded,
  24736. onCheckboxChange: () => {
  24737. isChecked ? api.removeTagFilters([entry.id]) : api.addTagFilters([entry.id], !1);
  24738. },
  24739. onInvert: () => api.addTagFilters([entry.id], !isExcluded)
  24740. };
  24741. },
  24742. [api, includedFilters, excludedFilters]
  24743. ), toStatusFilterItem = useCallback(
  24744. (entry) => {
  24745. 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";
  24746. return {
  24747. id: shortName,
  24748. type: "status",
  24749. title: shortName.charAt(0).toUpperCase() + shortName.slice(1),
  24750. tooltip: entry.description,
  24751. count: entry.count,
  24752. icon: showIcon ? react_default.createElement(StatusIcon2, { $iconColor: iconColor }, statusIconEl) : null,
  24753. isIncluded,
  24754. isExcluded,
  24755. onCheckboxChange: () => {
  24756. isChecked ? api.removeStatusFilters([entry.statusValue]) : api.addStatusFilters([entry.statusValue], !1);
  24757. },
  24758. onInvert: () => api.addStatusFilters([entry.statusValue], !isExcluded)
  24759. };
  24760. },
  24761. [api, includedStatusFilters, excludedStatusFilters, theme]
  24762. ), builtInItems = useMemo(
  24763. () => builtInEntries.sort((a2, b2) => a2.id.localeCompare(b2.id)).map(toTagFilterItem).filter((f2) => f2 !== null),
  24764. [builtInEntries, toTagFilterItem]
  24765. ), tagItems = useMemo(
  24766. () => tagEntries.sort((a2, b2) => a2.id.localeCompare(b2.id)).map(toTagFilterItem).filter((f2) => f2 !== null),
  24767. [tagEntries, toTagFilterItem]
  24768. ), statusItems = useMemo(
  24769. () => statusEntries.map(toStatusFilterItem),
  24770. [statusEntries, toStatusFilterItem]
  24771. ), filterIds = useMemo(
  24772. () => [...builtInEntries.map((e2) => e2.id), ...tagEntries.map((e2) => e2.id)],
  24773. [builtInEntries, tagEntries]
  24774. ), setAllFilters = useCallback(
  24775. (selected) => api.setAllTagFilters(selected ? filterIds : [], []),
  24776. [api, filterIds]
  24777. ), 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;
  24778. return react_default.createElement(Wrapper7, null, hasItems && react_default.createElement(ActionList, { as: "div" }, react_default.createElement(ActionList.Item, { as: "div" }, isNothingSelectedYet ? react_default.createElement(
  24779. ActionList.Button,
  24780. {
  24781. ariaLabel: !1,
  24782. id: "select-all",
  24783. key: "select-all",
  24784. onClick: () => setAllFilters(!0)
  24785. },
  24786. react_default.createElement(BatchAcceptIcon, null),
  24787. react_default.createElement(ActionList.Text, null, "Select all")
  24788. ) : react_default.createElement(
  24789. ActionList.Button,
  24790. {
  24791. ariaLabel: !1,
  24792. id: "deselect-all",
  24793. key: "deselect-all",
  24794. onClick: async () => {
  24795. await setAllFilters(!1), await api.resetStatusFilters();
  24796. }
  24797. },
  24798. react_default.createElement(SweepIcon, null),
  24799. react_default.createElement(ActionList.Text, null, "Clear filters")
  24800. ), hasDefaultSelection && react_default.createElement(
  24801. ActionList.Button,
  24802. {
  24803. id: "reset-filters",
  24804. key: "reset-filters",
  24805. onClick: () => api.resetTagFilters(),
  24806. ariaLabel: "Reset filters",
  24807. tooltip: "Reset to default selection",
  24808. disabled: isDefaultSelection
  24809. },
  24810. react_default.createElement(UndoIcon, null)
  24811. ))), builtInItems.length > 0 && react_default.createElement(ActionList, null, builtInItems.map((item) => {
  24812. let link = createFilterLink(item);
  24813. return react_default.createElement(Fragment, { key: link.id }, link.content);
  24814. })), statusItems.length > 0 && react_default.createElement(ActionList, null, statusItems.map((item) => {
  24815. let link = createFilterLink(item);
  24816. return react_default.createElement(Fragment, { key: link.id }, link.content);
  24817. })), tagItems.length > 0 && react_default.createElement(ActionList, null, tagItems.map((item) => {
  24818. let link = createFilterLink(item);
  24819. return react_default.createElement(Fragment, { key: link.id }, link.content);
  24820. })), tagItems.length === 0 && react_default.createElement(ActionList, { as: "div" }, react_default.createElement(ActionList.Item, { as: "div" }, react_default.createElement(
  24821. ActionList.Link,
  24822. {
  24823. ariaLabel: !1,
  24824. href: api.getDocsUrl({ subpath: "writing-stories/tags#custom-tags" }),
  24825. target: "_blank"
  24826. },
  24827. react_default.createElement(ActionList.Icon, null, react_default.createElement(DocumentIcon, null)),
  24828. react_default.createElement(ActionList.Text, null, react_default.createElement("span", null, "Learn how to add tags")),
  24829. react_default.createElement(ActionList.Icon, null, react_default.createElement(ShareAltIcon, null))
  24830. ))));
  24831. };
  24832. // src/manager/components/sidebar/Filter.tsx
  24833. var StyledButton2 = styled(Button)(({ $isHighlighted, theme }) => ({
  24834. "&:focus-visible": {
  24835. outlineOffset: 4
  24836. },
  24837. ...$isHighlighted && {
  24838. background: theme.background.hoverable,
  24839. color: theme.color.secondary
  24840. }
  24841. })), TagSelected = styled(Badge)(({ theme }) => ({
  24842. position: "absolute",
  24843. top: 7,
  24844. right: 7,
  24845. transform: "translate(50%, -50%)",
  24846. display: "flex",
  24847. alignItems: "center",
  24848. justifyContent: "center",
  24849. padding: 3,
  24850. height: 6,
  24851. minWidth: 6,
  24852. lineHeight: "px",
  24853. boxShadow: `${theme.barSelectedColor} 0 0 0 1px inset`,
  24854. fontSize: theme.typography.size.s1 - 1,
  24855. background: theme.barSelectedColor,
  24856. color: theme.color.inverseText
  24857. })), filterMapper = ({ api, state }) => ({
  24858. api,
  24859. indexJson: state.internal_index,
  24860. activeFilterCount: getActiveFilterCount(state),
  24861. defaultIncludedFilters: state.defaultIncludedTagFilters,
  24862. defaultExcludedFilters: state.defaultExcludedTagFilters,
  24863. includedFilters: state.includedTagFilters,
  24864. excludedFilters: state.excludedTagFilters,
  24865. includedStatusFilters: state.includedStatusFilters ?? [],
  24866. excludedStatusFilters: state.excludedStatusFilters ?? []
  24867. }), FilterInner = ({
  24868. api,
  24869. indexJson,
  24870. activeFilterCount,
  24871. defaultIncludedFilters,
  24872. defaultExcludedFilters,
  24873. includedFilters,
  24874. excludedFilters,
  24875. includedStatusFilters,
  24876. excludedStatusFilters
  24877. }) => {
  24878. let [expanded, setExpanded] = useState(!1), allStatuses = experimental_useStatusStore(), handleToggleExpand = useCallback(
  24879. (event) => {
  24880. event.preventDefault(), setExpanded(!expanded);
  24881. },
  24882. [expanded]
  24883. );
  24884. return react_default.createElement(
  24885. PopoverProvider,
  24886. {
  24887. ariaLabel: "Tag filters",
  24888. placement: "bottom",
  24889. onVisibleChange: setExpanded,
  24890. offset: 8,
  24891. padding: 0,
  24892. popover: () => react_default.createElement(
  24893. FilterPanel,
  24894. {
  24895. api,
  24896. indexJson,
  24897. defaultIncludedFilters,
  24898. defaultExcludedFilters,
  24899. includedFilters,
  24900. excludedFilters,
  24901. allStatuses,
  24902. includedStatusFilters,
  24903. excludedStatusFilters
  24904. }
  24905. )
  24906. },
  24907. react_default.createElement(
  24908. StyledButton2,
  24909. {
  24910. key: "tags",
  24911. ariaLabel: activeFilterCount ? `${activeFilterCount} active tag ${activeFilterCount !== 1 ? "filters" : "filter"}` : "Tag filters",
  24912. ariaDescription: "Filter the items shown in a sidebar based on the tags applied to them.",
  24913. variant: "ghost",
  24914. padding: "small",
  24915. $isHighlighted: activeFilterCount > 0,
  24916. onClick: handleToggleExpand
  24917. },
  24918. react_default.createElement(FilterIcon, null),
  24919. activeFilterCount > 0 && react_default.createElement(TagSelected, null)
  24920. )
  24921. );
  24922. }, Filter = () => react_default.createElement(Consumer, { filter: filterMapper }, ({
  24923. api,
  24924. indexJson,
  24925. activeFilterCount,
  24926. defaultIncludedFilters,
  24927. defaultExcludedFilters,
  24928. includedFilters,
  24929. excludedFilters,
  24930. includedStatusFilters,
  24931. excludedStatusFilters
  24932. }) => indexJson ? react_default.createElement(
  24933. FilterInner,
  24934. {
  24935. api,
  24936. indexJson,
  24937. activeFilterCount,
  24938. defaultIncludedFilters,
  24939. defaultExcludedFilters,
  24940. includedFilters,
  24941. excludedFilters,
  24942. includedStatusFilters,
  24943. excludedStatusFilters
  24944. }
  24945. ) : null);
  24946. // src/manager/components/sidebar/ReviewChangesButton.tsx
  24947. init_react();
  24948. // src/shared/universal-store/instances.ts
  24949. var instances = /* @__PURE__ */ new Map();
  24950. // src/shared/universal-store/index.ts
  24951. var CHANNEL_EVENT_PREFIX = "UNIVERSAL_STORE:", ProgressState = {
  24952. PENDING: "PENDING",
  24953. RESOLVED: "RESOLVED",
  24954. REJECTED: "REJECTED"
  24955. }, _UniversalStore = class _UniversalStore {
  24956. constructor(options2, environmentOverrides) {
  24957. /** Enable debug logs for this store */
  24958. this.debugging = !1;
  24959. // TODO: narrow type of listeners based on event type
  24960. this.listeners = /* @__PURE__ */ new Map([["*", /* @__PURE__ */ new Set()]]);
  24961. /** Gets the current state */
  24962. this.getState = () => (this.debug("getState", { state: this.state }), this.state);
  24963. /**
  24964. * Subscribes to store events
  24965. *
  24966. * @returns A function to unsubscribe
  24967. */
  24968. this.subscribe = (eventTypeOrListener, maybeListener) => {
  24969. let subscribesToAllEvents = typeof eventTypeOrListener == "function", eventType = subscribesToAllEvents ? "*" : eventTypeOrListener, listener = subscribesToAllEvents ? eventTypeOrListener : maybeListener;
  24970. if (this.debug("subscribe", { eventType, listener }), !listener)
  24971. throw new TypeError(
  24972. `Missing first subscribe argument, or second if first is the event type, when subscribing to a UniversalStore with id '${this.id}'`
  24973. );
  24974. return this.listeners.has(eventType) || this.listeners.set(eventType, /* @__PURE__ */ new Set()), this.listeners.get(eventType).add(listener), () => {
  24975. 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));
  24976. };
  24977. };
  24978. /** Sends a custom event to the other stores */
  24979. this.send = (event) => {
  24980. if (this.debug("send", { event }), this.status !== _UniversalStore.Status.READY)
  24981. throw new TypeError(
  24982. dedent`Cannot send event before store is ready. You can get the current status with store.status,
  24983. or await store.readyPromise to wait for the store to be ready before sending events.
  24984. ${JSON.stringify(
  24985. {
  24986. event,
  24987. id: this.id,
  24988. actor: this.actor,
  24989. environment: this.environment
  24990. },
  24991. null,
  24992. 2
  24993. )}`
  24994. );
  24995. this.emitToListeners(event, { actor: this.actor }), this.emitToChannel(event, { actor: this.actor });
  24996. };
  24997. if (this.debugging = options2.debug ?? !1, !_UniversalStore.isInternalConstructing)
  24998. throw new TypeError(
  24999. "UniversalStore is not constructable - use UniversalStore.create() instead"
  25000. );
  25001. 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", {
  25002. options: options2,
  25003. environmentOverrides,
  25004. channelEventName: this.channelEventName
  25005. }), this.actor.type === _UniversalStore.ActorType.LEADER)
  25006. this.syncing = {
  25007. state: ProgressState.RESOLVED,
  25008. promise: Promise.resolve()
  25009. };
  25010. else {
  25011. let syncingResolve, syncingReject, syncingPromise = new Promise((resolve, reject) => {
  25012. syncingResolve = () => {
  25013. this.syncing.state === ProgressState.PENDING && (this.syncing.state = ProgressState.RESOLVED, resolve());
  25014. }, syncingReject = (reason) => {
  25015. this.syncing.state === ProgressState.PENDING && (this.syncing.state = ProgressState.REJECTED, reject(reason));
  25016. };
  25017. });
  25018. this.syncing = {
  25019. state: ProgressState.PENDING,
  25020. promise: syncingPromise,
  25021. resolve: syncingResolve,
  25022. reject: syncingReject
  25023. };
  25024. }
  25025. 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);
  25026. }
  25027. static setupPreparationPromise() {
  25028. let resolveRef, rejectRef, promise = new Promise(
  25029. (resolve, reject) => {
  25030. resolveRef = (args) => {
  25031. resolve(args);
  25032. }, rejectRef = (...args) => {
  25033. reject(args);
  25034. };
  25035. }
  25036. );
  25037. _UniversalStore.preparation = {
  25038. resolve: resolveRef,
  25039. reject: rejectRef,
  25040. promise
  25041. };
  25042. }
  25043. /** The actor object representing the store instance with a unique ID and a type */
  25044. get actor() {
  25045. return Object.freeze({
  25046. id: this.actorId,
  25047. type: this.actorType,
  25048. environment: this.environment ?? _UniversalStore.Environment.UNKNOWN
  25049. });
  25050. }
  25051. /**
  25052. * The current state of the store, that signals both if the store is prepared by Storybook and
  25053. * also - in the case of a follower - if the state has been synced with the leader's state.
  25054. */
  25055. get status() {
  25056. if (!this.channel || !this.environment)
  25057. return _UniversalStore.Status.UNPREPARED;
  25058. switch (this.syncing?.state) {
  25059. case ProgressState.PENDING:
  25060. case void 0:
  25061. return _UniversalStore.Status.SYNCING;
  25062. case ProgressState.REJECTED:
  25063. return _UniversalStore.Status.ERROR;
  25064. case ProgressState.RESOLVED:
  25065. default:
  25066. return _UniversalStore.Status.READY;
  25067. }
  25068. }
  25069. /**
  25070. * A promise that resolves when the store is fully ready. A leader will be ready when the store
  25071. * has been prepared by Storybook, which is almost instantly.
  25072. *
  25073. * A follower will be ready when the state has been synced with the leader's state, within a few
  25074. * hundred milliseconds.
  25075. */
  25076. untilReady() {
  25077. return Promise.all([_UniversalStore.preparation.promise, this.syncing?.promise]);
  25078. }
  25079. /** Creates a new instance of UniversalStore */
  25080. static create(options2) {
  25081. if (!options2 || typeof options2?.id != "string")
  25082. throw new TypeError("id is required and must be a string, when creating a UniversalStore");
  25083. options2.debug && console.debug(
  25084. dedent`[UniversalStore]
  25085. create`,
  25086. { options: options2 }
  25087. );
  25088. let existing = instances.get(options2.id);
  25089. if (existing)
  25090. return console.warn(dedent`UniversalStore with id "${options2.id}" already exists in this environment, re-using existing.
  25091. You should reuse the existing instance instead of trying to create a new one.`), existing;
  25092. _UniversalStore.isInternalConstructing = !0;
  25093. let store2 = new _UniversalStore(options2);
  25094. return instances.set(options2.id, store2), store2;
  25095. }
  25096. /**
  25097. * Used by Storybook to set the channel for all instances of UniversalStore in the given
  25098. * environment.
  25099. *
  25100. * @internal
  25101. */
  25102. static __prepare(channel, environment) {
  25103. _UniversalStore.preparation.channel = channel, _UniversalStore.preparation.environment = environment, _UniversalStore.preparation.resolve({ channel, environment });
  25104. }
  25105. /**
  25106. * Updates the store's state
  25107. *
  25108. * Either a new state or a state updater function can be passed to the method.
  25109. */
  25110. setState(updater) {
  25111. let previousState = this.state, newState = typeof updater == "function" ? updater(previousState) : updater;
  25112. if (this.debug("setState", { newState, previousState, updater }), this.status !== _UniversalStore.Status.READY)
  25113. throw new TypeError(
  25114. dedent`Cannot set state before store is ready. You can get the current status with store.status,
  25115. or await store.readyPromise to wait for the store to be ready before sending events.
  25116. ${JSON.stringify(
  25117. {
  25118. newState,
  25119. id: this.id,
  25120. actor: this.actor,
  25121. environment: this.environment
  25122. },
  25123. null,
  25124. 2
  25125. )}`
  25126. );
  25127. this.state = newState;
  25128. let event = {
  25129. type: _UniversalStore.InternalEventType.SET_STATE,
  25130. payload: {
  25131. state: newState,
  25132. previousState
  25133. }
  25134. };
  25135. this.emitToChannel(event, { actor: this.actor }), this.emitToListeners(event, { actor: this.actor });
  25136. }
  25137. /**
  25138. * Subscribes to state changes
  25139. *
  25140. * @returns Unsubscribe function
  25141. */
  25142. onStateChange(listener) {
  25143. return this.debug("onStateChange", { listener }), this.subscribe(
  25144. _UniversalStore.InternalEventType.SET_STATE,
  25145. ({ payload }, eventInfo) => {
  25146. listener(payload.state, payload.previousState, eventInfo);
  25147. }
  25148. );
  25149. }
  25150. emitToChannel(event, eventInfo) {
  25151. this.debug("emitToChannel", { event, eventInfo, channel: !!this.channel }), this.channel?.emit(this.channelEventName, {
  25152. event,
  25153. eventInfo
  25154. });
  25155. }
  25156. prepareThis({
  25157. channel,
  25158. environment
  25159. }) {
  25160. 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(
  25161. { type: _UniversalStore.InternalEventType.LEADER_CREATED },
  25162. { actor: this.actor }
  25163. ) : (this.emitToChannel(
  25164. { type: _UniversalStore.InternalEventType.FOLLOWER_CREATED },
  25165. { actor: this.actor }
  25166. ), this.emitToChannel(
  25167. { type: _UniversalStore.InternalEventType.EXISTING_STATE_REQUEST },
  25168. { actor: this.actor }
  25169. ), setTimeout(() => {
  25170. this.syncing.reject(
  25171. new TypeError(
  25172. `No existing state found for follower with id: '${this.id}'. Make sure a leader with the same id exists before creating a follower.`
  25173. )
  25174. );
  25175. }, 1e3));
  25176. }
  25177. emitToListeners(event, eventInfo) {
  25178. let eventTypeListeners = this.listeners.get(event.type), everythingListeners = this.listeners.get("*");
  25179. this.debug("emitToListeners", {
  25180. event,
  25181. eventInfo,
  25182. eventTypeListeners,
  25183. everythingListeners
  25184. }), [...eventTypeListeners ?? [], ...everythingListeners ?? []].forEach(
  25185. (listener) => listener(event, eventInfo)
  25186. );
  25187. }
  25188. handleChannelEvents(channelEvent) {
  25189. let { event, eventInfo } = channelEvent;
  25190. if ([eventInfo.actor.id, eventInfo.forwardingActor?.id].includes(this.actor.id)) {
  25191. this.debug("handleChannelEvents: Ignoring event from self", { channelEvent });
  25192. return;
  25193. } else if (this.syncing?.state === ProgressState.PENDING && event.type !== _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE) {
  25194. this.debug("handleChannelEvents: Ignoring event while syncing", { channelEvent });
  25195. return;
  25196. }
  25197. if (this.debug("handleChannelEvents", { channelEvent }), this.actor.type === _UniversalStore.ActorType.LEADER) {
  25198. let shouldForwardEvent = !0;
  25199. switch (event.type) {
  25200. case _UniversalStore.InternalEventType.EXISTING_STATE_REQUEST:
  25201. shouldForwardEvent = !1;
  25202. let responseEvent = {
  25203. type: _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE,
  25204. payload: this.state
  25205. };
  25206. this.debug("handleChannelEvents: responding to existing state request", {
  25207. responseEvent
  25208. }), this.emitToChannel(responseEvent, { actor: this.actor }), this.emitToListeners(responseEvent, { actor: this.actor });
  25209. break;
  25210. case _UniversalStore.InternalEventType.LEADER_CREATED:
  25211. shouldForwardEvent = !1, this.syncing.state = ProgressState.REJECTED, this.debug("handleChannelEvents: erroring due to second leader being created", {
  25212. event
  25213. }), console.error(
  25214. dedent`Detected multiple UniversalStore leaders created with the same id "${this.id}".
  25215. Only one leader can exists at a time, your stores are now in an invalid state.
  25216. Leaders detected:
  25217. this: ${JSON.stringify(this.actor, null, 2)}
  25218. other: ${JSON.stringify(eventInfo.actor, null, 2)}`
  25219. );
  25220. break;
  25221. }
  25222. shouldForwardEvent && (this.debug("handleChannelEvents: forwarding event", { channelEvent }), this.emitToChannel(event, { actor: eventInfo.actor, forwardingActor: this.actor }));
  25223. }
  25224. if (this.actor.type === _UniversalStore.ActorType.FOLLOWER)
  25225. switch (event.type) {
  25226. case _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE:
  25227. if (this.debug("handleChannelEvents: Setting state from leader's existing state response", {
  25228. event
  25229. }), this.syncing?.state !== ProgressState.PENDING)
  25230. break;
  25231. this.syncing.resolve?.();
  25232. let setStateEvent = {
  25233. type: _UniversalStore.InternalEventType.SET_STATE,
  25234. payload: {
  25235. state: event.payload,
  25236. previousState: this.state
  25237. }
  25238. };
  25239. this.state = event.payload, this.emitToListeners(setStateEvent, eventInfo);
  25240. break;
  25241. }
  25242. event.type === _UniversalStore.InternalEventType.SET_STATE && (this.debug("handleChannelEvents: Setting state", { event }), this.state = event.payload.state), this.emitToListeners(event, { actor: eventInfo.actor });
  25243. }
  25244. debug(message, data) {
  25245. this.debugging && console.debug(
  25246. dedent`[UniversalStore::${this.id}::${this.environment ?? _UniversalStore.Environment.UNKNOWN}]
  25247. ${message}`,
  25248. JSON.stringify(
  25249. {
  25250. data,
  25251. actor: this.actor,
  25252. state: this.state,
  25253. status: this.status
  25254. },
  25255. null,
  25256. 2
  25257. )
  25258. );
  25259. }
  25260. /**
  25261. * Used to reset the static fields of the UniversalStore class when cleaning up tests
  25262. *
  25263. * @internal
  25264. */
  25265. static __reset() {
  25266. _UniversalStore.preparation.reject(new Error("reset")), _UniversalStore.setupPreparationPromise(), _UniversalStore.isInternalConstructing = !1;
  25267. }
  25268. };
  25269. /**
  25270. * Defines the possible actor types in the store system
  25271. *
  25272. * @readonly
  25273. */
  25274. _UniversalStore.ActorType = {
  25275. LEADER: "LEADER",
  25276. FOLLOWER: "FOLLOWER"
  25277. }, /**
  25278. * Defines the possible environments the store can run in
  25279. *
  25280. * @readonly
  25281. */
  25282. _UniversalStore.Environment = {
  25283. SERVER: "SERVER",
  25284. MANAGER: "MANAGER",
  25285. PREVIEW: "PREVIEW",
  25286. UNKNOWN: "UNKNOWN",
  25287. MOCK: "MOCK"
  25288. }, /**
  25289. * Internal event types used for store synchronization
  25290. *
  25291. * @readonly
  25292. */
  25293. _UniversalStore.InternalEventType = {
  25294. EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST",
  25295. EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE",
  25296. SET_STATE: "__SET_STATE",
  25297. LEADER_CREATED: "__LEADER_CREATED",
  25298. FOLLOWER_CREATED: "__FOLLOWER_CREATED"
  25299. }, _UniversalStore.Status = {
  25300. UNPREPARED: "UNPREPARED",
  25301. SYNCING: "SYNCING",
  25302. READY: "READY",
  25303. ERROR: "ERROR"
  25304. }, // This is used to check if constructor was called from the static factory create()
  25305. _UniversalStore.isInternalConstructing = !1, _UniversalStore.setupPreparationPromise();
  25306. var UniversalStore = _UniversalStore;
  25307. // src/shared/universal-store/use-universal-store-manager.ts
  25308. init_react();
  25309. var useUniversalStore = (universalStore, selector) => {
  25310. let snapshotRef = useRef(
  25311. selector ? selector(universalStore.getState()) : universalStore.getState()
  25312. ), subscribe = useCallback(
  25313. (listener) => universalStore.onStateChange((state2, previousState) => {
  25314. if (!selector) {
  25315. snapshotRef.current = state2, listener();
  25316. return;
  25317. }
  25318. let selectedState = selector(state2), selectedPreviousState = selector(previousState);
  25319. !isEqual(selectedState, selectedPreviousState) && (snapshotRef.current = selectedState, listener());
  25320. }),
  25321. [universalStore, selector]
  25322. ), getSnapshot = useCallback(() => {
  25323. let currentState = universalStore.getState(), selectedState = selector ? selector(currentState) : currentState;
  25324. return isEqual(selectedState, snapshotRef.current) || (snapshotRef.current = selectedState), snapshotRef.current;
  25325. }, [universalStore, selector]);
  25326. return [useSyncExternalStore(subscribe, getSnapshot), universalStore.setState];
  25327. };
  25328. // src/manager-api/stores/status.ts
  25329. var statusStore = createStatusStore({
  25330. universalStatusStore: UniversalStore.create({
  25331. ...UNIVERSAL_STATUS_STORE_OPTIONS,
  25332. leader: globalThis.CONFIG_TYPE === "PRODUCTION"
  25333. }),
  25334. useUniversalStore,
  25335. environment: "manager"
  25336. }), { fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore } = statusStore;
  25337. // src/manager-api/modules/statuses.ts
  25338. var computeStatusFilterFn = (includedStatusFilters, excludedStatusFilters) => (entry) => {
  25339. if (!includedStatusFilters.length && !excludedStatusFilters.length)
  25340. return !0;
  25341. 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));
  25342. return passesInclude && passesExclude;
  25343. };
  25344. // src/manager-api/modules/tags.ts
  25345. var import_memoizerific5 = __toESM(require_memoizerific(), 1);
  25346. var getDefaultTagsFromPreset = (0, import_memoizerific5.default)(1)((presets) => {
  25347. let presetEntries = Object.entries(presets);
  25348. return {
  25349. included: presetEntries.filter(([, option]) => option.defaultFilterSelection === "include").map(([tag]) => tag),
  25350. excluded: presetEntries.filter(([, option]) => option.defaultFilterSelection === "exclude").map(([tag]) => tag)
  25351. };
  25352. });
  25353. var computeTagsFilterFn = (includedTagFilters, excludedTagFilters) => {
  25354. let computeFilterFunctions = (set) => Object.values(
  25355. set.reduce(
  25356. (acc, tag) => (Object.hasOwn(BUILT_IN_FILTERS, tag) ? acc["built-in"].push(BUILT_IN_FILTERS[tag]) : acc.user.push(USER_TAG_FILTER(tag)), acc),
  25357. { "built-in": [], user: [] }
  25358. )
  25359. ).filter((group) => group.length > 0);
  25360. return (item) => {
  25361. let included = computeFilterFunctions(includedTagFilters), excluded = computeFilterFunctions(excludedTagFilters);
  25362. return (!included.length || included.every((group) => group.some((filterFn) => filterFn(item, !1)))) && (!excluded.length || excluded.every((group) => group.every((filterFn) => filterFn(item, !0))));
  25363. };
  25364. };
  25365. // src/manager/components/sidebar/ReviewChangesButton.tsx
  25366. var Wrapper8 = styled.div({
  25367. display: "flex",
  25368. alignItems: "center",
  25369. gap: 4,
  25370. marginTop: -8
  25371. }), StyledCTA = styled(ToggleButton)({
  25372. flex: 1,
  25373. justifyContent: "flex-start"
  25374. }), StyledIcon = styled.svg(({ theme }) => ({
  25375. color: theme.fgColor.accent
  25376. })), NEW = "status-value:new", MOD = "status-value:modified", ReviewChangesButton = () => {
  25377. let api = useStorybookApi(), {
  25378. internal_index: index,
  25379. includedStatusFilters: rawIncludedStatusFilters,
  25380. excludedStatusFilters: rawExcludedStatusFilters,
  25381. includedTagFilters: rawIncludedTagFilters,
  25382. excludedTagFilters: rawExcludedTagFilters
  25383. } = useStorybookState(), allStatuses = experimental_useStatusStore(), { newCount, modifiedCount } = useMemo(() => {
  25384. if (!index)
  25385. return { newCount: 0, modifiedCount: 0 };
  25386. 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(
  25387. contextualIncludedStatuses,
  25388. contextualExcludedStatuses
  25389. ), next = 0, modified = 0, entries = index.entries ?? {};
  25390. for (let [storyId, statusesByType] of Object.entries(allStatuses)) {
  25391. let entry = entries[storyId];
  25392. if (!entry)
  25393. continue;
  25394. let entryWithStatuses = { ...entry, statuses: statusesByType };
  25395. if (!tagFilterFn(entryWithStatuses) || !statusFilterFn(entryWithStatuses))
  25396. continue;
  25397. let statuses = Object.values(statusesByType);
  25398. statuses.some(({ value }) => value === NEW) && (next += 1), statuses.some(({ value }) => value === MOD) && (modified += 1);
  25399. }
  25400. return { newCount: next, modifiedCount: modified };
  25401. }, [
  25402. index,
  25403. allStatuses,
  25404. rawIncludedStatusFilters,
  25405. rawExcludedStatusFilters,
  25406. rawIncludedTagFilters,
  25407. rawExcludedTagFilters
  25408. ]), includedStatusFilters = rawIncludedStatusFilters ?? [], excludedStatusFilters = rawExcludedStatusFilters ?? [], isReviewActive = includedStatusFilters.includes(NEW) && includedStatusFilters.includes(MOD);
  25409. if (!globalThis.FEATURES?.changeDetection || newCount === 0 && modifiedCount === 0)
  25410. return null;
  25411. let clearReview = () => {
  25412. let nextIncluded = includedStatusFilters.filter((s2) => s2 !== NEW && s2 !== MOD), nextExcluded = excludedStatusFilters.filter((s2) => s2 !== NEW && s2 !== MOD);
  25413. api.setAllStatusFilters(nextIncluded, nextExcluded);
  25414. }, onClick = () => {
  25415. if (isReviewActive)
  25416. clearReview();
  25417. else {
  25418. let nextIncluded = Array.from(/* @__PURE__ */ new Set([...includedStatusFilters, NEW, MOD])), nextExcluded = excludedStatusFilters.filter((s2) => s2 !== NEW && s2 !== MOD);
  25419. api.setAllStatusFilters(nextIncluded, nextExcluded);
  25420. }
  25421. }, onClearClick = (e2) => {
  25422. e2.stopPropagation(), clearReview();
  25423. }, changeKinds = newCount > 0 && modifiedCount > 0 ? "new and modified" : newCount > 0 ? "new" : "modified", label = `${isReviewActive ? "Reviewing" : "Review"} ${changeKinds} stories`;
  25424. return react_default.createElement(Wrapper8, null, react_default.createElement(
  25425. StyledCTA,
  25426. {
  25427. variant: "ghost",
  25428. padding: "small",
  25429. pressed: isReviewActive,
  25430. ariaLabel: label,
  25431. onClick
  25432. },
  25433. react_default.createElement(StyledIcon, { viewBox: "0 0 14 14", width: "14", height: "14", "aria-hidden": !0 }, react_default.createElement(UseSymbol, { type: "new" })),
  25434. label
  25435. ), isReviewActive && react_default.createElement(
  25436. Button,
  25437. {
  25438. variant: "ghost",
  25439. padding: "small",
  25440. size: "small",
  25441. onClick: onClearClick,
  25442. ariaLabel: "Clear",
  25443. tooltip: "Clear"
  25444. },
  25445. react_default.createElement(CloseIcon, null)
  25446. ));
  25447. }, ReviewChangesButton_default = ReviewChangesButton;
  25448. // src/manager/components/sidebar/useLastViewed.ts
  25449. init_react();
  25450. var import_store2 = __toESM(require_store2(), 1), save = debounce((value) => import_store2.default.set("lastViewedStoryIds", value), 1e3), useLastViewed = (selection) => {
  25451. let initialLastViewedStoryIds = useMemo(() => {
  25452. let items = import_store2.default.get("lastViewedStoryIds");
  25453. return !items || !Array.isArray(items) ? [] : items.some((item) => typeof item == "object" && item.storyId && item.refId) ? items : [];
  25454. }, [import_store2.default]), lastViewedRef = useRef(initialLastViewedStoryIds), updateLastViewed = useCallback(
  25455. (story) => {
  25456. let items = lastViewedRef.current, index = items.findIndex(
  25457. ({ storyId, refId }) => storyId === story.storyId && refId === story.refId
  25458. );
  25459. index !== 0 && (index === -1 ? lastViewedRef.current = [story, ...items] : lastViewedRef.current = [story, ...items.slice(0, index), ...items.slice(index + 1)], save(lastViewedRef.current));
  25460. },
  25461. [lastViewedRef]
  25462. );
  25463. return useEffect(() => {
  25464. selection && updateLastViewed(selection);
  25465. }, [selection]), {
  25466. getLastViewed: useCallback(() => lastViewedRef.current, [lastViewedRef]),
  25467. clearLastViewed: useCallback(() => {
  25468. lastViewedRef.current = lastViewedRef.current.slice(0, 1), save(lastViewedRef.current);
  25469. }, [lastViewedRef])
  25470. };
  25471. };
  25472. // src/manager/components/sidebar/Sidebar.tsx
  25473. var DEFAULT_REF_ID = "storybook_internal", Container11 = styled.header(({ theme }) => ({
  25474. position: "absolute",
  25475. zIndex: 1,
  25476. left: 0,
  25477. top: 0,
  25478. bottom: 0,
  25479. right: 0,
  25480. width: "100%",
  25481. height: "100%",
  25482. display: "flex",
  25483. flexDirection: "column",
  25484. background: theme.background.content,
  25485. [MEDIA_DESKTOP_BREAKPOINT]: {
  25486. background: theme.background.app
  25487. }
  25488. })), Stack = styled.div({
  25489. display: "flex",
  25490. flexDirection: "column",
  25491. gap: 16,
  25492. padding: "16px 12px 20px 12px"
  25493. }), CreateNewStoryButton = styled(Button)(({ theme, isMobile: isMobile2 }) => ({
  25494. color: theme.textMutedColor,
  25495. width: isMobile2 ? 36 : 32,
  25496. height: isMobile2 ? 36 : 32,
  25497. borderRadius: theme.appBorderRadius + 2
  25498. })), useCombination = (index, indexError, previewInitialized, allStatuses, refs) => {
  25499. let hash = useMemo(
  25500. () => ({
  25501. [DEFAULT_REF_ID]: {
  25502. index,
  25503. filteredIndex: index,
  25504. indexError,
  25505. previewInitialized,
  25506. allStatuses,
  25507. title: null,
  25508. id: DEFAULT_REF_ID,
  25509. url: "iframe.html"
  25510. },
  25511. ...refs
  25512. }),
  25513. [refs, index, indexError, previewInitialized, allStatuses]
  25514. );
  25515. return useMemo(() => ({ hash, entries: Object.entries(hash) }), [hash]);
  25516. }, isRendererReact2 = scope.STORYBOOK_RENDERER === "react", Sidebar = react_default.memo(function({
  25517. // @ts-expect-error (non strict)
  25518. storyId = null,
  25519. refId = DEFAULT_REF_ID,
  25520. index,
  25521. indexJson,
  25522. indexError,
  25523. allStatuses,
  25524. previewInitialized,
  25525. menu,
  25526. menuHighlighted = !1,
  25527. enableShortcuts = !0,
  25528. isDevelopment = scope.CONFIG_TYPE === "DEVELOPMENT",
  25529. refs = {},
  25530. onMenuClick,
  25531. showCreateStoryButton = isDevelopment && isRendererReact2
  25532. }) {
  25533. 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(
  25534. { "aria-labelledby": "global-site-h1", role: "banner" },
  25535. headerRef
  25536. ), skipLinkHref = viewMode !== void 0 && viewMode !== "story" && viewMode !== "docs" ? "#main-content-wrapper" : "#storybook-preview-wrapper";
  25537. return react_default.createElement(
  25538. Container11,
  25539. {
  25540. className: "container sidebar-container",
  25541. id: focusableUIElements.sidebarRegion,
  25542. ref: headerRef,
  25543. ...landmarkProps
  25544. },
  25545. react_default.createElement("h1", { id: "global-site-h1", className: "sb-sr-only" }, "Storybook"),
  25546. react_default.createElement(IconSymbols, null),
  25547. 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(
  25548. Heading2,
  25549. {
  25550. className: "sidebar-header",
  25551. menuHighlighted,
  25552. menu,
  25553. skipLinkHref,
  25554. isLoading,
  25555. onMenuClick
  25556. }
  25557. ), !isLoading && scope.CONFIG_TYPE === "DEVELOPMENT" && scope.FEATURES?.sidebarOnboardingChecklist !== !1 && react_default.createElement(ChecklistWidget, null)), react_default.createElement(
  25558. Search,
  25559. {
  25560. dataset,
  25561. enableShortcuts,
  25562. searchBarContent: showCreateStoryButton && react_default.createElement(react_default.Fragment, null, react_default.createElement(
  25563. CreateNewStoryButton,
  25564. {
  25565. isMobile: isMobile2,
  25566. onClick: () => {
  25567. setIsFileSearchModalOpen(!0);
  25568. },
  25569. ariaLabel: "Create a new story",
  25570. variant: "outline",
  25571. padding: "small"
  25572. },
  25573. react_default.createElement(PlusIcon, null)
  25574. ), react_default.createElement(
  25575. CreateNewStoryFileModal,
  25576. {
  25577. open: isFileSearchModalOpen,
  25578. onOpenChange: setIsFileSearchModalOpen
  25579. }
  25580. )),
  25581. searchFieldContent: react_default.createElement(Filter, null),
  25582. belowSearchContent: react_default.createElement(ReviewChangesButton_default, null),
  25583. ...lastViewedProps
  25584. },
  25585. ({
  25586. query,
  25587. results,
  25588. isNavVisible,
  25589. isNavReachable,
  25590. isSearchResultRendered,
  25591. closeMenu,
  25592. getMenuProps,
  25593. getItemProps,
  25594. highlightedIndex
  25595. }) => react_default.createElement(react_default.Fragment, null, react_default.createElement(
  25596. Explorer,
  25597. {
  25598. dataset,
  25599. selected,
  25600. isLoading,
  25601. isBrowsing: isNavVisible,
  25602. isHidden: !isNavReachable,
  25603. hasEntries
  25604. }
  25605. ), isSearchResultRendered && react_default.createElement(
  25606. SearchResults,
  25607. {
  25608. query,
  25609. results,
  25610. closeMenu,
  25611. getMenuProps,
  25612. getItemProps,
  25613. highlightedIndex,
  25614. enableShortcuts,
  25615. isLoading,
  25616. clearLastViewed: lastViewedProps.clearLastViewed
  25617. }
  25618. ))
  25619. )), isMobile2 || isLoading ? null : react_default.createElement(SidebarBottom, { isDevelopment }))
  25620. );
  25621. });
  25622. // src/manager/container/Menu.tsx
  25623. init_react();
  25624. var ProgressCircle2 = styled(ProgressSpinner)(({ theme }) => ({
  25625. color: theme.color.secondary
  25626. })), useMenu = ({
  25627. api,
  25628. showToolbar,
  25629. isPanelShown,
  25630. isNavShown,
  25631. enableShortcuts
  25632. }) => {
  25633. let shortcutKeys = api.getShortcutKeys(), { progress } = useChecklist(), about = useMemo(
  25634. () => ({
  25635. id: "about",
  25636. title: "About your Storybook",
  25637. onClick: () => api.changeSettingsTab("about"),
  25638. href: "./?path=/settings/about",
  25639. internal: !0,
  25640. closeOnClick: !0,
  25641. icon: react_default.createElement(InfoIcon, null)
  25642. }),
  25643. [api]
  25644. ), guide = useMemo(
  25645. () => ({
  25646. id: "guide",
  25647. title: "Onboarding guide",
  25648. onClick: () => api.changeSettingsTab("guide"),
  25649. href: "./?path=/settings/guide",
  25650. internal: !0,
  25651. closeOnClick: !0,
  25652. icon: react_default.createElement(ListUnorderedIcon, null),
  25653. 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, "%")
  25654. }),
  25655. [api, progress]
  25656. ), shortcuts = useMemo(
  25657. () => ({
  25658. id: "shortcuts",
  25659. title: "Keyboard shortcuts",
  25660. onClick: () => api.changeSettingsTab("shortcuts"),
  25661. href: "./?path=/settings/shortcuts",
  25662. internal: !0,
  25663. closeOnClick: !0,
  25664. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.shortcutsPage }) : null,
  25665. icon: react_default.createElement(CommandIcon, null)
  25666. }),
  25667. [api, enableShortcuts, shortcutKeys.shortcutsPage]
  25668. ), sidebarToggle = useMemo(
  25669. () => ({
  25670. id: "S",
  25671. title: "Show sidebar",
  25672. onClick: () => api.toggleNav(),
  25673. closeOnClick: !0,
  25674. active: isNavShown,
  25675. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.toggleNav }) : null,
  25676. icon: isNavShown ? react_default.createElement(CheckIcon, null) : react_default.createElement(react_default.Fragment, null)
  25677. }),
  25678. [api, enableShortcuts, shortcutKeys, isNavShown]
  25679. ), toolbarToogle = useMemo(
  25680. () => ({
  25681. id: "T",
  25682. title: "Show toolbar",
  25683. onClick: () => api.toggleToolbar(),
  25684. active: showToolbar,
  25685. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.toolbar }) : null,
  25686. icon: showToolbar ? react_default.createElement(CheckIcon, null) : react_default.createElement(react_default.Fragment, null)
  25687. }),
  25688. [api, enableShortcuts, shortcutKeys, showToolbar]
  25689. ), addonsToggle = useMemo(
  25690. () => ({
  25691. id: "A",
  25692. title: "Show addons panel",
  25693. onClick: () => api.togglePanel(),
  25694. active: isPanelShown,
  25695. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.togglePanel }) : null,
  25696. icon: isPanelShown ? react_default.createElement(CheckIcon, null) : react_default.createElement(react_default.Fragment, null)
  25697. }),
  25698. [api, enableShortcuts, shortcutKeys, isPanelShown]
  25699. ), up = useMemo(
  25700. () => ({
  25701. id: "up",
  25702. title: "Previous component",
  25703. onClick: () => api.jumpToComponent(-1),
  25704. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.prevComponent }) : null,
  25705. icon: react_default.createElement(react_default.Fragment, null)
  25706. }),
  25707. [api, enableShortcuts, shortcutKeys]
  25708. ), down = useMemo(
  25709. () => ({
  25710. id: "down",
  25711. title: "Next component",
  25712. onClick: () => api.jumpToComponent(1),
  25713. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.nextComponent }) : null,
  25714. icon: react_default.createElement(react_default.Fragment, null)
  25715. }),
  25716. [api, enableShortcuts, shortcutKeys]
  25717. ), prev = useMemo(
  25718. () => ({
  25719. id: "prev",
  25720. title: "Previous story",
  25721. onClick: () => api.jumpToStory(-1),
  25722. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.prevStory }) : null,
  25723. icon: react_default.createElement(react_default.Fragment, null)
  25724. }),
  25725. [api, enableShortcuts, shortcutKeys]
  25726. ), next = useMemo(
  25727. () => ({
  25728. id: "next",
  25729. title: "Next story",
  25730. onClick: () => api.jumpToStory(1),
  25731. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.nextStory }) : null,
  25732. icon: react_default.createElement(react_default.Fragment, null)
  25733. }),
  25734. [api, enableShortcuts, shortcutKeys]
  25735. ), collapse = useMemo(
  25736. () => ({
  25737. id: "collapse",
  25738. title: "Collapse all",
  25739. onClick: () => api.emit(STORIES_COLLAPSE_ALL),
  25740. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: shortcutKeys.collapseAll }) : null,
  25741. icon: react_default.createElement(react_default.Fragment, null)
  25742. }),
  25743. [api, enableShortcuts, shortcutKeys]
  25744. ), documentation = useMemo(() => ({
  25745. id: "documentation",
  25746. title: "Documentation",
  25747. closeOnClick: !0,
  25748. href: api.getDocsUrl({ versioned: !0, renderer: !0 }),
  25749. right: react_default.createElement(ActionList.Icon, null, react_default.createElement(ShareAltIcon, null)),
  25750. icon: react_default.createElement(DocumentIcon, null)
  25751. }), [api]), getAddonsShortcuts = useCallback(() => {
  25752. let addonsShortcuts = api.getAddonsShortcuts(), keys = shortcutKeys;
  25753. return Object.entries(addonsShortcuts).filter(([_2, { showInMenu }]) => showInMenu).map(([actionName, { label, action }]) => ({
  25754. id: actionName,
  25755. title: label,
  25756. onClick: () => action(),
  25757. right: enableShortcuts ? react_default.createElement(Shortcut, { keys: keys[actionName] }) : null
  25758. }));
  25759. }, [api, enableShortcuts, shortcutKeys]);
  25760. return useMemo(
  25761. () => [
  25762. [
  25763. about,
  25764. ...scope.CONFIG_TYPE === "DEVELOPMENT" ? [guide] : [],
  25765. ...enableShortcuts ? [shortcuts] : []
  25766. ],
  25767. [sidebarToggle, toolbarToogle, addonsToggle, up, down, prev, next, collapse],
  25768. getAddonsShortcuts(),
  25769. [documentation]
  25770. ],
  25771. [
  25772. about,
  25773. guide,
  25774. documentation,
  25775. shortcuts,
  25776. sidebarToggle,
  25777. toolbarToogle,
  25778. addonsToggle,
  25779. up,
  25780. down,
  25781. prev,
  25782. next,
  25783. collapse,
  25784. getAddonsShortcuts,
  25785. enableShortcuts
  25786. ]
  25787. );
  25788. };
  25789. // src/manager/container/Sidebar.tsx
  25790. var Sidebar3 = react_default.memo(function({ onMenuClick }) {
  25791. return react_default.createElement(Consumer, { filter: ({ state, api }) => {
  25792. let {
  25793. ui: { name, url, enableShortcuts },
  25794. viewMode,
  25795. storyId,
  25796. refId,
  25797. layout: { showToolbar },
  25798. // FIXME: This is the actual `index.json` index where the `index` below
  25799. // is actually the stories hash. We should fix this up and make it consistent.
  25800. internal_index,
  25801. filteredIndex: index,
  25802. indexError,
  25803. previewInitialized,
  25804. refs
  25805. } = state, whatsNewNotificationsEnabled = state.whatsNewData?.status === "SUCCESS" && !state.disableWhatsNewNotifications;
  25806. return {
  25807. api,
  25808. title: name,
  25809. url,
  25810. indexJson: internal_index,
  25811. index,
  25812. indexError,
  25813. previewInitialized,
  25814. refs,
  25815. storyId,
  25816. refId,
  25817. viewMode,
  25818. showToolbar,
  25819. isPanelShown: api.getIsPanelShown(),
  25820. isNavShown: api.getIsNavShown(),
  25821. menuHighlighted: whatsNewNotificationsEnabled && api.isWhatsNewUnread(),
  25822. enableShortcuts
  25823. };
  25824. } }, ({ api, showToolbar, isPanelShown, isNavShown, enableShortcuts, ...state }) => {
  25825. let menu = useMenu({ api, showToolbar, isPanelShown, isNavShown, enableShortcuts }), allStatuses = experimental_useStatusStore();
  25826. return react_default.createElement(
  25827. Sidebar,
  25828. {
  25829. ...state,
  25830. menu,
  25831. onMenuClick,
  25832. allStatuses,
  25833. enableShortcuts
  25834. }
  25835. );
  25836. });
  25837. }), Sidebar_default = Sidebar3;
  25838. // src/manager/App.tsx
  25839. var App = ({ managerLayoutState, setManagerLayoutState, pages, hasTab }) => {
  25840. let { setMobileAboutOpen } = useLayout(), { enableShortcuts = !0 } = addons.getConfig();
  25841. return useEffect(() => {
  25842. document.body.setAttribute("data-shortcuts-enabled", enableShortcuts ? "true" : "false");
  25843. }, [enableShortcuts]), useEffect(() => {
  25844. let rootElement = document.getElementById("root");
  25845. if (!rootElement)
  25846. return;
  25847. let observer = new MutationObserver(() => {
  25848. let hasInert = rootElement.hasAttribute("inert");
  25849. addons.getChannel().emit(core_events_default.MANAGER_INERT_ATTRIBUTE_CHANGED, hasInert);
  25850. });
  25851. return observer.observe(rootElement, {
  25852. attributes: !0,
  25853. attributeFilter: ["inert"]
  25854. }), () => observer.disconnect();
  25855. }, []), react_default.createElement(react_default.Fragment, null, react_default.createElement(Global, { styles: createGlobal }), react_default.createElement(ManagerErrorBoundary, null, react_default.createElement(
  25856. Layout,
  25857. {
  25858. hasTab,
  25859. managerLayoutState,
  25860. setManagerLayoutState,
  25861. slotMain: react_default.createElement(Preview_default, { id: "main", withLoader: !0 }),
  25862. slotSidebar: react_default.createElement(Sidebar_default, { onMenuClick: () => setMobileAboutOpen((state) => !state) }),
  25863. slotPanel: react_default.createElement(Panel_default, null),
  25864. slotPages: pages.map(({ id, render: Content6 }) => react_default.createElement(Content6, { key: id }))
  25865. }
  25866. )));
  25867. };
  25868. // src/manager/provider.ts
  25869. var Provider2 = class {
  25870. getElements(_type) {
  25871. throw new Error("Provider.getElements() is not implemented!");
  25872. }
  25873. handleAPI(_api) {
  25874. throw new Error("Provider.handleAPI() is not implemented!");
  25875. }
  25876. getConfig() {
  25877. return console.error("Provider.getConfig() is not implemented!"), {};
  25878. }
  25879. };
  25880. // src/manager/settings/index.tsx
  25881. init_react();
  25882. // src/manager/settings/AboutPage.tsx
  25883. init_react();
  25884. // src/manager/settings/About.tsx
  25885. init_react();
  25886. var Container12 = styled.div({
  25887. display: "flex",
  25888. alignItems: "center",
  25889. flexDirection: "column",
  25890. marginTop: 40
  25891. }), Header = styled.header({
  25892. marginBottom: 32,
  25893. alignItems: "center",
  25894. display: "flex",
  25895. "> svg": {
  25896. height: 48,
  25897. width: "auto",
  25898. marginRight: 8
  25899. }
  25900. }), Footer = styled.div(({ theme }) => ({
  25901. marginBottom: 24,
  25902. display: "flex",
  25903. flexDirection: "column",
  25904. alignItems: "center",
  25905. color: theme.base === "light" ? theme.color.dark : theme.color.lightest,
  25906. fontWeight: theme.typography.weight.regular,
  25907. fontSize: theme.typography.size.s2
  25908. })), Actions2 = styled.div({
  25909. display: "flex",
  25910. flexDirection: "row",
  25911. alignItems: "center",
  25912. marginBottom: 24,
  25913. marginTop: 24,
  25914. gap: 16
  25915. }), StyledLink = styled(Link)(({ theme }) => ({
  25916. "&&": {
  25917. fontWeight: theme.typography.weight.bold,
  25918. color: theme.base === "light" ? theme.color.dark : theme.color.light
  25919. },
  25920. "&:hover": {
  25921. color: theme.base === "light" ? theme.color.darkest : theme.color.lightest
  25922. }
  25923. })), 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"))));
  25924. // src/manager/settings/AboutPage.tsx
  25925. var NotificationClearer = class extends Component {
  25926. componentDidMount() {
  25927. let { api, notificationId } = this.props;
  25928. api.clearNotification(notificationId);
  25929. }
  25930. render() {
  25931. let { children } = this.props;
  25932. return children;
  25933. }
  25934. }, AboutPage = () => {
  25935. let api = useStorybookApi(), state = useStorybookState(), onNavigateToWhatsNew = useCallback(() => {
  25936. api.changeSettingsTab("whats-new");
  25937. }, [api]);
  25938. return react_default.createElement(NotificationClearer, { api, notificationId: "update" }, react_default.createElement(
  25939. AboutScreen,
  25940. {
  25941. onNavigateToWhatsNew: state.whatsNewData?.status === "SUCCESS" ? onNavigateToWhatsNew : void 0
  25942. }
  25943. ));
  25944. };
  25945. // src/manager/settings/GuidePage.tsx
  25946. init_react();
  25947. // src/manager/settings/Checklist/Checklist.tsx
  25948. init_react();
  25949. // src/manager/components/Focus/Focus.tsx
  25950. init_react();
  25951. var FocusOutline = styled.div(
  25952. ({ theme, active = !1, outlineOffset = 0 }) => ({
  25953. width: "100%",
  25954. borderRadius: "inherit",
  25955. transition: "outline-color var(--transition-duration, 0.2s)",
  25956. outline: `2px solid ${active ? theme.color.secondary : "transparent"}`,
  25957. outlineOffset
  25958. })
  25959. ), FocusProxy = styled(FocusOutline)(({ theme, targetId }) => ({
  25960. [`&:has([data-target-id="${targetId}"]:focus-visible)`]: {
  25961. outlineColor: theme.color.secondary
  25962. }
  25963. })), FocusRing = ({
  25964. active = !1,
  25965. highlightDuration,
  25966. nodeRef,
  25967. ...props
  25968. }) => {
  25969. let [visible, setVisible] = useState(active);
  25970. return useEffect(() => {
  25971. if (highlightDuration) {
  25972. setVisible(active);
  25973. let timeout = setTimeout(setVisible, highlightDuration, !1);
  25974. return () => clearTimeout(timeout);
  25975. }
  25976. }, [active, highlightDuration]), react_default.createElement(FocusOutline, { ...props, active: highlightDuration ? visible : active, ref: nodeRef });
  25977. }, FocusTarget = ({
  25978. targetHash,
  25979. highlightDuration,
  25980. ...props
  25981. }) => {
  25982. let nodeRef = useRef(null), locationHash = useLocationHash(), [active, setActive] = useState(locationHash === targetHash);
  25983. return useEffect(() => {
  25984. let timeouts = [];
  25985. return setActive(!1), locationHash === targetHash && (timeouts.push(
  25986. setTimeout(() => {
  25987. setActive(!0), nodeRef.current?.focus({ preventScroll: !0 }), nodeRef.current?.scrollIntoView({ behavior: "smooth", block: "center" });
  25988. }, 0)
  25989. ), highlightDuration && timeouts.push(setTimeout(setActive, highlightDuration, !1))), () => timeouts.forEach(clearTimeout);
  25990. }, [locationHash, targetHash, highlightDuration]), react_default.createElement(FocusRing, { ...props, active, nodeRef, tabIndex: -1 });
  25991. }, Focus = {
  25992. Outline: FocusOutline,
  25993. Proxy: FocusProxy,
  25994. Ring: FocusRing,
  25995. Target: FocusTarget
  25996. };
  25997. // src/manager/settings/Checklist/Checklist.tsx
  25998. var Sections = styled.ol(({ theme }) => ({
  25999. listStyle: "none",
  26000. display: "flex",
  26001. flexDirection: "column",
  26002. gap: 20,
  26003. margin: 0,
  26004. padding: 0,
  26005. "& > li": {
  26006. background: theme.background.content,
  26007. border: `1px solid ${theme.base === "dark" ? theme.color.darker : theme.color.border}`,
  26008. borderRadius: 8
  26009. }
  26010. })), Items = styled.ol(({ theme }) => ({
  26011. listStyle: "none",
  26012. display: "flex",
  26013. flexDirection: "column",
  26014. margin: 0,
  26015. padding: 0,
  26016. "& > li:not(:last-child)": {
  26017. boxShadow: `inset 0 -1px 0 ${theme.base === "dark" ? theme.color.darker : theme.color.border}`
  26018. },
  26019. "& > li:last-child": {
  26020. borderBottomLeftRadius: 7,
  26021. borderBottomRightRadius: 7
  26022. }
  26023. })), SectionSummary = styled.div(
  26024. ({ theme, progress, isCollapsed, onClick }) => ({
  26025. position: "relative",
  26026. fontWeight: "bold",
  26027. display: "flex",
  26028. alignItems: "center",
  26029. gap: 10,
  26030. padding: "10px 10px 10px 15px",
  26031. borderBottom: `5px solid ${theme.base === "dark" ? theme.color.darker : theme.color.light}`,
  26032. borderBottomLeftRadius: isCollapsed ? 7 : 0,
  26033. borderBottomRightRadius: isCollapsed ? 7 : 0,
  26034. transition: "border-radius var(--transition-duration, 0.2s)",
  26035. cursor: onClick ? "pointer" : "default",
  26036. "--toggle-button-rotate": isCollapsed ? "0deg" : "180deg",
  26037. "--toggle-button-opacity": 0,
  26038. "&:hover, &:focus-visible": {
  26039. outline: "none",
  26040. "--toggle-button-opacity": 1
  26041. },
  26042. "&::after": {
  26043. pointerEvents: "none",
  26044. position: "absolute",
  26045. top: 0,
  26046. bottom: -5,
  26047. left: 0,
  26048. right: 0,
  26049. content: '""',
  26050. display: "block",
  26051. width: `${progress}%`,
  26052. borderBottom: `5px solid ${theme.color.positive}`,
  26053. borderBottomLeftRadius: "inherit",
  26054. borderBottomRightRadius: progress === 100 ? "inherit" : 0,
  26055. transition: "width var(--transition-duration, 0.2s)"
  26056. }
  26057. })
  26058. ), SectionHeading = styled.h2(({ theme }) => ({
  26059. flex: 1,
  26060. margin: 0,
  26061. fontSize: theme.typography.size.s3,
  26062. fontWeight: theme.typography.weight.bold
  26063. })), ItemSummary = styled.div(
  26064. ({ theme, isCollapsed, onClick }) => ({
  26065. fontWeight: theme.typography.weight.regular,
  26066. fontSize: theme.typography.size.s2,
  26067. display: "flex",
  26068. alignItems: "center",
  26069. minHeight: 40,
  26070. gap: 10,
  26071. padding: isCollapsed ? "6px 10px 6px 15px" : "10px 10px 10px 15px",
  26072. transition: "padding var(--transition-duration, 0.2s)",
  26073. cursor: onClick ? "pointer" : "default",
  26074. "--toggle-button-rotate": isCollapsed ? "0deg" : "180deg",
  26075. "&:focus-visible": {
  26076. outline: "none"
  26077. }
  26078. })
  26079. ), ItemHeading = styled.h3(({ theme, skipped }) => ({
  26080. flex: 1,
  26081. margin: 0,
  26082. color: skipped ? theme.textMutedColor : theme.color.defaultText,
  26083. overflow: "hidden",
  26084. textOverflow: "ellipsis",
  26085. whiteSpace: "nowrap",
  26086. fontSize: theme.typography.size.s2,
  26087. fontWeight: theme.typography.weight.bold
  26088. })), ItemContent2 = styled.div(({ theme }) => ({
  26089. display: "flex",
  26090. flexDirection: "column",
  26091. alignItems: "flex-start",
  26092. gap: 8,
  26093. padding: "0 15px 15px 41px",
  26094. fontSize: theme.typography.size.s2,
  26095. code: {
  26096. fontSize: "0.9em",
  26097. backgroundColor: theme.background.app,
  26098. borderRadius: theme.appBorderRadius,
  26099. padding: "1px 3px"
  26100. },
  26101. img: {
  26102. maxWidth: "100%",
  26103. margin: "15px auto"
  26104. },
  26105. p: {
  26106. margin: 0,
  26107. lineHeight: 1.4
  26108. },
  26109. "ol, ul": {
  26110. paddingLeft: 25,
  26111. listStyleType: "disc",
  26112. "li::marker": {
  26113. color: theme.color.mediumdark
  26114. }
  26115. }
  26116. })), StatusIcon3 = styled.div(({ theme }) => ({
  26117. position: "relative",
  26118. flex: "0 0 auto",
  26119. minHeight: 16,
  26120. minWidth: 16,
  26121. margin: 0,
  26122. background: theme.base === "dark" ? theme.color.darkest : theme.background.app,
  26123. borderRadius: 9,
  26124. outline: `1px solid ${theme.base === "dark" ? theme.color.darker : theme.color.border}`,
  26125. outlineOffset: -1
  26126. })), Checked2 = styled(StatusPassIcon)(
  26127. ({ theme, "data-visible": visible }) => ({
  26128. position: "absolute",
  26129. width: "inherit",
  26130. height: "inherit",
  26131. top: 0,
  26132. left: 0,
  26133. bottom: 0,
  26134. right: 0,
  26135. padding: 1,
  26136. borderRadius: "50%",
  26137. background: theme.color.positive,
  26138. color: theme.background.content,
  26139. opacity: visible ? 1 : 0,
  26140. transform: visible ? "scale(1)" : "scale(0.7)",
  26141. transition: "all var(--transition-duration, 0.2s)"
  26142. })
  26143. ), Skipped = styled.span(({ theme, visible }) => ({
  26144. display: "flex",
  26145. alignItems: "center",
  26146. color: theme.textMutedColor,
  26147. fontSize: "12px",
  26148. fontWeight: "bold",
  26149. overflow: "hidden",
  26150. padding: visible ? "0 10px" : 0,
  26151. opacity: visible ? 1 : 0,
  26152. width: visible ? "auto" : 0,
  26153. height: visible ? 18 : 16,
  26154. transition: "all var(--transition-duration, 0.2s)"
  26155. })), Actions3 = styled.div({
  26156. alignSelf: "flex-end",
  26157. flexDirection: "row-reverse",
  26158. display: "flex",
  26159. gap: 4
  26160. }), ToggleButton2 = styled(Button)({
  26161. opacity: "var(--toggle-button-opacity)",
  26162. transition: "opacity var(--transition-duration, 0.2s)",
  26163. "&:hover, &:focus": {
  26164. opacity: 1
  26165. },
  26166. svg: {
  26167. transform: "rotate(var(--toggle-button-rotate))",
  26168. transition: "transform var(--transition-duration, 0.2s)"
  26169. }
  26170. }), ChecklistCopyButton = ({
  26171. label,
  26172. copyContent,
  26173. onClick
  26174. }) => {
  26175. let { children: copyChildren, buttonProps: copyButtonProps } = useCopyButton({
  26176. children: label,
  26177. onCopy: onClick,
  26178. content: copyContent
  26179. });
  26180. return react_default.createElement(Button, { variant: "solid", size: "small", ...copyButtonProps }, copyChildren);
  26181. }, Checklist = ({
  26182. availableItems,
  26183. accept,
  26184. skip,
  26185. reset,
  26186. forceCollapsed = !1
  26187. }) => {
  26188. let api = useStorybookApi(), locationHash = useLocationHash(), { itemsById, sectionsById } = useMemo(
  26189. () => availableItems.reduce(
  26190. (acc, item) => {
  26191. acc.itemsById[item.id] = item;
  26192. let { sectionId: id, sectionTitle: title2 } = item;
  26193. return acc.sectionsById[id] = acc.sectionsById[id] ?? { id, title: title2, itemIds: [] }, acc.sectionsById[id].itemIds.push(item.id), acc;
  26194. },
  26195. { itemsById: {}, sectionsById: {} }
  26196. ),
  26197. [availableItems]
  26198. ), sections = useMemo(
  26199. () => Object.values(sectionsById).map(({ id, title: title2, itemIds }) => {
  26200. 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;
  26201. return { id, title: title2, items, progress };
  26202. }),
  26203. [itemsById, sectionsById]
  26204. );
  26205. return react_default.createElement(Sections, null, sections.map(({ id, title: title2, items, progress }) => {
  26206. let collapsed = forceCollapsed || progress === 100 && items.every((item) => item.id !== locationHash);
  26207. return react_default.createElement("li", { key: id }, react_default.createElement(Focus.Proxy, { targetId: `toggle-${id}` }, react_default.createElement(
  26208. Collapsible,
  26209. {
  26210. collapsed,
  26211. summary: ({ isCollapsed, toggleCollapsed, toggleProps }) => react_default.createElement(
  26212. SectionSummary,
  26213. {
  26214. progress,
  26215. isCollapsed,
  26216. onClick: toggleCollapsed
  26217. },
  26218. react_default.createElement(StatusIcon3, null, react_default.createElement(Checked2, { "data-visible": progress === 100 })),
  26219. react_default.createElement(SectionHeading, null, title2),
  26220. react_default.createElement(Actions3, null, react_default.createElement(
  26221. ToggleButton2,
  26222. {
  26223. ...toggleProps,
  26224. "data-target-id": `toggle-${id}`,
  26225. variant: "ghost",
  26226. padding: "small",
  26227. "aria-label": title2
  26228. },
  26229. react_default.createElement(ChevronSmallDownIcon, null)
  26230. ))
  26231. )
  26232. },
  26233. react_default.createElement(Items, null, items.map(
  26234. ({
  26235. content,
  26236. isOpen,
  26237. isAccepted,
  26238. isDone,
  26239. isLockedBy,
  26240. isImmutable,
  26241. isSkipped,
  26242. ...item
  26243. }) => {
  26244. let isChecked = isAccepted || isDone, isCollapsed = item.id !== locationHash, isLocked = !!isLockedBy, itemContent = content?.({ api });
  26245. return react_default.createElement(ActionList.Item, { key: item.id }, react_default.createElement(
  26246. Focus.Target,
  26247. {
  26248. targetHash: item.id,
  26249. highlightDuration: 2e3,
  26250. outlineOffset: -2
  26251. },
  26252. react_default.createElement(Focus.Proxy, { targetId: `toggle-${item.id}`, outlineOffset: -2 }, react_default.createElement(
  26253. Collapsible,
  26254. {
  26255. collapsed: isCollapsed,
  26256. summary: ({ isCollapsed: isCollapsed2, toggleCollapsed, toggleProps }) => react_default.createElement(
  26257. ItemSummary,
  26258. {
  26259. isCollapsed: isCollapsed2 || !itemContent,
  26260. onClick: itemContent ? toggleCollapsed : void 0
  26261. },
  26262. react_default.createElement(StatusIcon3, null, react_default.createElement(Checked2, { "data-visible": isChecked }), react_default.createElement(Skipped, { visible: isSkipped }, "Skipped")),
  26263. react_default.createElement(ItemHeading, { skipped: isSkipped }, item.label),
  26264. react_default.createElement(Actions3, null, itemContent && react_default.createElement(
  26265. ToggleButton2,
  26266. {
  26267. ...toggleProps,
  26268. "data-target-id": `toggle-${item.id}`,
  26269. variant: "ghost",
  26270. padding: "small",
  26271. ariaLabel: `${isCollapsed2 ? "Expand" : "Collapse"} ${item.label}`
  26272. },
  26273. react_default.createElement(ChevronSmallDownIcon, null)
  26274. ), isLocked && react_default.createElement(
  26275. Button,
  26276. {
  26277. variant: "ghost",
  26278. padding: "small",
  26279. ariaLabel: "Locked",
  26280. tooltip: `Complete \u201C${itemsById[isLockedBy].label}\u201D first`,
  26281. disabled: !0,
  26282. readOnly: !0
  26283. },
  26284. react_default.createElement(LockIcon, null)
  26285. ), isOpen && !isLocked && item.action && (item.action.copyContent ? react_default.createElement(
  26286. ChecklistCopyButton,
  26287. {
  26288. label: item.action.label,
  26289. copyContent: item.action.copyContent,
  26290. onClick: () => item.action.onClick({
  26291. api,
  26292. accept: () => accept(item.id)
  26293. })
  26294. }
  26295. ) : react_default.createElement(
  26296. Button,
  26297. {
  26298. ariaLabel: !1,
  26299. variant: "solid",
  26300. size: "small",
  26301. onClick: (e2) => {
  26302. e2.stopPropagation(), item.action?.onClick({
  26303. api,
  26304. accept: () => accept(item.id)
  26305. });
  26306. }
  26307. },
  26308. item.action.label
  26309. )), isOpen && !isLocked && !item.action && !item.subscribe && react_default.createElement(
  26310. Button,
  26311. {
  26312. ariaLabel: !1,
  26313. variant: "outline",
  26314. size: "small",
  26315. onClick: (e2) => {
  26316. e2.stopPropagation(), accept(item.id);
  26317. }
  26318. },
  26319. react_default.createElement(CheckIcon, null),
  26320. "Mark as complete"
  26321. ), isOpen && !isLocked && react_default.createElement(
  26322. Button,
  26323. {
  26324. ariaLabel: !1,
  26325. variant: "ghost",
  26326. size: "small",
  26327. onClick: (e2) => {
  26328. e2.stopPropagation(), skip(item.id);
  26329. }
  26330. },
  26331. "Skip"
  26332. ), (isAccepted && !isImmutable || isSkipped) && !isLocked && react_default.createElement(
  26333. Button,
  26334. {
  26335. ariaLabel: "Undo",
  26336. variant: "ghost",
  26337. padding: "small",
  26338. onClick: (e2) => {
  26339. e2.stopPropagation(), reset(item.id);
  26340. }
  26341. },
  26342. react_default.createElement(UndoIcon, null)
  26343. ))
  26344. )
  26345. },
  26346. itemContent && react_default.createElement(ItemContent2, null, itemContent)
  26347. ))
  26348. ));
  26349. }
  26350. ))
  26351. )));
  26352. }));
  26353. };
  26354. // src/manager/settings/Checklist/AiSetupBlock.tsx
  26355. init_react();
  26356. var AiCtaCard = styled.div(({ theme }) => ({
  26357. display: "flex",
  26358. flexDirection: "column",
  26359. padding: "10px 10px 10px 15px",
  26360. border: `1px solid ${theme.base === "dark" ? theme.color.darker : theme.color.border}`,
  26361. borderRadius: 8,
  26362. background: theme.background.content
  26363. })), AiCtaHeadingRow = styled.div({
  26364. display: "flex",
  26365. alignItems: "center",
  26366. gap: 10
  26367. }), AiCtaHeading = styled.h2(({ theme, $skipped }) => ({
  26368. flex: 1,
  26369. margin: 0,
  26370. color: $skipped ? theme.textMutedColor : theme.color.defaultText,
  26371. fontSize: theme.typography.size.s2,
  26372. fontWeight: theme.typography.weight.bold,
  26373. textWrap: "pretty"
  26374. })), AiCtaDescription = styled.p(({ theme }) => ({
  26375. margin: 0,
  26376. color: theme.color.defaultText,
  26377. fontSize: theme.typography.size.s2,
  26378. fontWeight: theme.typography.weight.regular,
  26379. marginTop: 8
  26380. })), AiCtaActions = styled.div({
  26381. display: "flex",
  26382. gap: 8,
  26383. justifyContent: "flex-end",
  26384. marginTop: 12
  26385. }), CopyButton2 = ({ api }) => {
  26386. let { children: buttonChildren, buttonProps } = useCopyButton({
  26387. children: "Copy prompt",
  26388. childrenOnCopy: react_default.createElement(react_default.Fragment, null, react_default.createElement(CheckIcon, null), " Copied!"),
  26389. content: getAiSetupPrompt(),
  26390. onCopy: () => {
  26391. api.emit(AI_PROMPT_NUDGE, { id: "setup", origin: "onboarding-guide-page" });
  26392. }
  26393. });
  26394. return react_default.createElement(Button, { variant: "solid", size: "medium", ...buttonProps }, buttonChildren);
  26395. }, AiSetupBlock = ({
  26396. item,
  26397. reset,
  26398. skip
  26399. }) => {
  26400. let api = useStorybookApi();
  26401. 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;
  26402. };
  26403. // src/manager/settings/GuidePage.tsx
  26404. var Container13 = styled.div(({ theme }) => ({
  26405. display: "flex",
  26406. flexDirection: "column",
  26407. maxWidth: 600,
  26408. margin: "0 auto",
  26409. padding: "48px 20px",
  26410. gap: 32,
  26411. fontSize: theme.typography.size.s2,
  26412. "--transition-duration": "0.2s"
  26413. })), Intro = styled.div(({ theme }) => ({
  26414. display: "flex",
  26415. flexDirection: "column",
  26416. gap: 8,
  26417. "& h1": {
  26418. fontSize: theme.typography.size.m3,
  26419. fontWeight: theme.typography.weight.bold,
  26420. margin: 0
  26421. },
  26422. "& > p": {
  26423. margin: 0
  26424. }
  26425. })), GuidePage = () => {
  26426. let checklist = useChecklist(), aiSetupItem = checklist.availableItems.find((item) => item.id === "aiSetup");
  26427. 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"))));
  26428. };
  26429. // src/manager/settings/ShortcutsPage.tsx
  26430. init_react();
  26431. // src/manager/settings/shortcuts.tsx
  26432. init_react();
  26433. // src/manager/settings/SettingsFooter.tsx
  26434. init_react();
  26435. var Footer2 = styled.div(({ theme }) => ({
  26436. display: "flex",
  26437. paddingTop: 20,
  26438. marginTop: 20,
  26439. borderTop: `1px solid ${theme.appBorderColor}`,
  26440. fontWeight: theme.typography.weight.bold,
  26441. "& > * + *": {
  26442. marginLeft: 20
  26443. }
  26444. })), 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(
  26445. Link,
  26446. {
  26447. secondary: !0,
  26448. href: "https://storybook.js.org/community?ref=ui#support",
  26449. cancel: !1,
  26450. target: "_blank"
  26451. },
  26452. "Support"
  26453. )), SettingsFooter_default = SettingsFooter;
  26454. // src/manager/settings/shortcuts.tsx
  26455. var Header2 = styled.header(({ theme }) => ({
  26456. marginBottom: 20,
  26457. fontSize: theme.typography.size.m3,
  26458. fontWeight: theme.typography.weight.bold,
  26459. alignItems: "center",
  26460. display: "flex"
  26461. })), HeaderItem = styled.div(({ theme }) => ({
  26462. fontWeight: theme.typography.weight.bold
  26463. })), GridHeaderRow = styled.div({
  26464. alignSelf: "flex-end",
  26465. display: "grid",
  26466. margin: "10px 0",
  26467. gridTemplateColumns: "1fr 1fr 12px",
  26468. "& > *:last-of-type": {
  26469. gridColumn: "2 / 2",
  26470. justifySelf: "flex-end",
  26471. gridRow: "1"
  26472. }
  26473. }), Row = styled.div(({ theme }) => ({
  26474. padding: "6px 0",
  26475. borderTop: `1px solid ${theme.appBorderColor}`,
  26476. display: "grid",
  26477. gridTemplateColumns: "1fr 1fr 0px"
  26478. })), GridWrapper = styled.div({
  26479. display: "grid",
  26480. gridTemplateColumns: "1fr",
  26481. gridAutoRows: "minmax(auto, auto)",
  26482. marginBottom: 20
  26483. }), Description = styled.div({
  26484. alignSelf: "center"
  26485. }), TextInput = styled(Form.Input)(
  26486. ({ valid, theme }) => valid === "error" ? {
  26487. animation: `${theme.animation.jiggle} 700ms ease-out`
  26488. } : {},
  26489. {
  26490. display: "flex",
  26491. width: 80,
  26492. flexDirection: "column",
  26493. justifySelf: "flex-end",
  26494. paddingLeft: 4,
  26495. paddingRight: 4,
  26496. textAlign: "center"
  26497. }
  26498. ), Fade = keyframes`
  26499. 0%,100% { opacity: 0; }
  26500. 50% { opacity: 1; }
  26501. `, SuccessIcon = styled(CheckIcon)(
  26502. ({ valid, theme }) => valid === "valid" ? {
  26503. color: theme.color.positive,
  26504. animation: `${Fade} 2s ease forwards`
  26505. } : {
  26506. opacity: 0
  26507. },
  26508. {
  26509. alignSelf: "center",
  26510. display: "flex",
  26511. marginLeft: 10,
  26512. height: 14,
  26513. width: 14
  26514. }
  26515. ), Container14 = styled.div(({ theme }) => ({
  26516. fontSize: theme.typography.size.s2,
  26517. padding: "3rem 20px",
  26518. maxWidth: 600,
  26519. margin: "0 auto"
  26520. })), shortcutLabels = {
  26521. fullScreen: "Go full screen",
  26522. togglePanel: "Toggle addons",
  26523. panelPosition: "Toggle addons orientation",
  26524. toggleNav: "Toggle sidebar",
  26525. toolbar: "Toggle toolbar",
  26526. search: "Focus search",
  26527. focusNav: "Focus sidebar",
  26528. focusIframe: "Focus canvas",
  26529. focusPanel: "Focus addons",
  26530. prevComponent: "Previous component",
  26531. nextComponent: "Next component",
  26532. prevStory: "Previous story",
  26533. nextStory: "Next story",
  26534. shortcutsPage: "Go to shortcuts page",
  26535. aboutPage: "Go to about page",
  26536. collapseAll: "Collapse all items on sidebar",
  26537. expandAll: "Expand all items on sidebar",
  26538. remount: "Reload story",
  26539. openInEditor: "Open story in editor",
  26540. openInIsolation: "Open story in isolation",
  26541. copyStoryLink: "Copy story link to clipboard",
  26542. goToPreviousLandmark: "Go to previous landmark",
  26543. goToNextLandmark: "Go to next landmark"
  26544. // TODO: bring this back once we want to add shortcuts for this
  26545. // copyStoryName: 'Copy story name to clipboard',
  26546. }, fixedShortcuts = ["escape"], hardcodedShortcuts = ["goToPreviousLandmark", "goToNextLandmark"];
  26547. function toShortcutState(shortcutKeys) {
  26548. let state = {};
  26549. for (let key of Object.keys(shortcutKeys).filter((k2) => !fixedShortcuts.includes(k2)))
  26550. state[key] = {
  26551. shortcut: shortcutKeys[key],
  26552. error: !1,
  26553. hardcoded: hardcodedShortcuts.includes(key)
  26554. };
  26555. return state;
  26556. }
  26557. var ShortcutsScreen = class extends Component {
  26558. constructor(props) {
  26559. super(props);
  26560. this.onKeyDown = (e2) => {
  26561. let { activeFeature, shortcutKeys } = this.state;
  26562. if (e2.key === "Backspace")
  26563. return this.restoreDefault();
  26564. let shortcut = eventToShortcut(e2);
  26565. if (!shortcut)
  26566. return !1;
  26567. let normalizedShortcut = shortcut.map(
  26568. (key) => Array.isArray(key) ? key.at(-1) : key
  26569. ), error = !!Object.entries(shortcutKeys).find(
  26570. ([feature, { shortcut: existingShortcut }]) => feature !== activeFeature && existingShortcut && shortcutMatchesShortcut(normalizedShortcut, existingShortcut)
  26571. );
  26572. return this.setState({
  26573. shortcutKeys: { ...shortcutKeys, [activeFeature]: { shortcut: normalizedShortcut, error } }
  26574. });
  26575. };
  26576. this.onFocus = (focusedInput) => () => {
  26577. let { shortcutKeys } = this.state;
  26578. this.setState({
  26579. activeFeature: focusedInput,
  26580. shortcutKeys: {
  26581. ...shortcutKeys,
  26582. [focusedInput]: { shortcut: null, error: !1 }
  26583. }
  26584. });
  26585. };
  26586. this.onBlur = async () => {
  26587. let { shortcutKeys, activeFeature } = this.state;
  26588. if (shortcutKeys[activeFeature]) {
  26589. let { shortcut, error } = shortcutKeys[activeFeature];
  26590. return !shortcut || error ? this.restoreDefault() : this.saveShortcut();
  26591. }
  26592. return !1;
  26593. };
  26594. this.saveShortcut = async () => {
  26595. let { activeFeature, shortcutKeys } = this.state, { setShortcut } = this.props;
  26596. await setShortcut(activeFeature, shortcutKeys[activeFeature].shortcut), this.setState({ successField: activeFeature });
  26597. };
  26598. this.restoreDefaults = async () => {
  26599. let { restoreAllDefaultShortcuts } = this.props, defaultShortcuts = await restoreAllDefaultShortcuts();
  26600. return this.setState({ shortcutKeys: toShortcutState(defaultShortcuts) });
  26601. };
  26602. this.restoreDefault = async () => {
  26603. let { activeFeature, shortcutKeys } = this.state, { restoreDefaultShortcut } = this.props, defaultShortcut = await restoreDefaultShortcut(activeFeature);
  26604. return this.setState({
  26605. shortcutKeys: {
  26606. ...shortcutKeys,
  26607. ...toShortcutState({ [activeFeature]: defaultShortcut })
  26608. }
  26609. });
  26610. };
  26611. this.displaySuccessMessage = (activeElement) => {
  26612. let { successField, shortcutKeys } = this.state;
  26613. return activeElement === successField && shortcutKeys[activeElement].error === !1 ? "valid" : void 0;
  26614. };
  26615. this.displayError = (activeElement) => {
  26616. let { activeFeature, shortcutKeys } = this.state;
  26617. return activeElement === activeFeature && shortcutKeys[activeElement].error === !0 ? "error" : void 0;
  26618. };
  26619. this.renderKeyInput = () => {
  26620. let { shortcutKeys, addonsShortcutLabels } = this.state;
  26621. return Object.entries(shortcutKeys).filter(
  26622. ([feature]) => shortcutLabels[feature] !== void 0 || addonsShortcutLabels && addonsShortcutLabels[feature]
  26623. ).map(
  26624. ([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(
  26625. TooltipProvider,
  26626. {
  26627. tooltip: react_default.createElement(Tooltip, { hasChrome: !0 }, "This shortcut cannot be changed."),
  26628. placement: "right"
  26629. },
  26630. react_default.createElement(
  26631. TextInput,
  26632. {
  26633. "aria-disabled": !0,
  26634. readOnly: !0,
  26635. valid: void 0,
  26636. value: shortcut ? shortcutToHumanString(shortcut) : ""
  26637. }
  26638. )
  26639. )) : react_default.createElement(
  26640. TextInput,
  26641. {
  26642. spellCheck: "false",
  26643. valid: this.displayError(feature),
  26644. className: "modalInput",
  26645. onBlur: this.onBlur,
  26646. onFocus: this.onFocus(feature),
  26647. onKeyDown: this.onKeyDown,
  26648. value: shortcut ? shortcutToHumanString(shortcut) : "",
  26649. placeholder: "Type keys",
  26650. readOnly: !0
  26651. }
  26652. ), react_default.createElement(SuccessIcon, { valid: this.displaySuccessMessage(feature) }))
  26653. );
  26654. };
  26655. 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());
  26656. this.state = {
  26657. // @ts-expect-error (non strict)
  26658. activeFeature: void 0,
  26659. // @ts-expect-error (non strict)
  26660. successField: void 0,
  26661. // The initial shortcutKeys that come from props are the defaults/what was saved
  26662. // As the user interacts with the page, the state stores the temporary, unsaved shortcuts
  26663. // This object also includes the error attached to each shortcut
  26664. shortcutKeys: toShortcutState(props.shortcutKeys),
  26665. addonsShortcutLabels: props.addonsShortcutLabels
  26666. };
  26667. }
  26668. render() {
  26669. let layout = this.renderKeyForm();
  26670. return react_default.createElement(Container14, null, react_default.createElement(Header2, null, "Keyboard shortcuts"), layout, react_default.createElement(
  26671. Button,
  26672. {
  26673. ariaLabel: !1,
  26674. variant: "outline",
  26675. size: "small",
  26676. id: "restoreDefaultsHotkeys",
  26677. onClick: this.restoreDefaults
  26678. },
  26679. "Restore defaults"
  26680. ), react_default.createElement(SettingsFooter_default, null));
  26681. }
  26682. };
  26683. // src/manager/settings/ShortcutsPage.tsx
  26684. var ShortcutsPage = () => react_default.createElement(Consumer, null, ({
  26685. api: {
  26686. getShortcutKeys,
  26687. getAddonsShortcutLabels,
  26688. setShortcut,
  26689. restoreDefaultShortcut,
  26690. restoreAllDefaultShortcuts
  26691. }
  26692. }) => react_default.createElement(
  26693. ShortcutsScreen,
  26694. {
  26695. shortcutKeys: getShortcutKeys(),
  26696. addonsShortcutLabels: getAddonsShortcutLabels(),
  26697. setShortcut,
  26698. restoreDefaultShortcut,
  26699. restoreAllDefaultShortcuts
  26700. }
  26701. ));
  26702. // src/manager/settings/whats_new_page.tsx
  26703. init_react();
  26704. // src/manager/settings/whats_new.tsx
  26705. init_react();
  26706. var Centered = styled.div({
  26707. top: "50%",
  26708. position: "absolute",
  26709. transform: "translateY(-50%)",
  26710. width: "100%",
  26711. textAlign: "center"
  26712. }), LoaderWrapper2 = styled.div({
  26713. position: "relative",
  26714. height: "32px"
  26715. }), Message2 = styled.div(({ theme }) => ({
  26716. paddingTop: "12px",
  26717. color: theme.textMutedColor,
  26718. maxWidth: "295px",
  26719. margin: "0 auto",
  26720. fontSize: `${theme.typography.size.s1}px`,
  26721. lineHeight: "16px"
  26722. })), Container15 = styled.div(({ theme }) => ({
  26723. position: "absolute",
  26724. width: "100%",
  26725. height: 40,
  26726. bottom: 0,
  26727. background: theme.background.bar,
  26728. fontSize: theme.typography.size.s2,
  26729. borderTop: `1px solid ${theme.color.border}`,
  26730. padding: "0 10px 0 15px",
  26731. display: "flex",
  26732. alignItems: "center",
  26733. justifyContent: "space-between"
  26734. })), WhatsNewFooter = ({
  26735. isNotificationsEnabled,
  26736. onToggleNotifications,
  26737. copyContent
  26738. }) => {
  26739. let theme = useTheme(), { children: copyText, buttonProps: copyButtonProps } = useCopyButton({
  26740. children: "Copy Link",
  26741. content: copyContent
  26742. });
  26743. 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"));
  26744. }, Iframe = styled.iframe(
  26745. {
  26746. position: "absolute",
  26747. top: 0,
  26748. left: 0,
  26749. right: 0,
  26750. bottom: 0,
  26751. border: 0,
  26752. margin: 0,
  26753. padding: 0,
  26754. width: "100%",
  26755. height: "calc(100% - 40px)",
  26756. background: "white"
  26757. },
  26758. ({ isLoaded }) => ({ visibility: isLoaded ? "visible" : "hidden" })
  26759. ), AlertIcon2 = styled(((props) => react_default.createElement(AlertIcon, { ...props })))(({ theme }) => ({
  26760. color: theme.textMutedColor,
  26761. width: 32,
  26762. height: 32,
  26763. margin: "0 auto"
  26764. })), 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 = ({
  26765. didHitMaxWaitTime,
  26766. isLoaded,
  26767. onLoad,
  26768. url,
  26769. copyContent,
  26770. onToggleNotifications,
  26771. isNotificationsEnabled
  26772. }) => 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(
  26773. WhatsNewFooter,
  26774. {
  26775. isNotificationsEnabled,
  26776. onToggleNotifications,
  26777. copyContent
  26778. }
  26779. ))), MAX_WAIT_TIME = 1e4, WhatsNewScreen = () => {
  26780. let api = useStorybookApi(), state = useStorybookState(), { whatsNewData } = state, [isLoaded, setLoaded] = useState(!1), [didHitMaxWaitTime, setDidHitMaxWaitTime] = useState(!1);
  26781. if (useEffect(() => {
  26782. let timer = setTimeout(() => !isLoaded && setDidHitMaxWaitTime(!0), MAX_WAIT_TIME);
  26783. return () => clearTimeout(timer);
  26784. }, [isLoaded]), whatsNewData?.status !== "SUCCESS")
  26785. return null;
  26786. let isNotificationsEnabled = !whatsNewData.disableWhatsNewNotifications;
  26787. return react_default.createElement(
  26788. PureWhatsNewScreen,
  26789. {
  26790. didHitMaxWaitTime,
  26791. isLoaded,
  26792. onLoad: () => {
  26793. api.whatsNewHasBeenRead(), setLoaded(!0);
  26794. },
  26795. url: whatsNewData.url,
  26796. isNotificationsEnabled,
  26797. copyContent: whatsNewData.blogUrl ?? whatsNewData.url,
  26798. onToggleNotifications: () => {
  26799. isNotificationsEnabled ? scope.confirm("All update notifications will no longer be shown. Are you sure?") && api.toggleWhatsNewNotifications() : api.toggleWhatsNewNotifications();
  26800. }
  26801. }
  26802. );
  26803. };
  26804. // src/manager/settings/whats_new_page.tsx
  26805. var WhatsNewPage = () => react_default.createElement(WhatsNewScreen, null);
  26806. // src/manager/settings/index.tsx
  26807. var { document: document9 } = scope, Content5 = styled(ScrollArea)(({ theme }) => ({
  26808. background: theme.background.content
  26809. })), SidebarToggle = styled.div({
  26810. // Extra specificity is necessary here
  26811. "&&:has(*)": {
  26812. order: 0,
  26813. display: "flex",
  26814. alignItems: "center",
  26815. marginLeft: 10,
  26816. marginRight: 6,
  26817. gap: 6
  26818. }
  26819. }), RouteWrapper = ({ children, path }) => react_default.createElement(Content5, { vertical: !0, horizontal: !1 }, react_default.createElement(Route, { path }, children)), Pages = ({ changeTab, onClose, enableShortcuts = !0, enableWhatsNew }) => {
  26820. react_default.useEffect(() => {
  26821. let handleEscape = (event) => {
  26822. !enableShortcuts || event.repeat || matchesModifiers(!1, event) && matchesKeyCode("Escape", event) && (event.preventDefault(), onClose());
  26823. };
  26824. return document9.addEventListener("keydown", handleEscape), () => document9.removeEventListener("keydown", handleEscape);
  26825. }, [enableShortcuts, onClose]);
  26826. let api = useStorybookApi(), toolsExtra = Object.values(api.getElements(Addon_TypesEnum.TOOLEXTRA)), tabs = useMemo(() => {
  26827. let tabsToInclude = [
  26828. {
  26829. id: "about",
  26830. title: "About",
  26831. children: react_default.createElement(RouteWrapper, { path: "about" }, react_default.createElement(AboutPage, { key: "about" }))
  26832. }
  26833. ];
  26834. return scope.CONFIG_TYPE === "DEVELOPMENT" && tabsToInclude.push({
  26835. id: "guide",
  26836. title: "Guide",
  26837. children: react_default.createElement(RouteWrapper, { path: "guide" }, react_default.createElement(GuidePage, { key: "guide" }))
  26838. }), tabsToInclude.push({
  26839. id: "shortcuts",
  26840. title: "Keyboard shortcuts",
  26841. children: react_default.createElement(RouteWrapper, { path: "shortcuts" }, react_default.createElement(ShortcutsPage, { key: "shortcuts" }))
  26842. }), enableWhatsNew && tabsToInclude.push({
  26843. id: "whats-new",
  26844. title: "What's new?",
  26845. children: react_default.createElement(RouteWrapper, { path: "whats-new" }, react_default.createElement(WhatsNewPage, { key: "whats-new" }))
  26846. }), tabsToInclude;
  26847. }, [enableWhatsNew]);
  26848. return react_default.createElement(Location, null, ({ path }) => {
  26849. let selected = tabs.find((tab) => path.includes(`settings/${tab.id}`))?.id;
  26850. return react_default.createElement(
  26851. TabsView,
  26852. {
  26853. tabs,
  26854. 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(
  26855. Button,
  26856. {
  26857. padding: "small",
  26858. variant: "ghost",
  26859. onClick: (e2) => (e2.preventDefault(), onClose()),
  26860. ariaLabel: "Close settings page"
  26861. },
  26862. react_default.createElement(CloseIcon, null)
  26863. )),
  26864. selected,
  26865. onSelectionChange: changeTab
  26866. }
  26867. );
  26868. });
  26869. }, SettingsPages = () => {
  26870. let api = useStorybookApi(), state = useStorybookState(), changeTab = (tab) => api.changeSettingsTab(tab);
  26871. return react_default.createElement(
  26872. Pages,
  26873. {
  26874. enableWhatsNew: state.whatsNewData?.status === "SUCCESS",
  26875. enableShortcuts: state.ui.enableShortcuts,
  26876. changeTab,
  26877. onClose: api.closeSettings
  26878. }
  26879. );
  26880. }, settingsPageAddon = {
  26881. id: "settings",
  26882. url: "/settings/",
  26883. title: "Settings",
  26884. type: types.experimental_PAGE,
  26885. render: () => react_default.createElement(Route, { path: "/settings/", startsWith: !0 }, react_default.createElement(SettingsPages, null))
  26886. };
  26887. // src/manager/index.tsx
  26888. ThemeProvider.displayName = "ThemeProvider";
  26889. q.displayName = "HelmetProvider";
  26890. var Root3 = ({ provider }) => react_default.createElement(q, { key: "helmet.Provider" }, react_default.createElement(LocationProvider, { key: "location.provider" }, react_default.createElement(Main, { provider }))), Main = ({ provider }) => {
  26891. let navigate = useNavigate();
  26892. return react_default.createElement(Location, { key: "location.consumer" }, (locationData) => react_default.createElement(
  26893. Provider,
  26894. {
  26895. key: "manager",
  26896. provider,
  26897. ...locationData,
  26898. navigate,
  26899. docsOptions: scope?.DOCS_OPTIONS || {}
  26900. },
  26901. (combo) => {
  26902. let { state, api } = combo, setManagerLayoutState = useCallback(
  26903. (sizes) => {
  26904. api.setSizes(sizes);
  26905. },
  26906. [api]
  26907. ), pages = useMemo(
  26908. () => [settingsPageAddon, ...Object.values(api.getElements(types.experimental_PAGE))],
  26909. [Object.keys(api.getElements(types.experimental_PAGE)).join()]
  26910. );
  26911. return react_default.createElement(ThemeProvider, { key: "theme.provider", theme: ensure(state.theme) }, react_default.createElement(LayoutProvider, null, react_default.createElement(
  26912. App,
  26913. {
  26914. key: "app",
  26915. pages,
  26916. managerLayoutState: {
  26917. ...state.layout,
  26918. viewMode: state.viewMode
  26919. },
  26920. hasTab: !!api.getQueryParam("tab"),
  26921. setManagerLayoutState
  26922. }
  26923. )));
  26924. }
  26925. ));
  26926. };
  26927. function renderStorybookUI(domNode, provider) {
  26928. if (!(provider instanceof Provider2))
  26929. throw new ProviderDoesNotExtendBaseProviderError();
  26930. createRoot(domNode).render(react_default.createElement(Root3, { key: "root", provider }));
  26931. }
  26932. // src/manager/runtime.tsx
  26933. var WS_DISCONNECTED_NOTIFICATION_ID = "CORE/WS_DISCONNECTED";
  26934. addons.register(
  26935. TOOLBAR_ID,
  26936. () => addons.add(TOOLBAR_ID, {
  26937. title: TOOLBAR_ID,
  26938. type: types.TOOL,
  26939. match: ({ tabId }) => !tabId,
  26940. render: () => react_default.createElement(ToolbarManager, null)
  26941. })
  26942. );
  26943. var ReactProvider = class extends Provider2 {
  26944. constructor() {
  26945. super();
  26946. this.wsDisconnected = !1;
  26947. let channel = createBrowserChannel({ page: "manager" });
  26948. addons.setChannel(channel), channel.emit(CHANNEL_CREATED), this.addons = addons, this.channel = channel, scope.__STORYBOOK_ADDONS_CHANNEL__ = channel;
  26949. }
  26950. getElements(type) {
  26951. return this.addons.getElements(type);
  26952. }
  26953. getConfig() {
  26954. return this.addons.getConfig();
  26955. }
  26956. handleAPI(api) {
  26957. this.addons.loadAddons(api), this.channel.on(CHANNEL_WS_DISCONNECT, (ev) => {
  26958. this.wsDisconnected = !0, api.addNotification({
  26959. id: WS_DISCONNECTED_NOTIFICATION_ID,
  26960. content: {
  26961. headline: ev.code === 3008 ? "Server timed out" : "Connection lost",
  26962. subHeadline: "Please restart your Storybook server and reload the page"
  26963. },
  26964. icon: react_default.createElement(FailedIcon, { color: color.negative }),
  26965. link: void 0
  26966. });
  26967. });
  26968. }
  26969. }, { document: document10 } = scope, rootEl = document10.getElementById("root");
  26970. setTimeout(() => {
  26971. renderStorybookUI(rootEl, new ReactProvider());
  26972. }, 0);