@model SceneEditViewModel
@{
    var totalSuggestions = Model.CharacterSuggestions.Count + Model.AssetSuggestions.Count + Model.LocationSuggestions.Count;
}

<div class="scene-inspector-editor-form">
    <div class="scene-inspector-editor-fields">
        <section class="scene-structure-editor-section">
            <div class="scene-structure-editor-heading">
                <span>Word Companion suggestions</span>
                <strong>@totalSuggestions</strong>
            </div>

            @if (totalSuggestions == 0)
            {
                <p class="muted">No pending Word Companion suggestions for this scene.</p>
            }
        </section>

        <section class="scene-structure-editor-section">
            <div class="scene-structure-editor-heading">
                <span>Character suggestions</span>
                <strong>@Model.CharacterSuggestions.Count</strong>
            </div>

            @if (!Model.CharacterSuggestions.Any())
            {
                <p class="muted">No pending character suggestions.</p>
            }
            else
            {
                <div class="scene-structure-editor-list">
                    @foreach (var suggestion in Model.CharacterSuggestions)
                    {
                        <article class="scene-structure-editor-card">
                            <div class="scene-structure-card-header">
                                <div>
                                    <h4>@suggestion.CharacterName</h4>
                                    <p>@suggestion.Confidence confidence</p>
                                </div>
                                <span class="scene-structure-marker">Character</span>
                            </div>

                            @if (!string.IsNullOrWhiteSpace(suggestion.Reason))
                            {
                                <p>@suggestion.Reason</p>
                            }
                            <p class="muted">Detected @suggestion.DetectedUtc.ToLocalTime().ToString("d MMM yyyy HH:mm")</p>

                            <div class="scene-structure-action-row">
                                <form asp-controller="Scenes" asp-action="AcceptCharacterSuggestion" method="post" class="scene-structure-delete-form" data-scene-editor-form>
                                    @Html.AntiForgeryToken()
                                    <input type="hidden" name="id" value="@suggestion.SceneCharacterSuggestionID" />
                                    <input type="hidden" name="sceneId" value="@Model.SceneID" />
                                    <input type="hidden" name="projectId" value="@Model.ReturnProjectID" />
                                    <input type="hidden" name="bookId" value="@Model.ReturnBookID" />
                                    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>
                                    <button class="btn btn-sm btn-primary" type="submit" data-scene-editor-save>Accept</button>
                                </form>
                                <form asp-controller="Scenes" asp-action="RejectCharacterSuggestion" method="post" class="scene-structure-delete-form" data-scene-editor-form>
                                    @Html.AntiForgeryToken()
                                    <input type="hidden" name="id" value="@suggestion.SceneCharacterSuggestionID" />
                                    <input type="hidden" name="sceneId" value="@Model.SceneID" />
                                    <input type="hidden" name="projectId" value="@Model.ReturnProjectID" />
                                    <input type="hidden" name="bookId" value="@Model.ReturnBookID" />
                                    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>
                                    <button class="btn btn-sm btn-outline-secondary" type="submit" data-scene-editor-save>Reject</button>
                                </form>
                            </div>
                        </article>
                    }
                </div>
            }
        </section>

        <section class="scene-structure-editor-section">
            <div class="scene-structure-editor-heading">
                <span>Asset suggestions</span>
                <strong>@Model.AssetSuggestions.Count</strong>
            </div>

            @if (!Model.AssetSuggestions.Any())
            {
                <p class="muted">No pending asset suggestions.</p>
            }
            else
            {
                <div class="scene-structure-editor-list">
                    @foreach (var suggestion in Model.AssetSuggestions)
                    {
                        <article class="scene-structure-editor-card">
                            <div class="scene-structure-card-header">
                                <div>
                                    <h4>@suggestion.AssetName</h4>
                                    <p>@suggestion.Confidence confidence</p>
                                </div>
                                <span class="scene-structure-marker">Asset</span>
                            </div>

                            @if (!string.IsNullOrWhiteSpace(suggestion.Reason))
                            {
                                <p>@suggestion.Reason</p>
                            }
                            <p class="muted">Detected @suggestion.DetectedUtc.ToLocalTime().ToString("d MMM yyyy HH:mm")</p>

                            <div class="scene-structure-action-row">
                                <form asp-controller="Scenes" asp-action="AcceptAssetSuggestion" method="post" class="scene-structure-delete-form" data-scene-editor-form>
                                    @Html.AntiForgeryToken()
                                    <input type="hidden" name="id" value="@suggestion.SceneAssetSuggestionID" />
                                    <input type="hidden" name="sceneId" value="@Model.SceneID" />
                                    <input type="hidden" name="projectId" value="@Model.ReturnProjectID" />
                                    <input type="hidden" name="bookId" value="@Model.ReturnBookID" />
                                    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>
                                    <button class="btn btn-sm btn-primary" type="submit" data-scene-editor-save>Accept</button>
                                </form>
                                <form asp-controller="Scenes" asp-action="RejectAssetSuggestion" method="post" class="scene-structure-delete-form" data-scene-editor-form>
                                    @Html.AntiForgeryToken()
                                    <input type="hidden" name="id" value="@suggestion.SceneAssetSuggestionID" />
                                    <input type="hidden" name="sceneId" value="@Model.SceneID" />
                                    <input type="hidden" name="projectId" value="@Model.ReturnProjectID" />
                                    <input type="hidden" name="bookId" value="@Model.ReturnBookID" />
                                    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>
                                    <button class="btn btn-sm btn-outline-secondary" type="submit" data-scene-editor-save>Reject</button>
                                </form>
                            </div>
                        </article>
                    }
                </div>
            }
        </section>

        <section class="scene-structure-editor-section">
            <div class="scene-structure-editor-heading">
                <span>Location suggestions</span>
                <strong>@Model.LocationSuggestions.Count</strong>
            </div>

            @if (!Model.LocationSuggestions.Any())
            {
                <p class="muted">No pending location suggestions.</p>
            }
            else
            {
                <div class="scene-structure-editor-list">
                    @foreach (var suggestion in Model.LocationSuggestions)
                    {
                        <article class="scene-structure-editor-card">
                            <div class="scene-structure-card-header">
                                <div>
                                    <h4>@(!string.IsNullOrWhiteSpace(suggestion.LocationPath) ? suggestion.LocationPath : suggestion.LocationName)</h4>
                                    <p>@suggestion.Confidence confidence</p>
                                </div>
                                <span class="scene-structure-marker">Location</span>
                            </div>

                            @if (!string.IsNullOrWhiteSpace(suggestion.Reason))
                            {
                                <p>@suggestion.Reason</p>
                            }
                            <p class="muted">Detected @suggestion.DetectedUtc.ToLocalTime().ToString("d MMM yyyy HH:mm")</p>

                            <div class="scene-structure-action-row">
                                <form asp-controller="Scenes" asp-action="AcceptLocationSuggestion" method="post" class="scene-structure-delete-form" data-scene-editor-form>
                                    @Html.AntiForgeryToken()
                                    <input type="hidden" name="id" value="@suggestion.SceneLocationSuggestionID" />
                                    <input type="hidden" name="sceneId" value="@Model.SceneID" />
                                    <input type="hidden" name="projectId" value="@Model.ReturnProjectID" />
                                    <input type="hidden" name="bookId" value="@Model.ReturnBookID" />
                                    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>
                                    <button class="btn btn-sm btn-primary" type="submit" data-scene-editor-save>Accept</button>
                                </form>
                                <form asp-controller="Scenes" asp-action="RejectLocationSuggestion" method="post" class="scene-structure-delete-form" data-scene-editor-form>
                                    @Html.AntiForgeryToken()
                                    <input type="hidden" name="id" value="@suggestion.SceneLocationSuggestionID" />
                                    <input type="hidden" name="sceneId" value="@Model.SceneID" />
                                    <input type="hidden" name="projectId" value="@Model.ReturnProjectID" />
                                    <input type="hidden" name="bookId" value="@Model.ReturnBookID" />
                                    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>
                                    <button class="btn btn-sm btn-outline-secondary" type="submit" data-scene-editor-save>Reject</button>
                                </form>
                            </div>
                        </article>
                    }
                </div>
            }
        </section>
    </div>

    <div class="scene-inspector-editor-footer">
        <button type="button" class="btn btn-sm btn-outline-secondary" data-scene-editor-close>Close</button>
    </div>
</div>
