import { A as NoWalletProviderFoundError, E as getWalletProviderFromWalletAccount, c as isWaasWalletProvider, d as DYNAMIC_WAAS_METADATA, f as getWalletProviders, gt as BaseError, pt as getDefaultClient } from "./updateAuthFromVerifyResponse-D1w-Aw9P.native.esm.js";
import { n as NotWaasWalletAccountError, r as __refreshAuth_wrapped } from "./isDynamicWaasEnabled-BXe0VyI4.native.esm.js";

//#region src/errors/NotWaasWalletProviderError.ts
var NotWaasWalletProviderError = class extends BaseError {
	constructor({ walletProviderKey }) {
		super({
			cause: null,
			code: "not_waas_wallet_provider_error",
			docsUrl: null,
			name: "NotWaasWalletProviderError",
			shortMessage: `Wallet provider ${walletProviderKey} is not a Dynamic WaaS wallet provider`
		});
	}
};

//#endregion
//#region src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts
/** @notInstrumented */
const getWaasWalletProviderFromWalletAccount = ({ walletAccount }, client) => {
	const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
	if (!isWaasWalletProvider(walletProvider)) throw new NotWaasWalletAccountError({ walletAddress: walletAccount.address });
	return walletProvider;
};

//#endregion
//#region src/modules/waas/migrateFromFireblocks/migrateFromFireblocks.ts
/**
* Migrates an existing Fireblocks NCW wallet into Dynamic's WaaS infrastructure.
*
* Migration is a single cross-chain operation: one call takes over the Fireblocks
* key material and provisions Dynamic WaaS wallet accounts for every supported
* chain. Because it is not per-chain, this resolves a single WaaS wallet provider
* (any registered chain) and delegates the takeover to it.
*
* @param params.deviceId - The Fireblocks NCW device id being migrated.
* @param params.jwt - The Fireblocks-issued JWT authorizing the takeover.
* @param params.storage - The serialized Fireblocks NCW device storage.
* @param params.password - The password that encrypted the legacy device storage.
* @param params.expectedAddresses - Required per-chain expected address; its keys are the chains migration runs on, and each imported address is verified against it.
* @param [params.coinTypes] - Optional SLIP-0044 coin types per chain name.
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
* @returns A promise resolving to the per-chain migration results.
* @notInstrumented
*/
const migrateFromFireblocks = async ({ coinTypes, deviceId, expectedAddresses, jwt, password, storage }, client = getDefaultClient()) => {
	const providers = getWalletProviders(client);
	if (providers.length === 0) throw new NoWalletProviderFoundError({ walletProviderKey: DYNAMIC_WAAS_METADATA.displayName });
	const waasProvider = providers.find(isWaasWalletProvider);
	if (!waasProvider) throw new NotWaasWalletProviderError({ walletProviderKey: providers[0].key });
	const result = await waasProvider.migrateFromFireblocks({
		coinTypes,
		deviceId,
		expectedAddresses,
		jwt,
		password,
		storage
	});
	await __refreshAuth_wrapped(client);
	return result;
};

//#endregion
export { getWaasWalletProviderFromWalletAccount as n, NotWaasWalletProviderError as r, migrateFromFireblocks as t };
//# sourceMappingURL=migrateFromFireblocks-D-J6-gRo.native.esm.js.map