@antimatter-audio/antimatter-ui 14.15.1 → 14.17.0

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 (50) hide show
  1. package/dist/advanced/ModMatrix/ModMatrix.d.ts.map +1 -1
  2. package/dist/advanced/ModMatrix/ModMatrixCell.d.ts.map +1 -1
  3. package/dist/advanced/ModMatrix/ModMatrixComboboxCell.d.ts +2 -1
  4. package/dist/advanced/ModMatrix/ModMatrixComboboxCell.d.ts.map +1 -1
  5. package/dist/advanced/ModMatrix/ModMatrixRow.d.ts +2 -1
  6. package/dist/advanced/ModMatrix/ModMatrixRow.d.ts.map +1 -1
  7. package/dist/advanced/ModMatrix/ModMatrixToggleCell.d.ts.map +1 -1
  8. package/dist/advanced/ModMatrix/constants.d.ts +1 -1
  9. package/dist/advanced/ModuleFooter/ModuleFooter.d.ts.map +1 -1
  10. package/dist/common/types.d.ts +17 -0
  11. package/dist/common/types.d.ts.map +1 -1
  12. package/dist/context/GlobalContextProvider.d.ts +9 -23
  13. package/dist/context/GlobalContextProvider.d.ts.map +1 -1
  14. package/dist/core/Button/Button.d.ts.map +1 -1
  15. package/dist/core/Input/Input.d.ts.map +1 -1
  16. package/dist/core/Label/Label.d.ts.map +1 -1
  17. package/dist/core/Tabs/Tabs.d.ts +4 -1
  18. package/dist/core/Tabs/Tabs.d.ts.map +1 -1
  19. package/dist/hooks/useCombobox.d.ts +2 -0
  20. package/dist/hooks/useCombobox.d.ts.map +1 -1
  21. package/dist/hooks/useDropdown.d.ts.map +1 -1
  22. package/dist/hooks/useSlider.d.ts +2 -1
  23. package/dist/hooks/useSlider.d.ts.map +1 -1
  24. package/dist/index.js +1720 -1683
  25. package/dist/index.js.map +1 -1
  26. package/dist/src/advanced/ModMatrix/ModMatrix.d.ts.map +1 -1
  27. package/dist/src/advanced/ModMatrix/ModMatrixCell.d.ts.map +1 -1
  28. package/dist/src/advanced/ModMatrix/ModMatrixComboboxCell.d.ts +2 -1
  29. package/dist/src/advanced/ModMatrix/ModMatrixComboboxCell.d.ts.map +1 -1
  30. package/dist/src/advanced/ModMatrix/ModMatrixRow.d.ts +2 -1
  31. package/dist/src/advanced/ModMatrix/ModMatrixRow.d.ts.map +1 -1
  32. package/dist/src/advanced/ModMatrix/ModMatrixToggleCell.d.ts.map +1 -1
  33. package/dist/src/advanced/ModMatrix/constants.d.ts +1 -1
  34. package/dist/src/advanced/ModuleFooter/ModuleFooter.d.ts.map +1 -1
  35. package/dist/src/common/types.d.ts +13 -0
  36. package/dist/src/common/types.d.ts.map +1 -1
  37. package/dist/src/context/GlobalContextProvider.d.ts +9 -23
  38. package/dist/src/context/GlobalContextProvider.d.ts.map +1 -1
  39. package/dist/src/core/Button/Button.d.ts.map +1 -1
  40. package/dist/src/core/Input/Input.d.ts.map +1 -1
  41. package/dist/src/core/Label/Label.d.ts.map +1 -1
  42. package/dist/src/core/Tabs/Tabs.d.ts +4 -1
  43. package/dist/src/core/Tabs/Tabs.d.ts.map +1 -1
  44. package/dist/src/hooks/useCombobox.d.ts +2 -0
  45. package/dist/src/hooks/useCombobox.d.ts.map +1 -1
  46. package/dist/src/hooks/useDropdown.d.ts.map +1 -1
  47. package/dist/src/hooks/useSlider.d.ts +2 -1
  48. package/dist/src/hooks/useSlider.d.ts.map +1 -1
  49. package/dist/styles.css +13 -10
  50. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
- import React__default, { useRef, useReducer, useCallback, createContext, useContext, useEffect, useState, useEffectEvent } from 'react';
2
+ import React__default, { useEffect, useState, useRef, useReducer, useCallback, createContext, useContext, useEffectEvent } from 'react';
3
+ import * as Juce from 'juce-framework-frontend';
3
4
  import classnames from 'classnames';
4
5
  import { TabGroup, TabList, Tab, Listbox, ListboxButton, ListboxOptions, ListboxOption, Combobox, ComboboxInput, ComboboxButton, ComboboxOptions, ComboboxOption } from '@headlessui/react';
5
- import * as Juce from 'juce-framework-frontend';
6
6
  import { useGesture } from '@use-gesture/react';
7
7
  import * as d3 from 'd3';
8
8
  import { line, curveBasis, area, scaleLinear, stack, scaleOrdinal } from 'd3';
@@ -34,7 +34,7 @@ function styleInject(css, ref) {
34
34
  }
35
35
  }
36
36
 
37
- var css_248z$g = "@theme static {\n --color-brand: #bb68d9;\n --color-brand-900: #1b181c;\n /* --color-brand-900: #443342; */\n --color-brand-700: #932eb8;\n --color-brand-600: #ac47d1;\n --color-brand-400: #d199e6;\n --color-brand-300: #f3d4f4;\n --color-brand-secondary: #18d6d6;\n --color-alert: #8a0101;\n --color-text: #bab6cf;\n --color-gray-100: #c7c3de;\n --color-gray-200: #9a96ab;\n --color-gray-300: #838091;\n --color-gray-400: #595763;\n --color-gray-500: #4c4a54;\n --color-gray-600: #2e2c33;\n --color-gray-700: #1e1d21;\n --color-gray-800: #101012;\n --color-gray-900: #09090a;\n\n --color-VFDBlue-100: #0d3814;\n --color-VFDBlue-200: #234e4a;\n --color-VFDBlue-300: #128073;\n --color-VFDBlue-400: #138c6e;\n --color-VFDBlue-500: #1abe95;\n --color-VFDBlue-600: #23d8a4;\n --color-VFDBlue-700: #4aeea4;\n --color-VFDBlue-1000: #35edb4;\n --spacing-none: 0px;\n --spacing-xs: 2px;\n --spacing-sm: 4px;\n --spacing-ms: 6px;\n --spacing-md: 8px;\n --spacing-ml: 12px;\n --spacing-lg: 16px;\n --spacing-xl: 20px;\n --m-none: 0px;\n --m-xs: 2px;\n --m-sm: 4px;\n --m-ms: 6px;\n --m-md: 8px;\n --m-ml: 12px;\n --m-lg: 16px;\n --m-xl: 20px;\n --mt-none: 0px;\n --mt-xs: 2px;\n --mt-sm: 4px;\n --mt-ms: 6px;\n --mt-md: 8px;\n --mt-ml: 12px;\n --mt-lg: 16px;\n --mt-xl: 20px;\n --mr-none: 0px;\n --mr-xs: 2px;\n --mr-sm: 4px;\n --mr-ms: 6px;\n --mr-md: 8px;\n --mr-ml: 12px;\n --mr-lg: 16px;\n --mr-xl: 20px;\n --mb-none: 0px;\n --mb-xs: 2px;\n --mb-sm: 4px;\n --mb-ms: 6px;\n --mb-md: 8px;\n --mb-ml: 12px;\n --mb-lg: 16px;\n --mb-xl: 20px;\n --ml-none: 0px;\n --ml-xs: 2px;\n --ml-sm: 4px;\n --ml-ms: 6px;\n --ml-md: 8px;\n --ml-ml: 12px;\n --ml-lg: 16px;\n --ml-xl: 20px;\n --p-none: 0px;\n --p-xs: 2px;\n --p-sm: 4px;\n --p-ms: 6px;\n --p-md: 8px;\n --p-ml: 12px;\n --p-lg: 16px;\n --p-xl: 20px;\n --pt-none: 0px;\n --pt-xs: 2px;\n --pt-sm: 4px;\n --pt-ms: 6px;\n --pt-md: 8px;\n --pt-ml: 12px;\n --pt-lg: 16px;\n --pt-xl: 20px;\n --pr-none: 0px;\n --pr-xs: 2px;\n --pr-sm: 4px;\n --pr-ms: 6px;\n --pr-md: 8px;\n --pr-ml: 12px;\n --pr-lg: 16px;\n --pr-xl: 20px;\n --pb-none: 0px;\n --pb-xs: 2px;\n --pb-sm: 4px;\n --pb-ms: 6px;\n --pb-md: 8px;\n --pb-ml: 12px;\n --pb-lg: 16px;\n --pb-xl: 20px;\n --pl-none: 0px;\n --pl-xs: 2px;\n --pl-sm: 4px;\n --pl-ms: 6px;\n --pl-md: 8px;\n --pl-ml: 12px;\n --pl-lg: 16px;\n --pl-xl: 20px;\n --bg-lv1: #0e0e12;\n --bg-lv2: #121216;\n --bg-lv3: #16171d;\n --bg-lv4: #212128;\n --bg-lv5: #2b2b31;\n --bg-lv6: #34343a;\n --bg-lv7: #3b3b41;\n --bg-lv8: #49494d;\n --bg-lv9: #535357;\n --bg-lv10: #797887;\n --bg-lv11: #9999a7;\n --bg-lv12: #c1c1c1;\n --bg-selected: #2e2c33;\n\n /* --bg-lv3-brightened: #1a1b21; */\n\n --font-leagueSpartan: 'LeagueSpartan';\n --text-xs: 0.625rem;\n --text-sm: 0.75rem;\n --text-ms: 0.813rem;\n --text-md: 0.875rem;\n --text-lg: 1rem;\n --text-xl: 1.25rem;\n --text-title: 1.75rem;\n --gap-none: 0px;\n --gap-xs: 2px;\n --gap-sm: 4px;\n --gap-ms: 6px;\n --gap-md: 8px;\n --gap-ml: 12px;\n --gap-lg: 16px;\n --gap-xl: 20px;\n}\n\ninput,\ninput:hover,\ninput:focus,\ninput:focus-visible {\n background: transparent;\n border: none;\n outline: none;\n appearance: textfield;\n}\n\nbutton,\nbutton:hover,\nbutton:focus,\nbutton:focus-visible {\n outline: none;\n}\n\nbutton:disabled,\ninput:disabled {\n cursor: default;\n}\n\ndiv:focus,\ndiv:focus-visible {\n outline: none;\n appearance: textfield;\n}\n\n.cursor-hidden * {\n cursor: none !important;\n}\n::-webkit-scrollbar,\n::-webkit-scrollbar-track {\n background-color: var(--color-gray-600);\n}\n\n::-webkit-scrollbar-thumb {\n background-color: #252429;\n}\n\n* {\n -ms-overflow-style: none;\n}\n\n/* div::-webkit-scrollbar {\n display: none;\n} */\n\n@font-face {\n font-family: LeagueSpartan;\n /* ascent-override: 70%; */\n src: url('./common/assets/fonts/LeagueSpartan-Regular.ttf');\n}\n\n@font-face {\n font-family: LeagueSpartan;\n /* ascent-override: 70%; */\n src: url('./common/assets/fonts/LeagueSpartan-Thin.ttf');\n font-weight: lighter;\n}\n";
37
+ var css_248z$g = "@theme static {\n --color-brand: #bb68d9;\n --color-brand-900: #1b181c;\n /* --color-brand-900: #443342; */\n --color-brand-700: #932eb8;\n --color-brand-600: #ac47d1;\n --color-brand-400: #d199e6;\n --color-brand-300: #f3d4f4;\n --color-brand-secondary: #18d6d6;\n --color-alert: #8a0101;\n --color-text: #bab6cf;\n --color-gray-100: #c7c3de;\n --color-gray-200: #9a96ab;\n --color-gray-300: #838091;\n --color-gray-400: #595763;\n --color-gray-500: #4c4a54;\n --color-gray-600: #2e2c33;\n --color-gray-700: #1e1d21;\n --color-gray-800: #101012;\n --color-gray-900: #09090a;\n\n --color-VFDBlue-100: #0d3814;\n --color-VFDBlue-200: #234e4a;\n --color-VFDBlue-300: #128073;\n --color-VFDBlue-400: #138c6e;\n --color-VFDBlue-500: #1abe95;\n --color-VFDBlue-600: #23d8a4;\n --color-VFDBlue-700: #4aeea4;\n --color-VFDBlue-1000: #35edb4;\n --spacing-none: 0px;\n --spacing-xs: 2px;\n --spacing-sm: 4px;\n --spacing-ms: 6px;\n --spacing-md: 8px;\n --spacing-ml: 12px;\n --spacing-lg: 16px;\n --spacing-xl: 20px;\n --m-none: 0px;\n --m-xs: 2px;\n --m-sm: 4px;\n --m-ms: 6px;\n --m-md: 8px;\n --m-ml: 12px;\n --m-lg: 16px;\n --m-xl: 20px;\n --mt-none: 0px;\n --mt-xs: 2px;\n --mt-sm: 4px;\n --mt-ms: 6px;\n --mt-md: 8px;\n --mt-ml: 12px;\n --mt-lg: 16px;\n --mt-xl: 20px;\n --mr-none: 0px;\n --mr-xs: 2px;\n --mr-sm: 4px;\n --mr-ms: 6px;\n --mr-md: 8px;\n --mr-ml: 12px;\n --mr-lg: 16px;\n --mr-xl: 20px;\n --mb-none: 0px;\n --mb-xs: 2px;\n --mb-sm: 4px;\n --mb-ms: 6px;\n --mb-md: 8px;\n --mb-ml: 12px;\n --mb-lg: 16px;\n --mb-xl: 20px;\n --ml-none: 0px;\n --ml-xs: 2px;\n --ml-sm: 4px;\n --ml-ms: 6px;\n --ml-md: 8px;\n --ml-ml: 12px;\n --ml-lg: 16px;\n --ml-xl: 20px;\n --p-none: 0px;\n --p-xs: 2px;\n --p-sm: 4px;\n --p-ms: 6px;\n --p-md: 8px;\n --p-ml: 12px;\n --p-lg: 16px;\n --p-xl: 20px;\n --pt-none: 0px;\n --pt-xs: 2px;\n --pt-sm: 4px;\n --pt-ms: 6px;\n --pt-md: 8px;\n --pt-ml: 12px;\n --pt-lg: 16px;\n --pt-xl: 20px;\n --pr-none: 0px;\n --pr-xs: 2px;\n --pr-sm: 4px;\n --pr-ms: 6px;\n --pr-md: 8px;\n --pr-ml: 12px;\n --pr-lg: 16px;\n --pr-xl: 20px;\n --pb-none: 0px;\n --pb-xs: 2px;\n --pb-sm: 4px;\n --pb-ms: 6px;\n --pb-md: 8px;\n --pb-ml: 12px;\n --pb-lg: 16px;\n --pb-xl: 20px;\n --pl-none: 0px;\n --pl-xs: 2px;\n --pl-sm: 4px;\n --pl-ms: 6px;\n --pl-md: 8px;\n --pl-ml: 12px;\n --pl-lg: 16px;\n --pl-xl: 20px;\n --bg-lv1: #0e0e12;\n --bg-lv2: #121216;\n --bg-lv3: #16171d;\n --bg-lv4: #212128;\n --bg-lv5: #2b2b31;\n --bg-lv6: #3b3b44;\n --bg-lv7: #4c4a54;\n --bg-lv8: #595763;\n --bg-lv9: #838091;\n --bg-lv10: #9a96ab;\n --bg-lv11: #9999a7;\n --bg-lv12: #c1c1c1;\n --bg-selected: #2e2c33;\n\n /* --bg-lv3-brightened: #1a1b21; */\n\n --font-leagueSpartan: 'LeagueSpartan';\n --text-xs: 0.625rem;\n --text-sm: 0.7rem;\n --text-ms: 0.813rem;\n --text-md: 0.875rem;\n --text-lg: 1rem;\n --text-xl: 1.25rem;\n --text-title: 1.75rem;\n --gap-none: 0px;\n --gap-xs: 2px;\n --gap-sm: 4px;\n --gap-ms: 6px;\n --gap-md: 8px;\n --gap-ml: 12px;\n --gap-lg: 16px;\n --gap-xl: 20px;\n}\n\ninput,\ninput:hover,\ninput:focus,\ninput:focus-visible {\n background: transparent;\n border: none;\n outline: none;\n appearance: textfield;\n}\n\nbutton,\nbutton:hover,\nbutton:focus,\nbutton:focus-visible {\n outline: none;\n}\n\nbutton:disabled,\ninput:disabled {\n cursor: default;\n}\n\ndiv:focus,\ndiv:focus-visible {\n outline: none;\n appearance: textfield;\n}\n\n/* .cursor-hidden * {\n cursor: none !important;\n} */\n::-webkit-scrollbar,\n::-webkit-scrollbar-track {\n background-color: var(--bg-lv4);\n scrollbar-width: 3px;\n}\n\n::-webkit-scrollbar-thumb {\n background-color: var(--bg-lv7);\n border-radius: 6px;\n width: 3px;\n}\n\n* {\n -ms-overflow-style: none;\n}\n\n/* div::-webkit-scrollbar {\n display: none;\n} */\n\n@font-face {\n font-family: LeagueSpartan;\n /* ascent-override: 70%; */\n src: url('./common/assets/fonts/LeagueSpartan-Regular.ttf');\n}\n\n@font-face {\n font-family: LeagueSpartan;\n /* ascent-override: 70%; */\n src: url('./common/assets/fonts/LeagueSpartan-Thin.ttf');\n font-weight: lighter;\n}\n";
38
38
  styleInject(css_248z$g);
39
39
 
