<!doctype html>
<!-- Copyright (c) Microsoft Corporation.
 Licensed under the MIT License. -->

<html>
  <head>
    <meta charset="utf-8" />
    <title>TypeAgent Knowledge Panel</title>
    <link rel="stylesheet" href="../vendor/bootstrap/bootstrap.min.css" />
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css"
      rel="stylesheet"
    />
    <link rel="stylesheet" href="pageKnowledge.css" />
  </head>
  <body>
    <div class="container-fluid p-3">
      <!-- Header Section -->
      <div class="knowledge-header rounded">
        <div class="d-flex justify-content-between align-items-center">
          <div>
            <h4 class="mb-1"><i class="bi bi-brain"></i> Knowledge Panel</h4>
            <small id="connectionStatus">
              <span class="status-indicator status-connected"></span>
              Connected to TypeAgent
            </small>
          </div>
          <div class="auto-index-toggle">
            <div class="form-check form-switch">
              <input
                class="form-check-input"
                type="checkbox"
                id="autoIndexToggle"
              />
              <label class="form-check-label text-muted" for="autoIndexToggle">
                Auto-index
              </label>
            </div>
          </div>
        </div>
      </div>

      <!-- Current Page Section -->
      <div class="knowledge-card card">
        <div
          class="card-header d-flex justify-content-between align-items-center"
        >
          <h6 class="mb-0"><i class="bi bi-globe"></i> Current Page</h6>
          <div class="btn-group btn-group-sm">
            <button id="extractKnowledge" class="btn btn-primary">
              <i class="bi bi-search"></i> Extract
            </button>
            <button id="indexPage" class="btn btn-outline-primary">
              <i class="bi bi-plus-circle"></i> Index
            </button>
          </div>
        </div>
        <div class="card-body">
          <!-- Mode Selection -->
          <div class="mb-3">
            <label for="extractionMode" class="form-label text-muted">
              <i class="bi bi-gear"></i> Extraction Mode
            </label>
            <div class="extraction-mode-slider-container">
              <div class="slider-labels">
                <span class="slider-label" data-value="0">Basic</span>
                <span class="slider-label" data-value="1">Summary</span>
                <span class="slider-label" data-value="2">Content</span>
                <span class="slider-label" data-value="3">Full</span>
              </div>

              <input
                type="range"
                id="extractionMode"
                class="extraction-mode-slider"
                min="0"
                max="3"
                value="2"
                step="1"
                data-mode="content"
              />

              <div class="slider-ticks">
                <span class="slider-tick" data-value="0"></span>
                <span class="slider-tick" data-value="1"></span>
                <span class="slider-tick" data-value="2"></span>
                <span class="slider-tick" data-value="3"></span>
              </div>
            </div>
            <div class="form-text" id="modeDescription">
              AI-powered content analysis with entity and topic extraction
            </div>
          </div>

          <!-- AI Model Status -->
          <div id="aiModelStatus" class="mb-3 d-none">
            <div class="alert alert-warning alert-sm p-2 mb-0">
              <i class="bi bi-exclamation-triangle me-2"></i>
              <span id="aiStatusMessage"
                >Checking AI model availability...</span
              >
            </div>
          </div>

          <div id="currentPageInfo">
            <div class="text-center text-muted">
              <i class="bi bi-hourglass-split"></i>
              <p class="mb-0">Loading page information...</p>
            </div>
          </div>
        </div>
      </div>

      <!-- Knowledge Results Section -->
      <div id="knowledgeSection" class="d-none">
        <!-- Entities Card -->
        <div class="knowledge-card card">
          <div class="card-header">
            <h6 class="mb-0">
              <i class="bi bi-tags"></i> Entities
              <span id="entitiesCount" class="badge bg-secondary ms-2">0</span>
            </h6>
          </div>
          <div class="card-body">
            <div id="entitiesContainer">
              <div class="text-muted text-center">
                <i class="bi bi-info-circle"></i>
                No entities extracted yet
              </div>
            </div>
          </div>
        </div>

        <!-- Relationships Card -->
        <div class="knowledge-card card">
          <div class="card-header">
            <h6 class="mb-0">
              <i class="bi bi-diagram-3"></i> Relationships
              <span id="relationshipsCount" class="badge bg-secondary ms-2"
                >0</span
              >
            </h6>
          </div>
          <div class="card-body">
            <div id="relationshipsContainer">
              <div class="text-muted text-center">
                <i class="bi bi-info-circle"></i>
                No relationships found yet
              </div>
            </div>
          </div>
        </div>

        <!-- Key Topics Card -->
        <div class="knowledge-card card">
          <div class="card-header">
            <h6 class="mb-0"><i class="bi bi-bookmark"></i> Key Topics</h6>
          </div>
          <div class="card-body">
            <div id="topicsContainer">
              <div class="text-muted text-center">
                <i class="bi bi-info-circle"></i>
                No topics identified yet
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- Suggested Questions Section -->
      <div id="questionsSection" class="knowledge-card card d-none">
        <div class="card-header">
          <h6 class="mb-0">
            <i class="bi bi-question-circle"></i> Ask About This Page
          </h6>
        </div>
        <div class="card-body">
          <div id="suggestedQuestions" class="mb-3">
            <!-- Suggested questions will be populated here -->
          </div>

          <div class="input-group">
            <input
              type="text"
              id="knowledgeQuery"
              class="form-control form-control-sm"
              placeholder="What would you like to know?"
            />
            <button id="submitQuery" class="btn btn-outline-primary btn-sm">
              <i class="bi bi-send"></i>
            </button>
          </div>

          <div id="queryResults" class="mt-3">
            <!-- Query results will appear here -->
          </div>
        </div>
      </div>
    </div>

    <script src="../vendor/bootstrap/bootstrap.bundle.min.js"></script>
    <script src="pageKnowledge.js"></script>
  </body>
</html>
