"use strict";
/**
 * WebCodecs type definitions for Node.js
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.DOMException = exports.WebCodecsDOMException = exports.DOMRectReadOnly = void 0;
exports.createDOMException = createDOMException;
// Polyfill DOMRectReadOnly for Node.js
class DOMRectReadOnly {
    constructor(x = 0, y = 0, width = 0, height = 0) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.top = y;
        this.right = x + width;
        this.bottom = y + height;
        this.left = x;
    }
    toJSON() {
        return { x: this.x, y: this.y, width: this.width, height: this.height };
    }
}
exports.DOMRectReadOnly = DOMRectReadOnly;
// Polyfill DOMException for Node.js if not available
class WebCodecsDOMException extends Error {
    constructor(message, name) {
        super(message);
        this.name = name ?? 'Error';
        this.code = WebCodecsDOMException.ERROR_CODES[this.name] ?? 0;
        Object.setPrototypeOf(this, WebCodecsDOMException.prototype);
    }
}
exports.WebCodecsDOMException = WebCodecsDOMException;
exports.DOMException = WebCodecsDOMException;
WebCodecsDOMException.INDEX_SIZE_ERR = 1;
WebCodecsDOMException.DOMSTRING_SIZE_ERR = 2;
WebCodecsDOMException.HIERARCHY_REQUEST_ERR = 3;
WebCodecsDOMException.WRONG_DOCUMENT_ERR = 4;
WebCodecsDOMException.INVALID_CHARACTER_ERR = 5;
WebCodecsDOMException.NO_DATA_ALLOWED_ERR = 6;
WebCodecsDOMException.NO_MODIFICATION_ALLOWED_ERR = 7;
WebCodecsDOMException.NOT_FOUND_ERR = 8;
WebCodecsDOMException.NOT_SUPPORTED_ERR = 9;
WebCodecsDOMException.INUSE_ATTRIBUTE_ERR = 10;
WebCodecsDOMException.INVALID_STATE_ERR = 11;
WebCodecsDOMException.SYNTAX_ERR = 12;
WebCodecsDOMException.INVALID_MODIFICATION_ERR = 13;
WebCodecsDOMException.NAMESPACE_ERR = 14;
WebCodecsDOMException.INVALID_ACCESS_ERR = 15;
WebCodecsDOMException.VALIDATION_ERR = 16;
WebCodecsDOMException.TYPE_MISMATCH_ERR = 17;
WebCodecsDOMException.SECURITY_ERR = 18;
WebCodecsDOMException.NETWORK_ERR = 19;
WebCodecsDOMException.ABORT_ERR = 20;
WebCodecsDOMException.URL_MISMATCH_ERR = 21;
WebCodecsDOMException.QUOTA_EXCEEDED_ERR = 22;
WebCodecsDOMException.TIMEOUT_ERR = 23;
WebCodecsDOMException.INVALID_NODE_TYPE_ERR = 24;
WebCodecsDOMException.DATA_CLONE_ERR = 25;
WebCodecsDOMException.ERROR_CODES = {
    IndexSizeError: 1,
    HierarchyRequestError: 3,
    WrongDocumentError: 4,
    InvalidCharacterError: 5,
    NoModificationAllowedError: 7,
    NotFoundError: 8,
    NotSupportedError: 9,
    InUseAttributeError: 10,
    InvalidStateError: 11,
    SyntaxError: 12,
    InvalidModificationError: 13,
    NamespaceError: 14,
    InvalidAccessError: 15,
    TypeMismatchError: 17,
    SecurityError: 18,
    NetworkError: 19,
    AbortError: 20,
    URLMismatchError: 21,
    QuotaExceededError: 22,
    TimeoutError: 23,
    InvalidNodeTypeError: 24,
    DataCloneError: 25,
    EncodingError: 0,
    NotReadableError: 0,
    UnknownError: 0,
    ConstraintError: 0,
    DataError: 0,
    TransactionInactiveError: 0,
    ReadOnlyError: 0,
    VersionError: 0,
    OperationError: 0,
};
function createDOMException(message, name) {
    return new WebCodecsDOMException(message, name);
}
//# sourceMappingURL=types.js.map