@{
    /******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Author(s)      : Natalia Portillo <claunia@claunia.com>
//
// --[ License ] --------------------------------------------------------------
//
//     This program is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as
//     published by the Free Software Foundation, either version 3 of the
//     License, or (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
//
//     You should have received a copy of the GNU General Public License
//     along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2026 Natalia Portillo
*******************************************************************************/
}

@page "/admin/machines/photo/details/{Id:guid}"
@page "/admin/machines/photo/edit/{Id:guid}"
@using Marechai.Data
@using Marechai.Database.Models
@using Orientation = Marechai.Data.Orientation
@inherits OwningComponentBase<MachinePhotosService>
@inject IStringLocalizer<MachinePhotosService> L
@inject NavigationManager                      NavigationManager
@inject LicensesService                        LicensesService
@inject UserManager<ApplicationUser>           UserManager
@inject AuthenticationStateProvider            AuthenticationStateProvider
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machine photo details"]</h3>
<hr/>
@if(!_loaded)
{
    <p align="center">@L["Loading..."]</p>

    return;
}
<div>
    <Field>
        <FieldLabel>@L["Machine"]</FieldLabel>
        <TextEdit Disabled="true" Text="@($"{_model.MachineCompanyName} - {_model.MachineName}")"/>
    </Field>
    <Field>
        <FieldLabel>@L["Uploaded by"]</FieldLabel>
        <TextEdit Disabled="true" Text="@($"{_user.UserName} <{_user.Email}>")"/>
    </Field>
    <Field>
        <FieldLabel>@L["Uploaded date"]</FieldLabel>
        <TextEdit Disabled="true" Text="@($"{_model.UploadDate}")"/>
    </Field>
    <Field>
        <FieldLabel>@L["License"]</FieldLabel>
        <Select @bind-SelectedValue="@_model.LicenseId" Disabled="!_editing" @TValue="int">
            @foreach(Database.Models.License license in _licenses)
            {
                <SelectItem @TValue="int" Value="@license.Id">@license.Name</SelectItem>
            }
        </Select>
    </Field>
    @if(_editing || _model.Author != null)
    {
        <Field>
            <FieldLabel>@L["Author"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownAuthor" @TValue="bool">@L["Unknown (author)"]</Check>
            }
            @if(!_editing || !_unknownSource)
            {
                <Validation Validator="@ValidateAuthor">
                    <TextEdit @bind-Text="@_model.Author" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid author."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.Source != null)
    {
        <Field>
            <FieldLabel>@L["Source URL"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSource" @TValue="bool">@L["Unknown (source url)"]</Check>
            }
            @if(!_editing || !_unknownSource)
            {
                <Validation Validator="@ValidateSource">
                    <TextEdit @bind-Text="@_model.Source" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid source URL."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.Aperture != null)
    {
        <Field>
            <FieldLabel>@L["Aperture"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownAperture" @TValue="bool">@L["Unknown (aperture)"]</Check>
            }
            @if(!_editing || !_unknownAperture)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.Aperture" Decimals="3" Disabled="!_editing" @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid aperture."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.CameraManufacturer != null)
    {
        <Field>
            <FieldLabel>@L["Camera manufacturer"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownCameraManufacturer"
                       @TValue="bool">@L["Unknown (camera manufacturer)"]</Check>
            }
            @if(!_editing || !_unknownCameraManufacturer)
            {
                <Validation Validator="@ValidateCameraManufacturer">
                    <TextEdit @bind-Text="@_model.CameraManufacturer" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid camera manufacturer."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.CameraModel != null)
    {
        <Field>
            <FieldLabel>@L["Camera model"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownCameraModel" @TValue="bool">@L["Unknown (camera model)"]</Check>
            }
            @if(!_editing || !_unknownCameraModel)
            {
                <Validation Validator="@ValidateCameraModel">
                    <TextEdit @bind-Text="@_model.CameraModel" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid camera model."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.ColorSpace != null)
    {
        <Field>
            <FieldLabel>@L["Color space"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownColorSpace" @TValue="bool">@L["Unknown (color space)"]</Check>
            }
            @if(!_editing || !_unknownColorSpace)
            {
                <Select @bind-SelectedValue="@ColorSpace" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(ColorSpace)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((ColorSpace)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Contrast != null)
    {
        <Field>
            <FieldLabel>@L["Contrast"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownContrast" @TValue="bool">@L["Unknown (contrast)"]</Check>
            }
            @if(!_editing || !_unknownContrast)
            {
                <Select @bind-SelectedValue="@Contrast" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(Contrast)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((Contrast)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.CreationDate != null)
    {
        <Field>
            <FieldLabel>@L["Creation date"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownCreationDate" @TValue="bool">@L["Unknown (creation date)"]</Check>
            }
            @if(!_editing || !_unknownCreationDate)
            {
                <Validation Validator="@ValidateDate">
                    <DateEdit @bind-Date="@_model.CreationDate" Disabled="!_editing" @TValue="DateTime?">
                        <Feedback>
                            <ValidationError>@L["Please enter a correct creation date."]</ValidationError>
                        </Feedback>
                    </DateEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.DigitalZoomRatio != null)
    {
        <Field>
            <FieldLabel>@L["Digital zoom ratio"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownDigitalZoomRatio"
                       @TValue="bool">@L["Unknown (digital zoom ratio)"]</Check>
            }
            @if(!_editing || !_unknownDigitalZoomRatio)
            {
                <Validation Validator="@ValidateDoubleBiggerOrEqualThanZero">
                    <NumericEdit @bind-Value="@_model.DigitalZoomRatio" Decimals="3" Disabled="!_editing"
                                 @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid digital zoom ratio."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.ExifVersion != null)
    {
        <Field>
            <FieldLabel>@L["Exif version"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownExifVersion" @TValue="bool">@L["Unknown (exif version)"]</Check>
            }
            @if(!_editing || !_unknownExifVersion)
            {
                <Validation Validator="@ValidateExifVersion">
                    <TextEdit @bind-Text="@_model.ExifVersion" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid Exif version."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.ExposureTime != null)
    {
        <Field>
            <FieldLabel>@L["Exposure time"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownExposure" @TValue="bool">@L["Unknown (exposure time)"]</Check>
            }
            @if(!_editing || !_unknownExposure)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.ExposureTime" Decimals="3" Disabled="!_editing" @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid exposure time."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.ExposureMethod != null)
    {
        <Field>
            <FieldLabel>@L["Exposure mode"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownExposureMethod" @TValue="bool">@L["Unknown (exposure mode)"]</Check>
            }
            @if(!_editing || !_unknownExposureMethod)
            {
                <Select @bind-SelectedValue="@ExposureMode" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(ExposureMode)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((ExposureMode)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.ExposureProgram != null)
    {
        <Field>
            <FieldLabel>@L["Exposure program"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownExposureProgram" @TValue="bool">@L["Unknown (exposure program)"]</Check>
            }
            @if(!_editing || !_unknownExposureProgram)
            {
                <Select @bind-SelectedValue="@ExposureProgram" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(ExposureProgram)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((ExposureProgram)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Flash != null)
    {
        <Field>
            <FieldLabel>@L["Flash"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownFlash" @TValue="bool">@L["Unknown (flash)"]</Check>
            }
            @if(!_editing || !_unknownFlash)
            {
                <Select @bind-SelectedValue="@Flash" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(Flash)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((Flash)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Focal != null)
    {
        <Field>
            <FieldLabel>@L["F-number"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownFocal" @TValue="bool">@L["Unknown (f-number)"]</Check>
            }
            @if(!_editing || !_unknownFocal)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.Focal" Decimals="3" Disabled="!_editing" @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid focal number."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.FocalLength != null)
    {
        <Field>
            <FieldLabel>@L["Focal length"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownFocalLength" @TValue="bool">@L["Unknown (focal length)"]</Check>
            }
            @if(!_editing || !_unknownFocalLength)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.FocalLength" Decimals="3" Disabled="!_editing" @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid focal length."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.FocalLengthEquivalent != null)
    {
        <Field>
            <FieldLabel>@L["Focal length in 35mm film"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownFocalLengthEquivalent"
                       @TValue="bool">@L["Unknown (focal length in 35mm film)"]</Check>
            }
            @if(!_editing || !_unknownFocalLengthEquivalent)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.FocalLengthEquivalent" Decimals="3" Disabled="!_editing"
                                 @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid focal length in 35mm film."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.HorizontalResolution != null)
    {
        <Field>
            <FieldLabel>@L["Horizontal resolution"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownHorizontalResolution"
                       @TValue="bool">@L["Unknown (horizontal resolution)"]</Check>
            }
            @if(!_editing || !_unknownHorizontalResolution)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.HorizontalResolution" Decimals="3" Disabled="!_editing"
                                 @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid horizontal resolution."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.IsoRating != null)
    {
        <Field>
            <FieldLabel>@L["ISO rating"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownIsoRating" @TValue="bool">@L["Unknown (ISO rating)"]</Check>
            }
            @if(!_editing || !_unknownIsoRating)
            {
                <Validation Validator="@ValidateUnsignedShortBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.IsoRating" Disabled="!_editing" @TValue="ushort?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid ISO rating."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.Lens != null)
    {
        <Field>
            <FieldLabel>@L["Lens"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownLens" @TValue="bool">@L["Unknown (lens)"]</Check>
            }
            @if(!_editing || !_unknownLens)
            {
                <Validation Validator="@ValidateLens">
                    <TextEdit @bind-Text="@_model.Lens" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid lens."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.LightSource != null)
    {
        <Field>
            <FieldLabel>@L["Light source"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownLightSource" @TValue="bool">@L["Unknown (light source)"]</Check>
            }
            @if(!_editing || !_unknownLightSource)
            {
                <Select @bind-SelectedValue="@LightSource" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(LightSource)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((LightSource)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.MeteringMode != null)
    {
        <Field>
            <FieldLabel>@L["Metering mode"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownMeteringMode" @TValue="bool">@L["Unknown (metering mode)"]</Check>
            }
            @if(!_editing || !_unknownMeteringMode)
            {
                <Select @bind-SelectedValue="@MeteringMode" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(MeteringMode)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((MeteringMode)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.ResolutionUnit != null)
    {
        <Field>
            <FieldLabel>@L["Resolution unit"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownResolutionUnit" @TValue="bool">@L["Unknown (resolution unit)"]</Check>
            }
            @if(!_editing || !_unknownResolutionUnit)
            {
                <Select @bind-SelectedValue="@ResolutionUnit" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(ResolutionUnit)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((ResolutionUnit)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Orientation != null)
    {
        <Field>
            <FieldLabel>@L["Orientation"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownOrientation" @TValue="bool">@L["Unknown (orientation)"]</Check>
            }
            @if(!_editing || !_unknownOrientation)
            {
                <Select @bind-SelectedValue="@Orientation" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(Orientation)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((Orientation)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Saturation != null)
    {
        <Field>
            <FieldLabel>@L["Saturation"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSaturation" @TValue="bool">@L["Unknown (saturation)"]</Check>
            }
            @if(!_editing || !_unknownSaturation)
            {
                <Select @bind-SelectedValue="@Saturation" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(Saturation)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((Saturation)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.SceneCaptureType != null)
    {
        <Field>
            <FieldLabel>@L["Scene capture type"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSceneCaptureType"
                       @TValue="bool">@L["Unknown (scene capture type)"]</Check>
            }
            @if(!_editing || !_unknownSceneCaptureType)
            {
                <Select @bind-SelectedValue="@SceneCaptureType" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(SceneCaptureType)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((SceneCaptureType)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.SensingMethod != null)
    {
        <Field>
            <FieldLabel>@L["Sensing method"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSensingMethod" @TValue="bool">@L["Unknown (sensing method)"]</Check>
            }
            @if(!_editing || !_unknownSensingMethod)
            {
                <Select @bind-SelectedValue="@SensingMethod" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(SensingMethod)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((SensingMethod)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Sharpness != null)
    {
        <Field>
            <FieldLabel>@L["Sharpness"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSharpness" @TValue="bool">@L["Unknown (sharpness)"]</Check>
            }
            @if(!_editing || !_unknownSharpness)
            {
                <Select @bind-SelectedValue="@Sharpness" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(Sharpness)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((Sharpness)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.SoftwareUsed != null)
    {
        <Field>
            <FieldLabel>@L["Software used"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSoftwareUsed" @TValue="bool">@L["Unknown (software used)"]</Check>
            }
            @if(!_editing || !_unknownSoftwareUsed)
            {
                <Validation Validator="@ValidateSoftwareUsed">
                    <TextEdit @bind-Text="@_model.SoftwareUsed" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid software used."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.SubjectDistanceRange != null)
    {
        <Field>
            <FieldLabel>@L["Subject distance range"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownSubjectDistanceRange"
                       @TValue="bool">@L["Unknown (subject distance range)"]</Check>
            }
            @if(!_editing || !_unknownSubjectDistanceRange)
            {
                <Select @bind-SelectedValue="@SubjectDistanceRange" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(SubjectDistanceRange)))
                    {
                        <SelectItem @TValue="ushort"
                                    Value="@value">@(((SubjectDistanceRange)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.VerticalResolution != null)
    {
        <Field>
            <FieldLabel>@L["Vertical resolution"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownVerticalResolution"
                       @TValue="bool">@L["Unknown (vertical resolution)"]</Check>
            }
            @if(!_editing || !_unknownVerticalResolution)
            {
                <Validation Validator="@ValidateDoubleBiggerThanZero">
                    <NumericEdit @bind-Value="@_model.VerticalResolution" Decimals="3" Disabled="!_editing"
                                 @TValue="double?">
                        <Feedback>
                            <ValidationError>@L["Please enter a valid vertical resolution."]</ValidationError>
                        </Feedback>
                    </NumericEdit>
                </Validation>
            }
        </Field>
    }
    @if(_editing || _model.WhiteBalance != null)
    {
        <Field>
            <FieldLabel>@L["White balance"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownWhiteBalance" @TValue="bool">@L["Unknown (white balance)"]</Check>
            }
            @if(!_editing || !_unknownWhiteBalance)
            {
                <Select @bind-SelectedValue="@WhiteBalance" Disabled="!_editing" @TValue="ushort">
                    @foreach(ushort value in Enum.GetValues(typeof(WhiteBalance)))
                    {
                        <SelectItem @TValue="ushort" Value="@value">@(((WhiteBalance)value).ToString())</SelectItem>
                    }
                </Select>
            }
        </Field>
    }
    @if(_editing || _model.Comments != null)
    {
        <Field>
            <FieldLabel>@L["User comments"]</FieldLabel>
            @if(_editing)
            {
                <Check @bind-Checked="@_unknownComments" @TValue="bool">@L["Unknown or empty (user comments)"]</Check>
            }
            @if(!_editing || !_unknownComments)
            {
                <Validation Validator="@ValidateComments">
                    <TextEdit @bind-Text="@_model.Comments" Disabled="!_editing">
                        <Feedback>
                            <ValidationError>@L["Please enter valid comments."]</ValidationError>
                        </Feedback>
                    </TextEdit>
                </Validation>
            }
        </Field>
    }
</div>
<a href="/assets/photos/machines/originals/@($"{_model.Id}{_model.OriginalExtension}")" target="_blank">
    <img alt="" height="auto" src="/assets/photos/machines/originals/@($"{_model.Id}{_model.OriginalExtension}")"
         style="max-height: 512px; max-width: 512px" width="auto"/>
</a>
<div>
    @if(!_editing)
    {
        <Button Clicked="@OnEditClicked" Color="Color.Primary">@L["Edit"]</Button>
    }
    else
    {
        <Button Clicked="@OnSaveClicked" Color="Color.Success">@L["Save"]</Button>

        <Button Clicked="@OnCancelClicked" Color="Color.Danger">@L["Cancel"]</Button>
    }
    <a class="btn btn-secondary" href="/admin/machines/details/@_model.MachineId">@L["Back to machine"]</a>
</div>