@0xsquid/ui 0.15.0 → 0.15.2

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.
package/dist/cjs/index.js CHANGED
@@ -2551,24 +2551,6 @@ const twMerge = /*#__PURE__*/createTailwindMerge(getDefaultConfig);
2551
2551
  const cn = (...inputs) => {
2552
2552
  return twMerge(clsx(inputs));
2553
2553
  };
2554
- function debounce(func, delay) {
2555
- let timeoutId;
2556
- const debounced = function (...args) {
2557
- // @ts-expect-error - 'this' implicitly has type 'any' because it does not have a type annotation.
2558
- const context = this;
2559
- const later = () => {
2560
- timeoutId = null;
2561
- func.apply(context, args);
2562
- };
2563
- clearTimeout(timeoutId);
2564
- timeoutId = setTimeout(later, delay);
2565
- };
2566
- debounced.cancel = () => {
2567
- clearTimeout(timeoutId);
2568
- timeoutId = null;
2569
- };
2570
- return debounced;
2571
- }
2572
2554
  const formatTime = (elapsedTime) => {
2573
2555
  const totalSeconds = Math.floor(elapsedTime / 1000);
2574
2556
  const minutes = Math.floor(totalSeconds / 60);
@@ -5818,43 +5800,591 @@ function toFixedPoint(str, e, z) {
5818
5800
 
5819
5801
  var BigNumber = clone();
5820
5802
 
5803
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5804
+
5805
+ function getDefaultExportFromCjs (x) {
5806
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5807
+ }
5808
+
5809
+ /**
5810
+ * Checks if `value` is the
5811
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
5812
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
5813
+ *
5814
+ * @static
5815
+ * @memberOf _
5816
+ * @since 0.1.0
5817
+ * @category Lang
5818
+ * @param {*} value The value to check.
5819
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
5820
+ * @example
5821
+ *
5822
+ * _.isObject({});
5823
+ * // => true
5824
+ *
5825
+ * _.isObject([1, 2, 3]);
5826
+ * // => true
5827
+ *
5828
+ * _.isObject(_.noop);
5829
+ * // => true
5830
+ *
5831
+ * _.isObject(null);
5832
+ * // => false
5833
+ */
5834
+
5835
+ function isObject$2(value) {
5836
+ var type = typeof value;
5837
+ return value != null && (type == 'object' || type == 'function');
5838
+ }
5839
+
5840
+ var isObject_1 = isObject$2;
5841
+
5842
+ /** Detect free variable `global` from Node.js. */
5843
+
5844
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
5845
+
5846
+ var _freeGlobal = freeGlobal$1;
5847
+
5848
+ var freeGlobal = _freeGlobal;
5849
+
5850
+ /** Detect free variable `self`. */
5851
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
5852
+
5853
+ /** Used as a reference to the global object. */
5854
+ var root$2 = freeGlobal || freeSelf || Function('return this')();
5855
+
5856
+ var _root = root$2;
5857
+
5858
+ var root$1 = _root;
5859
+
5860
+ /**
5861
+ * Gets the timestamp of the number of milliseconds that have elapsed since
5862
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
5863
+ *
5864
+ * @static
5865
+ * @memberOf _
5866
+ * @since 2.4.0
5867
+ * @category Date
5868
+ * @returns {number} Returns the timestamp.
5869
+ * @example
5870
+ *
5871
+ * _.defer(function(stamp) {
5872
+ * console.log(_.now() - stamp);
5873
+ * }, _.now());
5874
+ * // => Logs the number of milliseconds it took for the deferred invocation.
5875
+ */
5876
+ var now$1 = function() {
5877
+ return root$1.Date.now();
5878
+ };
5879
+
5880
+ var now_1 = now$1;
5881
+
5882
+ /** Used to match a single whitespace character. */
5883
+
5884
+ var reWhitespace = /\s/;
5885
+
5886
+ /**
5887
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
5888
+ * character of `string`.
5889
+ *
5890
+ * @private
5891
+ * @param {string} string The string to inspect.
5892
+ * @returns {number} Returns the index of the last non-whitespace character.
5893
+ */
5894
+ function trimmedEndIndex$1(string) {
5895
+ var index = string.length;
5896
+
5897
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
5898
+ return index;
5899
+ }
5900
+
5901
+ var _trimmedEndIndex = trimmedEndIndex$1;
5902
+
5903
+ var trimmedEndIndex = _trimmedEndIndex;
5904
+
5905
+ /** Used to match leading whitespace. */
5906
+ var reTrimStart = /^\s+/;
5907
+
5908
+ /**
5909
+ * The base implementation of `_.trim`.
5910
+ *
5911
+ * @private
5912
+ * @param {string} string The string to trim.
5913
+ * @returns {string} Returns the trimmed string.
5914
+ */
5915
+ function baseTrim$1(string) {
5916
+ return string
5917
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
5918
+ : string;
5919
+ }
5920
+
5921
+ var _baseTrim = baseTrim$1;
5922
+
5923
+ var root = _root;
5924
+
5925
+ /** Built-in value references. */
5926
+ var Symbol$3 = root.Symbol;
5927
+
5928
+ var _Symbol = Symbol$3;
5929
+
5930
+ var Symbol$2 = _Symbol;
5931
+
5932
+ /** Used for built-in method references. */
5933
+ var objectProto$1 = Object.prototype;
5934
+
5935
+ /** Used to check objects for own properties. */
5936
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
5937
+
5938
+ /**
5939
+ * Used to resolve the
5940
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
5941
+ * of values.
5942
+ */
5943
+ var nativeObjectToString$1 = objectProto$1.toString;
5944
+
5945
+ /** Built-in value references. */
5946
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
5947
+
5948
+ /**
5949
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
5950
+ *
5951
+ * @private
5952
+ * @param {*} value The value to query.
5953
+ * @returns {string} Returns the raw `toStringTag`.
5954
+ */
5955
+ function getRawTag$1(value) {
5956
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1),
5957
+ tag = value[symToStringTag$1];
5958
+
5959
+ try {
5960
+ value[symToStringTag$1] = undefined;
5961
+ var unmasked = true;
5962
+ } catch (e) {}
5963
+
5964
+ var result = nativeObjectToString$1.call(value);
5965
+ if (unmasked) {
5966
+ if (isOwn) {
5967
+ value[symToStringTag$1] = tag;
5968
+ } else {
5969
+ delete value[symToStringTag$1];
5970
+ }
5971
+ }
5972
+ return result;
5973
+ }
5974
+
5975
+ var _getRawTag = getRawTag$1;
5976
+
5977
+ /** Used for built-in method references. */
5978
+
5979
+ var objectProto = Object.prototype;
5980
+
5981
+ /**
5982
+ * Used to resolve the
5983
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
5984
+ * of values.
5985
+ */
5986
+ var nativeObjectToString = objectProto.toString;
5987
+
5988
+ /**
5989
+ * Converts `value` to a string using `Object.prototype.toString`.
5990
+ *
5991
+ * @private
5992
+ * @param {*} value The value to convert.
5993
+ * @returns {string} Returns the converted string.
5994
+ */
5995
+ function objectToString$1(value) {
5996
+ return nativeObjectToString.call(value);
5997
+ }
5998
+
5999
+ var _objectToString = objectToString$1;
6000
+
6001
+ var Symbol$1 = _Symbol,
6002
+ getRawTag = _getRawTag,
6003
+ objectToString = _objectToString;
6004
+
6005
+ /** `Object#toString` result references. */
6006
+ var nullTag = '[object Null]',
6007
+ undefinedTag = '[object Undefined]';
6008
+
6009
+ /** Built-in value references. */
6010
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
6011
+
6012
+ /**
6013
+ * The base implementation of `getTag` without fallbacks for buggy environments.
6014
+ *
6015
+ * @private
6016
+ * @param {*} value The value to query.
6017
+ * @returns {string} Returns the `toStringTag`.
6018
+ */
6019
+ function baseGetTag$1(value) {
6020
+ if (value == null) {
6021
+ return value === undefined ? undefinedTag : nullTag;
6022
+ }
6023
+ return (symToStringTag && symToStringTag in Object(value))
6024
+ ? getRawTag(value)
6025
+ : objectToString(value);
6026
+ }
6027
+
6028
+ var _baseGetTag = baseGetTag$1;
6029
+
6030
+ /**
6031
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
6032
+ * and has a `typeof` result of "object".
6033
+ *
6034
+ * @static
6035
+ * @memberOf _
6036
+ * @since 4.0.0
6037
+ * @category Lang
6038
+ * @param {*} value The value to check.
6039
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
6040
+ * @example
6041
+ *
6042
+ * _.isObjectLike({});
6043
+ * // => true
6044
+ *
6045
+ * _.isObjectLike([1, 2, 3]);
6046
+ * // => true
6047
+ *
6048
+ * _.isObjectLike(_.noop);
6049
+ * // => false
6050
+ *
6051
+ * _.isObjectLike(null);
6052
+ * // => false
6053
+ */
6054
+
6055
+ function isObjectLike$1(value) {
6056
+ return value != null && typeof value == 'object';
6057
+ }
6058
+
6059
+ var isObjectLike_1 = isObjectLike$1;
6060
+
6061
+ var baseGetTag = _baseGetTag,
6062
+ isObjectLike = isObjectLike_1;
6063
+
6064
+ /** `Object#toString` result references. */
6065
+ var symbolTag = '[object Symbol]';
6066
+
6067
+ /**
6068
+ * Checks if `value` is classified as a `Symbol` primitive or object.
6069
+ *
6070
+ * @static
6071
+ * @memberOf _
6072
+ * @since 4.0.0
6073
+ * @category Lang
6074
+ * @param {*} value The value to check.
6075
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
6076
+ * @example
6077
+ *
6078
+ * _.isSymbol(Symbol.iterator);
6079
+ * // => true
6080
+ *
6081
+ * _.isSymbol('abc');
6082
+ * // => false
6083
+ */
6084
+ function isSymbol$1(value) {
6085
+ return typeof value == 'symbol' ||
6086
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
6087
+ }
6088
+
6089
+ var isSymbol_1 = isSymbol$1;
6090
+
6091
+ var baseTrim = _baseTrim,
6092
+ isObject$1 = isObject_1,
6093
+ isSymbol = isSymbol_1;
6094
+
6095
+ /** Used as references for various `Number` constants. */
6096
+ var NAN = 0 / 0;
6097
+
6098
+ /** Used to detect bad signed hexadecimal string values. */
6099
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
6100
+
6101
+ /** Used to detect binary string values. */
6102
+ var reIsBinary = /^0b[01]+$/i;
6103
+
6104
+ /** Used to detect octal string values. */
6105
+ var reIsOctal = /^0o[0-7]+$/i;
6106
+
6107
+ /** Built-in method references without a dependency on `root`. */
6108
+ var freeParseInt = parseInt;
6109
+
6110
+ /**
6111
+ * Converts `value` to a number.
6112
+ *
6113
+ * @static
6114
+ * @memberOf _
6115
+ * @since 4.0.0
6116
+ * @category Lang
6117
+ * @param {*} value The value to process.
6118
+ * @returns {number} Returns the number.
6119
+ * @example
6120
+ *
6121
+ * _.toNumber(3.2);
6122
+ * // => 3.2
6123
+ *
6124
+ * _.toNumber(Number.MIN_VALUE);
6125
+ * // => 5e-324
6126
+ *
6127
+ * _.toNumber(Infinity);
6128
+ * // => Infinity
6129
+ *
6130
+ * _.toNumber('3.2');
6131
+ * // => 3.2
6132
+ */
6133
+ function toNumber$1(value) {
6134
+ if (typeof value == 'number') {
6135
+ return value;
6136
+ }
6137
+ if (isSymbol(value)) {
6138
+ return NAN;
6139
+ }
6140
+ if (isObject$1(value)) {
6141
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
6142
+ value = isObject$1(other) ? (other + '') : other;
6143
+ }
6144
+ if (typeof value != 'string') {
6145
+ return value === 0 ? value : +value;
6146
+ }
6147
+ value = baseTrim(value);
6148
+ var isBinary = reIsBinary.test(value);
6149
+ return (isBinary || reIsOctal.test(value))
6150
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
6151
+ : (reIsBadHex.test(value) ? NAN : +value);
6152
+ }
6153
+
6154
+ var toNumber_1 = toNumber$1;
6155
+
6156
+ var isObject = isObject_1,
6157
+ now = now_1,
6158
+ toNumber = toNumber_1;
6159
+
6160
+ /** Error message constants. */
6161
+ var FUNC_ERROR_TEXT = 'Expected a function';
6162
+
6163
+ /* Built-in method references for those with the same name as other `lodash` methods. */
6164
+ var nativeMax = Math.max,
6165
+ nativeMin = Math.min;
6166
+
6167
+ /**
6168
+ * Creates a debounced function that delays invoking `func` until after `wait`
6169
+ * milliseconds have elapsed since the last time the debounced function was
6170
+ * invoked. The debounced function comes with a `cancel` method to cancel
6171
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
6172
+ * Provide `options` to indicate whether `func` should be invoked on the
6173
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
6174
+ * with the last arguments provided to the debounced function. Subsequent
6175
+ * calls to the debounced function return the result of the last `func`
6176
+ * invocation.
6177
+ *
6178
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
6179
+ * invoked on the trailing edge of the timeout only if the debounced function
6180
+ * is invoked more than once during the `wait` timeout.
6181
+ *
6182
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
6183
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
6184
+ *
6185
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
6186
+ * for details over the differences between `_.debounce` and `_.throttle`.
6187
+ *
6188
+ * @static
6189
+ * @memberOf _
6190
+ * @since 0.1.0
6191
+ * @category Function
6192
+ * @param {Function} func The function to debounce.
6193
+ * @param {number} [wait=0] The number of milliseconds to delay.
6194
+ * @param {Object} [options={}] The options object.
6195
+ * @param {boolean} [options.leading=false]
6196
+ * Specify invoking on the leading edge of the timeout.
6197
+ * @param {number} [options.maxWait]
6198
+ * The maximum time `func` is allowed to be delayed before it's invoked.
6199
+ * @param {boolean} [options.trailing=true]
6200
+ * Specify invoking on the trailing edge of the timeout.
6201
+ * @returns {Function} Returns the new debounced function.
6202
+ * @example
6203
+ *
6204
+ * // Avoid costly calculations while the window size is in flux.
6205
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
6206
+ *
6207
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
6208
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
6209
+ * 'leading': true,
6210
+ * 'trailing': false
6211
+ * }));
6212
+ *
6213
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
6214
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
6215
+ * var source = new EventSource('/stream');
6216
+ * jQuery(source).on('message', debounced);
6217
+ *
6218
+ * // Cancel the trailing debounced invocation.
6219
+ * jQuery(window).on('popstate', debounced.cancel);
6220
+ */
6221
+ function debounce(func, wait, options) {
6222
+ var lastArgs,
6223
+ lastThis,
6224
+ maxWait,
6225
+ result,
6226
+ timerId,
6227
+ lastCallTime,
6228
+ lastInvokeTime = 0,
6229
+ leading = false,
6230
+ maxing = false,
6231
+ trailing = true;
6232
+
6233
+ if (typeof func != 'function') {
6234
+ throw new TypeError(FUNC_ERROR_TEXT);
6235
+ }
6236
+ wait = toNumber(wait) || 0;
6237
+ if (isObject(options)) {
6238
+ leading = !!options.leading;
6239
+ maxing = 'maxWait' in options;
6240
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
6241
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
6242
+ }
6243
+
6244
+ function invokeFunc(time) {
6245
+ var args = lastArgs,
6246
+ thisArg = lastThis;
6247
+
6248
+ lastArgs = lastThis = undefined;
6249
+ lastInvokeTime = time;
6250
+ result = func.apply(thisArg, args);
6251
+ return result;
6252
+ }
6253
+
6254
+ function leadingEdge(time) {
6255
+ // Reset any `maxWait` timer.
6256
+ lastInvokeTime = time;
6257
+ // Start the timer for the trailing edge.
6258
+ timerId = setTimeout(timerExpired, wait);
6259
+ // Invoke the leading edge.
6260
+ return leading ? invokeFunc(time) : result;
6261
+ }
6262
+
6263
+ function remainingWait(time) {
6264
+ var timeSinceLastCall = time - lastCallTime,
6265
+ timeSinceLastInvoke = time - lastInvokeTime,
6266
+ timeWaiting = wait - timeSinceLastCall;
6267
+
6268
+ return maxing
6269
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
6270
+ : timeWaiting;
6271
+ }
6272
+
6273
+ function shouldInvoke(time) {
6274
+ var timeSinceLastCall = time - lastCallTime,
6275
+ timeSinceLastInvoke = time - lastInvokeTime;
6276
+
6277
+ // Either this is the first call, activity has stopped and we're at the
6278
+ // trailing edge, the system time has gone backwards and we're treating
6279
+ // it as the trailing edge, or we've hit the `maxWait` limit.
6280
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
6281
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
6282
+ }
6283
+
6284
+ function timerExpired() {
6285
+ var time = now();
6286
+ if (shouldInvoke(time)) {
6287
+ return trailingEdge(time);
6288
+ }
6289
+ // Restart the timer.
6290
+ timerId = setTimeout(timerExpired, remainingWait(time));
6291
+ }
6292
+
6293
+ function trailingEdge(time) {
6294
+ timerId = undefined;
6295
+
6296
+ // Only invoke if we have `lastArgs` which means `func` has been
6297
+ // debounced at least once.
6298
+ if (trailing && lastArgs) {
6299
+ return invokeFunc(time);
6300
+ }
6301
+ lastArgs = lastThis = undefined;
6302
+ return result;
6303
+ }
6304
+
6305
+ function cancel() {
6306
+ if (timerId !== undefined) {
6307
+ clearTimeout(timerId);
6308
+ }
6309
+ lastInvokeTime = 0;
6310
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
6311
+ }
6312
+
6313
+ function flush() {
6314
+ return timerId === undefined ? result : trailingEdge(now());
6315
+ }
6316
+
6317
+ function debounced() {
6318
+ var time = now(),
6319
+ isInvoking = shouldInvoke(time);
6320
+
6321
+ lastArgs = arguments;
6322
+ lastThis = this;
6323
+ lastCallTime = time;
6324
+
6325
+ if (isInvoking) {
6326
+ if (timerId === undefined) {
6327
+ return leadingEdge(lastCallTime);
6328
+ }
6329
+ if (maxing) {
6330
+ // Handle invocations in a tight loop.
6331
+ clearTimeout(timerId);
6332
+ timerId = setTimeout(timerExpired, wait);
6333
+ return invokeFunc(lastCallTime);
6334
+ }
6335
+ }
6336
+ if (timerId === undefined) {
6337
+ timerId = setTimeout(timerExpired, wait);
6338
+ }
6339
+ return result;
6340
+ }
6341
+ debounced.cancel = cancel;
6342
+ debounced.flush = flush;
6343
+ return debounced;
6344
+ }
6345
+
6346
+ var debounce_1 = debounce;
6347
+
6348
+ var debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(debounce_1);
6349
+
5821
6350
  /**
5822
6351
  * Convert token amount to USD
5823
6352
  * @param {string|number} tokenAmount - The amount of tokens
5824
6353
  * @param {string|number} tokenPrice - The price of one token in USD
5825
6354
  * @returns {BigNumber} - The equivalent amount in USD
5826
6355
  */
5827
- function convertTokenAmountToUSD(tokenAmount, tokenPrice) {
6356
+ function convertTokenAmountToUSD(tokenAmount, tokenPrice, maxDecimals = 4) {
5828
6357
  if (!tokenAmount || !tokenPrice)
5829
- return '0';
6358
+ return '';
5830
6359
  const amount = new BigNumber(tokenAmount);
5831
6360
  const price = new BigNumber(tokenPrice);
5832
- return amount.multipliedBy(price).decimalPlaces(4).toString();
6361
+ return amount.multipliedBy(price).decimalPlaces(maxDecimals).toString();
5833
6362
  }
5834
6363
  /**
5835
6364
  * Convert USD to token amount
5836
6365
  * @param {string|number} usdAmount - The amount in USD
5837
6366
  * @param {string|number} tokenPrice - The price of one token in USD
6367
+ * @param {number} maxDecimals - The maximum number of decimals
5838
6368
  * @returns {BigNumber} - The equivalent amount of tokens
5839
6369
  */
5840
- function convertUSDToTokenAmount(usdAmount, tokenPrice) {
5841
- if (!usdAmount || !tokenPrice)
6370
+ function convertUSDToTokenAmount(usdAmount, tokenPrice, maxDecimals) {
6371
+ if (!usdAmount || !tokenPrice || !maxDecimals)
5842
6372
  return '0';
5843
6373
  const amount = new BigNumber(usdAmount);
5844
6374
  const price = new BigNumber(tokenPrice);
5845
- return amount.dividedBy(price).toString();
6375
+ return amount.dividedBy(price).decimalPlaces(maxDecimals).toString();
5846
6376
  }
5847
6377
  const INTL_NUMBER_FORMATTER = new Intl.NumberFormat('en-US', {
5848
6378
  minimumFractionDigits: 0,
5849
6379
  maximumFractionDigits: 5,
5850
6380
  });
5851
6381
  /**
5852
- * Formats a number to USD
6382
+ * Formats a number to the en-US number format
5853
6383
  *
5854
- * @param amount - The amount to format
5855
- * @returns The formatted currency string
6384
+ * @param amount - The number to format
6385
+ * @returns The formatted string
5856
6386
  */
5857
- function formatUSD(amount) {
6387
+ function formatAmount(amount) {
5858
6388
  return INTL_NUMBER_FORMATTER.format(amount);
5859
6389
  }
5860
6390
  function trimExtraDecimals(value, maxDecimals) {
@@ -5862,7 +6392,7 @@ function trimExtraDecimals(value, maxDecimals) {
5862
6392
  const split = value.split('.');
5863
6393
  if (split.length > 1) {
5864
6394
  const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
5865
- if (decimals.length > maxDecimals) {
6395
+ if (maxDecimals && decimals.length > maxDecimals) {
5866
6396
  const newValue = `${split[0]}.${decimals.slice(0, maxDecimals)}`;
5867
6397
  return newValue;
5868
6398
  }
@@ -5870,259 +6400,17 @@ function trimExtraDecimals(value, maxDecimals) {
5870
6400
  return value;
5871
6401
  }
5872
6402
 
5873
- const NumericInput = (_a) => {
5874
- var _b;
5875
- var { onParsedValueChanged, initialValue = '', forcedUpdateValue, maxDecimals, balance = '0', tokenPrice = 0, numericInputMode } = _a, props = __rest(_a, ["onParsedValueChanged", "initialValue", "forcedUpdateValue", "maxDecimals", "balance", "tokenPrice", "numericInputMode"]);
5876
- const [inputValue, setInputValue] = React.useState(initialValue);
5877
- // Probably a better way to handle this
5878
- // This was introduce to handle the "MAX" button setting an amount
5879
- // Other than that, this component is only sending value to the exterior
5880
- // Without this, we were losing inputs such as ".05" that were forced parsed to "0.05" after debounce
5881
- React.useEffect(() => {
5882
- if (forcedUpdateValue && forcedUpdateValue !== '0') {
5883
- setInputValue(forcedUpdateValue);
5884
- }
5885
- }, [forcedUpdateValue]);
5886
- /**
5887
- * Get the number of decimals of inputValue
5888
- * If there are more decimals than the maxDecimals
5889
- * remove the extra decimals
5890
- */
5891
- React.useEffect(() => {
5892
- var _a;
5893
- const split = inputValue.split('.');
5894
- if (split.length > 1) {
5895
- const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
5896
- if (maxDecimals && decimals.length > maxDecimals) {
5897
- const newValue = `${split[0]}.${decimals.slice(0, maxDecimals)}`;
5898
- setInputValue(newValue);
5899
- onParsedValueChanged(newValue);
5900
- }
5901
- }
5902
- }, [maxDecimals]);
5903
- const debouncePriceChanged = (value = '') => {
5904
- if (value.endsWith('.'))
5905
- return;
5906
- onParsedValueChanged(value);
5907
- };
5908
- // useCallback to memoizes the debounce function, prevents recreating it
5909
- const debouncePriceUpdate = React.useCallback(debounce(debouncePriceChanged, 700), []);
5910
- const handlePriceChanged = (event) => {
5911
- var _a;
5912
- try {
5913
- const formattedInput = event.currentTarget.value
5914
- .replace(/[^0-9\.\,%]/g, '')
5915
- .replace(',', '.');
5916
- if (formattedInput.includes('%')) {
5917
- let cleanedInput = formattedInput;
5918
- // remove duplicates & always add % at the end
5919
- cleanedInput = formattedInput.replaceAll('%', '').concat('%');
5920
- setInputValue(cleanedInput);
5921
- debouncePriceUpdate.cancel();
5922
- return;
5923
- }
5924
- // This is to prevent the user from typing more decimals than the decimals attribute of the token
5925
- if (maxDecimals !== undefined) {
5926
- const split = formattedInput.split('.');
5927
- if (split.length > 1) {
5928
- const decimals = (_a = split[1]) !== null && _a !== void 0 ? _a : '';
5929
- if (decimals.length > maxDecimals) {
5930
- // Don't update anything
5931
- return;
5932
- }
5933
- }
5934
- }
5935
- // Means the user is currently typing and will add decimal, no need to fetch or parse
5936
- // example input: 0.00
5937
- const isTypingDecimals = (formattedInput.includes('.') && formattedInput.endsWith('0')) ||
5938
- formattedInput.endsWith('.') ||
5939
- (formattedInput === '0' && (inputValue === '' || inputValue === '0'));
5940
- // if input includes at least one character different than `0` (zero), `.` (dot), or `,` (comma)
5941
- // means that user is typing a valid amount, for example: 1.02 or 0.005
5942
- // if so, then update the input value and fetch the price
5943
- if (/[^0,.]/.test(formattedInput)) {
5944
- setInputValue(formattedInput);
5945
- debouncePriceUpdate(formattedInput);
5946
- }
5947
- else if (isTypingDecimals) {
5948
- setInputValue(formattedInput);
5949
- }
5950
- else if (!isNaN(+formattedInput)) {
5951
- setInputValue(formattedInput.toString());
5952
- debouncePriceUpdate(formattedInput.toString());
5953
- // onParsedValueChanged(formattedInput.toString());
5954
- }
5955
- else {
5956
- setInputValue('');
5957
- }
5958
- if (numericInputMode === 'price' && !isTypingDecimals) {
5959
- const usdAmount = Number(formattedInput);
5960
- if (tokenPrice === 0 || usdAmount === 0) {
5961
- setInputValue('');
5962
- onParsedValueChanged('');
5963
- }
5964
- else if (usdAmount > 0) {
5965
- const tokenAmount = convertUSDToTokenAmount(usdAmount, tokenPrice);
5966
- setInputValue(usdAmount.toString());
5967
- debouncePriceUpdate(tokenAmount);
5968
- return;
5969
- }
5970
- }
5971
- }
5972
- catch (error) {
5973
- setInputValue('');
5974
- }
5975
- };
5976
- const handleSubmit = (event) => {
5977
- event.preventDefault();
5978
- if (inputValue.includes('%')) {
5979
- const percentage = Number(inputValue.replace('%', ''));
5980
- // If the percentage is greater than 100, set it to 100
5981
- const formattedPercentage = percentage > 100 ? 100 : percentage;
5982
- const valueByPercentage = Number(balance) * (formattedPercentage / 100);
5983
- // If the value is 0, we want to show 0, not 0.0000
5984
- const formattedValue = valueByPercentage === 0 ? '0' : valueByPercentage.toFixed(4);
5985
- setInputValue(formattedValue);
5986
- onParsedValueChanged(formattedValue);
5987
- }
5988
- };
5989
- return (jsxRuntime.jsxs("form", { className: "tw-relative tw-px-squid-m tw-pb-[15px] tw-pt-[5px] tw-text-heading-small tw-font-heading-regular", onSubmit: handleSubmit, children: [numericInputMode === 'price' && (jsxRuntime.jsx("span", { className: "tw-absolute tw-left-[30px] tw-top-[11px] tw-leading-[43px] tw-text-grey-600", children: "$" })), jsxRuntime.jsx("input", Object.assign({}, props, { onChange: handlePriceChanged, value: inputValue, type: "string", placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : '0', className: cn('tw-h-[55px] tw-w-full tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-grey-300 placeholder:tw-text-grey-600 hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin focus:tw-text-royal-400 focus:tw-outline-none', numericInputMode === 'price' && 'tw-pl-[33px]') }))] }));
5990
- };
5991
-
5992
- // font size, line height, and letter spacing classes
5993
- const textClassMap = {
5994
- small: 'tw-text-heading-small tw-tracking-heading-small tw-leading-heading-small',
5995
- medium: 'tw-text-heading-medium tw-tracking-heading-medium tw-leading-heading-medium',
5996
- large: 'tw-text-heading-large tw-tracking-heading-large tw-leading-heading-large',
5997
- };
5998
- function HeadingText({ children, bold, size }) {
5999
- const fontWeightClass = bold
6000
- ? 'tw-font-heading-bold'
6001
- : 'tw-font-heading-regular';
6002
- return (jsxRuntime.jsx("h6", { className: clsx(textClassMap[size], fontWeightClass), children: children }));
6403
+ function MaxIcon() {
6404
+ return (jsxRuntime.jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_41_20801)", children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM10.6508 4.74074L14.1508 7.74074C14.5701 8.10017 14.6187 8.73147 14.2593 9.15079C13.8998 9.57012 13.2685 9.61868 12.8492 9.25926L10 6.81708L7.15079 9.25926C6.73147 9.61868 6.10017 9.57012 5.74074 9.15079C5.38132 8.73147 5.42988 8.10017 5.84921 7.74074L9.34921 4.74074C9.7237 4.41975 10.2763 4.41975 10.6508 4.74074ZM14.1508 13.7407L10.6508 10.7407C10.2763 10.4198 9.7237 10.4198 9.34921 10.7407L5.84921 13.7407C5.42988 14.1002 5.38132 14.7315 5.74074 15.1508C6.10017 15.5701 6.73147 15.6187 7.15079 15.2593L10 12.8171L12.8492 15.2593C13.2685 15.6187 13.8998 15.5701 14.2593 15.1508C14.6187 14.7315 14.5701 14.1002 14.1508 13.7407Z", fill: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_41_20801", children: jsxRuntime.jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
6003
6405
  }
6004
6406
 
6005
- function SettingsSlider({ value, type, onChange, hasDecimals, max, min, }) {
6006
- return (jsxRuntime.jsxs("div", { className: "tw-relative tw-flex tw-h-full tw-items-center tw-justify-center tw-rounded-squid-xs", children: [jsxRuntime.jsx("input", { min: min !== null && min !== void 0 ? min : 0, max: max !== null && max !== void 0 ? max : 99, step: hasDecimals ? 0.1 : 1, placeholder: "0", type: "number", onChange: (e) => {
6007
- onChange === null || onChange === void 0 ? void 0 : onChange(Number(e.target.value));
6008
- }, className: cn('tw-relative tw-flex tw-h-full tw-items-center tw-justify-center tw-self-stretch tw-rounded-squid-xs tw-bg-transparent tw-p-squid-xs tw-text-caption !tw-font-medium tw-leading-[10px] tw-text-grey-300 placeholder-shown:tw-text-grey-600 hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin', type === 'percentage'
6009
- ? 'tw-w-[84px] tw-pr-[52px] tw-text-right'
6010
- : 'tw-w-[80px] tw-pl-[20px] tw-pr-[32px] tw-text-left'), value: value }), type === 'percentage' && jsxRuntime.jsx(PercentageDecorator, {}), type === 'amount' && jsxRuntime.jsx(AmountDecorator, {})] }));
6011
- }
6012
- function PercentageDecorator() {
6013
- return (jsxRuntime.jsxs("div", { className: "tw-absolute tw-right-squid-xs tw-flex tw-items-center tw-justify-center tw-gap-squid-xs !tw-font-medium tw-leading-[10px]", children: [jsxRuntime.jsx(CaptionText, { className: "tw-translate-y-[0.5px] !tw-font-medium !tw-leading-[10px] tw-text-grey-300", children: "%" }), jsxRuntime.jsx(Chip, { icon: jsxRuntime.jsx(ChevronGrabberVerticalIcon, { className: "tw-text-grey-900" }) })] }));
6407
+ function SwapInputsIcon() {
6408
+ return (jsxRuntime.jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_40_7936)", children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM8.38268 4.57612C8.75636 4.7309 9 5.09554 9 5.5V15.5C9 16.0523 8.55228 16.5 8 16.5C7.44772 16.5 7 16.0523 7 15.5V7.91421L5.70711 9.20711C5.31658 9.59763 4.68342 9.59763 4.29289 9.20711C3.90237 8.81658 3.90237 8.18342 4.29289 7.79289L7.29289 4.79289C7.57889 4.5069 8.00901 4.42134 8.38268 4.57612ZM11 15.5C11 15.9045 11.2436 16.2691 11.6173 16.4239C11.991 16.5787 12.4211 16.4931 12.7071 16.2071L15.7071 13.2071C16.0976 12.8166 16.0976 12.1834 15.7071 11.7929C15.3166 11.4024 14.6834 11.4024 14.2929 11.7929L13 13.0858V5.5C13 4.94771 12.5523 4.5 12 4.5C11.4477 4.5 11 4.94771 11 5.5V15.5Z", fill: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_40_7936", children: jsxRuntime.jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
6014
6409
  }
6015
- function AmountDecorator() {
6016
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CaptionText, { className: "tw-absolute tw-left-squid-xs tw-translate-y-[0.5px] !tw-font-medium !tw-leading-[10px] tw-text-grey-300", children: "$" }), jsxRuntime.jsx("div", { className: "tw-absolute tw-right-squid-xs tw-flex tw-items-center tw-justify-center tw-gap-squid-xs !tw-font-medium tw-leading-[10px]", children: jsxRuntime.jsx(Chip, { icon: jsxRuntime.jsx(ChevronGrabberVerticalIcon, { className: "tw-text-grey-900" }) }) })] }));
6017
- }
6018
-
6019
- const switchSizeClassMap = {
6020
- small: 'tw-w-[36px] tw-h-squid-m tw-p-0.5',
6021
- large: 'tw-w-[54px] tw-h-squid-l tw-p-[3px]',
6022
- };
6023
- const switchKnobSizeClassMap = {
6024
- small: 'tw-w-4 tw-h-4',
6025
- large: 'tw-w-6 tw-h-6',
6026
- };
6027
- const switchKnobCheckedClassMap = {
6028
- large: {
6029
- checked: 'tw-left-[26px]',
6030
- unchecked: 'tw-left-[2px]',
6031
- },
6032
- small: {
6033
- checked: 'tw-left-[17px]',
6034
- unchecked: 'tw-left-[1px]',
6035
- },
6036
- };
6037
- function Switch({ checked = false, onChange, size, disabled = false, }) {
6038
- return (
6039
- // Switch container
6040
- jsxRuntime.jsxs("label", { className: clsx('tw-relative tw-inline-flex tw-items-center tw-justify-end tw-overflow-hidden tw-rounded-squid-m tw-border tw-border-material-light-thin tw-transition-colors',
6041
- // size styles
6042
- switchSizeClassMap[size],
6043
- // checked styles
6044
- checked ? 'tw-bg-status-positive' : 'tw-bg-grey-800',
6045
- // disabled styles
6046
- disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'), children: [jsxRuntime.jsx("input", { disabled: disabled, checked: checked, onChange: disabled ? undefined : (e) => onChange === null || onChange === void 0 ? void 0 : onChange(e.target.checked), type: "checkbox", className: "tw-peer tw-sr-only" }), jsxRuntime.jsx("span", { style: {
6047
- filter: 'drop-shadow(0px 5px 20px rgba(0, 0, 0, 0.33)) drop-shadow(0px 2px 5px rgba(0, 0, 0, 0.20))',
6048
- }, className: clsx('tw-absolute tw-rounded-full tw-border tw-border-material-light-thin tw-transition-all',
6049
- // size styles
6050
- switchKnobSizeClassMap[size],
6051
- // checked styles
6052
- switchKnobCheckedClassMap[size][checked ? 'checked' : 'unchecked'], checked
6053
- ? 'group-data-[squid-theme-type=dark]:tw-bg-grey-100 group-data-[squid-theme-type=light]:tw-bg-grey-900'
6054
- : 'tw-bg-grey-500') })] }));
6055
- }
6056
-
6057
- const borderRadiusClassMap = {
6058
- sm: 'tw-rounded-squid-s',
6059
- lg: 'tw-rounded-squid-m',
6060
- };
6061
- function Menu(_a) {
6062
- var { children, containerClassName, contentClassName, title, displayControls, rounded = 'lg', menuRef } = _a, props = __rest(_a, ["children", "containerClassName", "contentClassName", "title", "displayControls", "rounded", "menuRef"]);
6063
- return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn('tw-max-w-[320px]', containerClassName), ref: menuRef, children: jsxRuntime.jsxs("div", { className: cn('tw-relative tw-inline-flex tw-max-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-rounded-squid-m tw-bg-material-dark-thick tw-p-squid-xs tw-text-center tw-text-material-light-thick tw-backdrop-blur/20 tw-backdrop-saturate-150 group-data-[squid-theme-type=dark]:tw-shadow-elevation-dark-2 group-data-[squid-theme-type=light]:tw-shadow-elevation-light-2', borderRadiusClassMap[rounded], contentClassName), children: [title ? (jsxRuntime.jsx("div", { className: "tw-z-20 tw-flex tw-flex-col tw-items-center tw-justify-center tw-self-stretch tw-py-squid-xxs tw-text-grey-100", children: jsxRuntime.jsx(BodyText, { size: "small", className: "tw-self-stretch !tw-leading-[10px]", children: title }) })) : null, typeof children === 'string' ? (jsxRuntime.jsx(CaptionText, { className: "tw-z-20 tw-self-stretch !tw-leading-[10px]", children: children })) : (jsxRuntime.jsx("div", { className: "tw-z-20 tw-max-w-full tw-text-caption", children: children })), displayControls ? (jsxRuntime.jsx("div", { className: "tw-z-20 tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-pt-squid-xs", children: jsxRuntime.jsx(Button, { size: "md", variant: "tertiary", label: "Learn more", className: "tw-self-stretch" }) })) : null, jsxRuntime.jsx("div", { className: cn('tw-absolute tw-z-10 tw-h-full tw-w-full tw-border tw-border-material-light-thin tw-bg-material-light-thin', borderRadiusClassMap[rounded]) })] }) })));
6064
- }
6065
-
6066
- const tooltipWidthClassMap = {
6067
- max: 'tw-w-max',
6068
- container: 'tw-w-full',
6069
- };
6070
- const tooltipThresholdClassMap = {
6071
- xxs: 'tw-pb-squid-xxs',
6072
- xs: 'tw-pb-squid-xs',
6073
- s: 'tw-pb-squid-s',
6074
- m: 'tw-pb-squid-m',
6075
- l: 'tw-pb-squid-l',
6076
- xl: 'tw-pb-squid-xl',
6077
- xxl: 'tw-pb-squid-xxl',
6078
- };
6079
- function Tooltip({ children, tooltipContent, tooltipWidth = 'container', threshold = 'xxs', containerClassName, childrenClassName, tooltipClassName, displayDelayMs = 0, }) {
6080
- return (jsxRuntime.jsxs("div", { className: cn('tw-relative', containerClassName), children: [jsxRuntime.jsx("div", { className: cn('tw-peer', childrenClassName), children: children }), tooltipContent ? (jsxRuntime.jsx(Menu, { style: {
6081
- [CSS_VARS.DISPLAY_DELAYED_DURATION]: `${displayDelayMs}ms`,
6082
- }, containerClassName: cn(
6083
- // general styles
6084
- 'tw-absolute tw-z-40 tw-bottom-full tw-left-1/2 -tw-translate-x-1/2',
6085
- // visibility styles. Display only on hover
6086
- 'tw-animate-hide peer-hover:tw-animate-display-delayed hover:tw-animate-display-delayed', tooltipWidthClassMap[tooltipWidth], tooltipThresholdClassMap[threshold], tooltipClassName), children: tooltipContent })) : null] }));
6087
- }
6088
-
6089
- function BoostButton({ boostMode, canToggleBoostMode = true, boostDisabledMessage = 'Boost disabled', tooltipDisplayDelayMs = 0, boostIndicatorRef, }) {
6090
- return (jsxRuntime.jsx(Tooltip, { tooltipWidth: "max", displayDelayMs: tooltipDisplayDelayMs, tooltipContent: canToggleBoostMode ? null : boostDisabledMessage, children: jsxRuntime.jsxs("div", { className: "tw-relative tw-flex tw-h-squid-xl tw-w-[140px] tw-flex-col tw-justify-between tw-overflow-hidden tw-rounded-squid-m tw-pb-squid-xxs tw-text-grey-300 focus:tw-outline-none", children: [jsxRuntime.jsx("span", { className: cn('tw-absolute tw-left-0 tw-top-0 tw-z-10 tw-h-full tw-w-8 tw-bg-gradient-to-r tw-from-grey-900 tw-to-transparent', canToggleBoostMode &&
6091
- 'group-hover/boost-toggle:tw-from-material-light-blend-grey-900') }), jsxRuntime.jsx("span", { className: cn('tw-absolute tw-right-0 tw-top-0 tw-z-10 tw-h-full tw-w-8 tw-bg-gradient-to-l tw-from-grey-900 tw-to-transparent', canToggleBoostMode &&
6092
- 'group-hover/boost-toggle:tw-from-material-light-blend-grey-900') }), jsxRuntime.jsxs("div", { ref: boostIndicatorRef, "data-boost-mode": boostMode, className: "tw-group tw-peer tw-flex tw-h-full tw-w-full tw-items-center tw-justify-between tw-transition-transform group-disabled/boost-toggle:tw-grayscale data-[boost-mode=boost]:tw-animate-move-to-left-with-spring-bounce data-[boost-mode=normal]:tw-animate-move-to-right-with-spring-bounce", children: [jsxRuntime.jsx("div", { className: "tw-w-1/2 tw-text-center group-disabled/boost-toggle:tw-grayscale", children: jsxRuntime.jsx(BodyText, { size: "small", className: "tw-text-grey-300", children: "Normal" }) }), jsxRuntime.jsxs("div", { className: "tw-w-1/2 tw-text-center group-disabled/boost-toggle:tw-grayscale", children: [jsxRuntime.jsx(BodyText, { size: "small", className: "tw-text-status-positive", children: "Boost" }), ' '] }), jsxRuntime.jsx("div", { className: "tw-absolute tw-bottom-0 tw-h-1.5 tw-w-[1.5px] tw-rounded-sm tw-bg-grey-500 tw-text-grey-500 group-data-[boost-mode=boost]:tw-left-[calc(50%-2px)] group-data-[boost-mode=normal]:tw-left-[calc(50%-6px)]", style: {
6093
- boxShadow: generateMarkerLines(40),
6094
- } })] }), jsxRuntime.jsx("div", { className: cn('tw-absolute tw-bottom-0.5 tw-left-[calc(50%-1.5px)] tw-z-20 tw-h-[10px] tw-w-[3px] tw-rounded-sm tw-transition-colors group-disabled/boost-toggle:tw-grayscale peer-data-[boost-mode=boost]:tw-bg-status-positive peer-data-[boost-mode=normal]:tw-bg-current'), style: {
6095
- transitionDuration: `${ANIMATION_DURATIONS.BOOST_BUTTON}ms`,
6096
- } })] }) }));
6097
- }
6098
- function generateMarkerLines(count) {
6099
- const halfCount = Math.ceil(count / 2);
6100
- const rightShadows = Array.from({ length: halfCount }, (_, index) => {
6101
- return `-${(index + 1) * 6}px 0 currentColor`;
6102
- });
6103
- const leftShadows = Array.from({ length: halfCount }, (_, index) => {
6104
- return `${(index + 1) * 6}px 0 currentColor`;
6105
- });
6106
- const allShadows = [...rightShadows, ...leftShadows];
6107
- return allShadows.join(', ');
6108
- }
6109
-
6110
- function Chip(_a) {
6111
- var { label, icon } = _a, props = __rest(_a, ["label", "icon"]);
6112
- return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn('tw-flex tw-h-squid-m tw-items-center tw-justify-center tw-rounded-squid-m tw-bg-grey-500 tw-text-grey-900', icon && 'tw-w-squid-m', props.className), children: label ? (jsxRuntime.jsx(CaptionText, { className: "tw-min-w-squid-xl tw-px-squid-xxs tw-text-center", children: label })) : (icon) })));
6113
- }
6114
-
6115
- function EthereumIcon() {
6116
- return (jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M9.99866 2.91669L9.99866 12.6994L14.471 10.1298L9.99866 2.91669Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99872 2.91669L5.52637 10.1298L9.99872 12.6995V8.15387V2.91669Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99866 13.5226V17.0802L14.4737 10.9542L9.99866 13.5226Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99872 17.0801V13.5225L5.52637 10.9542L9.99872 17.0801Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99866 12.6994L14.4709 10.1298L9.99866 8.15387V12.6994Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M5.52637 10.1298L9.99865 12.6994V8.15387L5.52637 10.1298Z", fill: "currentColor" })] }));
6117
- }
6118
-
6119
- function FeeButton(_a) {
6120
- var { feeInUsd = '0', chipLabel = 'Fee', className } = _a, props = __rest(_a, ["feeInUsd", "chipLabel", "className"]);
6121
- return (jsxRuntime.jsxs("button", Object.assign({}, props, { className: cn('tw-flex tw-h-squid-xl tw-w-full tw-items-center tw-gap-x-squid-xs tw-rounded-squid-m tw-px-squid-xs hover:tw-bg-material-light-thin', className), children: [jsxRuntime.jsx(Chip, { label: chipLabel }), jsxRuntime.jsxs("span", { className: "tw-flex tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(Chip, { icon: jsxRuntime.jsx(EthereumIcon, {}) }), jsxRuntime.jsx(UsdAmount, { usdAmount: feeInUsd })] })] })));
6122
- }
6123
-
6124
- function SettingsButton({ label, isSelected = false, onClick, }) {
6125
- return (jsxRuntime.jsx("button", { onClick: onClick, className: cn('tw-flex tw-items-center tw-justify-center tw-self-stretch tw-rounded-squid-xs tw-border-2 tw-border-transparent tw-p-squid-xs hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin', isSelected && 'tw-outline-royal-500'), children: jsxRuntime.jsx(CaptionText, { className: "!tw-font-medium", children: label }) }));
6410
+
6411
+ function Chip(_a) {
6412
+ var { label, icon } = _a, props = __rest(_a, ["label", "icon"]);
6413
+ return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn('tw-flex tw-h-squid-m tw-items-center tw-justify-center tw-rounded-squid-m tw-bg-grey-500 tw-text-grey-900', icon && 'tw-w-squid-m', props.className), children: label ? (jsxRuntime.jsx(CaptionText, { className: "tw-min-w-squid-xl tw-px-squid-xxs tw-text-center", children: label })) : (icon) })));
6126
6414
  }
6127
6415
 
6128
6416
  function Boost({ boostMode, onToggleBoostMode, estimatedTime, boostDisabledMessage, canToggleBoostMode = true, boostTooltipDisplayDelayMs = 0, }) {
@@ -6147,6 +6435,15 @@ function Boost({ boostMode, onToggleBoostMode, estimatedTime, boostDisabledMessa
6147
6435
  : 'tw-bg-status-positive') })] }) }));
