import { EventScope } from '@devvit/multiplatform/ui-shared-shared.js';
import { UIEventScope } from '@devvit/protos/payments.js';
const mapUIEventScopeToEventScope = (scope) => {
    switch (scope) {
        case UIEventScope.ALL:
            return EventScope.ALL;
        case UIEventScope.REMOTE:
            return EventScope.REMOTE;
        case UIEventScope.LOCAL:
            return EventScope.LOCAL;
        case UIEventScope.UNRECOGNIZED:
            return EventScope.ALL;
        default:
            throw new Error(`Unknown UIEventScope: ${scope}`);
    }
};
export class WrappedEvent {
    constructor(config) {
        this.scope = config.scope ? mapUIEventScopeToEventScope(config.scope) : EventScope.ALL;
        this.async = config.async;
        this.hook = config.hook;
        this.retry = config.retry;
        this.uiEvent = config;
    }
}
export class WrappedRequest {
    constructor(uiRequest) {
        this.uiRequest = uiRequest;
        this.events = uiRequest.events.map((event) => new WrappedEvent(event));
        if (uiRequest.state) {
            this.state = uiRequest.state;
        }
    }
}
export class WrappedResponse {
    constructor(uiResponse) {
        this.uiResponse = uiResponse;
        this.replay = uiResponse.events.map((event) => new WrappedEvent(event));
        if (uiResponse.state) {
            this.state = uiResponse.state;
        }
    }
}
//# sourceMappingURL=mappers.js.map