"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapImageData = void 0;
const _1 = require("../Class/$");
const InvalidKeyPathError_1 = require("../exception/InvalidKeyPathError");
const Array_1 = require("./Array");
function wrapImageData(imageData, system) {
    const image = new (class ImageObject extends _1.$ {
        constructor() {
            super(...arguments);
            this.__ = ['J', 'ID'];
        }
        imageData() {
            return imageData;
        }
        get(name) {
            return __awaiter(this, void 0, void 0, function* () {
                if (imageData[name] !== undefined) {
                    if (name === 'data') {
                        return (0, Array_1.wrapUint8Array)(imageData.data, system);
                    }
                    return imageData[name];
                }
            });
        }
        set(name, data) {
            return __awaiter(this, void 0, void 0, function* () {
                throw new Error('read only');
            });
        }
        delete(name) {
            return __awaiter(this, void 0, void 0, function* () {
                throw new Error('read only');
            });
        }
        hasKey(name) {
            return __awaiter(this, void 0, void 0, function* () {
                if (imageData[name] !== undefined) {
                    return true;
                }
                return false;
            });
        }
        keys() {
            return __awaiter(this, void 0, void 0, function* () {
                return ['width', 'height', 'data', 'colorSpace'];
            });
        }
        deepGet(path) {
            if (path.length === 1) {
                return this.get(path[0]);
            }
            throw new InvalidKeyPathError_1.InvalidKeyPathError();
        }
        deepSet(path, data) {
            throw new Error('read only');
        }
        deepDelete(path) {
            throw new Error('read only');
        }
        subscribe(path, key, listener) {
            throw new Error('read only');
        }
        raw() {
            return imageData;
        }
    })(system);
    return image;
}
exports.wrapImageData = wrapImageData;
//# sourceMappingURL=ImageData.js.map