6148
6436
  }
6149
6437
 
6438
+ function EthereumIcon() {
6439
+ return (jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M9.99866 2.91669L9.99866 12.6994L14.471 10.1298L9.99866 2.91669Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99872 2.91669L5.52637 10.1298L9.99872 12.6995V8.15387V2.91669Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99866 13.5226V17.0802L14.4737 10.9542L9.99866 13.5226Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99872 17.0801V13.5225L5.52637 10.9542L9.99872 17.0801Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M9.99866 12.6994L14.4709 10.1298L9.99866 8.15387V12.6994Z", fill: "currentColor" }), jsxRuntime.jsx("path", { d: "M5.52637 10.1298L9.99865 12.6994V8.15387L5.52637 10.1298Z", fill: "currentColor" })] }));
6440
+ }
6441
+
6442
+ function FeeButton(_a) {
6443
+ var { feeInUsd = '0', chipLabel = 'Fee', className } = _a, props = __rest(_a, ["feeInUsd", "chipLabel", "className"]);
6444
+ return (jsxRuntime.jsxs("button", Object.assign({}, props, { className: cn('tw-flex tw-h-squid-xl tw-w-full tw-items-center tw-gap-x-squid-xs tw-rounded-squid-m tw-px-squid-xs hover:tw-bg-material-light-thin', className), children: [jsxRuntime.jsx(Chip, { label: chipLabel }), jsxRuntime.jsxs("span", { className: "tw-flex tw-items-center tw-gap-squid-xxs", children: [jsxRuntime.jsx(Chip, { icon: jsxRuntime.jsx(EthereumIcon, {}) }), jsxRuntime.jsx(UsdAmount, { usdAmount: feeInUsd })] })] })));
6445
+ }
6446
+
6150
6447
  function EmojiSadIcon({ className, size = '20', }) {
6151
6448
  return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 20 20", fill: "none", className: className, children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M10 20C15.5228 20 20 15.5228 20 10C20 4.47715 15.5228 0 10 0C4.47715 0 0 4.47715 0 10C0 15.5228 4.47715 20 10 20ZM13.5341 12.4645C11.5815 10.5118 8.41568 10.5118 6.46306 12.4645C6.07254 12.855 6.07254 13.4882 6.46306 13.8787C6.85358 14.2692 7.48675 14.2692 7.87727 13.8787C9.04885 12.7071 10.9483 12.7071 12.1199 13.8787C12.5104 14.2692 13.1436 14.2692 13.5341 13.8787C13.9247 13.4882 13.9247 12.855 13.5341 12.4645ZM8.5 7.5C8.5 8.32843 7.94036 9 7.25 9C6.55964 9 6 8.32843 6 7.5C6 6.67157 6.55964 6 7.25 6C7.94036 6 8.5 6.67157 8.5 7.5ZM12.75 9C13.4404 9 14 8.32843 14 7.5C14 6.67157 13.4404 6 12.75 6C12.0596 6 11.5 6.67157 11.5 7.5C11.5 8.32843 12.0596 9 12.75 9Z", fill: "currentColor" }) }));
