@seeqdev/qomponents 0.0.115 → 0.0.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +135 -135
  2. package/dist/Accordion/Accordion.js +9 -0
  3. package/dist/Accordion/Accordion.js.map +1 -0
  4. package/dist/Accordion/Accordion.stories.js +115 -0
  5. package/dist/Accordion/Accordion.stories.js.map +1 -0
  6. package/dist/Accordion/Accordion.test.js +55 -0
  7. package/dist/Accordion/Accordion.test.js.map +1 -0
  8. package/dist/Accordion/Accordion.types.js +2 -0
  9. package/dist/Accordion/Accordion.types.js.map +1 -0
  10. package/dist/Accordion/index.js +2 -0
  11. package/dist/Accordion/index.js.map +1 -0
  12. package/dist/Alert/Alert.js +34 -0
  13. package/dist/Alert/Alert.js.map +1 -0
  14. package/dist/Alert/Alert.stories.js +52 -0
  15. package/dist/Alert/Alert.stories.js.map +1 -0
  16. package/dist/Alert/Alert.test.js +51 -0
  17. package/dist/Alert/Alert.test.js.map +1 -0
  18. package/dist/Alert/Alert.types.js +2 -0
  19. package/dist/Alert/Alert.types.js.map +1 -0
  20. package/dist/Alert/index.js +2 -0
  21. package/dist/Alert/index.js.map +1 -0
  22. package/dist/Button/Button.js +92 -0
  23. package/dist/Button/Button.js.map +1 -0
  24. package/dist/Button/Button.stories.js +100 -0
  25. package/dist/Button/Button.stories.js.map +1 -0
  26. package/dist/Button/Button.test.js +49 -0
  27. package/dist/Button/Button.test.js.map +1 -0
  28. package/dist/Button/Button.types.js +5 -0
  29. package/dist/Button/Button.types.js.map +1 -0
  30. package/dist/Button/index.js +2 -0
  31. package/dist/Button/index.js.map +1 -0
  32. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +67 -0
  33. package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  34. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +98 -0
  35. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
  36. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +85 -0
  37. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
  38. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
  39. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
  40. package/dist/ButtonWithDropdown/index.js +2 -0
  41. package/dist/ButtonWithDropdown/index.js.map +1 -0
  42. package/dist/ButtonWithPopover/ButtonWithPopover.js +53 -0
  43. package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
  44. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +75 -0
  45. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
  46. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +82 -0
  47. package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
  48. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
  49. package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
  50. package/dist/ButtonWithPopover/index.js +2 -0
  51. package/dist/ButtonWithPopover/index.js.map +1 -0
  52. package/dist/Checkbox/Checkbox.js +26 -0
  53. package/dist/Checkbox/Checkbox.js.map +1 -0
  54. package/dist/Checkbox/Checkbox.stories.js +34 -0
  55. package/dist/Checkbox/Checkbox.stories.js.map +1 -0
  56. package/dist/Checkbox/Checkbox.test.js +94 -0
  57. package/dist/Checkbox/Checkbox.test.js.map +1 -0
  58. package/dist/Checkbox/Checkbox.types.js +2 -0
  59. package/dist/Checkbox/Checkbox.types.js.map +1 -0
  60. package/dist/Checkbox/index.js +2 -0
  61. package/dist/Checkbox/index.js.map +1 -0
  62. package/dist/Collapse/Collapse.d.ts +4 -0
  63. package/dist/Collapse/Collapse.js +18 -0
  64. package/dist/Collapse/Collapse.js.map +1 -0
  65. package/dist/Collapse/Collapse.stories.d.ts +5 -0
  66. package/dist/Collapse/Collapse.stories.js +37 -0
  67. package/dist/Collapse/Collapse.stories.js.map +1 -0
  68. package/dist/Collapse/Collapse.test.d.ts +1 -0
  69. package/dist/Collapse/Collapse.test.js +19 -0
  70. package/dist/Collapse/Collapse.test.js.map +1 -0
  71. package/dist/Collapse/Collapse.types.d.ts +4 -0
  72. package/dist/Collapse/Collapse.types.js +2 -0
  73. package/dist/Collapse/Collapse.types.js.map +1 -0
  74. package/dist/Collapse/index.d.ts +1 -0
  75. package/dist/Collapse/index.js +2 -0
  76. package/dist/Collapse/index.js.map +1 -0
  77. package/dist/Icon/Icon.js +55 -0
  78. package/dist/Icon/Icon.js.map +1 -0
  79. package/dist/Icon/Icon.stories.js +50 -0
  80. package/dist/Icon/Icon.stories.js.map +1 -0
  81. package/dist/Icon/Icon.test.js +55 -0
  82. package/dist/Icon/Icon.test.js.map +1 -0
  83. package/dist/Icon/Icon.types.js +16 -0
  84. package/dist/Icon/Icon.types.js.map +1 -0
  85. package/dist/Icon/index.js +2 -0
  86. package/dist/Icon/index.js.map +1 -0
  87. package/dist/InputGroup/InputGroup.js +32 -0
  88. package/dist/InputGroup/InputGroup.js.map +1 -0
  89. package/dist/InputGroup/InputGroup.stories.js +168 -0
  90. package/dist/InputGroup/InputGroup.stories.js.map +1 -0
  91. package/dist/InputGroup/InputGroup.test.js +43 -0
  92. package/dist/InputGroup/InputGroup.test.js.map +1 -0
  93. package/dist/InputGroup/InputGroup.types.js +2 -0
  94. package/dist/InputGroup/InputGroup.types.js.map +1 -0
  95. package/dist/InputGroup/index.js +2 -0
  96. package/dist/InputGroup/index.js.map +1 -0
  97. package/dist/Modal/Modal.js +100 -0
  98. package/dist/Modal/Modal.js.map +1 -0
  99. package/dist/Modal/Modal.stories.js +127 -0
  100. package/dist/Modal/Modal.stories.js.map +1 -0
  101. package/dist/Modal/Modal.test.js +108 -0
  102. package/dist/Modal/Modal.test.js.map +1 -0
  103. package/dist/Modal/Modal.types.js +2 -0
  104. package/dist/Modal/Modal.types.js.map +1 -0
  105. package/dist/Modal/index.js +2 -0
  106. package/dist/Modal/index.js.map +1 -0
  107. package/dist/ProgressBar/ProgressBar.js +30 -0
  108. package/dist/ProgressBar/ProgressBar.js.map +1 -0
  109. package/dist/ProgressBar/ProgressBar.stories.js +73 -0
  110. package/dist/ProgressBar/ProgressBar.stories.js.map +1 -0
  111. package/dist/ProgressBar/ProgressBar.test.js +38 -0
  112. package/dist/ProgressBar/ProgressBar.test.js.map +1 -0
  113. package/dist/ProgressBar/ProgressBar.types.d.ts +22 -6
  114. package/dist/ProgressBar/ProgressBar.types.js +2 -0
  115. package/dist/ProgressBar/ProgressBar.types.js.map +1 -0
  116. package/dist/ProgressBar/index.js +2 -0
  117. package/dist/ProgressBar/index.js.map +1 -0
  118. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +48 -0
  119. package/dist/SeeqActionDropdown/SeeqActionDropdown.js.map +1 -0
  120. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +80 -0
  121. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js.map +1 -0
  122. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +73 -0
  123. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js.map +1 -0
  124. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +2 -0
  125. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js.map +1 -0
  126. package/dist/SeeqActionDropdown/index.js +2 -0
  127. package/dist/SeeqActionDropdown/index.js.map +1 -0
  128. package/dist/SeeqActionDropdown/variants.js +23 -0
  129. package/dist/SeeqActionDropdown/variants.js.map +1 -0
  130. package/dist/Select/Select.js +174 -0
  131. package/dist/Select/Select.js.map +1 -0
  132. package/dist/Select/Select.stories.js +80 -0
  133. package/dist/Select/Select.stories.js.map +1 -0
  134. package/dist/Select/Select.test.js +182 -0
  135. package/dist/Select/Select.test.js.map +1 -0
  136. package/dist/Select/Select.types.js +2 -0
  137. package/dist/Select/Select.types.js.map +1 -0
  138. package/dist/Select/index.js +3 -0
  139. package/dist/Select/index.js.map +1 -0
  140. package/dist/Slider/Slider.js +13 -0
  141. package/dist/Slider/Slider.js.map +1 -0
  142. package/dist/Slider/Slider.stories.js +58 -0
  143. package/dist/Slider/Slider.stories.js.map +1 -0
  144. package/dist/Slider/Slider.test.js +33 -0
  145. package/dist/Slider/Slider.test.js.map +1 -0
  146. package/dist/Slider/Slider.types.js +2 -0
  147. package/dist/Slider/Slider.types.js.map +1 -0
  148. package/dist/Slider/index.js +2 -0
  149. package/dist/Slider/index.js.map +1 -0
  150. package/dist/Tabs/Tabs.js +22 -0
  151. package/dist/Tabs/Tabs.js.map +1 -0
  152. package/dist/Tabs/Tabs.stories.js +91 -0
  153. package/dist/Tabs/Tabs.stories.js.map +1 -0
  154. package/dist/Tabs/Tabs.test.js +91 -0
  155. package/dist/Tabs/Tabs.test.js.map +1 -0
  156. package/dist/Tabs/Tabs.types.js +2 -0
  157. package/dist/Tabs/Tabs.types.js.map +1 -0
  158. package/dist/Tabs/index.js +2 -0
  159. package/dist/Tabs/index.js.map +1 -0
  160. package/dist/TextArea/TextArea.js +25 -0
  161. package/dist/TextArea/TextArea.js.map +1 -0
  162. package/dist/TextArea/TextArea.stories.js +46 -0
  163. package/dist/TextArea/TextArea.stories.js.map +1 -0
  164. package/dist/TextArea/TextArea.test.js +68 -0
  165. package/dist/TextArea/TextArea.test.js.map +1 -0
  166. package/dist/TextArea/TextArea.types.js +2 -0
  167. package/dist/TextArea/TextArea.types.js.map +1 -0
  168. package/dist/TextArea/index.js +2 -0
  169. package/dist/TextArea/index.js.map +1 -0
  170. package/dist/TextField/TextField.js +79 -0
  171. package/dist/TextField/TextField.js.map +1 -0
  172. package/dist/TextField/TextField.stories.js +70 -0
  173. package/dist/TextField/TextField.stories.js.map +1 -0
  174. package/dist/TextField/TextField.test.js +39 -0
  175. package/dist/TextField/TextField.test.js.map +1 -0
  176. package/dist/TextField/TextField.types.js +2 -0
  177. package/dist/TextField/TextField.types.js.map +1 -0
  178. package/dist/TextField/index.js +2 -0
  179. package/dist/TextField/index.js.map +1 -0
  180. package/dist/ToolbarButton/ToolbarButton.js +75 -0
  181. package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
  182. package/dist/ToolbarButton/ToolbarButton.stories.js +94 -0
  183. package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
  184. package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
  185. package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
  186. package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
  187. package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
  188. package/dist/ToolbarButton/index.js +2 -0
  189. package/dist/ToolbarButton/index.js.map +1 -0
  190. package/dist/Tooltip/QTip.stories.js +45 -0
  191. package/dist/Tooltip/QTip.stories.js.map +1 -0
  192. package/dist/Tooltip/QTip.types.js +2 -0
  193. package/dist/Tooltip/QTip.types.js.map +1 -0
  194. package/dist/Tooltip/QTipPerformance.stories.js +30 -0
  195. package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
  196. package/dist/Tooltip/Qtip.js +168 -0
  197. package/dist/Tooltip/Qtip.js.map +1 -0
  198. package/dist/Tooltip/Tooltip.js +36 -0
  199. package/dist/Tooltip/Tooltip.js.map +1 -0
  200. package/dist/Tooltip/Tooltip.stories.js +32 -0
  201. package/dist/Tooltip/Tooltip.stories.js.map +1 -0
  202. package/dist/Tooltip/Tooltip.types.js +3 -0
  203. package/dist/Tooltip/Tooltip.types.js.map +1 -0
  204. package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
  205. package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
  206. package/dist/Tooltip/index.js +3 -0
  207. package/dist/Tooltip/index.js.map +1 -0
  208. package/dist/Tooltip/qTip.utilities.js +11 -0
  209. package/dist/Tooltip/qTip.utilities.js.map +1 -0
  210. package/dist/example/.eslintrc.cjs +14 -14
  211. package/dist/example/README.md +33 -33
  212. package/dist/example/index.html +13 -13
  213. package/dist/example/package.json +30 -30
  214. package/dist/example/src/ComplexSelectExample.tsx +81 -81
  215. package/dist/example/src/Example.tsx +408 -408
  216. package/dist/example/src/index.css +102 -102
  217. package/dist/example/src/main.tsx +10 -10
  218. package/dist/example/src/vite-env.d.ts +1 -1
  219. package/dist/example/tsconfig.json +33 -33
  220. package/dist/example/tsconfig.node.json +12 -12
  221. package/dist/example/vite.config.ts +12 -12
  222. package/dist/index.d.ts +2 -0
  223. package/dist/index.esm.js +3566 -52
  224. package/dist/index.esm.js.map +1 -1
  225. package/dist/index.js +3563 -48
  226. package/dist/index.js.map +1 -1
  227. package/dist/styles.css +3629 -3631
  228. package/dist/types.js +2 -0
  229. package/dist/types.js.map +1 -0
  230. package/dist/utils/browserId.js +29 -0
  231. package/dist/utils/browserId.js.map +1 -0
  232. package/dist/utils/svg.js +20 -0
  233. package/dist/utils/svg.js.map +1 -0
  234. package/dist/utils/validateStyleDimension.js +14 -0
  235. package/dist/utils/validateStyleDimension.js.map +1 -0
  236. package/dist/utils/validateStyleDimension.test.js +20 -0
  237. package/dist/utils/validateStyleDimension.test.js.map +1 -0
  238. package/package.json +86 -85
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useCallback, createContext, useMemo, createElement, useContext, forwardRef, Children, isValidElement, cloneElement, Fragment, useEffect, useRef, useState, useLayoutEffect, useReducer, Component } from 'react';
3
3
  import * as ReactDOM from 'react-dom';
4
- import ReactDOM__default, { flushSync, createPortal } from 'react-dom';
4
+ import ReactDOM__default, { flushSync, createPortal, unstable_batchedUpdates } from 'react-dom';
5
5
  import { jsx as jsx$1, Fragment as Fragment$1, jsxs } from 'react/jsx-runtime';
6
6
 
7
7
  /**
@@ -89,7 +89,7 @@ const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClas
89
89
  const fontAwesomePrefix = iconPrefix ? iconPrefix : 'fa-sharp fa-regular';
90
90
  const iconPrefixString = icon.startsWith('fc') ? 'fc' : fontAwesomePrefix;
91
91
  const style = type === 'color' && color ? { color } : {};
92
- const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
92
+ const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
93
93
  ${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'tw-cursor-pointer' : ''} ${extraClassNames} focus:tw-outline-none focus-visible:tw-outline-none tw-outline-none`;
94
94
  const tooltipData = getQTipData(tooltipProps);
95
95
  return (React__default.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number, ...tooltipData }));
@@ -1077,7 +1077,7 @@ const oppositeAlignmentMap = {
1077
1077
  start: 'end',
1078
1078
  end: 'start'
1079
1079
  };
1080
- function clamp$1(start, value, end) {
1080
+ function clamp$2(start, value, end) {
1081
1081
  return max$1(start, min$1(value, end));
1082
1082
  }
1083
1083
  function evaluate(value, param) {
@@ -1450,7 +1450,7 @@ const arrow$1 = options => ({
1450
1450
  const min$1$1 = minPadding;
1451
1451
  const max = clientSize - arrowDimensions[length] - maxPadding;
1452
1452
  const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1453
- const offset = clamp$1(min$1$1, center, max);
1453
+ const offset = clamp$2(min$1$1, center, max);
1454
1454
 
1455
1455
  // If the reference is small enough that the arrow's padding causes it to
1456
1456
  // to point to nothing for an aligned placement, adjust the offset of the
@@ -1790,14 +1790,14 @@ const shift = function (options) {
1790
1790
  const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1791
1791
  const min = mainAxisCoord + overflow[minSide];
1792
1792
  const max = mainAxisCoord - overflow[maxSide];
1793
- mainAxisCoord = clamp$1(min, mainAxisCoord, max);
1793
+ mainAxisCoord = clamp$2(min, mainAxisCoord, max);
1794
1794
  }
1795
1795
  if (checkCrossAxis) {
1796
1796
  const minSide = crossAxis === 'y' ? 'top' : 'left';
1797
1797
  const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1798
1798
  const min = crossAxisCoord + overflow[minSide];
1799
1799
  const max = crossAxisCoord - overflow[maxSide];
1800
- crossAxisCoord = clamp$1(min, crossAxisCoord, max);
1800
+ crossAxisCoord = clamp$2(min, crossAxisCoord, max);
1801
1801
  }
1802
1802
  const limitedCoords = limiter.fn({
1803
1803
  ...state,
@@ -4757,13 +4757,13 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
4757
4757
  const arrowBaseClasses = 'before:tw-content-[\'\'] before:tw-absolute before:tw-border-8';
4758
4758
  const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
4759
4759
  const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
4760
- const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
4760
+ const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
4761
4761
  before:tw-border-l-transparent before:tw-border-r-black`;
4762
- const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
4762
+ const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
4763
4763
  before:tw-border-l-black before:tw-border-r-transparent`;
4764
- const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
4764
+ const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
4765
4765
  before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
4766
- const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
4766
+ const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
4767
4767
  before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
4768
4768
  const placements = {
4769
4769
  top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
@@ -4773,7 +4773,7 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
4773
4773
  };
4774
4774
  return (React__default.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
4775
4775
  children,
4776
- React__default.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
4776
+ React__default.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
4777
4777
  tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
4778
4778
  };
4779
4779
 
@@ -6107,7 +6107,7 @@ function createDOMPurify() {
6107
6107
  }
6108
6108
  var purify = createDOMPurify();
6109
6109
 
6110
- const noop$1 = () => { };
6110
+ const noop$2 = () => { };
6111
6111
 
6112
6112
  /**
6113
6113
  * A setInterval hook that calls a callback after a interval duration
@@ -6138,7 +6138,7 @@ function useIntervalWhen(callback, intervalDurationMs = 0, when = true, startImm
6138
6138
  window.clearInterval(interval);
6139
6139
  };
6140
6140
  }
6141
- return noop$1;
6141
+ return noop$2;
6142
6142
  }, [when, intervalDurationMs, startImmediate]);
6143
6143
  }
6144
6144
 
@@ -6814,7 +6814,7 @@ var from = String.fromCharCode;
6814
6814
  * @param {object}
6815
6815
  * @return {object}
6816
6816
  */
6817
- var assign = Object.assign;
6817
+ var assign$1 = Object.assign;
6818
6818
 
6819
6819
  /**
6820
6820
  * @param {string} value
@@ -6940,7 +6940,7 @@ function node (value, root, parent, type, props, children, length) {
6940
6940
  * @return {object}
6941
6941
  */
