'use client'
import { __awaiter } from '../../../../../_virtual/_tslib.js';
import ApiEndpoint from '../../../config/ApiEndpoint.js';
import '@dynamic-labs-sdk/client/core';
import '@dynamic-labs/sdk-api-core';
import 'react';
import 'eventemitter3';
import '@dynamic-labs/utils';
import '@dynamic-labs-sdk/client';
import '@dynamic-labs/iconic';
import '@dynamic-labs/wallet-connector-core';
import 'react/jsx-runtime';
import '../../../context/ViewContext/ViewContext.js';
import '../../../shared/logger.js';
import '@dynamic-labs/wallet-book';
import '../../../utils/constants/colors.js';
import '../../../utils/constants/values.js';
import '../../../shared/consts/index.js';
import { getApiHeaders } from '../../../client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js';
import '../../../events/dynamicEvents.js';
import { sdkApi } from '../api.js';

const getMoonPayCurrencies = (_a) => __awaiter(void 0, [_a], void 0, function* ({ chain, environmentId, networkId, }) {
    var _b;
    const params = new URLSearchParams({ chain });
    if (networkId) {
        params.set('networkId', networkId);
    }
    const response = yield fetch(`${ApiEndpoint.getBaseUrl()}/sdk/${environmentId}/onramps/moonpay/currencies?${params}`, {
        headers: Object.assign({ 'Content-Type': 'application/json' }, getApiHeaders()),
    });
    if (!response.ok) {
        throw new Error('Failed to fetch MoonPay currencies');
    }
    const data = yield response.json();
    return (_b = data.currencies) !== null && _b !== void 0 ? _b : [];
});
const getOnrampProviders = (_c) => __awaiter(void 0, [_c], void 0, function* ({ chain, environmentId, networkId, token, tokenAmount, walletAddress, currency, includeDisabled, merchantName, }) {
    const { onramps } = yield sdkApi().getSupportedOnramps({
        chain,
        currency,
        environmentId,
        includeDisabled,
        merchantName,
        networkId: networkId ? String(networkId) : undefined,
        token,
        tokenAmount,
        walletAddress,
    });
    return onramps !== null && onramps !== void 0 ? onramps : [];
});

export { getMoonPayCurrencies, getOnrampProviders };
