"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerOps = void 0;
var getSize = function (size_tensor) {
    var size = Array.from((size_tensor).dataSync());
    if (size_tensor.shape[0] < 2) {
        console.error(size_tensor.dataSync(), size_tensor.shape);
        throw new Error('Invalid size tensor');
    }
    var _a = Array.from(size_tensor.dataSync()), height = _a[0], width = _a[1];
    if (!height || !width) {
        console.error(size);
        throw new Error('Missing size elements');
    }
    return [
        height,
        width,
    ];
};
function registerOps(tf) {
    var ScaleAndTranslate = function (_a) {
        var inputs = _a.inputs;
        if (inputs.length <= 2) {
            throw new Error('Expected four tensors to scale and translate op');
        }
        var input = inputs[0], size_tensor = inputs[1];
        return tf.tidy(function () {
            var size = getSize(size_tensor);
            return tf.image.resizeNearestNeighbor(input, size);
        });
    };
    tf.registerOp('ScaleAndTranslate', ScaleAndTranslate);
}
exports.registerOps = registerOps;