6152
6449
  }
@@ -6154,6 +6451,19 @@ function EmojiMeh({ className, size = '20', }) {
6154
6451
  return (jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 20 20", fill: "none", className: className, children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10C20 15.5228 15.5228 20 10 20C4.47715 20 0 15.5228 0 10C0 4.47715 4.47715 0 10 0C15.5228 0 20 4.47715 20 10ZM7.25 9C7.94036 9 8.5 8.32843 8.5 7.5C8.5 6.67157 7.94036 6 7.25 6C6.55964 6 6 6.67157 6 7.5C6 8.32843 6.55964 9 7.25 9ZM14 7.5C14 8.32843 13.4404 9 12.75 9C12.0596 9 11.5 8.32843 11.5 7.5C11.5 6.67157 12.0596 6 12.75 6C13.4404 6 14 6.67157 14 7.5ZM7 12C6.44772 12 6 12.4477 6 13C6 13.5523 6.44772 14 7 14H13C13.5523 14 14 13.5523 14 13C14 12.4477 13.5523 12 13 12H7Z", fill: "currentColor" }) }));
6155
6452
  }
6156
6453
 
6454
+ // font size, line height, and letter spacing classes
6455
+ const textClassMap = {
6456
+ small: 'tw-text-heading-small tw-tracking-heading-small tw-leading-heading-small',
6457
+ medium: 'tw-text-heading-medium tw-tracking-heading-medium tw-leading-heading-medium',
6458
+ large: 'tw-text-heading-large tw-tracking-heading-large tw-leading-heading-large',
6459
+ };
6460
+ function HeadingText({ children, bold, size }) {
6461
+ const fontWeightClass = bold
6462
+ ? 'tw-font-heading-bold'
6463
+ : 'tw-font-heading-regular';
6464
+ return (jsxRuntime.jsx("h6", { className: clsx(textClassMap[size], fontWeightClass), children: children }));
6465
+ }
6466
+
6157
6467
  function ErrorMessage({ message, showIcon = true }) {
6158
6468
  return (jsxRuntime.jsxs("div", { className: "tw-flex tw-h-squid-xl tw-flex-1 tw-items-center tw-gap-squid-xxs tw-text-status-negative", children: [showIcon ? jsxRuntime.jsx(EmojiSadIcon, {}) : null, jsxRuntime.jsx(CaptionText, { children: message })] }));
6159
6469
  }
