"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addZapResolver = addZapResolver;
exports.resolveZap = resolveZap;
exports.saveZapData = saveZapData;
exports.getZapData = getZapData;
exports.clearZapData = clearZapData;
exports.saveSessionPrivateKey = saveSessionPrivateKey;
exports.getSessionPrivateKey = getSessionPrivateKey;
exports.clearSessionPrivateKey = clearSessionPrivateKey;
exports.setSessionTransactionConfirmationMode = setSessionTransactionConfirmationMode;
exports.getSessionTransactionConfirmationMode = getSessionTransactionConfirmationMode;
exports.setSessionTransactionConfirmationHandler = setSessionTransactionConfirmationHandler;
exports.getSessionTransactionConfirmationHandler = getSessionTransactionConfirmationHandler;
const zapResolvers = new Map();
const zapDataRegistry = new Map();
const sessionPrivateKeyRegistry = new Map();
const sessionTxConfirmationModeRegistry = new Map();
const sessionTxConfirmationHandlerRegistry = new Map();
function addZapResolver(sessionId, resolver) {
    console.log(`Adding zap resolver for session ${sessionId}`);
    zapResolvers.set(sessionId, resolver);
}
function resolveZap(sessionId, result) {
    const resolver = zapResolvers.get(sessionId);
    if (resolver) {
        resolver(result);
        zapResolvers.delete(sessionId);
        zapDataRegistry.delete(sessionId); // clean up zap data
        return true;
    }
    return false;
}
function saveZapData(sessionId, data) {
    console.log(`Saving zap data for session ${sessionId}`);
    zapDataRegistry.set(sessionId, data);
}
function getZapData(sessionId) {
    return zapDataRegistry.get(sessionId);
}
function clearZapData(sessionId) {
    zapDataRegistry.delete(sessionId);
}
function saveSessionPrivateKey(sessionId, privateKey) {
    if (!privateKey || privateKey.trim().length === 0) {
        return;
    }
    sessionPrivateKeyRegistry.set(sessionId, privateKey.trim());
}
function getSessionPrivateKey(sessionId) {
    return sessionPrivateKeyRegistry.get(sessionId);
}
function clearSessionPrivateKey(sessionId) {
    sessionPrivateKeyRegistry.delete(sessionId);
}
function setSessionTransactionConfirmationMode(sessionId, enabled) {
    sessionTxConfirmationModeRegistry.set(sessionId, enabled);
}
function getSessionTransactionConfirmationMode(sessionId) {
    var _a;
    return (_a = sessionTxConfirmationModeRegistry.get(sessionId)) !== null && _a !== void 0 ? _a : false;
}
function setSessionTransactionConfirmationHandler(sessionId, handler) {
    if (!handler) {
        sessionTxConfirmationHandlerRegistry.delete(sessionId);
        return;
    }
    sessionTxConfirmationHandlerRegistry.set(sessionId, handler);
}
function getSessionTransactionConfirmationHandler(sessionId) {
    return sessionTxConfirmationHandlerRegistry.get(sessionId);
}
