
<div class="fr-toolbar fr-@WebReport.ID-toolbar">

    @if (WebReport.Toolbar.ShowRefreshButton && !WebReport.Report.IsLoadPrepared)
    {
        <div class="fr-toolbar-item fr-toolbar-pointer fr-@WebReport.ID-toolbar-item fr-webreport-pointer" @onclick="Reload" title="@Localization.reloadTxt">
            <img src="_content/FastReport.Web/Resources/reload.svg" />
        </div>
    }

    @if (WebReport.Toolbar.Exports.Show)
    {
        var exports = WebReport.Toolbar.Exports;
        <div class="fr-toolbar-item fr-@WebReport.ID-toolbar-item">
            <img src="_content/FastReport.Web/Resources/save.svg" />
            <div class="fr-toolbar-dropdown-content fr-@WebReport.ID-toolbar-dropdown-content">
                @if (exports.ShowPreparedReport)
                {
                    <a target="_blank" href=@SaveFpx>@Localization.preparedTxt </a>
                    @*if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button class="fr-webreport-settings-btn" @onclick="() => ClickSettingsExport(Exports.Prepared)"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }*@
                }
                @if (exports.ShowPdfExport)
                {
                    <a target="_blank" href=@SavePdf>@Localization.pdfTxt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button class="fr-webreport-settings-btn" @onclick="() => ClickSettingsExport(Exports.Pdf)"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowExcel2007Export)
                {
                    <a target="_blank" href=@SaveXlsx>@Localization.excel2007Txt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button @onclick="() => ClickSettingsExport(Exports.Excel2007)" class="fr-webreport-settings-btn"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowWord2007Export)
                {
                    <a target="_blank" href=@SaveDocx>@Localization.word2007Txt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button @onclick="() => ClickSettingsExport(Exports.Word2007)" class="fr-webreport-settings-btn"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowPowerPoint2007Export)
                {
                    <a target="_blank" href=@SavePowerPoint2007>@Localization.powerPoint2007Txt </a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button class="fr-webreport-settings-btn" @onclick="() => ClickSettingsExport(Exports.PowerPoint2007)"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowTextExport)
                {<a target="_blank" href=@SaveText>@Localization.textTxt</a>}
                @if (exports.ShowRtfExport)
                {<a target="_blank" href=@SaveRtf>@Localization.rtfTxt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button class="fr-webreport-settings-btn" @onclick="() => ClickSettingsExport(Exports.Rtf)"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowXpsExport)
                {<a target="_blank" href=@SaveXps>@Localization.xpsTxt</a>}
                @if (exports.ShowOdsExport)
                {<a target="_blank" href=@SaveOds>@Localization.odsTxt</a>
                     if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button @onclick="() => ClickSettingsExport(Exports.Ods)" class="fr-webreport-settings-btn"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowOdtExport)
                {<a _target="_blank" href=@SaveOdt>@Localization.odtTxt</a>
                     if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button @onclick="() => ClickSettingsExport(Exports.Odt)" class="fr-webreport-settings-btn"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowXmlExcelExport)
                {<a target="_blank" href=@SaveXmlExcel>@Localization.xmlTxt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button class="fr-webreport-settings-btn" @onclick="() => ClickSettingsExport(Exports.XmlExcel)"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @if (exports.ShowCsvExport)
                {<a _target="_blank" href=@SaveCsv>@Localization.csvTxt</a>}
                @if (exports.ShowExcel97Export)
                {<a _target="_blank" href=@SaveBiff8>@Localization.excel97Txt</a>}
                @*@if (exports.ShowEmailExport)
                {<a _target="_blank" href=@SaveEmail>@Localization.emailTxt</a>}*@
                @if (exports.ShowHpglExport)
                {<a _target="_blank" href=@SaveHpgl>@Localization.hpglTxt</a>}
                @if (exports.ShowHTMLExport)
                {<a _target="_blank" href=@SaveHTML>@Localization.htmlTxt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button @onclick="() => ClickSettingsExport(Exports.HTML)" class="fr-webreport-settings-btn"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
                @*@if (exports.ShowImageExport)
                {<a _target="_blank" href=@SaveImage>@Localization.imageTxt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button @onclick="() => ClickSettingsExport(Exports.Image)" class="fr-webreport-settings-btn"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }*@
                @if (exports.ShowJsonExport)
                {<a _target="_blank" href=@SaveJson>@Localization.jsonTxt</a>}
                @if (exports.ShowDxfExport)
                {<a _target="_blank" href=@SaveDxf>@Localization.dxfTxt</a>}
                @if (exports.ShowLaTeXExport)
                {<a _target="_blank" href=@SaveLaTeX>@Localization.latexTxt</a>}
                @if (exports.ShowPpmlExport)
                {<a _target="_blank" href=@SavePpml>@Localization.ppmlTxt</a>}
                @if (exports.ShowPSExport)
                {<a target="_blank" href=@SavePS>@Localization.psTxt</a>}
                @if (exports.ShowXamlExport)
                {<a _target="_blank" href=@SaveXaml>@Localization.xamlTxt</a>}
                @if (exports.ShowZplExport)
                {<a _target="_blank" href=@SaveZpl>@Localization.zplTxt</a>}
                @if (exports.ShowDbfExport)
                {<a _target="_blank" href=@SaveDbf>@Localization.dbfTxt</a>}
                @if (exports.ShowSvgExport)
                {<a target="_blank" href=@SaveSvg>@Localization.svgTxt</a>
                    if (WebReport.Toolbar.Exports.EnableSettings)
                    {
                        <button class="fr-webreport-settings-btn" @onclick="() => ClickSettingsExport(Exports.Svg)"><img style="height:20px;" src="_content/FastReport.Web/Resources/settings.svg" /></button>
                    }
                }
            </div>
        </div>
    }

    @if (WebReport.Toolbar.ShowPrint)
    {
        <div class="fr-toolbar-item fr-@WebReport.ID-toolbar-item" title="@Localization.printTxt">
            <img src="_content/FastReport.Web/Resources/print.svg" />
            <div class="fr-toolbar-dropdown-content fr-@WebReport.ID-toolbar-dropdown-content">
                @if (WebReport.Toolbar.PrintInHtml)
                {
                    <a target="_blank" href=@PrintHtml>@Localization.printFromBrowserTxt</a>
                }
                @if (WebReport.Toolbar.PrintInPdf)
                {
                    <a target="_blank" href=@PrintPdf>@Localization.printFromPdf</a>
                }
            </div>
        </div>
    }

    @if (WebReport.Toolbar.ShowZoomButton)
    {
        <div class="fr-toolbar-item fr-@WebReport.ID-toolbar-item">
            <img src="_content/FastReport.Web/Resources/magnifier.svg" title="@Localization.zoomTxt" style="transform: translateY(1px)" />
            <div class="fr-toolbar-dropdown-content fr-@WebReport.ID-toolbar-dropdown-content">
                @foreach (int zoom in zoomList)
                {
                    <a @onclick="@(() => Zoom(zoom))">
                        <div class="fr-webreport-zoom-selected">
                            @if (currentZoom == zoom)
                            {
                                @zoomSymbol
                            }
                        </div>
                        @zoom%
                    </a>
                }
            </div>
        </div>
    }

    @if (!(WebReport.SinglePage || WebReport.TotalPages < 2))
    {

        <div class="fr-toolbar-item fr-toolbar-narrow fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-narrow @(isFirstPage ? $"fr-webreport-toolbar-notbutton fr-webreport-disabled": $"fr-webreport-pointer" )"
             @onclick="GotoFirst"
             Title="@Localization.firstPageTxt">
            <img src="_content/FastReport.Web/Resources/angle-double-left.svg" />
        </div>

        <div class="fr-toolbar-item fr-toolbar-narrow  fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-narrow @(isFirstPage ? $"fr-webreport-toolbar-notbutton fr-webreport-disabled": $"fr-webreport-pointer" )"
             @onclick="GotoPrevious"
             Title="@Localization.previousPageTxt">
            <img src="_content/FastReport.Web/Resources/angle-left.svg" />
        </div>

        <div class="fr-toolbar-item fr-toolbar-notbutton fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-notbutton">
            <input class="fr-@WebReport.ID-current-page-input"
                   type="text"
                   @bind="InputValue"
                   title="@Localization.currentPageTxt" />
        </div>

        <div class="fr-toolbar-item fr-toolbar-notbutton fr-toolbar-slash fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-notbutton fr-@WebReport.ID-toolbar-slash">
            <img src="_content/FastReport.Web/Resources/slash.svg" />
        </div>

        <div class="fr-toolbar-item fr-toolbar-notbutton fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-notbutton">
            <input type="text" value="@WebReport.TotalPages" readonly="readonly" title="@Localization.totalPagesTxt" />
        </div>

        <div class="fr-toolbar-item fr-toolbar-narrow fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-narrow @(isLastPage ? $"fr-webreport-toolbar-notbutton fr-webreport-disabled" : $"fr-webreport-pointer")"
             @onclick="GotoNext"
             title="@Localization.nextPageTxt">
            <img src="_content/FastReport.Web/Resources/angle-right.svg" />
        </div>

        <div class="fr-toolbar-item fr-toolbar-narrow fr-@WebReport.ID-toolbar-item fr-webreport-toolbar-narrow @(isLastPage ? $"fr-webreport-toolbar-notbutton fr-webreport-disabled" : $"fr-webreport-pointer")"
             @onclick="GotoLast"
             title="@Localization.lastPageTxt">
            <img src="_content/FastReport.Web/Resources/angle-double-right.svg" />
        </div>
    }

</div>

@if (WebReport.Tabs.Count > 1)
{
    <Tabs WebReport="WebReport" />
}

@code {
    [Parameter]
    public WebReport WebReport { get; set; }

    [Parameter]
    public Action PageChanged { get; set; }

    [Parameter]
    public Action OpenModalDialog { get; set; }


    protected override void OnParametersSet()
    {
        Localization = new ToolbarLocalization(WebReport.Res);
        currentZoom = WebReport.Zoom * 100;
        isFirstPage = WebReport.CurrentPageIndex == 0;
        isLastPage = WebReport.CurrentPageIndex >= WebReport.TotalPages - 1;
    }


}