@@ -6456,6 +6766,15 @@ function SwapStepItem({ descriptionBlocks, showStepSeparator = false, link, stat
6456
6766
  }) })] }), showStepSeparator && (jsxRuntime.jsx("span", { className: cn(separatorClassMap[status]), style: transitionStyle, children: jsxRuntime.jsx(SwapStepSeparator, {}) }))] }));
6457
6767
  }
6458
6768
 
6769
+ const borderRadiusClassMap = {
6770
+ sm: 'tw-rounded-squid-s',
6771
+ lg: 'tw-rounded-squid-m',
6772
+ };
6773
+ function Menu(_a) {
6774
+ var { children, containerClassName, contentClassName, title, displayControls, rounded = 'lg', menuRef } = _a, props = __rest(_a, ["children", "containerClassName", "contentClassName", "title", "displayControls", "rounded", "menuRef"]);
6775
+ return (jsxRuntime.jsx("div", Object.assign({}, props, { className: cn('tw-max-w-[320px]', containerClassName), ref: menuRef, children: jsxRuntime.jsxs("div", { className: cn('tw-relative tw-inline-flex tw-max-w-full tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-rounded-squid-m tw-bg-material-dark-thick tw-p-squid-xs tw-text-center tw-text-material-light-thick tw-backdrop-blur/20 tw-backdrop-saturate-150 group-data-[squid-theme-type=dark]:tw-shadow-elevation-dark-2 group-data-[squid-theme-type=light]:tw-shadow-elevation-light-2', borderRadiusClassMap[rounded], contentClassName), children: [title ? (jsxRuntime.jsx("div", { className: "tw-z-20 tw-flex tw-flex-col tw-items-center tw-justify-center tw-self-stretch tw-py-squid-xxs tw-text-grey-100", children: jsxRuntime.jsx(BodyText, { size: "small", className: "tw-self-stretch !tw-leading-[10px]", children: title }) })) : null, typeof children === 'string' ? (jsxRuntime.jsx(CaptionText, { className: "tw-z-20 tw-self-stretch !tw-leading-[10px]", children: children })) : (jsxRuntime.jsx("div", { className: "tw-z-20 tw-max-w-full tw-text-caption", children: children })), displayControls ? (jsxRuntime.jsx("div", { className: "tw-z-20 tw-flex tw-flex-col tw-items-center tw-justify-center tw-gap-squid-xs tw-self-stretch tw-pt-squid-xs", children: jsxRuntime.jsx(Button, { size: "md", variant: "tertiary", label: "Learn more", className: "tw-self-stretch" }) })) : null, jsxRuntime.jsx("div", { className: cn('tw-absolute tw-z-10 tw-h-full tw-w-full tw-border tw-border-material-light-thin tw-bg-material-light-thin', borderRadiusClassMap[rounded]) })] }) })));
6776
+ }
6777
+
6459
6778
  function DropdownMenu({ dropdownRef, items, className, menuRef, isHidden = false, listClassName, }) {
6460
6779
  return (jsxRuntime.jsx("div", { ref: dropdownRef, className: "tw-relative", children: jsxRuntime.jsx(Menu, { menuRef: menuRef, rounded: "sm", containerClassName: cn('tw-absolute tw-right-0 tw-z-20', className), contentClassName: "!tw-p-0", children: !isHidden && (jsxRuntime.jsx("ul", { className: cn('tw-flex tw-max-w-full tw-flex-col tw-gap-squid-xxs tw-overflow-auto tw-px-0 tw-py-squid-xxs', listClassName), children: items.map((item) => (jsxRuntime.jsx(DropdownMenuItem, Object.assign({}, item), item.label))) })) }) }));
6461
6780
  }