6942
6942
  function copy (root, props) {
6943
- return assign(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
6943
+ return assign$1(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
6944
6944
  }
6945
6945
 
6946
6946
  /**
@@ -7628,7 +7628,7 @@ var incorrectImportAlarm = function incorrectImportAlarm(element, index, childre
7628
7628
 
7629
7629
  /* eslint-disable no-fallthrough */
7630
7630
 
7631
- function prefix(value, length) {
7631
+ function prefix$1(value, length) {
7632
7632
  switch (hash(value, length)) {
7633
7633
  // color-adjust
7634
7634
  case 5103:
@@ -7756,7 +7756,7 @@ function prefix(value, length) {
7756
7756
  // (s)tretch
7757
7757
 
7758
7758
  case 115:
7759
- return ~indexof(value, 'stretch') ? prefix(replace(value, 'stretch', 'fill-available'), length) + value : value;
7759
+ return ~indexof(value, 'stretch') ? prefix$1(replace(value, 'stretch', 'fill-available'), length) + value : value;
7760
7760
  }
7761
7761
  break;
7762
7762
  // position: sticky
@@ -7804,7 +7804,7 @@ function prefix(value, length) {
7804
7804
  var prefixer = function prefixer(element, index, children, callback) {
7805
7805
  if (element.length > -1) if (!element["return"]) switch (element.type) {
7806
7806
  case DECLARATION:
7807
- element["return"] = prefix(element.value, element.length);
7807
+ element["return"] = prefix$1(element.value, element.length);
7808
7808
  break;
7809
7809
 
7810
7810
  case KEYFRAMES:
@@ -9272,7 +9272,7 @@ var _excluded$3 = ["className", "clearValue", "cx", "getStyles", "getClassNames"
9272
9272
  // NO OP
9273
9273
  // ==============================
9274
9274
 
9275
- var noop = function noop() {};
9275
+ var noop$1 = function noop() {};
9276
9276
 
9277
9277
  // ==============================
9278
9278
  // Class Name Prefixer
@@ -9433,7 +9433,7 @@ function easeOutCubic(t, b, c, d) {
9433
9433
  }
9434
9434
  function animatedScrollTo(element, to) {
9435
9435
  var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
9436
- var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
9436
+ var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop$1;
9437
9437
  var start = getScrollTop(element);
9438
9438
  var change = to - start;
9439
9439
  var increment = 10;
@@ -9521,8 +9521,8 @@ var options = {
9521
9521
  // check for SSR
9522
9522
  var w = typeof window !== 'undefined' ? window : {};
9523
9523
  if (w.addEventListener && w.removeEventListener) {
9524
- w.addEventListener('p', noop, options);
9525
- w.removeEventListener('p', noop, false);
9524
+ w.addEventListener('p', noop$1, options);
9525
+ w.removeEventListener('p', noop$1, false);
9526
9526
  }
9527
9527
  var supportsPassiveEvents = passiveOptionAccessed;
9528
9528
  function notNullish(item) {
@@ -10627,7 +10627,7 @@ var safeIsNaN = Number.isNaN ||
10627
10627
  function ponyfill(value) {
10628
10628
  return typeof value === 'number' && value !== value;
10629
10629
  };
10630
- function isEqual(first, second) {
10630
+ function isEqual$1(first, second) {
10631
10631
  if (first === second) {
10632
10632
  return true;
10633
10633
  }
@@ -10636,12 +10636,12 @@ function isEqual(first, second) {
10636
10636
  }
10637
10637
  return false;
10638
10638
  }
10639
- function areInputsEqual(newInputs, lastInputs) {
10639
+ function areInputsEqual$1(newInputs, lastInputs) {
10640
10640
  if (newInputs.length !== lastInputs.length) {
10641
10641
  return false;
10642
10642
  }
10643
10643
  for (var i = 0; i < newInputs.length; i++) {
10644
- if (!isEqual(newInputs[i], lastInputs[i])) {
10644
+ if (!isEqual$1(newInputs[i], lastInputs[i])) {
10645
10645
  return false;
10646
10646
  }
10647
10647
  }
@@ -10649,7 +10649,7 @@ function areInputsEqual(newInputs, lastInputs) {
10649
10649
  }
10650
10650
 
10651
10651
  function memoizeOne(resultFn, isEqual) {
10652
- if (isEqual === void 0) { isEqual = areInputsEqual; }
10652
+ if (isEqual === void 0) { isEqual = areInputsEqual$1; }
10653
10653
  var cache = null;
10654
10654
  function memoized() {
10655
10655
  var newArgs = [];
@@ -11554,7 +11554,7 @@ var defaultStyles = {
11554
11554
  valueContainer: valueContainerCSS
11555
11555
  };
11556
11556
 
11557
- var colors = {
11557
+ var colors$1 = {
11558
11558
  primary: '#2684FF',
11559
11559
  primary75: '#4C9AFF',
11560
11560
  primary50: '#B2D4FF',
@@ -11587,7 +11587,7 @@ var spacing = {
11587
11587
  };
11588
11588
  var defaultTheme = {
11589
11589
  borderRadius: borderRadius$1,
11590
- colors: colors,
11590
+ colors: colors$1,
11591
11591
  spacing: spacing
11592
11592
  };
11593
11593
 
@@ -12706,7 +12706,7 @@ var Select$1 = /*#__PURE__*/function (_Component) {
12706
12706
  id: id,
12707
12707
  innerRef: this.getInputRef,
12708
12708
  onBlur: this.onInputBlur,
12709
- onChange: noop,
12709
+ onChange: noop$1,
12710
12710
  onFocus: this.onInputFocus,
12711
12711
  disabled: isDisabled,
12712
12712
  tabIndex: tabIndex,
@@ -13761,9 +13761,9 @@ const Dialog = $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9;
13761
13761
  const DialogPortal = $5d3850c4d0b4e6c7$export$602eac185826482c;
13762
13762
  const DialogClose = $5d3850c4d0b4e6c7$export$f39c2d165cd861fe;
13763
13763
  const DialogContent = React__default.forwardRef(({ className, children, ...props }, ref) => (React__default.createElement(DialogPortal, null,
13764
- React__default.createElement("div", { className: "tw-select-none tw-fixed tw-w-full tw-h-full tw-opacity-50 tw-inset-0 tw-z-[1009] tw-bg-sq-dark-background\r\n data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0\r\n data-[state=open]:fade-in-0 " }),
13765
- React__default.createElement($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, { ref: ref, className: `tw-fixed tw-left-[50%] tw-top-0 tw-my-6 tw-translate-x-[-50%] tw-z-[1010] tw-grid
13766
- tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
13764
+ React__default.createElement("div", { className: "tw-select-none tw-fixed tw-w-full tw-h-full tw-opacity-50 tw-inset-0 tw-z-[1009] tw-bg-sq-dark-background\n data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0\n data-[state=open]:fade-in-0 " }),
13765
+ React__default.createElement($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, { ref: ref, className: `tw-fixed tw-left-[50%] tw-top-0 tw-my-6 tw-translate-x-[-50%] tw-z-[1010] tw-grid
13766
+ tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
13767
13767
  tw-rounded-lg ${className}`, ...props }, children))));
13768
13768
  DialogContent.displayName = $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2.displayName;
13769
13769
  const DialogHeader = (props) => (React__default.createElement("div", { className: "tw-w-full tw-justify-between" },
@@ -13835,7 +13835,7 @@ const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, sub
13835
13835
  'tw-max-w-5xl': size === '5xl',
13836
13836
  'tw-max-w-6xl': size === '6xl',
13837
13837
  }, dialogClassName) },
13838
- React__default.createElement(DialogHeader, { className: "modal-header tw-flex tw-w-full tw-justify-between tw-border-sq-disabled-gray\r\n dark:tw-border-sq-dark-disabled-gray tw-border-0 tw-border-b tw-px-6 tw-py-4" },
13838
+ React__default.createElement(DialogHeader, { className: "modal-header tw-flex tw-w-full tw-justify-between tw-border-sq-disabled-gray\n dark:tw-border-sq-dark-disabled-gray tw-border-0 tw-border-b tw-px-6 tw-py-4" },
13839
13839
  React__default.createElement("div", { className: "tw-flex tw-w-full" }, renderTitle()),
13840
13840
  !hideCloseIcon && (React__default.createElement(DialogClose, { autoFocus: false, className: "[&:has(:focus-visible)]:none tw-opacity-70 tw-bg-transparent hover:tw-opacity-100 close tw-cursor-pointer tw-ml-4", "data-testid": "closeButton" },
13841
13841
  React__default.createElement("span", { className: "tw-cursor-pointer" }, "\u00D7")))),
@@ -14756,8 +14756,8 @@ const ButtonWithPopover = ({ children, trigger, id, hasArrow, extraTriggerClassN
14756
14756
  React.useEffect(() => () => timeout && clearTimeout(timeout), []);
14757
14757
  const renderContent = () => {
14758
14758
  return (React.createElement($cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, { sideOffset: placementOffset, align: align, side: placement, onInteractOutside: onInteractOutside, onPointerDownOutside: onPointerDownOutside, alignOffset: isHoverEnabled ? -10 : alignOffset, asChild: true, onClick: () => isCloseOnContentClick && onOpenChange && onOpenChange(false), className: "focus-visible:tw-outline-none tw-outline-none tw-w-full tw-h-full" },
14759
- React.createElement("div", { "data-testid": containerTestId, className: `${bgStyles$2} ${borderStyles$2} tw-relative tw-z-[1200] tw-min-w-6 focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out
14760
- data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade tw-text-sq-text-color
14759
+ React.createElement("div", { "data-testid": containerTestId, className: `${bgStyles$2} ${borderStyles$2} tw-relative tw-z-[1200] tw-min-w-6 focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out
14760
+ data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade tw-text-sq-text-color
14761
14761
  ${extraPopoverClassNames || ''}` },
14762
14762
  hasArrow && (React.createElement($cb5cc270b50c6fcd$export$21b07c8f274aebd5, { asChild: true },
14763
14763
  React.createElement("div", { className: "tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-mt-[-7px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-500" }))),
@@ -15946,11 +15946,3511 @@ const InputGroup = React__default.forwardRef((props, ref) => {
15946
15946
  const tooltipData = getQTipData(tooltipProps);
15947
15947
  const appliedClasses = `${baseClasses} ${extraClassNames}`;
15948
15948
  const fieldAppliedClasses = `${fieldClasses} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius} ${showError ? errorClasses : borderColorClasses} `;
15949
- return (React__default.createElement("div", { id: id, className: appliedClasses },
15949
+ return (React__default.createElement("div", { id: `input-group-${id}`, className: appliedClasses },
15950
15950
  field ? (React__default.createElement("div", { "data-testid": testId, className: `tw-flex tw-flex-1 tw-cursor-pointer active:tw-z-50 ${fieldAppliedClasses}` }, field)) : (React__default.createElement(TextField, { testId: testId, readonly: readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, ref: ref, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, maxLength: maxLength, minLength: minLength, extraClassNames: `tw-flex tw-flex-1 tw-w-full tw-rounded-r-none focus:tw-z-30 ${extraClassNames}`, ...tooltipData })),
15951
- append.filter(Boolean).map((item, index) => item?.variant === 'button' ? (React__default.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", onClick: item.buttonProps.onClick, variant: item.buttonProps.variant, icon: item.buttonProps.icon, iconColor: item.buttonProps.iconColor, testId: item.buttonProps.testId, disabled: item.buttonProps.disabled, label: item.buttonProps.label, iconStyle: item.buttonProps.iconStyle, tooltip: item.buttonProps.tooltip, tooltipOptions: item.buttonProps.tooltipOptions, tooltipTestId: item.buttonProps.tooltipTestId, isHtmlTooltip: item.buttonProps.isHtmlTooltip, type: item.buttonProps.type, iconPosition: item.buttonProps.iconPosition })) : (React__default.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-justify-center tw-rounded-none tw-ml-[-1px] active:tw-z-30 active:tw-border tw-border last:tw-rounded-r-sm` }, item?.element)))));
15951
+ append.filter(Boolean).map((item, index) => item?.variant === 'button' ? (React__default.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", ...item.buttonProps })) : (React__default.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-justify-center tw-rounded-none tw-ml-[-1px] active:tw-z-30 active:tw-border tw-border last:tw-rounded-r-sm` }, item?.element)))));
15952
15952
  });
15953
15953
 
15954
+ // src/index.ts
15955
+ var updateQueue = makeQueue();
15956
+ var raf = (fn) => schedule(fn, updateQueue);
15957
+ var writeQueue = makeQueue();
15958
+ raf.write = (fn) => schedule(fn, writeQueue);
15959
+ var onStartQueue = makeQueue();
15960
+ raf.onStart = (fn) => schedule(fn, onStartQueue);
15961
+ var onFrameQueue = makeQueue();
15962
+ raf.onFrame = (fn) => schedule(fn, onFrameQueue);
15963
+ var onFinishQueue = makeQueue();
15964
+ raf.onFinish = (fn) => schedule(fn, onFinishQueue);
15965
+ var timeouts = [];
15966
+ raf.setTimeout = (handler, ms) => {
15967
+ const time = raf.now() + ms;
15968
+ const cancel = () => {
15969
+ const i = timeouts.findIndex((t) => t.cancel == cancel);
15970
+ if (~i)
15971
+ timeouts.splice(i, 1);
15972
+ pendingCount -= ~i ? 1 : 0;
15973
+ };
15974
+ const timeout = { time, handler, cancel };
15975
+ timeouts.splice(findTimeout(time), 0, timeout);
15976
+ pendingCount += 1;
15977
+ start();
15978
+ return timeout;
15979
+ };
15980
+ var findTimeout = (time) => ~(~timeouts.findIndex((t) => t.time > time) || ~timeouts.length);
15981
+ raf.cancel = (fn) => {
15982
+ onStartQueue.delete(fn);
15983
+ onFrameQueue.delete(fn);
15984
+ onFinishQueue.delete(fn);
15985
+ updateQueue.delete(fn);
15986
+ writeQueue.delete(fn);
15987
+ };
15988
+ raf.sync = (fn) => {
15989
+ sync = true;
15990
+ raf.batchedUpdates(fn);
15991
+ sync = false;
15992
+ };
15993
+ raf.throttle = (fn) => {
15994
+ let lastArgs;
15995
+ function queuedFn() {
15996
+ try {
15997
+ fn(...lastArgs);
15998
+ } finally {
15999
+ lastArgs = null;
16000
+ }
16001
+ }
16002
+ function throttled(...args) {
16003
+ lastArgs = args;
16004
+ raf.onStart(queuedFn);
16005
+ }
16006
+ throttled.handler = fn;
16007
+ throttled.cancel = () => {
16008
+ onStartQueue.delete(queuedFn);
16009
+ lastArgs = null;
16010
+ };
16011
+ return throttled;
16012
+ };
16013
+ var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : (
16014
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
16015
+ () => {
16016
+ }
16017
+ );
16018
+ raf.use = (impl) => nativeRaf = impl;
16019
+ raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
16020
+ raf.batchedUpdates = (fn) => fn();
16021
+ raf.catch = console.error;
16022
+ raf.frameLoop = "always";
16023
+ raf.advance = () => {
16024
+ if (raf.frameLoop !== "demand") {
16025
+ console.warn(
16026
+ "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"
16027
+ );
16028
+ } else {
16029
+ update();
16030
+ }
16031
+ };
16032
+ var ts = -1;
16033
+ var pendingCount = 0;
16034
+ var sync = false;
16035
+ function schedule(fn, queue) {
16036
+ if (sync) {
16037
+ queue.delete(fn);
16038
+ fn(0);
16039
+ } else {
16040
+ queue.add(fn);
16041
+ start();
16042
+ }
16043
+ }
16044
+ function start() {
16045
+ if (ts < 0) {
16046
+ ts = 0;
16047
+ if (raf.frameLoop !== "demand") {
16048
+ nativeRaf(loop);
16049
+ }
16050
+ }
16051
+ }
16052
+ function stop() {
16053
+ ts = -1;
16054
+ }
16055
+ function loop() {
16056
+ if (~ts) {
16057
+ nativeRaf(loop);
16058
+ raf.batchedUpdates(update);
16059
+ }
16060
+ }
16061
+ function update() {
16062
+ const prevTs = ts;
16063
+ ts = raf.now();
16064
+ const count = findTimeout(ts);
16065
+ if (count) {
16066
+ eachSafely(timeouts.splice(0, count), (t) => t.handler());
16067
+ pendingCount -= count;
16068
+ }
16069
+ if (!pendingCount) {
16070
+ stop();
16071
+ return;
16072
+ }
16073
+ onStartQueue.flush();
16074
+ updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
16075
+ onFrameQueue.flush();
16076
+ writeQueue.flush();
16077
+ onFinishQueue.flush();
16078
+ }
16079
+ function makeQueue() {
16080
+ let next = /* @__PURE__ */ new Set();
16081
+ let current = next;
16082
+ return {
16083
+ add(fn) {
16084
+ pendingCount += current == next && !next.has(fn) ? 1 : 0;
16085
+ next.add(fn);
16086
+ },
16087
+ delete(fn) {
16088
+ pendingCount -= current == next && next.has(fn) ? 1 : 0;
16089
+ return next.delete(fn);
16090
+ },
16091
+ flush(arg) {
16092
+ if (current.size) {
16093
+ next = /* @__PURE__ */ new Set();
16094
+ pendingCount -= current.size;
16095
+ eachSafely(current, (fn) => fn(arg) && next.add(fn));
16096
+ pendingCount += next.size;
16097
+ current = next;
16098
+ }
16099
+ }
16100
+ };
16101
+ }
16102
+ function eachSafely(values, each) {
16103
+ values.forEach((value) => {
16104
+ try {
16105
+ each(value);
16106
+ } catch (e) {
16107
+ raf.catch(e);
16108
+ }
16109
+ });
16110
+ }
16111
+
16112
+ var __defProp = Object.defineProperty;
16113
+ var __export = (target, all) => {
16114
+ for (var name in all)
16115
+ __defProp(target, name, { get: all[name], enumerable: true });
16116
+ };
16117
+
16118
+ // src/globals.ts
16119
+ var globals_exports = {};
16120
+ __export(globals_exports, {
16121
+ assign: () => assign,
16122
+ colors: () => colors,
16123
+ createStringInterpolator: () => createStringInterpolator,
16124
+ skipAnimation: () => skipAnimation,
16125
+ to: () => to,
16126
+ willAdvance: () => willAdvance
16127
+ });
16128
+
16129
+ // src/helpers.ts
16130
+ function noop() {
16131
+ }
16132
+ var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { value, writable: true, configurable: true });
16133
+ var is = {
16134
+ arr: Array.isArray,
16135
+ obj: (a) => !!a && a.constructor.name === "Object",
16136
+ fun: (a) => typeof a === "function",
16137
+ str: (a) => typeof a === "string",
16138
+ num: (a) => typeof a === "number",
16139
+ und: (a) => a === void 0
16140
+ };
16141
+ function isEqual(a, b) {
16142
+ if (is.arr(a)) {
16143
+ if (!is.arr(b) || a.length !== b.length)
16144
+ return false;
16145
+ for (let i = 0; i < a.length; i++) {
16146
+ if (a[i] !== b[i])
16147
+ return false;
16148
+ }
16149
+ return true;
16150
+ }
16151
+ return a === b;
16152
+ }
16153
+ var each = (obj, fn) => obj.forEach(fn);
16154
+ function eachProp(obj, fn, ctx) {
16155
+ if (is.arr(obj)) {
16156
+ for (let i = 0; i < obj.length; i++) {
16157
+ fn.call(ctx, obj[i], `${i}`);
16158
+ }
16159
+ return;
16160
+ }
16161
+ for (const key in obj) {
16162
+ if (obj.hasOwnProperty(key)) {
16163
+ fn.call(ctx, obj[key], key);
16164
+ }
16165
+ }
16166
+ }
16167
+ var toArray = (a) => is.und(a) ? [] : is.arr(a) ? a : [a];
16168
+ function flush(queue, iterator) {
16169
+ if (queue.size) {
16170
+ const items = Array.from(queue);
16171
+ queue.clear();
16172
+ each(items, iterator);
16173
+ }
16174
+ }
16175
+ var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args));
16176
+ var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
16177
+
16178
+ // src/globals.ts
16179
+ var createStringInterpolator;
16180
+ var to;
16181
+ var colors = null;
16182
+ var skipAnimation = false;
16183
+ var willAdvance = noop;
16184
+ var assign = (globals) => {
16185
+ if (globals.to)
16186
+ to = globals.to;
16187
+ if (globals.now)
16188
+ raf.now = globals.now;
16189
+ if (globals.colors !== void 0)
16190
+ colors = globals.colors;
16191
+ if (globals.skipAnimation != null)
16192
+ skipAnimation = globals.skipAnimation;
16193
+ if (globals.createStringInterpolator)
16194
+ createStringInterpolator = globals.createStringInterpolator;
16195
+ if (globals.requestAnimationFrame)
16196
+ raf.use(globals.requestAnimationFrame);
16197
+ if (globals.batchedUpdates)
16198
+ raf.batchedUpdates = globals.batchedUpdates;
16199
+ if (globals.willAdvance)
16200
+ willAdvance = globals.willAdvance;
16201
+ if (globals.frameLoop)
16202
+ raf.frameLoop = globals.frameLoop;
16203
+ };
16204
+ var startQueue = /* @__PURE__ */ new Set();
16205
+ var currentFrame = [];
16206
+ var prevFrame = [];
16207
+ var priority = 0;
16208
+ var frameLoop = {
16209
+ get idle() {
16210
+ return !startQueue.size && !currentFrame.length;
16211
+ },
16212
+ /** Advance the given animation on every frame until idle. */
16213
+ start(animation) {
16214
+ if (priority > animation.priority) {
16215
+ startQueue.add(animation);
16216
+ raf.onStart(flushStartQueue);
16217
+ } else {
16218
+ startSafely(animation);
16219
+ raf(advance);
16220
+ }
16221
+ },
16222
+ /** Advance all animations by the given time. */
16223
+ advance,
16224
+ /** Call this when an animation's priority changes. */
16225
+ sort(animation) {
16226
+ if (priority) {
16227
+ raf.onFrame(() => frameLoop.sort(animation));
16228
+ } else {
16229
+ const prevIndex = currentFrame.indexOf(animation);
16230
+ if (~prevIndex) {
16231
+ currentFrame.splice(prevIndex, 1);
16232
+ startUnsafely(animation);
16233
+ }
16234
+ }
16235
+ },
16236
+ /**
16237
+ * Clear all animations. For testing purposes.
16238
+ *
16239
+ * ☠️ Never call this from within the frameloop.
16240
+ */
16241
+ clear() {
16242
+ currentFrame = [];
16243
+ startQueue.clear();
16244
+ }
16245
+ };
16246
+ function flushStartQueue() {
16247
+ startQueue.forEach(startSafely);
16248
+ startQueue.clear();
16249
+ raf(advance);
16250
+ }
16251
+ function startSafely(animation) {
16252
+ if (!currentFrame.includes(animation))
16253
+ startUnsafely(animation);
16254
+ }
16255
+ function startUnsafely(animation) {
16256
+ currentFrame.splice(
16257
+ findIndex(currentFrame, (other) => other.priority > animation.priority),
16258
+ 0,
16259
+ animation
16260
+ );
16261
+ }
16262
+ function advance(dt) {
16263
+ const nextFrame = prevFrame;
16264
+ for (let i = 0; i < currentFrame.length; i++) {
16265
+ const animation = currentFrame[i];
16266
+ priority = animation.priority;
16267
+ if (!animation.idle) {
16268
+ willAdvance(animation);
16269
+ animation.advance(dt);
16270
+ if (!animation.idle) {
16271
+ nextFrame.push(animation);
16272
+ }
16273
+ }
16274
+ }
16275
+ priority = 0;
16276
+ prevFrame = currentFrame;
16277
+ prevFrame.length = 0;
16278
+ currentFrame = nextFrame;
16279
+ return currentFrame.length > 0;
16280
+ }
16281
+ function findIndex(arr, test) {
16282
+ const index = arr.findIndex(test);
16283
+ return index < 0 ? arr.length : index;
16284
+ }
16285
+
16286
+ // src/clamp.ts
16287
+ var clamp$1 = (min, max, v) => Math.min(Math.max(v, min), max);
16288
+
16289
+ // src/colors.ts
16290
+ var colors2 = {
16291
+ transparent: 0,
16292
+ aliceblue: 4042850303,
16293
+ antiquewhite: 4209760255,
16294
+ aqua: 16777215,
16295
+ aquamarine: 2147472639,
16296
+ azure: 4043309055,
16297
+ beige: 4126530815,
16298
+ bisque: 4293182719,
16299
+ black: 255,
16300
+ blanchedalmond: 4293643775,
16301
+ blue: 65535,
16302
+ blueviolet: 2318131967,
16303
+ brown: 2771004159,
16304
+ burlywood: 3736635391,
16305
+ burntsienna: 3934150143,
16306
+ cadetblue: 1604231423,
16307
+ chartreuse: 2147418367,
16308
+ chocolate: 3530104575,
16309
+ coral: 4286533887,
16310
+ cornflowerblue: 1687547391,
16311
+ cornsilk: 4294499583,
16312
+ crimson: 3692313855,
16313
+ cyan: 16777215,
16314
+ darkblue: 35839,
16315
+ darkcyan: 9145343,
16316
+ darkgoldenrod: 3095792639,
16317
+ darkgray: 2846468607,
16318
+ darkgreen: 6553855,
16319
+ darkgrey: 2846468607,
16320
+ darkkhaki: 3182914559,
16321
+ darkmagenta: 2332068863,
16322
+ darkolivegreen: 1433087999,
16323
+ darkorange: 4287365375,
16324
+ darkorchid: 2570243327,
16325
+ darkred: 2332033279,
16326
+ darksalmon: 3918953215,
16327
+ darkseagreen: 2411499519,
16328
+ darkslateblue: 1211993087,
16329
+ darkslategray: 793726975,
16330
+ darkslategrey: 793726975,
16331
+ darkturquoise: 13554175,
16332
+ darkviolet: 2483082239,
16333
+ deeppink: 4279538687,
16334
+ deepskyblue: 12582911,
16335
+ dimgray: 1768516095,
16336
+ dimgrey: 1768516095,
16337
+ dodgerblue: 512819199,
16338
+ firebrick: 2988581631,
16339
+ floralwhite: 4294635775,
16340
+ forestgreen: 579543807,
16341
+ fuchsia: 4278255615,
16342
+ gainsboro: 3705462015,
16343
+ ghostwhite: 4177068031,
16344
+ gold: 4292280575,
16345
+ goldenrod: 3668254975,
16346
+ gray: 2155905279,
16347
+ green: 8388863,
16348
+ greenyellow: 2919182335,
16349
+ grey: 2155905279,
16350
+ honeydew: 4043305215,
16351
+ hotpink: 4285117695,
16352
+ indianred: 3445382399,
16353
+ indigo: 1258324735,
16354
+ ivory: 4294963455,
16355
+ khaki: 4041641215,
16356
+ lavender: 3873897215,
16357
+ lavenderblush: 4293981695,
16358
+ lawngreen: 2096890111,
16359
+ lemonchiffon: 4294626815,
16360
+ lightblue: 2916673279,
16361
+ lightcoral: 4034953471,
16362
+ lightcyan: 3774873599,
16363
+ lightgoldenrodyellow: 4210742015,
16364
+ lightgray: 3553874943,
16365
+ lightgreen: 2431553791,
16366
+ lightgrey: 3553874943,
16367
+ lightpink: 4290167295,
16368
+ lightsalmon: 4288707327,
16369
+ lightseagreen: 548580095,
16370
+ lightskyblue: 2278488831,
16371
+ lightslategray: 2005441023,
16372
+ lightslategrey: 2005441023,
16373
+ lightsteelblue: 2965692159,
16374
+ lightyellow: 4294959359,
16375
+ lime: 16711935,
16376
+ limegreen: 852308735,
16377
+ linen: 4210091775,
16378
+ magenta: 4278255615,
16379
+ maroon: 2147483903,
16380
+ mediumaquamarine: 1724754687,
16381
+ mediumblue: 52735,
16382
+ mediumorchid: 3126187007,
16383
+ mediumpurple: 2473647103,
16384
+ mediumseagreen: 1018393087,
16385
+ mediumslateblue: 2070474495,
16386
+ mediumspringgreen: 16423679,
16387
+ mediumturquoise: 1221709055,
16388
+ mediumvioletred: 3340076543,
16389
+ midnightblue: 421097727,
16390
+ mintcream: 4127193855,
16391
+ mistyrose: 4293190143,
16392
+ moccasin: 4293178879,
16393
+ navajowhite: 4292783615,
16394
+ navy: 33023,
16395
+ oldlace: 4260751103,
16396
+ olive: 2155872511,
16397
+ olivedrab: 1804477439,
16398
+ orange: 4289003775,
16399
+ orangered: 4282712319,
16400
+ orchid: 3664828159,
16401
+ palegoldenrod: 4008225535,
16402
+ palegreen: 2566625535,
16403
+ paleturquoise: 2951671551,
16404
+ palevioletred: 3681588223,
16405
+ papayawhip: 4293907967,
16406
+ peachpuff: 4292524543,
16407
+ peru: 3448061951,
16408
+ pink: 4290825215,
16409
+ plum: 3718307327,
16410
+ powderblue: 2967529215,
16411
+ purple: 2147516671,
16412
+ rebeccapurple: 1714657791,
16413
+ red: 4278190335,
16414
+ rosybrown: 3163525119,
16415
+ royalblue: 1097458175,
16416
+ saddlebrown: 2336560127,
16417
+ salmon: 4202722047,
16418
+ sandybrown: 4104413439,
16419
+ seagreen: 780883967,
16420
+ seashell: 4294307583,
16421
+ sienna: 2689740287,
16422
+ silver: 3233857791,
16423
+ skyblue: 2278484991,
16424
+ slateblue: 1784335871,
16425
+ slategray: 1887473919,
16426
+ slategrey: 1887473919,
16427
+ snow: 4294638335,
16428
+ springgreen: 16744447,
16429
+ steelblue: 1182971135,
16430
+ tan: 3535047935,
16431
+ teal: 8421631,
16432
+ thistle: 3636451583,
16433
+ tomato: 4284696575,
16434
+ turquoise: 1088475391,
16435
+ violet: 4001558271,
16436
+ wheat: 4125012991,
16437
+ white: 4294967295,
16438
+ whitesmoke: 4126537215,
16439
+ yellow: 4294902015,
16440
+ yellowgreen: 2597139199
16441
+ };
16442
+
16443
+ // src/colorMatchers.ts
16444
+ var NUMBER = "[-+]?\\d*\\.?\\d+";
16445
+ var PERCENTAGE = NUMBER + "%";
16446
+ function call(...parts) {
16447
+ return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)";
16448
+ }
16449
+ var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER));
16450
+ var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER));
16451
+ var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE));
16452
+ var hsla = new RegExp(
16453
+ "hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)
16454
+ );
16455
+ var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
16456
+ var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
16457
+ var hex6 = /^#([0-9a-fA-F]{6})$/;
16458
+ var hex8 = /^#([0-9a-fA-F]{8})$/;
16459
+
16460
+ // src/normalizeColor.ts
16461
+ function normalizeColor(color) {
16462
+ let match;
16463
+ if (typeof color === "number") {
16464
+ return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null;
16465
+ }
16466
+ if (match = hex6.exec(color))
16467
+ return parseInt(match[1] + "ff", 16) >>> 0;
16468
+ if (colors && colors[color] !== void 0) {
16469
+ return colors[color];
16470
+ }
16471
+ if (match = rgb.exec(color)) {
16472
+ return (parse255(match[1]) << 24 | // r
16473
+ parse255(match[2]) << 16 | // g
16474
+ parse255(match[3]) << 8 | // b
16475
+ 255) >>> // a
16476
+ 0;
16477
+ }
16478
+ if (match = rgba.exec(color)) {
16479
+ return (parse255(match[1]) << 24 | // r
16480
+ parse255(match[2]) << 16 | // g
16481
+ parse255(match[3]) << 8 | // b
16482
+ parse1(match[4])) >>> // a
16483
+ 0;
16484
+ }
16485
+ if (match = hex3.exec(color)) {
16486
+ return parseInt(
16487
+ match[1] + match[1] + // r
16488
+ match[2] + match[2] + // g
16489
+ match[3] + match[3] + // b
16490
+ "ff",
16491
+ // a
16492
+ 16
16493
+ ) >>> 0;
16494
+ }
16495
+ if (match = hex8.exec(color))
16496
+ return parseInt(match[1], 16) >>> 0;
16497
+ if (match = hex4.exec(color)) {
16498
+ return parseInt(
16499
+ match[1] + match[1] + // r
16500
+ match[2] + match[2] + // g
16501
+ match[3] + match[3] + // b
16502
+ match[4] + match[4],
16503
+ // a
16504
+ 16
16505
+ ) >>> 0;
16506
+ }
16507
+ if (match = hsl.exec(color)) {
16508
+ return (hslToRgb(
16509
+ parse360(match[1]),
16510
+ // h
16511
+ parsePercentage(match[2]),
16512
+ // s
16513
+ parsePercentage(match[3])
16514
+ // l
16515
+ ) | 255) >>> // a
16516
+ 0;
16517
+ }
16518
+ if (match = hsla.exec(color)) {
16519
+ return (hslToRgb(
16520
+ parse360(match[1]),
16521
+ // h
16522
+ parsePercentage(match[2]),
16523
+ // s
16524
+ parsePercentage(match[3])
16525
+ // l
16526
+ ) | parse1(match[4])) >>> // a
16527
+ 0;
16528
+ }
16529
+ return null;
16530
+ }
16531
+ function hue2rgb(p, q, t) {
16532
+ if (t < 0)
16533
+ t += 1;
16534
+ if (t > 1)
16535
+ t -= 1;
16536
+ if (t < 1 / 6)
16537
+ return p + (q - p) * 6 * t;
16538
+ if (t < 1 / 2)
16539
+ return q;
16540
+ if (t < 2 / 3)
16541
+ return p + (q - p) * (2 / 3 - t) * 6;
16542
+ return p;
16543
+ }
16544
+ function hslToRgb(h, s, l) {
16545
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
16546
+ const p = 2 * l - q;
16547
+ const r = hue2rgb(p, q, h + 1 / 3);
16548
+ const g = hue2rgb(p, q, h);
16549
+ const b = hue2rgb(p, q, h - 1 / 3);
16550
+ return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
16551
+ }
16552
+ function parse255(str) {
16553
+ const int = parseInt(str, 10);
16554
+ if (int < 0)
16555
+ return 0;
16556
+ if (int > 255)
16557
+ return 255;
16558
+ return int;
16559
+ }
16560
+ function parse360(str) {
16561
+ const int = parseFloat(str);
16562
+ return (int % 360 + 360) % 360 / 360;
16563
+ }
16564
+ function parse1(str) {
16565
+ const num = parseFloat(str);
16566
+ if (num < 0)
16567
+ return 0;
16568
+ if (num > 1)
16569
+ return 255;
16570
+ return Math.round(num * 255);
16571
+ }
16572
+ function parsePercentage(str) {
16573
+ const int = parseFloat(str);
16574
+ if (int < 0)
16575
+ return 0;
16576
+ if (int > 100)
16577
+ return 1;
16578
+ return int / 100;
16579
+ }
16580
+
16581
+ // src/colorToRgba.ts
16582
+ function colorToRgba(input) {
16583
+ let int32Color = normalizeColor(input);
16584
+ if (int32Color === null)
16585
+ return input;
16586
+ int32Color = int32Color || 0;
16587
+ const r = (int32Color & 4278190080) >>> 24;
16588
+ const g = (int32Color & 16711680) >>> 16;
16589
+ const b = (int32Color & 65280) >>> 8;
16590
+ const a = (int32Color & 255) / 255;
16591
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
16592
+ }
16593
+
16594
+ // src/createInterpolator.ts
16595
+ var createInterpolator = (range, output, extrapolate) => {
16596
+ if (is.fun(range)) {
16597
+ return range;
16598
+ }
16599
+ if (is.arr(range)) {
16600
+ return createInterpolator({
16601
+ range,
16602
+ output,
16603
+ extrapolate
16604
+ });
16605
+ }
16606
+ if (is.str(range.output[0])) {
16607
+ return createStringInterpolator(range);
16608
+ }
16609
+ const config = range;
16610
+ const outputRange = config.output;
16611
+ const inputRange = config.range || [0, 1];
16612
+ const extrapolateLeft = config.extrapolateLeft || config.extrapolate || "extend";
16613
+ const extrapolateRight = config.extrapolateRight || config.extrapolate || "extend";
16614
+ const easing = config.easing || ((t) => t);
16615
+ return (input) => {
16616
+ const range2 = findRange(input, inputRange);
16617
+ return interpolate(
16618
+ input,
16619
+ inputRange[range2],
16620
+ inputRange[range2 + 1],
16621
+ outputRange[range2],
16622
+ outputRange[range2 + 1],
16623
+ easing,
16624
+ extrapolateLeft,
16625
+ extrapolateRight,
16626
+ config.map
16627
+ );
16628
+ };
16629
+ };
16630
+ function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
16631
+ let result = map ? map(input) : input;
16632
+ if (result < inputMin) {
16633
+ if (extrapolateLeft === "identity")
16634
+ return result;
16635
+ else if (extrapolateLeft === "clamp")
16636
+ result = inputMin;
16637
+ }
16638
+ if (result > inputMax) {
16639
+ if (extrapolateRight === "identity")
16640
+ return result;
16641
+ else if (extrapolateRight === "clamp")
16642
+ result = inputMax;
16643
+ }
16644
+ if (outputMin === outputMax)
16645
+ return outputMin;
16646
+ if (inputMin === inputMax)
16647
+ return input <= inputMin ? outputMin : outputMax;
16648
+ if (inputMin === -Infinity)
16649
+ result = -result;
16650
+ else if (inputMax === Infinity)
16651
+ result = result - inputMin;
16652
+ else
16653
+ result = (result - inputMin) / (inputMax - inputMin);
16654
+ result = easing(result);
16655
+ if (outputMin === -Infinity)
16656
+ result = -result;
16657
+ else if (outputMax === Infinity)
16658
+ result = result + outputMin;
16659
+ else
16660
+ result = result * (outputMax - outputMin) + outputMin;
16661
+ return result;
16662
+ }
16663
+ function findRange(input, inputRange) {
16664
+ for (var i = 1; i < inputRange.length - 1; ++i)
16665
+ if (inputRange[i] >= input)
16666
+ break;
16667
+ return i - 1;
16668
+ }
16669
+
16670
+ // src/easings.ts
16671
+ var steps = (steps2, direction = "end") => (progress2) => {
16672
+ progress2 = direction === "end" ? Math.min(progress2, 0.999) : Math.max(progress2, 1e-3);
16673
+ const expanded = progress2 * steps2;
16674
+ const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
16675
+ return clamp$1(0, 1, rounded / steps2);
16676
+ };
16677
+ var c1 = 1.70158;
16678
+ var c2 = c1 * 1.525;
16679
+ var c3 = c1 + 1;
16680
+ var c4 = 2 * Math.PI / 3;
16681
+ var c5 = 2 * Math.PI / 4.5;
16682
+ var bounceOut = (x) => {
16683
+ const n1 = 7.5625;
16684
+ const d1 = 2.75;
16685
+ if (x < 1 / d1) {
16686
+ return n1 * x * x;
16687
+ } else if (x < 2 / d1) {
16688
+ return n1 * (x -= 1.5 / d1) * x + 0.75;
16689
+ } else if (x < 2.5 / d1) {
16690
+ return n1 * (x -= 2.25 / d1) * x + 0.9375;
16691
+ } else {
16692
+ return n1 * (x -= 2.625 / d1) * x + 0.984375;
16693
+ }
16694
+ };
16695
+ var easings = {
16696
+ linear: (x) => x,
16697
+ easeInQuad: (x) => x * x,
16698
+ easeOutQuad: (x) => 1 - (1 - x) * (1 - x),
16699
+ easeInOutQuad: (x) => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
16700
+ easeInCubic: (x) => x * x * x,
16701
+ easeOutCubic: (x) => 1 - Math.pow(1 - x, 3),
16702
+ easeInOutCubic: (x) => x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2,
16703
+ easeInQuart: (x) => x * x * x * x,
16704
+ easeOutQuart: (x) => 1 - Math.pow(1 - x, 4),
16705
+ easeInOutQuart: (x) => x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2,
16706
+ easeInQuint: (x) => x * x * x * x * x,
16707
+ easeOutQuint: (x) => 1 - Math.pow(1 - x, 5),
16708
+ easeInOutQuint: (x) => x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2,
16709
+ easeInSine: (x) => 1 - Math.cos(x * Math.PI / 2),
16710
+ easeOutSine: (x) => Math.sin(x * Math.PI / 2),
16711
+ easeInOutSine: (x) => -(Math.cos(Math.PI * x) - 1) / 2,
16712
+ easeInExpo: (x) => x === 0 ? 0 : Math.pow(2, 10 * x - 10),
16713
+ easeOutExpo: (x) => x === 1 ? 1 : 1 - Math.pow(2, -10 * x),
16714
+ easeInOutExpo: (x) => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2,
16715
+ easeInCirc: (x) => 1 - Math.sqrt(1 - Math.pow(x, 2)),
16716
+ easeOutCirc: (x) => Math.sqrt(1 - Math.pow(x - 1, 2)),
16717
+ easeInOutCirc: (x) => x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2,
16718
+ easeInBack: (x) => c3 * x * x * x - c1 * x * x,
16719
+ easeOutBack: (x) => 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2),
16720
+ easeInOutBack: (x) => x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
16721
+ easeInElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4),
16722
+ easeOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
16723
+ easeInOutElastic: (x) => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1,
16724
+ easeInBounce: (x) => 1 - bounceOut(1 - x),
16725
+ easeOutBounce: bounceOut,
16726
+ easeInOutBounce: (x) => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2,
16727
+ steps
16728
+ };
16729
+
16730
+ // src/fluids.ts
16731
+ var $get = Symbol.for("FluidValue.get");
16732
+ var $observers = Symbol.for("FluidValue.observers");
16733
+ var hasFluidValue = (arg) => Boolean(arg && arg[$get]);
16734
+ var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg;
16735
+ var getFluidObservers = (target) => target[$observers] || null;
16736
+ function callFluidObserver(observer2, event) {
16737
+ if (observer2.eventObserved) {
16738
+ observer2.eventObserved(event);
16739
+ } else {
16740
+ observer2(event);
16741
+ }
16742
+ }
16743
+ function callFluidObservers(target, event) {
16744
+ const observers = target[$observers];
16745
+ if (observers) {
16746
+ observers.forEach((observer2) => {
16747
+ callFluidObserver(observer2, event);
16748
+ });
16749
+ }
16750
+ }
16751
+ var FluidValue = class {
16752
+ constructor(get) {
16753
+ if (!get && !(get = this.get)) {
16754
+ throw Error("Unknown getter");
16755
+ }
16756
+ setFluidGetter(this, get);
16757
+ }
16758
+ };
16759
+ var setFluidGetter = (target, get) => setHidden(target, $get, get);
16760
+ function addFluidObserver(target, observer2) {
16761
+ if (target[$get]) {
16762
+ let observers = target[$observers];
16763
+ if (!observers) {
16764
+ setHidden(target, $observers, observers = /* @__PURE__ */ new Set());
16765
+ }
16766
+ if (!observers.has(observer2)) {
16767
+ observers.add(observer2);
16768
+ if (target.observerAdded) {
16769
+ target.observerAdded(observers.size, observer2);
16770
+ }
16771
+ }
16772
+ }
16773
+ return observer2;
16774
+ }
16775
+ function removeFluidObserver(target, observer2) {
16776
+ const observers = target[$observers];
16777
+ if (observers && observers.has(observer2)) {
16778
+ const count = observers.size - 1;
16779
+ if (count) {
16780
+ observers.delete(observer2);
16781
+ } else {
16782
+ target[$observers] = null;
16783
+ }
16784
+ if (target.observerRemoved) {
16785
+ target.observerRemoved(count, observer2);
16786
+ }
16787
+ }
16788
+ }
16789
+ var setHidden = (target, key, value) => Object.defineProperty(target, key, {
16790
+ value,
16791
+ writable: true,
16792
+ configurable: true
16793
+ });
16794
+
16795
+ // src/regexs.ts
16796
+ var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
16797
+ var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
16798
+ var unitRegex = new RegExp(`(${numberRegex.source})(%|[a-z]+)`, "i");
16799
+ var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi;
16800
+ var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
16801
+
16802
+ // src/variableToRgba.ts
16803
+ var variableToRgba = (input) => {
16804
+ const [token, fallback] = parseCSSVariable(input);
16805
+ if (!token || isSSR()) {
16806
+ return input;
16807
+ }
16808
+ const value = window.getComputedStyle(document.documentElement).getPropertyValue(token);
16809
+ if (value) {
16810
+ return value.trim();
16811
+ } else if (fallback && fallback.startsWith("--")) {
16812
+ const value2 = window.getComputedStyle(document.documentElement).getPropertyValue(fallback);
16813
+ if (value2) {
16814
+ return value2;
16815
+ } else {
16816
+ return input;
16817
+ }
16818
+ } else if (fallback && cssVariableRegex.test(fallback)) {
16819
+ return variableToRgba(fallback);
16820
+ } else if (fallback) {
16821
+ return fallback;
16822
+ }
16823
+ return input;
16824
+ };
16825
+ var parseCSSVariable = (current) => {
16826
+ const match = cssVariableRegex.exec(current);
16827
+ if (!match)
16828
+ return [,];
16829
+ const [, token, fallback] = match;
16830
+ return [token, fallback];
16831
+ };
16832
+
16833
+ // src/stringInterpolation.ts
16834
+ var namedColorRegex;
16835
+ var rgbaRound = (_, p1, p2, p3, p4) => `rgba(${Math.round(p1)}, ${Math.round(p2)}, ${Math.round(p3)}, ${p4})`;
16836
+ var createStringInterpolator2 = (config) => {
16837
+ if (!namedColorRegex)
16838
+ namedColorRegex = colors ? (
16839
+ // match color names, ignore partial matches
16840
+ new RegExp(`(${Object.keys(colors).join("|")})(?!\\w)`, "g")
16841
+ ) : (
16842
+ // never match
16843
+ /^\b$/
16844
+ );
16845
+ const output = config.output.map((value) => {
16846
+ return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba);
16847
+ });
16848
+ const keyframes = output.map((value) => value.match(numberRegex).map(Number));
16849
+ const outputRanges = keyframes[0].map(
16850
+ (_, i) => keyframes.map((values) => {
16851
+ if (!(i in values)) {
16852
+ throw Error('The arity of each "output" value must be equal');
16853
+ }
16854
+ return values[i];
16855
+ })
16856
+ );
16857
+ const interpolators = outputRanges.map(
16858
+ (output2) => createInterpolator({ ...config, output: output2 })
16859
+ );
16860
+ return (input) => {
16861
+ const missingUnit = !unitRegex.test(output[0]) && output.find((value) => unitRegex.test(value))?.replace(numberRegex, "");
16862
+ let i = 0;
16863
+ return output[0].replace(
16864
+ numberRegex,
16865
+ () => `${interpolators[i++](input)}${missingUnit || ""}`
16866
+ ).replace(rgbaRegex, rgbaRound);
16867
+ };
16868
+ };
16869
+
16870
+ // src/deprecations.ts
16871
+ var prefix = "react-spring: ";
16872
+ var once = (fn) => {
16873
+ const func = fn;
16874
+ let called = false;
16875
+ if (typeof func != "function") {
16876
+ throw new TypeError(`${prefix}once requires a function parameter`);
16877
+ }
16878
+ return (...args) => {
16879
+ if (!called) {
16880
+ func(...args);
16881
+ called = true;
16882
+ }
16883
+ };
16884
+ };
16885
+ var warnInterpolate = once(console.warn);
16886
+ function deprecateInterpolate() {
16887
+ warnInterpolate(
16888
+ `${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`
16889
+ );
16890
+ }
16891
+ var warnDirectCall = once(console.warn);
16892
+ function deprecateDirectCall() {
16893
+ warnDirectCall(
16894
+ `${prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`
16895
+ );
16896
+ }
16897
+
16898
+ // src/isAnimatedString.ts
16899
+ function isAnimatedString(value) {
16900
+ return is.str(value) && (value[0] == "#" || /\d/.test(value) || // Do not identify a CSS variable as an AnimatedString if its SSR
16901
+ !isSSR() && cssVariableRegex.test(value) || value in (colors || {}));
16902
+ }
16903
+ var useIsomorphicLayoutEffect = isSSR() ? useEffect : useLayoutEffect;
16904
+
16905
+ // src/hooks/useIsMounted.ts
16906
+ var useIsMounted = () => {
16907
+ const isMounted = useRef(false);
16908
+ useIsomorphicLayoutEffect(() => {
16909
+ isMounted.current = true;
16910
+ return () => {
16911
+ isMounted.current = false;
16912
+ };
16913
+ }, []);
16914
+ return isMounted;
16915
+ };
16916
+
16917
+ // src/hooks/useForceUpdate.ts
16918
+ function useForceUpdate() {
16919
+ const update = useState()[1];
16920
+ const isMounted = useIsMounted();
16921
+ return () => {
16922
+ if (isMounted.current) {
16923
+ update(Math.random());
16924
+ }
16925
+ };
16926
+ }
16927
+ function useMemoOne(getResult, inputs) {
16928
+ const [initial] = useState(
16929
+ () => ({
16930
+ inputs,
16931
+ result: getResult()
16932
+ })
16933
+ );
16934
+ const committed = useRef();
16935
+ const prevCache = committed.current;
16936
+ let cache = prevCache;
16937
+ if (cache) {
16938
+ const useCache = Boolean(
16939
+ inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)
16940
+ );
16941
+ if (!useCache) {
16942
+ cache = {
16943
+ inputs,
16944
+ result: getResult()
16945
+ };
16946
+ }
16947
+ } else {
16948
+ cache = initial;
16949
+ }
16950
+ useEffect(() => {
16951
+ committed.current = cache;
16952
+ if (prevCache == initial) {
16953
+ initial.inputs = initial.result = void 0;
16954
+ }
16955
+ }, [cache]);
16956
+ return cache.result;
16957
+ }
16958
+ function areInputsEqual(next, prev) {
16959
+ if (next.length !== prev.length) {
16960
+ return false;
16961
+ }
16962
+ for (let i = 0; i < next.length; i++) {
16963
+ if (next[i] !== prev[i]) {
16964
+ return false;
16965
+ }
16966
+ }
16967
+ return true;
16968
+ }
16969
+ var useOnce = (effect) => useEffect(effect, emptyDeps);
16970
+ var emptyDeps = [];
16971
+ function usePrev(value) {
16972
+ const prevRef = useRef();
16973
+ useEffect(() => {
16974
+ prevRef.current = value;
16975
+ });
16976
+ return prevRef.current;
16977
+ }
16978
+
16979
+ // src/Animated.ts
16980
+ var $node = Symbol.for("Animated:node");
16981
+ var isAnimated = (value) => !!value && value[$node] === value;
16982
+ var getAnimated = (owner) => owner && owner[$node];
16983
+ var setAnimated = (owner, node) => defineHidden(owner, $node, node);
16984
+ var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
16985
+ var Animated = class {
16986
+ constructor() {
16987
+ setAnimated(this, this);
16988
+ }
16989
+ /** Get every `AnimatedValue` used by this node. */
16990
+ getPayload() {
16991
+ return this.payload || [];
16992
+ }
16993
+ };
16994
+ var AnimatedValue = class extends Animated {
16995
+ constructor(_value) {
16996
+ super();
16997
+ this._value = _value;
16998
+ this.done = true;
16999
+ this.durationProgress = 0;
17000
+ if (is.num(this._value)) {
17001
+ this.lastPosition = this._value;
17002
+ }
17003
+ }
17004
+ /** @internal */
17005
+ static create(value) {
17006
+ return new AnimatedValue(value);
17007
+ }
17008
+ getPayload() {
17009
+ return [this];
17010
+ }
17011
+ getValue() {
17012
+ return this._value;
17013
+ }
17014
+ setValue(value, step) {
17015
+ if (is.num(value)) {
17016
+ this.lastPosition = value;
17017
+ if (step) {
17018
+ value = Math.round(value / step) * step;
17019
+ if (this.done) {
17020
+ this.lastPosition = value;
17021
+ }
17022
+ }
17023
+ }
17024
+ if (this._value === value) {
17025
+ return false;
17026
+ }
17027
+ this._value = value;
17028
+ return true;
17029
+ }
17030
+ reset() {
17031
+ const { done } = this;
17032
+ this.done = false;
17033
+ if (is.num(this._value)) {
17034
+ this.elapsedTime = 0;
17035
+ this.durationProgress = 0;
17036
+ this.lastPosition = this._value;
17037
+ if (done)
17038
+ this.lastVelocity = null;
17039
+ this.v0 = null;
17040
+ }
17041
+ }
17042
+ };
17043
+ var AnimatedString = class extends AnimatedValue {
17044
+ constructor(value) {
17045
+ super(0);
17046
+ this._string = null;
17047
+ this._toString = createInterpolator({
17048
+ output: [value, value]
17049
+ });
17050
+ }
17051
+ /** @internal */
17052
+ static create(value) {
17053
+ return new AnimatedString(value);
17054
+ }
17055
+ getValue() {
17056
+ const value = this._string;
17057
+ return value == null ? this._string = this._toString(this._value) : value;
17058
+ }
17059
+ setValue(value) {
17060
+ if (is.str(value)) {
17061
+ if (value == this._string) {
17062
+ return false;
17063
+ }
17064
+ this._string = value;
17065
+ this._value = 1;
17066
+ } else if (super.setValue(value)) {
17067
+ this._string = null;
17068
+ } else {
17069
+ return false;
17070
+ }
17071
+ return true;
17072
+ }
17073
+ reset(goal) {
17074
+ if (goal) {
17075
+ this._toString = createInterpolator({
17076
+ output: [this.getValue(), goal]
17077
+ });
17078
+ }
17079
+ this._value = 0;
17080
+ super.reset();
17081
+ }
17082
+ };
17083
+
17084
+ // src/context.ts
17085
+ var TreeContext = { dependencies: null };
17086
+
17087
+ // src/AnimatedObject.ts
17088
+ var AnimatedObject = class extends Animated {
17089
+ constructor(source) {
17090
+ super();
17091
+ this.source = source;
17092
+ this.setValue(source);
17093
+ }
17094
+ getValue(animated) {
17095
+ const values = {};
17096
+ eachProp(this.source, (source, key) => {
17097
+ if (isAnimated(source)) {
17098
+ values[key] = source.getValue(animated);
17099
+ } else if (hasFluidValue(source)) {
17100
+ values[key] = getFluidValue(source);
17101
+ } else if (!animated) {
17102
+ values[key] = source;
17103
+ }
17104
+ });
17105
+ return values;
17106
+ }
17107
+ /** Replace the raw object data */
17108
+ setValue(source) {
17109
+ this.source = source;
17110
+ this.payload = this._makePayload(source);
17111
+ }
17112
+ reset() {
17113
+ if (this.payload) {
17114
+ each(this.payload, (node) => node.reset());
17115
+ }
17116
+ }
17117
+ /** Create a payload set. */
17118
+ _makePayload(source) {
17119
+ if (source) {
17120
+ const payload = /* @__PURE__ */ new Set();
17121
+ eachProp(source, this._addToPayload, payload);
17122
+ return Array.from(payload);
17123
+ }
17124
+ }
17125
+ /** Add to a payload set. */
17126
+ _addToPayload(source) {
17127
+ if (TreeContext.dependencies && hasFluidValue(source)) {
17128
+ TreeContext.dependencies.add(source);
17129
+ }
17130
+ const payload = getPayload(source);
17131
+ if (payload) {
17132
+ each(payload, (node) => this.add(node));
17133
+ }
17134
+ }
17135
+ };
17136
+
17137
+ // src/AnimatedArray.ts
17138
+ var AnimatedArray = class extends AnimatedObject {
17139
+ constructor(source) {
17140
+ super(source);
17141
+ }
17142
+ /** @internal */
17143
+ static create(source) {
17144
+ return new AnimatedArray(source);
17145
+ }
17146
+ getValue() {
17147
+ return this.source.map((node) => node.getValue());
17148
+ }
17149
+ setValue(source) {
17150
+ const payload = this.getPayload();
17151
+ if (source.length == payload.length) {
17152
+ return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
17153
+ }
17154
+ super.setValue(source.map(makeAnimated));
17155
+ return true;
17156
+ }
17157
+ };
17158
+ function makeAnimated(value) {
17159
+ const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
17160
+ return nodeType.create(value);
17161
+ }
17162
+ function getAnimatedType(value) {
17163
+ const parentNode = getAnimated(value);
17164
+ return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
17165
+ }
17166
+ var withAnimated = (Component, host) => {
17167
+ const hasInstance = (
17168
+ // Function components must use "forwardRef" to avoid being
17169
+ // re-rendered on every animation frame.
17170
+ !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent
17171
+ );
17172
+ return forwardRef((givenProps, givenRef) => {
17173
+ const instanceRef = useRef(null);
17174
+ const ref = hasInstance && // eslint-disable-next-line react-hooks/rules-of-hooks
17175
+ useCallback(
17176
+ (value) => {
17177
+ instanceRef.current = updateRef(givenRef, value);
17178
+ },
17179
+ [givenRef]
17180
+ );
17181
+ const [props, deps] = getAnimatedState(givenProps, host);
17182
+ const forceUpdate = useForceUpdate();
17183
+ const callback = () => {
17184
+ const instance = instanceRef.current;
17185
+ if (hasInstance && !instance) {
17186
+ return;
17187
+ }
17188
+ const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false;
17189
+ if (didUpdate === false) {
17190
+ forceUpdate();
17191
+ }
17192
+ };
17193
+ const observer = new PropsObserver(callback, deps);
17194
+ const observerRef = useRef();
17195
+ useIsomorphicLayoutEffect(() => {
17196
+ observerRef.current = observer;
17197
+ each(deps, (dep) => addFluidObserver(dep, observer));
17198
+ return () => {
17199
+ if (observerRef.current) {
17200
+ each(
17201
+ observerRef.current.deps,
17202
+ (dep) => removeFluidObserver(dep, observerRef.current)
17203
+ );
17204
+ raf.cancel(observerRef.current.update);
17205
+ }
17206
+ };
17207
+ });
17208
+ useEffect(callback, []);
17209
+ useOnce(() => () => {
17210
+ const observer2 = observerRef.current;
17211
+ each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
17212
+ });
17213
+ const usedProps = host.getComponentProps(props.getValue());
17214
+ return /* @__PURE__ */ React.createElement(Component, { ...usedProps, ref });
17215
+ });
17216
+ };
17217
+ var PropsObserver = class {
17218
+ constructor(update, deps) {
17219
+ this.update = update;
17220
+ this.deps = deps;
17221
+ }
17222
+ eventObserved(event) {
17223
+ if (event.type == "change") {
17224
+ raf.write(this.update);
17225
+ }
17226
+ }
17227
+ };
17228
+ function getAnimatedState(props, host) {
17229
+ const dependencies = /* @__PURE__ */ new Set();
17230
+ TreeContext.dependencies = dependencies;
17231
+ if (props.style)
17232
+ props = {
17233
+ ...props,
17234
+ style: host.createAnimatedStyle(props.style)
17235
+ };
17236
+ props = new AnimatedObject(props);
17237
+ TreeContext.dependencies = null;
17238
+ return [props, dependencies];
17239
+ }
17240
+ function updateRef(ref, value) {
17241
+ if (ref) {
17242
+ if (is.fun(ref))
17243
+ ref(value);
17244
+ else
17245
+ ref.current = value;
17246
+ }
17247
+ return value;
17248
+ }
17249
+
17250
+ // src/createHost.ts
17251
+ var cacheKey = Symbol.for("AnimatedComponent");
17252
+ var createHost = (components, {
17253
+ applyAnimatedValues = () => false,
17254
+ createAnimatedStyle = (style) => new AnimatedObject(style),
17255
+ getComponentProps = (props) => props
17256
+ } = {}) => {
17257
+ const hostConfig = {
17258
+ applyAnimatedValues,
17259
+ createAnimatedStyle,
17260
+ getComponentProps
17261
+ };
17262
+ const animated = (Component) => {
17263
+ const displayName = getDisplayName(Component) || "Anonymous";
17264
+ if (is.str(Component)) {
17265
+ Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig));
17266
+ } else {
17267
+ Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
17268
+ }
17269
+ Component.displayName = `Animated(${displayName})`;
17270
+ return Component;
17271
+ };
17272
+ eachProp(components, (Component, key) => {
17273
+ if (is.arr(components)) {
17274
+ key = getDisplayName(Component);
17275
+ }
17276
+ animated[key] = animated(Component);
17277
+ });
17278
+ return {
17279
+ animated
17280
+ };
17281
+ };
17282
+ var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
17283
+
17284
+ // src/hooks/useChain.ts
17285
+ function callProp(value, ...args) {
17286
+ return is.fun(value) ? value(...args) : value;
17287
+ }
17288
+ var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key)));
17289
+ var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop;
17290
+ var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0;
17291
+ var noopTransform = (value) => value;
17292
+ var getDefaultProps = (props, transform = noopTransform) => {
17293
+ let keys = DEFAULT_PROPS;
17294
+ if (props.default && props.default !== true) {
17295
+ props = props.default;
17296
+ keys = Object.keys(props);
17297
+ }
17298
+ const defaults2 = {};
17299
+ for (const key of keys) {
17300
+ const value = transform(props[key], key);
17301
+ if (!is.und(value)) {
17302
+ defaults2[key] = value;
17303
+ }
17304
+ }
17305
+ return defaults2;
17306
+ };
17307
+ var DEFAULT_PROPS = [
17308
+ "config",
17309
+ "onProps",
17310
+ "onStart",
17311
+ "onChange",
17312
+ "onPause",
17313
+ "onResume",
17314
+ "onRest"
17315
+ ];
17316
+ var RESERVED_PROPS = {
17317
+ config: 1,
17318
+ from: 1,
17319
+ to: 1,
17320
+ ref: 1,
17321
+ loop: 1,
17322
+ reset: 1,
17323
+ pause: 1,
17324
+ cancel: 1,
17325
+ reverse: 1,
17326
+ immediate: 1,
17327
+ default: 1,
17328
+ delay: 1,
17329
+ onProps: 1,
17330
+ onStart: 1,
17331
+ onChange: 1,
17332
+ onPause: 1,
17333
+ onResume: 1,
17334
+ onRest: 1,
17335
+ onResolve: 1,
17336
+ // Transition props
17337
+ items: 1,
17338
+ trail: 1,
17339
+ sort: 1,
17340
+ expires: 1,
17341
+ initial: 1,
17342
+ enter: 1,
17343
+ update: 1,
17344
+ leave: 1,
17345
+ children: 1,
17346
+ onDestroyed: 1,
17347
+ // Internal props
17348
+ keys: 1,
17349
+ callId: 1,
17350
+ parentId: 1
17351
+ };
17352
+ function getForwardProps(props) {
17353
+ const forward = {};
17354
+ let count = 0;
17355
+ eachProp(props, (value, prop) => {
17356
+ if (!RESERVED_PROPS[prop]) {
17357
+ forward[prop] = value;
17358
+ count++;
17359
+ }
17360
+ });
17361
+ if (count) {
17362
+ return forward;
17363
+ }
17364
+ }
17365
+ function inferTo(props) {
17366
+ const to2 = getForwardProps(props);
17367
+ if (to2) {
17368
+ const out = { to: to2 };
17369
+ eachProp(props, (val, key) => key in to2 || (out[key] = val));
17370
+ return out;
17371
+ }
17372
+ return { ...props };
17373
+ }
17374
+ function computeGoal(value) {
17375
+ value = getFluidValue(value);
17376
+ return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals_exports.createStringInterpolator({
17377
+ range: [0, 1],
17378
+ output: [value, value]
17379
+ })(1) : value;
17380
+ }
17381
+ function hasProps(props) {
17382
+ for (const _ in props)
17383
+ return true;
17384
+ return false;
17385
+ }
17386
+ function isAsyncTo(to2) {
17387
+ return is.fun(to2) || is.arr(to2) && is.obj(to2[0]);
17388
+ }
17389
+ function detachRefs(ctrl, ref) {
17390
+ ctrl.ref?.delete(ctrl);
17391
+ ref?.delete(ctrl);
17392
+ }
17393
+ function replaceRef(ctrl, ref) {
17394
+ if (ref && ctrl.ref !== ref) {
17395
+ ctrl.ref?.delete(ctrl);
17396
+ ref.add(ctrl);
17397
+ ctrl.ref = ref;
17398
+ }
17399
+ }
17400
+
17401
+ // src/constants.ts
17402
+ var config = {
17403
+ default: { tension: 170, friction: 26 },
17404
+ gentle: { tension: 120, friction: 14 },
17405
+ wobbly: { tension: 180, friction: 12 },
17406
+ stiff: { tension: 210, friction: 20 },
17407
+ slow: { tension: 280, friction: 60 },
17408
+ molasses: { tension: 280, friction: 120 }
17409
+ };
17410
+
17411
+ // src/AnimationConfig.ts
17412
+ var defaults = {
17413
+ ...config.default,
17414
+ mass: 1,
17415
+ damping: 1,
17416
+ easing: easings.linear,
17417
+ clamp: false
17418
+ };
17419
+ var AnimationConfig = class {
17420
+ constructor() {
17421
+ /**
17422
+ * The initial velocity of one or more values.
17423
+ *
17424
+ * @default 0
17425
+ */
17426
+ this.velocity = 0;
17427
+ Object.assign(this, defaults);
17428
+ }
17429
+ };
17430
+ function mergeConfig(config2, newConfig, defaultConfig) {
17431
+ if (defaultConfig) {
17432
+ defaultConfig = { ...defaultConfig };
17433
+ sanitizeConfig(defaultConfig, newConfig);
17434
+ newConfig = { ...defaultConfig, ...newConfig };
17435
+ }
17436
+ sanitizeConfig(config2, newConfig);
17437
+ Object.assign(config2, newConfig);
17438
+ for (const key in defaults) {
17439
+ if (config2[key] == null) {
17440
+ config2[key] = defaults[key];
17441
+ }
17442
+ }
17443
+ let { frequency, damping } = config2;
17444
+ const { mass } = config2;
17445
+ if (!is.und(frequency)) {
17446
+ if (frequency < 0.01)
17447
+ frequency = 0.01;
17448
+ if (damping < 0)
17449
+ damping = 0;
17450
+ config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass;
17451
+ config2.friction = 4 * Math.PI * damping * mass / frequency;
17452
+ }
17453
+ return config2;
17454
+ }
17455
+ function sanitizeConfig(config2, props) {
17456
+ if (!is.und(props.decay)) {
17457
+ config2.duration = void 0;
17458
+ } else {
17459
+ const isTensionConfig = !is.und(props.tension) || !is.und(props.friction);
17460
+ if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) {
17461
+ config2.duration = void 0;
17462
+ config2.decay = void 0;
17463
+ }
17464
+ if (isTensionConfig) {
17465
+ config2.frequency = void 0;
17466
+ }
17467
+ }
17468
+ }
17469
+
17470
+ // src/Animation.ts
17471
+ var emptyArray = [];
17472
+ var Animation = class {
17473
+ constructor() {
17474
+ this.changed = false;
17475
+ this.values = emptyArray;
17476
+ this.toValues = null;
17477
+ this.fromValues = emptyArray;
17478
+ this.config = new AnimationConfig();
17479
+ this.immediate = false;
17480
+ }
17481
+ };
17482
+ function scheduleProps(callId, { key, props, defaultProps, state, actions }) {
17483
+ return new Promise((resolve, reject) => {
17484
+ let delay;
17485
+ let timeout;
17486
+ let cancel = matchProp(props.cancel ?? defaultProps?.cancel, key);
17487
+ if (cancel) {
17488
+ onStart();
17489
+ } else {
17490
+ if (!is.und(props.pause)) {
17491
+ state.paused = matchProp(props.pause, key);
17492
+ }
17493
+ let pause = defaultProps?.pause;
17494
+ if (pause !== true) {
17495
+ pause = state.paused || matchProp(pause, key);
17496
+ }
17497
+ delay = callProp(props.delay || 0, key);
17498
+ if (pause) {
17499
+ state.resumeQueue.add(onResume);
17500
+ actions.pause();
17501
+ } else {
17502
+ actions.resume();
17503
+ onResume();
17504
+ }
17505
+ }
17506
+ function onPause() {
17507
+ state.resumeQueue.add(onResume);
17508
+ state.timeouts.delete(timeout);
17509
+ timeout.cancel();
17510
+ delay = timeout.time - raf.now();
17511
+ }
17512
+ function onResume() {
17513
+ if (delay > 0 && !globals_exports.skipAnimation) {
17514
+ state.delayed = true;
17515
+ timeout = raf.setTimeout(onStart, delay);
17516
+ state.pauseQueue.add(onPause);
17517
+ state.timeouts.add(timeout);
17518
+ } else {
17519
+ onStart();
17520
+ }
17521
+ }
17522
+ function onStart() {
17523
+ if (state.delayed) {
17524
+ state.delayed = false;
17525
+ }
17526
+ state.pauseQueue.delete(onPause);
17527
+ state.timeouts.delete(timeout);
17528
+ if (callId <= (state.cancelId || 0)) {
17529
+ cancel = true;
17530
+ }
17531
+ try {
17532
+ actions.start({ ...props, callId, cancel }, resolve);
17533
+ } catch (err) {
17534
+ reject(err);
17535
+ }
17536
+ }
17537
+ });
17538
+ }
17539
+
17540
+ // src/AnimationResult.ts
17541
+ var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(
17542
+ target.get(),
17543
+ results.every((result) => result.finished)
17544
+ );
17545
+ var getNoopResult = (value) => ({
17546
+ value,
17547
+ noop: true,
17548
+ finished: true,
17549
+ cancelled: false
17550
+ });
17551
+ var getFinishedResult = (value, finished, cancelled = false) => ({
17552
+ value,
17553
+ finished,
17554
+ cancelled
17555
+ });
17556
+ var getCancelledResult = (value) => ({
17557
+ value,
17558
+ cancelled: true,
17559
+ finished: false
17560
+ });
17561
+
17562
+ // src/runAsync.ts
17563
+ function runAsync(to2, props, state, target) {
17564
+ const { callId, parentId, onRest } = props;
17565
+ const { asyncTo: prevTo, promise: prevPromise } = state;
17566
+ if (!parentId && to2 === prevTo && !props.reset) {
17567
+ return prevPromise;
17568
+ }
17569
+ return state.promise = (async () => {
17570
+ state.asyncId = callId;
17571
+ state.asyncTo = to2;
17572
+ const defaultProps = getDefaultProps(
17573
+ props,
17574
+ (value, key) => (
17575
+ // The `onRest` prop is only called when the `runAsync` promise is resolved.
17576
+ key === "onRest" ? void 0 : value
17577
+ )
17578
+ );
17579
+ let preventBail;
17580
+ let bail;
17581
+ const bailPromise = new Promise(
17582
+ (resolve, reject) => (preventBail = resolve, bail = reject)
17583
+ );
17584
+ const bailIfEnded = (bailSignal) => {
17585
+ const bailResult = (
17586
+ // The `cancel` prop or `stop` method was used.
17587
+ callId <= (state.cancelId || 0) && getCancelledResult(target) || // The async `to` prop was replaced.
17588
+ callId !== state.asyncId && getFinishedResult(target, false)
17589
+ );
17590
+ if (bailResult) {
17591
+ bailSignal.result = bailResult;
17592
+ bail(bailSignal);
17593
+ throw bailSignal;
17594
+ }
17595
+ };
17596
+ const animate = (arg1, arg2) => {
17597
+ const bailSignal = new BailSignal();
17598
+ const skipAnimationSignal = new SkipAnimationSignal();
17599
+ return (async () => {
17600
+ if (globals_exports.skipAnimation) {
17601
+ stopAsync(state);
17602
+ skipAnimationSignal.result = getFinishedResult(target, false);
17603
+ bail(skipAnimationSignal);
17604
+ throw skipAnimationSignal;
17605
+ }
17606
+ bailIfEnded(bailSignal);
17607
+ const props2 = is.obj(arg1) ? { ...arg1 } : { ...arg2, to: arg1 };
17608
+ props2.parentId = callId;
17609
+ eachProp(defaultProps, (value, key) => {
17610
+ if (is.und(props2[key])) {
17611
+ props2[key] = value;
17612
+ }
17613
+ });
17614
+ const result2 = await target.start(props2);
17615
+ bailIfEnded(bailSignal);
17616
+ if (state.paused) {
17617
+ await new Promise((resume) => {
17618
+ state.resumeQueue.add(resume);
17619
+ });
17620
+ }
17621
+ return result2;
17622
+ })();
17623
+ };
17624
+ let result;
17625
+ if (globals_exports.skipAnimation) {
17626
+ stopAsync(state);
17627
+ return getFinishedResult(target, false);
17628
+ }
17629
+ try {
17630
+ let animating;
17631
+ if (is.arr(to2)) {
17632
+ animating = (async (queue) => {
17633
+ for (const props2 of queue) {
17634
+ await animate(props2);
17635
+ }
17636
+ })(to2);
17637
+ } else {
17638
+ animating = Promise.resolve(to2(animate, target.stop.bind(target)));
17639
+ }
17640
+ await Promise.all([animating.then(preventBail), bailPromise]);
17641
+ result = getFinishedResult(target.get(), true, false);
17642
+ } catch (err) {
17643
+ if (err instanceof BailSignal) {
17644
+ result = err.result;
17645
+ } else if (err instanceof SkipAnimationSignal) {
17646
+ result = err.result;
17647
+ } else {
17648
+ throw err;
17649
+ }
17650
+ } finally {
17651
+ if (callId == state.asyncId) {
17652
+ state.asyncId = parentId;
17653
+ state.asyncTo = parentId ? prevTo : void 0;
17654
+ state.promise = parentId ? prevPromise : void 0;
17655
+ }
17656
+ }
17657
+ if (is.fun(onRest)) {
17658
+ raf.batchedUpdates(() => {
17659
+ onRest(result, target, target.item);
17660
+ });
17661
+ }
17662
+ return result;
17663
+ })();
17664
+ }
17665
+ function stopAsync(state, cancelId) {
17666
+ flush(state.timeouts, (t) => t.cancel());
17667
+ state.pauseQueue.clear();
17668
+ state.resumeQueue.clear();
17669
+ state.asyncId = state.asyncTo = state.promise = void 0;
17670
+ if (cancelId)
17671
+ state.cancelId = cancelId;
17672
+ }
17673
+ var BailSignal = class extends Error {
17674
+ constructor() {
17675
+ super(
17676
+ "An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."
17677
+ );
17678
+ }
17679
+ };
17680
+ var SkipAnimationSignal = class extends Error {
17681
+ constructor() {
17682
+ super("SkipAnimationSignal");
17683
+ }
17684
+ };
17685
+ var isFrameValue = (value) => value instanceof FrameValue;
17686
+ var nextId = 1;
17687
+ var FrameValue = class extends FluidValue {
17688
+ constructor() {
17689
+ super(...arguments);
17690
+ this.id = nextId++;
17691
+ this._priority = 0;
17692
+ }
17693
+ get priority() {
17694
+ return this._priority;
17695
+ }
17696
+ set priority(priority) {
17697
+ if (this._priority != priority) {
17698
+ this._priority = priority;
17699
+ this._onPriorityChange(priority);
17700
+ }
17701
+ }
17702
+ /** Get the current value */
17703
+ get() {
17704
+ const node = getAnimated(this);
17705
+ return node && node.getValue();
17706
+ }
17707
+ /** Create a spring that maps our value to another value */
17708
+ to(...args) {
17709
+ return globals_exports.to(this, args);
17710
+ }
17711
+ /** @deprecated Use the `to` method instead. */
17712
+ interpolate(...args) {
17713
+ deprecateInterpolate();
17714
+ return globals_exports.to(this, args);
17715
+ }
17716
+ toJSON() {
17717
+ return this.get();
17718
+ }
17719
+ observerAdded(count) {
17720
+ if (count == 1)
17721
+ this._attach();
17722
+ }
17723
+ observerRemoved(count) {
17724
+ if (count == 0)
17725
+ this._detach();
17726
+ }
17727
+ /** Called when the first child is added. */
17728
+ _attach() {
17729
+ }
17730
+ /** Called when the last child is removed. */
17731
+ _detach() {
17732
+ }
17733
+ /** Tell our children about our new value */
17734
+ _onChange(value, idle = false) {
17735
+ callFluidObservers(this, {
17736
+ type: "change",
17737
+ parent: this,
17738
+ value,
17739
+ idle
17740
+ });
17741
+ }
17742
+ /** Tell our children about our new priority */
17743
+ _onPriorityChange(priority) {
17744
+ if (!this.idle) {
17745
+ frameLoop.sort(this);
17746
+ }
17747
+ callFluidObservers(this, {
17748
+ type: "priority",
17749
+ parent: this,
17750
+ priority
17751
+ });
17752
+ }
17753
+ };
17754
+
17755
+ // src/SpringPhase.ts
17756
+ var $P = Symbol.for("SpringPhase");
17757
+ var HAS_ANIMATED = 1;
17758
+ var IS_ANIMATING = 2;
17759
+ var IS_PAUSED = 4;
17760
+ var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0;
17761
+ var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0;
17762
+ var isPaused = (target) => (target[$P] & IS_PAUSED) > 0;
17763
+ var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING;
17764
+ var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED;
17765
+
17766
+ // src/SpringValue.ts
17767
+ var SpringValue = class extends FrameValue {
17768
+ constructor(arg1, arg2) {
17769
+ super();
17770
+ /** The animation state */
17771
+ this.animation = new Animation();
17772
+ /** Some props have customizable default values */
17773
+ this.defaultProps = {};
17774
+ /** The state for `runAsync` calls */
17775
+ this._state = {
17776
+ paused: false,
17777
+ delayed: false,
17778
+ pauseQueue: /* @__PURE__ */ new Set(),
17779
+ resumeQueue: /* @__PURE__ */ new Set(),
17780
+ timeouts: /* @__PURE__ */ new Set()
17781
+ };
17782
+ /** The promise resolvers of pending `start` calls */
17783
+ this._pendingCalls = /* @__PURE__ */ new Set();
17784
+ /** The counter for tracking `scheduleProps` calls */
17785
+ this._lastCallId = 0;
17786
+ /** The last `scheduleProps` call that changed the `to` prop */
17787
+ this._lastToId = 0;
17788
+ this._memoizedDuration = 0;
17789
+ if (!is.und(arg1) || !is.und(arg2)) {
17790
+ const props = is.obj(arg1) ? { ...arg1 } : { ...arg2, from: arg1 };
17791
+ if (is.und(props.default)) {
17792
+ props.default = true;
17793
+ }
17794
+ this.start(props);
17795
+ }
17796
+ }
17797
+ /** Equals true when not advancing on each frame. */
17798
+ get idle() {
17799
+ return !(isAnimating(this) || this._state.asyncTo) || isPaused(this);
17800
+ }
17801
+ get goal() {
17802
+ return getFluidValue(this.animation.to);
17803
+ }
17804
+ get velocity() {
17805
+ const node = getAnimated(this);
17806
+ return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0);
17807
+ }
17808
+ /**
17809
+ * When true, this value has been animated at least once.
17810
+ */
17811
+ get hasAnimated() {
17812
+ return hasAnimated(this);
17813
+ }
17814
+ /**
17815
+ * When true, this value has an unfinished animation,
17816
+ * which is either active or paused.
17817
+ */
17818
+ get isAnimating() {
17819
+ return isAnimating(this);
17820
+ }
17821
+ /**
17822
+ * When true, all current and future animations are paused.
17823
+ */
17824
+ get isPaused() {
17825
+ return isPaused(this);
17826
+ }
17827
+ /**
17828
+ *
17829
+ *
17830
+ */
17831
+ get isDelayed() {
17832
+ return this._state.delayed;
17833
+ }
17834
+ /** Advance the current animation by a number of milliseconds */
17835
+ advance(dt) {
17836
+ let idle = true;
17837
+ let changed = false;
17838
+ const anim = this.animation;
17839
+ let { toValues } = anim;
17840
+ const { config: config2 } = anim;
17841
+ const payload = getPayload(anim.to);
17842
+ if (!payload && hasFluidValue(anim.to)) {
17843
+ toValues = toArray(getFluidValue(anim.to));
17844
+ }
17845
+ anim.values.forEach((node2, i) => {
17846
+ if (node2.done)
17847
+ return;
17848
+ const to2 = (
17849
+ // Animated strings always go from 0 to 1.
17850
+ node2.constructor == AnimatedString ? 1 : payload ? payload[i].lastPosition : toValues[i]
17851
+ );
17852
+ let finished = anim.immediate;
17853
+ let position = to2;
17854
+ if (!finished) {
17855
+ position = node2.lastPosition;
17856
+ if (config2.tension <= 0) {
17857
+ node2.done = true;
17858
+ return;
17859
+ }
17860
+ let elapsed = node2.elapsedTime += dt;
17861
+ const from = anim.fromValues[i];
17862
+ const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i] : config2.velocity;
17863
+ let velocity;
17864
+ const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3));
17865
+ if (!is.und(config2.duration)) {
17866
+ let p = 1;
17867
+ if (config2.duration > 0) {
17868
+ if (this._memoizedDuration !== config2.duration) {
17869
+ this._memoizedDuration = config2.duration;
17870
+ if (node2.durationProgress > 0) {
17871
+ node2.elapsedTime = config2.duration * node2.durationProgress;
17872
+ elapsed = node2.elapsedTime += dt;
17873
+ }
17874
+ }
17875
+ p = (config2.progress || 0) + elapsed / this._memoizedDuration;
17876
+ p = p > 1 ? 1 : p < 0 ? 0 : p;
17877
+ node2.durationProgress = p;
17878
+ }
17879
+ position = from + config2.easing(p) * (to2 - from);
17880
+ velocity = (position - node2.lastPosition) / dt;
17881
+ finished = p == 1;
17882
+ } else if (config2.decay) {
17883
+ const decay = config2.decay === true ? 0.998 : config2.decay;
17884
+ const e = Math.exp(-(1 - decay) * elapsed);
17885
+ position = from + v0 / (1 - decay) * (1 - e);
17886
+ finished = Math.abs(node2.lastPosition - position) <= precision;
17887
+ velocity = v0 * e;
17888
+ } else {
17889
+ velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity;
17890
+ const restVelocity = config2.restVelocity || precision / 10;
17891
+ const bounceFactor = config2.clamp ? 0 : config2.bounce;
17892
+ const canBounce = !is.und(bounceFactor);
17893
+ const isGrowing = from == to2 ? node2.v0 > 0 : from < to2;
17894
+ let isMoving;
17895
+ let isBouncing = false;
17896
+ const step = 1;
17897
+ const numSteps = Math.ceil(dt / step);
17898
+ for (let n = 0; n < numSteps; ++n) {
17899
+ isMoving = Math.abs(velocity) > restVelocity;
17900
+ if (!isMoving) {
17901
+ finished = Math.abs(to2 - position) <= precision;
17902
+ if (finished) {
17903
+ break;
17904
+ }
17905
+ }
17906
+ if (canBounce) {
17907
+ isBouncing = position == to2 || position > to2 == isGrowing;
17908
+ if (isBouncing) {
17909
+ velocity = -velocity * bounceFactor;
17910
+ position = to2;
17911
+ }
17912
+ }
17913
+ const springForce = -config2.tension * 1e-6 * (position - to2);
17914
+ const dampingForce = -config2.friction * 1e-3 * velocity;
17915
+ const acceleration = (springForce + dampingForce) / config2.mass;
17916
+ velocity = velocity + acceleration * step;
17917
+ position = position + velocity * step;
17918
+ }
17919
+ }
17920
+ node2.lastVelocity = velocity;
17921
+ if (Number.isNaN(position)) {
17922
+ console.warn(`Got NaN while animating:`, this);
17923
+ finished = true;
17924
+ }
17925
+ }
17926
+ if (payload && !payload[i].done) {
17927
+ finished = false;
17928
+ }
17929
+ if (finished) {
17930
+ node2.done = true;
17931
+ } else {
17932
+ idle = false;
17933
+ }
17934
+ if (node2.setValue(position, config2.round)) {
17935
+ changed = true;
17936
+ }
17937
+ });
17938
+ const node = getAnimated(this);
17939
+ const currVal = node.getValue();
17940
+ if (idle) {
17941
+ const finalVal = getFluidValue(anim.to);
17942
+ if ((currVal !== finalVal || changed) && !config2.decay) {
17943
+ node.setValue(finalVal);
17944
+ this._onChange(finalVal);
17945
+ } else if (changed && config2.decay) {
17946
+ this._onChange(currVal);
17947
+ }
17948
+ this._stop();
17949
+ } else if (changed) {
17950
+ this._onChange(currVal);
17951
+ }
17952
+ }
17953
+ /** Set the current value, while stopping the current animation */
17954
+ set(value) {
17955
+ raf.batchedUpdates(() => {
17956
+ this._stop();
17957
+ this._focus(value);
17958
+ this._set(value);
17959
+ });
17960
+ return this;
17961
+ }
17962
+ /**
17963
+ * Freeze the active animation in time, as well as any updates merged
17964
+ * before `resume` is called.
17965
+ */
17966
+ pause() {
17967
+ this._update({ pause: true });
17968
+ }
17969
+ /** Resume the animation if paused. */
17970
+ resume() {
17971
+ this._update({ pause: false });
17972
+ }
17973
+ /** Skip to the end of the current animation. */
17974
+ finish() {
17975
+ if (isAnimating(this)) {
17976
+ const { to: to2, config: config2 } = this.animation;
17977
+ raf.batchedUpdates(() => {
17978
+ this._onStart();
17979
+ if (!config2.decay) {
17980
+ this._set(to2, false);
17981
+ }
17982
+ this._stop();
17983
+ });
17984
+ }
17985
+ return this;
17986
+ }
17987
+ /** Push props into the pending queue. */
17988
+ update(props) {
17989
+ const queue = this.queue || (this.queue = []);
17990
+ queue.push(props);
17991
+ return this;
17992
+ }
17993
+ start(to2, arg2) {
17994
+ let queue;
17995
+ if (!is.und(to2)) {
17996
+ queue = [is.obj(to2) ? to2 : { ...arg2, to: to2 }];
17997
+ } else {
17998
+ queue = this.queue || [];
17999
+ this.queue = [];
18000
+ }
18001
+ return Promise.all(
18002
+ queue.map((props) => {
18003
+ const up = this._update(props);
18004
+ return up;
18005
+ })
18006
+ ).then((results) => getCombinedResult(this, results));
18007
+ }
18008
+ /**
18009
+ * Stop the current animation, and cancel any delayed updates.
18010
+ *
18011
+ * Pass `true` to call `onRest` with `cancelled: true`.
18012
+ */
18013
+ stop(cancel) {
18014
+ const { to: to2 } = this.animation;
18015
+ this._focus(this.get());
18016
+ stopAsync(this._state, cancel && this._lastCallId);
18017
+ raf.batchedUpdates(() => this._stop(to2, cancel));
18018
+ return this;
18019
+ }
18020
+ /** Restart the animation. */
18021
+ reset() {
18022
+ this._update({ reset: true });
18023
+ }
18024
+ /** @internal */
18025
+ eventObserved(event) {
18026
+ if (event.type == "change") {
18027
+ this._start();
18028
+ } else if (event.type == "priority") {
18029
+ this.priority = event.priority + 1;
18030
+ }
18031
+ }
18032
+ /**
18033
+ * Parse the `to` and `from` range from the given `props` object.
18034
+ *
18035
+ * This also ensures the initial value is available to animated components
18036
+ * during the render phase.
18037
+ */
18038
+ _prepareNode(props) {
18039
+ const key = this.key || "";
18040
+ let { to: to2, from } = props;
18041
+ to2 = is.obj(to2) ? to2[key] : to2;
18042
+ if (to2 == null || isAsyncTo(to2)) {
18043
+ to2 = void 0;
18044
+ }
18045
+ from = is.obj(from) ? from[key] : from;
18046
+ if (from == null) {
18047
+ from = void 0;
18048
+ }
18049
+ const range = { to: to2, from };
18050
+ if (!hasAnimated(this)) {
18051
+ if (props.reverse)
18052
+ [to2, from] = [from, to2];
18053
+ from = getFluidValue(from);
18054
+ if (!is.und(from)) {
18055
+ this._set(from);
18056
+ } else if (!getAnimated(this)) {
18057
+ this._set(to2);
18058
+ }
18059
+ }
18060
+ return range;
18061
+ }
18062
+ /** Every update is processed by this method before merging. */
18063
+ _update({ ...props }, isLoop) {
18064
+ const { key, defaultProps } = this;
18065
+ if (props.default)
18066
+ Object.assign(
18067
+ defaultProps,
18068
+ getDefaultProps(
18069
+ props,
18070
+ (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value
18071
+ )
18072
+ );
18073
+ mergeActiveFn(this, props, "onProps");
18074
+ sendEvent(this, "onProps", props, this);
18075
+ const range = this._prepareNode(props);
18076
+ if (Object.isFrozen(this)) {
18077
+ throw Error(
18078
+ "Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"
18079
+ );
18080
+ }
18081
+ const state = this._state;
18082
+ return scheduleProps(++this._lastCallId, {
18083
+ key,
18084
+ props,
18085
+ defaultProps,
18086
+ state,
18087
+ actions: {
18088
+ pause: () => {
18089
+ if (!isPaused(this)) {
18090
+ setPausedBit(this, true);
18091
+ flushCalls(state.pauseQueue);
18092
+ sendEvent(
18093
+ this,
18094
+ "onPause",
18095
+ getFinishedResult(this, checkFinished(this, this.animation.to)),
18096
+ this
18097
+ );
18098
+ }
18099
+ },
18100
+ resume: () => {
18101
+ if (isPaused(this)) {
18102
+ setPausedBit(this, false);
18103
+ if (isAnimating(this)) {
18104
+ this._resume();
18105
+ }
18106
+ flushCalls(state.resumeQueue);
18107
+ sendEvent(
18108
+ this,
18109
+ "onResume",
18110
+ getFinishedResult(this, checkFinished(this, this.animation.to)),
18111
+ this
18112
+ );
18113
+ }
18114
+ },
18115
+ start: this._merge.bind(this, range)
18116
+ }
18117
+ }).then((result) => {
18118
+ if (props.loop && result.finished && !(isLoop && result.noop)) {
18119
+ const nextProps = createLoopUpdate(props);
18120
+ if (nextProps) {
18121
+ return this._update(nextProps, true);
18122
+ }
18123
+ }
18124
+ return result;
18125
+ });
18126
+ }
18127
+ /** Merge props into the current animation */
18128
+ _merge(range, props, resolve) {
18129
+ if (props.cancel) {
18130
+ this.stop(true);
18131
+ return resolve(getCancelledResult(this));
18132
+ }
18133
+ const hasToProp = !is.und(range.to);
18134
+ const hasFromProp = !is.und(range.from);
18135
+ if (hasToProp || hasFromProp) {
18136
+ if (props.callId > this._lastToId) {
18137
+ this._lastToId = props.callId;
18138
+ } else {
18139
+ return resolve(getCancelledResult(this));
18140
+ }
18141
+ }
18142
+ const { key, defaultProps, animation: anim } = this;
18143
+ const { to: prevTo, from: prevFrom } = anim;
18144
+ let { to: to2 = prevTo, from = prevFrom } = range;
18145
+ if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) {
18146
+ to2 = from;
18147
+ }
18148
+ if (props.reverse)
18149
+ [to2, from] = [from, to2];
18150
+ const hasFromChanged = !isEqual(from, prevFrom);
18151
+ if (hasFromChanged) {
18152
+ anim.from = from;
18153
+ }
18154
+ from = getFluidValue(from);
18155
+ const hasToChanged = !isEqual(to2, prevTo);
18156
+ if (hasToChanged) {
18157
+ this._focus(to2);
18158
+ }
18159
+ const hasAsyncTo = isAsyncTo(props.to);
18160
+ const { config: config2 } = anim;
18161
+ const { decay, velocity } = config2;
18162
+ if (hasToProp || hasFromProp) {
18163
+ config2.velocity = 0;
18164
+ }
18165
+ if (props.config && !hasAsyncTo) {
18166
+ mergeConfig(
18167
+ config2,
18168
+ callProp(props.config, key),
18169
+ // Avoid calling the same "config" prop twice.
18170
+ props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0
18171
+ );
18172
+ }
18173
+ let node = getAnimated(this);
18174
+ if (!node || is.und(to2)) {
18175
+ return resolve(getFinishedResult(this, true));
18176
+ }
18177
+ const reset = (
18178
+ // When `reset` is undefined, the `from` prop implies `reset: true`,
18179
+ // except for declarative updates. When `reset` is defined, there
18180
+ // must exist a value to animate from.
18181
+ is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key)
18182
+ );
18183
+ const value = reset ? from : this.get();
18184
+ const goal = computeGoal(to2);
18185
+ const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal);
18186
+ const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key));
18187
+ if (hasToChanged) {
18188
+ const nodeType = getAnimatedType(to2);
18189
+ if (nodeType !== node.constructor) {
18190
+ if (immediate) {
18191
+ node = this._set(goal);
18192
+ } else
18193
+ throw Error(
18194
+ `Cannot animate between ${node.constructor.name} and ${nodeType.name}, as the "to" prop suggests`
18195
+ );
18196
+ }
18197
+ }
18198
+ const goalType = node.constructor;
18199
+ let started = hasFluidValue(to2);
18200
+ let finished = false;
18201
+ if (!started) {
18202
+ const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged;
18203
+ if (hasToChanged || hasValueChanged) {
18204
+ finished = isEqual(computeGoal(value), goal);
18205
+ started = !finished;
18206
+ }
18207
+ if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) {
18208
+ started = true;
18209
+ }
18210
+ }
18211
+ if (finished && isAnimating(this)) {
18212
+ if (anim.changed && !reset) {
18213
+ started = true;
18214
+ } else if (!started) {
18215
+ this._stop(prevTo);
18216
+ }
18217
+ }
18218
+ if (!hasAsyncTo) {
18219
+ if (started || hasFluidValue(prevTo)) {
18220
+ anim.values = node.getPayload();
18221
+ anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal);
18222
+ }
18223
+ if (anim.immediate != immediate) {
18224
+ anim.immediate = immediate;
18225
+ if (!immediate && !reset) {
18226
+ this._set(prevTo);
18227
+ }
18228
+ }
18229
+ if (started) {
18230
+ const { onRest } = anim;
18231
+ each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type));
18232
+ const result = getFinishedResult(this, checkFinished(this, prevTo));
18233
+ flushCalls(this._pendingCalls, result);
18234
+ this._pendingCalls.add(resolve);
18235
+ if (anim.changed)
18236
+ raf.batchedUpdates(() => {
18237
+ anim.changed = !reset;
18238
+ onRest?.(result, this);
18239
+ if (reset) {
18240
+ callProp(defaultProps.onRest, result);
18241
+ } else {
18242
+ anim.onStart?.(result, this);
18243
+ }
18244
+ });
18245
+ }
18246
+ }
18247
+ if (reset) {
18248
+ this._set(value);
18249
+ }
18250
+ if (hasAsyncTo) {
18251
+ resolve(runAsync(props.to, props, this._state, this));
18252
+ } else if (started) {
18253
+ this._start();
18254
+ } else if (isAnimating(this) && !hasToChanged) {
18255
+ this._pendingCalls.add(resolve);
18256
+ } else {
18257
+ resolve(getNoopResult(value));
18258
+ }
18259
+ }
18260
+ /** Update the `animation.to` value, which might be a `FluidValue` */
18261
+ _focus(value) {
18262
+ const anim = this.animation;
18263
+ if (value !== anim.to) {
18264
+ if (getFluidObservers(this)) {
18265
+ this._detach();
18266
+ }
18267
+ anim.to = value;
18268
+ if (getFluidObservers(this)) {
18269
+ this._attach();
18270
+ }
18271
+ }
18272
+ }
18273
+ _attach() {
18274
+ let priority = 0;
18275
+ const { to: to2 } = this.animation;
18276
+ if (hasFluidValue(to2)) {
18277
+ addFluidObserver(to2, this);
18278
+ if (isFrameValue(to2)) {
18279
+ priority = to2.priority + 1;
18280
+ }
18281
+ }
18282
+ this.priority = priority;
18283
+ }
18284
+ _detach() {
18285
+ const { to: to2 } = this.animation;
18286
+ if (hasFluidValue(to2)) {
18287
+ removeFluidObserver(to2, this);
18288
+ }
18289
+ }
18290
+ /**
18291
+ * Update the current value from outside the frameloop,
18292
+ * and return the `Animated` node.
18293
+ */
18294
+ _set(arg, idle = true) {
18295
+ const value = getFluidValue(arg);
18296
+ if (!is.und(value)) {
18297
+ const oldNode = getAnimated(this);
18298
+ if (!oldNode || !isEqual(value, oldNode.getValue())) {
18299
+ const nodeType = getAnimatedType(value);
18300
+ if (!oldNode || oldNode.constructor != nodeType) {
18301
+ setAnimated(this, nodeType.create(value));
18302
+ } else {
18303
+ oldNode.setValue(value);
18304
+ }
18305
+ if (oldNode) {
18306
+ raf.batchedUpdates(() => {
18307
+ this._onChange(value, idle);
18308
+ });
18309
+ }
18310
+ }
18311
+ }
18312
+ return getAnimated(this);
18313
+ }
18314
+ _onStart() {
18315
+ const anim = this.animation;
18316
+ if (!anim.changed) {
18317
+ anim.changed = true;
18318
+ sendEvent(
18319
+ this,
18320
+ "onStart",
18321
+ getFinishedResult(this, checkFinished(this, anim.to)),
18322
+ this
18323
+ );
18324
+ }
18325
+ }
18326
+ _onChange(value, idle) {
18327
+ if (!idle) {
18328
+ this._onStart();
18329
+ callProp(this.animation.onChange, value, this);
18330
+ }
18331
+ callProp(this.defaultProps.onChange, value, this);
18332
+ super._onChange(value, idle);
18333
+ }
18334
+ // This method resets the animation state (even if already animating) to
18335
+ // ensure the latest from/to range is used, and it also ensures this spring
18336
+ // is added to the frameloop.
18337
+ _start() {
18338
+ const anim = this.animation;
18339
+ getAnimated(this).reset(getFluidValue(anim.to));
18340
+ if (!anim.immediate) {
18341
+ anim.fromValues = anim.values.map((node) => node.lastPosition);
18342
+ }
18343
+ if (!isAnimating(this)) {
18344
+ setActiveBit(this, true);
18345
+ if (!isPaused(this)) {
18346
+ this._resume();
18347
+ }
18348
+ }
18349
+ }
18350
+ _resume() {
18351
+ if (globals_exports.skipAnimation) {
18352
+ this.finish();
18353
+ } else {
18354
+ frameLoop.start(this);
18355
+ }
18356
+ }
18357
+ /**
18358
+ * Exit the frameloop and notify `onRest` listeners.
18359
+ *
18360
+ * Always wrap `_stop` calls with `batchedUpdates`.
18361
+ */
18362
+ _stop(goal, cancel) {
18363
+ if (isAnimating(this)) {
18364
+ setActiveBit(this, false);
18365
+ const anim = this.animation;
18366
+ each(anim.values, (node) => {
18367
+ node.done = true;
18368
+ });
18369
+ if (anim.toValues) {
18370
+ anim.onChange = anim.onPause = anim.onResume = void 0;
18371
+ }
18372
+ callFluidObservers(this, {
18373
+ type: "idle",
18374
+ parent: this
18375
+ });
18376
+ const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal ?? anim.to));
18377
+ flushCalls(this._pendingCalls, result);
18378
+ if (anim.changed) {
18379
+ anim.changed = false;
18380
+ sendEvent(this, "onRest", result, this);
18381
+ }
18382
+ }
18383
+ }
18384
+ };
18385
+ function checkFinished(target, to2) {
18386
+ const goal = computeGoal(to2);
18387
+ const value = computeGoal(target.get());
18388
+ return isEqual(value, goal);
18389
+ }
18390
+ function createLoopUpdate(props, loop = props.loop, to2 = props.to) {
18391
+ const loopRet = callProp(loop);
18392
+ if (loopRet) {
18393
+ const overrides = loopRet !== true && inferTo(loopRet);
18394
+ const reverse = (overrides || props).reverse;
18395
+ const reset = !overrides || overrides.reset;
18396
+ return createUpdate({
18397
+ ...props,
18398
+ loop,
18399
+ // Avoid updating default props when looping.
18400
+ default: false,
18401
+ // Never loop the `pause` prop.
18402
+ pause: void 0,
18403
+ // For the "reverse" prop to loop as expected, the "to" prop
18404
+ // must be undefined. The "reverse" prop is ignored when the
18405
+ // "to" prop is an array or function.
18406
+ to: !reverse || isAsyncTo(to2) ? to2 : void 0,
18407
+ // Ignore the "from" prop except on reset.
18408
+ from: reset ? props.from : void 0,
18409
+ reset,
18410
+ // The "loop" prop can return a "useSpring" props object to
18411
+ // override any of the original props.
18412
+ ...overrides
18413
+ });
18414
+ }
18415
+ }
18416
+ function createUpdate(props) {
18417
+ const { to: to2, from } = props = inferTo(props);
18418
+ const keys = /* @__PURE__ */ new Set();
18419
+ if (is.obj(to2))
18420
+ findDefined(to2, keys);
18421
+ if (is.obj(from))
18422
+ findDefined(from, keys);
18423
+ props.keys = keys.size ? Array.from(keys) : null;
18424
+ return props;
18425
+ }
18426
+ function declareUpdate(props) {
18427
+ const update2 = createUpdate(props);
18428
+ if (is.und(update2.default)) {
18429
+ update2.default = getDefaultProps(update2);
18430
+ }
18431
+ return update2;
18432
+ }
18433
+ function findDefined(values, keys) {
18434
+ eachProp(values, (value, key) => value != null && keys.add(key));
18435
+ }
18436
+ var ACTIVE_EVENTS = [
18437
+ "onStart",
18438
+ "onRest",
18439
+ "onChange",
18440
+ "onPause",
18441
+ "onResume"
18442
+ ];
18443
+ function mergeActiveFn(target, props, type) {
18444
+ target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0;
18445
+ }
18446
+ function sendEvent(target, type, ...args) {
18447
+ target.animation[type]?.(...args);
18448
+ target.defaultProps[type]?.(...args);
18449
+ }
18450
+ var BATCHED_EVENTS = ["onStart", "onChange", "onRest"];
18451
+ var nextId2 = 1;
18452
+ var Controller = class {
18453
+ constructor(props, flush3) {
18454
+ this.id = nextId2++;
18455
+ /** The animated values */
18456
+ this.springs = {};
18457
+ /** The queue of props passed to the `update` method. */
18458
+ this.queue = [];
18459
+ /** The counter for tracking `scheduleProps` calls */
18460
+ this._lastAsyncId = 0;
18461
+ /** The values currently being animated */
18462
+ this._active = /* @__PURE__ */ new Set();
18463
+ /** The values that changed recently */
18464
+ this._changed = /* @__PURE__ */ new Set();
18465
+ /** Equals false when `onStart` listeners can be called */
18466
+ this._started = false;
18467
+ /** State used by the `runAsync` function */
18468
+ this._state = {
18469
+ paused: false,
18470
+ pauseQueue: /* @__PURE__ */ new Set(),
18471
+ resumeQueue: /* @__PURE__ */ new Set(),
18472
+ timeouts: /* @__PURE__ */ new Set()
18473
+ };
18474
+ /** The event queues that are flushed once per frame maximum */
18475
+ this._events = {
18476
+ onStart: /* @__PURE__ */ new Map(),
18477
+ onChange: /* @__PURE__ */ new Map(),
18478
+ onRest: /* @__PURE__ */ new Map()
18479
+ };
18480
+ this._onFrame = this._onFrame.bind(this);
18481
+ if (flush3) {
18482
+ this._flush = flush3;
18483
+ }
18484
+ if (props) {
18485
+ this.start({ default: true, ...props });
18486
+ }
18487
+ }
18488
+ /**
18489
+ * Equals `true` when no spring values are in the frameloop, and
18490
+ * no async animation is currently active.
18491
+ */
18492
+ get idle() {
18493
+ return !this._state.asyncTo && Object.values(this.springs).every((spring) => {
18494
+ return spring.idle && !spring.isDelayed && !spring.isPaused;
18495
+ });
18496
+ }
18497
+ get item() {
18498
+ return this._item;
18499
+ }
18500
+ set item(item) {
18501
+ this._item = item;
18502
+ }
18503
+ /** Get the current values of our springs */
18504
+ get() {
18505
+ const values = {};
18506
+ this.each((spring, key) => values[key] = spring.get());
18507
+ return values;
18508
+ }
18509
+ /** Set the current values without animating. */
18510
+ set(values) {
18511
+ for (const key in values) {
18512
+ const value = values[key];
18513
+ if (!is.und(value)) {
18514
+ this.springs[key].set(value);
18515
+ }
18516
+ }
18517
+ }
18518
+ /** Push an update onto the queue of each value. */
18519
+ update(props) {
18520
+ if (props) {
18521
+ this.queue.push(createUpdate(props));
18522
+ }
18523
+ return this;
18524
+ }
18525
+ /**
18526
+ * Start the queued animations for every spring, and resolve the returned
18527
+ * promise once all queued animations have finished or been cancelled.
18528
+ *
18529
+ * When you pass a queue (instead of nothing), that queue is used instead of
18530
+ * the queued animations added with the `update` method, which are left alone.
18531
+ */
18532
+ start(props) {
18533
+ let { queue } = this;
18534
+ if (props) {
18535
+ queue = toArray(props).map(createUpdate);
18536
+ } else {
18537
+ this.queue = [];
18538
+ }
18539
+ if (this._flush) {
18540
+ return this._flush(this, queue);
18541
+ }
18542
+ prepareKeys(this, queue);
18543
+ return flushUpdateQueue(this, queue);
18544
+ }
18545
+ /** @internal */
18546
+ stop(arg, keys) {
18547
+ if (arg !== !!arg) {
18548
+ keys = arg;
18549
+ }
18550
+ if (keys) {
18551
+ const springs = this.springs;
18552
+ each(toArray(keys), (key) => springs[key].stop(!!arg));
18553
+ } else {
18554
+ stopAsync(this._state, this._lastAsyncId);
18555
+ this.each((spring) => spring.stop(!!arg));
18556
+ }
18557
+ return this;
18558
+ }
18559
+ /** Freeze the active animation in time */
18560
+ pause(keys) {
18561
+ if (is.und(keys)) {
18562
+ this.start({ pause: true });
18563
+ } else {
18564
+ const springs = this.springs;
18565
+ each(toArray(keys), (key) => springs[key].pause());
18566
+ }
18567
+ return this;
18568
+ }
18569
+ /** Resume the animation if paused. */
18570
+ resume(keys) {
18571
+ if (is.und(keys)) {
18572
+ this.start({ pause: false });
18573
+ } else {
18574
+ const springs = this.springs;
18575
+ each(toArray(keys), (key) => springs[key].resume());
18576
+ }
18577
+ return this;
18578
+ }
18579
+ /** Call a function once per spring value */
18580
+ each(iterator) {
18581
+ eachProp(this.springs, iterator);
18582
+ }
18583
+ /** @internal Called at the end of every animation frame */
18584
+ _onFrame() {
18585
+ const { onStart, onChange, onRest } = this._events;
18586
+ const active = this._active.size > 0;
18587
+ const changed = this._changed.size > 0;
18588
+ if (active && !this._started || changed && !this._started) {
18589
+ this._started = true;
18590
+ flush(onStart, ([onStart2, result]) => {
18591
+ result.value = this.get();
18592
+ onStart2(result, this, this._item);
18593
+ });
18594
+ }
18595
+ const idle = !active && this._started;
18596
+ const values = changed || idle && onRest.size ? this.get() : null;
18597
+ if (changed && onChange.size) {
18598
+ flush(onChange, ([onChange2, result]) => {
18599
+ result.value = values;
18600
+ onChange2(result, this, this._item);
18601
+ });
18602
+ }
18603
+ if (idle) {
18604
+ this._started = false;
18605
+ flush(onRest, ([onRest2, result]) => {
18606
+ result.value = values;
18607
+ onRest2(result, this, this._item);
18608
+ });
18609
+ }
18610
+ }
18611
+ /** @internal */
18612
+ eventObserved(event) {
18613
+ if (event.type == "change") {
18614
+ this._changed.add(event.parent);
18615
+ if (!event.idle) {
18616
+ this._active.add(event.parent);
18617
+ }
18618
+ } else if (event.type == "idle") {
18619
+ this._active.delete(event.parent);
18620
+ } else
18621
+ return;
18622
+ raf.onFrame(this._onFrame);
18623
+ }
18624
+ };
18625
+ function flushUpdateQueue(ctrl, queue) {
18626
+ return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then(
18627
+ (results) => getCombinedResult(ctrl, results)
18628
+ );
18629
+ }
18630
+ async function flushUpdate(ctrl, props, isLoop) {
18631
+ const { keys, to: to2, from, loop, onRest, onResolve } = props;
18632
+ const defaults2 = is.obj(props.default) && props.default;
18633
+ if (loop) {
18634
+ props.loop = false;
18635
+ }
18636
+ if (to2 === false)
18637
+ props.to = null;
18638
+ if (from === false)
18639
+ props.from = null;
18640
+ const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0;
18641
+ if (asyncTo) {
18642
+ props.to = void 0;
18643
+ props.onRest = void 0;
18644
+ if (defaults2) {
18645
+ defaults2.onRest = void 0;
18646
+ }
18647
+ } else {
18648
+ each(BATCHED_EVENTS, (key) => {
18649
+ const handler = props[key];
18650
+ if (is.fun(handler)) {
18651
+ const queue = ctrl["_events"][key];
18652
+ props[key] = ({ finished, cancelled }) => {
18653
+ const result2 = queue.get(handler);
18654
+ if (result2) {
18655
+ if (!finished)
18656
+ result2.finished = false;
18657
+ if (cancelled)
18658
+ result2.cancelled = true;
18659
+ } else {
18660
+ queue.set(handler, {
18661
+ value: null,
18662
+ finished: finished || false,
18663
+ cancelled: cancelled || false
18664
+ });
18665
+ }
18666
+ };
18667
+ if (defaults2) {
18668
+ defaults2[key] = props[key];
18669
+ }
18670
+ }
18671
+ });
18672
+ }
18673
+ const state = ctrl["_state"];
18674
+ if (props.pause === !state.paused) {
18675
+ state.paused = props.pause;
18676
+ flushCalls(props.pause ? state.pauseQueue : state.resumeQueue);
18677
+ } else if (state.paused) {
18678
+ props.pause = true;
18679
+ }
18680
+ const promises = (keys || Object.keys(ctrl.springs)).map(
18681
+ (key) => ctrl.springs[key].start(props)
18682
+ );
18683
+ const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true;
18684
+ if (asyncTo || cancel && state.asyncId) {
18685
+ promises.push(
18686
+ scheduleProps(++ctrl["_lastAsyncId"], {
18687
+ props,
18688
+ state,
18689
+ actions: {
18690
+ pause: noop,
18691
+ resume: noop,
18692
+ start(props2, resolve) {
18693
+ if (cancel) {
18694
+ stopAsync(state, ctrl["_lastAsyncId"]);
18695
+ resolve(getCancelledResult(ctrl));
18696
+ } else {
18697
+ props2.onRest = onRest;
18698
+ resolve(
18699
+ runAsync(
18700
+ asyncTo,
18701
+ props2,
18702
+ state,
18703
+ ctrl
18704
+ )
18705
+ );
18706
+ }
18707
+ }
18708
+ }
18709
+ })
18710
+ );
18711
+ }
18712
+ if (state.paused) {
18713
+ await new Promise((resume) => {
18714
+ state.resumeQueue.add(resume);
18715
+ });
18716
+ }
18717
+ const result = getCombinedResult(ctrl, await Promise.all(promises));
18718
+ if (loop && result.finished && !(isLoop && result.noop)) {
18719
+ const nextProps = createLoopUpdate(props, loop, to2);
18720
+ if (nextProps) {
18721
+ prepareKeys(ctrl, [nextProps]);
18722
+ return flushUpdate(ctrl, nextProps, true);
18723
+ }
18724
+ }
18725
+ if (onResolve) {
18726
+ raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item));
18727
+ }
18728
+ return result;
18729
+ }
18730
+ function getSprings(ctrl, props) {
18731
+ const springs = { ...ctrl.springs };
18732
+ if (props) {
18733
+ each(toArray(props), (props2) => {
18734
+ if (is.und(props2.keys)) {
18735
+ props2 = createUpdate(props2);
18736
+ }
18737
+ if (!is.obj(props2.to)) {
18738
+ props2 = { ...props2, to: void 0 };
18739
+ }
18740
+ prepareSprings(springs, props2, (key) => {
18741
+ return createSpring(key);
18742
+ });
18743
+ });
18744
+ }
18745
+ setSprings(ctrl, springs);
18746
+ return springs;
18747
+ }
18748
+ function setSprings(ctrl, springs) {
18749
+ eachProp(springs, (spring, key) => {
18750
+ if (!ctrl.springs[key]) {
18751
+ ctrl.springs[key] = spring;
18752
+ addFluidObserver(spring, ctrl);
18753
+ }
18754
+ });
18755
+ }
18756
+ function createSpring(key, observer) {
18757
+ const spring = new SpringValue();
18758
+ spring.key = key;
18759
+ if (observer) {
18760
+ addFluidObserver(spring, observer);
18761
+ }
18762
+ return spring;
18763
+ }
18764
+ function prepareSprings(springs, props, create) {
18765
+ if (props.keys) {
18766
+ each(props.keys, (key) => {
18767
+ const spring = springs[key] || (springs[key] = create(key));
18768
+ spring["_prepareNode"](props);
18769
+ });
18770
+ }
18771
+ }
18772
+ function prepareKeys(ctrl, queue) {
18773
+ each(queue, (props) => {
18774
+ prepareSprings(ctrl.springs, props, (key) => {
18775
+ return createSpring(key, ctrl);
18776
+ });
18777
+ });
18778
+ }
18779
+ var SpringContext = ({
18780
+ children,
18781
+ ...props
18782
+ }) => {
18783
+ const inherited = useContext(ctx);
18784
+ const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate;
18785
+ props = useMemoOne(() => ({ pause, immediate }), [pause, immediate]);
18786
+ const { Provider } = ctx;
18787
+ return /* @__PURE__ */ React.createElement(Provider, { value: props }, children);
18788
+ };
18789
+ var ctx = makeContext(SpringContext, {});
18790
+ SpringContext.Provider = ctx.Provider;
18791
+ SpringContext.Consumer = ctx.Consumer;
18792
+ function makeContext(target, init) {
18793
+ Object.assign(target, React.createContext(init));
18794
+ target.Provider._context = target;
18795
+ target.Consumer._context = target;
18796
+ return target;
18797
+ }
18798
+ var SpringRef = () => {
18799
+ const current = [];
18800
+ const SpringRef2 = function(props) {
18801
+ deprecateDirectCall();
18802
+ const results = [];
18803
+ each(current, (ctrl, i) => {
18804
+ if (is.und(props)) {
18805
+ results.push(ctrl.start());
18806
+ } else {
18807
+ const update2 = _getProps(props, ctrl, i);
18808
+ if (update2) {
18809
+ results.push(ctrl.start(update2));
18810
+ }
18811
+ }
18812
+ });
18813
+ return results;
18814
+ };
18815
+ SpringRef2.current = current;
18816
+ SpringRef2.add = function(ctrl) {
18817
+ if (!current.includes(ctrl)) {
18818
+ current.push(ctrl);
18819
+ }
18820
+ };
18821
+ SpringRef2.delete = function(ctrl) {
18822
+ const i = current.indexOf(ctrl);
18823
+ if (~i)
18824
+ current.splice(i, 1);
18825
+ };
18826
+ SpringRef2.pause = function() {
18827
+ each(current, (ctrl) => ctrl.pause(...arguments));
18828
+ return this;
18829
+ };
18830
+ SpringRef2.resume = function() {
18831
+ each(current, (ctrl) => ctrl.resume(...arguments));
18832
+ return this;
18833
+ };
18834
+ SpringRef2.set = function(values) {
18835
+ each(current, (ctrl, i) => {
18836
+ const update2 = is.fun(values) ? values(i, ctrl) : values;
18837
+ if (update2) {
18838
+ ctrl.set(update2);
18839
+ }
18840
+ });
18841
+ };
18842
+ SpringRef2.start = function(props) {
18843
+ const results = [];
18844
+ each(current, (ctrl, i) => {
18845
+ if (is.und(props)) {
18846
+ results.push(ctrl.start());
18847
+ } else {
18848
+ const update2 = this._getProps(props, ctrl, i);
18849
+ if (update2) {
18850
+ results.push(ctrl.start(update2));
18851
+ }
18852
+ }
18853
+ });
18854
+ return results;
18855
+ };
18856
+ SpringRef2.stop = function() {
18857
+ each(current, (ctrl) => ctrl.stop(...arguments));
18858
+ return this;
18859
+ };
18860
+ SpringRef2.update = function(props) {
18861
+ each(current, (ctrl, i) => ctrl.update(this._getProps(props, ctrl, i)));
18862
+ return this;
18863
+ };
18864
+ const _getProps = function(arg, ctrl, index) {
18865
+ return is.fun(arg) ? arg(index, ctrl) : arg;
18866
+ };
18867
+ SpringRef2._getProps = _getProps;
18868
+ return SpringRef2;
18869
+ };
18870
+
18871
+ // src/hooks/useSprings.ts
18872
+ function useSprings(length, props, deps) {
18873
+ const propsFn = is.fun(props) && props;
18874
+ if (propsFn && !deps)
18875
+ deps = [];
18876
+ const ref = useMemo(
18877
+ () => propsFn || arguments.length == 3 ? SpringRef() : void 0,
18878
+ []
18879
+ );
18880
+ const layoutId = useRef(0);
18881
+ const forceUpdate = useForceUpdate();
18882
+ const state = useMemo(
18883
+ () => ({
18884
+ ctrls: [],
18885
+ queue: [],
18886
+ flush(ctrl, updates2) {
18887
+ const springs2 = getSprings(ctrl, updates2);
18888
+ const canFlushSync = layoutId.current > 0 && !state.queue.length && !Object.keys(springs2).some((key) => !ctrl.springs[key]);
18889
+ return canFlushSync ? flushUpdateQueue(ctrl, updates2) : new Promise((resolve) => {
18890
+ setSprings(ctrl, springs2);
18891
+ state.queue.push(() => {
18892
+ resolve(flushUpdateQueue(ctrl, updates2));
18893
+ });
18894
+ forceUpdate();
18895
+ });
18896
+ }
18897
+ }),
18898
+ []
18899
+ );
18900
+ const ctrls = useRef([...state.ctrls]);
18901
+ const updates = [];
18902
+ const prevLength = usePrev(length) || 0;
18903
+ useMemo(() => {
18904
+ each(ctrls.current.slice(length, prevLength), (ctrl) => {
18905
+ detachRefs(ctrl, ref);
18906
+ ctrl.stop(true);
18907
+ });
18908
+ ctrls.current.length = length;
18909
+ declareUpdates(prevLength, length);
18910
+ }, [length]);
18911
+ useMemo(() => {
18912
+ declareUpdates(0, Math.min(prevLength, length));
18913
+ }, deps);
18914
+ function declareUpdates(startIndex, endIndex) {
18915
+ for (let i = startIndex; i < endIndex; i++) {
18916
+ const ctrl = ctrls.current[i] || (ctrls.current[i] = new Controller(null, state.flush));
18917
+ const update2 = propsFn ? propsFn(i, ctrl) : props[i];
18918
+ if (update2) {
18919
+ updates[i] = declareUpdate(update2);
18920
+ }
18921
+ }
18922
+ }
18923
+ const springs = ctrls.current.map((ctrl, i) => getSprings(ctrl, updates[i]));
18924
+ const context = useContext(SpringContext);
18925
+ const prevContext = usePrev(context);
18926
+ const hasContext = context !== prevContext && hasProps(context);
18927
+ useIsomorphicLayoutEffect(() => {
18928
+ layoutId.current++;
18929
+ state.ctrls = ctrls.current;
18930
+ const { queue } = state;
18931
+ if (queue.length) {
18932
+ state.queue = [];
18933
+ each(queue, (cb) => cb());
18934
+ }
18935
+ each(ctrls.current, (ctrl, i) => {
18936
+ ref?.add(ctrl);
18937
+ if (hasContext) {
18938
+ ctrl.start({ default: context });
18939
+ }
18940
+ const update2 = updates[i];
18941
+ if (update2) {
18942
+ replaceRef(ctrl, update2.ref);
18943
+ if (ctrl.ref) {
18944
+ ctrl.queue.push(update2);
18945
+ } else {
18946
+ ctrl.start(update2);
18947
+ }
18948
+ }
18949
+ });
18950
+ });
18951
+ useOnce(() => () => {
18952
+ each(state.ctrls, (ctrl) => ctrl.stop(true));
18953
+ });
18954
+ const values = springs.map((x) => ({ ...x }));
18955
+ return ref ? [values, ref] : values;
18956
+ }
18957
+
18958
+ // src/hooks/useSpring.ts
18959
+ function useSpring(props, deps) {
18960
+ const isFn = is.fun(props);
18961
+ const [[values], ref] = useSprings(
18962
+ 1,
18963
+ isFn ? props : [props],
18964
+ isFn ? deps || [] : deps
18965
+ );
18966
+ return isFn || arguments.length == 2 ? [values, ref] : values;
18967
+ }
18968
+ var Interpolation = class extends FrameValue {
18969
+ constructor(source, args) {
18970
+ super();
18971
+ this.source = source;
18972
+ /** Equals false when in the frameloop */
18973
+ this.idle = true;
18974
+ /** The inputs which are currently animating */
18975
+ this._active = /* @__PURE__ */ new Set();
18976
+ this.calc = createInterpolator(...args);
18977
+ const value = this._get();
18978
+ const nodeType = getAnimatedType(value);
18979
+ setAnimated(this, nodeType.create(value));
18980
+ }
18981
+ advance(_dt) {
18982
+ const value = this._get();
18983
+ const oldValue = this.get();
18984
+ if (!isEqual(value, oldValue)) {
18985
+ getAnimated(this).setValue(value);
18986
+ this._onChange(value, this.idle);
18987
+ }
18988
+ if (!this.idle && checkIdle(this._active)) {
18989
+ becomeIdle(this);
18990
+ }
18991
+ }
18992
+ _get() {
18993
+ const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source));
18994
+ return this.calc(...inputs);
18995
+ }
18996
+ _start() {
18997
+ if (this.idle && !checkIdle(this._active)) {
18998
+ this.idle = false;
18999
+ each(getPayload(this), (node) => {
19000
+ node.done = false;
19001
+ });
19002
+ if (globals_exports.skipAnimation) {
19003
+ raf.batchedUpdates(() => this.advance());
19004
+ becomeIdle(this);
19005
+ } else {
19006
+ frameLoop.start(this);
19007
+ }
19008
+ }
19009
+ }
19010
+ // Observe our sources only when we're observed.
19011
+ _attach() {
19012
+ let priority = 1;
19013
+ each(toArray(this.source), (source) => {
19014
+ if (hasFluidValue(source)) {
19015
+ addFluidObserver(source, this);
19016
+ }
19017
+ if (isFrameValue(source)) {
19018
+ if (!source.idle) {
19019
+ this._active.add(source);
19020
+ }
19021
+ priority = Math.max(priority, source.priority + 1);
19022
+ }
19023
+ });
19024
+ this.priority = priority;
19025
+ this._start();
19026
+ }
19027
+ // Stop observing our sources once we have no observers.
19028
+ _detach() {
19029
+ each(toArray(this.source), (source) => {
19030
+ if (hasFluidValue(source)) {
19031
+ removeFluidObserver(source, this);
19032
+ }
19033
+ });
19034
+ this._active.clear();
19035
+ becomeIdle(this);
19036
+ }
19037
+ /** @internal */
19038
+ eventObserved(event) {
19039
+ if (event.type == "change") {
19040
+ if (event.idle) {
19041
+ this.advance();
19042
+ } else {
19043
+ this._active.add(event.parent);
19044
+ this._start();
19045
+ }
19046
+ } else if (event.type == "idle") {
19047
+ this._active.delete(event.parent);
19048
+ } else if (event.type == "priority") {
19049
+ this.priority = toArray(this.source).reduce(
19050
+ (highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1),
19051
+ 0
19052
+ );
19053
+ }
19054
+ }
19055
+ };
19056
+ function isIdle(source) {
19057
+ return source.idle !== false;
19058
+ }
19059
+ function checkIdle(active) {
19060
+ return !active.size || Array.from(active).every(isIdle);
19061
+ }
19062
+ function becomeIdle(self) {
19063
+ if (!self.idle) {
19064
+ self.idle = true;
19065
+ each(getPayload(self), (node) => {
19066
+ node.done = true;
19067
+ });
19068
+ callFluidObservers(self, {
19069
+ type: "idle",
19070
+ parent: self
19071
+ });
19072
+ }
19073
+ }
19074
+ globals_exports.assign({
19075
+ createStringInterpolator: createStringInterpolator2,
19076
+ to: (source, args) => new Interpolation(source, args)
19077
+ });
19078
+
19079
+ // src/index.ts
19080
+
19081
+ // src/applyAnimatedValues.ts
19082
+ var isCustomPropRE = /^--/;
19083
+ function dangerousStyleValue(name, value) {
19084
+ if (value == null || typeof value === "boolean" || value === "")
19085
+ return "";
19086
+ if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]))
19087
+ return value + "px";
19088
+ return ("" + value).trim();
19089
+ }
19090
+ var attributeCache = {};
19091
+ function applyAnimatedValues(instance, props) {
19092
+ if (!instance.nodeType || !instance.setAttribute) {
19093
+ return false;
19094
+ }
19095
+ const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter";
19096
+ const {
19097
+ className,
19098
+ style,
19099
+ children,
19100
+ scrollTop,
19101
+ scrollLeft,
19102
+ viewBox,
19103
+ ...attributes
19104
+ } = props;
19105
+ const values = Object.values(attributes);
19106
+ const names = Object.keys(attributes).map(
19107
+ (name) => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(
19108
+ /([A-Z])/g,
19109
+ // Attributes are written in dash case
19110
+ (n) => "-" + n.toLowerCase()
19111
+ ))
19112
+ );
19113
+ if (children !== void 0) {
19114
+ instance.textContent = children;
19115
+ }
19116
+ for (const name in style) {
19117
+ if (style.hasOwnProperty(name)) {
19118
+ const value = dangerousStyleValue(name, style[name]);
19119
+ if (isCustomPropRE.test(name)) {
19120
+ instance.style.setProperty(name, value);
19121
+ } else {
19122
+ instance.style[name] = value;
19123
+ }
19124
+ }
19125
+ }
19126
+ names.forEach((name, i) => {
19127
+ instance.setAttribute(name, values[i]);
19128
+ });
19129
+ if (className !== void 0) {
19130
+ instance.className = className;
19131
+ }
19132
+ if (scrollTop !== void 0) {
19133
+ instance.scrollTop = scrollTop;
19134
+ }
19135
+ if (scrollLeft !== void 0) {
19136
+ instance.scrollLeft = scrollLeft;
19137
+ }
19138
+ if (viewBox !== void 0) {
19139
+ instance.setAttribute("viewBox", viewBox);
19140
+ }
19141
+ }
19142
+ var isUnitlessNumber = {
19143
+ animationIterationCount: true,
19144
+ borderImageOutset: true,
19145
+ borderImageSlice: true,
19146
+ borderImageWidth: true,
19147
+ boxFlex: true,
19148
+ boxFlexGroup: true,
19149
+ boxOrdinalGroup: true,
19150
+ columnCount: true,
19151
+ columns: true,
19152
+ flex: true,
19153
+ flexGrow: true,
19154
+ flexPositive: true,
19155
+ flexShrink: true,
19156
+ flexNegative: true,
19157
+ flexOrder: true,
19158
+ gridRow: true,
19159
+ gridRowEnd: true,
19160
+ gridRowSpan: true,
19161
+ gridRowStart: true,
19162
+ gridColumn: true,
19163
+ gridColumnEnd: true,
19164
+ gridColumnSpan: true,
19165
+ gridColumnStart: true,
19166
+ fontWeight: true,
19167
+ lineClamp: true,
19168
+ lineHeight: true,
19169
+ opacity: true,
19170
+ order: true,
19171
+ orphans: true,
19172
+ tabSize: true,
19173
+ widows: true,
19174
+ zIndex: true,
19175
+ zoom: true,
19176
+ // SVG-related properties
19177
+ fillOpacity: true,
19178
+ floodOpacity: true,
19179
+ stopOpacity: true,
19180
+ strokeDasharray: true,
19181
+ strokeDashoffset: true,
19182
+ strokeMiterlimit: true,
19183
+ strokeOpacity: true,
19184
+ strokeWidth: true
19185
+ };
19186
+ var prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
19187
+ var prefixes = ["Webkit", "Ms", "Moz", "O"];
19188
+ isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
19189
+ prefixes.forEach((prefix) => acc[prefixKey(prefix, prop)] = acc[prop]);
19190
+ return acc;
19191
+ }, isUnitlessNumber);
19192
+ var domTransforms = /^(matrix|translate|scale|rotate|skew)/;
19193
+ var pxTransforms = /^(translate)/;
19194
+ var degTransforms = /^(rotate|skew)/;
19195
+ var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value;
19196
+ var isValueIdentity = (value, id) => is.arr(value) ? value.every((v) => isValueIdentity(v, id)) : is.num(value) ? value === id : parseFloat(value) === id;
19197
+ var AnimatedStyle = class extends AnimatedObject {
19198
+ constructor({ x, y, z, ...style }) {
19199
+ const inputs = [];
19200
+ const transforms = [];
19201
+ if (x || y || z) {
19202
+ inputs.push([x || 0, y || 0, z || 0]);
19203
+ transforms.push((xyz) => [
19204
+ `translate3d(${xyz.map((v) => addUnit(v, "px")).join(",")})`,
19205
+ // prettier-ignore
19206
+ isValueIdentity(xyz, 0)
19207
+ ]);
19208
+ }
19209
+ eachProp(style, (value, key) => {
19210
+ if (key === "transform") {
19211
+ inputs.push([value || ""]);
19212
+ transforms.push((transform) => [transform, transform === ""]);
19213
+ } else if (domTransforms.test(key)) {
19214
+ delete style[key];
19215
+ if (is.und(value))
19216
+ return;
19217
+ const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : "";
19218
+ inputs.push(toArray(value));
19219
+ transforms.push(
19220
+ key === "rotate3d" ? ([x2, y2, z2, deg]) => [
19221
+ `rotate3d(${x2},${y2},${z2},${addUnit(deg, unit)})`,
19222
+ isValueIdentity(deg, 0)
19223
+ ] : (input) => [
19224
+ `${key}(${input.map((v) => addUnit(v, unit)).join(",")})`,
19225
+ isValueIdentity(input, key.startsWith("scale") ? 1 : 0)
19226
+ ]
19227
+ );
19228
+ }
19229
+ });
19230
+ if (inputs.length) {
19231
+ style.transform = new FluidTransform(inputs, transforms);
19232
+ }
19233
+ super(style);
19234
+ }
19235
+ };
19236
+ var FluidTransform = class extends FluidValue {
19237
+ constructor(inputs, transforms) {
19238
+ super();
19239
+ this.inputs = inputs;
19240
+ this.transforms = transforms;
19241
+ this._value = null;
19242
+ }
19243
+ get() {
19244
+ return this._value || (this._value = this._get());
19245
+ }
19246
+ _get() {
19247
+ let transform = "";
19248
+ let identity = true;
19249
+ each(this.inputs, (input, i) => {
19250
+ const arg1 = getFluidValue(input[0]);
19251
+ const [t, id] = this.transforms[i](
19252
+ is.arr(arg1) ? arg1 : input.map(getFluidValue)
19253
+ );
19254
+ transform += " " + t;
19255
+ identity = identity && id;
19256
+ });
19257
+ return identity ? "none" : transform;
19258
+ }
19259
+ // Start observing our inputs once we have an observer.
19260
+ observerAdded(count) {
19261
+ if (count == 1)
19262
+ each(
19263
+ this.inputs,
19264
+ (input) => each(
19265
+ input,
19266
+ (value) => hasFluidValue(value) && addFluidObserver(value, this)
19267
+ )
19268
+ );
19269
+ }
19270
+ // Stop observing our inputs once we have no observers.
19271
+ observerRemoved(count) {
19272
+ if (count == 0)
19273
+ each(
19274
+ this.inputs,
19275
+ (input) => each(
19276
+ input,
19277
+ (value) => hasFluidValue(value) && removeFluidObserver(value, this)
19278
+ )
19279
+ );
19280
+ }
19281
+ eventObserved(event) {
19282
+ if (event.type == "change") {
19283
+ this._value = null;
19284
+ }
19285
+ callFluidObservers(this, event);
19286
+ }
19287
+ };
19288
+
19289
+ // src/primitives.ts
19290
+ var primitives = [
19291
+ "a",
19292
+ "abbr",
19293
+ "address",
19294
+ "area",
19295
+ "article",
19296
+ "aside",
19297
+ "audio",
19298
+ "b",
19299
+ "base",
19300
+ "bdi",
19301
+ "bdo",
19302
+ "big",
19303
+ "blockquote",
19304
+ "body",
19305
+ "br",
19306
+ "button",
19307
+ "canvas",
19308
+ "caption",
19309
+ "cite",
19310
+ "code",
19311
+ "col",
19312
+ "colgroup",
19313
+ "data",
19314
+ "datalist",
19315
+ "dd",
19316
+ "del",
19317
+ "details",
19318
+ "dfn",
19319
+ "dialog",
19320
+ "div",
19321
+ "dl",
19322
+ "dt",
19323
+ "em",
19324
+ "embed",
19325
+ "fieldset",
19326
+ "figcaption",
19327
+ "figure",
19328
+ "footer",
19329
+ "form",
19330
+ "h1",
19331
+ "h2",
19332
+ "h3",
19333
+ "h4",
19334
+ "h5",
19335
+ "h6",
19336
+ "head",
19337
+ "header",
19338
+ "hgroup",
19339
+ "hr",
19340
+ "html",
19341
+ "i",
19342
+ "iframe",
19343
+ "img",
19344
+ "input",
19345
+ "ins",
19346
+ "kbd",
19347
+ "keygen",
19348
+ "label",
19349
+ "legend",
19350
+ "li",
19351
+ "link",
19352
+ "main",
19353
+ "map",
19354
+ "mark",
19355
+ "menu",
19356
+ "menuitem",
19357
+ "meta",
19358
+ "meter",
19359
+ "nav",
19360
+ "noscript",
19361
+ "object",
19362
+ "ol",
19363
+ "optgroup",
19364
+ "option",
19365
+ "output",
19366
+ "p",
19367
+ "param",
19368
+ "picture",
19369
+ "pre",
19370
+ "progress",
19371
+ "q",
19372
+ "rp",
19373
+ "rt",
19374
+ "ruby",
19375
+ "s",
19376
+ "samp",
19377
+ "script",
19378
+ "section",
19379
+ "select",
19380
+ "small",
19381
+ "source",
19382
+ "span",
19383
+ "strong",
19384
+ "style",
19385
+ "sub",
19386
+ "summary",
19387
+ "sup",
19388
+ "table",
19389
+ "tbody",
19390
+ "td",
19391
+ "textarea",
19392
+ "tfoot",
19393
+ "th",
19394
+ "thead",
19395
+ "time",
19396
+ "title",
19397
+ "tr",
19398
+ "track",
19399
+ "u",
19400
+ "ul",
19401
+ "var",
19402
+ "video",
19403
+ "wbr",
19404
+ // SVG
19405
+ "circle",
19406
+ "clipPath",
19407
+ "defs",
19408
+ "ellipse",
19409
+ "foreignObject",
19410
+ "g",
19411
+ "image",
19412
+ "line",
19413
+ "linearGradient",
19414
+ "mask",
19415
+ "path",
19416
+ "pattern",
19417
+ "polygon",
19418
+ "polyline",
19419
+ "radialGradient",
19420
+ "rect",
19421
+ "stop",
19422
+ "svg",
19423
+ "text",
19424
+ "tspan"
19425
+ ];
19426
+ globals_exports.assign({
19427
+ batchedUpdates: unstable_batchedUpdates,
19428
+ createStringInterpolator: createStringInterpolator2,
19429
+ colors: colors2
19430
+ });
19431
+ var host = createHost(primitives, {
19432
+ applyAnimatedValues,
19433
+ createAnimatedStyle: (style) => new AnimatedStyle(style),
19434
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19435
+ getComponentProps: ({ scrollTop, scrollLeft, ...props }) => props
19436
+ });
19437
+ var animated = host.animated;
19438
+
19439
+ const Collapse = ({ isVisible, children }) => {
19440
+ const contentRef = useRef(null);
19441
+ const [contentHeight, setContentHeight] = useState(contentRef.current?.scrollHeight);
19442
+ useEffect(() => {
19443
+ if (contentRef.current) {
19444
+ setContentHeight(contentRef.current?.scrollHeight ?? 0);
19445
+ }
19446
+ }, [children]);
19447
+ const styles = useSpring({
19448
+ opacity: isVisible ? 1 : 0,
19449
+ height: isVisible ? contentHeight : 0,
19450
+ });
19451
+ return React__default.createElement(animated.div, { style: styles }, isVisible ? React__default.createElement("div", { ref: contentRef }, children) : undefined);
19452
+ };
19453
+
15954
19454
  // packages/core/number/src/number.ts
