export interface AccessRuleSchema {
  /**
   * The unique identifier for the access rule.
   * This is used to reference the rule in the API configuration.
   */
  type: string
}

/**
 * Base class for all access rules.
 */
export class AccessRule extends EventTarget implements AccessRuleSchema {
  readonly type: string

  constructor(state: Partial<AccessRuleSchema> = {}) {
    super()
    this.type = state.type ?? ''
  }

  toJSON(): AccessRuleSchema {
    return {
      type: this.type,
    }
  }

  notifyChange() {
    this.dispatchEvent(new Event('change'))
  }
}
