import { fromOperationRaw, toOperationRaw } from "../account";
export const fromSignedOperationRaw = (signedOp, accountId) => {
    const { operation, signature, expirationDate, rawData } = signedOp;
    const out = {
        operation: fromOperationRaw(operation, accountId),
        signature,
    };
    if (rawData) {
        out.rawData = rawData;
    }
    if (expirationDate) {
        out.expirationDate = new Date(expirationDate);
    }
    return out;
};
export const toSignedOperationRaw = (signedOp, preserveSubOperation) => {
    const { operation, signature, expirationDate, rawData } = signedOp;
    const out = {
        operation: toOperationRaw(operation, preserveSubOperation),
        signature,
    };
    if (rawData) {
        out.rawData = rawData;
    }
    if (expirationDate) {
        out.expirationDate = expirationDate.toISOString();
    }
    return out;
};
export const fromSignOperationEventRaw = (e, accountId) => {
    switch (e.type) {
        case "signed":
            return {
                type: "signed",
                signedOperation: fromSignedOperationRaw(e.signedOperation, accountId),
            };
        default:
            return e;
    }
};
export const toSignOperationEventRaw = (e) => {
    switch (e.type) {
        case "signed":
            return {
                type: "signed",
                signedOperation: toSignedOperationRaw(e.signedOperation, true),
            };
        default:
            return e;
    }
};
//# sourceMappingURL=signOperation.js.map