15955
19455
  function clamp(value, [min, max]) {
15956
19456
  return Math.min(max, Math.max(min, value));
@@ -17119,7 +20619,7 @@ var Progress = React.forwardRef(
17119
20619
  );
17120
20620
  Progress.displayName = PROGRESS_NAME;
17121
20621
  var INDICATOR_NAME = "ProgressIndicator";
17122
- var ProgressIndicator = React.forwardRef(
20622
+ var ProgressIndicator$1 = React.forwardRef(
17123
20623
  (props, forwardedRef) => {
17124
20624
  const { __scopeProgress, ...indicatorProps } = props;
17125
20625
  const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
@@ -17135,7 +20635,7 @@ var ProgressIndicator = React.forwardRef(
17135
20635
  );
17136
20636
  }
17137
20637
  );
17138
- ProgressIndicator.displayName = INDICATOR_NAME;
20638
+ ProgressIndicator$1.displayName = INDICATOR_NAME;
17139
20639
  function defaultGetValueLabel(value, max) {
17140
20640
  return `${Math.round(value / max * 100)}%`;
17141
20641
  }
@@ -17163,19 +20663,33 @@ function getInvalidValueError(propValue, componentName) {
17163
20663
  Defaulting to \`null\`.`;
17164
20664
  }
17165
20665
  var Root = Progress;
17166
- var Indicator = ProgressIndicator;
17167
-
17168
- const ProgressBar = ({ value, max = 100, label, extraClasses, testId }) => {
17169
- const tooltipData = getQTipData({ tooltip: label });
17170
- const [progress, setProgress] = React__default.useState(0);
17171
- React__default.useEffect(() => {
17172
- const timer = setTimeout(() => setProgress(value), 500);
17173
- return () => clearTimeout(timer);
17174
- }, []);
17175
- return (React__default.createElement("span", { "data-testid": testId, ...tooltipData },
17176
- React__default.createElement(Root, { className: "tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray", max: max, value: value },
17177
- React__default.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-h-full tw-bg-sq-color-dark tw-transition-transform tw-duration-[660ms] ${extraClasses}`, style: { transform: `translateX(-${100 - progress}%)` } }))));
20666
+ var Indicator = ProgressIndicator$1;
20667
+
20668
+ const ProgressIndicator = (props) => {
20669
+ const { value, color = undefined, testId, label, extraClasses = '', labelClasses = '', valuesLength, max, index, ...tooltipProps } = props;
20670
+ const tooltipData = getQTipData(tooltipProps);
20671
+ const previousWidth = useRef(0);
20672
+ const [animatedWidth, setAnimatedWidth] = React__default.useState(previousWidth.current);
20673
+ useEffect(() => {
20674
+ const timeout = setTimeout(() => {
20675
+ const newWidth = (Number(value) / Number(max)) * 100;
20676
+ setAnimatedWidth(newWidth);
20677
+ previousWidth.current = newWidth;
20678
+ }, 100);
20679
+ return () => clearTimeout(timeout);
20680
+ }, [value]);
20681
+ return (React__default.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-full tw-duration-[660ms] tw-flex tw-bg-sq-color-dark ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${index}-${value}`, style: {
20682
+ // Background color will default to the theme color if undefined
20683
+ backgroundColor: valuesLength === 1 ? undefined : color,
20684
+ animation: 'width 660ms forwards',
20685
+ width: `${animatedWidth}%`,
20686
+ } }, label ? (React__default.createElement("span", { className: `tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center ${labelClasses}` }, label)) : undefined));
20687
+ };
20688
+ const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', }) => {
20689
+ return (React__default.createElement(Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: values.reduce((acc, { value }) => acc + value, 0) }, values.map((props, i) => {
20690
+ return React__default.createElement(ProgressIndicator, { ...props, max: max, valuesLength: values.length, index: i, key: i });
20691
+ })));
17178
20692
  };
17179
20693
 
17180
- export { Accordion, Alert, Button, ButtonWithDropdown, ButtonWithPopover, Checkbox, Icon, InputGroup, Modal, ProgressBar, QTip, SeeqActionDropdown, Select, components as SelectCompoents, Slider, Tabs, TextArea, TextField, ToolbarButton, Tooltip };
20694
+ export { Accordion, Alert, Button, ButtonWithDropdown, ButtonWithPopover, Checkbox, Collapse, Icon, InputGroup, Modal, ProgressBar, QTip, SeeqActionDropdown, Select, components as SelectCompoents, Slider, Tabs, TextArea, TextField, ToolbarButton, Tooltip };
17181
20695
  //# sourceMappingURL=index.esm.js.map