40
40
  var Spacing = /*#__PURE__*/ function(Spacing) {
@@ -96,6 +96,7 @@ var FontSizes = /*#__PURE__*/ function(FontSizes) {
96
96
  FontSizes["xSmall"] = "xs";
97
97
  FontSizes["small"] = "sm";
98
98
  FontSizes["medium"] = "md";
99
+ FontSizes["mediumSmall"] = "ms";
99
100
  FontSizes["large"] = "lg";
100
101
  FontSizes["xLarge"] = "xl";
101
102
  FontSizes["title"] = "title";
@@ -153,260 +154,14 @@ var ButtonType = /*#__PURE__*/ function(ButtonType) {
153
154
  return ButtonType;
154
155
  }({});
155
156
 
156
- function useObservable(param) {
157
- var onFire = param.onFire;
158
- var observers = useRef([]);
159
- var subscribe = function(observer, id) {
160
- var _observers_current;
161
- if (((_observers_current = observers.current) === null || _observers_current === void 0 ? void 0 : _observers_current.find(function(item) {
162
- return item[1] === id;
163
- })) === undefined) {
164
- observers.current.push([
165
- observer,
166
- id
167
- ]);
168
- }
169
- };
170
- var unsubscribe = function(observer, id) {
171
- var _observers_current;
172
- if (((_observers_current = observers.current) === null || _observers_current === void 0 ? void 0 : _observers_current.find(function(item) {
173
- return item[1] === id;
174
- })) !== undefined) {
175
- var _observers_current1;
176
- var index = (_observers_current1 = observers.current) === null || _observers_current1 === void 0 ? void 0 : _observers_current1.findIndex(function(item) {
177
- return item[1] === id;
178
- });
179
- observers.current.splice(index, 1);
180
- }
181
- };
182
- var fire = function() {
183
- var _observers_current;
184
- onFire();
185
- (_observers_current = observers.current) === null || _observers_current === void 0 ? void 0 : _observers_current.forEach(function(observer) {
186
- return observer[0]();
187
- });
188
- };
189
- return {
190
- subscribe: subscribe,
191
- unsubscribe: unsubscribe,
192
- fire: fire
193
- };
194
- }
195
-
196
157
  function _array_like_to_array$i(arr, len) {
197
158
  if (len == null || len > arr.length) len = arr.length;
198
159
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
199
160
  return arr2;
200
161
  }
201
- function _array_without_holes$2(arr) {
202
- if (Array.isArray(arr)) return _array_like_to_array$i(arr);
203
- }
204
- function _iterable_to_array$2(iter) {
205
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
206
- }
207
- function _non_iterable_spread$2() {
208
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
209
- }
210
- function _to_consumable_array$2(arr) {
211
- return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$i(arr) || _non_iterable_spread$2();
212
- }
213
- function _unsupported_iterable_to_array$i(o, minLen) {
214
- if (!o) return;
215
- if (typeof o === "string") return _array_like_to_array$i(o, minLen);
216
- var n = Object.prototype.toString.call(o).slice(8, -1);
217
- if (n === "Object" && o.constructor) n = o.constructor.name;
218
- if (n === "Map" || n === "Set") return Array.from(n);
219
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$i(o, minLen);
220
- }
221
- // export const roundUpToTwoDecimals = (val: number) => Math.ceil(val * 100) / 100;
222
- // mocks the `normalisedToScaledValue` internal method from JUCE
223
- // This will allow us to test the JS UI without needing access to the JUCE backend
224
- // ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false)
225
- function normalisedToScaled(param) {
226
- var normalisedValue = param.normalisedValue, properties = param.properties;
227
- var skew = properties.skew, end = properties.end, start = properties.start;
228
- return Math.pow(normalisedValue, 1 / skew) * (end - start) + start;
229
- }
230
- // mocks the `getnormalisedValue` method from JUCE
231
- // This will allow us to test the JS UI without needing access to the JUCE backend
232
- function scaledToNormalised(param) {
233
- var scaledValue = param.scaledValue, start = param.start, end = param.end, skew = param.skew;
234
- return Math.pow((scaledValue - start) / (end - start), skew !== null && skew !== void 0 ? skew : 1);
235
- }
236
- var decimalToPercent = function(decimal) {
237
- return Math.round(100 * (typeof decimal === 'string' ? parseFloat(decimal) : decimal));
238
- };
239
- var percentToDecimal = function(percent) {
240
- return Math.round(0.01 * (typeof percent === 'string' ? parseFloat(percent) : percent));
241
- };
242
- var inputCharacterIsValid = function(char) {
243
- var validCharacter = /^[\d.-]$/;
244
- return validCharacter.test(char.toString());
245
- };
246
- var clamp = function(val) {
247
- var min = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, max = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
248
- return Math.max(min, Math.min(max, val));
249
- };
250
- function snapToLegalValue(param) {
251
- var value = param.value, properties = param.properties;
252
- var interval = properties.interval, start = properties.start, end = properties.end;
253
- if (interval == 0) return value;
254
- var roundedInterval = parseFloat(interval === null || interval === void 0 ? void 0 : interval.toFixed(2));
255
- var formattedValue = start + roundedInterval * Math.floor((value - start) / roundedInterval + 0.5);
256
- return clamp(parseFloat(formattedValue.toFixed(2)), start, end);
257
- }
258
- // const validNumber = /^-?\.?\d+(\.\d)?$/;
259
- // const lastNumberIsDigit = /\d$/;
260
- var validateInputChange = function(e) {
261
- return e.nativeEvent.data === '' || e.nativeEvent.data === null || inputCharacterIsValid(e.nativeEvent.data);
262
- };
263
- var getValidValueForInput = function(param) {
264
- var value = param.value, oldValue = param.oldValue, properties = param.properties;
265
- var _splitValueArray_;
266
- // TODO: Clean up
267
- var matchCriteria = /^-?(?:\d+\.\d+|\d+|\.\d+)$/g;
268
- var splitValue = value.toString().matchAll(matchCriteria);
269
- var splitValueArray = _to_consumable_array$2(splitValue);
270
- var validValue = splitValueArray === null || splitValueArray === void 0 ? void 0 : (_splitValueArray_ = splitValueArray[0]) === null || _splitValueArray_ === void 0 ? void 0 : _splitValueArray_[0];
271
- var start = properties.start, end = properties.end;
272
- if (validValue !== null && validValue !== undefined) {
273
- if (parseFloat(validValue) > end) {
274
- return end;
275
- } else if (parseFloat(validValue) < start) {
276
- return start;
277
- } else {
278
- return snapToLegalValue({
279
- value: parseFloat(validValue),
280
- properties: properties
281
- });
282
- }
283
- } else {
284
- return oldValue;
285
- }
286
- };
287
- var getBarTransformStyles = function(param) {
288
- var polarity = param.polarity, orientation = param.orientation, normalisedValue = param.normalisedValue, isDisabled = param.isDisabled;
289
- var wholeNumberNormalisedValue = normalisedValue * 100;
290
- var unipolarValue = wholeNumberNormalisedValue ? parseFloat(wholeNumberNormalisedValue === null || wholeNumberNormalisedValue === void 0 ? void 0 : wholeNumberNormalisedValue.toFixed(2)) : 0;
291
- var bipolarValue = (wholeNumberNormalisedValue - 50) / 100;
292
- if (!isDisabled) {
293
- if (polarity === Polarity.unipolar) {
294
- return orientation === Orientation.horizontal ? {
295
- width: unipolarValue ? "100%" : '1px',
296
- height: '100%',
297
- transform: unipolarValue ? "scale(".concat(Math.ceil(unipolarValue) * 0.01, ", 1)") : 'none',
298
- transformOrigin: 'center left',
299
- top: '0',
300
- bottom: '0',
301
- left: '0'
302
- } : {
303
- width: "100%",
304
- height: unipolarValue ? '100%' : '1px',
305
- transform: "scale(1, ".concat(Math.ceil(unipolarValue) * 0.01, ")"),
306
- transformOrigin: 'bottom center',
307
- top: '0',
308
- bottom: '0',
309
- left: '0'
310
- };
311
- } else {
312
- return orientation === Orientation.horizontal ? {
313
- width: bipolarValue ? "100%" : '1px',
314
- height: '100%',
315
- transform: bipolarValue ? "scale(".concat(bipolarValue, ", 1)") : 'none',
316
- transformOrigin: 'left center',
317
- top: '0',
318
- bottom: '0',
319
- left: '50%'
320
- } : {
321
- width: "100%",
322
- height: bipolarValue ? '100%' : '1px',
323
- transform: bipolarValue ? "scale(1, ".concat(bipolarValue, ")") : 'none',
324
- transformOrigin: 'bottom center',
325
- bottom: '50%',
326
- left: '0',
327
- right: '0'
328
- };
329
- }
330
- } else return;
331
- };
332
- var randomizeValue = function(min, max) {
333
- return Math.random() * (max - min) + min;
334
- };
335
- var incrementValue = function(param) {
336
- var incomingVal = param.incomingVal, prevVal = param.prevVal, interval = param.interval;
337
- var getNormalisedInterval = function() {
338
- if (interval) {
339
- if (interval >= 1) {
340
- return interval * 0.01;
341
- } else {
342
- return interval;
343
- }
344
- } else {
345
- return 0.01;
346
- }
347
- };
348
- var normalisedInterval = getNormalisedInterval();
349
- var newValue = (prevVal !== null && prevVal !== void 0 ? prevVal : 0) + incomingVal * // (interval && interval.toString().length > 4
350
- // ? 4
351
- // : 0.4) *
352
- normalisedInterval;
353
- return clamp(newValue);
354
- };
355
- var timerFlag = null;
356
- function throttle(mainFunction, delay) {
357
- return function() {
358
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
359
- args[_key] = arguments[_key];
360
- }
361
- if (timerFlag === null) {
362
- mainFunction.apply(void 0, _to_consumable_array$2(args));
363
- timerFlag = setTimeout(function() {
364
- timerFlag = null;
365
- }, delay);
366
- }
367
- };
368
- }
369
-
370
- function _array_like_to_array$h(arr, len) {
371
- if (len == null || len > arr.length) len = arr.length;
372
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
373
- return arr2;
374
- }
375
162
  function _array_with_holes$h(arr) {
376
163
  if (Array.isArray(arr)) return arr;
377
164
  }
378
- function _array_without_holes$1(arr) {
379
- if (Array.isArray(arr)) return _array_like_to_array$h(arr);
380
- }
381
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
382
- try {
383
- var info = gen[key](arg);
384
- var value = info.value;
385
- } catch (error) {
386
- reject(error);
387
- return;
388
- }
389
- if (info.done) {
390
- resolve(value);
391
- } else {
392
- Promise.resolve(value).then(_next, _throw);
393
- }
394
- }
395
- function _async_to_generator$4(fn) {
396
- return function() {
397
- var self = this, args = arguments;
398
- return new Promise(function(resolve, reject) {
399
- var gen = fn.apply(self, args);
400
- function _next(value) {
401
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
402
- }
403
- function _throw(err) {
404
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
405
- }
406
- _next(undefined);
407
- });
408
- };
409
- }
410
165
  function _define_property$o(obj, key, value) {
411
166
  if (key in obj) {
412
167
  Object.defineProperty(obj, key, {
@@ -420,9 +175,6 @@ function _define_property$o(obj, key, value) {
420
175
  }
421
176
  return obj;
422
177
  }
423
- function _iterable_to_array$1(iter) {
424
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
425
- }
426
178
  function _iterable_to_array_limit$h(arr, i) {
427
179
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
428
180
  if (_i == null) return;
@@ -450,9 +202,6 @@ function _iterable_to_array_limit$h(arr, i) {
450
202
  function _non_iterable_rest$h() {
451
203
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
452
204
  }
453
- function _non_iterable_spread$1() {
454
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
455
- }
456
205
  function _object_spread$n(target) {
457
206
  for(var i = 1; i < arguments.length; i++){
458
207
  var source = arguments[i] != null ? arguments[i] : {};
@@ -468,11 +217,168 @@ function _object_spread$n(target) {
468
217
  }
469
218
  return target;
470
219
  }
471
- function ownKeys$4(object, enumerableOnly) {
472
- var keys = Object.keys(object);
473
- if (Object.getOwnPropertySymbols) {
474
- var symbols = Object.getOwnPropertySymbols(object);
475
- keys.push.apply(keys, symbols);
220
+ function _sliced_to_array$h(arr, i) {
221
+ return _array_with_holes$h(arr) || _iterable_to_array_limit$h(arr, i) || _unsupported_iterable_to_array$i(arr, i) || _non_iterable_rest$h();
222
+ }
223
+ function _unsupported_iterable_to_array$i(o, minLen) {
224
+ if (!o) return;
225
+ if (typeof o === "string") return _array_like_to_array$i(o, minLen);
226
+ var n = Object.prototype.toString.call(o).slice(8, -1);
227
+ if (n === "Object" && o.constructor) n = o.constructor.name;
228
+ if (n === "Map" || n === "Set") return Array.from(n);
229
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$i(o, minLen);
230
+ }
231
+ function Button(param) {
232
+ var disabled = param.disabled, text = param.text, id = param.id, className = param.className, style = param.style, onClick = param.onClick, children = param.children, _param_padding = param.padding, padding = _param_padding === void 0 ? [
233
+ Spacing.small
234
+ ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
235
+ Spacing.none
236
+ ] : _param_margin, _param_type = param.type, type = _param_type === void 0 ? ButtonType.latch : _param_type, size = param.size;
237
+ var _React_useState = _sliced_to_array$h(React__default.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
238
+ var buttonState = Juce.getToggleState(id);
239
+ var isLocalhost = window.location.hostname === 'localhost';
240
+ // const { updateModSlotRowTarget } = useGlobalContext();
241
+ // Update the local state when the ID changes
242
+ useEffect(function() {
243
+ setIsSelected(buttonState === null || buttonState === void 0 ? void 0 : buttonState.value);
244
+ }, [
245
+ id
246
+ ]);
247
+ // Sets up listeners to handle changes on the backend
248
+ useEffect(function() {
249
+ if (!isLocalhost && !onClick) {
250
+ var valueListenerId = buttonState === null || buttonState === void 0 ? void 0 : buttonState.valueChangedEvent.addListener(function() {
251
+ setIsSelected(buttonState === null || buttonState === void 0 ? void 0 : buttonState.value);
252
+ });
253
+ return function cleanup() {
254
+ buttonState === null || buttonState === void 0 ? void 0 : buttonState.valueChangedEvent.removeListener(valueListenerId);
255
+ };
256
+ } else {
257
+ return;
258
+ }
259
+ });
260
+ var handleMouseDown = function(e) {
261
+ // TODO: handle this in a callback?
262
+ // updateModSlotRowTarget({
263
+ // value: id,
264
+ // saveToBackend: false,
265
+ // });
266
+ if (!onClick) {
267
+ e.preventDefault();
268
+ if (type === ButtonType.momentary) {
269
+ setIsSelected(true);
270
+ buttonState.setValue(true);
271
+ } else {
272
+ setIsSelected(!isSelected);
273
+ buttonState.setValue(!isSelected);
274
+ }
275
+ }
276
+ };
277
+ var handleMouseUp = function() {
278
+ if (!onClick) {
279
+ setIsSelected(false);
280
+ buttonState.setValue(false);
281
+ }
282
+ };
283
+ React__default.useEffect(function() {
284
+ if (type === ButtonType.momentary && !onClick) {
285
+ window.addEventListener('mouseup', handleMouseUp);
286
+ return function() {
287
+ window.removeEventListener('mouseup', handleMouseUp);
288
+ };
289
+ }
290
+ return;
291
+ }, [
292
+ isSelected
293
+ ]);
294
+ var _padding_, _padding_1, _padding_2, _ref, _margin_, _margin_1, _margin_2, _ref1;
295
+ return /*#__PURE__*/ React__default.createElement("button", {
296
+ id: id,
297
+ onMouseDown: handleMouseDown,
298
+ disabled: disabled,
299
+ onClick: onClick && onClick,
300
+ style: _object_spread$n({
301
+ paddingTop: "var(--p-".concat(padding[0], ")"),
302
+ paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
303
+ paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
304
+ paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
305
+ marginTop: "var(--p-".concat(margin[0], ")"),
306
+ marginRight: "var(--p-".concat((_margin_ = margin[1]) !== null && _margin_ !== void 0 ? _margin_ : margin[0], ")"),
307
+ marginBottom: "var(--p-".concat((_margin_1 = margin[2]) !== null && _margin_1 !== void 0 ? _margin_1 : margin[0], ")"),
308
+ marginLeft: "var(--p-".concat((_ref1 = (_margin_2 = margin[3]) !== null && _margin_2 !== void 0 ? _margin_2 : margin[1]) !== null && _ref1 !== void 0 ? _ref1 : margin[0], ")")
309
+ }, style),
310
+ className: classnames('Button', isSelected && 'selected', "".concat(size), className)
311
+ }, size !== ButtonSize.xSmall && (text ? text : children));
312
+ }
313
+ Button.padding = Spacing;
314
+ Button.margin = Spacing;
315
+ Button.type = ButtonType;
316
+ Button.size = ButtonSize;
317
+
318
+ var css_248z$d = ".IconButton {\n cursor: pointer;\n}\n.IconButton:hover:not(:disabled) {\n filter: brightness(80%);\n}\n";
319
+ styleInject(css_248z$d);
320
+
321
+ var JustifyContent = /*#__PURE__*/ function(JustifyContent) {
322
+ JustifyContent["flexStart"] = "flex-start";
323
+ JustifyContent["flexEnd"] = "flex-end";
324
+ JustifyContent["center"] = "center";
325
+ JustifyContent["spaceBetween"] = "space-between";
326
+ JustifyContent["spaceAround"] = "space-around";
327
+ JustifyContent["spaceEvenly"] = "space-evenly";
328
+ return JustifyContent;
329
+ }({});
330
+ var AlignItems = /*#__PURE__*/ function(AlignItems) {
331
+ AlignItems["flexStart"] = "flex-start";
332
+ AlignItems["flexEnd"] = "flex-end";
333
+ AlignItems["center"] = "center";
334
+ AlignItems["stretch"] = "stretch";
335
+ AlignItems["baseline"] = "baseline";
336
+ return AlignItems;
337
+ }({});
338
+ var LayoutTags = /*#__PURE__*/ function(LayoutTags) {
339
+ LayoutTags["header"] = "header";
340
+ LayoutTags["main"] = "main";
341
+ LayoutTags["section"] = "section";
342
+ LayoutTags["div"] = "div";
343
+ LayoutTags["footer"] = "footer";
344
+ LayoutTags["ul"] = "ul";
345
+ LayoutTags["li"] = "li";
346
+ return LayoutTags;
347
+ }({});
348
+
349
+ function _define_property$n(obj, key, value) {
350
+ if (key in obj) {
351
+ Object.defineProperty(obj, key, {
352
+ value: value,
353
+ enumerable: true,
354
+ configurable: true,
355
+ writable: true
356
+ });
357
+ } else {
358
+ obj[key] = value;
359
+ }
360
+ return obj;
361
+ }
362
+ function _object_spread$m(target) {
363
+ for(var i = 1; i < arguments.length; i++){
364
+ var source = arguments[i] != null ? arguments[i] : {};
365
+ var ownKeys = Object.keys(source);
366
+ if (typeof Object.getOwnPropertySymbols === "function") {
367
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
368
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
369
+ }));
370
+ }
371
+ ownKeys.forEach(function(key) {
372
+ _define_property$n(target, key, source[key]);
373
+ });
374
+ }
375
+ return target;
376
+ }
377
+ function ownKeys$4(object, enumerableOnly) {
378
+ var keys = Object.keys(object);
379
+ if (Object.getOwnPropertySymbols) {
380
+ var symbols = Object.getOwnPropertySymbols(object);
381
+ keys.push.apply(keys, symbols);
476
382
  }
477
383
  return keys;
478
384
  }
@@ -487,947 +393,186 @@ function _object_spread_props$4(target, source) {
487
393
  }
488
394
  return target;
489
395
  }
490
- function _sliced_to_array$h(arr, i) {
491
- return _array_with_holes$h(arr) || _iterable_to_array_limit$h(arr, i) || _unsupported_iterable_to_array$h(arr, i) || _non_iterable_rest$h();
396
+ function _object_without_properties(source, excluded) {
397
+ if (source == null) return {};
398
+ var target = _object_without_properties_loose(source, excluded);
399
+ var key, i;
400
+ if (Object.getOwnPropertySymbols) {
401
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
402
+ for(i = 0; i < sourceSymbolKeys.length; i++){
403
+ key = sourceSymbolKeys[i];
404
+ if (excluded.indexOf(key) >= 0) continue;
405
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
406
+ target[key] = source[key];
407
+ }
408
+ }
409
+ return target;
492
410
  }
493
- function _to_consumable_array$1(arr) {
494
- return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$h(arr) || _non_iterable_spread$1();
411
+ function _object_without_properties_loose(source, excluded) {
412
+ if (source == null) return {};
413
+ var target = {};
414
+ var sourceKeys = Object.keys(source);
415
+ var key, i;
416
+ for(i = 0; i < sourceKeys.length; i++){
417
+ key = sourceKeys[i];
418
+ if (excluded.indexOf(key) >= 0) continue;
419
+ target[key] = source[key];
420
+ }
421
+ return target;
495
422
  }
496
- function _unsupported_iterable_to_array$h(o, minLen) {
497
- if (!o) return;
498
- if (typeof o === "string") return _array_like_to_array$h(o, minLen);
499
- var n = Object.prototype.toString.call(o).slice(8, -1);
500
- if (n === "Object" && o.constructor) n = o.constructor.name;
501
- if (n === "Map" || n === "Set") return Array.from(n);
502
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
423
+ var BoxDisplay = /*#__PURE__*/ function(BoxDisplay) {
424
+ BoxDisplay["flex"] = "flex";
425
+ BoxDisplay["block"] = "block";
426
+ return BoxDisplay;
427
+ }(BoxDisplay || {});
428
+ function Box(_param) {
429
+ var className = _param.className, style = _param.style, children = _param.children, flex = _param.flex, key = _param.key, onClick = _param.onClick, _param_alignItems = _param.alignItems, alignItems = _param_alignItems === void 0 ? AlignItems.center : _param_alignItems, _param_justifyContent = _param.justifyContent, justifyContent = _param_justifyContent === void 0 ? JustifyContent.center : _param_justifyContent, _param_display = _param.display, display = _param_display === void 0 ? "flex" : _param_display, _param_width = _param.width, width = _param_width === void 0 ? Width.full : _param_width, _param_flexWrap = _param.flexWrap, flexWrap = _param_flexWrap === void 0 ? FlexWrap.noWrap : _param_flexWrap, height = _param.height, _param_borderWidth = _param.borderWidth, borderWidth = _param_borderWidth === void 0 ? [
430
+ '0px',
431
+ '0px',
432
+ '0px',
433
+ '0px'
434
+ ] : _param_borderWidth, _param_borderStyle = _param.borderStyle, borderStyle = _param_borderStyle === void 0 ? BorderStyles.solid : _param_borderStyle, _param_borderColor = _param.borderColor, borderColor = _param_borderColor === void 0 ? 'var(--bg-lv8)' : _param_borderColor, _param_flexDirection = _param.flexDirection, flexDirection = _param_flexDirection === void 0 ? FlexDirection.row : _param_flexDirection, _param_fullHeight = _param.fullHeight, fullHeight = _param_fullHeight === void 0 ? false : _param_fullHeight, _param_padding = _param.padding, padding = _param_padding === void 0 ? [
435
+ Spacing.none,
436
+ Spacing.none,
437
+ Spacing.none,
438
+ Spacing.none
439
+ ] : _param_padding, _param_gap = _param.gap, gap = _param_gap === void 0 ? Spacing.xSmall : _param_gap, _param_tag = _param.tag, tag = _param_tag === void 0 ? LayoutTags.div : _param_tag, rest = _object_without_properties(_param, [
440
+ "className",
441
+ "style",
442
+ "children",
443
+ "flex",
444
+ "key",
445
+ "onClick",
446
+ "alignItems",
447
+ "justifyContent",
448
+ "display",
449
+ "width",
450
+ "flexWrap",
451
+ "height",
452
+ "borderWidth",
453
+ "borderStyle",
454
+ "borderColor",
455
+ "flexDirection",
456
+ "fullHeight",
457
+ "padding",
458
+ "gap",
459
+ "tag"
460
+ ]);
461
+ var Tag = tag;
462
+ var _padding_, _padding_1, _padding_2, _ref;
463
+ return /*#__PURE__*/ React__default.createElement(Tag, _object_spread_props$4(_object_spread$m({
464
+ // id="globalValues"
465
+ key: key,
466
+ className: className,
467
+ onClick: onClick
468
+ }, rest), {
469
+ style: _object_spread$m({
470
+ flexWrap: flexWrap,
471
+ display: display,
472
+ width: width,
473
+ gap: "var(--gap-".concat(gap, ")"),
474
+ paddingTop: "var(--p-".concat(padding[0], ")"),
475
+ paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
476
+ paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
477
+ paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
478
+ borderTop: borderWidth[0],
479
+ borderRight: borderWidth[1] !== null ? borderWidth[1] : borderWidth[0],
480
+ borderBottom: borderWidth[2] !== null ? borderWidth[2] : borderWidth[0],
481
+ borderLeft: borderWidth[3] !== null ? borderWidth[3] : borderWidth[1] !== null ? borderWidth[1] : borderWidth[0],
482
+ borderColor: borderColor,
483
+ borderStyle: borderStyle,
484
+ maxWidth: width,
485
+ height: fullHeight ? '100%' : height,
486
+ flexDirection: flexDirection === FlexDirection.row ? FlexDirection.row : FlexDirection.column,
487
+ justifyContent: "".concat(justifyContent),
488
+ alignItems: "".concat(alignItems),
489
+ flex: flex ? flex : ''
490
+ }, style)
491
+ }), children);
503
492
  }
504
- function _ts_generator$4(thisArg, body) {
505
- var f, y, t, _ = {
506
- label: 0,
507
- sent: function() {
508
- if (t[0] & 1) throw t[1];
509
- return t[1];
510
- },
511
- trys: [],
512
- ops: []
513
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
514
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
515
- return this;
516
- }), g;
517
- function verb(n) {
518
- return function(v) {
519
- return step([
520
- n,
521
- v
522
- ]);
523
- };
493
+ // Object.assign(Layout, width, height, ALIGN, JUSTIFY, DIRECTION, SPACING);
494
+ Box.display = BoxDisplay;
495
+ Box.alignItems = AlignItems;
496
+ Box.justifyContent = JustifyContent;
497
+ Box.gap = Spacing;
498
+ Box.flexDirection = FlexDirection;
499
+ Box.width = Width;
500
+ Box.height = Height;
501
+ Box.padding = Spacing;
502
+ Box.flexWrap = FlexWrap;
503
+ Box.tag = LayoutTags;
504
+
505
+ var css_248z$c = ".Icon svg {\n width: 100%;\n}\n";
506
+ styleInject(css_248z$c);
507
+
508
+ function _define_property$m(obj, key, value) {
509
+ if (key in obj) {
510
+ Object.defineProperty(obj, key, {
511
+ value: value,
512
+ enumerable: true,
513
+ configurable: true,
514
+ writable: true
515
+ });
516
+ } else {
517
+ obj[key] = value;
524
518
  }
525
- function step(op) {
526
- if (f) throw new TypeError("Generator is already executing.");
527
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
528
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
529
- if (y = 0, t) op = [
530
- op[0] & 2,
531
- t.value
532
- ];
533
- switch(op[0]){
534
- case 0:
535
- case 1:
536
- t = op;
537
- break;
538
- case 4:
539
- _.label++;
540
- return {
541
- value: op[1],
542
- done: false
543
- };
544
- case 5:
545
- _.label++;
546
- y = op[1];
547
- op = [
548
- 0
549
- ];
550
- continue;
551
- case 7:
552
- op = _.ops.pop();
553
- _.trys.pop();
554
- continue;
555
- default:
556
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
557
- _ = 0;
558
- continue;
559
- }
560
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
561
- _.label = op[1];
562
- break;
563
- }
564
- if (op[0] === 6 && _.label < t[1]) {
565
- _.label = t[1];
566
- t = op;
567
- break;
568
- }
569
- if (t && _.label < t[2]) {
570
- _.label = t[2];
571
- _.ops.push(op);
572
- break;
573
- }
574
- if (t[2]) _.ops.pop();
575
- _.trys.pop();
576
- continue;
577
- }
578
- op = body.call(thisArg, _);
579
- } catch (e) {
580
- op = [
581
- 6,
582
- e
583
- ];
584
- y = 0;
585
- } finally{
586
- f = t = 0;
519
+ return obj;
520
+ }
521
+ function _object_spread$l(target) {
522
+ for(var i = 1; i < arguments.length; i++){
523
+ var source = arguments[i] != null ? arguments[i] : {};
524
+ var ownKeys = Object.keys(source);
525
+ if (typeof Object.getOwnPropertySymbols === "function") {
526
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
527
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
528
+ }));
587
529
  }
588
- if (op[0] & 5) throw op[1];
589
- return {
590
- value: op[0] ? op[1] : void 0,
591
- done: true
592
- };
530
+ ownKeys.forEach(function(key) {
531
+ _define_property$m(target, key, source[key]);
532
+ });
593
533
  }
534
+ return target;
594
535
  }
595
- // Initial state
596
- var defaultGlobalStateValue = {
597
- highlightedItem: {
598
- label: 'Antimatter Audio',
599
- value: 0
600
- },
601
- // focusedItem: '',
602
- allParameters: [],
603
- automatableParamsList: [],
604
- automatableParamLabels: [],
605
- parameterTypes: [],
606
- modSlotTargets: {},
607
- modSlotIds: [],
608
- modSlotPreview: {
609
- slotId: '',
610
- targetIndex: 0,
611
- isEditable: false
612
- },
613
- modSlotParams: [],
614
- modSlotParamLabels: [],
615
- defaultParamValues: [],
616
- advancedView: false
617
- };
618
- // Reducer function to handle state updates
619
- var reducer = function(state, action) {
620
- switch(action.type){
621
- case 'HIGHLIGHTED_ITEM_CHANGED':
622
- return _object_spread_props$4(_object_spread$n({}, state), {
623
- highlightedItem: action.payload
624
- });
625
- // case 'FOCUSED_ITEM_CHANGED':
626
- // return { ...state, focusedItem: action.payload };
627
- case 'ADVANCED_VIEW_TOGGLED':
628
- return _object_spread_props$4(_object_spread$n({}, state), {
629
- advancedView: action.payload
630
- });
631
- case 'AUTOMATABLE_PARAMS_LIST_RECEIVED':
632
- return _object_spread_props$4(_object_spread$n({}, state), {
633
- automatableParamsList: action.payload
634
- });
635
- case 'AUTOMATABLE_PARAM_LABELS_RECEIVED':
636
- return _object_spread_props$4(_object_spread$n({}, state), {
637
- automatableParamLabels: action.payload
638
- });
639
- case 'PARAMETER_TYPES_RECEIVED':
640
- return _object_spread_props$4(_object_spread$n({}, state), {
641
- parameterTypes: action.payload
642
- });
643
- case 'ALL_PARAMETERS_RECEIVED':
644
- return _object_spread_props$4(_object_spread$n({}, state), {
645
- allParameters: action.payload
646
- });
647
- case 'MOD_SLOTS_RECEIVED':
648
- return _object_spread_props$4(_object_spread$n({}, state), {
649
- modSlotIds: action.payload.map(function(val) {
650
- return val[0];
651
- })
652
- });
653
- case 'MOD_SLOT_ROW_TARGETS_RECEIVED':
654
- var _action_payload;
655
- return _object_spread_props$4(_object_spread$n({}, state), {
656
- modSlotTargets: action === null || action === void 0 ? void 0 : (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.reduce(function(acc, val) {
657
- return _object_spread_props$4(_object_spread$n({}, acc), _define_property$o({}, val[0], val[1]));
658
- }, {})
659
- });
660
- case 'MOD_SLOT_ROW_TARGET_UPDATED':
661
- var _action_payload1, _action_payload2;
662
- return _object_spread_props$4(_object_spread$n({}, state), {
663
- modSlotTargets: _object_spread_props$4(_object_spread$n({}, state === null || state === void 0 ? void 0 : state.modSlotTargets), _define_property$o({}, (_action_payload1 = action.payload) === null || _action_payload1 === void 0 ? void 0 : _action_payload1.id, action === null || action === void 0 ? void 0 : (_action_payload2 = action.payload) === null || _action_payload2 === void 0 ? void 0 : _action_payload2.value))
664
- });
665
- case 'MOD_SLOT_PREVIEW_TARGET_INDEX_UPDATED':
666
- {
667
- return _object_spread_props$4(_object_spread$n({}, state), {
668
- modSlotPreview: _object_spread_props$4(_object_spread$n({}, state.modSlotPreview), {
669
- targetIndex: action.payload
670
- })
671
- });
672
- }
673
- case 'MOD_SLOT_PREVIEW_SLOT_ID_UPDATED':
674
- {
675
- return _object_spread_props$4(_object_spread$n({}, state), {
676
- modSlotPreview: _object_spread_props$4(_object_spread$n({}, state.modSlotPreview), {
677
- slotId: action === null || action === void 0 ? void 0 : action.payload
678
- })
679
- });
680
- }
681
- case 'SET_NEW_MOD_SLOT_PREVIEW':
682
- {
683
- var _state_modSlotIds_find;
684
- return _object_spread_props$4(_object_spread$n({}, state), {
685
- modSlotPreview: {
686
- slotId: (_state_modSlotIds_find = state.modSlotIds.find(function(item) {
687
- return state.modSlotTargets[item] <= 0;
688
- })) !== null && _state_modSlotIds_find !== void 0 ? _state_modSlotIds_find : '',
689
- isEditable: false,
690
- targetIndex: 0
691
- }
692
- });
693
- }
694
- case 'CLEAR_MOD_SLOT_PREVIEW':
695
- {
696
- return _object_spread_props$4(_object_spread$n({}, state), {
697
- modSlotPreview: {
698
- slotId: '',
699
- isEditable: false,
700
- targetIndex: 0
701
- }
702
- });
703
- }
704
- case 'MOD_SLOT_PREVIEW_IS_EDITABLE_UPDATED':
705
- {
706
- return _object_spread_props$4(_object_spread$n({}, state), {
707
- modSlotPreview: _object_spread_props$4(_object_spread$n({}, state.modSlotPreview), {
708
- isEditable: action === null || action === void 0 ? void 0 : action.payload
709
- })
710
- });
711
- }
712
- case 'MOD_SLOT_PARAMS_LIST_RECEIVED':
713
- var modSlotNames = Object.keys(state.modSlotTargets);
714
- return _object_spread_props$4(_object_spread$n({}, state), {
715
- modSlotParams: action === null || action === void 0 ? void 0 : action.payload.reduce(function(acc, item, i) {
716
- acc[modSlotNames[i]] = item;
717
- return acc;
718
- }, {})
719
- });
720
- case 'DEFAULT_PARAM_VALUES_RECEIVED':
721
- return _object_spread_props$4(_object_spread$n({}, state), {
722
- defaultParamValues: action === null || action === void 0 ? void 0 : action.payload
723
- });
724
- case 'MOD_SLOT_PARAM_LABELS_RECIEVED':
725
- return _object_spread_props$4(_object_spread$n({}, state), {
726
- modSlotParamLabels: action === null || action === void 0 ? void 0 : action.payload
727
- });
728
- default:
729
- return state;
730
- }
731
- };
732
- // Create the context
733
- var GlobalContext = /*#__PURE__*/ createContext({
734
- globalState: defaultGlobalStateValue
735
- });
736
- // Custom hook for consuming context with a selector
737
- function useGlobalContext(selector) {
738
- var localContext = useContext(GlobalContext);
739
- return selector ? selector(localContext) : localContext;
740
- }
741
- // Context provider
742
- function GlobalContextProvider(param) {
743
- var children = param.children;
744
- var _useReducer = _sliced_to_array$h(useReducer(reducer, defaultGlobalStateValue), 2), state = _useReducer[0], dispatch = _useReducer[1];
745
- var highlightedItemChanged = useCallback(function(highlightedItem) {
746
- dispatch({
747
- type: 'HIGHLIGHTED_ITEM_CHANGED',
748
- payload: highlightedItem
749
- });
750
- }, []);
751
- // const focusedItemChanged = useCallback((focusedItem: string) => {
752
- // dispatch({ type: 'FOCUSED_ITEM_CHANGED', payload: focusedItem });
753
- // }, []);
754
- var advancedViewToggled = useCallback(function(advancedView) {
755
- dispatch({
756
- type: 'ADVANCED_VIEW_TOGGLED',
757
- payload: advancedView
758
- });
759
- }, []);
760
- var automatableParamsListReceived = useCallback(function(automatableParamsList) {
761
- dispatch({
762
- type: 'AUTOMATABLE_PARAMS_LIST_RECEIVED',
763
- payload: [
764
- 'none'
765
- ].concat(_to_consumable_array$1(automatableParamsList))
766
- });
767
- }, []);
768
- var allParametersReceived = useCallback(function(allParameters) {
769
- dispatch({
770
- type: 'ALL_PARAMETERS_RECEIVED',
771
- payload: allParameters
772
- });
773
- }, []);
774
- var parameterTypesReceived = useCallback(function(parameterTypes) {
775
- dispatch({
776
- type: 'PARAMETER_TYPES_RECEIVED',
777
- payload: parameterTypes
778
- });
779
- }, []);
780
- var automatableParamLabelsReceived = useCallback(function(automatableParamLabels) {
781
- dispatch({
782
- type: 'AUTOMATABLE_PARAM_LABELS_RECEIVED',
783
- payload: automatableParamLabels
784
- });
785
- }, []);
786
- var defaultParamValuesReceived = useCallback(function(defaultParamValues) {
787
- dispatch({
788
- type: 'DEFAULT_PARAM_VALUES_RECEIVED',
789
- payload: defaultParamValues
790
- });
791
- }, []);
792
- var modSlotsReceived = useCallback(function(modSlots) {
793
- dispatch({
794
- type: 'MOD_SLOTS_RECEIVED',
795
- payload: modSlots
796
- });
797
- }, []);
798
- var modSlotRowTargetsReceived = useCallback(function(modSlots) {
799
- dispatch({
800
- type: 'MOD_SLOT_ROW_TARGETS_RECEIVED',
801
- payload: modSlots
802
- });
803
- }, []);
804
- var modSlotRowTargetUpdated = useCallback(function(modSlot) {
805
- dispatch({
806
- type: 'MOD_SLOT_ROW_TARGET_UPDATED',
807
- payload: modSlot
808
- });
809
- }, []);
810
- var modSlotPreviewTargetIndexUpdated = useCallback(function(targetIndex) {
811
- dispatch({
812
- type: 'MOD_SLOT_PREVIEW_TARGET_INDEX_UPDATED',
813
- payload: targetIndex
814
- });
815
- }, []);
816
- var modSlotPreviewIsEditableUpdated = useCallback(function(isEditable) {
817
- dispatch({
818
- type: 'MOD_SLOT_PREVIEW_IS_EDITABLE_UPDATED',
819
- payload: isEditable
820
- });
821
- }, []);
822
- var modSlotPreviewSlotIdUpdated = useCallback(function(slotId) {
823
- dispatch({
824
- type: 'MOD_SLOT_PREVIEW_SLOT_ID_UPDATED',
825
- payload: slotId
826
- });
827
- }, []);
828
- var setNewModSlotPreview = useCallback(function() {
829
- dispatch({
830
- type: 'SET_NEW_MOD_SLOT_PREVIEW',
831
- payload: null
832
- });
833
- }, []);
834
- var clearModSlotPreview = useCallback(function() {
835
- dispatch({
836
- type: 'CLEAR_MOD_SLOT_PREVIEW',
837
- payload: null
838
- });
839
- }, []);
840
- var modSlotParamsListReceived = useCallback(function(modSlotParams) {
841
- dispatch({
842
- type: 'MOD_SLOT_PARAMS_LIST_RECEIVED',
843
- payload: modSlotParams
844
- });
845
- }, []);
846
- var modSlotParamLabelsReceived = useCallback(function(modSlotParamLables) {
847
- dispatch({
848
- type: 'MOD_SLOT_PARAM_LABELS_RECIEVED',
849
- payload: modSlotParamLables
850
- });
851
- }, []);
852
- var setDefaultParameter = function(id) {
853
- var paramIndex = state === null || state === void 0 ? void 0 : state.allParameters.indexOf(id);
854
- var defaultValue = state === null || state === void 0 ? void 0 : state.defaultParamValues[paramIndex];
855
- var parameterType = state === null || state === void 0 ? void 0 : state.parameterTypes[paramIndex];
856
- if (parameterType === 'slider') {
857
- var _sliderState_properties, _sliderState_properties1, _sliderState_properties2;
858
- var sliderState = Juce.getSliderState(id);
859
- var normalisedDefaultValue = scaledToNormalised({
860
- scaledValue: defaultValue,
861
- start: sliderState === null || sliderState === void 0 ? void 0 : (_sliderState_properties = sliderState.properties) === null || _sliderState_properties === void 0 ? void 0 : _sliderState_properties.start,
862
- end: sliderState === null || sliderState === void 0 ? void 0 : (_sliderState_properties1 = sliderState.properties) === null || _sliderState_properties1 === void 0 ? void 0 : _sliderState_properties1.end,
863
- skew: sliderState === null || sliderState === void 0 ? void 0 : (_sliderState_properties2 = sliderState.properties) === null || _sliderState_properties2 === void 0 ? void 0 : _sliderState_properties2.skew
864
- });
865
- sliderState.setNormalisedValue(normalisedDefaultValue);
866
- // if(state?.modSlots)
867
- } else if (parameterType === 'combobox') {
868
- var comboBoxState = Juce.getComboBoxState(id);
869
- comboBoxState.setChoiceIndex(defaultValue);
870
- }
871
- };
872
- var getDefaultParameter = function(id) {
873
- var paramIndex = state === null || state === void 0 ? void 0 : state.allParameters.indexOf(id);
874
- return state === null || state === void 0 ? void 0 : state.defaultParamValues[paramIndex];
875
- };
876
- // const setModSlotTarget = (newTarget: number, rowId: string) => {
877
- // const comboBoxState = Juce.getComboBoxState(rowId);
878
- // comboBoxState?.setChoiceIndex(newTarget);
879
- // };
880
- var refetchModSlots = function() {
881
- return _async_to_generator$4(function() {
882
- var getAllModSlotsFunc, modSlotsData, e;
883
- return _ts_generator$4(this, function(_state) {
884
- switch(_state.label){
885
- case 0:
886
- _state.trys.push([
887
- 0,
888
- 2,
889
- ,
890
- 3
891
- ]);
892
- getAllModSlotsFunc = Juce.getNativeFunction('getAllModSlots');
893
- return [
894
- 4,
895
- getAllModSlotsFunc()
896
- ];
897
- case 1:
898
- modSlotsData = _state.sent();
899
- modSlotRowTargetsReceived(modSlotsData || []);
900
- return [
901
- 3,
902
- 3
903
- ];
904
- case 2:
905
- e = _state.sent();
906
- console.log(e);
907
- return [
908
- 3,
909
- 3
910
- ];
911
- case 3:
912
- return [
913
- 2
914
- ];
915
- }
916
- });
917
- })();
918
- };
919
- var setModSlotRowTargetAsPreview = function(param) {
920
- var paramIndex = param.paramIndex, paramId = param.paramId;
921
- var _Object_values;
922
- // Setting a row target for a preview row enables the preview row to be interactive.
923
- // This row target will not be saved to Juce until a user sets a new value for one of the inputs in the row.
924
- // This function only stores the target in local state and does NOT save anything to the Juce state.
925
- var targetIndex = paramId ? state.automatableParamsList.indexOf(paramId) : paramIndex;
926
- if (!((_Object_values = Object.values(state.modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.includes(targetIndex))) {
927
- setNewModSlotPreview();
928
- modSlotPreviewTargetIndexUpdated(targetIndex);
929
- modSlotPreviewIsEditableUpdated(true);
930
- }
931
- };
932
- var saveModSlotPreviewRowTargetToBackend = function(value, rowId) {
933
- var _state_modSlotPreview, _state_modSlotPreview1, _state_modSlotPreview2;
934
- var rowState = Juce.getComboBoxState(rowId);
935
- // If the row is a preview row, setting a target will remove the row's preview status.
936
- // In this scenario, we want to clear the current row's preview status and set a new preview row (if there is an unassigned mod slot available)
937
- var defaultParameter = getDefaultParameter(rowId);
938
- if (((_state_modSlotPreview = state.modSlotPreview) === null || _state_modSlotPreview === void 0 ? void 0 : _state_modSlotPreview.slotId) && ((_state_modSlotPreview1 = state.modSlotPreview) === null || _state_modSlotPreview1 === void 0 ? void 0 : _state_modSlotPreview1.targetIndex) && ((_state_modSlotPreview2 = state.modSlotPreview) === null || _state_modSlotPreview2 === void 0 ? void 0 : _state_modSlotPreview2.slotId) === rowId && defaultParameter !== null && defaultParameter !== undefined && value !== defaultParameter) {
939
- var _state_modSlotPreview3;
940
- modSlotRowTargetUpdated({
941
- id: state.modSlotPreview.slotId,
942
- value: state.modSlotPreview.targetIndex
943
- });
944
- rowState === null || rowState === void 0 ? void 0 : rowState.setChoiceIndex((_state_modSlotPreview3 = state.modSlotPreview) === null || _state_modSlotPreview3 === void 0 ? void 0 : _state_modSlotPreview3.targetIndex);
945
- clearModSlotPreview();
946
- setNewModSlotPreview();
947
- refetchModSlots();
948
- }
949
- };
950
- var updateModSlotRowTarget = function(value, rowId) {
951
- // An index of 0 = 'none' in the mod slot target list.
952
- // If the new row target value is 0, the user is deleting the row's target.
953
- // Clear all of the values that have been set for that target on the front end and in JUCE.
954
- var rowState = Juce.getComboBoxState(rowId);
955
- rowState === null || rowState === void 0 ? void 0 : rowState.setChoiceIndex(value);
956
- if (rowId === state.modSlotPreview.slotId) {
957
- clearModSlotPreview();
958
- }
959
- if (value === 0) {
960
- var _state_modSlotParams_rowId, _state_modSlotParams;
961
- state === null || state === void 0 ? void 0 : (_state_modSlotParams = state.modSlotParams) === null || _state_modSlotParams === void 0 ? void 0 : (_state_modSlotParams_rowId = _state_modSlotParams[rowId]) === null || _state_modSlotParams_rowId === void 0 ? void 0 : _state_modSlotParams_rowId.forEach(function(item) {
962
- setDefaultParameter(item);
963
- });
964
- clearModSlotPreview();
965
- setNewModSlotPreview();
966
- }
967
- modSlotRowTargetUpdated({
968
- id: rowId,
969
- value: value
970
- });
971
- refetchModSlots();
972
- };
973
- var onFire = function() {
974
- var //@ts-expect-error
975
- _window___JUCE___backend, _window___JUCE__, _window;
976
- (_window = window) === null || _window === void 0 ? void 0 : (_window___JUCE__ = _window.__JUCE__) === null || _window___JUCE__ === void 0 ? void 0 : (_window___JUCE___backend = _window___JUCE__.backend) === null || _window___JUCE___backend === void 0 ? void 0 : _window___JUCE___backend.emitEvent('setRandom', {});
977
- };
978
- var useRandom = useObservable({
979
- onFire: onFire
980
- });
981
- var value = {
982
- globalState: state,
983
- highlightedItemChanged: highlightedItemChanged,
984
- // focusedItemChanged,
985
- clearModSlotPreview: clearModSlotPreview,
986
- setNewModSlotPreview: setNewModSlotPreview,
987
- modSlotPreviewSlotIdUpdated: modSlotPreviewSlotIdUpdated,
988
- modSlotPreviewTargetIndexUpdated: modSlotPreviewTargetIndexUpdated,
989
- modSlotPreviewIsEditableUpdated: modSlotPreviewIsEditableUpdated,
990
- advancedViewToggled: advancedViewToggled,
991
- automatableParamsListReceived: automatableParamsListReceived,
992
- automatableParamLabelsReceived: automatableParamLabelsReceived,
993
- parameterTypesReceived: parameterTypesReceived,
994
- allParametersReceived: allParametersReceived,
995
- defaultParamValuesReceived: defaultParamValuesReceived,
996
- setDefaultParameter: setDefaultParameter,
997
- getDefaultParameter: getDefaultParameter,
998
- modSlotsReceived: modSlotsReceived,
999
- modSlotRowTargetsReceived: modSlotRowTargetsReceived,
1000
- // setModSlotTarget,
1001
- modSlotParamsListReceived: modSlotParamsListReceived,
1002
- modSlotParamLabelsReceived: modSlotParamLabelsReceived,
1003
- setModSlotRowTargetAsPreview: setModSlotRowTargetAsPreview,
1004
- saveModSlotPreviewRowTargetToBackend: saveModSlotPreviewRowTargetToBackend,
1005
- updateModSlotRowTarget: updateModSlotRowTarget,
1006
- useRandom: useRandom
1007
- };
1008
- return /*#__PURE__*/ React__default.createElement(GlobalContext.Provider, {
1009
- value: value
1010
- }, children);
1011
- }
1012
-
1013
- function _array_like_to_array$g(arr, len) {
1014
- if (len == null || len > arr.length) len = arr.length;
1015
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1016
- return arr2;
1017
- }
1018
- function _array_with_holes$g(arr) {
1019
- if (Array.isArray(arr)) return arr;
1020
- }
1021
- function _define_property$n(obj, key, value) {
1022
- if (key in obj) {
1023
- Object.defineProperty(obj, key, {
1024
- value: value,
1025
- enumerable: true,
1026
- configurable: true,
1027
- writable: true
1028
- });
1029
- } else {
1030
- obj[key] = value;
1031
- }
1032
- return obj;
1033
- }
1034
- function _iterable_to_array_limit$g(arr, i) {
1035
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1036
- if (_i == null) return;
1037
- var _arr = [];
1038
- var _n = true;
1039
- var _d = false;
1040
- var _s, _e;
1041
- try {
1042
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1043
- _arr.push(_s.value);
1044
- if (i && _arr.length === i) break;
1045
- }
1046
- } catch (err) {
1047
- _d = true;
1048
- _e = err;
1049
- } finally{
1050
- try {
1051
- if (!_n && _i["return"] != null) _i["return"]();
1052
- } finally{
1053
- if (_d) throw _e;
1054
- }
1055
- }
1056
- return _arr;
1057
- }
1058
- function _non_iterable_rest$g() {
1059
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1060
- }
1061
- function _object_spread$m(target) {
1062
- for(var i = 1; i < arguments.length; i++){
1063
- var source = arguments[i] != null ? arguments[i] : {};
1064
- var ownKeys = Object.keys(source);
1065
- if (typeof Object.getOwnPropertySymbols === "function") {
1066
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1067
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1068
- }));
1069
- }
1070
- ownKeys.forEach(function(key) {
1071
- _define_property$n(target, key, source[key]);
1072
- });
1073
- }
1074
- return target;
1075
- }
1076
- function _sliced_to_array$g(arr, i) {
1077
- return _array_with_holes$g(arr) || _iterable_to_array_limit$g(arr, i) || _unsupported_iterable_to_array$g(arr, i) || _non_iterable_rest$g();
1078
- }
1079
- function _unsupported_iterable_to_array$g(o, minLen) {
1080
- if (!o) return;
1081
- if (typeof o === "string") return _array_like_to_array$g(o, minLen);
1082
- var n = Object.prototype.toString.call(o).slice(8, -1);
1083
- if (n === "Object" && o.constructor) n = o.constructor.name;
1084
- if (n === "Map" || n === "Set") return Array.from(n);
1085
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
1086
- }
1087
- function Button(param) {
1088
- var disabled = param.disabled, text = param.text, id = param.id, className = param.className, style = param.style, onClick = param.onClick, children = param.children, _param_padding = param.padding, padding = _param_padding === void 0 ? [
1089
- Spacing.small
1090
- ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
1091
- Spacing.none
1092
- ] : _param_margin, _param_type = param.type, type = _param_type === void 0 ? ButtonType.latch : _param_type, size = param.size;
1093
- var _React_useState = _sliced_to_array$g(React__default.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
1094
- var buttonState = Juce.getToggleState(id);
1095
- var isLocalhost = window.location.hostname === 'localhost';
1096
- var setModSlotRowTargetAsPreview = useGlobalContext().setModSlotRowTargetAsPreview;
1097
- // Update the local state when the ID changes
1098
- useEffect(function() {
1099
- setIsSelected(buttonState === null || buttonState === void 0 ? void 0 : buttonState.value);
1100
- }, [
1101
- id
1102
- ]);
1103
- // Sets up listeners to handle changes on the backend
1104
- useEffect(function() {
1105
- if (!isLocalhost && !onClick) {
1106
- var valueListenerId = buttonState === null || buttonState === void 0 ? void 0 : buttonState.valueChangedEvent.addListener(function() {
1107
- setIsSelected(buttonState === null || buttonState === void 0 ? void 0 : buttonState.value);
1108
- });
1109
- return function cleanup() {
1110
- buttonState === null || buttonState === void 0 ? void 0 : buttonState.valueChangedEvent.removeListener(valueListenerId);
1111
- };
1112
- } else {
1113
- return;
1114
- }
1115
- });
1116
- var handleMouseDown = function(e) {
1117
- // TODO: handle this in a callback?
1118
- setModSlotRowTargetAsPreview({
1119
- paramId: id
1120
- });
1121
- if (!onClick) {
1122
- e.preventDefault();
1123
- if (type === ButtonType.momentary) {
1124
- setIsSelected(true);
1125
- buttonState.setValue(true);
1126
- } else {
1127
- setIsSelected(!isSelected);
1128
- buttonState.setValue(!isSelected);
1129
- }
1130
- }
1131
- };
1132
- var handleMouseUp = function() {
1133
- if (!onClick) {
1134
- setIsSelected(false);
1135
- buttonState.setValue(false);
1136
- }
1137
- };
1138
- React__default.useEffect(function() {
1139
- if (type === ButtonType.momentary && !onClick) {
1140
- window.addEventListener('mouseup', handleMouseUp);
1141
- return function() {
1142
- window.removeEventListener('mouseup', handleMouseUp);
1143
- };
1144
- }
1145
- return;
1146
- }, [
1147
- isSelected
1148
- ]);
1149
- var _padding_, _padding_1, _padding_2, _ref, _margin_, _margin_1, _margin_2, _ref1;
1150
- return /*#__PURE__*/ React__default.createElement("button", {
1151
- id: id,
1152
- onMouseDown: handleMouseDown,
1153
- disabled: disabled,
1154
- onClick: onClick && onClick,
1155
- style: _object_spread$m({
1156
- paddingTop: "var(--p-".concat(padding[0], ")"),
1157
- paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
1158
- paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
1159
- paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
1160
- marginTop: "var(--p-".concat(margin[0], ")"),
1161
- marginRight: "var(--p-".concat((_margin_ = margin[1]) !== null && _margin_ !== void 0 ? _margin_ : margin[0], ")"),
1162
- marginBottom: "var(--p-".concat((_margin_1 = margin[2]) !== null && _margin_1 !== void 0 ? _margin_1 : margin[0], ")"),
1163
- marginLeft: "var(--p-".concat((_ref1 = (_margin_2 = margin[3]) !== null && _margin_2 !== void 0 ? _margin_2 : margin[1]) !== null && _ref1 !== void 0 ? _ref1 : margin[0], ")")
1164
- }, style),
1165
- className: classnames('Button', isSelected && 'selected', "".concat(size), className)
1166
- }, size !== ButtonSize.xSmall && (text ? text : children));
1167
- }
1168
- Button.padding = Spacing;
1169
- Button.margin = Spacing;
1170
- Button.type = ButtonType;
1171
- Button.size = ButtonSize;
1172
-
1173
- var css_248z$d = ".IconButton {\n cursor: pointer;\n}\n.IconButton:hover:not(:disabled) {\n filter: brightness(80%);\n}\n";
1174
- styleInject(css_248z$d);
1175
-
1176
- var JustifyContent = /*#__PURE__*/ function(JustifyContent) {
1177
- JustifyContent["flexStart"] = "flex-start";
1178
- JustifyContent["flexEnd"] = "flex-end";
1179
- JustifyContent["center"] = "center";
1180
- JustifyContent["spaceBetween"] = "space-between";
1181
- JustifyContent["spaceAround"] = "space-around";
1182
- JustifyContent["spaceEvenly"] = "space-evenly";
1183
- return JustifyContent;
1184
- }({});
1185
- var AlignItems = /*#__PURE__*/ function(AlignItems) {
1186
- AlignItems["flexStart"] = "flex-start";
1187
- AlignItems["flexEnd"] = "flex-end";
1188
- AlignItems["center"] = "center";
1189
- AlignItems["stretch"] = "stretch";
1190
- AlignItems["baseline"] = "baseline";
1191
- return AlignItems;
1192
- }({});
1193
- var LayoutTags = /*#__PURE__*/ function(LayoutTags) {
1194
- LayoutTags["header"] = "header";
1195
- LayoutTags["main"] = "main";
1196
- LayoutTags["section"] = "section";
1197
- LayoutTags["div"] = "div";
1198
- LayoutTags["footer"] = "footer";
1199
- LayoutTags["ul"] = "ul";
1200
- LayoutTags["li"] = "li";
1201
- return LayoutTags;
1202
- }({});
1203
-
1204
- function _define_property$m(obj, key, value) {
1205
- if (key in obj) {
1206
- Object.defineProperty(obj, key, {
1207
- value: value,
1208
- enumerable: true,
1209
- configurable: true,
1210
- writable: true
1211
- });
1212
- } else {
1213
- obj[key] = value;
1214
- }
1215
- return obj;
1216
- }
1217
- function _object_spread$l(target) {
1218
- for(var i = 1; i < arguments.length; i++){
1219
- var source = arguments[i] != null ? arguments[i] : {};
1220
- var ownKeys = Object.keys(source);
1221
- if (typeof Object.getOwnPropertySymbols === "function") {
1222
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1223
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1224
- }));
1225
- }
1226
- ownKeys.forEach(function(key) {
1227
- _define_property$m(target, key, source[key]);
1228
- });
1229
- }
1230
- return target;
1231
- }
1232
- function ownKeys$3(object, enumerableOnly) {
1233
- var keys = Object.keys(object);
1234
- if (Object.getOwnPropertySymbols) {
1235
- var symbols = Object.getOwnPropertySymbols(object);
1236
- keys.push.apply(keys, symbols);
1237
- }
1238
- return keys;
1239
- }
1240
- function _object_spread_props$3(target, source) {
1241
- source = source != null ? source : {};
1242
- if (Object.getOwnPropertyDescriptors) {
1243
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1244
- } else {
1245
- ownKeys$3(Object(source)).forEach(function(key) {
1246
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1247
- });
1248
- }
1249
- return target;
1250
- }
1251
- function _object_without_properties(source, excluded) {
1252
- if (source == null) return {};
1253
- var target = _object_without_properties_loose(source, excluded);
1254
- var key, i;
1255
- if (Object.getOwnPropertySymbols) {
1256
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
1257
- for(i = 0; i < sourceSymbolKeys.length; i++){
1258
- key = sourceSymbolKeys[i];
1259
- if (excluded.indexOf(key) >= 0) continue;
1260
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
1261
- target[key] = source[key];
1262
- }
1263
- }
1264
- return target;
1265
- }
1266
- function _object_without_properties_loose(source, excluded) {
1267
- if (source == null) return {};
1268
- var target = {};
1269
- var sourceKeys = Object.keys(source);
1270
- var key, i;
1271
- for(i = 0; i < sourceKeys.length; i++){
1272
- key = sourceKeys[i];
1273
- if (excluded.indexOf(key) >= 0) continue;
1274
- target[key] = source[key];
1275
- }
1276
- return target;
1277
- }
1278
- var BoxDisplay = /*#__PURE__*/ function(BoxDisplay) {
1279
- BoxDisplay["flex"] = "flex";
1280
- BoxDisplay["block"] = "block";
1281
- return BoxDisplay;
1282
- }(BoxDisplay || {});
1283
- function Box(_param) {
1284
- var className = _param.className, style = _param.style, children = _param.children, flex = _param.flex, key = _param.key, onClick = _param.onClick, _param_alignItems = _param.alignItems, alignItems = _param_alignItems === void 0 ? AlignItems.center : _param_alignItems, _param_justifyContent = _param.justifyContent, justifyContent = _param_justifyContent === void 0 ? JustifyContent.center : _param_justifyContent, _param_display = _param.display, display = _param_display === void 0 ? "flex" : _param_display, _param_width = _param.width, width = _param_width === void 0 ? Width.full : _param_width, _param_flexWrap = _param.flexWrap, flexWrap = _param_flexWrap === void 0 ? FlexWrap.noWrap : _param_flexWrap, height = _param.height, _param_borderWidth = _param.borderWidth, borderWidth = _param_borderWidth === void 0 ? [
1285
- '0px',
1286
- '0px',
1287
- '0px',
1288
- '0px'
1289
- ] : _param_borderWidth, _param_borderStyle = _param.borderStyle, borderStyle = _param_borderStyle === void 0 ? BorderStyles.solid : _param_borderStyle, _param_borderColor = _param.borderColor, borderColor = _param_borderColor === void 0 ? 'var(--bg-lv8)' : _param_borderColor, _param_flexDirection = _param.flexDirection, flexDirection = _param_flexDirection === void 0 ? FlexDirection.row : _param_flexDirection, _param_fullHeight = _param.fullHeight, fullHeight = _param_fullHeight === void 0 ? false : _param_fullHeight, _param_padding = _param.padding, padding = _param_padding === void 0 ? [
1290
- Spacing.none,
1291
- Spacing.none,
1292
- Spacing.none,
1293
- Spacing.none
1294
- ] : _param_padding, _param_gap = _param.gap, gap = _param_gap === void 0 ? Spacing.xSmall : _param_gap, _param_tag = _param.tag, tag = _param_tag === void 0 ? LayoutTags.div : _param_tag, rest = _object_without_properties(_param, [
1295
- "className",
1296
- "style",
1297
- "children",
1298
- "flex",
1299
- "key",
1300
- "onClick",
1301
- "alignItems",
1302
- "justifyContent",
1303
- "display",
1304
- "width",
1305
- "flexWrap",
1306
- "height",
1307
- "borderWidth",
1308
- "borderStyle",
1309
- "borderColor",
1310
- "flexDirection",
1311
- "fullHeight",
1312
- "padding",
1313
- "gap",
1314
- "tag"
1315
- ]);
1316
- var Tag = tag;
1317
- var _padding_, _padding_1, _padding_2, _ref;
1318
- return /*#__PURE__*/ React__default.createElement(Tag, _object_spread_props$3(_object_spread$l({
1319
- // id="globalValues"
1320
- key: key,
1321
- className: className,
1322
- onClick: onClick
1323
- }, rest), {
1324
- style: _object_spread$l({
1325
- flexWrap: flexWrap,
1326
- display: display,
1327
- width: width,
1328
- gap: "var(--gap-".concat(gap, ")"),
1329
- paddingTop: "var(--p-".concat(padding[0], ")"),
1330
- paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
1331
- paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
1332
- paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
1333
- borderTop: borderWidth[0],
1334
- borderRight: borderWidth[1] !== null ? borderWidth[1] : borderWidth[0],
1335
- borderBottom: borderWidth[2] !== null ? borderWidth[2] : borderWidth[0],
1336
- borderLeft: borderWidth[3] !== null ? borderWidth[3] : borderWidth[1] !== null ? borderWidth[1] : borderWidth[0],
1337
- borderColor: borderColor,
1338
- borderStyle: borderStyle,
1339
- maxWidth: width,
1340
- height: fullHeight ? '100%' : height,
1341
- flexDirection: flexDirection === FlexDirection.row ? FlexDirection.row : FlexDirection.column,
1342
- justifyContent: "".concat(justifyContent),
1343
- alignItems: "".concat(alignItems),
1344
- flex: flex ? flex : ''
1345
- }, style)
1346
- }), children);
1347
- }
1348
- // Object.assign(Layout, width, height, ALIGN, JUSTIFY, DIRECTION, SPACING);
1349
- Box.display = BoxDisplay;
1350
- Box.alignItems = AlignItems;
1351
- Box.justifyContent = JustifyContent;
1352
- Box.gap = Spacing;
1353
- Box.flexDirection = FlexDirection;
1354
- Box.width = Width;
1355
- Box.height = Height;
1356
- Box.padding = Spacing;
1357
- Box.flexWrap = FlexWrap;
1358
- Box.tag = LayoutTags;
1359
-
1360
- var css_248z$c = ".Icon svg {\n width: 100%;\n}\n";
1361
- styleInject(css_248z$c);
1362
-
1363
- function _define_property$l(obj, key, value) {
1364
- if (key in obj) {
1365
- Object.defineProperty(obj, key, {
1366
- value: value,
1367
- enumerable: true,
1368
- configurable: true,
1369
- writable: true
1370
- });
1371
- } else {
1372
- obj[key] = value;
1373
- }
1374
- return obj;
1375
- }
1376
- function _object_spread$k(target) {
1377
- for(var i = 1; i < arguments.length; i++){
1378
- var source = arguments[i] != null ? arguments[i] : {};
1379
- var ownKeys = Object.keys(source);
1380
- if (typeof Object.getOwnPropertySymbols === "function") {
1381
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1382
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1383
- }));
1384
- }
1385
- ownKeys.forEach(function(key) {
1386
- _define_property$l(target, key, source[key]);
1387
- });
1388
- }
1389
- return target;
1390
- }
1391
- var Icons = /*#__PURE__*/ function(Icons) {
1392
- Icons["undo"] = "Undo";
1393
- Icons["redo"] = "Redo";
1394
- Icons["random"] = "Random";
1395
- Icons["favorite"] = "Favorite";
1396
- Icons["up"] = "Up";
1397
- Icons["down"] = "Down";
1398
- Icons["save"] = "Save";
1399
- Icons["add"] = "Add";
1400
- Icons["delete"] = "Delete";
1401
- Icons["negativeSaw"] = "NegativeSaw";
1402
- Icons["positiveSaw"] = "PositiveSaw";
1403
- Icons["sine"] = "Sine";
1404
- Icons["square"] = "Square";
1405
- Icons["triangle"] = "Triangle";
1406
- return Icons;
1407
- }({});
1408
- var Undo = function(param) {
1409
- var color = param.color, width = param.width;
1410
- return /*#__PURE__*/ React__default.createElement("svg", {
1411
- viewBox: "0 0 25 25",
1412
- "stroke-width": "1.5",
1413
- fill: "none",
1414
- xmlns: "http://www.w3.org/2000/svg",
1415
- color: color,
1416
- height: width,
1417
- width: width
1418
- }, /*#__PURE__*/ React__default.createElement("path", {
1419
- d: "M4.5 8C8.5 8 11 8 15 8C15 8 15 8 15 8C15 8 20 8 20 12.7059C20 18 15 18 15 18C11.5714 18 9.71429 18 6.28571 18",
1420
- stroke: color,
1421
- "stroke-width": "1.5",
1422
- "stroke-linecap": "round",
1423
- "stroke-linejoin": "round"
1424
- }), /*#__PURE__*/ React__default.createElement("path", {
1425
- d: "M7.5 11.5C6.13317 10.1332 5.36683 9.36683 4 8C5.36683 6.63317 6.13317 5.86683 7.5 4.5",
1426
- stroke: color,
1427
- "stroke-width": "1.5",
1428
- "stroke-linecap": "round",
1429
- "stroke-linejoin": "round"
1430
- }));
536
+ var Icons = /*#__PURE__*/ function(Icons) {
537
+ Icons["undo"] = "Undo";
538
+ Icons["redo"] = "Redo";
539
+ Icons["random"] = "Random";
540
+ Icons["favorite"] = "Favorite";
541
+ Icons["up"] = "Up";
542
+ Icons["down"] = "Down";
543
+ Icons["save"] = "Save";
544
+ Icons["add"] = "Add";
545
+ Icons["delete"] = "Delete";
546
+ Icons["negativeSaw"] = "NegativeSaw";
547
+ Icons["positiveSaw"] = "PositiveSaw";
548
+ Icons["sine"] = "Sine";
549
+ Icons["square"] = "Square";
550
+ Icons["triangle"] = "Triangle";
551
+ return Icons;
552
+ }({});
553
+ var Undo = function(param) {
554
+ var color = param.color, width = param.width;
555
+ return /*#__PURE__*/ React__default.createElement("svg", {
556
+ viewBox: "0 0 25 25",
557
+ "stroke-width": "1.5",
558
+ fill: "none",
559
+ xmlns: "http://www.w3.org/2000/svg",
560
+ color: color,
561
+ height: width,
562
+ width: width
563
+ }, /*#__PURE__*/ React__default.createElement("path", {
564
+ d: "M4.5 8C8.5 8 11 8 15 8C15 8 15 8 15 8C15 8 20 8 20 12.7059C20 18 15 18 15 18C11.5714 18 9.71429 18 6.28571 18",
565
+ stroke: color,
566
+ "stroke-width": "1.5",
567
+ "stroke-linecap": "round",
568
+ "stroke-linejoin": "round"
569
+ }), /*#__PURE__*/ React__default.createElement("path", {
570
+ d: "M7.5 11.5C6.13317 10.1332 5.36683 9.36683 4 8C5.36683 6.63317 6.13317 5.86683 7.5 4.5",
571
+ stroke: color,
572
+ "stroke-width": "1.5",
573
+ "stroke-linecap": "round",
574
+ "stroke-linejoin": "round"
575
+ }));
1431
576
  };
1432
577
  var Redo = function(param) {
1433
578
  var color = param.color, width = param.width;
@@ -1616,136 +761,672 @@ var Delete = function(param) {
1616
761
  fill: "none",
1617
762
  xmlns: "http://www.w3.org/2000/svg",
1618
763
  color: color,
1619
- "stroke-width": "1.5",
1620
- height: width,
1621
- width: width
1622
- }, /*#__PURE__*/ React__default.createElement("path", {
1623
- "fill-rule": "evenodd",
1624
- "clip-rule": "evenodd",
1625
- d: "M12 1.25C6.06294 1.25 1.25 6.06294 1.25 12C1.25 17.9371 6.06294 22.75 12 22.75C17.9371 22.75 22.75 17.9371 22.75 12C22.75 6.06294 17.9371 1.25 12 1.25ZM9.70164 8.64124C9.40875 8.34835 8.93388 8.34835 8.64098 8.64124C8.34809 8.93414 8.34809 9.40901 8.64098 9.7019L10.9391 12L8.64098 14.2981C8.34809 14.591 8.34809 15.0659 8.64098 15.3588C8.93388 15.6517 9.40875 15.6517 9.70164 15.3588L11.9997 13.0607L14.2978 15.3588C14.5907 15.6517 15.0656 15.6517 15.3585 15.3588C15.6514 15.0659 15.6514 14.591 15.3585 14.2981L13.0604 12L15.3585 9.7019C15.6514 9.40901 15.6514 8.93414 15.3585 8.64124C15.0656 8.34835 14.5907 8.34835 14.2978 8.64124L11.9997 10.9393L9.70164 8.64124Z",
1626
- fill: color
1627
- }));
764
+ "stroke-width": "1.5",
765
+ height: width,
766
+ width: width
767
+ }, /*#__PURE__*/ React__default.createElement("path", {
768
+ "fill-rule": "evenodd",
769
+ "clip-rule": "evenodd",
770
+ d: "M12 1.25C6.06294 1.25 1.25 6.06294 1.25 12C1.25 17.9371 6.06294 22.75 12 22.75C17.9371 22.75 22.75 17.9371 22.75 12C22.75 6.06294 17.9371 1.25 12 1.25ZM9.70164 8.64124C9.40875 8.34835 8.93388 8.34835 8.64098 8.64124C8.34809 8.93414 8.34809 9.40901 8.64098 9.7019L10.9391 12L8.64098 14.2981C8.34809 14.591 8.34809 15.0659 8.64098 15.3588C8.93388 15.6517 9.40875 15.6517 9.70164 15.3588L11.9997 13.0607L14.2978 15.3588C14.5907 15.6517 15.0656 15.6517 15.3585 15.3588C15.6514 15.0659 15.6514 14.591 15.3585 14.2981L13.0604 12L15.3585 9.7019C15.6514 9.40901 15.6514 8.93414 15.3585 8.64124C15.0656 8.34835 14.5907 8.34835 14.2978 8.64124L11.9997 10.9393L9.70164 8.64124Z",
771
+ fill: color
772
+ }));
773
+ };
774
+ var NegativeSaw = function(param) {
775
+ var color = param.color, width = param.width;
776
+ return /*#__PURE__*/ React__default.createElement("svg", {
777
+ xmlns: "http://www.w3.org/2000/svg",
778
+ viewBox: "0 0 67.27 33.41",
779
+ width: width
780
+ }, /*#__PURE__*/ React__default.createElement("polyline", {
781
+ points: "2.5 2.5 2.5 30.91 64.77 2.5 64.77 30.91",
782
+ fill: "none",
783
+ stroke: color,
784
+ "stroke-linecap": "round",
785
+ "stroke-linejoin": "round",
786
+ "stroke-width": "4"
787
+ }));
788
+ };
789
+ var PositiveSaw = function(param) {
790
+ var color = param.color, width = param.width;
791
+ return /*#__PURE__*/ React__default.createElement("svg", {
792
+ xmlns: "http://www.w3.org/2000/svg",
793
+ viewBox: "0 0 67.27 33.41",
794
+ width: width
795
+ }, /*#__PURE__*/ React__default.createElement("polyline", {
796
+ points: "64.77 2.5 64.77 30.91 2.5 2.5 2.5 30.91",
797
+ fill: "none",
798
+ stroke: color,
799
+ "stroke-linecap": "round",
800
+ "stroke-linejoin": "round",
801
+ "stroke-width": "4"
802
+ }));
803
+ };
804
+ var Sine = function(param) {
805
+ var color = param.color, width = param.width;
806
+ return /*#__PURE__*/ React__default.createElement("svg", {
807
+ width: width,
808
+ xmlns: "http://www.w3.org/2000/svg",
809
+ viewBox: "0 0 65.2 33.19"
810
+ }, /*#__PURE__*/ React__default.createElement("path", {
811
+ d: "M4,17.08c3.67-6.45,7.25-13.08,14.58-13.08,14.31,0,14.31,25.19,28.62,25.19,6.94,0,10.52-5.93,13.99-12.03",
812
+ fill: "none",
813
+ stroke: color,
814
+ "stroke-linecap": "round",
815
+ "stroke-miterlimit": "10",
816
+ "stroke-width": "4"
817
+ }));
818
+ };
819
+ var Square = function(param) {
820
+ var color = param.color, width = param.width;
821
+ return /*#__PURE__*/ React__default.createElement("svg", {
822
+ width: width,
823
+ xmlns: "http://www.w3.org/2000/svg",
824
+ viewBox: "0 0 68.77 33.8"
825
+ }, /*#__PURE__*/ React__default.createElement("polyline", {
826
+ points: "2.5 31.3 2.5 2.5 34.38 2.5 34.38 31.3 66.27 31.3 66.27 2.5",
827
+ fill: "none",
828
+ stroke: color,
829
+ "stroke-linecap": "round",
830
+ "stroke-linejoin": "round",
831
+ "stroke-width": "4"
832
+ }));
833
+ };
834
+ var Triangle = function(param) {
835
+ var color = param.color, width = param.width;
836
+ return /*#__PURE__*/ React__default.createElement("svg", {
837
+ xmlns: "http://www.w3.org/2000/svg",
838
+ width: width,
839
+ viewBox: "0 0 72.68 35.16"
840
+ }, /*#__PURE__*/ React__default.createElement("polyline", {
841
+ points: "3 32.16 25.59 3 47.69 31.54 69.68 3.15",
842
+ fill: "none",
843
+ stroke: color,
844
+ "stroke-linecap": "round",
845
+ "stroke-linejoin": "round",
846
+ "stroke-width": "4"
847
+ }));
848
+ };
849
+ var iconList = {
850
+ Undo: Undo,
851
+ Redo: Redo,
852
+ Random: Random,
853
+ Favorite: Favorite,
854
+ Up: Up,
855
+ Down: Down,
856
+ Save: Save,
857
+ Add: Add,
858
+ Delete: Delete,
859
+ NegativeSaw: NegativeSaw,
860
+ PositiveSaw: PositiveSaw,
861
+ Sine: Sine,
862
+ Square: Square,
863
+ Triangle: Triangle
864
+ };
865
+ // const getViewBoxWidth = (width: string) => {
866
+ // const numericWidth = width.match(/\d+/)?.[0];
867
+ // return numericWidth !== undefined ? parseInt(numericWidth) : 24;
868
+ // };
869
+ function Icon(param) {
870
+ var icon = param.icon, onClick = param.onClick, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_color = param.color, color = _param_color === void 0 ? 'var(--color-text)' : _param_color, _param_padding = param.padding, padding = _param_padding === void 0 ? [
871
+ Spacing.none
872
+ ] : _param_padding, _param_width = param.width, width = _param_width === void 0 ? '24px' : _param_width, height = param.height, className = param.className, style = param.style;
873
+ var _$Icon = iconList[icon];
874
+ var _width_match;
875
+ var numberWidth = parseInt(((_width_match = width.match(/\d/g)) !== null && _width_match !== void 0 ? _width_match : []).join(''), 10);
876
+ return /*#__PURE__*/ React__default.createElement(Box, {
877
+ className: "Icon ".concat(className ? className : ''),
878
+ onClick: onClick,
879
+ padding: padding,
880
+ style: _object_spread$l({
881
+ width: width,
882
+ height: height !== null && height !== void 0 ? height : width
883
+ }, style)
884
+ }, /*#__PURE__*/ React__default.createElement(_$Icon, {
885
+ width: numberWidth,
886
+ color: disabled ? 'var(--color-gray-400)' : color
887
+ }));
888
+ }
889
+ Icon.icon = Icons;
890
+ Icon.padding = Spacing;
891
+ Icon.margin = Spacing;
892
+
893
+ function _define_property$l(obj, key, value) {
894
+ if (key in obj) {
895
+ Object.defineProperty(obj, key, {
896
+ value: value,
897
+ enumerable: true,
898
+ configurable: true,
899
+ writable: true
900
+ });
901
+ } else {
902
+ obj[key] = value;
903
+ }
904
+ return obj;
905
+ }
906
+ function _object_spread$k(target) {
907
+ for(var i = 1; i < arguments.length; i++){
908
+ var source = arguments[i] != null ? arguments[i] : {};
909
+ var ownKeys = Object.keys(source);
910
+ if (typeof Object.getOwnPropertySymbols === "function") {
911
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
912
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
913
+ }));
914
+ }
915
+ ownKeys.forEach(function(key) {
916
+ _define_property$l(target, key, source[key]);
917
+ });
918
+ }
919
+ return target;
920
+ }
921
+ function Label(param) {
922
+ var value = param.value, id = param.id, className = param.className, style = param.style, _param_color = param.color, color = _param_color === void 0 ? 'var(--color-text)' : _param_color, _param_padding = param.padding, padding = _param_padding === void 0 ? [
923
+ Spacing.none
924
+ ] : _param_padding, uppercase = param.uppercase, children = param.children, htmlFor = param.htmlFor, _param_fontSize = param.fontSize, fontSize = _param_fontSize === void 0 ? FontSizes.medium : _param_fontSize;
925
+ var _padding_, _padding_1, _padding_2, _ref;
926
+ return /*#__PURE__*/ React.createElement("label", {
927
+ id: id,
928
+ htmlFor: htmlFor,
929
+ style: _object_spread$k({
930
+ fontSize: "var(--text-".concat(fontSize, ")"),
931
+ paddingTop: "var(--p-".concat(padding[0], ")"),
932
+ paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
933
+ paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
934
+ paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
935
+ WebkitUserSelect: 'none',
936
+ userSelect: 'none',
937
+ textTransform: uppercase ? 'uppercase' : 'none',
938
+ cursor: 'inherit',
939
+ color: color
940
+ }, style),
941
+ className: classnames('Label', 'select-none', className)
942
+ }, value ? value : children);
943
+ }
944
+ Label.padding = Spacing;
945
+ Label.fontSize = FontSizes;
946
+
947
+ function _define_property$k(obj, key, value) {
948
+ if (key in obj) {
949
+ Object.defineProperty(obj, key, {
950
+ value: value,
951
+ enumerable: true,
952
+ configurable: true,
953
+ writable: true
954
+ });
955
+ } else {
956
+ obj[key] = value;
957
+ }
958
+ return obj;
959
+ }
960
+ function _object_spread$j(target) {
961
+ for(var i = 1; i < arguments.length; i++){
962
+ var source = arguments[i] != null ? arguments[i] : {};
963
+ var ownKeys = Object.keys(source);
964
+ if (typeof Object.getOwnPropertySymbols === "function") {
965
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
966
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
967
+ }));
968
+ }
969
+ ownKeys.forEach(function(key) {
970
+ _define_property$k(target, key, source[key]);
971
+ });
972
+ }
973
+ return target;
974
+ }
975
+ function IconButton(param) {
976
+ var id = param.id, icon = param.icon, onClick = param.onClick, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_color = param.color, color = _param_color === void 0 ? 'var(--color-text)' : _param_color, // backgroundColor = 'var(--bg-lv1)',
977
+ backgroundColor = param.backgroundColor, _param_padding = param.padding, padding = _param_padding === void 0 ? [
978
+ Button.padding.none
979
+ ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
980
+ Button.margin.none
981
+ ] : _param_margin, _param_width = param.width, width = _param_width === void 0 ? '24px' : _param_width, iconWidth = param.iconWidth, label = param.label, height = param.height, className = param.className, style = param.style;
982
+ var Icon = iconList[icon];
983
+ var _width_match;
984
+ var numberWidth = parseInt(((_width_match = width.match(/\d/g)) !== null && _width_match !== void 0 ? _width_match : []).join(''), 10);
985
+ var _iconWidth_match;
986
+ var iconNumberWidth = typeof iconWidth === 'string' && parseInt(((_iconWidth_match = iconWidth === null || iconWidth === void 0 ? void 0 : iconWidth.match(/\d/g)) !== null && _iconWidth_match !== void 0 ? _iconWidth_match : []).join(''), 10);
987
+ return /*#__PURE__*/ React__default.createElement(Button, {
988
+ id: id,
989
+ className: "IconButton ".concat(className ? className : ''),
990
+ onClick: onClick,
991
+ padding: padding,
992
+ margin: margin,
993
+ disabled: disabled,
994
+ style: _object_spread$j({
995
+ backgroundColor: backgroundColor,
996
+ width: width,
997
+ height: height !== null && height !== void 0 ? height : 'auto'
998
+ }, style)
999
+ }, /*#__PURE__*/ React__default.createElement(Box, {
1000
+ flexDirection: Box.flexDirection.column,
1001
+ gap: Box.gap.mediumSmall
1002
+ }, /*#__PURE__*/ React__default.createElement(Icon, {
1003
+ width: iconNumberWidth || numberWidth,
1004
+ color: disabled ? 'var(--color-gray-400)' : color
1005
+ }), label ? /*#__PURE__*/ React__default.createElement(Label, {
1006
+ color: color,
1007
+ fontSize: Label.fontSize.xSmall,
1008
+ value: label
1009
+ }) : null));
1010
+ }
1011
+ IconButton.icon = Icons;
1012
+ IconButton.padding = Spacing;
1013
+ IconButton.margin = Spacing;
1014
+
1015
+ function _array_like_to_array$h(arr, len) {
1016
+ if (len == null || len > arr.length) len = arr.length;
1017
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1018
+ return arr2;
1019
+ }
1020
+ function _array_with_holes$g(arr) {
1021
+ if (Array.isArray(arr)) return arr;
1022
+ }
1023
+ function _iterable_to_array_limit$g(arr, i) {
1024
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1025
+ if (_i == null) return;
1026
+ var _arr = [];
1027
+ var _n = true;
1028
+ var _d = false;
1029
+ var _s, _e;
1030
+ try {
1031
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1032
+ _arr.push(_s.value);
1033
+ if (i && _arr.length === i) break;
1034
+ }
1035
+ } catch (err) {
1036
+ _d = true;
1037
+ _e = err;
1038
+ } finally{
1039
+ try {
1040
+ if (!_n && _i["return"] != null) _i["return"]();
1041
+ } finally{
1042
+ if (_d) throw _e;
1043
+ }
1044
+ }
1045
+ return _arr;
1046
+ }
1047
+ function _non_iterable_rest$g() {
1048
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1049
+ }
1050
+ function _sliced_to_array$g(arr, i) {
1051
+ return _array_with_holes$g(arr) || _iterable_to_array_limit$g(arr, i) || _unsupported_iterable_to_array$h(arr, i) || _non_iterable_rest$g();
1052
+ }
1053
+ function _unsupported_iterable_to_array$h(o, minLen) {
1054
+ if (!o) return;
1055
+ if (typeof o === "string") return _array_like_to_array$h(o, minLen);
1056
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1057
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1058
+ if (n === "Map" || n === "Set") return Array.from(n);
1059
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
1060
+ }
1061
+ function Tabs(param) {
1062
+ var items = param.items, _param_initialSelectedIndex = param.initialSelectedIndex, initialSelectedIndex = _param_initialSelectedIndex === void 0 ? undefined : _param_initialSelectedIndex, _param_id = param.id, id = _param_id === void 0 ? '' : _param_id, className = param.className, _param_padding = param.padding, padding = _param_padding === void 0 ? [
1063
+ Spacing.none
1064
+ ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
1065
+ Spacing.none
1066
+ ] : _param_margin, _param_gap = param.gap, gap = _param_gap === void 0 ? Spacing.small : _param_gap, width = param.width, height = param.height, tabWidth = param.tabWidth, tabHeight = param.tabHeight, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.horizontal : _param_orientation, _param_justifyContent = param.justifyContent, justifyContent = _param_justifyContent === void 0 ? JustifyContent$1.stretch : _param_justifyContent, _param_alignItems = param.alignItems, alignItems = _param_alignItems === void 0 ? AlignItems$1.stretch : _param_alignItems, _param_color = param.color, color = _param_color === void 0 ? 'var(--bg-lv11)' : _param_color, _param_selectedColor = param.selectedColor, selectedColor = _param_selectedColor === void 0 ? 'var(--color-brand)' : _param_selectedColor, _param_backgroundColor = param.backgroundColor, backgroundColor = _param_backgroundColor === void 0 ? 'transparent' : _param_backgroundColor, _param_fontSize = param.fontSize, fontSize = _param_fontSize === void 0 ? FontSizes.small : _param_fontSize, selectedBackgroundColor = param.selectedBackgroundColor, icons = param.icons, onChange = param.onChange, isDisabled = param.isDisabled;
1067
+ var _useState = _sliced_to_array$g(useState(null), 2), selectedIndex = _useState[0], setSelectedIndex = _useState[1];
1068
+ var _useState1 = _sliced_to_array$g(useState([]), 2), choices = _useState1[0], setChoices = _useState1[1];
1069
+ var dataSource = id ? "JuceCombobox" : "JuceAction";
1070
+ var comboBoxState = dataSource === "JuceCombobox" ? Juce.getComboBoxState(id) : null;
1071
+ useEffect(function() {
1072
+ if (dataSource === "JuceCombobox") {
1073
+ var _comboBoxState_properties;
1074
+ setChoices(comboBoxState === null || comboBoxState === void 0 ? void 0 : (_comboBoxState_properties = comboBoxState.properties) === null || _comboBoxState_properties === void 0 ? void 0 : _comboBoxState_properties.choices);
1075
+ setSelectedIndex(comboBoxState.getChoiceIndex());
1076
+ } else {
1077
+ setChoices((items === null || items === void 0 ? void 0 : items.length) ? items : []);
1078
+ }
1079
+ }, [
1080
+ window
1081
+ ]);
1082
+ useEffect(function() {
1083
+ if (initialSelectedIndex !== null && initialSelectedIndex !== undefined && selectedIndex === null) {
1084
+ setSelectedIndex(initialSelectedIndex);
1085
+ }
1086
+ }, [
1087
+ initialSelectedIndex
1088
+ ]);
1089
+ var handleChange = function(choiceIndex) {
1090
+ if (!isDisabled && choiceIndex !== selectedIndex) {
1091
+ if (dataSource === "JuceCombobox") {
1092
+ comboBoxState.setChoiceIndex(choiceIndex);
1093
+ }
1094
+ onChange && onChange(choiceIndex);
1095
+ setSelectedIndex(choiceIndex);
1096
+ return choices[choiceIndex];
1097
+ }
1098
+ return;
1099
+ };
1100
+ var _margin_, _margin_1, _margin_2, _ref;
1101
+ // console.log(choices, 'CHOICES');
1102
+ //around
1103
+ //vertical, horizontal
1104
+ // top, right, bottom, left
1105
+ return /*#__PURE__*/ React__default.createElement(TabGroup, {
1106
+ style: {
1107
+ marginTop: "var(--mt-".concat(margin[0], ")"),
1108
+ marginRight: "var(--mr-".concat((_margin_ = margin[1]) !== null && _margin_ !== void 0 ? _margin_ : margin[0], ")"),
1109
+ marginBottom: "var(--mb-".concat((_margin_1 = margin[2]) !== null && _margin_1 !== void 0 ? _margin_1 : margin[0], ")"),
1110
+ marginLeft: "var(--ml-".concat((_ref = (_margin_2 = margin[3]) !== null && _margin_2 !== void 0 ? _margin_2 : margin[1]) !== null && _ref !== void 0 ? _ref : margin[0], ")"),
1111
+ width: width,
1112
+ height: height
1113
+ },
1114
+ manual: true,
1115
+ selectedIndex: selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : 0,
1116
+ onChange: function(index) {
1117
+ return handleChange(index);
1118
+ }
1119
+ }, /*#__PURE__*/ React__default.createElement(TabList, {
1120
+ className: classnames('Tabs', className),
1121
+ style: {
1122
+ gap: "var(--gap-".concat(gap, ")"),
1123
+ height: height ? height : 'auto',
1124
+ justifyContent: justifyContent,
1125
+ alignItems: alignItems,
1126
+ flexDirection: orientation === Orientation.horizontal ? 'row' : 'column'
1127
+ }
1128
+ }, choices && choices.map(function(item, i) {
1129
+ var _padding_, _padding_1, _padding_2, _ref;
1130
+ return /*#__PURE__*/ React__default.createElement(Tab, {
1131
+ key: item,
1132
+ id: item,
1133
+ style: {
1134
+ cursor: 'pointer',
1135
+ width: tabWidth,
1136
+ height: tabHeight,
1137
+ fontSize: 'var(--text-md)',
1138
+ lineHeight: '1.25rem',
1139
+ backgroundColor: i === selectedIndex ? selectedBackgroundColor !== null && selectedBackgroundColor !== void 0 ? selectedBackgroundColor : backgroundColor : backgroundColor,
1140
+ paddingTop: "var(--p-".concat(padding[0], ")"),
1141
+ paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
1142
+ paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
1143
+ paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
1144
+ display: 'flex',
1145
+ flex: 1,
1146
+ justifyContent: 'center',
1147
+ alignItems: 'center'
1148
+ },
1149
+ className: classnames('Tabs-item', 'bg-body', 'color-input-text')
1150
+ }, icons && icons[i] ? /*#__PURE__*/ React__default.createElement(IconButton, {
1151
+ icon: icons[i],
1152
+ id: item,
1153
+ iconWidth: "20px",
1154
+ // width={tabWidth}
1155
+ // height={tabHeight}
1156
+ color: i === selectedIndex ? selectedColor : color
1157
+ }) : /*#__PURE__*/ React__default.createElement(Label, {
1158
+ value: item,
1159
+ fontSize: fontSize,
1160
+ color: color
1161
+ }));
1162
+ })));
1163
+ }
1164
+ Tabs.padding = Spacing;
1165
+ Tabs.gap = Spacing;
1166
+ Tabs.margin = Spacing;
1167
+ Tabs.orientation = Orientation;
1168
+ Tabs.justifyContent = JustifyContent$1;
1169
+ Tabs.alignItems = AlignItems$1;
1170
+ Tabs.fontSize = FontSizes;
1171
+
1172
+ var css_248z$b = ".Dropdown-button {\n font-size: var(--text-sm);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--spacing-ml);\n cursor: pointer;\n vertical-align: middle;\n white-space: nowrap;\n text-decoration: none;\n text-align: center;\n border-radius: 4px;\n appearance: none;\n user-select: none;\n -webkit-user-select: none;\n height: 26px;\n border: 1px solid var(--bg-lv9);\n /* background: var(--color-gray-800); */\n /* color: var(--color-text); */\n}\n\n.Dropdown-button:hover,\n.Dropdown-button[data-open] {\n outline: none;\n cursor: pointer;\n border: 1px solid var(--color-brand-secondary);\n}\n\n.Dropdown-button:hover .Label {\n cursor: pointer;\n}\n\n.Dropdown-button:disabled {\n cursor: default;\n}\n\n.Dropdown-items {\n border: 1px solid var(--bg-lv9);\n background: var(--bg-lv4);\n box-shadow: rgba(0, 0, 0, 0.25) 0px 0px 5px 3px;\n border-radius: 4px;\n width: 150px;\n z-index: 50;\n -ms-overflow-style: none;\n scrollbar-width: none;\n overflow-y: scroll;\n}\n.Dropdown-items::-webkit-scrollbar {\n display: none;\n}\n\n.Dropdown-item {\n font-size: var(--text-sm);\n padding: var(--spacing-md) var(--spacing-xl);\n min-width: 100px;\n color: var(--color-text);\n cursor: pointer;\n /* text-align: center; */\n}\n\n.Dropdown-item[data-selected] {\n color: var(--color-brand-secondary);\n}\n\n.Dropdown-item:hover {\n background-color: var(--bg-lv7);\n}\n\n.Dropdown-item:hover:not([data-selected]) {\n color: var(--color-text);\n}\n";
1173
+ styleInject(css_248z$b);
1174
+
1175
+ function useObservable(param) {
1176
+ var onFire = param.onFire;
1177
+ var observers = useRef([]);
1178
+ var subscribe = function(observer, id) {
1179
+ var _observers_current;
1180
+ if (((_observers_current = observers.current) === null || _observers_current === void 0 ? void 0 : _observers_current.find(function(item) {
1181
+ return item[1] === id;
1182
+ })) === undefined) {
1183
+ observers.current.push([
1184
+ observer,
1185
+ id
1186
+ ]);
1187
+ }
1188
+ };
1189
+ var unsubscribe = function(observer, id) {
1190
+ var _observers_current;
1191
+ if (((_observers_current = observers.current) === null || _observers_current === void 0 ? void 0 : _observers_current.find(function(item) {
1192
+ return item[1] === id;
1193
+ })) !== undefined) {
1194
+ var _observers_current1;
1195
+ var index = (_observers_current1 = observers.current) === null || _observers_current1 === void 0 ? void 0 : _observers_current1.findIndex(function(item) {
1196
+ return item[1] === id;
1197
+ });
1198
+ observers.current.splice(index, 1);
1199
+ }
1200
+ };
1201
+ var fire = function() {
1202
+ var _observers_current;
1203
+ onFire();
1204
+ (_observers_current = observers.current) === null || _observers_current === void 0 ? void 0 : _observers_current.forEach(function(observer) {
1205
+ return observer[0]();
1206
+ });
1207
+ };
1208
+ return {
1209
+ subscribe: subscribe,
1210
+ unsubscribe: unsubscribe,
1211
+ fire: fire
1212
+ };
1213
+ }
1214
+
1215
+ function _array_like_to_array$g(arr, len) {
1216
+ if (len == null || len > arr.length) len = arr.length;
1217
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1218
+ return arr2;
1219
+ }
1220
+ function _array_without_holes$2(arr) {
1221
+ if (Array.isArray(arr)) return _array_like_to_array$g(arr);
1222
+ }
1223
+ function _iterable_to_array$2(iter) {
1224
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1225
+ }
1226
+ function _non_iterable_spread$2() {
1227
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1228
+ }
1229
+ function _to_consumable_array$2(arr) {
1230
+ return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$g(arr) || _non_iterable_spread$2();
1231
+ }
1232
+ function _unsupported_iterable_to_array$g(o, minLen) {
1233
+ if (!o) return;
1234
+ if (typeof o === "string") return _array_like_to_array$g(o, minLen);
1235
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1236
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1237
+ if (n === "Map" || n === "Set") return Array.from(n);
1238
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
1239
+ }
1240
+ // export const roundUpToTwoDecimals = (val: number) => Math.ceil(val * 100) / 100;
1241
+ // mocks the `normalisedToScaledValue` internal method from JUCE
1242
+ // This will allow us to test the JS UI without needing access to the JUCE backend
1243
+ // ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false)
1244
+ function normalisedToScaled(param) {
1245
+ var normalisedValue = param.normalisedValue, properties = param.properties;
1246
+ var skew = properties.skew, end = properties.end, start = properties.start;
1247
+ return Math.pow(normalisedValue, 1 / skew) * (end - start) + start;
1248
+ }
1249
+ // mocks the `getnormalisedValue` method from JUCE
1250
+ // This will allow us to test the JS UI without needing access to the JUCE backend
1251
+ function scaledToNormalised(param) {
1252
+ var scaledValue = param.scaledValue, start = param.start, end = param.end, skew = param.skew;
1253
+ return Math.pow((scaledValue - start) / (end - start), skew !== null && skew !== void 0 ? skew : 1);
1254
+ }
1255
+ var decimalToPercent = function(decimal) {
1256
+ return Math.round(100 * (typeof decimal === 'string' ? parseFloat(decimal) : decimal));
1628
1257
  };
