"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dst = exports.src = exports.apply = exports.diff = exports.toBin = exports.toStr = void 0;
const tslib_1 = require("tslib");
const str = tslib_1.__importStar(require("./str"));
const toStr = (buf) => {
    let hex = '';
    const length = buf.length;
    for (let i = 0; i < length; i++)
        hex += String.fromCharCode(buf[i]);
    return hex;
};
exports.toStr = toStr;
const toBin = (hex) => {
    const length = hex.length;
    const buf = new Uint8Array(length);
    for (let i = 0; i < length; i++)
        buf[i] = hex.charCodeAt(i);
    return buf;
};
exports.toBin = toBin;
const diff = (src, dst) => {
    const txtSrc = (0, exports.toStr)(src);
    const txtDst = (0, exports.toStr)(dst);
    return str.diff(txtSrc, txtDst);
};
exports.diff = diff;
const apply = (patch, srcLen, onInsert, onDelete) => str.apply(patch, srcLen, (pos, str) => onInsert(pos, (0, exports.toBin)(str)), onDelete);
exports.apply = apply;
const src = (patch) => (0, exports.toBin)(str.src(patch));
exports.src = src;
const dst = (patch) => (0, exports.toBin)(str.dst(patch));
exports.dst = dst;
//# sourceMappingURL=bin.js.map