/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { html, when } from "chrome://global/content/vendor/lit.all.mjs";
import { SidebarPage } from "./sidebar-page.mjs";
// eslint-disable-next-line import/no-unassigned-import
import "chrome://browser/content/firefoxview/fxview-search-textbox.mjs";
// eslint-disable-next-line import/no-unassigned-import
import "chrome://browser/content/firefoxview/fxview-tab-list.mjs";
// eslint-disable-next-line import/no-unassigned-import
import "chrome://global/content/elements/moz-card.mjs";
import { HistoryController } from "chrome://browser/content/firefoxview/HistoryController.mjs";
import { navigateToLink } from "chrome://browser/content/firefoxview/helpers.mjs";
const NEVER_REMEMBER_HISTORY_PREF = "browser.privatebrowsing.autostart";
export class SidebarHistory extends SidebarPage {
constructor() {
super();
this._started = false;
// Setting maxTabsLength to -1 for no max
this.maxTabsLength = -1;
}
controller = new HistoryController(this, {
component: "sidebar",
});
connectedCallback() {
super.connectedCallback();
this.controller.updateAllHistoryItems();
}
onPrimaryAction(e) {
navigateToLink(e);
}
deleteFromHistory() {
this.controller.deleteFromHistory();
}
/**
* The template to use for cards-container.
*/
get cardsTemplate() {
if (this.controller.searchResults) {
return this.#searchResultsTemplate();
} else if (this.controller.allHistoryItems.size) {
return this.#historyCardsTemplate();
}
return this.#emptyMessageTemplate();
}
#historyCardsTemplate() {
let cardsTemplate = [];
this.controller.historyMapByDate.forEach(historyItem => {
if (historyItem.items.length) {
let dateArg = JSON.stringify({ date: historyItem.items[0].time });
cardsTemplate.push(html`