<!--

    Copyright © 2016-2026 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section [formGroup]="slackConfigForm" class="flex flex-col">
  <mat-form-field class="mat-block flex-1" appearance="outline">
    <mat-label translate>rule-node-config.message-template</mat-label>
    <input required matInput formControlName="messageTemplate">
    @if (slackConfigForm.get('messageTemplate').hasError('required')) {
      <mat-error>
        {{ 'rule-node-config.message-template-required' | translate }}
      </mat-error>
    }
    <mat-hint translate>rule-node-config.general-pattern-hint</mat-hint>
  </mat-form-field>
  <mat-checkbox formControlName="useSystemSettings">
    {{ 'rule-node-config.use-system-slack-settings' | translate }}
  </mat-checkbox>
  @if (!slackConfigForm.get('useSystemSettings').value) {
    <mat-form-field class="mat-block" appearance="outline">
      <mat-label translate>rule-node-config.slack-api-token</mat-label>
      <input required matInput formControlName="botToken">
      @if (slackConfigForm.get('botToken').hasError('required')) {
        <mat-error>
          {{ 'rule-node-config.slack-api-token-required' | translate }}
        </mat-error>
      }
    </mat-form-field>
  }
  <label class="tb-title">{{ 'notification.slack-chanel-type' | translate }}</label>
  <mat-radio-group formControlName="conversationType">
    @for (slackChanelType of slackChanelTypes; track slackChanelType) {
      <mat-radio-button [value]="slackChanelType">
        {{ slackChanelTypesTranslateMap.get(slackChanelType) | translate }}
      </mat-radio-button>
    }
  </mat-radio-group>
  <tb-slack-conversation-autocomplete
    appearance="outline"
    formControlName="conversation"
    required
    [token]="slackConfigForm.get('useSystemSettings').value ? '' : slackConfigForm.get('botToken').value"
    [slackChanelType]="slackConfigForm.get('conversationType').value">
  </tb-slack-conversation-autocomplete>
</section>
