import { getClashApiUrl } from '../../helpers'; import { createBaseApiRequest, IBaseApiResponse } from '../../api'; export async function triggerLatencyGroupTest( tag: string, timeout: number = 5000, url: string = 'https://www.gstatic.com/generate_204', ): Promise> { return createBaseApiRequest(() => fetch( `${getClashApiUrl()}/group/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }, ), ); } export async function triggerLatencyProxyTest( tag: string, timeout: number = 2000, url: string = 'https://www.gstatic.com/generate_204', ): Promise> { return createBaseApiRequest(() => fetch( `${getClashApiUrl()}/proxies/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }, ), ); }