import { eventually as awaiterUtilsEventually } from '@wix/awaiter-utils';
const DEFAULT_INTERVAL_MS = 10; // Reasonable interval for a component library which does not do any fetching
export const eventually = (fn, params) => {
    const testFrameworkTimeout = 10_000;
    const interval = params?.interval || DEFAULT_INTERVAL_MS;
    const suggestedTimeout = testFrameworkTimeout && testFrameworkTimeout - 2 * interval;
    let timeout;
    if (params?.timeout) {
        if (suggestedTimeout && params?.timeout > suggestedTimeout) {
            throw new Error(`eventually: options.timeout of ${params?.timeout} should be smaller than the suggested timeout (testFrameworkTimeout - 2 * interval = ${testFrameworkTimeout} - 2 * ${interval} = ${suggestedTimeout})`);
        }
    }
    else {
        timeout = suggestedTimeout;
    }
    return awaiterUtilsEventually(fn, { timeout, interval });
};
//# sourceMappingURL=eventually.js.map