import { FiltersEngine, Request, ENGINE_VERSION } from '@ghostery/adblocker';
export { Request as AdblockerRequest };
// eslint-disable-next-line @typescript-eslint/require-await
export default async function loadTrackerDBEngine(engineBytes) {
    const engine = FiltersEngine.deserialize(engineBytes);
    return {
        ENGINE_VERSION,
        engine,
        matchUrl(requestArgs, getPatternMetadataParams = { getDomainMetadata: true }) {
            const params = { ...requestArgs };
            if (params.type === undefined) {
                params.type = 'xhr';
            }
            return engine.getPatternMetadata(Request.fromRawDetails(params), getPatternMetadataParams);
        },
        matchDomain(domain) {
            if (!engine.metadata) {
                return [];
            }
            return engine.metadata.fromDomain(domain);
        },
    };
}