@@ -6538,62 +6857,21 @@ function LogoContainer({ children }) {
6538
6857
  return (jsxRuntime.jsx("div", { className: "tw-flex tw-h-[60px] tw-w-[60px] tw-items-center tw-justify-center", children: children }));
6539
6858
  }
6540
6859
 
6541
- function MaxIcon() {
6542
- return (jsxRuntime.jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_41_20801)", children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM10.6508 4.74074L14.1508 7.74074C14.5701 8.10017 14.6187 8.73147 14.2593 9.15079C13.8998 9.57012 13.2685 9.61868 12.8492 9.25926L10 6.81708L7.15079 9.25926C6.73147 9.61868 6.10017 9.57012 5.74074 9.15079C5.38132 8.73147 5.42988 8.10017 5.84921 7.74074L9.34921 4.74074C9.7237 4.41975 10.2763 4.41975 10.6508 4.74074ZM14.1508 13.7407L10.6508 10.7407C10.2763 10.4198 9.7237 10.4198 9.34921 10.7407L5.84921 13.7407C5.42988 14.1002 5.38132 14.7315 5.74074 15.1508C6.10017 15.5701 6.73147 15.6187 7.15079 15.2593L10 12.8171L12.8492 15.2593C13.2685 15.6187 13.8998 15.5701 14.2593 15.1508C14.6187 14.7315 14.5701 14.1002 14.1508 13.7407Z", fill: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_41_20801", children: jsxRuntime.jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
6543
- }
6544
-
6545
- function SwapInputsIcon() {
6546
- return (jsxRuntime.jsxs("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("g", { clipPath: "url(#clip0_40_7936)", children: jsxRuntime.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M20 10.5C20 16.0228 15.5228 20.5 10 20.5C4.47715 20.5 0 16.0228 0 10.5C0 4.97715 4.47715 0.5 10 0.5C15.5228 0.5 20 4.97715 20 10.5ZM8.38268 4.57612C8.75636 4.7309 9 5.09554 9 5.5V15.5C9 16.0523 8.55228 16.5 8 16.5C7.44772 16.5 7 16.0523 7 15.5V7.91421L5.70711 9.20711C5.31658 9.59763 4.68342 9.59763 4.29289 9.20711C3.90237 8.81658 3.90237 8.18342 4.29289 7.79289L7.29289 4.79289C7.57889 4.5069 8.00901 4.42134 8.38268 4.57612ZM11 15.5C11 15.9045 11.2436 16.2691 11.6173 16.4239C11.991 16.5787 12.4211 16.4931 12.7071 16.2071L15.7071 13.2071C16.0976 12.8166 16.0976 12.1834 15.7071 11.7929C15.3166 11.4024 14.6834 11.4024 14.2929 11.7929L13 13.0858V5.5C13 4.94771 12.5523 4.5 12 4.5C11.4477 4.5 11 4.94771 11 5.5V15.5Z", fill: "currentColor" }) }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_40_7936", children: jsxRuntime.jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(0 0.5)" }) }) })] }));
6547
- }
6548
-
6549
- const buttonClassName = 'tw-flex tw-h-squid-l tw-items-center tw-gap-1.5 tw-rounded-squid-s tw-px-squid-xs';
6550
- const interactiveChipClassName = 'hover:tw-bg-material-light-thin';
6551
- function SwapConfiguration({ priceImpactPercentage, amount, forcedAmount: _forcedAmount, balance = '0', tokenPrice = 0, isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, onBalanceButtonClick, address, error, criticalPriceImpactPercentage = 5, emptyAddressLabel = 'Connect wallet', }) {
6860
+ function SwapConfiguration({ amount, tokenPrice = 0, isFetching = false, chain, token, direction, onAmountChange, onWalletButtonClick, onAssetsButtonClick, address, emptyAddressLabel = 'Connect wallet', balance, criticalPriceImpactPercentage, error, priceImpactPercentage, amountUsd, }) {
6552
6861
  var _a, _b;
6553
- const [inputMode, setInputMode] = React.useState('token');
6554
- const [tokenAmount, setTokenAmount] = React.useState('0');
6555
- const forcedAmount = React.useMemo(() => {
6556
- var _a, _b;
6557
- if (_forcedAmount) {
6558
- return _forcedAmount;
6559
- }
6560
- if (inputMode === 'token') {
6561
- const amountLimitedToMaxDecimals = trimExtraDecimals(amount !== null && amount !== void 0 ? amount : '0', (_a = token === null || token === void 0 ? void 0 : token.decimals) !== null && _a !== void 0 ? _a : 18);
6562
- return amountLimitedToMaxDecimals;
6563
- }
6564
- else if (inputMode === 'price') {
6565
- const tokenAmountToUsd = convertTokenAmountToUSD(amount || 0, tokenPrice);
6566
- const amountLimitedToMaxDecimals = trimExtraDecimals(tokenAmountToUsd, (_b = token === null || token === void 0 ? void 0 : token.decimals) !== null && _b !== void 0 ? _b : 18);
6567
- return amountLimitedToMaxDecimals;
6568
- }
6569
- return '0';
6570
- }, [_forcedAmount, inputMode, amount, tokenPrice, token === null || token === void 0 ? void 0 : token.decimals]);
6571
- const swapAmountUsd = React.useMemo(() => {
6572
- if (tokenPrice && forcedAmount) {
6573
- return formatUSD(convertTokenAmountToUSD(forcedAmount, tokenPrice));
6574
- }
6575
- return '0';
6576
- }, [forcedAmount, tokenPrice]);
6577
- const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) > Number(criticalPriceImpactPercentage)
6578
- ? 'tw-text-status-negative'
6579
- : 'tw-text-grey-300';
6580
- const isBalanceChipInteractive = !!onBalanceButtonClick;
6581
- const BalanceChipTag = isBalanceChipInteractive ? 'button' : 'div';
6582
- const handleSwapAmountButtonClick = React.useCallback(() => {
6583
- if (inputMode === 'token') {
6584
- setInputMode('price');
6585
- }
6586
- else {
6587
- setInputMode('token');
6588
- }
6589
- }, [inputMode]);
6590
- const tokenAmountFormatted = React.useMemo(() => {
6591
- return formatUSD(tokenAmount || 0);
6592
- }, [tokenAmount]);
6593
- return (jsxRuntime.jsxs("section", { className: "tw-relative tw-h-[205px] tw-max-h-[205px] tw-w-[480px] tw-overflow-hidden tw-border-t tw-border-t-material-light-thin tw-bg-grey-900 tw-pb-squid-m", children: [jsxRuntime.jsx("header", { className: "tw-flex tw-items-center tw-gap-1 tw-px-squid-l tw-py-squid-xs tw-leading-5 tw-text-grey-300", children: jsxRuntime.jsxs("button", { onClick: onWalletButtonClick, className: "-tw-ml-squid-xs tw-flex tw-h-squid-l tw-items-center tw-gap-squid-xxs tw-rounded-squid-s tw-px-squid-xs tw-text-grey-600 hover:tw-bg-material-light-thin", children: [jsxRuntime.jsx(BodyText, { className: "tw-text-grey-500", size: "small", children: direction === 'from' ? 'Pay' : 'Receive' }), jsxRuntime.jsx(BodyText, { size: "small", children: ":" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center tw-gap-1", children: [jsxRuntime.jsx(BodyText, { size: "small", className: address ? 'tw-text-grey-300' : 'tw-text-royal-400', children: address ? address : emptyAddressLabel }), jsxRuntime.jsx(ChevronArrowIcon, { className: address ? 'tw-text-grey-600' : 'tw-text-royal-400' })] })] }) }), jsxRuntime.jsx("div", { className: "tw-px-squid-l", children: jsxRuntime.jsx(AssetsButton, { onClick: onAssetsButtonClick, chainImageUrl: chain === null || chain === void 0 ? void 0 : chain.iconUrl, tokenImageUrl: token === null || token === void 0 ? void 0 : token.iconUrl, tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol, chainBgColor: chain === null || chain === void 0 ? void 0 : chain.bgColor, tokenBgColor: token === null || token === void 0 ? void 0 : token.bgColor, tokenTextColor: token === null || token === void 0 ? void 0 : token.textColor }) }), isFetching && (jsxRuntime.jsx("div", { className: "tw-absolute tw-bottom-4 tw-left-squid-l tw-z-10 tw-overflow-hidden", children: jsxRuntime.jsx("div", { className: "tw-h-[94px] tw-w-[1260px] tw-animate-move-loading-cover-to-right tw-bg-dark-cover" }) })), direction === 'from' ? (jsxRuntime.jsx(NumericInput, { balance: balance, tokenPrice: tokenPrice, forcedUpdateValue: forcedAmount, initialValue: amount, maxDecimals: (_b = token === null || token === void 0 ? void 0 : token.decimals) !== null && _b !== void 0 ? _b : 18, onParsedValueChanged: (value) => {
6594
- setTokenAmount(value);
6862
+ return (jsxRuntime.jsxs("section", { className: "tw-relative tw-h-[205px] tw-max-h-[205px] tw-w-[480px] tw-overflow-hidden tw-border-t tw-border-t-material-light-thin tw-bg-grey-900 tw-pb-squid-m", children: [jsxRuntime.jsx("header", { className: "tw-flex tw-items-center tw-gap-1 tw-px-squid-l tw-py-squid-xs tw-leading-5 tw-text-grey-300", children: jsxRuntime.jsxs("button", { onClick: onWalletButtonClick, className: "-tw-ml-squid-xs tw-flex tw-h-squid-l tw-items-center tw-gap-squid-xxs tw-rounded-squid-s tw-px-squid-xs tw-text-grey-600 hover:tw-bg-material-light-thin", children: [jsxRuntime.jsx(BodyText, { className: "tw-text-grey-500", size: "small", children: direction === 'from' ? 'Pay' : 'Receive' }), jsxRuntime.jsx(BodyText, { size: "small", children: ":" }), jsxRuntime.jsxs("div", { className: "tw-flex tw-items-center tw-gap-1", children: [jsxRuntime.jsx(BodyText, { size: "small", className: address ? 'tw-text-grey-300' : 'tw-text-royal-400', children: address ? address : emptyAddressLabel }), jsxRuntime.jsx(ChevronArrowIcon, { className: address ? 'tw-text-grey-600' : 'tw-text-royal-400' })] })] }) }), jsxRuntime.jsx("div", { className: "tw-px-squid-l", children: jsxRuntime.jsx(AssetsButton, { onClick: onAssetsButtonClick, chainImageUrl: chain === null || chain === void 0 ? void 0 : chain.iconUrl, tokenImageUrl: token === null || token === void 0 ? void 0 : token.iconUrl, tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol, chainBgColor: chain === null || chain === void 0 ? void 0 : chain.bgColor, tokenBgColor: token === null || token === void 0 ? void 0 : token.bgColor, tokenTextColor: token === null || token === void 0 ? void 0 : token.textColor }) }), isFetching && (jsxRuntime.jsx("div", { className: "tw-absolute tw-bottom-4 tw-left-squid-l tw-z-10 tw-overflow-hidden", children: jsxRuntime.jsx("div", { className: "tw-h-[94px] tw-w-[1260px] tw-animate-move-loading-cover-to-right tw-bg-dark-cover" }) })), jsxRuntime.jsx(NumericInput, { token: {
6863
+ decimals: (_a = token === null || token === void 0 ? void 0 : token.decimals) !== null && _a !== void 0 ? _a : 18,
6864
+ symbol: (_b = token === null || token === void 0 ? void 0 : token.symbol) !== null && _b !== void 0 ? _b : '',
6865
+ price: tokenPrice,
6866
+ }, onAmountChange: (value) => {
6595
6867
  onAmountChange === null || onAmountChange === void 0 ? void 0 : onAmountChange(value);
6596
- }, numericInputMode: inputMode })) : (jsxRuntime.jsx("div", { className: cn('tw-w-full tw-px-squid-m tw-pb-[15px] tw-pt-[5px]', isFetching && 'tw-opacity-50'), children: jsxRuntime.jsx("div", { className: "tw-flex tw-h-[55px] tw-w-full tw-items-center tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-heading-small tw-font-heading-regular tw-text-grey-300", children: jsxRuntime.jsx("span", { children: amount }) }) })), !(token === null || token === void 0 ? void 0 : token.iconUrl) ? null : (jsxRuntime.jsxs("footer", { className: cn('tw-flex tw-h-squid-m tw-max-h-squid-m tw-items-center tw-justify-between tw-gap-2 tw-px-squid-m tw-text-grey-500', isFetching && 'tw-opacity-50'), children: [error ? (jsxRuntime.jsx("div", { className: "tw-px-squid-xs", children: jsxRuntime.jsx(ErrorMessage, { message: error.message }) })) : (jsxRuntime.jsxs("button", { onClick: handleSwapAmountButtonClick, className: cn(buttonClassName, interactiveChipClassName), children: [jsxRuntime.jsx(SwapInputsIcon, {}), inputMode === 'token' ? (jsxRuntime.jsx(UsdAmount, { usdAmount: swapAmountUsd })) : (jsxRuntime.jsxs("span", { className: "tw-text-grey-500", children: [jsxRuntime.jsx(CaptionText, { children: tokenAmountFormatted }), ' ', jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: token.symbol })] })), priceImpactPercentage && direction === 'to' ? (jsxRuntime.jsxs("span", { className: clsx('tw-flex tw-items-center', priceImpactClass), children: [jsxRuntime.jsx(ArrowTriangle, {}), jsxRuntime.jsx(CaptionText, { bold: true, children: priceImpactPercentage.toString().concat('%') })] })) : null] })), jsxRuntime.jsxs(BalanceChipTag, { onClick: onBalanceButtonClick, className: cn(buttonClassName, isBalanceChipInteractive && interactiveChipClassName), children: [jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsxRuntime.jsxs(CaptionText, { children: [balance, " ", token.symbol] }), jsxRuntime.jsx(MaxIcon, {})] })] }))] }));
6868
+ }, balance: balance, criticalPriceImpactPercentage: criticalPriceImpactPercentage, error: error, formatIfVerySmall: {
6869
+ token: '0.001',
6870
+ usd: '0.01',
6871
+ }, isLoading: isFetching, maxDecimals: {
6872
+ token: 4,
6873
+ usd: 2,
6874
+ }, priceImpactPercentage: priceImpactPercentage, showDetails: !!(token === null || token === void 0 ? void 0 : token.iconUrl), direction: direction, forcedAmount: amount, amountUsd: amountUsd })] }));
6597
6875
  }
6598
6876
 
6599
6877
  function SwapProgressViewHeader({ title, description, }) {
@@ -6674,6 +6952,250 @@ function TokenPair({ firstToken, secondToken }) {
6674
6952
  }, children: [jsxRuntime.jsx("img", { className: "tw-ml-[1px] tw-aspect-square tw-w-10", src: firstToken.imageUrl }), jsxRuntime.jsx("img", { className: "tw-mr-[1px] tw-aspect-square tw-w-10", src: secondToken.imageUrl })] })] }));
