<!--

    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.

-->
<div class="tb-form-panel no-padding no-border">
  <div class="tb-form-table tb-map-data-sources">
    <div class="tb-form-table-header no-padding-right">
      <div class="tb-form-table-header-cell tb-source-header" translate>widgets.maps.data-layer.source</div>
      <div class="tb-form-table-header-cell tb-filter-header" translate>widgets.maps.data-layer.filter</div>
      <div class="tb-form-table-header-cell tb-actions-header"></div>
    </div>
    @if (dataSourcesFormArray().controls.length) {
      <div class="tb-form-table-body">
        @for (dataSourceControl of dataSourcesFormArray().controls; track trackByDataSource($index, dataSourceControl)) {
          <div>
            <tb-map-data-source-row class="flex-1"
                                    [context]="context"
                                    [formControl]="dataSourceControl"
                                    (dataSourceRemoved)="removeDataSource($index)">
            </tb-map-data-source-row>
          </div>
        }
      </div>
    } @else {
      <span class="tb-prompt flex items-center justify-center">{{ 'widgets.maps.data-layer.no-datasources' | translate }}</span>
    }
  </div>
  <div>
    <button type="button" mat-stroked-button color="primary" (click)="addDataSource()">
      {{ 'widgets.maps.data-layer.add-datasource' | translate }}
    </button>
  </div>
</div>
