import { Mixin } from 'ts-mixer';
import { always } from 'ramda';
import { toValue } from '@swagger-api/apidom-core';
import { MapVisitor, FallbackVisitor } from '@swagger-api/apidom-ns-openapi-3-1';
import WebhooksElement from "../../../elements/nces/Webhooks.mjs";
import { isPathItemElement } from "../../../predicates.mjs";
/**
 * @public
 */
/**
 * @public
 */
class WebhooksVisitor extends Mixin(MapVisitor, FallbackVisitor) {
  constructor(options) {
    super(options);
    this.element = new WebhooksElement();
    this.specPath = always(['document', 'objects', 'PathItem']);
  }
  ObjectElement(objectElement) {
    const result = MapVisitor.prototype.ObjectElement.call(this, objectElement);

    // decorate every PathItemElement with Webhook name metadata
    this.element.filter(isPathItemElement)
    // @ts-ignore
    .forEach((pathItemElement, key) => {
      // @ts-ignore
      pathItemElement.setMetaProperty('webhook-name', toValue(key));
    });
    return result;
  }
}
export default WebhooksVisitor;