import { set_platform } from './platform.common.js';
import { ident } from './prototype.common.js';
import { encoder } from './utils.common.js';
export * from './platform.common.js';
function get_buffer(length) {
    return new Uint8Array(length);
}
function encode(str) {
    return encoder.encode(str);
}
async function delay(milliseconds, { signal } = {}) {
    signal?.throwIfAborted();
    return new Promise((resolve, reject) => {
        function on_signal_abort() {
            clearTimeout(timeout);
            reject(signal.reason);
        }
        signal?.addEventListener('abort', on_signal_abort);
        let timeout = setTimeout(() => {
            signal?.removeEventListener('abort', on_signal_abort);
            resolve();
        }, milliseconds);
    });
}
set_platform({
    nodejs: false,
    browser: true,
    get_buffer,
    encode,
    delay,
    strip_ansi: ident,
    get_websocket() {
        return globalThis.WebSocket;
    },
    get_https_proxy_agent() {
        return null;
    }
});
//# sourceMappingURL=platform.browser.js.map