'use client'
import { SDKApi, Configuration } from '@dynamic-labs/sdk-api-core';
import { FetchService } from '@dynamic-labs/utils';
import '@dynamic-labs-sdk/client/core';
import '../../client/client.js';
import 'react';
import '@dynamic-labs-sdk/client';
import ApiEndpoint from '../../config/ApiEndpoint.js';
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 { getProjectSettings } from '../../client/extension/projectSettings/getProjectSettings/getProjectSettings.js';
import '../../../../_virtual/_tslib.js';
import { isCookieEnabled } from '../../client/extension/functions/isCookieEnabled/isCookieEnabled.js';
import { getMinAuthToken } from '../../client/extension/functions/getMinAuthToken/getMinAuthToken.js';
import '@dynamic-labs/multi-wallet';
import 'react-international-phone';
import '../../store/state/nonce/nonce.js';
import { randomString } from '../../utils/functions/randomString/randomString.js';
import '@dynamic-labs/locale';
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../store/state/primaryWalletId/primaryWalletId.js';
import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';

const sdkApi = ({ customHeaders } = {}) => {
    const settings = {
        basePath: ApiEndpoint.getBaseUrl(),
        headers: Object.assign(Object.assign({ 'Content-Type': 'application/json', 'x-dyn-request-id': randomString(50) }, getApiHeaders()), customHeaders),
    };
    const minJwt = getMinAuthToken();
    if (minJwt) {
        settings.headers.Authorization = `Bearer ${minJwt}`;
    }
    const projectSettings = getProjectSettings();
    const credentials = projectSettings && isCookieEnabled() ? 'include' : undefined;
    return new SDKApi(new Configuration(Object.assign(Object.assign({}, settings), { credentials, fetchApi: FetchService.fetch })));
};

export { sdkApi };
