/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Access, Conformance, Constraint, Quality } from "../aspects/index.js";
import { ElementTag } from "../common/index.js";
import { RequirementElement } from "../elements/index.js";
import { Model } from "./Model.js";
class RequirementModel extends Model {
  tag = RequirementElement.Tag;
  #constraint;
  #conformance;
  #access;
  #quality;
  get discriminator() {
    return this.element;
  }
  get constraint() {
    return this.#constraint;
  }
  set constraint(definition) {
    this.#constraint = Constraint.create(definition);
  }
  get conformance() {
    return this.#conformance;
  }
  set conformance(definition) {
    this.#conformance = Conformance.create(definition);
  }
  get access() {
    return this.#access;
  }
  set access(definition) {
    this.#access = Access.create(definition);
  }
  get quality() {
    return this.#quality;
  }
  set quality(definition) {
    this.#quality = Quality.create(definition);
  }
  /**
   * Condition requirements may derive from ConditionElement models via qualified types
   * (e.g. type: "RootNode.AclExtensionCond").
   */
  get allowedBaseTags() {
    if (this.element === RequirementElement.ElementType.Condition) {
      return [this.tag, ElementTag.Condition];
    }
    return [this.tag];
  }
  get requirements() {
    return this.all(RequirementModel);
  }
  /**
   * Is the element mandatory?
   */
  get isMandatory() {
    return this.conformance.isMandatory;
  }
  constructor(definition, ...children) {
    super(definition, ...children);
    this.element = definition.element;
    this.default = definition.default;
    this.instance = definition.instance;
    this.#constraint = Constraint.create(definition.constraint);
    this.#conformance = Conformance.create(definition.conformance);
    this.#access = Access.create(definition.access);
    this.#quality = Quality.create(definition.quality);
  }
  toElement(omitResources = false, extra) {
    return super.toElement(omitResources, {
      element: this.element,
      instance: this.instance,
      default: this.default,
      constraint: this.#constraint.valueOf(),
      conformance: this.#conformance.valueOf(),
      access: this.#access.valueOf(),
      quality: this.#quality.valueOf(),
      ...extra
    });
  }
  static Tag = RequirementElement.Tag;
}
RequirementModel.register();
export {
  RequirementModel
};
//# sourceMappingURL=RequirementModel.js.map
