const ABORTABLE_WORKER_REQUEST_TYPES = new Set([
    'syncPull',
    'syncPush',
    'syncOnce',
    'storeBlob',
    'retrieveBlob',
    'processBlobUploadQueue',
]);
const DIAGNOSED_SUCCESS_WORKER_REQUEST_TYPES = new Set([
    'open',
    'setAuthHeaders',
    'setFieldEncryption',
    'setEncryptedCrdt',
    'setBlobEncryption',
    'forceSubscriptionsBootstrap',
    'startRealtime',
    'stopRealtime',
    'syncPull',
    'syncPush',
    'syncOnce',
    'storeBlob',
    'retrieveBlob',
    'processBlobUploadQueue',
    'pruneBlobCache',
    'clearBlobCache',
    'compactStorage',
    'exportLocalSupportBundle',
    'importLocalSupportBundle',
    'repairLocalHealth',
    'resetLocalSyncState',
    'close',
]);
const OPERATIONAL_STATE_WORKER_REQUEST_TYPES = new Set([
    'upsertAuthLease',
    'applyMutation',
    'applyLeasedMutation',
    'applyMutationsBatch',
    'applyMutationsCommit',
    'applyLeasedMutationsCommit',
    'syncPull',
    'syncPush',
    'syncOnce',
    'retryConflictKeepLocal',
    'resolveConflict',
    'compactStorage',
    'repairLocalHealth',
    'resetLocalSyncState',
]);
const WORKER_REQUEST_DIAGNOSTIC_SOURCES = {
    open: 'storage',
    setAuthHeaders: 'auth',
    setFieldEncryption: 'client',
    setEncryptedCrdt: 'client',
    setBlobEncryption: 'client',
    setSubscriptions: 'sync',
    forceSubscriptionsBootstrap: 'sync',
    startRealtime: 'realtime',
    stopRealtime: 'realtime',
    syncPull: 'sync',
    syncPush: 'sync',
    syncOnce: 'sync',
    storeBlob: 'blob',
    retrieveBlob: 'blob',
    isBlobLocal: 'blob',
    processBlobUploadQueue: 'blob',
    blobUploadQueueStats: 'blob',
    blobCacheStats: 'blob',
    pruneBlobCache: 'blob',
    clearBlobCache: 'blob',
    compactStorage: 'storage',
    generatedSchemaState: 'storage',
    localHealthCheck: 'storage',
    exportLocalSupportBundle: 'storage',
    importLocalSupportBundle: 'storage',
    repairLocalHealth: 'storage',
    resetLocalSyncState: 'storage',
    encryptionHelper: 'client',
    close: 'storage',
};
export function isGeneratedSyncularAbortableWorkerRequestType(type) {
    return ABORTABLE_WORKER_REQUEST_TYPES.has(type);
}
export function isGeneratedSyncularDiagnosedSuccessWorkerRequestType(type) {
    return DIAGNOSED_SUCCESS_WORKER_REQUEST_TYPES.has(type);
}
export function isGeneratedSyncularOperationalStateWorkerRequestType(type) {
    return OPERATIONAL_STATE_WORKER_REQUEST_TYPES.has(type);
}
export function generatedSyncularWorkerRequestDiagnosticSource(type) {
    return WORKER_REQUEST_DIAGNOSTIC_SOURCES[type] ?? 'worker';
}
export async function dispatchGeneratedSyncularWorkerRequest(context, request) {
    switch (request.type) {
        case 'open':
            return context.openClient(request);
        case 'setAuthHeaders':
            return context.requireClient().setAuthHeaders(request.headers);
        case 'setFieldEncryption':
            return context.requireClient().setFieldEncryption(request.config);
        case 'setEncryptedCrdt':
            return context.requireClient().setEncryptedCrdt(request.config);
        case 'setBlobEncryption':
            return context.requireClient().setBlobEncryption(request.config);
        case 'setSubscriptions':
            return context.requireClient().setSubscriptions(request.subscriptions);
        case 'forceSubscriptionsBootstrap':
            return context
                .requireClient()
                .forceSubscriptionsBootstrap(request.subscriptionIds ?? []);
        case 'upsertAuthLease':
            return context.requireClient().upsertAuthLease(request.lease);
        case 'authLease':
            return context.requireClient().authLease(request.leaseId);
        case 'activeAuthLeases':
            return context
                .requireClient()
                .activeAuthLeases(request.actorId, request.nowMs);
        case 'startRealtime':
            return context.startRealtime(request.options);
        case 'stopRealtime':
            return context.stopRealtime();
        case 'sendPresence':
            return context.sendPresence(request.action, request.scopeKey, request.metadata);
        case 'executeSql':
            return context.requireClient().executeSql(request.sql, request.params);
        case 'executeUnsafeSql':
            return context
                .requireClient()
                .executeUnsafeSql(request.sql, request.params);
        case 'subscribeQuery':
            return context
                .requireClient()
                .subscribeQuery(request.sql, request.params, request.tables, request.hints ?? []);
        case 'unsubscribeQuery':
            return context.requireClient().unsubscribeQuery(request.queryId) ?? true;
        case 'drainLiveQueryEvents':
            return context.requireClient().drainLiveQueryEvents();
        case 'liveQueryDiagnostics':
            return context.requireClient().liveQueryDiagnostics();
        case 'applyMutation':
            return context
                .requireClient()
                .applyMutation(request.operation, request.localRow);
        case 'applyLeasedMutation':
            return context
                .requireClient()
                .applyLeasedMutation(request.operation, request.localRow);
        case 'applyMutationsBatch':
            return context.requireClient().applyMutationsBatch(request.operations);
        case 'applyMutationsCommit':
            return context.requireClient().applyMutationsCommit(request.operations);
        case 'applyLeasedMutationsCommit':
            return context
                .requireClient()
                .applyLeasedMutationsCommit(request.operations);
        case 'syncPull':
            return context
                .requireClient()
                .syncPull({ syncAttempt: request.syncAttempt });
        case 'syncPush':
            return context
                .requireClient()
                .syncPush({ syncAttempt: request.syncAttempt });
        case 'syncOnce':
            return context
                .requireClient()
                .syncOnce({ syncAttempt: request.syncAttempt });
        case 'transportStats':
            return context.requireClient().transportStats();
        case 'resetTransportStats':
            return context.requireClient().resetTransportStats() ?? true;
        case 'conflictSummaries':
            return context.requireClient().conflictSummaries();
        case 'retryConflictKeepLocal':
            return context.requireClient().retryConflictKeepLocal(request.conflictId);
        case 'resolveConflict':
            return context
                .requireClient()
                .resolveConflict(request.conflictId, request.resolution);
        case 'listTable':
            return context.requireClient().listTable(request.table);
        case 'storeBlob':
            return context.requireClient().storeBlob(request.data, request.options);
        case 'retrieveBlob':
            return context.requireClient().retrieveBlob(request.ref);
        case 'isBlobLocal':
            return context.requireClient().isBlobLocal(request.hash);
        case 'processBlobUploadQueue':
            return context.requireClient().processBlobUploadQueue(request.options);
        case 'blobUploadQueueStats':
            return context.requireClient().blobUploadQueueStats();
        case 'blobCacheStats':
            return context.requireClient().blobCacheStats();
        case 'pruneBlobCache':
            return context.requireClient().pruneBlobCache(request.maxBytes);
        case 'clearBlobCache':
            return context.requireClient().clearBlobCache() ?? true;
        case 'compactStorage':
            return context.requireClient().compactStorage(request.options);
        case 'generatedSchemaState':
            return context.requireClient().generatedSchemaState();
        case 'localHealthCheck':
            return context.requireClient().localHealthCheck();
        case 'exportLocalSupportBundle':
            return context.requireClient().exportLocalSupportBundle();
        case 'importLocalSupportBundle':
            return context
                .requireClient()
                .importLocalSupportBundle(request.bundleJson);
        case 'repairLocalHealth':
            return context.requireClient().repairLocalHealth(request.request);
        case 'resetLocalSyncState':
            return context.requireClient().resetLocalSyncState(request.request);
        case 'buildYjsTextUpdate':
            return context.requireClient().buildYjsTextUpdate(request.args);
        case 'applyYjsTextUpdates':
            return context.requireClient().applyYjsTextUpdates(request.args);
        case 'applyYjsEnvelopeToPayload':
            return context.requireClient().applyYjsEnvelopeToPayload(request.args);
        case 'openCrdtField':
            return context.requireClient().openCrdtField(request.request);
        case 'applyCrdtFieldText':
            return context.requireClient().applyCrdtFieldText(request.request);
        case 'applyCrdtFieldYjsUpdate':
            return context.requireClient().applyCrdtFieldYjsUpdate(request.request);
        case 'materializeCrdtField':
            return context.requireClient().materializeCrdtField(request.request);
        case 'crdtDocumentSnapshot':
            return context.requireClient().crdtDocumentSnapshot(request.request);
        case 'crdtUpdateLog':
            return context.requireClient().crdtUpdateLog(request.request);
        case 'snapshotCrdtFieldStateVector':
            return context
                .requireClient()
                .snapshotCrdtFieldStateVector(request.request);
        case 'compactCrdtField':
            return context.requireClient().compactCrdtField(request.request);
        case 'encryptionHelper':
            return context
                .requireClient()
                .encryptionHelper(request.method, request.args);
        case 'runtimeInfo':
            return context.runtimeInfo();
        case 'close':
            return context.closeClient();
        case 'cancel':
            throw new Error('Generated Syncular bridge dispatch does not handle cancel requests.');
    }
}
//# sourceMappingURL=generated-bridge.js.map