import { __esDecorate, __runInitializers } from "tslib";
import { Action } from './Action.js';
import { observed, toRaw } from '../../decorators/observed.js';
/**
 * Enables modifying an existing resource.
 * Endpoints: PUT or PATCH /[entity-collection-name]/{id}
 */
let UpdateAction = (() => {
    let _classSuper = Action;
    let _kind_decorators;
    let _kind_initializers = [];
    let _kind_extraInitializers = [];
    let _allowedMethods_decorators;
    let _allowedMethods_initializers = [];
    let _allowedMethods_extraInitializers = [];
    return class UpdateAction extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _kind_decorators = [observed()];
            _allowedMethods_decorators = [observed({ deep: true })];
            __esDecorate(this, null, _kind_decorators, { kind: "accessor", name: "kind", static: false, private: false, access: { has: obj => "kind" in obj, get: obj => obj.kind, set: (obj, value) => { obj.kind = value; } }, metadata: _metadata }, _kind_initializers, _kind_extraInitializers);
            __esDecorate(this, null, _allowedMethods_decorators, { kind: "accessor", name: "allowedMethods", static: false, private: false, access: { has: obj => "allowedMethods" in obj, get: obj => obj.allowedMethods, set: (obj, value) => { obj.allowedMethods = value; } }, metadata: _metadata }, _allowedMethods_initializers, _allowedMethods_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        #kind_accessor_storage = __runInitializers(this, _kind_initializers, void 0);
        get kind() { return this.#kind_accessor_storage; }
        set kind(value) { this.#kind_accessor_storage = value; }
        #allowedMethods_accessor_storage = (__runInitializers(this, _kind_extraInitializers), __runInitializers(this, _allowedMethods_initializers, void 0));
        get allowedMethods() { return this.#allowedMethods_accessor_storage; }
        set allowedMethods(value) { this.#allowedMethods_accessor_storage = value; }
        constructor(state = {}) {
            super(state);
            __runInitializers(this, _allowedMethods_extraInitializers);
            this.kind = 'update';
            this.allowedMethods = state.allowedMethods ? [...state.allowedMethods] : ['PATCH'];
        }
        toJSON() {
            return {
                ...super.toJSON(),
                kind: 'update',
                allowedMethods: structuredClone(toRaw(this, this.allowedMethods)),
            };
        }
        static isUpdateAction(action) {
            return action.kind === 'update';
        }
        static isUpdateActionSchema(schema) {
            return schema.kind === 'update';
        }
    };
})();
export { UpdateAction };
//# sourceMappingURL=UpdateAction.js.map