<ng-container *ngIf="linked; else unlinked">
  <a [routerLink]="therapy.link">
    <ng-template [ngTemplateOutlet]="tag"></ng-template>
  </a>
</ng-container>

<ng-template #tag>
  <nz-tag
    nz-popover
    [nzPopoverMouseEnterDelay]="0.5"
    [nzPopoverContent]="enablePopover ? therapyPopover : undefined"
    [nzPopoverPlacement]="popoverPlacement">
    <ng-template [ngTemplateOutlet]="tagContent"></ng-template>
  </nz-tag>

  <ng-template #therapyPopover>
    <cvc-therapy-popover
      [therapyId]="therapy.id"
      (contentRendered)="updatePopoverPosition()"></cvc-therapy-popover>
  </ng-template>
</ng-template>

<ng-template #unlinked>
  <ng-template [ngTemplateOutlet]="tag"></ng-template>
</ng-template>

<ng-template #tagContent>
  <i
    nz-icon
    nzType="civic-therapy"
    nzTheme="twotone"
    nzTwotoneColor="#AC3996"></i>
  <ng-container *ngIf="truncateLongName; else fullName">
    {{ therapy.name | truncate: 21 }}
  </ng-container>
  <ng-template #fullName>
    {{ therapy.name }}
  </ng-template>
</ng-template>
