interface MintallKeepGlobal {
	nonce: string;
	apiBase: string;
	adminUrl: string;
	adminEmail: string;
	appUrl: string;
	featureInDevelopment: boolean;
	/** Runtime MINTALL_KEEP_EDITION. A plain string: wp-config.php can set any value. */
	edition: string;
}

interface MintallKeepProductGlobal {
	productId: string;
	productName: string;
	nonce: string;
	apiBase: string;
}

declare global {
	interface Window {
		mintallKeep?: MintallKeepGlobal;
		mintallKeepProduct?: MintallKeepProductGlobal;
	}

	/** Build-time edition switch, injected via webpack.DefinePlugin (see webpack.config.js). */
	const MINTALL_EDITION: 'wporg' | 'woo';
}

declare module '@wordpress/api-fetch' {
	interface APIFetchOptions {
		path?: string;
		method?: string;
		data?: Record<string, unknown>;
	}

	type Middleware = (
		options: APIFetchOptions,
		next: (options: APIFetchOptions) => Promise<unknown>,
	) => Promise<unknown>;

	interface ApiFetch {
		(options: APIFetchOptions): Promise<unknown>;
		use: (middleware: Middleware) => void;
		createNonceMiddleware: (nonce: string | undefined) => Middleware;
		createRootURLMiddleware: (rootURL: string) => Middleware;
	}

	const apiFetch: ApiFetch;
	export default apiFetch;
}

declare module '@wordpress/element' {
	export const useState: typeof import('react').useState;
	export const useEffect: typeof import('react').useEffect;
	export const useRef: typeof import('react').useRef;
	export function createRoot(container: Element): {
		render(element: React.ReactNode): void;
	};
}

export {};
