import { dateToNumber } from '../utils/date';
import { PinTypeMap } from './types/entities';
export const mapParticleToEntity = (particle) => {
    const { cid, result, meta, textPreview } = particle;
    const { size, mime, type, blocks, sizeLocal } = meta;
    const text = (textPreview === null || textPreview === void 0 ? void 0 : textPreview.replace(/"/g, "'")) || '';
    return {
        cid,
        size: size || 0,
        mime: mime || 'unknown',
        type,
        text,
        size_local: sizeLocal || -1,
        blocks: blocks || 0,
    };
};
export const mapPinToEntity = (pin) => ({
    cid: pin.cid.toString(),
    type: PinTypeMap[pin.type],
});
export const mapTransactionToEntity = (neuron, tx) => {
    const { transaction_hash, transaction: { memo, block: { timestamp }, success, }, type, value, } = tx;
    return {
        hash: transaction_hash,
        type,
        timestamp: dateToNumber(timestamp),
        memo,
        value,
        success,
        neuron,
    };
};
export const mapLinkToEntity = (from, to, neuron = '', timestamp = 0) => ({
    from,
    to,
    neuron,
    timestamp,
});
//# sourceMappingURL=mapping.js.map