6675
6953
  }
6676
6954
 
6955
+ const buttonClassName = 'tw-flex tw-h-squid-l tw-items-center tw-gap-1.5 tw-rounded-squid-s tw-px-squid-xs';
6956
+ // checks that the value includes at least one character different than `0` (zero), or `.` (dot)
6957
+ const RegExpNonZeroValue = /[^0.]/;
6958
+ const interactiveChipClassName = 'hover:tw-bg-material-light-thin';
6959
+ var InputMode;
6960
+ (function (InputMode) {
6961
+ InputMode[InputMode["TOKEN"] = 0] = "TOKEN";
6962
+ InputMode[InputMode["USD"] = 1] = "USD";
6963
+ })(InputMode || (InputMode = {}));
6964
+ function NumericInput({ priceImpactPercentage, balance = '0', error, criticalPriceImpactPercentage = 5, token, onAmountChange, forcedAmount, maxDecimals = {
6965
+ token: 4,
6966
+ usd: 2,
6967
+ }, formatIfVerySmall = {
6968
+ token: '0.001',
6969
+ usd: '0.01',
6970
+ }, showDetails = true, isLoading = false, direction, amountUsd, }) {
6971
+ var _a;
6972
+ const [inputValue, setInputValue] = React.useState('');
6973
+ const [inputMode, setInputMode] = React.useState(InputMode.TOKEN);
6974
+ React.useEffect(() => {
6975
+ if (forcedAmount !== undefined) {
6976
+ updateInputValue(forcedAmount);
6977
+ }
6978
+ }, [forcedAmount]);
6979
+ const updateInputValue = React.useCallback((newValue) => {
6980
+ const safeNewValue = trimExtraDecimals(newValue, token.decimals);
6981
+ const formattedAmount = inputMode === InputMode.TOKEN
6982
+ ? safeNewValue
6983
+ : convertTokenAmountToUSD(safeNewValue, token.price);
6984
+ setInputValue(formattedAmount);
6985
+ }, [inputMode, token.price, direction, token.decimals]);
6986
+ const onBalanceButtonClick = React.useCallback(() => {
6987
+ if (direction === 'from') {
6988
+ updateInputValue(balance);
6989
+ onAmountChange(balance);
6990
+ }
6991
+ }, [balance, direction, onAmountChange, updateInputValue]);
6992
+ const onAmountChangeDebounced = React.useCallback(debounce$1(onAmountChange, 1000), [
6993
+ onAmountChange,
6994
+ ]);
6995
+ const handleInputChange = (e) => {
6996
+ let value = e.target.value.replace(/,/g, '.'); // Replace commas with dots
6997
+ const maxDecimalsForInputType = inputMode === InputMode.TOKEN ? token.decimals : maxDecimals.usd;
6998
+ const isValidAmount = new RegExp(`^\\d*\\.?\\d{0,${maxDecimalsForInputType}}$`).test(value);
6999
+ if (isValidAmount) {
7000
+ setInputValue(value);
7001
+ // Means the user is currently typing and will add decimal, no need to fetch or parse
7002
+ // example inputs: 0.00, 0., 0, 0.0, 50. 13.00
7003
+ const isTypingDecimals = (value.includes('.') && value.endsWith('0')) || value.endsWith('.');
7004
+ if (isTypingDecimals) {
7005
+ onAmountChangeDebounced.cancel();
7006
+ }
7007
+ else {
7008
+ const { tokenRawAmount } = getRawAmounts(value);
7009
+ onAmountChangeDebounced(tokenRawAmount);
7010
+ }
7011
+ }
7012
+ };
7013
+ const handleSwitchInputMode = () => {
7014
+ if (inputValue !== '') {
7015
+ const convertedAmount = inputMode === InputMode.TOKEN
7016
+ ? convertTokenAmountToUSD(inputValue, token.price)
7017
+ : convertUSDToTokenAmount(inputValue, token.price, token.decimals);
7018
+ setInputValue(convertedAmount);
7019
+ }
7020
+ setInputMode((prevMode) => prevMode === InputMode.TOKEN ? InputMode.USD : InputMode.TOKEN);
7021
+ };
7022
+ const getRawAmounts = (amount) => {
7023
+ if (amount === '')
7024
+ return {
7025
+ usdRawAmount: '',
7026
+ tokenRawAmount: '',
7027
+ isTokenAmountVerySmall: false,
7028
+ isUsdAmountVerySmall: false,
7029
+ };
7030
+ if (inputMode === InputMode.TOKEN) {
7031
+ const usdRawAmount = convertTokenAmountToUSD(amount, token.price, maxDecimals.usd);
7032
+ const tokenRawAmount = amount;
7033
+ const isTokenAmountVerySmall = !!tokenRawAmount &&
7034
+ RegExpNonZeroValue.test(tokenRawAmount) &&
7035
+ BigNumber(tokenRawAmount).isLessThan(formatIfVerySmall.token);
7036
+ const isUsdAmountVerySmall = (!!usdRawAmount &&
7037
+ RegExpNonZeroValue.test(usdRawAmount) &&
7038
+ BigNumber(usdRawAmount).isLessThan(formatIfVerySmall.usd)) ||
7039
+ (usdRawAmount === '0' && RegExpNonZeroValue.test(tokenRawAmount));
7040
+ return {
7041
+ tokenRawAmount,
7042
+ usdRawAmount,
7043
+ isTokenAmountVerySmall,
7044
+ isUsdAmountVerySmall,
7045
+ };
7046
+ }
7047
+ else {
7048
+ const tokenRawAmount = convertUSDToTokenAmount(amount, token.price, token.decimals);
7049
+ const usdRawAmount = amount;
7050
+ const isUsdAmountVerySmall = (!!usdRawAmount &&
7051
+ RegExpNonZeroValue.test(usdRawAmount) &&
7052
+ BigNumber(usdRawAmount).isLessThan(formatIfVerySmall.usd)) ||
7053
+ (usdRawAmount === '0' && RegExpNonZeroValue.test(tokenRawAmount));
7054
+ const isTokenAmountVerySmall = !!tokenRawAmount &&
7055
+ RegExpNonZeroValue.test(tokenRawAmount) &&
7056
+ BigNumber(tokenRawAmount).isLessThan(formatIfVerySmall.token);
7057
+ return {
7058
+ tokenRawAmount,
7059
+ usdRawAmount,
7060
+ isTokenAmountVerySmall,
7061
+ isUsdAmountVerySmall,
7062
+ };
7063
+ }
7064
+ };
7065
+ const { isTokenAmountVerySmall, isUsdAmountVerySmall } = getRawAmounts(inputValue);
7066
+ const amountFormatted = React.useMemo(() => {
7067
+ if (inputValue === '')
7068
+ return '0';
7069
+ if (inputMode === InputMode.TOKEN) {
7070
+ if (direction === 'from') {
7071
+ return formatAmount(convertTokenAmountToUSD(inputValue, token.price, maxDecimals.usd));
7072
+ }
7073
+ else {
7074
+ return formatAmount(amountUsd !== null && amountUsd !== void 0 ? amountUsd : '0');
7075
+ }
7076
+ }
7077
+ else {
7078
+ return formatAmount(convertUSDToTokenAmount(inputValue, token.price, maxDecimals.token));
7079
+ }
7080
+ }, [inputValue, inputMode, token.price, maxDecimals, direction, amountUsd]);
7081
+ const isInteractive = direction === 'from';
7082
+ const AmountChip = isInteractive ? 'button' : 'div';
7083
+ const priceImpactClass = ((_a = Number(priceImpactPercentage)) !== null && _a !== void 0 ? _a : 0) > Number(criticalPriceImpactPercentage)
7084
+ ? 'tw-text-status-negative'
7085
+ : 'tw-text-grey-300';
7086
+ const BalanceChipTag = isInteractive ? 'button' : 'div';
7087
+ const balanceFormatted = React.useMemo(() => {
7088
+ return formatAmount(balance !== null && balance !== void 0 ? balance : '0');
7089
+ }, [balance]);
7090
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isInteractive ? (jsxRuntime.jsxs("form", { className: "tw-relative tw-px-squid-m tw-pb-[15px] tw-pt-[5px] tw-text-heading-small tw-font-heading-regular", onSubmit: (e) => {
7091
+ e.preventDefault();
7092
+ }, children: [inputMode === InputMode.USD && (jsxRuntime.jsx("span", { className: "tw-absolute tw-left-[30px] tw-top-[11px] tw-leading-[43px] tw-text-grey-600", children: "$" })), jsxRuntime.jsx("input", { type: "text", value: inputValue, onChange: handleInputChange, placeholder: "0", className: cn('tw-h-[55px] tw-w-full tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-grey-300 placeholder:tw-text-grey-600 hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin focus:tw-text-royal-400 focus:tw-outline-none', inputMode === InputMode.USD && 'tw-pl-[33px]') })] })) : (jsxRuntime.jsx("div", { className: cn('tw-w-full tw-px-squid-m tw-pb-[15px] tw-pt-[5px]', isLoading && 'tw-opacity-50'), children: jsxRuntime.jsx("div", { className: "tw-flex tw-h-[55px] tw-w-full tw-items-center tw-rounded-squid-s tw-bg-transparent tw-px-squid-xs tw-py-squid-s tw-text-heading-small tw-font-heading-regular tw-text-grey-300", children: jsxRuntime.jsx("span", { children: inputValue }) }) })), !showDetails ? null : (jsxRuntime.jsxs("footer", { className: cn('tw-flex tw-h-squid-m tw-max-h-squid-m tw-items-center tw-justify-between tw-gap-2 tw-px-squid-m tw-text-grey-500', isLoading && 'tw-opacity-50'), children: [error ? (jsxRuntime.jsx("div", { className: "tw-px-squid-xs", children: jsxRuntime.jsx(ErrorMessage, { message: error.message }) })) : (jsxRuntime.jsxs(AmountChip, { onClick: isInteractive ? handleSwitchInputMode : undefined, className: cn(buttonClassName, isInteractive && interactiveChipClassName), children: [jsxRuntime.jsx(SwapInputsIcon, {}), inputMode === InputMode.TOKEN ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("span", { className: "tw-flex tw-items-center tw-text-grey-500", children: [jsxRuntime.jsxs(CaptionText, { className: "tw-opacity-66", children: [isUsdAmountVerySmall ? '<' : '', "$"] }), jsxRuntime.jsx(CaptionText, { children: isUsdAmountVerySmall
7093
+ ? formatIfVerySmall.token
7094
+ : amountFormatted })] }) })) : (jsxRuntime.jsxs("span", { className: "tw-text-grey-500", children: [isTokenAmountVerySmall ? '<' : '', jsxRuntime.jsx(CaptionText, { children: isTokenAmountVerySmall
7095
+ ? formatIfVerySmall.token
7096
+ : amountFormatted }), ' ', jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: token.symbol })] })), priceImpactPercentage && direction === 'to' ? (jsxRuntime.jsxs("span", { className: cn('tw-flex tw-items-center', priceImpactClass), children: [jsxRuntime.jsx(ArrowTriangle, {}), jsxRuntime.jsx(CaptionText, { bold: true, children: priceImpactPercentage.toString().concat('%') })] })) : null] })), jsxRuntime.jsxs(BalanceChipTag, { onClick: onBalanceButtonClick, className: cn(buttonClassName, isInteractive && interactiveChipClassName), children: [jsxRuntime.jsx(CaptionText, { className: "tw-opacity-66", children: "Balance" }), jsxRuntime.jsxs(CaptionText, { children: [balanceFormatted, " ", token.symbol] }), jsxRuntime.jsx(MaxIcon, {})] })] }))] }));
7097
+ }
7098
+
7099
+ function SettingsSlider({ value, type, onChange, hasDecimals, max, min, }) {
7100
+ return (jsxRuntime.jsxs("div", { className: "tw-relative tw-flex tw-h-full tw-items-center tw-justify-center tw-rounded-squid-xs", children: [jsxRuntime.jsx("input", { min: min !== null && min !== void 0 ? min : 0, max: max !== null && max !== void 0 ? max : 99, step: hasDecimals ? 0.1 : 1, placeholder: "0", type: "number", onChange: (e) => {
7101
+ onChange === null || onChange === void 0 ? void 0 : onChange(Number(e.target.value));
7102
+ }, className: cn('tw-relative tw-flex tw-h-full tw-items-center tw-justify-center tw-self-stretch tw-rounded-squid-xs tw-bg-transparent tw-p-squid-xs tw-text-caption !tw-font-medium tw-leading-[10px] tw-text-grey-300 placeholder-shown:tw-text-grey-600 hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin', type === 'percentage'
7103
+ ? 'tw-w-[84px] tw-pr-[52px] tw-text-right'
7104
+ : 'tw-w-[80px] tw-pl-[20px] tw-pr-[32px] tw-text-left'), value: value }), type === 'percentage' && jsxRuntime.jsx(PercentageDecorator, {}), type === 'amount' && jsxRuntime.jsx(AmountDecorator, {})] }));
7105
+ }
7106
+ function PercentageDecorator() {
7107
+ return (jsxRuntime.jsxs("div", { className: "tw-absolute tw-right-squid-xs tw-flex tw-items-center tw-justify-center tw-gap-squid-xs !tw-font-medium tw-leading-[10px]", children: [jsxRuntime.jsx(CaptionText, { className: "tw-translate-y-[0.5px] !tw-font-medium !tw-leading-[10px] tw-text-grey-300", children: "%" }), jsxRuntime.jsx(Chip, { icon: jsxRuntime.jsx(ChevronGrabberVerticalIcon, { className: "tw-text-grey-900" }) })] }));
7108
+ }
7109
+ function AmountDecorator() {
7110
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CaptionText, { className: "tw-absolute tw-left-squid-xs tw-translate-y-[0.5px] !tw-font-medium !tw-leading-[10px] tw-text-grey-300", children: "$" }), jsxRuntime.jsx("div", { className: "tw-absolute tw-right-squid-xs tw-flex tw-items-center tw-justify-center tw-gap-squid-xs !tw-font-medium tw-leading-[10px]", children: jsxRuntime.jsx(Chip, { icon: jsxRuntime.jsx(ChevronGrabberVerticalIcon, { className: "tw-text-grey-900" }) }) })] }));
7111
+ }
7112
+
7113
+ const switchSizeClassMap = {
7114
+ small: 'tw-w-[36px] tw-h-squid-m tw-p-0.5',
7115
+ large: 'tw-w-[54px] tw-h-squid-l tw-p-[3px]',
7116
+ };
7117
+ const switchKnobSizeClassMap = {
7118
+ small: 'tw-w-4 tw-h-4',
7119
+ large: 'tw-w-6 tw-h-6',
7120
+ };
7121
+ const switchKnobCheckedClassMap = {
7122
+ large: {
7123
+ checked: 'tw-left-[26px]',
7124
+ unchecked: 'tw-left-[2px]',
7125
+ },
7126
+ small: {
7127
+ checked: 'tw-left-[17px]',
7128
+ unchecked: 'tw-left-[1px]',
7129
+ },
7130
+ };
7131
+ function Switch({ checked = false, onChange, size, disabled = false, }) {
7132
+ return (
7133
+ // Switch container
7134
+ jsxRuntime.jsxs("label", { className: clsx('tw-relative tw-inline-flex tw-items-center tw-justify-end tw-overflow-hidden tw-rounded-squid-m tw-border tw-border-material-light-thin tw-transition-colors',
7135
+ // size styles
7136
+ switchSizeClassMap[size],
7137
+ // checked styles
7138
+ checked ? 'tw-bg-status-positive' : 'tw-bg-grey-800',
7139
+ // disabled styles
7140
+ disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'), children: [jsxRuntime.jsx("input", { disabled: disabled, checked: checked, onChange: disabled ? undefined : (e) => onChange === null || onChange === void 0 ? void 0 : onChange(e.target.checked), type: "checkbox", className: "tw-peer tw-sr-only" }), jsxRuntime.jsx("span", { style: {
7141
+ filter: 'drop-shadow(0px 5px 20px rgba(0, 0, 0, 0.33)) drop-shadow(0px 2px 5px rgba(0, 0, 0, 0.20))',
7142
+ }, className: clsx('tw-absolute tw-rounded-full tw-border tw-border-material-light-thin tw-transition-all',
7143
+ // size styles
7144
+ switchKnobSizeClassMap[size],
7145
+ // checked styles
7146
+ switchKnobCheckedClassMap[size][checked ? 'checked' : 'unchecked'], checked
7147
+ ? 'group-data-[squid-theme-type=dark]:tw-bg-grey-100 group-data-[squid-theme-type=light]:tw-bg-grey-900'
7148
+ : 'tw-bg-grey-500') })] }));
7149
+ }
7150
+
7151
+ const tooltipWidthClassMap = {
7152
+ max: 'tw-w-max',
7153
+ container: 'tw-w-full',
7154
+ };
7155
+ const tooltipThresholdClassMap = {
7156
+ xxs: 'tw-pb-squid-xxs',
7157
+ xs: 'tw-pb-squid-xs',
7158
+ s: 'tw-pb-squid-s',
7159
+ m: 'tw-pb-squid-m',
7160
+ l: 'tw-pb-squid-l',
7161
+ xl: 'tw-pb-squid-xl',
7162
+ xxl: 'tw-pb-squid-xxl',
7163
+ };
7164
+ function Tooltip({ children, tooltipContent, tooltipWidth = 'container', threshold = 'xxs', containerClassName, childrenClassName, tooltipClassName, displayDelayMs = 0, }) {
7165
+ return (jsxRuntime.jsxs("div", { className: cn('tw-relative', containerClassName), children: [jsxRuntime.jsx("div", { className: cn('tw-peer', childrenClassName), children: children }), tooltipContent ? (jsxRuntime.jsx(Menu, { style: {
7166
+ [CSS_VARS.DISPLAY_DELAYED_DURATION]: `${displayDelayMs}ms`,
7167
+ }, containerClassName: cn(
7168
+ // general styles
7169
+ 'tw-absolute tw-z-40 tw-bottom-full tw-left-1/2 -tw-translate-x-1/2',
7170
+ // visibility styles. Display only on hover
7171
+ 'tw-animate-hide peer-hover:tw-animate-display-delayed hover:tw-animate-display-delayed', tooltipWidthClassMap[tooltipWidth], tooltipThresholdClassMap[threshold], tooltipClassName), children: tooltipContent })) : null] }));
7172
+ }
7173
+
7174
+ function BoostButton({ boostMode, canToggleBoostMode = true, boostDisabledMessage = 'Boost disabled', tooltipDisplayDelayMs = 0, boostIndicatorRef, }) {
7175
+ return (jsxRuntime.jsx(Tooltip, { tooltipWidth: "max", displayDelayMs: tooltipDisplayDelayMs, tooltipContent: canToggleBoostMode ? null : boostDisabledMessage, children: jsxRuntime.jsxs("div", { className: "tw-relative tw-flex tw-h-squid-xl tw-w-[140px] tw-flex-col tw-justify-between tw-overflow-hidden tw-rounded-squid-m tw-pb-squid-xxs tw-text-grey-300 focus:tw-outline-none", children: [jsxRuntime.jsx("span", { className: cn('tw-absolute tw-left-0 tw-top-0 tw-z-10 tw-h-full tw-w-8 tw-bg-gradient-to-r tw-from-grey-900 tw-to-transparent', canToggleBoostMode &&
7176
+ 'group-hover/boost-toggle:tw-from-material-light-blend-grey-900') }), jsxRuntime.jsx("span", { className: cn('tw-absolute tw-right-0 tw-top-0 tw-z-10 tw-h-full tw-w-8 tw-bg-gradient-to-l tw-from-grey-900 tw-to-transparent', canToggleBoostMode &&
7177
+ 'group-hover/boost-toggle:tw-from-material-light-blend-grey-900') }), jsxRuntime.jsxs("div", { ref: boostIndicatorRef, "data-boost-mode": boostMode, className: "tw-group tw-peer tw-flex tw-h-full tw-w-full tw-items-center tw-justify-between tw-transition-transform group-disabled/boost-toggle:tw-grayscale data-[boost-mode=boost]:tw-animate-move-to-left-with-spring-bounce data-[boost-mode=normal]:tw-animate-move-to-right-with-spring-bounce", children: [jsxRuntime.jsx("div", { className: "tw-w-1/2 tw-text-center group-disabled/boost-toggle:tw-grayscale", children: jsxRuntime.jsx(BodyText, { size: "small", className: "tw-text-grey-300", children: "Normal" }) }), jsxRuntime.jsxs("div", { className: "tw-w-1/2 tw-text-center group-disabled/boost-toggle:tw-grayscale", children: [jsxRuntime.jsx(BodyText, { size: "small", className: "tw-text-status-positive", children: "Boost" }), ' '] }), jsxRuntime.jsx("div", { className: "tw-absolute tw-bottom-0 tw-h-1.5 tw-w-[1.5px] tw-rounded-sm tw-bg-grey-500 tw-text-grey-500 group-data-[boost-mode=boost]:tw-left-[calc(50%-2px)] group-data-[boost-mode=normal]:tw-left-[calc(50%-6px)]", style: {
7178
+ boxShadow: generateMarkerLines(40),
7179
+ } })] }), jsxRuntime.jsx("div", { className: cn('tw-absolute tw-bottom-0.5 tw-left-[calc(50%-1.5px)] tw-z-20 tw-h-[10px] tw-w-[3px] tw-rounded-sm tw-transition-colors group-disabled/boost-toggle:tw-grayscale peer-data-[boost-mode=boost]:tw-bg-status-positive peer-data-[boost-mode=normal]:tw-bg-current'), style: {
7180
+ transitionDuration: `${ANIMATION_DURATIONS.BOOST_BUTTON}ms`,
7181
+ } })] }) }));
7182
+ }
7183
+ function generateMarkerLines(count) {
7184
+ const halfCount = Math.ceil(count / 2);
7185
+ const rightShadows = Array.from({ length: halfCount }, (_, index) => {
7186
+ return `-${(index + 1) * 6}px 0 currentColor`;
7187
+ });
7188
+ const leftShadows = Array.from({ length: halfCount }, (_, index) => {
7189
+ return `${(index + 1) * 6}px 0 currentColor`;
7190
+ });
7191
+ const allShadows = [...rightShadows, ...leftShadows];
7192
+ return allShadows.join(', ');
7193
+ }
7194
+
7195
+ function SettingsButton({ label, isSelected = false, onClick, }) {
7196
+ return (jsxRuntime.jsx("button", { onClick: onClick, className: cn('tw-flex tw-items-center tw-justify-center tw-self-stretch tw-rounded-squid-xs tw-border-2 tw-border-transparent tw-p-squid-xs hover:tw-bg-material-light-thin focus:tw-bg-material-light-thin', isSelected && 'tw-outline-royal-500'), children: jsxRuntime.jsx(CaptionText, { className: "!tw-font-medium", children: label }) }));
7197
+ }
7198
+
6677
7199
  var v$5 = "5.10.0";
6678
7200
  var fr$5 = 25;
6679
7201
  var ip$5 = 0;