<!--

    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 class="tb-widget-settings" [formGroup]="commonMapSettingsFormGroup">
  <fieldset class="fields-group">
    <legend class="group-title" translate>widgets.maps.common-map-settings</legend>
    <section class="!flex flex-col gt-xs:flex-row gt-xs:gap-2">
      <tb-datasources-key-autocomplete class="flex-1"
                                       [class.!hidden]="provider !== mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.x-pos-key-name"
                                       formControlName="xPosKeyName">
      </tb-datasources-key-autocomplete>
      <tb-datasources-key-autocomplete class="flex-1"
                                       [class.!hidden]="provider !== mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.y-pos-key-name"
                                       formControlName="yPosKeyName">
      </tb-datasources-key-autocomplete>
      <tb-datasources-key-autocomplete class="flex-1"
                                       [class.!hidden]="provider === mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.latitude-key-name"
                                       formControlName="latKeyName">
      </tb-datasources-key-autocomplete>
      <tb-datasources-key-autocomplete class="flex-1"
                                       [class.!hidden]="provider === mapProvider.image"
                                       required
                                       [datasources]="widget?.config?.datasources"
                                       label="widgets.maps.longitude-key-name"
                                       formControlName="lngKeyName">
      </tb-datasources-key-autocomplete>
    </section>
    <mat-expansion-panel class="tb-settings">
      <mat-expansion-panel-header class="flex-wrap">
        <mat-panel-description class="justify-end" translate>
          widget-config.advanced-settings
        </mat-panel-description>
      </mat-expansion-panel-header>
      <ng-template matExpansionPanelContent>
        <section [class.!hidden]="provider === mapProvider.image" class="flex flex-row xs:flex-col gt-xs:gap-2">
          <mat-form-field class="flex-1">
            <mat-label translate>widgets.maps.default-map-zoom-level</mat-label>
            <input matInput type="number" min="0" max="20" step="1" formControlName="defaultZoomLevel">
          </mat-form-field>
          <mat-form-field class="flex-1">
            <mat-label translate>widgets.maps.default-map-center-position</mat-label>
            <input matInput formControlName="defaultCenterPosition">
          </mat-form-field>
        </section>
        <section class="mb-3.5 flex flex-row xs:flex-col gt-xs:gap-2">
          <section class="flex flex-1 flex-col">
            <mat-slide-toggle formControlName="disableScrollZooming" class="slide-block">
              {{ 'widgets.maps.disable-scroll-zooming' | translate }}
            </mat-slide-toggle>
            <mat-slide-toggle formControlName="disableDoubleClickZooming" class="slide-block">
              {{ 'widgets.maps.disable-double-click-zooming' | translate }}
            </mat-slide-toggle>
            <mat-slide-toggle formControlName="disableZoomControl" class="slide-block">
              {{ 'widgets.maps.disable-zoom-control-buttons' | translate }}
            </mat-slide-toggle>
            <mat-slide-toggle [class.!hidden]="provider === mapProvider.image" formControlName="fitMapBounds" class="slide-block">
              {{ 'widgets.maps.fit-map-bounds' | translate }}
            </mat-slide-toggle>
          </section>
          <section class="flex-1" [class.!hidden]="provider === mapProvider.image">
            <mat-slide-toggle formControlName="useDefaultCenterPosition" class="slide-block">
              {{ 'widgets.maps.use-default-map-center-position' | translate }}
            </mat-slide-toggle>
          </section>
        </section>
        <mat-form-field class="mat-block">
          <mat-label translate>widgets.maps.entities-limit</mat-label>
          <input matInput type="number" min="1" step="1" formControlName="mapPageSize">
        </mat-form-field>
      </ng-template>
    </mat-expansion-panel>
  </fieldset>
</section>
