var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Helpers } from '../helpers';
import { profile } from '@nativescript/core';
let ctor;
export class TextDecoder {
    get native() {
        return this._native;
    }
    constructor(encoding = 'utf-8') {
        this._native = new ctor(encoding);
    }
    get encoding() {
        return this.native.encoding;
    }
    decode(buffer, options) {
        if (buffer instanceof ArrayBuffer || buffer instanceof Uint8Array || buffer instanceof Int8Array || buffer instanceof Uint16Array || buffer instanceof Int16Array || buffer instanceof Uint32Array || buffer instanceof Int32Array || buffer instanceof Float32Array || buffer instanceof Uint8ClampedArray) {
            if (buffer.byteLength === 0) {
                return '';
            }
            return this.native.decode(buffer);
        }
        else {
            return '';
        }
    }
}
(() => {
    Helpers.initialize();
    ctor = global.CanvasModule.TextDecoder;
})();
__decorate([
    profile,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", String)
], TextDecoder.prototype, "decode", null);
//# sourceMappingURL=index.js.map