import { __esDecorate, __runInitializers } from "tslib";
import { Action } from './Action.js';
import { observed, toRaw } from '../../decorators/observed.js';
/**
 * Enables retrieving a collection of resources.
 * Endpoint: GET /[entity-collection-name]
 */
let ListAction = (() => {
    let _classSuper = Action;
    let _kind_decorators;
    let _kind_initializers = [];
    let _kind_extraInitializers = [];
    let _pagination_decorators;
    let _pagination_initializers = [];
    let _pagination_extraInitializers = [];
    let _filterableFields_decorators;
    let _filterableFields_initializers = [];
    let _filterableFields_extraInitializers = [];
    let _sortableFields_decorators;
    let _sortableFields_initializers = [];
    let _sortableFields_extraInitializers = [];
    return class ListAction extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _kind_decorators = [observed()];
            _pagination_decorators = [observed({ deep: true })];
            _filterableFields_decorators = [observed({ deep: true })];
            _sortableFields_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, _pagination_decorators, { kind: "accessor", name: "pagination", static: false, private: false, access: { has: obj => "pagination" in obj, get: obj => obj.pagination, set: (obj, value) => { obj.pagination = value; } }, metadata: _metadata }, _pagination_initializers, _pagination_extraInitializers);
            __esDecorate(this, null, _filterableFields_decorators, { kind: "accessor", name: "filterableFields", static: false, private: false, access: { has: obj => "filterableFields" in obj, get: obj => obj.filterableFields, set: (obj, value) => { obj.filterableFields = value; } }, metadata: _metadata }, _filterableFields_initializers, _filterableFields_extraInitializers);
            __esDecorate(this, null, _sortableFields_decorators, { kind: "accessor", name: "sortableFields", static: false, private: false, access: { has: obj => "sortableFields" in obj, get: obj => obj.sortableFields, set: (obj, value) => { obj.sortableFields = value; } }, metadata: _metadata }, _sortableFields_initializers, _sortableFields_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; }
        #pagination_accessor_storage = (__runInitializers(this, _kind_extraInitializers), __runInitializers(this, _pagination_initializers, void 0));
        get pagination() { return this.#pagination_accessor_storage; }
        set pagination(value) { this.#pagination_accessor_storage = value; }
        #filterableFields_accessor_storage = (__runInitializers(this, _pagination_extraInitializers), __runInitializers(this, _filterableFields_initializers, []));
        get filterableFields() { return this.#filterableFields_accessor_storage; }
        set filterableFields(value) { this.#filterableFields_accessor_storage = value; }
        #sortableFields_accessor_storage = (__runInitializers(this, _filterableFields_extraInitializers), __runInitializers(this, _sortableFields_initializers, []));
        get sortableFields() { return this.#sortableFields_accessor_storage; }
        set sortableFields(value) { this.#sortableFields_accessor_storage = value; }
        constructor(state = {}) {
            super(state);
            __runInitializers(this, _sortableFields_extraInitializers);
            this.kind = state.kind || 'list';
            this.pagination = state.pagination
                ? { ...state.pagination }
                : {
                    kind: 'offset',
                };
            this.filterableFields = state.filterableFields ? [...state.filterableFields] : [];
            this.sortableFields = state.sortableFields ? [...state.sortableFields] : [];
        }
        toJSON() {
            return {
                ...super.toJSON(),
                pagination: structuredClone(toRaw(this, this.pagination)),
                filterableFields: structuredClone(toRaw(this, this.filterableFields)),
                sortableFields: structuredClone(toRaw(this, this.sortableFields)),
            };
        }
        static isListAction(action) {
            return action.kind === 'list';
        }
        static isListActionSchema(schema) {
            return schema.kind === 'list';
        }
    };
})();
export { ListAction };
//# sourceMappingURL=ListAction.js.map