@xyo-network/chain-sdk 4.4.0 → 4.5.1
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/browser/modules/ethereum/block/index.d.ts +0 -2
- package/dist/browser/modules/ethereum/block/index.d.ts.map +1 -1
- package/dist/browser/modules/ethereum/index.d.ts +0 -2
- package/dist/browser/modules/ethereum/index.d.ts.map +1 -1
- package/dist/browser/modules/ethereum/indexing/index.d.ts +0 -1
- package/dist/browser/modules/ethereum/indexing/index.d.ts.map +1 -1
- package/dist/browser/modules/ethereum/providers/AbstractEvmRunner.d.ts +2 -2
- package/dist/browser/modules/ethereum/providers/AbstractEvmRunner.d.ts.map +1 -1
- package/dist/browser/modules/ethereum/providers/index.d.ts +0 -4
- package/dist/browser/modules/ethereum/providers/index.d.ts.map +1 -1
- package/dist/browser/modules/telemetry/TelemetryProviders.d.ts +2 -0
- package/dist/browser/modules/telemetry/TelemetryProviders.d.ts.map +1 -1
- package/dist/browser/modules/telemetry/createTelemetryGlobalCleanup.d.ts +16 -0
- package/dist/browser/modules/telemetry/createTelemetryGlobalCleanup.d.ts.map +1 -0
- package/dist/browser/modules/telemetry/createTelemetryShutdown.d.ts +10 -0
- package/dist/browser/modules/telemetry/createTelemetryShutdown.d.ts.map +1 -0
- package/dist/browser/modules/telemetry/initTelemetry.d.ts.map +1 -1
- package/dist/browser/modules/telemetry/initTelemetryNode.d.ts.map +1 -1
- package/dist/browser/telemetry.mjs +144 -29
- package/dist/browser/telemetry.mjs.map +4 -4
- package/dist/neutral/ethereum.mjs +1 -149
- package/dist/neutral/ethereum.mjs.map +4 -4
- package/dist/neutral/modules/ethereum/block/index.d.ts +0 -2
- package/dist/neutral/modules/ethereum/block/index.d.ts.map +1 -1
- package/dist/neutral/modules/ethereum/index.d.ts +0 -2
- package/dist/neutral/modules/ethereum/index.d.ts.map +1 -1
- package/dist/neutral/modules/ethereum/indexing/index.d.ts +0 -1
- package/dist/neutral/modules/ethereum/indexing/index.d.ts.map +1 -1
- package/dist/neutral/modules/ethereum/providers/AbstractEvmRunner.d.ts +2 -2
- package/dist/neutral/modules/ethereum/providers/AbstractEvmRunner.d.ts.map +1 -1
- package/dist/neutral/modules/ethereum/providers/index.d.ts +0 -4
- package/dist/neutral/modules/ethereum/providers/index.d.ts.map +1 -1
- package/dist/neutral/modules/telemetry/TelemetryProviders.d.ts +2 -0
- package/dist/neutral/modules/telemetry/TelemetryProviders.d.ts.map +1 -1
- package/dist/neutral/modules/telemetry/createTelemetryGlobalCleanup.d.ts +16 -0
- package/dist/neutral/modules/telemetry/createTelemetryGlobalCleanup.d.ts.map +1 -0
- package/dist/neutral/modules/telemetry/createTelemetryShutdown.d.ts +10 -0
- package/dist/neutral/modules/telemetry/createTelemetryShutdown.d.ts.map +1 -0
- package/dist/neutral/modules/telemetry/initTelemetry.d.ts.map +1 -1
- package/dist/neutral/modules/telemetry/initTelemetryNode.d.ts.map +1 -1
- package/dist/neutral/services.mjs +1 -1
- package/dist/neutral/services.mjs.map +2 -2
- package/dist/neutral/telemetry.mjs +144 -29
- package/dist/neutral/telemetry.mjs.map +4 -4
- package/dist/neutral/utils.mjs +2 -2
- package/dist/neutral/utils.mjs.map +2 -2
- package/dist/neutral/validation.mjs +1 -1
- package/dist/neutral/validation.mjs.map +2 -2
- package/dist/node/modules/ethereum/block/index.d.ts +0 -2
- package/dist/node/modules/ethereum/block/index.d.ts.map +1 -1
- package/dist/node/modules/ethereum/index.d.ts +0 -2
- package/dist/node/modules/ethereum/index.d.ts.map +1 -1
- package/dist/node/modules/ethereum/indexing/index.d.ts +0 -1
- package/dist/node/modules/ethereum/indexing/index.d.ts.map +1 -1
- package/dist/node/modules/ethereum/providers/AbstractEvmRunner.d.ts +2 -2
- package/dist/node/modules/ethereum/providers/AbstractEvmRunner.d.ts.map +1 -1
- package/dist/node/modules/ethereum/providers/index.d.ts +0 -4
- package/dist/node/modules/ethereum/providers/index.d.ts.map +1 -1
- package/dist/node/modules/telemetry/TelemetryProviders.d.ts +2 -0
- package/dist/node/modules/telemetry/TelemetryProviders.d.ts.map +1 -1
- package/dist/node/modules/telemetry/createTelemetryGlobalCleanup.d.ts +16 -0
- package/dist/node/modules/telemetry/createTelemetryGlobalCleanup.d.ts.map +1 -0
- package/dist/node/modules/telemetry/createTelemetryShutdown.d.ts +10 -0
- package/dist/node/modules/telemetry/createTelemetryShutdown.d.ts.map +1 -0
- package/dist/node/modules/telemetry/initTelemetry.d.ts.map +1 -1
- package/dist/node/modules/telemetry/initTelemetryNode.d.ts.map +1 -1
- package/dist/node/telemetry.mjs +152 -32
- package/dist/node/telemetry.mjs.map +4 -4
- package/package.json +8 -8
- package/dist/browser/modules/ethereum/block/estimateBlockNumberAt.d.ts +0 -2
- package/dist/browser/modules/ethereum/block/estimateBlockNumberAt.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/block/findContractDeploymentBlock.d.ts +0 -2
- package/dist/browser/modules/ethereum/block/findContractDeploymentBlock.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/drivers/EvmStakeEventZod.d.ts +0 -2
- package/dist/browser/modules/ethereum/drivers/EvmStakeEventZod.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/drivers/EvmStakeEventsViewer.d.ts +0 -2
- package/dist/browser/modules/ethereum/drivers/EvmStakeEventsViewer.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/drivers/EvmStakeViewer.d.ts +0 -2
- package/dist/browser/modules/ethereum/drivers/EvmStakeViewer.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/drivers/index.d.ts +0 -4
- package/dist/browser/modules/ethereum/drivers/index.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/providers/AbstractEvmProvider.d.ts +0 -2
- package/dist/browser/modules/ethereum/providers/AbstractEvmProvider.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/providers/AbstractEvmViewer.d.ts +0 -2
- package/dist/browser/modules/ethereum/providers/AbstractEvmViewer.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/providers/EvmChainContractViewer.d.ts +0 -2
- package/dist/browser/modules/ethereum/providers/EvmChainContractViewer.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/providers/EvmStakeTotalsViewer.d.ts +0 -2
- package/dist/browser/modules/ethereum/providers/EvmStakeTotalsViewer.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/rpc/index.d.ts +0 -4
- package/dist/browser/modules/ethereum/rpc/index.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/rpc/isRpcRangeLimitError.d.ts +0 -2
- package/dist/browser/modules/ethereum/rpc/isRpcRangeLimitError.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/rpc/isRpcRateLimitError.d.ts +0 -2
- package/dist/browser/modules/ethereum/rpc/isRpcRateLimitError.d.ts.map +0 -1
- package/dist/browser/modules/ethereum/rpc/withRpcRateLimitBackoff.d.ts +0 -2
- package/dist/browser/modules/ethereum/rpc/withRpcRateLimitBackoff.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/block/estimateBlockNumberAt.d.ts +0 -2
- package/dist/neutral/modules/ethereum/block/estimateBlockNumberAt.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/block/findContractDeploymentBlock.d.ts +0 -2
- package/dist/neutral/modules/ethereum/block/findContractDeploymentBlock.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/drivers/EvmStakeEventZod.d.ts +0 -2
- package/dist/neutral/modules/ethereum/drivers/EvmStakeEventZod.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/drivers/EvmStakeEventsViewer.d.ts +0 -2
- package/dist/neutral/modules/ethereum/drivers/EvmStakeEventsViewer.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/drivers/EvmStakeViewer.d.ts +0 -2
- package/dist/neutral/modules/ethereum/drivers/EvmStakeViewer.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/drivers/index.d.ts +0 -4
- package/dist/neutral/modules/ethereum/drivers/index.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/providers/AbstractEvmProvider.d.ts +0 -2
- package/dist/neutral/modules/ethereum/providers/AbstractEvmProvider.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/providers/AbstractEvmViewer.d.ts +0 -2
- package/dist/neutral/modules/ethereum/providers/AbstractEvmViewer.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/providers/EvmChainContractViewer.d.ts +0 -2
- package/dist/neutral/modules/ethereum/providers/EvmChainContractViewer.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/providers/EvmStakeTotalsViewer.d.ts +0 -2
- package/dist/neutral/modules/ethereum/providers/EvmStakeTotalsViewer.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/rpc/index.d.ts +0 -4
- package/dist/neutral/modules/ethereum/rpc/index.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/rpc/isRpcRangeLimitError.d.ts +0 -2
- package/dist/neutral/modules/ethereum/rpc/isRpcRangeLimitError.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/rpc/isRpcRateLimitError.d.ts +0 -2
- package/dist/neutral/modules/ethereum/rpc/isRpcRateLimitError.d.ts.map +0 -1
- package/dist/neutral/modules/ethereum/rpc/withRpcRateLimitBackoff.d.ts +0 -2
- package/dist/neutral/modules/ethereum/rpc/withRpcRateLimitBackoff.d.ts.map +0 -1
- package/dist/node/modules/ethereum/block/estimateBlockNumberAt.d.ts +0 -2
- package/dist/node/modules/ethereum/block/estimateBlockNumberAt.d.ts.map +0 -1
- package/dist/node/modules/ethereum/block/findContractDeploymentBlock.d.ts +0 -2
- package/dist/node/modules/ethereum/block/findContractDeploymentBlock.d.ts.map +0 -1
- package/dist/node/modules/ethereum/drivers/EvmStakeEventZod.d.ts +0 -2
- package/dist/node/modules/ethereum/drivers/EvmStakeEventZod.d.ts.map +0 -1
- package/dist/node/modules/ethereum/drivers/EvmStakeEventsViewer.d.ts +0 -2
- package/dist/node/modules/ethereum/drivers/EvmStakeEventsViewer.d.ts.map +0 -1
- package/dist/node/modules/ethereum/drivers/EvmStakeViewer.d.ts +0 -2
- package/dist/node/modules/ethereum/drivers/EvmStakeViewer.d.ts.map +0 -1
- package/dist/node/modules/ethereum/drivers/index.d.ts +0 -4
- package/dist/node/modules/ethereum/drivers/index.d.ts.map +0 -1
- package/dist/node/modules/ethereum/providers/AbstractEvmProvider.d.ts +0 -2
- package/dist/node/modules/ethereum/providers/AbstractEvmProvider.d.ts.map +0 -1
- package/dist/node/modules/ethereum/providers/AbstractEvmViewer.d.ts +0 -2
- package/dist/node/modules/ethereum/providers/AbstractEvmViewer.d.ts.map +0 -1
- package/dist/node/modules/ethereum/providers/EvmChainContractViewer.d.ts +0 -2
- package/dist/node/modules/ethereum/providers/EvmChainContractViewer.d.ts.map +0 -1
- package/dist/node/modules/ethereum/providers/EvmStakeTotalsViewer.d.ts +0 -2
- package/dist/node/modules/ethereum/providers/EvmStakeTotalsViewer.d.ts.map +0 -1
- package/dist/node/modules/ethereum/rpc/index.d.ts +0 -4
- package/dist/node/modules/ethereum/rpc/index.d.ts.map +0 -1
- package/dist/node/modules/ethereum/rpc/isRpcRangeLimitError.d.ts +0 -2
- package/dist/node/modules/ethereum/rpc/isRpcRangeLimitError.d.ts.map +0 -1
- package/dist/node/modules/ethereum/rpc/isRpcRateLimitError.d.ts +0 -2
- package/dist/node/modules/ethereum/rpc/isRpcRateLimitError.d.ts.map +0 -1
- package/dist/node/modules/ethereum/rpc/withRpcRateLimitBackoff.d.ts +0 -2
- package/dist/node/modules/ethereum/rpc/withRpcRateLimitBackoff.d.ts.map +0 -1
package/dist/neutral/utils.mjs
CHANGED
|
@@ -126,7 +126,7 @@ function formatNumberForDisplay(value, significantFigures = 5, bigIntShift = 18)
|
|
|
126
126
|
if (!isFloat) {
|
|
127
127
|
return safeReturnInteger(resolvedValue);
|
|
128
128
|
}
|
|
129
|
-
const [whole, fraction] = resolvedValue.split(".");
|
|
129
|
+
const [whole, fraction] = resolvedValue.split(".", 2);
|
|
130
130
|
if (whole.length >= significantFigures) {
|
|
131
131
|
return isUnsafeInteger(whole) ? {
|
|
132
132
|
unsafeInteger: true,
|
|
@@ -154,7 +154,7 @@ function formatNumberForDisplay(value, significantFigures = 5, bigIntShift = 18)
|
|
|
154
154
|
// src/modules/utils/conversion/units.ts
|
|
155
155
|
var parseBigIntDecimal = (value, decimal) => {
|
|
156
156
|
const valueString = typeof value === "number" || typeof value === "bigint" ? value.toString(10) : value;
|
|
157
|
-
const [intPart, fracPart = "0"] = valueString.split(".");
|
|
157
|
+
const [intPart, fracPart = "0"] = valueString.split(".", 2);
|
|
158
158
|
const fracPartLength = Math.min(fracPart.length, decimal);
|
|
159
159
|
const trimmedFracPart = fracPart.slice(0, fracPartLength);
|
|
160
160
|
const intPartBigInt = BigInt(Number.parseInt(intPart)) * 10n ** BigInt(decimal);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/modules/utils/archivist/findFirstMatching.ts", "../../src/modules/utils/archivist/payloadsToArchivist.ts", "../../src/modules/utils/archivist/synchronizeArchivists.ts", "../../src/modules/utils/conversion/units.ts", "../../src/modules/utils/formatters/string/removeTrailingZeros.ts", "../../src/modules/utils/formatters/string/bigIntToFixedPointString.ts", "../../src/modules/utils/formatters/string/formatNumber.ts", "../../src/modules/utils/hex/hexToLastFourBytesInt.ts", "../../src/modules/utils/interval/IntervalMap.ts", "../../src/modules/utils/interval/IntervalTree.ts", "../../src/modules/utils/random/shuffleWithSeed.ts", "../../src/modules/utils/steps/calculator/window/stepWindowCalculatorFromBlock.ts", "../../src/modules/utils/telemetry/startupSpanAsync.ts", "../../src/modules/utils/telemetry/XyoConsoleSpanExporter.ts"],
|
|
4
|
-
"sourcesContent": ["import { isDefined } from '@ariestools/sdk'\nimport type {\n ArchivistNextOptions, Payload, ReadArchivist,\n Sequence, WithStorageMeta,\n} from '@xyo-network/sdk'\n\nexport const DEFAULT_FIND_FIRST_MATCHING_NEXT_OPTIONS: ArchivistNextOptions = {\n limit: 100,\n open: false,\n order: 'desc',\n}\n\n/**\n * Find the first payload that matches the predicate from the archivist\n * @param archivist The archivist to search\n * @param predicate The predicate to match\n * @param nextOptions The default options for the next call\n * @returns The first payload that matches the predicate\n */\nexport const findFirstMatching = async (\n archivist: ReadArchivist,\n predicate: (p: WithStorageMeta<Payload>) => boolean = () => true,\n nextOptions: ArchivistNextOptions = DEFAULT_FIND_FIRST_MATCHING_NEXT_OPTIONS,\n): Promise<WithStorageMeta<Payload> | undefined> => {\n let cursor: Sequence | undefined = isDefined(nextOptions.cursor) ? nextOptions.cursor : undefined\n let batch: WithStorageMeta<Payload>[]\n do {\n // Get the next batch from the archivist\n batch = await archivist.next({ ...nextOptions, cursor: cursor })\n // If the batch is empty there's nothing left to check\n if (batch.length === 0) break\n // Filter batch using predicate\n const found = batch.find(p => predicate(p))\n if (found) return found\n // Update the cursor\n const updatedCursor = batch.at(-1)?._sequence\n if (isDefined(updatedCursor)) cursor = updatedCursor\n } while (batch.length > 0)\n return undefined\n}\n", "import type { ArchivistInstance, Payload } from '@xyo-network/sdk'\nimport { Account, MemoryArchivist } from '@xyo-network/sdk'\n\nexport const payloadsToArchivist = async (payloads: Payload[]): Promise<ArchivistInstance> => {\n const archivist = await MemoryArchivist.create({ account: await Account.random() })\n await archivist.insert(payloads)\n return archivist\n}\n", "import { isDefined } from '@ariestools/sdk'\nimport type {\n ArchivistInstance, Payload, ReadArchivist,\n Sequence, WithStorageMeta,\n} from '@xyo-network/sdk'\n\nimport { findFirstMatching } from './findFirstMatching.ts'\n\n/**\n * Synchronize two archivists\n * @param source The source archivist\n * @param destination The destination archivist\n * @param sourceCursor The cursor for the source archivist\n * @param predicate A predicate to filter payloads for the first matching payload\n * @param filter A predicate to filter payloads for all the payloads\n * @returns The next cursor to use for the source archivist\n */\nexport const synchronizeArchivists = async (\n source: ReadArchivist,\n destination: ArchivistInstance,\n sourceCursor?: Sequence,\n predicate: (payload: WithStorageMeta<Payload>) => boolean = () => true,\n filter: (payload: WithStorageMeta<Payload>) => boolean = () => true,\n): Promise<Sequence | undefined> => {\n const destLast = await findFirstMatching(destination, predicate)\n const sourceLast = await findFirstMatching(source, predicate)\n // If there's nothing in the source, there is nothing to sync\n if (!sourceLast) return\n if (destLast) {\n const sourcePayloadResult = await source.get([destLast._hash])\n const sourcePayload = sourcePayloadResult.at(0)\n if (sourcePayload) {\n sourceCursor = sourcePayload._sequence\n } else {\n // Corrupt local DB, delete and re-sync\n throw new Error('Local DB is out of sync with source')\n }\n } else {\n // If there's nothing in the local, sync everything\n // Grab the first payload from the source archivist\n const sourceFirstResult = await source.next({\n open: false, limit: 1, order: 'asc',\n })\n const sourceFirst = sourceFirstResult.at(0)\n // If there are any payloads in the source archivist\n if (sourceFirst) {\n // Insert the first payload into the local archivist\n await destination.insert([sourceFirst].filter(filter))\n // Update the cursor to start there\n sourceCursor = sourceFirst._sequence\n } else {\n // source DB is empty, nothing to sync\n return\n }\n }\n\n let batch: WithStorageMeta<Payload>[]\n do {\n // Get the next batch from the source archivist\n batch = await source.next({\n open: true, limit: 500, order: 'asc', cursor: sourceCursor,\n })\n\n // If the batch is empty there's nothing left to sync\n if (batch.length === 0) break\n // Update the cursor\n const updatedCursor = batch.at(-1)?._sequence\n if (isDefined(updatedCursor)) sourceCursor = updatedCursor\n // Insert the batch into the local archivist\n await destination.insert(batch.filter(filter))\n console.log('syncing batch', sourceCursor, batch.length)\n console.log('batch sequences', batch.map(b => b._sequence))\n } while (batch.length > 0)\n return sourceCursor\n}\n", "import { XL1 } from '@xyo-network/xl1-sdk'\n\nimport { removeTrailingZeros } from '../formatters/index.ts'\n\nexport type BigIntDecimal = string | number | bigint\n\nconst parseBigIntDecimal = (value: BigIntDecimal, decimal: number): XL1 => {\n const valueString = (typeof value === 'number') || (typeof value === 'bigint') ? value.toString(10) : value\n const [intPart, fracPart = '0'] = valueString.split('.')\n const fracPartLength = Math.min(fracPart.length, decimal)\n\n // Handle max decimals\n const trimmedFracPart = fracPart.slice(0, fracPartLength)\n\n const intPartBigInt = BigInt(Number.parseInt(intPart)) * (10n ** BigInt(decimal))\n const fracPartBigInt = BigInt(Number.parseInt(trimmedFracPart)) * (10n ** BigInt(decimal - trimmedFracPart.length))\n const valueBigInt = intPartBigInt + fracPartBigInt\n return XL1(valueBigInt)\n}\n\nconst bigIntFormat = (value: bigint, decimal: number): string => {\n const intPart = value / (10n ** BigInt(decimal))\n const fracPart = value - intPart * (10n ** BigInt(decimal))\n const fracPartString = fracPart.toString().padStart(decimal, '0')\n\n return removeTrailingZeros(`${intPart}.${fracPartString}`)\n}\n\nexport const formattedMXL1toXl1 = (value: string | number | bigint): string => {\n return bigIntFormat(parseBigIntDecimal(value, 12), 18)\n}\n", "export const removeTrailingZeros = (value: string): string => {\n let i = value.length - 1\n while (i >= 0 && value[i] === '0') {\n i--\n }\n return value.slice(0, i + 1)\n}\n", "import { removeTrailingZeros } from './removeTrailingZeros.ts'\n\nexport const bigIntToFixedPointString = (value: bigint, decimalPlaces = 18): string => {\n const stringValue = value.toString(10)\n const splitAtIndex = (value: string, index: number): [string, string] => {\n const part1 = value.slice(0, index)\n const part2 = value.slice(index)\n return [part1, part2]\n }\n\n const floatable = stringValue.length > decimalPlaces\n if (floatable) {\n const [whole, fraction] = splitAtIndex(stringValue, stringValue.length - decimalPlaces)\n const cleanedFraction = removeTrailingZeros(fraction)\n return cleanedFraction.length > 0 ? `${whole}.${cleanedFraction}` : whole\n }\n if (stringValue === '0') return stringValue\n const cleanedFraction = removeTrailingZeros(stringValue)\n return `0.${'0'.repeat(decimalPlaces - stringValue.length)}${cleanedFraction}`\n}\n", "import { bigIntToFixedPointString } from './bigIntToFixedPointString.ts'\nimport { removeTrailingZeros } from './removeTrailingZeros.ts'\n\nexport interface FloatStringFormatterResults {\n truncatedFloat?: boolean\n unsafeInteger?: boolean\n value: string\n}\n\nconst isUnsafeInteger = (value: string): boolean => {\n try {\n const parsedNumber = BigInt(value)\n return parsedNumber > BigInt(Number.MAX_SAFE_INTEGER)\n } catch (error) {\n console.error('Failed to parse number:', error)\n return true\n }\n}\n\nconst safeReturnInteger = (value: string): FloatStringFormatterResults => {\n return isUnsafeInteger(value)\n ? {\n unsafeInteger: true,\n value,\n }\n : { value }\n}\n\n// Overloaded function signatures\nexport function formatNumberForDisplay(value: bigint, significantFigures?: number, bigIntShift?: number): FloatStringFormatterResults\nexport function formatNumberForDisplay(value: string, significantFigures?: number): FloatStringFormatterResults\n\nexport function formatNumberForDisplay(value: string | bigint, significantFigures = 5, bigIntShift = 18): FloatStringFormatterResults {\n const resolvedValue = typeof value === 'bigint' ? bigIntToFixedPointString(value, bigIntShift) : value\n\n const isFloat = resolvedValue.includes('.')\n if (!isFloat) {\n return safeReturnInteger(resolvedValue)\n }\n\n // If the whole part of the float is greater than or equal to the significant figures, return it as is\n const [whole, fraction] = resolvedValue.split('.')\n if (whole.length >= significantFigures) {\n return isUnsafeInteger(whole)\n ? {\n unsafeInteger: true,\n value: whole,\n }\n : { value: whole }\n }\n const cleanedFraction = fraction.at(-1) === '0' ? removeTrailingZeros(fraction) : fraction\n\n // If the whole part of the float is less than the significant figures and the fraction exists\n const safeWholeNumber = whole.length <= significantFigures\n const safeFraction = cleanedFraction.length <= significantFigures\n\n if (safeWholeNumber) {\n // if we have a safe whole number, the fraction and be trimmed\n if (safeFraction) {\n const show = significantFigures - whole.length\n return { value: `${whole}.${cleanedFraction.slice(0, show)}` }\n }\n // Handle very small numbers\n const leadingZeros = RegExp(/^0+/).exec(cleanedFraction)?.at(0)?.length ?? 0\n const significantPart = cleanedFraction.slice(leadingZeros, leadingZeros + significantFigures)\n return {\n value: `0.0...${significantPart}`,\n truncatedFloat: true,\n }\n }\n // handle very large numbers with a fraction by just returning the whole number\n return safeReturnInteger(whole)\n}\n", "import type { Hex } from '@ariestools/sdk'\nimport { assertEx, isHex } from '@ariestools/sdk'\n\nexport function hexToLast4BytesInt(value: Hex): number {\n assertEx(isHex(value), () => 'value must be a hex string')\n\n // Extract the last 4 bytes (8 characters) of the hex string\n const last4Bytes = value.slice(-8)\n\n // Convert the last 4 bytes to an integer\n return Number.parseInt(last4Bytes, 16)\n}\n", "/* eslint-disable unicorn/prefer-at */\n/* eslint-disable unicorn/prefer-math-min-max */\n\nexport interface Serializable<T> {\n serialize(): T\n}\n\nexport type IntervalMapInterval = [number, number]\n\nexport type SerializedIntervalMap = Record<string, [number, number][]>\n\nexport class IntervalMap<T> implements Serializable<SerializedIntervalMap> {\n private map: Map<T, IntervalMapInterval[]>\n\n constructor(data?: SerializedIntervalMap) {\n this.map = new Map()\n if (data) {\n for (const [key, intervals] of Object.entries(data)) {\n for (const interval of intervals) {\n this.insert(key as T, interval[0], interval[1])\n }\n }\n }\n }\n\n findAllContaining(point: number): readonly T[] {\n const result: T[] = []\n for (const [address, intervals] of this.map) {\n if (intervals.some(([start, end]) => start <= point && point <= end)) {\n result.push(address)\n }\n }\n return result\n }\n\n get(key: T): readonly Readonly<IntervalMapInterval>[] | undefined {\n const intervals = this.map.get(key)\n return intervals ? Object.freeze(intervals.map(interval => Object.freeze(interval))) : undefined\n }\n\n insert(value: T, start: number, end: number): void {\n if (start > end) {\n throw new Error('Invalid interval: start must be less than or equal to end')\n }\n\n const intervals = this.map.get(value) ?? []\n intervals.push([start, end])\n // Merge overlapping intervals\n const merged: IntervalMapInterval[] = []\n for (const [s, e] of intervals) {\n if (merged.length === 0 || merged[merged.length - 1][1] < s) {\n merged.push([s, e])\n } else {\n merged[merged.length - 1][1] = merged[merged.length - 1][1] > e ? merged[merged.length - 1][1] : e\n }\n }\n\n this.map.set(value, merged)\n }\n\n serialize(): SerializedIntervalMap {\n const obj: SerializedIntervalMap = {}\n for (const [key, intervals] of this.map) {\n obj[key as string] = intervals.map(([start, end]) => [start, end])\n }\n return obj\n }\n}\n", "/* eslint-disable max-lines */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable @typescript-eslint/member-ordering */\n// Full credit to: https://github.com/ShieldBattery/node-interval-tree\n// Adapted from original repo as legacy export syntax and would not\n// work with Node & ESM imports\n\n// An augmented AVL Tree where each node maintains a list of records and their search intervals.\n// Record is composed of an interval and its underlying data, sent by a client. This allows the\n// interval tree to have the same interval inserted multiple times, as long its data is different.\n// Both insertion and deletion require O(log n) time. Searching requires O(k*logn) time, where `k`\n// is the number of intervals in the output list.\n\n// import isSame = require('shallowequal')\nimport isSame from 'shallowequal'\n\nexport interface Interval<N extends number | bigint = number> {\n readonly low: N\n readonly high: N\n}\n\nfunction max<N extends number | bigint>(a: N, b: N): N {\n return a > b ? a : b\n}\n\nfunction height<T extends Interval<N>, N extends number | bigint = number>(node?: Node<T, N>) {\n return node === undefined ? -1 : node.height\n}\n\nexport class Node<T extends Interval<N>, N extends number | bigint = number> {\n intervalTree: IntervalTree<T, N>\n key: N\n max: N\n records: T[] = []\n parent?: Node<T, N>\n height = 0\n left?: Node<T, N>\n right?: Node<T, N>\n\n constructor(intervalTree: IntervalTree<T, N>, record: T) {\n this.intervalTree = intervalTree\n this.key = record.low\n this.max = record.high\n\n // Save the array of all records with the same key for this node\n this.records.push(record)\n }\n\n // Gets the highest record.high value for this node\n getNodeHigh() {\n let high = this.records[0].high\n\n for (let i = 1; i < this.records.length; i++) {\n if (this.records[i].high > high) {\n high = this.records[i].high\n }\n }\n\n return high\n }\n\n // Updates height value of the node. Called during insertion, rebalance, removal\n updateHeight() {\n this.height = max(height(this.left), height(this.right)) + 1\n }\n\n // Updates the max value of all the parents after inserting into already existing node, as well as\n // removing the node completely or removing the record of an already existing node. Starts with\n // the parent of an affected node and bubbles up to root\n updateMaxOfParents() {\n if (this === undefined) {\n return\n }\n\n const thisHigh = this.getNodeHigh()\n if (this.left !== undefined && this.right !== undefined) {\n this.max = max(max(this.left.max, this.right.max), thisHigh)\n } else if (this.left !== undefined && this.right === undefined) {\n this.max = max(this.left.max, thisHigh)\n } else if (this.left === undefined && this.right !== undefined) {\n this.max = max(this.right.max, thisHigh)\n } else {\n this.max = thisHigh\n }\n\n if (this.parent) {\n this.parent.updateMaxOfParents()\n }\n }\n\n /*\n Left-Left case:\n\n z y\n / \\ / \\\n y T4 Right Rotate (z) x z\n / \\ - - - - - - - - -> / \\ / \\\n x T3 T1 T2 T3 T4\n / \\\n T1 T2\n\n Left-Right case:\n\n z z x\n / \\ / \\ / \\\n y T4 Left Rotate (y) x T4 Right Rotate(z) y z\n / \\ - - - - - - - - -> / \\ - - - - - - - -> / \\ / \\\n T1 x y T3 T1 T2 T3 T4\n / \\ / \\\n T2 T3 T1 T2\n */\n\n // Handles Left-Left case and Left-Right case after rebalancing AVL tree\n private _updateMaxAfterRightRotate() {\n const parent = this.parent!\n const left = parent.left!\n // Update max of left sibling (x in first case, y in second)\n const thisParentLeftHigh = left.getNodeHigh()\n if (left.left === undefined && left.right !== undefined) {\n left.max = max(thisParentLeftHigh, left.right.max)\n } else if (left.left !== undefined && left.right === undefined) {\n left.max = max(thisParentLeftHigh, left.left.max)\n } else if (left.left === undefined && left.right === undefined) {\n left.max = thisParentLeftHigh\n } else {\n left.max = max(max(left.left!.max, left.right!.max), thisParentLeftHigh)\n }\n\n // Update max of itself (z)\n const thisHigh = this.getNodeHigh()\n if (this.left === undefined && this.right !== undefined) {\n this.max = max(thisHigh, this.right.max)\n } else if (this.left !== undefined && this.right === undefined) {\n this.max = max(thisHigh, this.left.max)\n } else if (this.left === undefined && this.right === undefined) {\n this.max = thisHigh\n } else {\n this.max = max(max(this.left!.max, this.right!.max), thisHigh)\n }\n\n // Update max of parent (y in first case, x in second)\n parent.max = max(max(parent.left!.max, parent.right!.max), parent.getNodeHigh())\n }\n\n /*\n Right-Right case:\n\n z y\n / \\ / \\\n T1 y Left Rotate(z) z x\n / \\ - - - - - - - -> / \\ / \\\n T2 x T1 T2 T3 T4\n / \\\n T3 T4\n\n Right-Left case:\n\n z z x\n / \\ / \\ / \\\n T1 y Right Rotate (y) T1 x Left Rotate(z) z y\n / \\ - - - - - - - - -> / \\ - - - - - - - -> / \\ / \\\n x T4 T2 y T1 T2 T3 T4\n / \\ / \\\n T2 T3 T3 T4\n */\n\n // Handles Right-Right case and Right-Left case in rebalancing AVL tree\n private _updateMaxAfterLeftRotate() {\n const parent = this.parent!\n const right = parent.right!\n // Update max of right sibling (x in first case, y in second)\n const thisParentRightHigh = right.getNodeHigh()\n if (right.left === undefined && right.right !== undefined) {\n right.max = max(thisParentRightHigh, right.right.max)\n } else if (right.left !== undefined && right.right === undefined) {\n right.max = max(thisParentRightHigh, right.left.max)\n } else if (right.left === undefined && right.right === undefined) {\n right.max = thisParentRightHigh\n } else {\n right.max = max(max(right.left!.max, right.right!.max), thisParentRightHigh)\n }\n\n // Update max of itself (z)\n const thisHigh = this.getNodeHigh()\n if (this.left === undefined && this.right !== undefined) {\n this.max = max(thisHigh, this.right.max)\n } else if (this.left !== undefined && this.right === undefined) {\n this.max = max(thisHigh, this.left.max)\n } else if (this.left === undefined && this.right === undefined) {\n this.max = thisHigh\n } else {\n this.max = max(max(this.left!.max, this.right!.max), thisHigh)\n }\n\n // Update max of parent (y in first case, x in second)\n parent.max = max(max(parent.left!.max, right.max), parent.getNodeHigh())\n }\n\n private _leftRotate() {\n const rightChild = this.right!\n rightChild.parent = this.parent\n\n if (rightChild.parent === undefined) {\n this.intervalTree.root = rightChild\n } else {\n if (rightChild.parent.left === this) {\n rightChild.parent.left = rightChild\n } else if (rightChild.parent.right === this) {\n rightChild.parent.right = rightChild\n }\n }\n\n this.right = rightChild.left\n if (this.right !== undefined) {\n this.right.parent = this\n }\n rightChild.left = this\n this.parent = rightChild\n this.updateHeight()\n rightChild.updateHeight()\n }\n\n private _rightRotate() {\n const leftChild = this.left!\n leftChild.parent = this.parent\n\n if (leftChild.parent === undefined) {\n this.intervalTree.root = leftChild\n } else {\n if (leftChild.parent.left === this) {\n leftChild.parent.left = leftChild\n } else if (leftChild.parent.right === this) {\n leftChild.parent.right = leftChild\n }\n }\n\n this.left = leftChild.right\n if (this.left !== undefined) {\n this.left.parent = this\n }\n leftChild.right = this\n this.parent = leftChild\n this.updateHeight()\n leftChild.updateHeight()\n }\n\n // Rebalances the tree if the height value between two nodes of the same parent is greater than\n // two. There are 4 cases that can happen which are outlined in the graphics above\n private _rebalance() {\n if (height(this.left) >= 2 + height(this.right)) {\n const left = this.left!\n if (height(left.left) >= height(left.right)) {\n // Left-Left case\n this._rightRotate()\n this._updateMaxAfterRightRotate()\n } else {\n // Left-Right case\n left._leftRotate()\n this._rightRotate()\n this._updateMaxAfterRightRotate()\n }\n } else if (height(this.right) >= 2 + height(this.left)) {\n const right = this.right!\n if (height(right.right) >= height(right.left)) {\n // Right-Right case\n this._leftRotate()\n this._updateMaxAfterLeftRotate()\n } else {\n // Right-Left case\n right._rightRotate()\n this._leftRotate()\n this._updateMaxAfterLeftRotate()\n }\n }\n }\n\n insert(record: T) {\n if (record.low < this.key) {\n // Insert into left subtree\n if (this.left === undefined) {\n this.left = new Node(this.intervalTree, record)\n this.left.parent = this\n } else {\n this.left.insert(record)\n }\n } else {\n // Insert into right subtree\n if (this.right === undefined) {\n this.right = new Node(this.intervalTree, record)\n this.right.parent = this\n } else {\n this.right.insert(record)\n }\n }\n\n // Update the max value of this ancestor if needed\n if (this.max < record.high) {\n this.max = record.high\n }\n\n // Update height of each node\n this.updateHeight()\n\n // Rebalance the tree to ensure all operations are executed in O(logn) time. This is especially\n // important in searching, as the tree has a high chance of degenerating without the rebalancing\n this._rebalance()\n }\n\n private _getOverlappingRecords(currentNode: Node<T, N>, low: N, high: N) {\n if (currentNode.key <= high && low <= currentNode.getNodeHigh()) {\n // Nodes are overlapping, check if individual records in the node are overlapping\n const tempResults: T[] = []\n for (const record of currentNode.records) {\n if (record.high >= low) {\n tempResults.push(record)\n }\n }\n return tempResults\n }\n return []\n }\n\n search(low: N, high: N) {\n // Don't search nodes that don't exist\n if (this === undefined) {\n return []\n }\n\n // If interval is to the right of the rightmost point of any interval in this node and all its\n // children, there won't be any matches\n if (low > this.max) {\n return []\n }\n\n let leftSearch: T[] = []\n let rightSearch: T[] = []\n\n // Search left children\n if (this.left !== undefined && this.left.max >= low) {\n leftSearch = this.left.search(low, high)\n }\n\n // Check this node\n const ownSearch = this._getOverlappingRecords(this, low, high)\n\n // If interval is to the left of the start of this interval, then it can't be in any child to\n // the right\n if (high < this.key) {\n // return leftSearch.concat(ownSearch)\n return [...leftSearch, ...ownSearch]\n }\n\n // Otherwise, search right children\n if (this.right !== undefined) {\n rightSearch = this.right.search(low, high)\n }\n\n // Return accumulated results, if any\n // return leftSearch.concat(ownSearch, rightSearch)\n return [...leftSearch, ...ownSearch, ...rightSearch]\n }\n\n // Searches for a node by a `key` value\n searchExisting(low: N): Node<T, N> | undefined {\n if (this === undefined) {\n return undefined\n }\n\n if (this.key === low) {\n return this\n }\n if (low < this.key) {\n if (this.left !== undefined) {\n return this.left.searchExisting(low)\n }\n } else {\n if (this.right !== undefined) {\n return this.right.searchExisting(low)\n }\n }\n\n return undefined\n }\n\n // Returns the smallest node of the subtree\n private _minValue(): Node<T, N> {\n return this.left === undefined ? this : this.left._minValue()\n }\n\n remove(node: Node<T, N>): Node<T, N> | undefined {\n if (node.key < this.key) {\n // Node to be removed is on the left side\n return this.left === undefined ? undefined : this.left.remove(node)\n }\n if (node.key > this.key) {\n // Node to be removed is on the right side\n return this.right === undefined ? undefined : this.right.remove(node)\n }\n if (this.left !== undefined && this.right !== undefined) {\n // Node has two children\n const minValue = this.right._minValue()\n this.key = minValue.key\n this.records = minValue.records\n return this.right.remove(this)\n }\n const parent = this.parent!\n if (parent.left === this) {\n // One child or no child case on left side\n if (this.right === undefined) {\n parent.left = this.left\n if (this.left !== undefined) {\n this.left.parent = parent\n }\n } else {\n parent.left = this.right\n this.right.parent = parent\n }\n parent.updateMaxOfParents()\n parent.updateHeight()\n parent._rebalance()\n return this\n }\n if (parent.right === this) {\n // One child or no child case on right side\n if (this.right === undefined) {\n parent.right = this.left\n if (this.left !== undefined) {\n this.left.parent = parent\n }\n } else {\n parent.right = this.right\n this.right.parent = parent\n }\n parent.updateMaxOfParents()\n parent.updateHeight()\n parent._rebalance()\n return this\n }\n\n // Make linter happy\n return undefined\n }\n}\n\nexport class IntervalTree<T extends Interval<N>, N extends number | bigint = number> {\n root?: Node<T, N>\n count = 0\n\n insert(record: T) {\n if (record.low > record.high) {\n throw new Error('`low` value must be lower or equal to `high` value')\n }\n\n if (this.root === undefined) {\n // Base case: Tree is empty, new node becomes root\n this.root = new Node(this, record)\n this.count++\n return true\n }\n // Otherwise, check if node already exists with the same key\n const node = this.root.searchExisting(record.low)\n if (node === undefined) {\n // Node with this key doesn't already exist. Call insert function on root's node\n this.root.insert(record)\n this.count++\n return true\n }\n // Check the records in this node if there already is the one with same low, high, data\n for (const existing of node.records) {\n if (isSame(existing, record)) {\n // This record is same as the one we're trying to insert; return false to indicate\n // nothing has been inserted\n return false\n }\n }\n\n // Add the record to the node\n node.records.push(record)\n\n // Update max of the node and its parents if necessary\n if (record.high > node.max) {\n node.max = record.high\n if (node.parent) {\n node.parent.updateMaxOfParents()\n }\n }\n this.count++\n return true\n }\n\n search(low: N, high: N) {\n return this.root === undefined ? [] : this.root.search(low, high)\n }\n\n remove(record: T) {\n if (this.root === undefined) {\n // Tree is empty; nothing to remove\n return false\n }\n const node = this.root.searchExisting(record.low)\n if (node === undefined) {\n return false\n }\n if (node.records.length > 1) {\n // Node with this key has 2 or more records. Find the one we need and remove it\n const removedIndex = node.records.findIndex(r => isSame(r, record))\n\n if (removedIndex === -1) {\n return false\n }\n\n node.records.splice(removedIndex, 1)\n // Update max of that node and its parents if necessary\n if (record.high === node.max) {\n const nodeHigh = node.getNodeHigh()\n if (node.left !== undefined && node.right !== undefined) {\n node.max = max(max(node.left.max, node.right.max), nodeHigh)\n } else if (node.left !== undefined && node.right === undefined) {\n node.max = max(node.left.max, nodeHigh)\n } else if (node.left === undefined && node.right !== undefined) {\n node.max = max(node.right.max, nodeHigh)\n } else {\n node.max = nodeHigh\n }\n if (node.parent) {\n node.parent.updateMaxOfParents()\n }\n }\n this.count--\n return true\n }\n if (node.records.length === 1) {\n // Node with this key has only 1 record. Check if the remaining record in this node is\n // actually the one we want to remove\n if (isSame(node.records[0], record)) {\n // The remaining record is the one we want to remove. Remove the whole node from the tree\n if (this.root.key === node.key) {\n // We're removing the root element. Create a dummy node that will temporarily take\n // root's parent role\n const rootParent = new Node<T, N>(this, { low: record.low, high: record.low } as T)\n rootParent.left = this.root\n this.root.parent = rootParent\n const removedNode = this.root.remove(node)\n this.root = rootParent.left\n if (this.root !== undefined) {\n this.root.parent = undefined\n }\n if (removedNode) {\n this.count--\n return true\n }\n return false\n }\n const removedNode = this.root.remove(node)\n if (removedNode) {\n this.count--\n return true\n }\n return false\n }\n // The remaining record is not the one we want to remove\n return false\n }\n // No records at all in this node?! Shouldn't happen\n return false\n }\n\n inOrder() {\n return new InOrder(this.root)\n }\n\n reverseInOrder() {\n return new ReverseInOrder(this.root)\n }\n\n preOrder() {\n return new PreOrder(this.root)\n }\n}\n\nexport interface DataInterval<T, N extends number | bigint = number> extends Interval<N> {\n data: T\n}\n\n/**\n * The default export just wraps the `IntervalTree`, while providing a simpler API. Check out the\n * README for description on how to use each.\n */\nexport class DataIntervalTree<T, N extends number | bigint = number> {\n private tree = new IntervalTree<DataInterval<T, N>, N>()\n\n insert(low: N, high: N, data: T) {\n return this.tree.insert({\n low, high, data,\n })\n }\n\n remove(low: N, high: N, data: T) {\n return this.tree.remove({\n low, high, data,\n })\n }\n\n search(low: N, high: N) {\n return this.tree.search(low, high).map(v => v.data)\n }\n\n inOrder() {\n return this.tree.inOrder()\n }\n\n reverseInOrder() {\n return this.tree.reverseInOrder()\n }\n\n preOrder() {\n return this.tree.preOrder()\n }\n\n get count() {\n return this.tree.count\n }\n}\n\nabstract class TreeOrderIterator<T extends Interval<N>, N extends number | bigint = number>\nimplements IterableIterator<T> {\n protected stack: Node<T, N>[] = []\n\n protected currentNode?: Node<T, N>\n protected i: number | undefined\n\n constructor(startNode?: Node<T, N>) {\n if (startNode !== undefined) {\n this.initialize(startNode)\n }\n }\n\n protected abstract initialize(node: Node<T, N>): void\n\n [Symbol.iterator]() {\n return this\n }\n\n abstract next(): IteratorResult<T>\n}\n\nexport class InOrder<T extends Interval<N>, N extends number | bigint = number>\n extends TreeOrderIterator<T, N> {\n protected initialize(node: Node<T, N>) {\n this.push(node)\n }\n\n next(): IteratorResult<T> {\n // Will only happen if stack is empty and pop is called\n if (this.currentNode === undefined) {\n return {\n done: true,\n value: undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any as IteratorResult<T>\n }\n\n // Process this node\n if (this.i !== undefined && this.i < this.currentNode.records.length) {\n return {\n done: false,\n value: this.currentNode.records[this.i++],\n }\n }\n\n if (this.currentNode.right === undefined) {\n // Otherwise go up\n // Might pop the last and set this.currentNode = undefined\n this.pop()\n } else {\n // Can we go right?\n this.push(this.currentNode.right)\n }\n return this.next()\n }\n\n private push(node: Node<T, N>) {\n this.currentNode = node\n this.i = 0\n\n while (this.currentNode.left !== undefined) {\n this.stack.push(this.currentNode)\n this.currentNode = this.currentNode.left\n }\n }\n\n private pop() {\n this.currentNode = this.stack.pop()\n this.i = 0\n }\n}\n\nexport class ReverseInOrder<T extends Interval<N>, N extends number | bigint = number>\n extends TreeOrderIterator<T, N> {\n protected initialize(node: Node<T, N>) {\n this.push(node)\n }\n\n next(): IteratorResult<T> {\n // Will only happen if stack is empty and pop is called\n if (this.currentNode === undefined) {\n return {\n done: true,\n value: undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any as IteratorResult<T>\n }\n\n // Process this node\n if (this.currentNode.records.length > 0 && this.i !== undefined && this.i >= 0) {\n return {\n done: false,\n value: this.currentNode.records[this.i--],\n }\n }\n\n if (this.currentNode.left === undefined) {\n // Otherwise go up\n // Might pop the last and set this.currentNode = undefined\n this.pop()\n } else {\n // Can we go left?\n this.push(this.currentNode.left)\n }\n return this.next()\n }\n\n private push(node: Node<T, N>) {\n this.currentNode = node\n this.i = (this.currentNode?.records.length ?? 0) - 1\n\n while (this.currentNode.right !== undefined) {\n this.stack.push(this.currentNode)\n this.currentNode = this.currentNode.right\n this.i = (this.currentNode?.records.length ?? 0) - 1\n }\n }\n\n private pop() {\n this.currentNode = this.stack.pop()\n this.i = (this.currentNode?.records.length ?? 0) - 1\n }\n}\n\nexport class PreOrder<T extends Interval<N>, N extends number | bigint = number>\nimplements IterableIterator<T> {\n private stack: Node<T, N>[] = []\n\n private currentNode?: Node<T, N>\n private i = 0\n\n constructor(startNode?: Node<T, N>) {\n this.currentNode = startNode\n }\n\n [Symbol.iterator]() {\n return this\n }\n\n next(): IteratorResult<T> {\n // Will only happen if stack is empty and pop is called,\n // which only happens if there is no right node (i.e we are done)\n if (this.currentNode === undefined) {\n return {\n done: true,\n value: undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any as IteratorResult<T>\n }\n\n // Process this node\n if (this.i < this.currentNode.records.length) {\n return {\n done: false,\n value: this.currentNode.records[this.i++],\n }\n }\n\n if (this.currentNode.right !== undefined) {\n this.push(this.currentNode.right)\n }\n if (this.currentNode.left !== undefined) {\n this.push(this.currentNode.left)\n }\n this.pop()\n return this.next()\n }\n\n private push(node: Node<T, N>) {\n this.stack.push(node)\n }\n\n private pop() {\n this.currentNode = this.stack.pop()\n this.i = 0\n }\n}\n", "function seededRandom(seed: number): () => number {\n return function () {\n const x = Math.sin(seed++) * 10_000\n return x - Math.floor(x)\n }\n}\n\nexport function shuffleWithSeed<T>(set: Set<T>, seed: number): T[] {\n const array = [...set].toSorted((a, b) => String(a).localeCompare(String(b)))\n const random = seededRandom(seed) // Create seeded PRNG\n\n // Fisher-Yates Shuffle\n for (let i = array.length - 1; i > 0; i--) {\n const j = Math.floor(random() * (i + 1)) // Use PRNG for index\n const swap = array[i]\n array[i] = array[j]\n array[j] = swap\n }\n\n return array\n}\n", "import { asXL1BlockNumber, StepSizes } from '@xyo-network/xl1-sdk'\n\nexport type StepWindow = [number, number]\n\n/**\n * DO NOT USE!\n * This function is meant for future use cases where we need to get all block numbers\n * in a given step from a given block number\n */\nexport const stepWindowCalculatorFromBlock = (blockNumber: number): StepWindow => {\n // If the block number is less than the first step size, return the first window\n if (blockNumber < StepSizes[0]) {\n return [0, StepSizes[0] - 1]\n }\n\n let lower = 0\n\n for (let i = 0; i < StepSizes.length; i++) {\n const stepSize = StepSizes[i]\n let nextStep = StepSizes[i + 1]\n // If the block number is less than the first step size, return the first window\n // If we are past the first step size, we need to adjust the lower bound\n if (i > 0) lower = stepSize\n\n // If we are at the last step size, we need to calculate the next step dynamically\n if (i === StepSizes.length - 1) {\n // Increase the next step height to the end of the next window since we don't have\n // a predefined next step\n nextStep = asXL1BlockNumber(stepSize * 2, { name: 'stepWindowCalculatorFromBlock A' })\n // Dynamically increase the next step height until it is greater than the block number\n while (blockNumber >= nextStep) {\n // Set next step to the end of the next window\n nextStep = asXL1BlockNumber(nextStep + stepSize, { name: 'stepWindowCalculatorFromBlock B' })\n }\n }\n\n if (blockNumber >= stepSize && blockNumber <= nextStep) {\n // block number is between two step sizes so iterate till\n // we find the correct window\n for (let lowerBound = lower; lowerBound < nextStep; lowerBound += stepSize) {\n // -1 since the last block in the window includes step hash of the previous step\n const upperBound = lowerBound + stepSize - 1\n // if the block number is within the current window\n // return the lower and upper bounds of the window\n if (blockNumber >= lowerBound && blockNumber <= upperBound) {\n return [lowerBound, upperBound]\n }\n }\n }\n }\n throw new Error(`No valid window could be calculated for Block number ${blockNumber}.`)\n}\n", "import type { Logger, Promisable } from '@ariestools/sdk'\n\n/**\n * Executes a function and logs the duration.\n * This is useful for tracking the performance of startup tasks.\n * Written is such a fashion to be signature compatible with the\n * wrappers for spanning without exporting actual spans for functions\n * that initialize potentially long running background processes and\n * result in non-terminating spans.\n * @param name The name of the span\n * @param fn The function to execute within the span\n * @returns The result of the function\n */\nexport async function startupSpanAsync<T>(\n name: string,\n fn: () => Promisable<T>,\n logger?: Logger,\n): Promise<T> {\n const start = Date.now()\n try {\n logger?.log(`[${name}] Initializing`)\n const result = await fn()\n return result\n } finally {\n const stop = Date.now()\n const duration = stop - start\n logger?.log(`[${name}] Initialized (${duration}ms)`)\n }\n}\n", "import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'\nimport { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-base'\nimport chalk from 'chalk'\n\nexport function spanDurationInMillis(span: ReadableSpan) {\n return span.duration[0] * 1000 + span.duration[1] / 1e6\n}\n\nexport class XyoConsoleSpanExporter extends ConsoleSpanExporter {\n static readonly durationToLogLevel = [\n 0,\n 1,\n 10,\n 100,\n 1000,\n ]\n\n static readonly logLevelToChalkColor = [\n chalk.grey,\n chalk.white,\n chalk.green,\n chalk.yellow,\n chalk.red,\n ]\n\n private _logLevel: number\n\n constructor(logLevel = 0) {\n super()\n this._logLevel = logLevel\n }\n\n get logLevel() {\n return this._logLevel\n }\n\n override export(spans: ReadableSpan[]): void {\n for (const span of spans) {\n const spanLevel = this.spanLevel(span)\n if (spanLevel < this.logLevel) {\n continue\n }\n const duration = spanDurationInMillis(span)\n console.log(chalk.grey([\n `Span [${span.name}]`,\n this.logColor(spanLevel)(`${duration}ms`),\n `TraceId: ${span.spanContext().traceId}`,\n ].join(', ')))\n }\n }\n\n logColor(level: number) {\n return XyoConsoleSpanExporter.logLevelToChalkColor[level] ?? chalk.magenta\n }\n\n spanLevel(span: ReadableSpan) {\n let logLevel = 0\n const duration = spanDurationInMillis(span)\n for (let x = XyoConsoleSpanExporter.durationToLogLevel.length - 1; x >= 0; x--) {\n if (duration > XyoConsoleSpanExporter.durationToLogLevel[x]) {\n logLevel = x\n break\n }\n }\n return logLevel\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAMnB,IAAM,2CAAiE;AAAA,EAC5E,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;AASO,IAAM,oBAAoB,OAC/B,WACA,YAAsD,MAAM,MAC5D,cAAoC,6CACc;AAClD,MAAI,SAA+B,UAAU,YAAY,MAAM,IAA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AAA,IACf;AAAA,EACF;AAAA,EAEA,SAAS,OAAe;AACtB,WAAO,wBAAuB,qBAAqB,KAAK,KAAK,MAAM;AAAA,EACrE;AAAA,EAEA,UAAU,MAAoB;AAC5B,QAAI,WAAW;AACf,UAAM,WAAW,qBAAqB,IAAI;AAC1C,aAAS,IAAI,wBAAuB,mBAAmB,SAAS,GAAG,KAAK,GAAG,KAAK;AAC9E,UAAI,WAAW,wBAAuB,mBAAmB,CAAC,GAAG;AAC3D,mBAAW;AACX;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["import { isDefined } from '@ariestools/sdk'\nimport type {\n ArchivistNextOptions, Payload, ReadArchivist,\n Sequence, WithStorageMeta,\n} from '@xyo-network/sdk'\n\nexport const DEFAULT_FIND_FIRST_MATCHING_NEXT_OPTIONS: ArchivistNextOptions = {\n limit: 100,\n open: false,\n order: 'desc',\n}\n\n/**\n * Find the first payload that matches the predicate from the archivist\n * @param archivist The archivist to search\n * @param predicate The predicate to match\n * @param nextOptions The default options for the next call\n * @returns The first payload that matches the predicate\n */\nexport const findFirstMatching = async (\n archivist: ReadArchivist,\n predicate: (p: WithStorageMeta<Payload>) => boolean = () => true,\n nextOptions: ArchivistNextOptions = DEFAULT_FIND_FIRST_MATCHING_NEXT_OPTIONS,\n): Promise<WithStorageMeta<Payload> | undefined> => {\n let cursor: Sequence | undefined = isDefined(nextOptions.cursor) ? nextOptions.cursor : undefined\n let batch: WithStorageMeta<Payload>[]\n do {\n // Get the next batch from the archivist\n batch = await archivist.next({ ...nextOptions, cursor: cursor })\n // If the batch is empty there's nothing left to check\n if (batch.length === 0) break\n // Filter batch using predicate\n const found = batch.find(p => predicate(p))\n if (found) return found\n // Update the cursor\n const updatedCursor = batch.at(-1)?._sequence\n if (isDefined(updatedCursor)) cursor = updatedCursor\n } while (batch.length > 0)\n return undefined\n}\n", "import type { ArchivistInstance, Payload } from '@xyo-network/sdk'\nimport { Account, MemoryArchivist } from '@xyo-network/sdk'\n\nexport const payloadsToArchivist = async (payloads: Payload[]): Promise<ArchivistInstance> => {\n const archivist = await MemoryArchivist.create({ account: await Account.random() })\n await archivist.insert(payloads)\n return archivist\n}\n", "import { isDefined } from '@ariestools/sdk'\nimport type {\n ArchivistInstance, Payload, ReadArchivist,\n Sequence, WithStorageMeta,\n} from '@xyo-network/sdk'\n\nimport { findFirstMatching } from './findFirstMatching.ts'\n\n/**\n * Synchronize two archivists\n * @param source The source archivist\n * @param destination The destination archivist\n * @param sourceCursor The cursor for the source archivist\n * @param predicate A predicate to filter payloads for the first matching payload\n * @param filter A predicate to filter payloads for all the payloads\n * @returns The next cursor to use for the source archivist\n */\nexport const synchronizeArchivists = async (\n source: ReadArchivist,\n destination: ArchivistInstance,\n sourceCursor?: Sequence,\n predicate: (payload: WithStorageMeta<Payload>) => boolean = () => true,\n filter: (payload: WithStorageMeta<Payload>) => boolean = () => true,\n): Promise<Sequence | undefined> => {\n const destLast = await findFirstMatching(destination, predicate)\n const sourceLast = await findFirstMatching(source, predicate)\n // If there's nothing in the source, there is nothing to sync\n if (!sourceLast) return\n if (destLast) {\n const sourcePayloadResult = await source.get([destLast._hash])\n const sourcePayload = sourcePayloadResult.at(0)\n if (sourcePayload) {\n sourceCursor = sourcePayload._sequence\n } else {\n // Corrupt local DB, delete and re-sync\n throw new Error('Local DB is out of sync with source')\n }\n } else {\n // If there's nothing in the local, sync everything\n // Grab the first payload from the source archivist\n const sourceFirstResult = await source.next({\n open: false, limit: 1, order: 'asc',\n })\n const sourceFirst = sourceFirstResult.at(0)\n // If there are any payloads in the source archivist\n if (sourceFirst) {\n // Insert the first payload into the local archivist\n await destination.insert([sourceFirst].filter(filter))\n // Update the cursor to start there\n sourceCursor = sourceFirst._sequence\n } else {\n // source DB is empty, nothing to sync\n return\n }\n }\n\n let batch: WithStorageMeta<Payload>[]\n do {\n // Get the next batch from the source archivist\n batch = await source.next({\n open: true, limit: 500, order: 'asc', cursor: sourceCursor,\n })\n\n // If the batch is empty there's nothing left to sync\n if (batch.length === 0) break\n // Update the cursor\n const updatedCursor = batch.at(-1)?._sequence\n if (isDefined(updatedCursor)) sourceCursor = updatedCursor\n // Insert the batch into the local archivist\n await destination.insert(batch.filter(filter))\n console.log('syncing batch', sourceCursor, batch.length)\n console.log('batch sequences', batch.map(b => b._sequence))\n } while (batch.length > 0)\n return sourceCursor\n}\n", "import { XL1 } from '@xyo-network/xl1-sdk'\n\nimport { removeTrailingZeros } from '../formatters/index.ts'\n\nexport type BigIntDecimal = string | number | bigint\n\nconst parseBigIntDecimal = (value: BigIntDecimal, decimal: number): XL1 => {\n const valueString = (typeof value === 'number') || (typeof value === 'bigint') ? value.toString(10) : value\n const [intPart, fracPart = '0'] = valueString.split('.', 2)\n const fracPartLength = Math.min(fracPart.length, decimal)\n\n // Handle max decimals\n const trimmedFracPart = fracPart.slice(0, fracPartLength)\n\n const intPartBigInt = BigInt(Number.parseInt(intPart)) * (10n ** BigInt(decimal))\n const fracPartBigInt = BigInt(Number.parseInt(trimmedFracPart)) * (10n ** BigInt(decimal - trimmedFracPart.length))\n const valueBigInt = intPartBigInt + fracPartBigInt\n return XL1(valueBigInt)\n}\n\nconst bigIntFormat = (value: bigint, decimal: number): string => {\n const intPart = value / (10n ** BigInt(decimal))\n const fracPart = value - intPart * (10n ** BigInt(decimal))\n const fracPartString = fracPart.toString().padStart(decimal, '0')\n\n return removeTrailingZeros(`${intPart}.${fracPartString}`)\n}\n\nexport const formattedMXL1toXl1 = (value: string | number | bigint): string => {\n return bigIntFormat(parseBigIntDecimal(value, 12), 18)\n}\n", "export const removeTrailingZeros = (value: string): string => {\n let i = value.length - 1\n while (i >= 0 && value[i] === '0') {\n i--\n }\n return value.slice(0, i + 1)\n}\n", "import { removeTrailingZeros } from './removeTrailingZeros.ts'\n\nexport const bigIntToFixedPointString = (value: bigint, decimalPlaces = 18): string => {\n const stringValue = value.toString(10)\n const splitAtIndex = (value: string, index: number): [string, string] => {\n const part1 = value.slice(0, index)\n const part2 = value.slice(index)\n return [part1, part2]\n }\n\n const floatable = stringValue.length > decimalPlaces\n if (floatable) {\n const [whole, fraction] = splitAtIndex(stringValue, stringValue.length - decimalPlaces)\n const cleanedFraction = removeTrailingZeros(fraction)\n return cleanedFraction.length > 0 ? `${whole}.${cleanedFraction}` : whole\n }\n if (stringValue === '0') return stringValue\n const cleanedFraction = removeTrailingZeros(stringValue)\n return `0.${'0'.repeat(decimalPlaces - stringValue.length)}${cleanedFraction}`\n}\n", "import { bigIntToFixedPointString } from './bigIntToFixedPointString.ts'\nimport { removeTrailingZeros } from './removeTrailingZeros.ts'\n\nexport interface FloatStringFormatterResults {\n truncatedFloat?: boolean\n unsafeInteger?: boolean\n value: string\n}\n\nconst isUnsafeInteger = (value: string): boolean => {\n try {\n const parsedNumber = BigInt(value)\n return parsedNumber > BigInt(Number.MAX_SAFE_INTEGER)\n } catch (error) {\n console.error('Failed to parse number:', error)\n return true\n }\n}\n\nconst safeReturnInteger = (value: string): FloatStringFormatterResults => {\n return isUnsafeInteger(value)\n ? {\n unsafeInteger: true,\n value,\n }\n : { value }\n}\n\n// Overloaded function signatures\nexport function formatNumberForDisplay(value: bigint, significantFigures?: number, bigIntShift?: number): FloatStringFormatterResults\nexport function formatNumberForDisplay(value: string, significantFigures?: number): FloatStringFormatterResults\n\nexport function formatNumberForDisplay(value: string | bigint, significantFigures = 5, bigIntShift = 18): FloatStringFormatterResults {\n const resolvedValue = typeof value === 'bigint' ? bigIntToFixedPointString(value, bigIntShift) : value\n\n const isFloat = resolvedValue.includes('.')\n if (!isFloat) {\n return safeReturnInteger(resolvedValue)\n }\n\n // If the whole part of the float is greater than or equal to the significant figures, return it as is\n const [whole, fraction] = resolvedValue.split('.', 2)\n if (whole.length >= significantFigures) {\n return isUnsafeInteger(whole)\n ? {\n unsafeInteger: true,\n value: whole,\n }\n : { value: whole }\n }\n const cleanedFraction = fraction.at(-1) === '0' ? removeTrailingZeros(fraction) : fraction\n\n // If the whole part of the float is less than the significant figures and the fraction exists\n const safeWholeNumber = whole.length <= significantFigures\n const safeFraction = cleanedFraction.length <= significantFigures\n\n if (safeWholeNumber) {\n // if we have a safe whole number, the fraction and be trimmed\n if (safeFraction) {\n const show = significantFigures - whole.length\n return { value: `${whole}.${cleanedFraction.slice(0, show)}` }\n }\n // Handle very small numbers\n const leadingZeros = RegExp(/^0+/).exec(cleanedFraction)?.at(0)?.length ?? 0\n const significantPart = cleanedFraction.slice(leadingZeros, leadingZeros + significantFigures)\n return {\n value: `0.0...${significantPart}`,\n truncatedFloat: true,\n }\n }\n // handle very large numbers with a fraction by just returning the whole number\n return safeReturnInteger(whole)\n}\n", "import type { Hex } from '@ariestools/sdk'\nimport { assertEx, isHex } from '@ariestools/sdk'\n\nexport function hexToLast4BytesInt(value: Hex): number {\n assertEx(isHex(value), () => 'value must be a hex string')\n\n // Extract the last 4 bytes (8 characters) of the hex string\n const last4Bytes = value.slice(-8)\n\n // Convert the last 4 bytes to an integer\n return Number.parseInt(last4Bytes, 16)\n}\n", "/* eslint-disable unicorn/prefer-at */\n/* eslint-disable unicorn/prefer-math-min-max */\n\nexport interface Serializable<T> {\n serialize(): T\n}\n\nexport type IntervalMapInterval = [number, number]\n\nexport type SerializedIntervalMap = Record<string, [number, number][]>\n\nexport class IntervalMap<T> implements Serializable<SerializedIntervalMap> {\n private map: Map<T, IntervalMapInterval[]>\n\n constructor(data?: SerializedIntervalMap) {\n this.map = new Map()\n if (data) {\n for (const [key, intervals] of Object.entries(data)) {\n for (const interval of intervals) {\n this.insert(key as T, interval[0], interval[1])\n }\n }\n }\n }\n\n findAllContaining(point: number): readonly T[] {\n const result: T[] = []\n for (const [address, intervals] of this.map) {\n if (intervals.some(([start, end]) => start <= point && point <= end)) {\n result.push(address)\n }\n }\n return result\n }\n\n get(key: T): readonly Readonly<IntervalMapInterval>[] | undefined {\n const intervals = this.map.get(key)\n return intervals ? Object.freeze(intervals.map(interval => Object.freeze(interval))) : undefined\n }\n\n insert(value: T, start: number, end: number): void {\n if (start > end) {\n throw new Error('Invalid interval: start must be less than or equal to end')\n }\n\n const intervals = this.map.get(value) ?? []\n intervals.push([start, end])\n // Merge overlapping intervals\n const merged: IntervalMapInterval[] = []\n for (const [s, e] of intervals) {\n if (merged.length === 0 || merged[merged.length - 1][1] < s) {\n merged.push([s, e])\n } else {\n merged[merged.length - 1][1] = merged[merged.length - 1][1] > e ? merged[merged.length - 1][1] : e\n }\n }\n\n this.map.set(value, merged)\n }\n\n serialize(): SerializedIntervalMap {\n const obj: SerializedIntervalMap = {}\n for (const [key, intervals] of this.map) {\n obj[key as string] = intervals.map(([start, end]) => [start, end])\n }\n return obj\n }\n}\n", "/* eslint-disable max-lines */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable @typescript-eslint/member-ordering */\n// Full credit to: https://github.com/ShieldBattery/node-interval-tree\n// Adapted from original repo as legacy export syntax and would not\n// work with Node & ESM imports\n\n// An augmented AVL Tree where each node maintains a list of records and their search intervals.\n// Record is composed of an interval and its underlying data, sent by a client. This allows the\n// interval tree to have the same interval inserted multiple times, as long its data is different.\n// Both insertion and deletion require O(log n) time. Searching requires O(k*logn) time, where `k`\n// is the number of intervals in the output list.\n\n// import isSame = require('shallowequal')\nimport isSame from 'shallowequal'\n\nexport interface Interval<N extends number | bigint = number> {\n readonly low: N\n readonly high: N\n}\n\nfunction max<N extends number | bigint>(a: N, b: N): N {\n return a > b ? a : b\n}\n\nfunction height<T extends Interval<N>, N extends number | bigint = number>(node?: Node<T, N>) {\n return node === undefined ? -1 : node.height\n}\n\nexport class Node<T extends Interval<N>, N extends number | bigint = number> {\n intervalTree: IntervalTree<T, N>\n key: N\n max: N\n records: T[] = []\n parent?: Node<T, N>\n height = 0\n left?: Node<T, N>\n right?: Node<T, N>\n\n constructor(intervalTree: IntervalTree<T, N>, record: T) {\n this.intervalTree = intervalTree\n this.key = record.low\n this.max = record.high\n\n // Save the array of all records with the same key for this node\n this.records.push(record)\n }\n\n // Gets the highest record.high value for this node\n getNodeHigh() {\n let high = this.records[0].high\n\n for (let i = 1; i < this.records.length; i++) {\n if (this.records[i].high > high) {\n high = this.records[i].high\n }\n }\n\n return high\n }\n\n // Updates height value of the node. Called during insertion, rebalance, removal\n updateHeight() {\n this.height = max(height(this.left), height(this.right)) + 1\n }\n\n // Updates the max value of all the parents after inserting into already existing node, as well as\n // removing the node completely or removing the record of an already existing node. Starts with\n // the parent of an affected node and bubbles up to root\n updateMaxOfParents() {\n if (this === undefined) {\n return\n }\n\n const thisHigh = this.getNodeHigh()\n if (this.left !== undefined && this.right !== undefined) {\n this.max = max(max(this.left.max, this.right.max), thisHigh)\n } else if (this.left !== undefined && this.right === undefined) {\n this.max = max(this.left.max, thisHigh)\n } else if (this.left === undefined && this.right !== undefined) {\n this.max = max(this.right.max, thisHigh)\n } else {\n this.max = thisHigh\n }\n\n if (this.parent) {\n this.parent.updateMaxOfParents()\n }\n }\n\n /*\n Left-Left case:\n\n z y\n / \\ / \\\n y T4 Right Rotate (z) x z\n / \\ - - - - - - - - -> / \\ / \\\n x T3 T1 T2 T3 T4\n / \\\n T1 T2\n\n Left-Right case:\n\n z z x\n / \\ / \\ / \\\n y T4 Left Rotate (y) x T4 Right Rotate(z) y z\n / \\ - - - - - - - - -> / \\ - - - - - - - -> / \\ / \\\n T1 x y T3 T1 T2 T3 T4\n / \\ / \\\n T2 T3 T1 T2\n */\n\n // Handles Left-Left case and Left-Right case after rebalancing AVL tree\n private _updateMaxAfterRightRotate() {\n const parent = this.parent!\n const left = parent.left!\n // Update max of left sibling (x in first case, y in second)\n const thisParentLeftHigh = left.getNodeHigh()\n if (left.left === undefined && left.right !== undefined) {\n left.max = max(thisParentLeftHigh, left.right.max)\n } else if (left.left !== undefined && left.right === undefined) {\n left.max = max(thisParentLeftHigh, left.left.max)\n } else if (left.left === undefined && left.right === undefined) {\n left.max = thisParentLeftHigh\n } else {\n left.max = max(max(left.left!.max, left.right!.max), thisParentLeftHigh)\n }\n\n // Update max of itself (z)\n const thisHigh = this.getNodeHigh()\n if (this.left === undefined && this.right !== undefined) {\n this.max = max(thisHigh, this.right.max)\n } else if (this.left !== undefined && this.right === undefined) {\n this.max = max(thisHigh, this.left.max)\n } else if (this.left === undefined && this.right === undefined) {\n this.max = thisHigh\n } else {\n this.max = max(max(this.left!.max, this.right!.max), thisHigh)\n }\n\n // Update max of parent (y in first case, x in second)\n parent.max = max(max(parent.left!.max, parent.right!.max), parent.getNodeHigh())\n }\n\n /*\n Right-Right case:\n\n z y\n / \\ / \\\n T1 y Left Rotate(z) z x\n / \\ - - - - - - - -> / \\ / \\\n T2 x T1 T2 T3 T4\n / \\\n T3 T4\n\n Right-Left case:\n\n z z x\n / \\ / \\ / \\\n T1 y Right Rotate (y) T1 x Left Rotate(z) z y\n / \\ - - - - - - - - -> / \\ - - - - - - - -> / \\ / \\\n x T4 T2 y T1 T2 T3 T4\n / \\ / \\\n T2 T3 T3 T4\n */\n\n // Handles Right-Right case and Right-Left case in rebalancing AVL tree\n private _updateMaxAfterLeftRotate() {\n const parent = this.parent!\n const right = parent.right!\n // Update max of right sibling (x in first case, y in second)\n const thisParentRightHigh = right.getNodeHigh()\n if (right.left === undefined && right.right !== undefined) {\n right.max = max(thisParentRightHigh, right.right.max)\n } else if (right.left !== undefined && right.right === undefined) {\n right.max = max(thisParentRightHigh, right.left.max)\n } else if (right.left === undefined && right.right === undefined) {\n right.max = thisParentRightHigh\n } else {\n right.max = max(max(right.left!.max, right.right!.max), thisParentRightHigh)\n }\n\n // Update max of itself (z)\n const thisHigh = this.getNodeHigh()\n if (this.left === undefined && this.right !== undefined) {\n this.max = max(thisHigh, this.right.max)\n } else if (this.left !== undefined && this.right === undefined) {\n this.max = max(thisHigh, this.left.max)\n } else if (this.left === undefined && this.right === undefined) {\n this.max = thisHigh\n } else {\n this.max = max(max(this.left!.max, this.right!.max), thisHigh)\n }\n\n // Update max of parent (y in first case, x in second)\n parent.max = max(max(parent.left!.max, right.max), parent.getNodeHigh())\n }\n\n private _leftRotate() {\n const rightChild = this.right!\n rightChild.parent = this.parent\n\n if (rightChild.parent === undefined) {\n this.intervalTree.root = rightChild\n } else {\n if (rightChild.parent.left === this) {\n rightChild.parent.left = rightChild\n } else if (rightChild.parent.right === this) {\n rightChild.parent.right = rightChild\n }\n }\n\n this.right = rightChild.left\n if (this.right !== undefined) {\n this.right.parent = this\n }\n rightChild.left = this\n this.parent = rightChild\n this.updateHeight()\n rightChild.updateHeight()\n }\n\n private _rightRotate() {\n const leftChild = this.left!\n leftChild.parent = this.parent\n\n if (leftChild.parent === undefined) {\n this.intervalTree.root = leftChild\n } else {\n if (leftChild.parent.left === this) {\n leftChild.parent.left = leftChild\n } else if (leftChild.parent.right === this) {\n leftChild.parent.right = leftChild\n }\n }\n\n this.left = leftChild.right\n if (this.left !== undefined) {\n this.left.parent = this\n }\n leftChild.right = this\n this.parent = leftChild\n this.updateHeight()\n leftChild.updateHeight()\n }\n\n // Rebalances the tree if the height value between two nodes of the same parent is greater than\n // two. There are 4 cases that can happen which are outlined in the graphics above\n private _rebalance() {\n if (height(this.left) >= 2 + height(this.right)) {\n const left = this.left!\n if (height(left.left) >= height(left.right)) {\n // Left-Left case\n this._rightRotate()\n this._updateMaxAfterRightRotate()\n } else {\n // Left-Right case\n left._leftRotate()\n this._rightRotate()\n this._updateMaxAfterRightRotate()\n }\n } else if (height(this.right) >= 2 + height(this.left)) {\n const right = this.right!\n if (height(right.right) >= height(right.left)) {\n // Right-Right case\n this._leftRotate()\n this._updateMaxAfterLeftRotate()\n } else {\n // Right-Left case\n right._rightRotate()\n this._leftRotate()\n this._updateMaxAfterLeftRotate()\n }\n }\n }\n\n insert(record: T) {\n if (record.low < this.key) {\n // Insert into left subtree\n if (this.left === undefined) {\n this.left = new Node(this.intervalTree, record)\n this.left.parent = this\n } else {\n this.left.insert(record)\n }\n } else {\n // Insert into right subtree\n if (this.right === undefined) {\n this.right = new Node(this.intervalTree, record)\n this.right.parent = this\n } else {\n this.right.insert(record)\n }\n }\n\n // Update the max value of this ancestor if needed\n if (this.max < record.high) {\n this.max = record.high\n }\n\n // Update height of each node\n this.updateHeight()\n\n // Rebalance the tree to ensure all operations are executed in O(logn) time. This is especially\n // important in searching, as the tree has a high chance of degenerating without the rebalancing\n this._rebalance()\n }\n\n private _getOverlappingRecords(currentNode: Node<T, N>, low: N, high: N) {\n if (currentNode.key <= high && low <= currentNode.getNodeHigh()) {\n // Nodes are overlapping, check if individual records in the node are overlapping\n const tempResults: T[] = []\n for (const record of currentNode.records) {\n if (record.high >= low) {\n tempResults.push(record)\n }\n }\n return tempResults\n }\n return []\n }\n\n search(low: N, high: N) {\n // Don't search nodes that don't exist\n if (this === undefined) {\n return []\n }\n\n // If interval is to the right of the rightmost point of any interval in this node and all its\n // children, there won't be any matches\n if (low > this.max) {\n return []\n }\n\n let leftSearch: T[] = []\n let rightSearch: T[] = []\n\n // Search left children\n if (this.left !== undefined && this.left.max >= low) {\n leftSearch = this.left.search(low, high)\n }\n\n // Check this node\n const ownSearch = this._getOverlappingRecords(this, low, high)\n\n // If interval is to the left of the start of this interval, then it can't be in any child to\n // the right\n if (high < this.key) {\n // return leftSearch.concat(ownSearch)\n return [...leftSearch, ...ownSearch]\n }\n\n // Otherwise, search right children\n if (this.right !== undefined) {\n rightSearch = this.right.search(low, high)\n }\n\n // Return accumulated results, if any\n // return leftSearch.concat(ownSearch, rightSearch)\n return [...leftSearch, ...ownSearch, ...rightSearch]\n }\n\n // Searches for a node by a `key` value\n searchExisting(low: N): Node<T, N> | undefined {\n if (this === undefined) {\n return undefined\n }\n\n if (this.key === low) {\n return this\n }\n if (low < this.key) {\n if (this.left !== undefined) {\n return this.left.searchExisting(low)\n }\n } else {\n if (this.right !== undefined) {\n return this.right.searchExisting(low)\n }\n }\n\n return undefined\n }\n\n // Returns the smallest node of the subtree\n private _minValue(): Node<T, N> {\n return this.left === undefined ? this : this.left._minValue()\n }\n\n remove(node: Node<T, N>): Node<T, N> | undefined {\n if (node.key < this.key) {\n // Node to be removed is on the left side\n return this.left === undefined ? undefined : this.left.remove(node)\n }\n if (node.key > this.key) {\n // Node to be removed is on the right side\n return this.right === undefined ? undefined : this.right.remove(node)\n }\n if (this.left !== undefined && this.right !== undefined) {\n // Node has two children\n const minValue = this.right._minValue()\n this.key = minValue.key\n this.records = minValue.records\n return this.right.remove(this)\n }\n const parent = this.parent!\n if (parent.left === this) {\n // One child or no child case on left side\n if (this.right === undefined) {\n parent.left = this.left\n if (this.left !== undefined) {\n this.left.parent = parent\n }\n } else {\n parent.left = this.right\n this.right.parent = parent\n }\n parent.updateMaxOfParents()\n parent.updateHeight()\n parent._rebalance()\n return this\n }\n if (parent.right === this) {\n // One child or no child case on right side\n if (this.right === undefined) {\n parent.right = this.left\n if (this.left !== undefined) {\n this.left.parent = parent\n }\n } else {\n parent.right = this.right\n this.right.parent = parent\n }\n parent.updateMaxOfParents()\n parent.updateHeight()\n parent._rebalance()\n return this\n }\n\n // Make linter happy\n return undefined\n }\n}\n\nexport class IntervalTree<T extends Interval<N>, N extends number | bigint = number> {\n root?: Node<T, N>\n count = 0\n\n insert(record: T) {\n if (record.low > record.high) {\n throw new Error('`low` value must be lower or equal to `high` value')\n }\n\n if (this.root === undefined) {\n // Base case: Tree is empty, new node becomes root\n this.root = new Node(this, record)\n this.count++\n return true\n }\n // Otherwise, check if node already exists with the same key\n const node = this.root.searchExisting(record.low)\n if (node === undefined) {\n // Node with this key doesn't already exist. Call insert function on root's node\n this.root.insert(record)\n this.count++\n return true\n }\n // Check the records in this node if there already is the one with same low, high, data\n for (const existing of node.records) {\n if (isSame(existing, record)) {\n // This record is same as the one we're trying to insert; return false to indicate\n // nothing has been inserted\n return false\n }\n }\n\n // Add the record to the node\n node.records.push(record)\n\n // Update max of the node and its parents if necessary\n if (record.high > node.max) {\n node.max = record.high\n if (node.parent) {\n node.parent.updateMaxOfParents()\n }\n }\n this.count++\n return true\n }\n\n search(low: N, high: N) {\n return this.root === undefined ? [] : this.root.search(low, high)\n }\n\n remove(record: T) {\n if (this.root === undefined) {\n // Tree is empty; nothing to remove\n return false\n }\n const node = this.root.searchExisting(record.low)\n if (node === undefined) {\n return false\n }\n if (node.records.length > 1) {\n // Node with this key has 2 or more records. Find the one we need and remove it\n const removedIndex = node.records.findIndex(r => isSame(r, record))\n\n if (removedIndex === -1) {\n return false\n }\n\n node.records.splice(removedIndex, 1)\n // Update max of that node and its parents if necessary\n if (record.high === node.max) {\n const nodeHigh = node.getNodeHigh()\n if (node.left !== undefined && node.right !== undefined) {\n node.max = max(max(node.left.max, node.right.max), nodeHigh)\n } else if (node.left !== undefined && node.right === undefined) {\n node.max = max(node.left.max, nodeHigh)\n } else if (node.left === undefined && node.right !== undefined) {\n node.max = max(node.right.max, nodeHigh)\n } else {\n node.max = nodeHigh\n }\n if (node.parent) {\n node.parent.updateMaxOfParents()\n }\n }\n this.count--\n return true\n }\n if (node.records.length === 1) {\n // Node with this key has only 1 record. Check if the remaining record in this node is\n // actually the one we want to remove\n if (isSame(node.records[0], record)) {\n // The remaining record is the one we want to remove. Remove the whole node from the tree\n if (this.root.key === node.key) {\n // We're removing the root element. Create a dummy node that will temporarily take\n // root's parent role\n const rootParent = new Node<T, N>(this, { low: record.low, high: record.low } as T)\n rootParent.left = this.root\n this.root.parent = rootParent\n const removedNode = this.root.remove(node)\n this.root = rootParent.left\n if (this.root !== undefined) {\n this.root.parent = undefined\n }\n if (removedNode) {\n this.count--\n return true\n }\n return false\n }\n const removedNode = this.root.remove(node)\n if (removedNode) {\n this.count--\n return true\n }\n return false\n }\n // The remaining record is not the one we want to remove\n return false\n }\n // No records at all in this node?! Shouldn't happen\n return false\n }\n\n inOrder() {\n return new InOrder(this.root)\n }\n\n reverseInOrder() {\n return new ReverseInOrder(this.root)\n }\n\n preOrder() {\n return new PreOrder(this.root)\n }\n}\n\nexport interface DataInterval<T, N extends number | bigint = number> extends Interval<N> {\n data: T\n}\n\n/**\n * The default export just wraps the `IntervalTree`, while providing a simpler API. Check out the\n * README for description on how to use each.\n */\nexport class DataIntervalTree<T, N extends number | bigint = number> {\n private tree = new IntervalTree<DataInterval<T, N>, N>()\n\n insert(low: N, high: N, data: T) {\n return this.tree.insert({\n low, high, data,\n })\n }\n\n remove(low: N, high: N, data: T) {\n return this.tree.remove({\n low, high, data,\n })\n }\n\n search(low: N, high: N) {\n return this.tree.search(low, high).map(v => v.data)\n }\n\n inOrder() {\n return this.tree.inOrder()\n }\n\n reverseInOrder() {\n return this.tree.reverseInOrder()\n }\n\n preOrder() {\n return this.tree.preOrder()\n }\n\n get count() {\n return this.tree.count\n }\n}\n\nabstract class TreeOrderIterator<T extends Interval<N>, N extends number | bigint = number>\nimplements IterableIterator<T> {\n protected stack: Node<T, N>[] = []\n\n protected currentNode?: Node<T, N>\n protected i: number | undefined\n\n constructor(startNode?: Node<T, N>) {\n if (startNode !== undefined) {\n this.initialize(startNode)\n }\n }\n\n protected abstract initialize(node: Node<T, N>): void\n\n [Symbol.iterator]() {\n return this\n }\n\n abstract next(): IteratorResult<T>\n}\n\nexport class InOrder<T extends Interval<N>, N extends number | bigint = number>\n extends TreeOrderIterator<T, N> {\n protected initialize(node: Node<T, N>) {\n this.push(node)\n }\n\n next(): IteratorResult<T> {\n // Will only happen if stack is empty and pop is called\n if (this.currentNode === undefined) {\n return {\n done: true,\n value: undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any as IteratorResult<T>\n }\n\n // Process this node\n if (this.i !== undefined && this.i < this.currentNode.records.length) {\n return {\n done: false,\n value: this.currentNode.records[this.i++],\n }\n }\n\n if (this.currentNode.right === undefined) {\n // Otherwise go up\n // Might pop the last and set this.currentNode = undefined\n this.pop()\n } else {\n // Can we go right?\n this.push(this.currentNode.right)\n }\n return this.next()\n }\n\n private push(node: Node<T, N>) {\n this.currentNode = node\n this.i = 0\n\n while (this.currentNode.left !== undefined) {\n this.stack.push(this.currentNode)\n this.currentNode = this.currentNode.left\n }\n }\n\n private pop() {\n this.currentNode = this.stack.pop()\n this.i = 0\n }\n}\n\nexport class ReverseInOrder<T extends Interval<N>, N extends number | bigint = number>\n extends TreeOrderIterator<T, N> {\n protected initialize(node: Node<T, N>) {\n this.push(node)\n }\n\n next(): IteratorResult<T> {\n // Will only happen if stack is empty and pop is called\n if (this.currentNode === undefined) {\n return {\n done: true,\n value: undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any as IteratorResult<T>\n }\n\n // Process this node\n if (this.currentNode.records.length > 0 && this.i !== undefined && this.i >= 0) {\n return {\n done: false,\n value: this.currentNode.records[this.i--],\n }\n }\n\n if (this.currentNode.left === undefined) {\n // Otherwise go up\n // Might pop the last and set this.currentNode = undefined\n this.pop()\n } else {\n // Can we go left?\n this.push(this.currentNode.left)\n }\n return this.next()\n }\n\n private push(node: Node<T, N>) {\n this.currentNode = node\n this.i = (this.currentNode?.records.length ?? 0) - 1\n\n while (this.currentNode.right !== undefined) {\n this.stack.push(this.currentNode)\n this.currentNode = this.currentNode.right\n this.i = (this.currentNode?.records.length ?? 0) - 1\n }\n }\n\n private pop() {\n this.currentNode = this.stack.pop()\n this.i = (this.currentNode?.records.length ?? 0) - 1\n }\n}\n\nexport class PreOrder<T extends Interval<N>, N extends number | bigint = number>\nimplements IterableIterator<T> {\n private stack: Node<T, N>[] = []\n\n private currentNode?: Node<T, N>\n private i = 0\n\n constructor(startNode?: Node<T, N>) {\n this.currentNode = startNode\n }\n\n [Symbol.iterator]() {\n return this\n }\n\n next(): IteratorResult<T> {\n // Will only happen if stack is empty and pop is called,\n // which only happens if there is no right node (i.e we are done)\n if (this.currentNode === undefined) {\n return {\n done: true,\n value: undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any as IteratorResult<T>\n }\n\n // Process this node\n if (this.i < this.currentNode.records.length) {\n return {\n done: false,\n value: this.currentNode.records[this.i++],\n }\n }\n\n if (this.currentNode.right !== undefined) {\n this.push(this.currentNode.right)\n }\n if (this.currentNode.left !== undefined) {\n this.push(this.currentNode.left)\n }\n this.pop()\n return this.next()\n }\n\n private push(node: Node<T, N>) {\n this.stack.push(node)\n }\n\n private pop() {\n this.currentNode = this.stack.pop()\n this.i = 0\n }\n}\n", "function seededRandom(seed: number): () => number {\n return function () {\n const x = Math.sin(seed++) * 10_000\n return x - Math.floor(x)\n }\n}\n\nexport function shuffleWithSeed<T>(set: Set<T>, seed: number): T[] {\n const array = [...set].toSorted((a, b) => String(a).localeCompare(String(b)))\n const random = seededRandom(seed) // Create seeded PRNG\n\n // Fisher-Yates Shuffle\n for (let i = array.length - 1; i > 0; i--) {\n const j = Math.floor(random() * (i + 1)) // Use PRNG for index\n const swap = array[i]\n array[i] = array[j]\n array[j] = swap\n }\n\n return array\n}\n", "import { asXL1BlockNumber, StepSizes } from '@xyo-network/xl1-sdk'\n\nexport type StepWindow = [number, number]\n\n/**\n * DO NOT USE!\n * This function is meant for future use cases where we need to get all block numbers\n * in a given step from a given block number\n */\nexport const stepWindowCalculatorFromBlock = (blockNumber: number): StepWindow => {\n // If the block number is less than the first step size, return the first window\n if (blockNumber < StepSizes[0]) {\n return [0, StepSizes[0] - 1]\n }\n\n let lower = 0\n\n for (let i = 0; i < StepSizes.length; i++) {\n const stepSize = StepSizes[i]\n let nextStep = StepSizes[i + 1]\n // If the block number is less than the first step size, return the first window\n // If we are past the first step size, we need to adjust the lower bound\n if (i > 0) lower = stepSize\n\n // If we are at the last step size, we need to calculate the next step dynamically\n if (i === StepSizes.length - 1) {\n // Increase the next step height to the end of the next window since we don't have\n // a predefined next step\n nextStep = asXL1BlockNumber(stepSize * 2, { name: 'stepWindowCalculatorFromBlock A' })\n // Dynamically increase the next step height until it is greater than the block number\n while (blockNumber >= nextStep) {\n // Set next step to the end of the next window\n nextStep = asXL1BlockNumber(nextStep + stepSize, { name: 'stepWindowCalculatorFromBlock B' })\n }\n }\n\n if (blockNumber >= stepSize && blockNumber <= nextStep) {\n // block number is between two step sizes so iterate till\n // we find the correct window\n for (let lowerBound = lower; lowerBound < nextStep; lowerBound += stepSize) {\n // -1 since the last block in the window includes step hash of the previous step\n const upperBound = lowerBound + stepSize - 1\n // if the block number is within the current window\n // return the lower and upper bounds of the window\n if (blockNumber >= lowerBound && blockNumber <= upperBound) {\n return [lowerBound, upperBound]\n }\n }\n }\n }\n throw new Error(`No valid window could be calculated for Block number ${blockNumber}.`)\n}\n", "import type { Logger, Promisable } from '@ariestools/sdk'\n\n/**\n * Executes a function and logs the duration.\n * This is useful for tracking the performance of startup tasks.\n * Written is such a fashion to be signature compatible with the\n * wrappers for spanning without exporting actual spans for functions\n * that initialize potentially long running background processes and\n * result in non-terminating spans.\n * @param name The name of the span\n * @param fn The function to execute within the span\n * @returns The result of the function\n */\nexport async function startupSpanAsync<T>(\n name: string,\n fn: () => Promisable<T>,\n logger?: Logger,\n): Promise<T> {\n const start = Date.now()\n try {\n logger?.log(`[${name}] Initializing`)\n const result = await fn()\n return result\n } finally {\n const stop = Date.now()\n const duration = stop - start\n logger?.log(`[${name}] Initialized (${duration}ms)`)\n }\n}\n", "import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'\nimport { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-base'\nimport chalk from 'chalk'\n\nexport function spanDurationInMillis(span: ReadableSpan) {\n return span.duration[0] * 1000 + span.duration[1] / 1e6\n}\n\nexport class XyoConsoleSpanExporter extends ConsoleSpanExporter {\n static readonly durationToLogLevel = [\n 0,\n 1,\n 10,\n 100,\n 1000,\n ]\n\n static readonly logLevelToChalkColor = [\n chalk.grey,\n chalk.white,\n chalk.green,\n chalk.yellow,\n chalk.red,\n ]\n\n private _logLevel: number\n\n constructor(logLevel = 0) {\n super()\n this._logLevel = logLevel\n }\n\n get logLevel() {\n return this._logLevel\n }\n\n override export(spans: ReadableSpan[]): void {\n for (const span of spans) {\n const spanLevel = this.spanLevel(span)\n if (spanLevel < this.logLevel) {\n continue\n }\n const duration = spanDurationInMillis(span)\n console.log(chalk.grey([\n `Span [${span.name}]`,\n this.logColor(spanLevel)(`${duration}ms`),\n `TraceId: ${span.spanContext().traceId}`,\n ].join(', ')))\n }\n }\n\n logColor(level: number) {\n return XyoConsoleSpanExporter.logLevelToChalkColor[level] ?? chalk.magenta\n }\n\n spanLevel(span: ReadableSpan) {\n let logLevel = 0\n const duration = spanDurationInMillis(span)\n for (let x = XyoConsoleSpanExporter.durationToLogLevel.length - 1; x >= 0; x--) {\n if (duration > XyoConsoleSpanExporter.durationToLogLevel[x]) {\n logLevel = x\n break\n }\n }\n return logLevel\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAMnB,IAAM,2CAAiE;AAAA,EAC5E,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;AASO,IAAM,oBAAoB,OAC/B,WACA,YAAsD,MAAM,MAC5D,cAAoC,6CACc;AAClD,MAAI,SAA+B,UAAU,YAAY,MAAM,IAAI,YAAY,SAAS;AACxF,MAAI;AACJ,KAAG;AAED,YAAQ,MAAM,UAAU,KAAK,EAAE,GAAG,aAAa,OAAe,CAAC;AAE/D,QAAI,MAAM,WAAW,EAAG;AAExB,UAAM,QAAQ,MAAM,KAAK,OAAK,UAAU,CAAC,CAAC;AAC1C,QAAI,MAAO,QAAO;AAElB,UAAM,gBAAgB,MAAM,GAAG,EAAE,GAAG;AACpC,QAAI,UAAU,aAAa,EAAG,UAAS;AAAA,EACzC,SAAS,MAAM,SAAS;AACxB,SAAO;AACT;;;ACtCA,SAAS,SAAS,uBAAuB;AAElC,IAAM,sBAAsB,OAAO,aAAoD;AAC5F,QAAM,YAAY,MAAM,gBAAgB,OAAO,EAAE,SAAS,MAAM,QAAQ,OAAO,EAAE,CAAC;AAClF,QAAM,UAAU,OAAO,QAAQ;AAC/B,SAAO;AACT;;;ACPA,SAAS,aAAAA,kBAAiB;AAiBnB,IAAM,wBAAwB,OACnC,QACA,aACA,cACA,YAA4D,MAAM,MAClE,SAAyD,MAAM,SAC7B;AAClC,QAAM,WAAW,MAAM,kBAAkB,aA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