<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You 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
    [attr.data-jtk-managed]="pipelineElement.payload.dom"
    id="{{ pipelineElement.payload.dom }}"
    style="{{ getElementCss(pipelineElement.settings) }}"
    (click)="updateOptionsClick(pipelineElement.payload.dom)"
    (mouseenter)="updateMouseover(pipelineElement.payload.dom)"
    (mouseleave)="updateMouseover('')"
    *ngFor="let pipelineElement of rawPipelineModel | enabledPipelineElement"
    class="sp-no-pan"
>
    <div style="z-index: 5" [ngClass]="getElementCssClasses(pipelineElement)">
        <div
            class="pipeline-element-progress-container sp-fade"
            *ngIf="pipelineElement.settings.loadingStatus"
        >
            <mat-spinner
                [mode]="'indeterminate'"
                class="pipeline-element-progress"
                [diameter]="40"
                color="accent"
            ></mat-spinner>
        </div>
        <div
            class="pipeline-element-loading-container sp-fade-opacity"
            *ngIf="pipelineElement.settings.loadingStatus"
        ></div>
        <div
            class="pipeline-element-configuration-status {{
                pipelineElement.type === 'stream' ? 'pi-stream' : 'pi-processor'
            }}"
            *ngIf="!preview"
        >
            <i
                class="material-icons pipeline-element-configuration-invalid-icon"
                *ngIf="pipelineElement.settings.completed === 3"
            >
                warning
            </i>
            <i
                class="material-icons pipeline-element-configuration-modified-icon"
                *ngIf="pipelineElement.settings.completed === 2"
            >
                warning
            </i>
            <i
                class="material-icons pipeline-element-configuration-ok-icon"
                *ngIf="pipelineElement.settings.completed === 1"
            >
                check_circle
            </i>
        </div>
        <sp-pipeline-element
            [pipelineElement]="pipelineElement.payload"
            [preview]="preview"
        ></sp-pipeline-element>
    </div>
    <sp-pipeline-element-options
        *ngIf="!preview"
        (delete)="handleDeleteOption($event)"
        (customize)="showCustomizeDialog($event)"
        [currentMouseOverElement]="currentMouseOverElement"
        [pipelineValid]="pipelineValid"
        [allElements]="allElements"
        [pipelineElement]="pipelineElement"
        [rawPipelineModel]="rawPipelineModel"
        [pipelineElementId]="
            pipelineElement.type === 'stream' || pipelineElement.type === 'set'
                ? pipelineElement.payload.elementId
                : pipelineElement.payload.belongsTo
        "
        [internalId]="pipelineElement.payload.dom"
        [attr.data-cy]="
            'sp-pe-menu-' +
            pipelineElement.payload.name.toLowerCase().replaceAll(' ', '_')
        "
    >
    </sp-pipeline-element-options>
    <sp-pipeline-element-preview
        *ngIf="
            previewModeActive &&
            pipelinePreview.supportedPipelineElementDomIds.indexOf(
                pipelineElement.payload.dom
            ) > -1
        "
        [previewId]="pipelinePreview.previewId"
        [pipelineElementDomId]="pipelineElement.payload.dom"
    >
    </sp-pipeline-element-preview>
</div>