1629
- var NegativeSaw = function(param) {
1630
- var color = param.color, width = param.width;
1631
- return /*#__PURE__*/ React__default.createElement("svg", {
1632
- xmlns: "http://www.w3.org/2000/svg",
1633
- viewBox: "0 0 67.27 33.41",
1634
- width: width
1635
- }, /*#__PURE__*/ React__default.createElement("polyline", {
1636
- points: "2.5 2.5 2.5 30.91 64.77 2.5 64.77 30.91",
1637
- fill: "none",
1638
- stroke: color,
1639
- "stroke-linecap": "round",
1640
- "stroke-linejoin": "round",
1641
- "stroke-width": "4"
1642
- }));
1258
+ var percentToDecimal = function(percent) {
1259
+ return Math.round(0.01 * (typeof percent === 'string' ? parseFloat(percent) : percent));
1643
1260
  };
1644
- var PositiveSaw = function(param) {
1645
- var color = param.color, width = param.width;
1646
- return /*#__PURE__*/ React__default.createElement("svg", {
1647
- xmlns: "http://www.w3.org/2000/svg",
1648
- viewBox: "0 0 67.27 33.41",
1649
- width: width
1650
- }, /*#__PURE__*/ React__default.createElement("polyline", {
1651
- points: "64.77 2.5 64.77 30.91 2.5 2.5 2.5 30.91",
1652
- fill: "none",
1653
- stroke: color,
1654
- "stroke-linecap": "round",
1655
- "stroke-linejoin": "round",
1656
- "stroke-width": "4"
1657
- }));
1261
+ var inputCharacterIsValid = function(char) {
1262
+ var validCharacter = /^[\d.-]$/;
1263
+ return validCharacter.test(char.toString());
1658
1264
  };
1659
- var Sine = function(param) {
1660
- var color = param.color, width = param.width;
1661
- return /*#__PURE__*/ React__default.createElement("svg", {
1662
- width: width,
1663
- xmlns: "http://www.w3.org/2000/svg",
1664
- viewBox: "0 0 65.2 33.19"
1665
- }, /*#__PURE__*/ React__default.createElement("path", {
1666
- d: "M4,17.08c3.67-6.45,7.25-13.08,14.58-13.08,14.31,0,14.31,25.19,28.62,25.19,6.94,0,10.52-5.93,13.99-12.03",
1667
- fill: "none",
1668
- stroke: color,
1669
- "stroke-linecap": "round",
1670
- "stroke-miterlimit": "10",
1671
- "stroke-width": "4"
1672
- }));
1265
+ var clamp = function(val) {
1266
+ var min = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, max = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
1267
+ return Math.max(min, Math.min(max, val));
1673
1268
  };
1674
- var Square = function(param) {
1675
- var color = param.color, width = param.width;
1676
- return /*#__PURE__*/ React__default.createElement("svg", {
1677
- width: width,
1678
- xmlns: "http://www.w3.org/2000/svg",
1679
- viewBox: "0 0 68.77 33.8"
1680
- }, /*#__PURE__*/ React__default.createElement("polyline", {
1681
- points: "2.5 31.3 2.5 2.5 34.38 2.5 34.38 31.3 66.27 31.3 66.27 2.5",
1682
- fill: "none",
1683
- stroke: color,
1684
- "stroke-linecap": "round",
1685
- "stroke-linejoin": "round",
1686
- "stroke-width": "4"
1687
- }));
1269
+ function snapToLegalValue(param) {
1270
+ var value = param.value, properties = param.properties;
1271
+ var interval = properties.interval, start = properties.start, end = properties.end;
1272
+ if (interval == 0) return value;
1273
+ var roundedInterval = parseFloat(interval === null || interval === void 0 ? void 0 : interval.toFixed(2));
1274
+ var formattedValue = start + roundedInterval * Math.floor((value - start) / roundedInterval + 0.5);
1275
+ return clamp(parseFloat(formattedValue.toFixed(2)), start, end);
1276
+ }
1277
+ // const validNumber = /^-?\.?\d+(\.\d)?$/;
1278
+ // const lastNumberIsDigit = /\d$/;
1279
+ var validateInputChange = function(e) {
1280
+ return e.nativeEvent.data === '' || e.nativeEvent.data === null || inputCharacterIsValid(e.nativeEvent.data);
1688
1281
  };
1689
- var Triangle = function(param) {
1690
- var color = param.color, width = param.width;
1691
- return /*#__PURE__*/ React__default.createElement("svg", {
1692
- xmlns: "http://www.w3.org/2000/svg",
1693
- width: width,
1694
- viewBox: "0 0 72.68 35.16"
1695
- }, /*#__PURE__*/ React__default.createElement("polyline", {
1696
- points: "3 32.16 25.59 3 47.69 31.54 69.68 3.15",
1697
- fill: "none",
1698
- stroke: color,
1699
- "stroke-linecap": "round",
1700
- "stroke-linejoin": "round",
1701
- "stroke-width": "4"
1702
- }));
1282
+ var getValidValueForInput = function(param) {
1283
+ var value = param.value, oldValue = param.oldValue, properties = param.properties;
1284
+ var _splitValueArray_;
1285
+ // TODO: Clean up
1286
+ var matchCriteria = /^-?(?:\d+\.\d+|\d+|\.\d+)$/g;
1287
+ var splitValue = value.toString().matchAll(matchCriteria);
1288
+ var splitValueArray = _to_consumable_array$2(splitValue);
1289
+ var validValue = splitValueArray === null || splitValueArray === void 0 ? void 0 : (_splitValueArray_ = splitValueArray[0]) === null || _splitValueArray_ === void 0 ? void 0 : _splitValueArray_[0];
1290
+ var start = properties.start, end = properties.end;
1291
+ if (validValue !== null && validValue !== undefined) {
1292
+ if (parseFloat(validValue) > end) {
1293
+ return end;
1294
+ } else if (parseFloat(validValue) < start) {
1295
+ return start;
1296
+ } else {
1297
+ return snapToLegalValue({
1298
+ value: parseFloat(validValue),
1299
+ properties: properties
1300
+ });
1301
+ }
1302
+ } else {
1303
+ return oldValue;
1304
+ }
1703
1305
  };
1704
- var iconList = {
1705
- Undo: Undo,
1706
- Redo: Redo,
1707
- Random: Random,
1708
- Favorite: Favorite,
1709
- Up: Up,
1710
- Down: Down,
1711
- Save: Save,
1712
- Add: Add,
1713
- Delete: Delete,
1714
- NegativeSaw: NegativeSaw,
1715
- PositiveSaw: PositiveSaw,
1716
- Sine: Sine,
1717
- Square: Square,
1718
- Triangle: Triangle
1306
+ var getBarTransformStyles = function(param) {
1307
+ var polarity = param.polarity, orientation = param.orientation, normalisedValue = param.normalisedValue, isDisabled = param.isDisabled;
1308
+ var wholeNumberNormalisedValue = normalisedValue * 100;
1309
+ var unipolarValue = wholeNumberNormalisedValue ? parseFloat(wholeNumberNormalisedValue === null || wholeNumberNormalisedValue === void 0 ? void 0 : wholeNumberNormalisedValue.toFixed(2)) : 0;
1310
+ var bipolarValue = (wholeNumberNormalisedValue - 50) / 100;
1311
+ if (!isDisabled) {
1312
+ if (polarity === Polarity.unipolar) {
1313
+ return orientation === Orientation.horizontal ? {
1314
+ width: unipolarValue ? "100%" : '1px',
1315
+ height: '100%',
1316
+ transform: unipolarValue ? "scale(".concat(Math.ceil(unipolarValue) * 0.01, ", 1)") : 'none',
1317
+ transformOrigin: 'center left',
1318
+ top: '0',
1319
+ bottom: '0',
1320
+ left: '0'
1321
+ } : {
1322
+ width: "100%",
1323
+ height: unipolarValue ? '100%' : '1px',
1324
+ transform: "scale(1, ".concat(Math.ceil(unipolarValue) * 0.01, ")"),
1325
+ transformOrigin: 'bottom center',
1326
+ top: '0',
1327
+ bottom: '0',
1328
+ left: '0'
1329
+ };
1330
+ } else {
1331
+ return orientation === Orientation.horizontal ? {
1332
+ width: bipolarValue ? "100%" : '1px',
1333
+ height: '100%',
1334
+ transform: bipolarValue ? "scale(".concat(bipolarValue, ", 1)") : 'none',
1335
+ transformOrigin: 'left center',
1336
+ top: '0',
1337
+ bottom: '0',
1338
+ left: '50%'
1339
+ } : {
1340
+ width: "100%",
1341
+ height: bipolarValue ? '100%' : '1px',
1342
+ transform: bipolarValue ? "scale(1, ".concat(bipolarValue, ")") : 'none',
1343
+ transformOrigin: 'bottom center',
1344
+ bottom: '50%',
1345
+ left: '0',
1346
+ right: '0'
1347
+ };
1348
+ }
1349
+ } else return;
1719
1350
  };
1720
- // const getViewBoxWidth = (width: string) => {
1721
- // const numericWidth = width.match(/\d+/)?.[0];
1722
- // return numericWidth !== undefined ? parseInt(numericWidth) : 24;
1723
- // };
1724
- function Icon(param) {
1725
- var icon = param.icon, onClick = param.onClick, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_color = param.color, color = _param_color === void 0 ? 'var(--color-text)' : _param_color, _param_padding = param.padding, padding = _param_padding === void 0 ? [
1726
- Spacing.none
1727
- ] : _param_padding, _param_width = param.width, width = _param_width === void 0 ? '24px' : _param_width, height = param.height, className = param.className, style = param.style;
1728
- var _$Icon = iconList[icon];
1729
- var _width_match;
1730
- var numberWidth = parseInt(((_width_match = width.match(/\d/g)) !== null && _width_match !== void 0 ? _width_match : []).join(''), 10);
1731
- return /*#__PURE__*/ React__default.createElement(Box, {
1732
- className: "Icon ".concat(className ? className : ''),
1733
- onClick: onClick,
1734
- padding: padding,
1735
- style: _object_spread$k({
1736
- width: width,
1737
- height: height !== null && height !== void 0 ? height : width
1738
- }, style)
1739
- }, /*#__PURE__*/ React__default.createElement(_$Icon, {
1740
- width: numberWidth,
1741
- color: disabled ? 'var(--color-gray-400)' : color
1742
- }));
1351
+ var randomizeValue = function(min, max) {
1352
+ return Math.random() * (max - min) + min;
1353
+ };
1354
+ var incrementValue = function(param) {
1355
+ var incomingVal = param.incomingVal, prevVal = param.prevVal, interval = param.interval;
1356
+ var getNormalisedInterval = function() {
1357
+ if (interval) {
1358
+ if (interval >= 1) {
1359
+ return interval * 0.01;
1360
+ } else {
1361
+ return interval;
1362
+ }
1363
+ } else {
1364
+ return 0.01;
1365
+ }
1366
+ };
1367
+ var normalisedInterval = getNormalisedInterval();
1368
+ var newValue = (prevVal !== null && prevVal !== void 0 ? prevVal : 0) + incomingVal * // (interval && interval.toString().length > 4
1369
+ // ? 4
1370
+ // : 0.4) *
1371
+ normalisedInterval;
1372
+ return clamp(newValue);
1373
+ };
1374
+ var timerFlag = null;
1375
+ function throttle(mainFunction, delay) {
1376
+ return function() {
1377
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1378
+ args[_key] = arguments[_key];
1379
+ }
1380
+ if (timerFlag === null) {
1381
+ mainFunction.apply(void 0, _to_consumable_array$2(args));
1382
+ timerFlag = setTimeout(function() {
1383
+ timerFlag = null;
1384
+ }, delay);
1385
+ }
1386
+ };
1387
+ }
1388
+
1389
+ function _array_like_to_array$f(arr, len) {
1390
+ if (len == null || len > arr.length) len = arr.length;
1391
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1392
+ return arr2;
1393
+ }
1394
+ function _array_with_holes$f(arr) {
1395
+ if (Array.isArray(arr)) return arr;
1396
+ }
1397
+ function _array_without_holes$1(arr) {
1398
+ if (Array.isArray(arr)) return _array_like_to_array$f(arr);
1399
+ }
1400
+ function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
1401
+ try {
1402
+ var info = gen[key](arg);
1403
+ var value = info.value;
1404
+ } catch (error) {
1405
+ reject(error);
1406
+ return;
1407
+ }
1408
+ if (info.done) {
1409
+ resolve(value);
1410
+ } else {
1411
+ Promise.resolve(value).then(_next, _throw);
1412
+ }
1743
1413
  }
1744
- Icon.icon = Icons;
1745
- Icon.padding = Spacing;
1746
- Icon.margin = Spacing;
1747
-
1748
- function _define_property$k(obj, key, value) {
1414
+ function _async_to_generator$4(fn) {
1415
+ return function() {
1416
+ var self = this, args = arguments;
1417
+ return new Promise(function(resolve, reject) {
1418
+ var gen = fn.apply(self, args);
1419
+ function _next(value) {
1420
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
1421
+ }
1422
+ function _throw(err) {
1423
+ asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
1424
+ }
1425
+ _next(undefined);
1426
+ });
1427
+ };
1428
+ }
1429
+ function _define_property$j(obj, key, value) {
1749
1430
  if (key in obj) {
1750
1431
  Object.defineProperty(obj, key, {
1751
1432
  value: value,
@@ -1758,7 +1439,40 @@ function _define_property$k(obj, key, value) {
1758
1439
  }
1759
1440
  return obj;
1760
1441
  }
1761
- function _object_spread$j(target) {
1442
+ function _iterable_to_array$1(iter) {
1443
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1444
+ }
1445
+ function _iterable_to_array_limit$f(arr, i) {
1446
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1447
+ if (_i == null) return;
1448
+ var _arr = [];
1449
+ var _n = true;
1450
+ var _d = false;
1451
+ var _s, _e;
1452
+ try {
1453
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1454
+ _arr.push(_s.value);
1455
+ if (i && _arr.length === i) break;
1456
+ }
1457
+ } catch (err) {
1458
+ _d = true;
1459
+ _e = err;
1460
+ } finally{
1461
+ try {
1462
+ if (!_n && _i["return"] != null) _i["return"]();
1463
+ } finally{
1464
+ if (_d) throw _e;
1465
+ }
1466
+ }
1467
+ return _arr;
1468
+ }
1469
+ function _non_iterable_rest$f() {
1470
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1471
+ }
1472
+ function _non_iterable_spread$1() {
1473
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1474
+ }
1475
+ function _object_spread$i(target) {
1762
1476
  for(var i = 1; i < arguments.length; i++){
1763
1477
  var source = arguments[i] != null ? arguments[i] : {};
1764
1478
  var ownKeys = Object.keys(source);
@@ -1768,116 +1482,516 @@ function _object_spread$j(target) {
1768
1482
  }));
1769
1483
  }
1770
1484
  ownKeys.forEach(function(key) {
1771
- _define_property$k(target, key, source[key]);
1485
+ _define_property$j(target, key, source[key]);
1486
+ });
1487
+ }
1488
+ return target;
1489
+ }
1490
+ function ownKeys$3(object, enumerableOnly) {
1491
+ var keys = Object.keys(object);
1492
+ if (Object.getOwnPropertySymbols) {
1493
+ var symbols = Object.getOwnPropertySymbols(object);
1494
+ keys.push.apply(keys, symbols);
1495
+ }
1496
+ return keys;
1497
+ }
1498
+ function _object_spread_props$3(target, source) {
1499
+ source = source != null ? source : {};
1500
+ if (Object.getOwnPropertyDescriptors) {
1501
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
1502
+ } else {
1503
+ ownKeys$3(Object(source)).forEach(function(key) {
1504
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1772
1505
  });
1773
1506
  }
1774
- return target;
1775
- }
1776
- function Label(param) {
1777
- var value = param.value, id = param.id, className = param.className, style = param.style, _param_color = param.color, color = _param_color === void 0 ? 'var(--color-text)' : _param_color, _param_padding = param.padding, padding = _param_padding === void 0 ? [
1778
- Spacing.none
1779
- ] : _param_padding, uppercase = param.uppercase, children = param.children, htmlFor = param.htmlFor, _param_fontSize = param.fontSize, fontSize = _param_fontSize === void 0 ? FontSizes.medium : _param_fontSize;
1780
- var _padding_, _padding_1, _padding_2, _ref;
1781
- return /*#__PURE__*/ React.createElement("label", {
1782
- id: id,
1783
- htmlFor: htmlFor,
1784
- style: _object_spread$j({
1785
- fontSize: "var(--text-".concat(fontSize, ")"),
1786
- lineHeight: "var(--text-".concat(fontSize, ")"),
1787
- paddingTop: "var(--p-".concat(padding[0], ")"),
1788
- paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
1789
- paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
1790
- paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
1791
- WebkitUserSelect: 'none',
1792
- userSelect: 'none',
1793
- letterSpacing: '1px',
1794
- textTransform: uppercase ? 'uppercase' : 'none',
1795
- cursor: 'inherit',
1796
- color: color
1797
- }, style),
1798
- className: classnames('Label', 'select-none', className)
1799
- }, value ? value : children);
1507
+ return target;
1508
+ }
1509
+ function _sliced_to_array$f(arr, i) {
1510
+ return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest$f();
1511
+ }
1512
+ function _to_consumable_array$1(arr) {
1513
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$f(arr) || _non_iterable_spread$1();
1514
+ }
1515
+ function _unsupported_iterable_to_array$f(o, minLen) {
1516
+ if (!o) return;
1517
+ if (typeof o === "string") return _array_like_to_array$f(o, minLen);
1518
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1519
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1520
+ if (n === "Map" || n === "Set") return Array.from(n);
1521
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
1522
+ }
1523
+ function _ts_generator$4(thisArg, body) {
1524
+ var f, y, t, _ = {
1525
+ label: 0,
1526
+ sent: function() {
1527
+ if (t[0] & 1) throw t[1];
1528
+ return t[1];
1529
+ },
1530
+ trys: [],
1531
+ ops: []
1532
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
1533
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1534
+ return this;
1535
+ }), g;
1536
+ function verb(n) {
1537
+ return function(v) {
1538
+ return step([
1539
+ n,
1540
+ v
1541
+ ]);
1542
+ };
1543
+ }
1544
+ function step(op) {
1545
+ if (f) throw new TypeError("Generator is already executing.");
1546
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
1547
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1548
+ if (y = 0, t) op = [
1549
+ op[0] & 2,
1550
+ t.value
1551
+ ];
1552
+ switch(op[0]){
1553
+ case 0:
1554
+ case 1:
1555
+ t = op;
1556
+ break;
1557
+ case 4:
1558
+ _.label++;
1559
+ return {
1560
+ value: op[1],
1561
+ done: false
1562
+ };
1563
+ case 5:
1564
+ _.label++;
1565
+ y = op[1];
1566
+ op = [
1567
+ 0
1568
+ ];
1569
+ continue;
1570
+ case 7:
1571
+ op = _.ops.pop();
1572
+ _.trys.pop();
1573
+ continue;
1574
+ default:
1575
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1576
+ _ = 0;
1577
+ continue;
1578
+ }
1579
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1580
+ _.label = op[1];
1581
+ break;
1582
+ }
1583
+ if (op[0] === 6 && _.label < t[1]) {
1584
+ _.label = t[1];
1585
+ t = op;
1586
+ break;
1587
+ }
1588
+ if (t && _.label < t[2]) {
1589
+ _.label = t[2];
1590
+ _.ops.push(op);
1591
+ break;
1592
+ }
1593
+ if (t[2]) _.ops.pop();
1594
+ _.trys.pop();
1595
+ continue;
1596
+ }
1597
+ op = body.call(thisArg, _);
1598
+ } catch (e) {
1599
+ op = [
1600
+ 6,
1601
+ e
1602
+ ];
1603
+ y = 0;
1604
+ } finally{
1605
+ f = t = 0;
1606
+ }
1607
+ if (op[0] & 5) throw op[1];
1608
+ return {
1609
+ value: op[0] ? op[1] : void 0,
1610
+ done: true
1611
+ };
1612
+ }
1613
+ }
1614
+ // Initial state
1615
+ var defaultGlobalStateValue = {
1616
+ highlightedItem: {
1617
+ label: 'Antimatter Audio',
1618
+ value: 0
1619
+ },
1620
+ // focusedItem: '',
1621
+ allParameters: [],
1622
+ automatableParamsList: [],
1623
+ automatableParamLabels: [],
1624
+ parameterTypes: [],
1625
+ modSlotTargets: {},
1626
+ modSlotIds: [],
1627
+ modSlotParams: [],
1628
+ modSlotParamLabels: [],
1629
+ defaultParamValues: [],
1630
+ advancedView: false
1631
+ };
1632
+ // Reducer function to handle state updates
1633
+ var reducer = function(state, action) {
1634
+ switch(action.type){
1635
+ case 'HIGHLIGHTED_ITEM_CHANGED':
1636
+ return _object_spread_props$3(_object_spread$i({}, state), {
1637
+ highlightedItem: action.payload
1638
+ });
1639
+ // case 'FOCUSED_ITEM_CHANGED':
1640
+ // return { ...state, focusedItem: action.payload };
1641
+ case 'ADVANCED_VIEW_TOGGLED':
1642
+ return _object_spread_props$3(_object_spread$i({}, state), {
1643
+ advancedView: action.payload
1644
+ });
1645
+ case 'AUTOMATABLE_PARAMS_LIST_RECEIVED':
1646
+ return _object_spread_props$3(_object_spread$i({}, state), {
1647
+ automatableParamsList: action.payload
1648
+ });
1649
+ case 'AUTOMATABLE_PARAM_LABELS_RECEIVED':
1650
+ return _object_spread_props$3(_object_spread$i({}, state), {
1651
+ automatableParamLabels: action.payload
1652
+ });
1653
+ case 'PARAMETER_TYPES_RECEIVED':
1654
+ return _object_spread_props$3(_object_spread$i({}, state), {
1655
+ parameterTypes: action.payload
1656
+ });
1657
+ case 'ALL_PARAMETERS_RECEIVED':
1658
+ return _object_spread_props$3(_object_spread$i({}, state), {
1659
+ allParameters: action.payload
1660
+ });
1661
+ case 'MOD_SLOTS_RECEIVED':
1662
+ var _action_payload;
1663
+ return _object_spread_props$3(_object_spread$i({}, state), {
1664
+ modSlotIds: action === null || action === void 0 ? void 0 : (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.map(function(val) {
1665
+ return val === null || val === void 0 ? void 0 : val[0];
1666
+ })
1667
+ });
1668
+ case 'MOD_SLOT_ROW_TARGETS_RECEIVED':
1669
+ var _Object_values, _action_payload1;
1670
+ var unsavedPreview = (_Object_values = Object.values(state === null || state === void 0 ? void 0 : state.modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.find(function(item) {
1671
+ return (item === null || item === void 0 ? void 0 : item.targetIndex) > 0 && !item.isSaved;
1672
+ });
1673
+ return _object_spread_props$3(_object_spread$i({}, state), {
1674
+ modSlotTargets: action === null || action === void 0 ? void 0 : (_action_payload1 = action.payload) === null || _action_payload1 === void 0 ? void 0 : _action_payload1.reduce(function(acc, val) {
1675
+ var newVal = _object_spread_props$3(_object_spread$i({}, acc), _define_property$j({}, val === null || val === void 0 ? void 0 : val[0], {
1676
+ rowId: val === null || val === void 0 ? void 0 : val[0],
1677
+ targetIndex: val === null || val === void 0 ? void 0 : val[1],
1678
+ isSaved: (val === null || val === void 0 ? void 0 : val[1]) > 0
1679
+ }));
1680
+ if (unsavedPreview !== undefined) {
1681
+ newVal[unsavedPreview.rowId] = {
1682
+ rowId: unsavedPreview.rowId,
1683
+ targetIndex: unsavedPreview.targetIndex,
1684
+ isSaved: false
1685
+ };
1686
+ }
1687
+ acc = newVal;
1688
+ return acc;
1689
+ }, {})
1690
+ });
1691
+ // modSlotTargets have three states:
1692
+ // 1. Unassigned:
1693
+ // rowId: 'modSlotId',
1694
+ // targetIndex: 0,
1695
+ // isSaved: false
1696
+ // 2. Assigned and unsaved:
1697
+ // rowId: 'modSlotId',
1698
+ // targetIndex: 2,
1699
+ // isSaved: false
1700
+ // 3. Assigned and saved:
1701
+ // rowId: 'modSlotId',
1702
+ // targetIndex: 2,
1703
+ // isSaved: true
1704
+ case 'MOD_SLOT_ROW_TARGET_UPDATED':
1705
+ var _action_payload2, _action_payload3, _state_modSlotTargets, _action_payload4, _state_modSlotTargets_action_payload_id, _state_modSlotTargets1, _action_payload5, _state_modSlotTargets_action_payload_id1, _action_payload6, _state_modSlotTargets2;
1706
+ var _action_payload_value, _action_payload_isSaved;
1707
+ return _object_spread_props$3(_object_spread$i({}, state), {
1708
+ modSlotTargets: _object_spread_props$3(_object_spread$i({}, state === null || state === void 0 ? void 0 : state.modSlotTargets), _define_property$j({}, (_action_payload2 = action.payload) === null || _action_payload2 === void 0 ? void 0 : _action_payload2.id, _object_spread_props$3(_object_spread$i({}, state === null || state === void 0 ? void 0 : (_state_modSlotTargets = state.modSlotTargets) === null || _state_modSlotTargets === void 0 ? void 0 : _state_modSlotTargets[(_action_payload3 = action.payload) === null || _action_payload3 === void 0 ? void 0 : _action_payload3.id]), {
1709
+ targetIndex: (_action_payload_value = action === null || action === void 0 ? void 0 : (_action_payload4 = action.payload) === null || _action_payload4 === void 0 ? void 0 : _action_payload4.value) !== null && _action_payload_value !== void 0 ? _action_payload_value : state === null || state === void 0 ? void 0 : (_state_modSlotTargets1 = state.modSlotTargets) === null || _state_modSlotTargets1 === void 0 ? void 0 : (_state_modSlotTargets_action_payload_id = _state_modSlotTargets1[action.payload.id]) === null || _state_modSlotTargets_action_payload_id === void 0 ? void 0 : _state_modSlotTargets_action_payload_id.targetIndex,
1710
+ isSaved: (_action_payload_isSaved = action === null || action === void 0 ? void 0 : (_action_payload5 = action.payload) === null || _action_payload5 === void 0 ? void 0 : _action_payload5.isSaved) !== null && _action_payload_isSaved !== void 0 ? _action_payload_isSaved : state === null || state === void 0 ? void 0 : (_state_modSlotTargets2 = state.modSlotTargets) === null || _state_modSlotTargets2 === void 0 ? void 0 : (_state_modSlotTargets_action_payload_id1 = _state_modSlotTargets2[(_action_payload6 = action.payload) === null || _action_payload6 === void 0 ? void 0 : _action_payload6.id]) === null || _state_modSlotTargets_action_payload_id1 === void 0 ? void 0 : _state_modSlotTargets_action_payload_id1.isSaved
1711
+ })))
1712
+ });
1713
+ case 'MOD_SLOT_PARAMS_LIST_RECEIVED':
1714
+ var modSlotNames = Object.keys(state.modSlotTargets);
1715
+ return _object_spread_props$3(_object_spread$i({}, state), {
1716
+ modSlotParams: action === null || action === void 0 ? void 0 : action.payload.reduce(function(acc, item, i) {
1717
+ acc[modSlotNames[i]] = item;
1718
+ return acc;
1719
+ }, {})
1720
+ });
1721
+ case 'DEFAULT_PARAM_VALUES_RECEIVED':
1722
+ return _object_spread_props$3(_object_spread$i({}, state), {
1723
+ defaultParamValues: action === null || action === void 0 ? void 0 : action.payload
1724
+ });
1725
+ case 'MOD_SLOT_PARAM_LABELS_RECIEVED':
1726
+ return _object_spread_props$3(_object_spread$i({}, state), {
1727
+ modSlotParamLabels: action === null || action === void 0 ? void 0 : action.payload
1728
+ });
1729
+ default:
1730
+ return state;
1731
+ }
1732
+ };
1733
+ // Create the context
1734
+ var GlobalContext = /*#__PURE__*/ createContext({
1735
+ globalState: defaultGlobalStateValue
1736
+ });
1737
+ // Custom hook for consuming context with a selector
1738
+ function useGlobalContext(selector) {
1739
+ var localContext = useContext(GlobalContext);
1740
+ return selector ? selector(localContext) : localContext;
1800
1741
  }
1801
- Label.padding = Spacing;
1802
- Label.fontSize = FontSizes;
1803
-
1804
- function _define_property$j(obj, key, value) {
1805
- if (key in obj) {
1806
- Object.defineProperty(obj, key, {
1807
- value: value,
1808
- enumerable: true,
1809
- configurable: true,
1810
- writable: true
1742
+ // Context provider
1743
+ function GlobalContextProvider(param) {
1744
+ var children = param.children;
1745
+ var _useReducer = _sliced_to_array$f(useReducer(reducer, defaultGlobalStateValue), 2), state = _useReducer[0], dispatch = _useReducer[1];
1746
+ var highlightedItemChanged = useCallback(function(highlightedItem) {
1747
+ dispatch({
1748
+ type: 'HIGHLIGHTED_ITEM_CHANGED',
1749
+ payload: highlightedItem
1811
1750
  });
1812
- } else {
1813
- obj[key] = value;
1814
- }
1815
- return obj;
1816
- }
1817
- function _object_spread$i(target) {
1818
- for(var i = 1; i < arguments.length; i++){
1819
- var source = arguments[i] != null ? arguments[i] : {};
1820
- var ownKeys = Object.keys(source);
1821
- if (typeof Object.getOwnPropertySymbols === "function") {
1822
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1823
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1824
- }));
1751
+ }, []);
1752
+ // const focusedItemChanged = useCallback((focusedItem: string) => {
1753
+ // dispatch({ type: 'FOCUSED_ITEM_CHANGED', payload: focusedItem });
1754
+ // }, []);
1755
+ var advancedViewToggled = useCallback(function(advancedView) {
1756
+ dispatch({
1757
+ type: 'ADVANCED_VIEW_TOGGLED',
1758
+ payload: advancedView
1759
+ });
1760
+ }, []);
1761
+ var automatableParamsListReceived = useCallback(function(automatableParamsList) {
1762
+ dispatch({
1763
+ type: 'AUTOMATABLE_PARAMS_LIST_RECEIVED',
1764
+ payload: [
1765
+ 'none'
1766
+ ].concat(_to_consumable_array$1(automatableParamsList))
1767
+ });
1768
+ }, []);
1769
+ var allParametersReceived = useCallback(function(allParameters) {
1770
+ dispatch({
1771
+ type: 'ALL_PARAMETERS_RECEIVED',
1772
+ payload: allParameters
1773
+ });
1774
+ }, []);
1775
+ var parameterTypesReceived = useCallback(function(parameterTypes) {
1776
+ dispatch({
1777
+ type: 'PARAMETER_TYPES_RECEIVED',
1778
+ payload: parameterTypes
1779
+ });
1780
+ }, []);
1781
+ var automatableParamLabelsReceived = useCallback(function(automatableParamLabels) {
1782
+ dispatch({
1783
+ type: 'AUTOMATABLE_PARAM_LABELS_RECEIVED',
1784
+ payload: automatableParamLabels
1785
+ });
1786
+ }, []);
1787
+ var defaultParamValuesReceived = useCallback(function(defaultParamValues) {
1788
+ dispatch({
1789
+ type: 'DEFAULT_PARAM_VALUES_RECEIVED',
1790
+ payload: defaultParamValues
1791
+ });
1792
+ }, []);
1793
+ var modSlotsReceived = useCallback(function(modSlots) {
1794
+ dispatch({
1795
+ type: 'MOD_SLOTS_RECEIVED',
1796
+ payload: modSlots
1797
+ });
1798
+ }, []);
1799
+ var modSlotRowTargetsReceived = useCallback(function(modSlots) {
1800
+ dispatch({
1801
+ type: 'MOD_SLOT_ROW_TARGETS_RECEIVED',
1802
+ payload: modSlots
1803
+ });
1804
+ }, []);
1805
+ var modSlotRowTargetUpdated = useCallback(function(modSlot) {
1806
+ dispatch({
1807
+ type: 'MOD_SLOT_ROW_TARGET_UPDATED',
1808
+ payload: modSlot
1809
+ });
1810
+ }, []);
1811
+ var modSlotParamsListReceived = useCallback(function(modSlotParams) {
1812
+ dispatch({
1813
+ type: 'MOD_SLOT_PARAMS_LIST_RECEIVED',
1814
+ payload: modSlotParams
1815
+ });
1816
+ }, []);
1817
+ var modSlotParamLabelsReceived = useCallback(function(modSlotParamLables) {
1818
+ dispatch({
1819
+ type: 'MOD_SLOT_PARAM_LABELS_RECIEVED',
1820
+ payload: modSlotParamLables
1821
+ });
1822
+ }, []);
1823
+ var setDefaultParameter = function(id) {
1824
+ var paramIndex = state === null || state === void 0 ? void 0 : state.allParameters.indexOf(id);
1825
+ var defaultValue = state === null || state === void 0 ? void 0 : state.defaultParamValues[paramIndex];
1826
+ var parameterType = state === null || state === void 0 ? void 0 : state.parameterTypes[paramIndex];
1827
+ if (parameterType === 'slider') {
1828
+ var _sliderState_properties, _sliderState_properties1, _sliderState_properties2;
1829
+ var sliderState = Juce.getSliderState(id);
1830
+ var normalisedDefaultValue = scaledToNormalised({
1831
+ scaledValue: defaultValue,
1832
+ start: sliderState === null || sliderState === void 0 ? void 0 : (_sliderState_properties = sliderState.properties) === null || _sliderState_properties === void 0 ? void 0 : _sliderState_properties.start,
1833
+ end: sliderState === null || sliderState === void 0 ? void 0 : (_sliderState_properties1 = sliderState.properties) === null || _sliderState_properties1 === void 0 ? void 0 : _sliderState_properties1.end,
1834
+ skew: sliderState === null || sliderState === void 0 ? void 0 : (_sliderState_properties2 = sliderState.properties) === null || _sliderState_properties2 === void 0 ? void 0 : _sliderState_properties2.skew
1835
+ });
1836
+ sliderState === null || sliderState === void 0 ? void 0 : sliderState.setNormalisedValue(normalisedDefaultValue);
1837
+ // if(state?.modSlots)
1838
+ } else if (parameterType === 'combobox') {
1839
+ var comboBoxState = Juce.getComboBoxState(id);
1840
+ comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.setChoiceIndex(defaultValue);
1825
1841
  }
1826
- ownKeys.forEach(function(key) {
1827
- _define_property$j(target, key, source[key]);
1842
+ };
1843
+ var getDefaultParameter = function(id) {
1844
+ var paramIndex = state === null || state === void 0 ? void 0 : state.allParameters.indexOf(id);
1845
+ return state === null || state === void 0 ? void 0 : state.defaultParamValues[paramIndex];
1846
+ };
1847
+ var getModSlotPreview = function() {
1848
+ var _Object_values, _Object;
1849
+ return (_Object = Object) === null || _Object === void 0 ? void 0 : (_Object_values = _Object.values(state === null || state === void 0 ? void 0 : state.modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.find(function(item) {
1850
+ return !(item === null || item === void 0 ? void 0 : item.isSaved);
1828
1851
  });
1829
- }
1830
- return target;
1831
- }
1832
- function IconButton(param) {
1833
- var id = param.id, icon = param.icon, onClick = param.onClick, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_color = param.color, color = _param_color === void 0 ? 'var(--color-text)' : _param_color, // backgroundColor = 'var(--bg-lv1)',
1834
- backgroundColor = param.backgroundColor, _param_padding = param.padding, padding = _param_padding === void 0 ? [
1835
- Button.padding.none
1836
- ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
1837
- Button.margin.none
1838
- ] : _param_margin, _param_width = param.width, width = _param_width === void 0 ? '24px' : _param_width, iconWidth = param.iconWidth, label = param.label, height = param.height, className = param.className, style = param.style;
1839
- var Icon = iconList[icon];
1840
- var _width_match;
1841
- var numberWidth = parseInt(((_width_match = width.match(/\d/g)) !== null && _width_match !== void 0 ? _width_match : []).join(''), 10);
1842
- var _iconWidth_match;
1843
- var iconNumberWidth = typeof iconWidth === 'string' && parseInt(((_iconWidth_match = iconWidth === null || iconWidth === void 0 ? void 0 : iconWidth.match(/\d/g)) !== null && _iconWidth_match !== void 0 ? _iconWidth_match : []).join(''), 10);
1844
- return /*#__PURE__*/ React__default.createElement(Button, {
1845
- id: id,
1846
- className: "IconButton ".concat(className ? className : ''),
1847
- onClick: onClick,
1848
- padding: padding,
1849
- margin: margin,
1850
- disabled: disabled,
1851
- style: _object_spread$i({
1852
- backgroundColor: backgroundColor,
1853
- width: width,
1854
- height: height !== null && height !== void 0 ? height : 'auto'
1855
- }, style)
1856
- }, /*#__PURE__*/ React__default.createElement(Box, {
1857
- flexDirection: Box.flexDirection.column,
1858
- gap: Box.gap.mediumSmall
1859
- }, /*#__PURE__*/ React__default.createElement(Icon, {
1860
- width: iconNumberWidth || numberWidth,
1861
- color: disabled ? 'var(--color-gray-400)' : color
1862
- }), label ? /*#__PURE__*/ React__default.createElement(Label, {
1863
- color: color,
1864
- fontSize: Label.fontSize.xSmall,
1865
- value: label
1866
- }) : null));
1852
+ };
1853
+ // const setModSlotTarget = (newTarget: number, rowId: string) => {
1854
+ // const comboBoxState = Juce.getComboBoxState(rowId);
1855
+ // comboBoxState?.setChoiceIndex(newTarget);
1856
+ // };
1857
+ var refetchModSlots = function() {
1858
+ return _async_to_generator$4(function() {
1859
+ var getAllModSlotsFunc, modSlotsData, e;
1860
+ return _ts_generator$4(this, function(_state) {
1861
+ switch(_state.label){
1862
+ case 0:
1863
+ _state.trys.push([
1864
+ 0,
1865
+ 2,
1866
+ ,
1867
+ 3
1868
+ ]);
1869
+ getAllModSlotsFunc = Juce.getNativeFunction('getAllModSlots');
1870
+ return [
1871
+ 4,
1872
+ getAllModSlotsFunc()
1873
+ ];
1874
+ case 1:
1875
+ modSlotsData = _state.sent();
1876
+ modSlotRowTargetsReceived(modSlotsData || []);
1877
+ return [
1878
+ 3,
1879
+ 3
1880
+ ];
1881
+ case 2:
1882
+ e = _state.sent();
1883
+ console.log(e);
1884
+ return [
1885
+ 3,
1886
+ 3
1887
+ ];
1888
+ case 3:
1889
+ return [
1890
+ 2
1891
+ ];
1892
+ }
1893
+ });
1894
+ })();
1895
+ };
1896
+ // modSlotTargets have three states:
1897
+ // 1. Unassigned:
1898
+ // rowId: 'modSlotId',
1899
+ // targetIndex: 0,
1900
+ // isSaved: false
1901
+ // 2. Assigned and unsaved:
1902
+ // rowId: 'modSlotId',
1903
+ // targetIndex: 2,
1904
+ // isSaved: false
1905
+ // 3. Assigned and saved:
1906
+ // rowId: 'modSlotId',
1907
+ // targetIndex: 2,
1908
+ // isSaved: true
1909
+ var updateModSlotRowTarget = function(param) {
1910
+ var value = param.value, rowId = param.rowId, saveToBackend = param.saveToBackend;
1911
+ var _Object_values;
1912
+ // Convert a string id to an automatableParamsList index
1913
+ var numValue = typeof value === 'string' ? state === null || state === void 0 ? void 0 : state.automatableParamsList.findIndex(function(item) {
1914
+ return item === value;
1915
+ }) : value;
1916
+ // Don't allow duplicate targets
1917
+ // This check happens when a new (unsaved) target is added to the matriz
1918
+ var targetExists = ((_Object_values = Object.values(state === null || state === void 0 ? void 0 : state.modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.find(function(item) {
1919
+ return (item === null || item === void 0 ? void 0 : item.targetIndex) === numValue;
1920
+ })) !== undefined;
1921
+ var isPreview = !saveToBackend;
1922
+ if (isPreview && !targetExists) {
1923
+ modSlotRowTargetUpdated({
1924
+ id: rowId,
1925
+ value: numValue > -1 ? numValue : undefined,
1926
+ isSaved: false
1927
+ });
1928
+ } else if (!isPreview && value !== null && value !== undefined || numValue === 0) {
1929
+ modSlotRowTargetUpdated({
1930
+ id: rowId,
1931
+ value: numValue > -1 ? numValue : undefined,
1932
+ isSaved: true
1933
+ });
1934
+ var rowState = Juce.getComboBoxState(rowId);
1935
+ rowState === null || rowState === void 0 ? void 0 : rowState.setChoiceIndex(value);
1936
+ if (value === 0) {
1937
+ var _state_modSlotParams_rowId, _state_modSlotParams;
1938
+ state === null || state === void 0 ? void 0 : (_state_modSlotParams = state.modSlotParams) === null || _state_modSlotParams === void 0 ? void 0 : (_state_modSlotParams_rowId = _state_modSlotParams[rowId]) === null || _state_modSlotParams_rowId === void 0 ? void 0 : _state_modSlotParams_rowId.forEach(function(item) {
1939
+ setDefaultParameter(item);
1940
+ });
1941
+ }
1942
+ refetchModSlots();
1943
+ }
1944
+ };
1945
+ var deleteModSlotRowTarget = function(rowId) {
1946
+ updateModSlotRowTarget({
1947
+ rowId: rowId,
1948
+ value: 0,
1949
+ saveToBackend: true
1950
+ });
1951
+ };
1952
+ var onFire = function() {
1953
+ var //@ts-expect-error
1954
+ _window___JUCE___backend, _window___JUCE__, _window;
1955
+ (_window = window) === null || _window === void 0 ? void 0 : (_window___JUCE__ = _window.__JUCE__) === null || _window___JUCE__ === void 0 ? void 0 : (_window___JUCE___backend = _window___JUCE__.backend) === null || _window___JUCE___backend === void 0 ? void 0 : _window___JUCE___backend.emitEvent('setRandom', {});
1956
+ };
1957
+ var useRandom = useObservable({
1958
+ onFire: onFire
1959
+ });
1960
+ var value = {
1961
+ globalState: state,
1962
+ highlightedItemChanged: highlightedItemChanged,
1963
+ advancedViewToggled: advancedViewToggled,
1964
+ automatableParamsListReceived: automatableParamsListReceived,
1965
+ automatableParamLabelsReceived: automatableParamLabelsReceived,
1966
+ parameterTypesReceived: parameterTypesReceived,
1967
+ allParametersReceived: allParametersReceived,
1968
+ defaultParamValuesReceived: defaultParamValuesReceived,
1969
+ setDefaultParameter: setDefaultParameter,
1970
+ getDefaultParameter: getDefaultParameter,
1971
+ getModSlotPreview: getModSlotPreview,
1972
+ modSlotsReceived: modSlotsReceived,
1973
+ modSlotRowTargetsReceived: modSlotRowTargetsReceived,
1974
+ updateModSlotRowTarget: updateModSlotRowTarget,
1975
+ deleteModSlotRowTarget: deleteModSlotRowTarget,
1976
+ // setModSlotTarget,
1977
+ modSlotParamsListReceived: modSlotParamsListReceived,
1978
+ modSlotParamLabelsReceived: modSlotParamLabelsReceived,
1979
+ useRandom: useRandom
1980
+ };
1981
+ return /*#__PURE__*/ React__default.createElement(GlobalContext.Provider, {
1982
+ value: value
1983
+ }, children);
1867
1984
  }
1868
- IconButton.icon = Icons;
1869
- IconButton.padding = Spacing;
1870
- IconButton.margin = Spacing;
1871
1985
 
1872
- function _array_like_to_array$f(arr, len) {
1986
+ function _array_like_to_array$e(arr, len) {
1873
1987
  if (len == null || len > arr.length) len = arr.length;
1874
1988
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1875
1989
  return arr2;
1876
1990
  }
1877
- function _array_with_holes$f(arr) {
1991
+ function _array_with_holes$e(arr) {
1878
1992
  if (Array.isArray(arr)) return arr;
1879
1993
  }
1880
- function _iterable_to_array_limit$f(arr, i) {
1994
+ function _iterable_to_array_limit$e(arr, i) {
1881
1995
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1882
1996
  if (_i == null) return;
1883
1997
  var _arr = [];
@@ -1901,28 +2015,28 @@ function _iterable_to_array_limit$f(arr, i) {
1901
2015
  }
1902
2016
  return _arr;
1903
2017
  }
1904
- function _non_iterable_rest$f() {
2018
+ function _non_iterable_rest$e() {
1905
2019
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1906
2020
  }
1907
- function _sliced_to_array$f(arr, i) {
1908
- return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest$f();
2021
+ function _sliced_to_array$e(arr, i) {
2022
+ return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$e(arr, i) || _non_iterable_rest$e();
1909
2023
  }
1910
- function _unsupported_iterable_to_array$f(o, minLen) {
2024
+ function _unsupported_iterable_to_array$e(o, minLen) {
1911
2025
  if (!o) return;
1912
- if (typeof o === "string") return _array_like_to_array$f(o, minLen);
2026
+ if (typeof o === "string") return _array_like_to_array$e(o, minLen);
1913
2027
  var n = Object.prototype.toString.call(o).slice(8, -1);
1914
2028
  if (n === "Object" && o.constructor) n = o.constructor.name;
1915
2029
  if (n === "Map" || n === "Set") return Array.from(n);
1916
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
2030
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
1917
2031
  }
1918
2032
  var useDropdown = function(param) {
1919
2033
  var id = param.id, // TODO: Is there a better way to handle mod matrix dropdowns?
1920
2034
  rowId = param.rowId, label = param.label, _param_items = param.items, items = _param_items === void 0 ? [] : _param_items, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, filter = param.filter, onChange = param.onChange, _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader;
1921
2035
  var _properties_choices;
1922
2036
  var comboBoxState = Juce.getComboBoxState(id);
1923
- var _useState = _sliced_to_array$f(useState(comboBoxState.getChoiceIndex()), 2), index = _useState[0], setIndex = _useState[1];
1924
- var _useState1 = _sliced_to_array$f(useState(comboBoxState.properties), 2), properties = _useState1[0], setProperties = _useState1[1];
1925
- var _useGlobalContext = useGlobalContext(), highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview;
2037
+ var _useState = _sliced_to_array$e(useState(comboBoxState.getChoiceIndex()), 2), index = _useState[0], setIndex = _useState[1];
2038
+ var _useState1 = _sliced_to_array$e(useState(comboBoxState.properties), 2), properties = _useState1[0], setProperties = _useState1[1];
2039
+ var _useGlobalContext = useGlobalContext(), highlightedItemChanged = _useGlobalContext.highlightedItemChanged, updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget;
1926
2040
  var choices = items.length ? items : (properties === null || properties === void 0 ? void 0 : (_properties_choices = properties.choices) === null || _properties_choices === void 0 ? void 0 : _properties_choices.length) ? properties === null || properties === void 0 ? void 0 : properties.choices : [];
1927
2041
  var filteredChoices = filter ? choices === null || choices === void 0 ? void 0 : choices.filter(function(item) {
1928
2042
  var _item_;
@@ -1999,8 +2113,9 @@ var useDropdown = function(param) {
1999
2113
  }
2000
2114
  };
2001
2115
  var onClick = function() {
2002
- setModSlotRowTargetAsPreview({
2003
- paramId: id
2116
+ updateModSlotRowTarget({
2117
+ value: id,
2118
+ saveToBackend: false
2004
2119
  });
2005
2120
  };
2006
2121
  return {
@@ -2017,148 +2132,6 @@ var useDropdown = function(param) {
2017
2132
  };
2018
2133
  };
2019
2134
 
2020
- function _array_like_to_array$e(arr, len) {
2021
- if (len == null || len > arr.length) len = arr.length;
2022
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2023
- return arr2;
2024
- }
2025
- function _array_with_holes$e(arr) {
2026
- if (Array.isArray(arr)) return arr;
2027
- }
2028
- function _iterable_to_array_limit$e(arr, i) {
2029
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2030
- if (_i == null) return;
2031
- var _arr = [];
2032
- var _n = true;
2033
- var _d = false;
2034
- var _s, _e;
2035
- try {
2036
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2037
- _arr.push(_s.value);
2038
- if (i && _arr.length === i) break;
2039
- }
2040
- } catch (err) {
2041
- _d = true;
2042
- _e = err;
2043
- } finally{
2044
- try {
2045
- if (!_n && _i["return"] != null) _i["return"]();
2046
- } finally{
2047
- if (_d) throw _e;
2048
- }
2049
- }
2050
- return _arr;
2051
- }
2052
- function _non_iterable_rest$e() {
2053
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2054
- }
2055
- function _sliced_to_array$e(arr, i) {
2056
- return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$e(arr, i) || _non_iterable_rest$e();
2057
- }
2058
- function _unsupported_iterable_to_array$e(o, minLen) {
2059
- if (!o) return;
2060
- if (typeof o === "string") return _array_like_to_array$e(o, minLen);
2061
- var n = Object.prototype.toString.call(o).slice(8, -1);
2062
- if (n === "Object" && o.constructor) n = o.constructor.name;
2063
- if (n === "Map" || n === "Set") return Array.from(n);
2064
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
2065
- }
2066
- function Tabs(param) {
2067
- var items = param.items, _param_id = param.id, id = _param_id === void 0 ? '' : _param_id, className = param.className, _param_padding = param.padding, padding = _param_padding === void 0 ? [
2068
- Spacing.none
2069
- ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
2070
- Spacing.none
2071
- ] : _param_margin, _param_gap = param.gap, gap = _param_gap === void 0 ? Spacing.small : _param_gap, width = param.width, height = param.height, tabWidth = param.tabWidth, tabHeight = param.tabHeight, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.horizontal : _param_orientation, _param_justifyContent = param.justifyContent, justifyContent = _param_justifyContent === void 0 ? JustifyContent$1.stretch : _param_justifyContent, _param_alignItems = param.alignItems, alignItems = _param_alignItems === void 0 ? AlignItems$1.stretch : _param_alignItems, _param_color = param.color, color = _param_color === void 0 ? 'var(--bg-lv11)' : _param_color, _param_selectedColor = param.selectedColor, selectedColor = _param_selectedColor === void 0 ? 'var(--color-brand)' : _param_selectedColor, _param_backgroundColor = param.backgroundColor, backgroundColor = _param_backgroundColor === void 0 ? 'transparent' : _param_backgroundColor, _param_fontSize = param.fontSize, fontSize = _param_fontSize === void 0 ? FontSizes.small : _param_fontSize, selectedBackgroundColor = param.selectedBackgroundColor, icons = param.icons, onChange = param.onChange;
2072
- var _useState = _sliced_to_array$e(useState(0), 2), selectedIndex = _useState[0], setSelectedIndex = _useState[1];
2073
- var _useDropdown = useDropdown({
2074
- id: id,
2075
- onChange: onChange
2076
- }), index = _useDropdown.index, choices = _useDropdown.choices, handleChange = _useDropdown.handleChange;
2077
- var changeHandler = function(index) {
2078
- if (id) {
2079
- handleChange(index);
2080
- } else {
2081
- setSelectedIndex(index);
2082
- onChange && onChange(index);
2083
- }
2084
- };
2085
- var currentIndex = id ? index : selectedIndex;
2086
- // console.log(choices, 'CHOICES');
2087
- var displayedItems = items !== null && items !== void 0 ? items : choices;
2088
- var _margin_, _margin_1, _margin_2, _ref;
2089
- //around
2090
- //vertical, horizontal
2091
- // top, right, bottom, left
2092
- return /*#__PURE__*/ React__default.createElement(TabGroup, {
2093
- style: {
2094
- marginTop: "var(--mt-".concat(margin[0], ")"),
2095
- marginRight: "var(--mr-".concat((_margin_ = margin[1]) !== null && _margin_ !== void 0 ? _margin_ : margin[0], ")"),
2096
- marginBottom: "var(--mb-".concat((_margin_1 = margin[2]) !== null && _margin_1 !== void 0 ? _margin_1 : margin[0], ")"),
2097
- marginLeft: "var(--ml-".concat((_ref = (_margin_2 = margin[3]) !== null && _margin_2 !== void 0 ? _margin_2 : margin[1]) !== null && _ref !== void 0 ? _ref : margin[0], ")"),
2098
- width: width,
2099
- height: height
2100
- },
2101
- manual: true,
2102
- selectedIndex: currentIndex,
2103
- onChange: function(index) {
2104
- return changeHandler(index);
2105
- }
2106
- }, /*#__PURE__*/ React__default.createElement(TabList, {
2107
- className: classnames('Tabs', className),
2108
- style: {
2109
- gap: "var(--gap-".concat(gap, ")"),
2110
- height: height ? height : 'auto',
2111
- justifyContent: justifyContent,
2112
- alignItems: alignItems,
2113
- flexDirection: orientation === Orientation.horizontal ? 'row' : 'column'
2114
- }
2115
- }, displayedItems && displayedItems.map(function(item, i) {
2116
- var _padding_, _padding_1, _padding_2, _ref;
2117
- return /*#__PURE__*/ React__default.createElement(Tab, {
2118
- key: item,
2119
- id: item,
2120
- style: {
2121
- cursor: 'pointer',
2122
- width: tabWidth,
2123
- height: tabHeight,
2124
- fontSize: 'var(--text-md)',
2125
- lineHeight: '1.25rem',
2126
- backgroundColor: i === currentIndex ? selectedBackgroundColor !== null && selectedBackgroundColor !== void 0 ? selectedBackgroundColor : backgroundColor : backgroundColor,
2127
- paddingTop: "var(--p-".concat(padding[0], ")"),
2128
- paddingRight: "var(--p-".concat((_padding_ = padding[1]) !== null && _padding_ !== void 0 ? _padding_ : padding[0], ")"),
2129
- paddingBottom: "var(--p-".concat((_padding_1 = padding[2]) !== null && _padding_1 !== void 0 ? _padding_1 : padding[0], ")"),
2130
- paddingLeft: "var(--p-".concat((_ref = (_padding_2 = padding[3]) !== null && _padding_2 !== void 0 ? _padding_2 : padding[1]) !== null && _ref !== void 0 ? _ref : padding[0], ")"),
2131
- display: 'flex',
2132
- flex: 1,
2133
- justifyContent: 'center',
2134
- alignItems: 'center'
2135
- },
2136
- className: classnames('Tabs-item', 'bg-body', 'color-input-text')
2137
- }, icons && icons[i] ? /*#__PURE__*/ React__default.createElement(IconButton, {
2138
- icon: icons[i],
2139
- id: item,
2140
- iconWidth: "20px",
2141
- // width={tabWidth}
2142
- // height={tabHeight}
2143
- color: i === currentIndex ? selectedColor : color
2144
- }) : /*#__PURE__*/ React__default.createElement(Label, {
2145
- value: item,
2146
- fontSize: fontSize,
2147
- color: color
2148
- }));
2149
- })));
2150
- }
2151
- Tabs.padding = Spacing;
2152
- Tabs.gap = Spacing;
2153
- Tabs.margin = Spacing;
2154
- Tabs.orientation = Orientation;
2155
- Tabs.justifyContent = JustifyContent$1;
2156
- Tabs.alignItems = AlignItems$1;
2157
- Tabs.fontSize = FontSizes;
2158
-
2159
- var css_248z$b = ".Dropdown-button {\n font-size: var(--text-sm);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--spacing-ml);\n cursor: pointer;\n vertical-align: middle;\n white-space: nowrap;\n text-decoration: none;\n text-align: center;\n border-radius: 4px;\n appearance: none;\n user-select: none;\n -webkit-user-select: none;\n height: 26px;\n border: 1px solid var(--bg-lv9);\n /* background: var(--color-gray-800); */\n /* color: var(--color-text); */\n}\n\n.Dropdown-button:hover,\n.Dropdown-button[data-open] {\n outline: none;\n cursor: pointer;\n border: 1px solid var(--color-brand-secondary);\n}\n\n.Dropdown-button:hover .Label {\n cursor: pointer;\n}\n\n.Dropdown-button:disabled {\n cursor: default;\n}\n\n.Dropdown-items {\n border: 1px solid var(--bg-lv9);\n background: var(--bg-lv4);\n box-shadow: rgba(0, 0, 0, 0.25) 0px 0px 5px 3px;\n border-radius: 4px;\n width: 150px;\n z-index: 50;\n}\n\n.Dropdown-item {\n font-size: var(--text-sm);\n padding: var(--spacing-md) var(--spacing-xl);\n min-width: 100px;\n color: var(--color-text);\n cursor: pointer;\n /* text-align: center; */\n}\n\n.Dropdown-item[data-selected] {\n color: var(--color-brand-secondary);\n}\n\n.Dropdown-item:hover {\n background-color: var(--bg-lv7);\n}\n\n.Dropdown-item:hover:not([data-selected]) {\n color: var(--color-text);\n}\n";
2160
- styleInject(css_248z$b);
2161
-
2162
2135
  function _define_property$i(obj, key, value) {
2163
2136
  if (key in obj) {
2164
2137
  Object.defineProperty(obj, key, {
@@ -2497,6 +2470,7 @@ function Input(param) {
2497
2470
  id: "".concat(id, "-input"),
2498
2471
  ref: inputRef,
2499
2472
  className: classnames('TextInput', isHighlighted ? 'is-highlighted' : '', className),
2473
+ spellCheck: false,
2500
2474
  style: _object_spread$g({
2501
2475
  fontSize: "var(--text-".concat(fontSize),
2502
2476
  textAlign: textAlign,
@@ -2612,7 +2586,7 @@ var useSlider = function(param) {
2612
2586
  end: 15000,
2613
2587
  interval: 0.1,
2614
2588
  skew: 0.7
2615
- } : _param_mockProperties, _param_isRandomizable = param.isRandomizable, isRandomizable = _param_isRandomizable === void 0 ? false : _param_isRandomizable, _param_isControlGroup = param.isControlGroup, isControlGroup = _param_isControlGroup === void 0 ? false : _param_isControlGroup, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.vertical : _param_orientation, _param_dragOrientation = param.dragOrientation, dragOrientation = _param_dragOrientation === void 0 ? Orientation.vertical : _param_dragOrientation, _param_mockInitialNormalisedValue = param.mockInitialNormalisedValue, mockInitialNormalisedValue = _param_mockInitialNormalisedValue === void 0 ? 0.0 : _param_mockInitialNormalisedValue, onChange = param.onChange; param.sliderElementRef; var _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled;
2589
+ } : _param_mockProperties, _param_isRandomizable = param.isRandomizable, isRandomizable = _param_isRandomizable === void 0 ? false : _param_isRandomizable, _param_isControlGroup = param.isControlGroup, isControlGroup = _param_isControlGroup === void 0 ? false : _param_isControlGroup, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.vertical : _param_orientation, _param_dragOrientation = param.dragOrientation, dragOrientation = _param_dragOrientation === void 0 ? Orientation.vertical : _param_dragOrientation, _param_mockInitialNormalisedValue = param.mockInitialNormalisedValue, mockInitialNormalisedValue = _param_mockInitialNormalisedValue === void 0 ? 0.0 : _param_mockInitialNormalisedValue, _param_updateModSlot = param.updateModSlot, updateModSlot = _param_updateModSlot === void 0 ? true : _param_updateModSlot, onChange = param.onChange; param.sliderElementRef; var _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled;
2616
2590
  // const sliderState: JuceSlider = Juce.getSliderState(id);
2617
2591
  // if isLocalhost is true, the front end app is running outside of JUCE in a browser.
2618
2592
  var isLocalhost = window.location.hostname === 'localhost';
@@ -2633,8 +2607,9 @@ var useSlider = function(param) {
2633
2607
  var sliderState = Juce.getSliderState(id);
2634
2608
  var prevValueRef = useRef(null);
2635
2609
  // const randomValueSetCounter = useRef<number>(null);
2636
- var _useGlobalContext = useGlobalContext(), useRandom = _useGlobalContext.useRandom, highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setDefaultParameter = _useGlobalContext.setDefaultParameter, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview, // setModSlotRowTarget,
2637
- modSlotPreview = _useGlobalContext.globalState.modSlotPreview;
2610
+ var _useGlobalContext = useGlobalContext(), useRandom = _useGlobalContext.useRandom, highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setDefaultParameter = _useGlobalContext.setDefaultParameter, updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, // setModSlotRowTarget,
2611
+ getModSlotPreview = _useGlobalContext.getModSlotPreview;
2612
+ var modSlotPreview = getModSlotPreview();
2638
2613
  // Set the initial state
2639
2614
  //@ts-expect-error
2640
2615
  useEffect(function() {
@@ -2669,7 +2644,7 @@ var useSlider = function(param) {
2669
2644
  normalisedValue: normalisedValue,
2670
2645
  properties: sliderState === null || sliderState === void 0 ? void 0 : sliderState.properties
2671
2646
  });
2672
- if (rowId === modSlotPreview.targetIndex) {
2647
+ if (rowId === (modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.targetIndex)) {
2673
2648
  onChange && onChange(parseFloat(scaledValue.toFixed(2)), rowId);
2674
2649
  } else {
2675
2650
  onChange && onChange(parseFloat(scaledValue.toFixed(2)), sliderId);
@@ -2730,9 +2705,11 @@ var useSlider = function(param) {
2730
2705
  onDrag: function(param) {
2731
2706
  param.event; var delta = param.delta;
2732
2707
  //TODO: Move this out of useSlider
2733
- if (id !== modSlotPreview.rowId) {
2734
- setModSlotRowTargetAsPreview({
2735
- paramId: id
2708
+ // Sets the slider as a mod slot preview
2709
+ if (updateModSlot) {
2710
+ updateModSlotRowTarget({
2711
+ rowId: modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.rowId,
2712
+ value: id
2736
2713
  });
2737
2714
  }
2738
2715
  if (!dragInProgress) {
@@ -2770,6 +2747,13 @@ var useSlider = function(param) {
2770
2747
  var rect = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.getBoundingClientRect();
2771
2748
  var y = (event === null || event === void 0 ? void 0 : event.clientY) - rect.top;
2772
2749
  var x = (event === null || event === void 0 ? void 0 : event.clientX) - rect.left;
2750
+ // Sets the slider as a mod slot preview
2751
+ if (updateModSlot) {
2752
+ updateModSlotRowTarget({
2753
+ rowId: modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.rowId,
2754
+ value: id
2755
+ });
2756
+ }
2773
2757
  hasMoved = dragOrientation === Orientation.vertical ? movement[1] !== 0 : movement[0] !== 0;
2774
2758
  var ignoreMoveStatus = !isControlGroup;
2775
2759
  if (event.buttons === 1) {
@@ -3867,14 +3851,15 @@ function _unsupported_iterable_to_array$a(o, minLen) {
3867
3851
  }
3868
3852
  var useCombobox = function(param) {
3869
3853
  var id = param.id, label = param.label, filter = param.filter; param.onChange; var _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader, isDisabled = param.isDisabled;
3870
- var _Object_values, _properties_choices;
3854
+ var _Object_values_find, _Object_values, _Object_values_map, _Object_values1, _properties_choices;
3871
3855
  var comboBoxState = Juce.getComboBoxState(id);
3872
3856
  var _useState = _sliced_to_array$a(useState(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.properties), 2), properties = _useState[0], setProperties = _useState[1];
3873
3857
  var _useState1 = _sliced_to_array$a(useState(0), 2), index = _useState1[0], setIndex = _useState1[1];
3874
3858
  var prevIndex = useRef(null);
3875
3859
  var nextIndex = useRef(null);
3876
3860
  var prevDragDirection = useRef(null);
3877
- var _useGlobalContext = useGlobalContext(), highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview, _useGlobalContext_globalState = _useGlobalContext.globalState, automatableParamLabels = _useGlobalContext_globalState.automatableParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
3861
+ var _useGlobalContext = useGlobalContext(), highlightedItemChanged = _useGlobalContext.highlightedItemChanged, getModSlotPreview = _useGlobalContext.getModSlotPreview, updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, _useGlobalContext_globalState = _useGlobalContext.globalState, automatableParamLabels = _useGlobalContext_globalState.automatableParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets;
3862
+ var modSlotPreview = getModSlotPreview();
3878
3863
  //TODO: Filter choices for subsequent rows
3879
3864
  // const availableChoices = properties?.choices;
3880
3865
  useEffect(function() {
@@ -3886,8 +3871,8 @@ var useCombobox = function(param) {
3886
3871
  setProperties(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.properties);
3887
3872
  });
3888
3873
  useEffect(function() {
3889
- if (modSlotPreview.slotId === id) {
3890
- setIndex(modSlotPreview.targetIndex);
3874
+ if ((modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.rowId) === id) {
3875
+ setIndex(modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.targetIndex);
3891
3876
  }
3892
3877
  }, [
3893
3878
  modSlotTargets,
@@ -3911,19 +3896,29 @@ var useCombobox = function(param) {
3911
3896
  }, [
3912
3897
  window
3913
3898
  ]);
3914
- var selectedChoices = (_Object_values = Object.values(modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.filter(function(item) {
3899
+ //TODO: Remove mod slot code from this component
3900
+ var selectedIndex = (_Object_values = Object.values(modSlotTargets)) === null || _Object_values === void 0 ? void 0 : (_Object_values_find = _Object_values.find(function(item) {
3901
+ return (item === null || item === void 0 ? void 0 : item.rowId) === id;
3902
+ })) === null || _Object_values_find === void 0 ? void 0 : _Object_values_find.targetIndex;
3903
+ var selectedItem = automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels.find(function(_, i) {
3904
+ return selectedIndex === i;
3905
+ });
3906
+ var allSelectedIndexes = (_Object_values1 = Object.values(modSlotTargets)) === null || _Object_values1 === void 0 ? void 0 : (_Object_values_map = _Object_values1.map(function(item) {
3907
+ return item === null || item === void 0 ? void 0 : item.targetIndex;
3908
+ })) === null || _Object_values_map === void 0 ? void 0 : _Object_values_map.filter(function(item) {
3915
3909
  return item > 0;
3916
3910
  });
3917
- var selectedLabels = automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels.filter(function(item, i) {
3918
- return selectedChoices === null || selectedChoices === void 0 ? void 0 : selectedChoices.includes(i);
3911
+ var allSelectedItems = allSelectedIndexes === null || allSelectedIndexes === void 0 ? void 0 : allSelectedIndexes.map(function(item) {
3912
+ return automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels[item];
3919
3913
  });
3920
3914
  var displayedLabels = automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels.filter(function(item) {
3921
- return !(selectedLabels === null || selectedLabels === void 0 ? void 0 : selectedLabels.includes(item)) || item === automatableParamLabels[index];
3915
+ return !(allSelectedItems === null || allSelectedItems === void 0 ? void 0 : allSelectedItems.includes(item)) || item === automatableParamLabels[index];
3922
3916
  });
3923
3917
  var filteredChoices = filter && (filter === null || filter === void 0 ? void 0 : filter.length) > 1 ? displayedLabels === null || displayedLabels === void 0 ? void 0 : displayedLabels.filter(function(item) {
3924
3918
  var _item_toLowerCase;
3925
3919
  return item === null || item === void 0 ? void 0 : (_item_toLowerCase = item.toLowerCase()) === null || _item_toLowerCase === void 0 ? void 0 : _item_toLowerCase.includes(filter === null || filter === void 0 ? void 0 : filter.toLowerCase());
3926
3920
  }) : displayedLabels;
3921
+ // console.log(filteredChoices, 'FILTERED');
3927
3922
  // const prevIndex = useRef<string | null>(null);
3928
3923
  // const handleChange = (newValue: number) => {
3929
3924
  // if (newValue !== prevIndex.current) {
@@ -3962,8 +3957,10 @@ var useCombobox = function(param) {
3962
3957
  var direction = param.direction, velocity = param.velocity;
3963
3958
  //TODO: Move this out of useSlider
3964
3959
  if (id !== modSlotPreview.rowId) {
3965
- setModSlotRowTargetAsPreview({
3966
- paramId: id
3960
+ updateModSlotRowTarget({
3961
+ rowId: modSlotPreview.rowId,
3962
+ value: id,
3963
+ saveToBackend: false
3967
3964
  });
3968
3965
  }
3969
3966
  var directionY;
@@ -3994,13 +3991,17 @@ var useCombobox = function(param) {
3994
3991
  }
3995
3992
  };
3996
3993
  var onClick = function() {
3997
- setModSlotRowTargetAsPreview({
3998
- paramId: id
3994
+ updateModSlotRowTarget({
3995
+ value: id,
3996
+ rowId: modSlotPreview.rowId,
3997
+ saveToBackend: false
3999
3998
  });
4000
3999
  };
4001
4000
  var onDoubleClick = function() {
4002
- setModSlotRowTargetAsPreview({
4003
- paramId: id
4001
+ updateModSlotRowTarget({
4002
+ value: id,
4003
+ rowId: modSlotPreview.rowId,
4004
+ saveToBackend: false
4004
4005
  });
4005
4006
  };
4006
4007
  return {
@@ -4012,6 +4013,8 @@ var useCombobox = function(param) {
4012
4013
  onMouseEnter: onMouseEnter,
4013
4014
  onClick: onClick,
4014
4015
  onDoubleClick: onDoubleClick,
4016
+ selectedIndex: selectedIndex,
4017
+ selectedItem: selectedItem,
4015
4018
  bindDrag: bindDrag
4016
4019
  };
4017
4020
  };
@@ -5953,7 +5956,7 @@ function ModuleHeader(param) {
5953
5956
  }, "Advanced")))));
5954
5957
  }
5955
5958
 
5956
- var css_248z$2 = ".ModMatrix {\n color: var(--color-text);\n font-size: var(--text-ms);\n}\n\n.ModMatrixCell {\n background: #252429;\n position: relative;\n}\n\n.ModMatrixCell.isDisabled {\n color: var(--color-gray-400);\n opacity: 0.5;\n cursor: default;\n}\n\n/* .isActive .ModMatrixCell {\n background: var(--color-gray-600);\n} */\n\n.ModMatrixToggleCell {\n cursor: pointer;\n}\n\n.ModMatrixComboboxCell {\n background: #252429;\n cursor: pointer;\n}\n\n.ModMatrixComboboxItems {\n position: absolute;\n z-index: 50;\n bottom: -151px;\n left: 0px;\n height: 150px;\n width: 100%;\n background: var(--color-gray-500);\n color: var(--color-text);\n font-family: var(--font-leagueSpartan);\n overflow-y: auto;\n overflow-x: hidden;\n cursor: pointer;\n}\n\n.ModMatrixComboboxItem:hover,\n.ModMatrixComboboxItem:active,\n.ModMatrixComboboxItem[data-selected] {\n background: var(--color-gray-600);\n}\n\n.ModMatrixComboboxItem {\n padding: var(--spacing-md) var(--spacing-lg);\n width: 100%;\n}\n.ModMatrixComboboxButton {\n cursor: pointer;\n}\n\n.ModMatrixInput {\n text-align: center;\n margin-top: 3px;\n}\n";
5959
+ var css_248z$2 = ".ModMatrix {\n color: var(--color-text);\n font-size: var(--text-ms);\n}\n\n.ModMatrixCell {\n background: #252429;\n position: relative;\n}\n\n.ModMatrixCell.isDisabled {\n color: var(--color-gray-400);\n opacity: 0.5;\n cursor: default;\n}\n\n/* .isActive .ModMatrixCell {\n background: var(--color-gray-600);\n} */\n\n.ModMatrixToggleCell {\n cursor: pointer;\n}\n\n.ModMatrixComboboxCell {\n background: #252429;\n cursor: pointer;\n}\n\n.ModMatrixComboboxItems {\n position: absolute;\n z-index: 50;\n left: 0px;\n /* height: 150px; */\n /* width: 100%; */\n color: var(--color-text);\n /* -ms-overflow-style: none; */\n scrollbar-width: thin;\n overflow-y: scroll;\n overflow-x: hidden;\n cursor: pointer;\n}\n\n.ModMatrixComboboxItems::-webkit-scrollbar {\n width: 10px;\n}\n\n.ModMatrixComboboxItem {\n display: flex;\n align-items: center;\n background: var(--bg-lv4);\n padding: 0 var(--spacing-md);\n width: 100%;\n}\n\n.ModMatrixComboboxItem:hover,\n.ModMatrixComboboxItem:active {\n background: var(--bg-lv5);\n}\n\n.ModMatrixComboboxButton {\n cursor: pointer;\n}\n\n.ModMatrixInput {\n text-align: center;\n margin-top: 3px;\n}\n";
5957
5960
  styleInject(css_248z$2);
5958
5961
 
5959
5962
  var targetColors = [
@@ -5966,7 +5969,7 @@ var targetColors = [
5966
5969
  '#4DA1CB',
5967
5970
  '#cb4d62'
5968
5971
  ];
5969
- var ComboboxCellWidth = '217px';
5972
+ var ComboboxCellWidth = '200px';
5970
5973
  var DeleteButtonCellWidth = '50px';
5971
5974
 
5972
5975
  function _array_like_to_array$7(arr, len) {
@@ -6044,50 +6047,58 @@ function _unsupported_iterable_to_array$7(o, minLen) {
6044
6047
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
6045
6048
  }
6046
6049
  function ModMatrixComboboxCell(param) {
6047
- var rowId = param.rowId, key = param.key, color = param.color, style = param.style;
6050
+ var rowId = param.rowId, rowIndex = param.rowIndex, key = param.key, color = param.color, style = param.style;
6048
6051
  var _useState = _sliced_to_array$7(useState(''), 2), filterString = _useState[0], setFilterString = _useState[1];
6049
- var _useGlobalContext = useGlobalContext(), updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview, clearModSlotPreview = _useGlobalContext.clearModSlotPreview, setNewModSlotPreview = _useGlobalContext.setNewModSlotPreview, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotPreview = _useGlobalContext_globalState.modSlotPreview, automatableParamLabels = _useGlobalContext_globalState.automatableParamLabels;
6052
+ var listItemHeight = 25;
6053
+ var maxVisibleItems = 5;
6054
+ var _useGlobalContext = useGlobalContext(), updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, getModSlotPreview = _useGlobalContext.getModSlotPreview, automatableParamLabels = _useGlobalContext.globalState.automatableParamLabels;
6050
6055
  var _useCombobox = useCombobox({
6051
6056
  id: rowId,
6052
6057
  filter: filterString,
6053
6058
  displayValInHeader: false
6054
- }), index = _useCombobox.index, filteredChoices = _useCombobox.filteredChoices;
6055
- var previewValue = modSlotPreview.slotId === rowId ? modSlotPreview.targetIndex : null;
6059
+ }), index = _useCombobox.index, filteredChoices = _useCombobox.filteredChoices, selectedItem = _useCombobox.selectedItem;
6060
+ var previewValue = getModSlotPreview();
6056
6061
  var onChange = function(newValue) {
6057
6062
  // TODO: 'juceIndex' is needed here because the 'value' from the combobox is the string label.
6058
6063
  // Refactor the combobox so that the 'value' is the index number corresponding to the parameter's index in JUCE?
6064
+ setFilterString('');
6059
6065
  var juceIndex = automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels.indexOf(newValue);
6060
6066
  // handleChange(juceIndex);
6061
- if (rowId === modSlotPreview.slotId) {
6067
+ if (previewValue.rowId === rowId) {
6062
6068
  if (juceIndex > 0) {
6063
- setModSlotRowTargetAsPreview({
6064
- paramIndex: juceIndex
6069
+ // setModSlotRowTargetAsPreview({ paramIndex: juceIndex });
6070
+ updateModSlotRowTarget({
6071
+ value: juceIndex,
6072
+ rowId: rowId,
6073
+ saveToBackend: false
6065
6074
  });
6066
- } else {
6067
- clearModSlotPreview();
6068
- setNewModSlotPreview();
6069
6075
  }
6070
6076
  } else {
6071
- updateModSlotRowTarget(juceIndex, rowId);
6077
+ updateModSlotRowTarget({
6078
+ value: juceIndex,
6079
+ rowId: rowId,
6080
+ saveToBackend: true
6081
+ });
6072
6082
  }
6073
6083
  };
6084
+ var numVisibleItems = filteredChoices.length > maxVisibleItems ? maxVisibleItems : filteredChoices.length;
6085
+ var anchorTo = rowIndex > 3 ? 'top' : 'bottom';
6074
6086
  return /*#__PURE__*/ React__default.createElement(Box, {
6075
6087
  key: key,
6076
6088
  className: "ModMatrixCell ModMatrixComboboxCell",
6077
- justifyContent: Box.justifyContent.flexEnd,
6089
+ justifyContent: Box.justifyContent.center,
6078
6090
  flexDirection: Box.flexDirection.column,
6079
6091
  style: _object_spread$6({
6080
6092
  color: color
6081
6093
  }, style),
6082
- padding: [
6083
- Box.padding.medium,
6084
- Box.padding.large
6085
- ],
6086
- alignItems: Box.alignItems.flexStart,
6094
+ alignItems: Box.alignItems.center,
6087
6095
  height: '2.5rem'
6088
6096
  }, /*#__PURE__*/ React__default.createElement(Combobox, {
6089
- value: index || previewValue,
6090
- onChange: onChange
6097
+ value: index || (previewValue === null || previewValue === void 0 ? void 0 : previewValue.targetIndex),
6098
+ onChange: onChange,
6099
+ onClose: function() {
6100
+ setFilterString('');
6101
+ }
6091
6102
  }, /*#__PURE__*/ React__default.createElement(Box, null, /*#__PURE__*/ React__default.createElement(ComboboxInput, {
6092
6103
  displayValue: function(item) {
6093
6104
  return index ? automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels[index] : '';
@@ -6097,7 +6108,8 @@ function ModMatrixComboboxCell(param) {
6097
6108
  var _e_target;
6098
6109
  setFilterString(e === null || e === void 0 ? void 0 : (_e_target = e.target) === null || _e_target === void 0 ? void 0 : _e_target.value);
6099
6110
  },
6100
- autoFocus: true
6111
+ autoFocus: true,
6112
+ spellCheck: false
6101
6113
  }), /*#__PURE__*/ React__default.createElement(ComboboxButton, {
6102
6114
  className: "ModMatrixComboboxButton",
6103
6115
  id: rowId
@@ -6113,13 +6125,37 @@ function ModMatrixComboboxCell(param) {
6113
6125
  }))), /*#__PURE__*/ React__default.createElement(ComboboxOptions, {
6114
6126
  className: "ModMatrixComboboxItems",
6115
6127
  // anchor="bottom"
6128
+ anchor: {
6129
+ to: anchorTo,
6130
+ offset: 'var(--spacing-ms)',
6131
+ gap: 'var(--spacing-ms)'
6132
+ },
6133
+ style: {
6134
+ visibility: numVisibleItems === 0 ? 'hidden' : 'visible',
6135
+ // bottom: `${-(listItemHeight * numVisibleItems)}px`,
6136
+ height: "".concat(listItemHeight * numVisibleItems, "px"),
6137
+ width: ComboboxCellWidth
6138
+ },
6116
6139
  transition: true
6117
6140
  }, filteredChoices === null || filteredChoices === void 0 ? void 0 : filteredChoices.map(function(item) {
6141
+ // console.log(
6142
+ // item,
6143
+ // selectedItem,
6144
+ // selectedItem === item,
6145
+ // 'item, selectedItem',
6146
+ // );
6118
6147
  return /*#__PURE__*/ React__default.createElement(ComboboxOption, {
6148
+ "data-selected": selectedItem === item,
6149
+ style: {
6150
+ height: "".concat(listItemHeight, "px")
6151
+ },
6119
6152
  className: "ModMatrixComboboxItem",
6120
6153
  key: item,
6121
6154
  value: item
6122
- }, /*#__PURE__*/ React__default.createElement(Label, null, item));
6155
+ }, /*#__PURE__*/ React__default.createElement(Label, {
6156
+ color: selectedItem === item ? 'var(--color-brand)' : 'var(--color-text)',
6157
+ fontSize: Label.fontSize.mediumSmall
6158
+ }, item));
6123
6159
  }))));
6124
6160
  }
6125
6161
 
@@ -6154,14 +6190,21 @@ function _object_spread$5(target) {
6154
6190
  // import * as Juce from 'juce-framework-frontend';
6155
6191
  function ModMatrixToggleCell(param) {
6156
6192
  var modifier = param.modifier, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, rowId = param.rowId, color = param.color, style = param.style;
6157
- var // getDefaultParameter,
6158
- saveModSlotPreviewRowTargetToBackend = useGlobalContext().saveModSlotPreviewRowTargetToBackend;
6193
+ var _useGlobalContext = useGlobalContext(), // getDefaultParameter,
6194
+ updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, modSlotTargets = _useGlobalContext.globalState.modSlotTargets;
6159
6195
  // const rowState = Juce.getComboBoxState(rowId);
6160
6196
  var _useDropdown = useDropdown({
6161
6197
  id: modifier,
6162
6198
  rowId: rowId,
6163
6199
  isDisabled: isDisabled,
6164
- onChange: saveModSlotPreviewRowTargetToBackend
6200
+ onChange: function() {
6201
+ var _modSlotTargets_rowId;
6202
+ return updateModSlotRowTarget({
6203
+ value: modSlotTargets === null || modSlotTargets === void 0 ? void 0 : (_modSlotTargets_rowId = modSlotTargets[rowId]) === null || _modSlotTargets_rowId === void 0 ? void 0 : _modSlotTargets_rowId.targetIndex,
6204
+ rowId: rowId,
6205
+ saveToBackend: true
6206
+ });
6207
+ }
6165
6208
  }), index = _useDropdown.index, choices = _useDropdown.choices, handleChange = _useDropdown.handleChange;
6166
6209
  return /*#__PURE__*/ React__default.createElement(Box, {
6167
6210
  className: "ModMatrixCell ModMatrixToggleCell ".concat(isDisabled ? 'isDisabled' : ''),
@@ -6186,6 +6229,7 @@ function ModMatrixToggleCell(param) {
6186
6229
  pointerEvents: 'none'
6187
6230
  }
6188
6231
  }, /*#__PURE__*/ React__default.createElement(Label, {
6232
+ fontSize: Label.fontSize.mediumSmall,
6189
6233
  style: {
6190
6234
  pointerEvents: 'none'
6191
6235
  }
@@ -6341,15 +6385,23 @@ function _unsupported_iterable_to_array$6(o, minLen) {
6341
6385
  function ModMatrixCell(param) {
6342
6386
  var modifier = param.modifier, rowId = param.rowId, isDisabled = param.isDisabled, color = param.color, style = param.style;
6343
6387
  var _SingleBarViz_polarity;
6344
- var _useGlobalContext = useGlobalContext(), setDefaultParameter = _useGlobalContext.setDefaultParameter, saveModSlotPreviewRowTargetToBackend = _useGlobalContext.saveModSlotPreviewRowTargetToBackend;
6388
+ var _useGlobalContext = useGlobalContext(), setDefaultParameter = _useGlobalContext.setDefaultParameter, updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, modSlotTargets = _useGlobalContext.globalState.modSlotTargets;
6345
6389
  var _useState = _sliced_to_array$6(useState(false), 2); _useState[0]; var setIsActive = _useState[1];
6346
6390
  var _useSlider = useSlider({
6347
6391
  id: modifier,
6348
6392
  rowId: rowId,
6393
+ updateModSlot: false,
6349
6394
  displayValInHeader: false,
6350
6395
  orientation: Orientation.horizontal,
6351
6396
  dragOrientation: Orientation.vertical,
6352
- onChange: saveModSlotPreviewRowTargetToBackend,
6397
+ onChange: function() {
6398
+ var _modSlotTargets_rowId;
6399
+ updateModSlotRowTarget({
6400
+ value: modSlotTargets === null || modSlotTargets === void 0 ? void 0 : (_modSlotTargets_rowId = modSlotTargets[rowId]) === null || _modSlotTargets_rowId === void 0 ? void 0 : _modSlotTargets_rowId.targetIndex,
6401
+ rowId: rowId,
6402
+ saveToBackend: true
6403
+ });
6404
+ },
6353
6405
  isDisabled: isDisabled,
6354
6406
  isControlGroup: true
6355
6407
  }), bindBarSliderDrag = _useSlider.bindBarSliderDrag, normalisedValue = _useSlider.normalisedValue, scaledValue = _useSlider.scaledValue, properties = _useSlider.properties, setNormalisedState = _useSlider.setNormalisedState;
@@ -6413,6 +6465,7 @@ function ModMatrixCell(param) {
6413
6465
  // backgroundColor={
6414
6466
  // isActive ? 'var(--color-gray-500)' : 'var(--color-gray-600)'
6415
6467
  // }
6468
+ className: "FOOOOOOOOO",
6416
6469
  sliderColor: color,
6417
6470
  style: _object_spread$3({
6418
6471
  alignSelf: 'flex-end',
@@ -6426,10 +6479,17 @@ function ModMatrixCell(param) {
6426
6479
  }
6427
6480
 
6428
6481
  function ModMatrixRow(param) {
6429
- var rowId = param.rowId, key = param.key;
6482
+ var rowId = param.rowId, rowIndex = param.rowIndex, key = param.key;
6430
6483
  var _modSlotParams_rowId;
6431
- var _useGlobalContext = useGlobalContext(), updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParams = _useGlobalContext_globalState.modSlotParams, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
6432
- var isDisabled = modSlotPreview.slotId === rowId && !modSlotPreview.targetIndex;
6484
+ var _useGlobalContext = useGlobalContext(), deleteModSlotRowTarget = _useGlobalContext.deleteModSlotRowTarget, getModSlotPreview = _useGlobalContext.getModSlotPreview, modSlotParams = _useGlobalContext.globalState.modSlotParams;
6485
+ var previewValue = getModSlotPreview();
6486
+ // console.log(
6487
+ // modSlotParams?.[rowId],
6488
+ // 'modSlotParams?.[rowId]modSlotParams?.[rowId]modSlotParams?.[rowId]',
6489
+ // );
6490
+ // const isDisabled =
6491
+ // modSlotPreview.slotId === rowId && !modSlotPreview.targetIndex;
6492
+ var isDisabled = (previewValue === null || previewValue === void 0 ? void 0 : previewValue.rowId) === rowId && !(previewValue === null || previewValue === void 0 ? void 0 : previewValue.targetIndex);
6433
6493
  return /*#__PURE__*/ React__default.createElement(Box, {
6434
6494
  className: "ModMatrixBodyRow",
6435
6495
  gap: Box.gap.medium,
@@ -6445,6 +6505,7 @@ function ModMatrixRow(param) {
6445
6505
  }, /*#__PURE__*/ React__default.createElement(ModMatrixComboboxCell, {
6446
6506
  // target={modSlotTargets[rowId]}
6447
6507
  rowId: rowId,
6508
+ rowIndex: rowIndex,
6448
6509
  color: targetColors[0],
6449
6510
  style: {
6450
6511
  width: ComboboxCellWidth
@@ -6480,7 +6541,7 @@ function ModMatrixRow(param) {
6480
6541
  width: "20px",
6481
6542
  disabled: isDisabled,
6482
6543
  onClick: function() {
6483
- return updateModSlotRowTarget(0, rowId);
6544
+ return deleteModSlotRowTarget(rowId);
6484
6545
  }
6485
6546
  })));
6486
6547
  }
@@ -6698,52 +6759,17 @@ function ModMatrix(param) {
6698
6759
  var getAllModSlotsFunc = Juce.getNativeFunction('getAllModSlots');
6699
6760
  var getModSlotParamsFunc = Juce.getNativeFunction('getModSlotParams');
6700
6761
  var _useState = _sliced_to_array$5(useState([]), 2), displayedModSlots = _useState[0], setDisplayedModSlots = _useState[1];
6701
- var _useGlobalContext = useGlobalContext(), automatableParamsListReceived = _useGlobalContext.automatableParamsListReceived, automatableParamLabelsReceived = _useGlobalContext.automatableParamLabelsReceived, modSlotsReceived = _useGlobalContext.modSlotsReceived, modSlotRowTargetsReceived = _useGlobalContext.modSlotRowTargetsReceived, setNewModSlotPreview = _useGlobalContext.setNewModSlotPreview, modSlotParamsListReceived = _useGlobalContext.modSlotParamsListReceived, modSlotParamLabelsReceived = _useGlobalContext.modSlotParamLabelsReceived, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParamLabels = _useGlobalContext_globalState.modSlotParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotIds = _useGlobalContext_globalState.modSlotIds, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
6762
+ // const [previewSlot, setPreviewSlot] = useState<Array<string>>([]);
6763
+ // const [previewSlot, setPreviewSlot] = useState<string>();
6764
+ var _useGlobalContext = useGlobalContext(), automatableParamsListReceived = _useGlobalContext.automatableParamsListReceived, automatableParamLabelsReceived = _useGlobalContext.automatableParamLabelsReceived, modSlotsReceived = _useGlobalContext.modSlotsReceived, modSlotRowTargetsReceived = _useGlobalContext.modSlotRowTargetsReceived, modSlotParamsListReceived = _useGlobalContext.modSlotParamsListReceived, modSlotParamLabelsReceived = _useGlobalContext.modSlotParamLabelsReceived, getModSlotPreview = _useGlobalContext.getModSlotPreview, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParamLabels = _useGlobalContext_globalState.modSlotParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotIds = _useGlobalContext_globalState.modSlotIds;
6702
6765
  // Empty state preview row
6703
- useEffect(function() {
6704
- var unassignedModSlots = modSlotIds === null || modSlotIds === void 0 ? void 0 : modSlotIds.filter(function(item) {
6705
- return modSlotTargets[item] <= 0;
6706
- });
6707
- if ((unassignedModSlots === null || unassignedModSlots === void 0 ? void 0 : unassignedModSlots.length) > 0 && modSlotPreview.slotId.length === 0) {
6708
- setNewModSlotPreview();
6709
- }
6710
- }, [
6711
- window,
6712
- modSlotIds,
6713
- modSlotPreview
6714
- ]);
6715
6766
  // console.log(
6716
6767
  // modSlotTargets,
6717
6768
  // 'modSlotTargetsmodSlotTargetsmodSlotTargetsmodSlotTargets',
6718
6769
  // );
6719
- useEffect(function() {
6720
- var _Object_keys;
6721
- var displayedSlots = (_Object_keys = Object.keys(modSlotTargets)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.reduce(function(acc, item) {
6722
- if ((modSlotTargets === null || modSlotTargets === void 0 ? void 0 : modSlotTargets[item]) > 0) {
6723
- acc === null || acc === void 0 ? void 0 : acc.push(item);
6724
- }
6725
- return acc;
6726
- }, []);
6727
- // .sort();
6728
- var unassignedModSlots = modSlotIds === null || modSlotIds === void 0 ? void 0 : modSlotIds.filter(function(item) {
6729
- return modSlotTargets[item] <= 0;
6730
- });
6731
- if (unassignedModSlots.length > 0 && modSlotPreview.slotId) {
6732
- setDisplayedModSlots(_to_consumable_array(displayedSlots).concat([
6733
- modSlotPreview.slotId
6734
- ]));
6735
- } else {
6736
- setDisplayedModSlots(displayedSlots);
6737
- }
6738
- }, [
6739
- window,
6740
- modSlotTargets,
6741
- modSlotIds,
6742
- modSlotPreview
6743
- ]);
6744
6770
  var getAPVTSParams = function() {
6745
6771
  return _async_to_generator$1(function() {
6746
- var automatableParamsList, modSlotsData, modSlotParams, e;
6772
+ var automatableParamsList, modSlotsData, modSlotParams, modSlotPreview, hasUnsavedPreview, e;
6747
6773
  return _ts_generator$1(this, function(_state) {
6748
6774
  switch(_state.label){
6749
6775
  case 0:
@@ -6771,11 +6797,15 @@ function ModMatrix(param) {
6771
6797
  ];
6772
6798
  case 3:
6773
6799
  modSlotParams = _state.sent();
6800
+ modSlotPreview = getModSlotPreview();
6774
6801
  // const ap = await getAllParametersFunc();
6775
6802
  automatableParamsListReceived(automatableParamsList === null || automatableParamsList === void 0 ? void 0 : automatableParamsList[0]);
6776
6803
  automatableParamLabelsReceived(automatableParamsList === null || automatableParamsList === void 0 ? void 0 : automatableParamsList[1]);
6777
6804
  modSlotsReceived(modSlotsData || []);
6778
- modSlotRowTargetsReceived(modSlotsData || []);
6805
+ hasUnsavedPreview = (modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.targetIndex) > 0 && !(modSlotPreview === null || modSlotPreview === void 0 ? void 0 : modSlotPreview.isSaved);
6806
+ if (!hasUnsavedPreview) {
6807
+ modSlotRowTargetsReceived(modSlotsData || []);
6808
+ }
6779
6809
  modSlotParamsListReceived(modSlotParams === null || modSlotParams === void 0 ? void 0 : modSlotParams[0]);
6780
6810
  modSlotParamLabelsReceived(modSlotParams === null || modSlotParams === void 0 ? void 0 : modSlotParams[1]);
6781
6811
  return [
@@ -6798,10 +6828,34 @@ function ModMatrix(param) {
6798
6828
  })();
6799
6829
  };
6800
6830
  useEffect(function() {
6831
+ console.log('dssdffsd');
6801
6832
  getAPVTSParams();
6802
6833
  }, [
6803
6834
  window
6804
6835
  ]);
6836
+ useEffect(function() {
6837
+ var _Object_keys;
6838
+ var savedSlots = (_Object_keys = Object.keys(modSlotTargets)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.reduce(function(acc, item) {
6839
+ if (modSlotTargets === null || modSlotTargets === void 0 ? void 0 : modSlotTargets[item].isSaved) {
6840
+ acc === null || acc === void 0 ? void 0 : acc.push(item);
6841
+ }
6842
+ return acc;
6843
+ }, []);
6844
+ // .sort();
6845
+ var previewSlot = getModSlotPreview();
6846
+ var displayPreviewSlot = previewSlot !== undefined;
6847
+ if (displayPreviewSlot) {
6848
+ setDisplayedModSlots(_to_consumable_array(savedSlots).concat([
6849
+ previewSlot.rowId
6850
+ ]));
6851
+ } else {
6852
+ setDisplayedModSlots(savedSlots);
6853
+ }
6854
+ console.log(modSlotTargets, 'modSlotTargets');
6855
+ }, [
6856
+ modSlotTargets,
6857
+ modSlotIds
6858
+ ]);
6805
6859
  var headers = [
6806
6860
  'Target'
6807
6861
  ].concat(_to_consumable_array(modSlotParamLabels), [
@@ -6810,7 +6864,6 @@ function ModMatrix(param) {
6810
6864
  return /*#__PURE__*/ React__default.createElement(Box, {
6811
6865
  gap: Box.gap.medium,
6812
6866
  padding: [
6813
- Box.padding.medium,
6814
6867
  Box.padding.large
6815
6868
  ],
6816
6869
  className: "ModMatrix ".concat(className ? className : ''),
@@ -6828,11 +6881,7 @@ function ModMatrix(param) {
6828
6881
  flex: i === 0 ? "0 0 ".concat(ComboboxCellWidth) : i === headers.length - 1 ? "0 0 ".concat(DeleteButtonCellWidth) : '2'
6829
6882
  },
6830
6883
  key: item,
6831
- className: "ModMatrixHeaderCell",
6832
- padding: [
6833
- Box.padding.medium,
6834
- Box.padding.large
6835
- ]
6884
+ className: "ModMatrixHeaderCell"
6836
6885
  }, /*#__PURE__*/ React__default.createElement(Label, {
6837
6886
  fontSize: Label.fontSize.small
6838
6887
  }, item));
@@ -6843,7 +6892,8 @@ function ModMatrix(param) {
6843
6892
  }, (displayedModSlots === null || displayedModSlots === void 0 ? void 0 : displayedModSlots.length) ? displayedModSlots === null || displayedModSlots === void 0 ? void 0 : displayedModSlots.map(function(item, i) {
6844
6893
  return /*#__PURE__*/ React__default.createElement(ModMatrixRow, {
6845
6894
  rowId: item,
6846
- key: "".concat(item + i)
6895
+ key: "".concat(item + i),
6896
+ rowIndex: i
6847
6897
  });
6848
6898
  }) : null));
6849
6899
  }
@@ -8211,7 +8261,7 @@ var SettingsTab = function() {
8211
8261
  };
8212
8262
  function ModuleFooter(param) {
8213
8263
  var className = param.className, style = param.style;
8214
- var _useState = _sliced_to_array(useState(0), 2), selectedTab = _useState[0], setSelectedTab = _useState[1];
8264
+ var _useState = _sliced_to_array(useState(null), 2), selectedTab = _useState[0], setSelectedTab = _useState[1];
8215
8265
  var setSelectedFooterTabFunc = Juce.getNativeFunction('setSelectedFooterTab');
8216
8266
  var getSelectedFooterTabFunc = Juce.getNativeFunction('getSelectedFooterTab');
8217
8267
  useEffect(function() {
@@ -8258,22 +8308,8 @@ function ModuleFooter(param) {
8258
8308
  window
8259
8309
  ]);
8260
8310
  var handleTabChange = function(newSelection) {
8261
- var updateBackend = function() {
8262
- return _async_to_generator(function() {
8263
- return _ts_generator(this, function(_state) {
8264
- try {
8265
- setSelectedFooterTabFunc(newSelection);
8266
- setSelectedTab(newSelection);
8267
- } catch (e) {
8268
- console.log(e);
8269
- }
8270
- return [
8271
- 2
8272
- ];
8273
- });
8274
- })();
8275
- };
8276
- updateBackend();
8311
+ setSelectedTab(newSelection);
8312
+ setSelectedFooterTabFunc(newSelection);
8277
8313
  };
8278
8314
  return /*#__PURE__*/ React__default.createElement(Box, {
8279
8315
  gap: Box.gap.small,
@@ -8307,6 +8343,7 @@ function ModuleFooter(param) {
8307
8343
  'Sequencer',
8308
8344
  'Settings'
8309
8345
  ],
8346
+ initialSelectedIndex: selectedTab,
8310
8347
  onChange: handleTabChange,
8311
8348
  padding: [
8312
8349
  Tabs.padding.medium,