import { CSS } from "../helpers/loader.js";
const isRunningFromAnIframe = window.self !== window.top;
const css = await CSS(import.meta.url, "breadcrumb.css");
class ComponentBreadcrumb extends HTMLDivElement {
constructor() {
super();
if (new window.URL(location.href).searchParams.get("nav") === "false") return;
const htmlLogout = isRunningFromAnIframe
? ""
: `
`;
const paths = (this.getAttribute("path") || "").replace(new RegExp("/$"), "").split("/");
console.log(paths);
const htmlPathChunks = paths.map((chunk, idx) => {
const label = idx === 0 ? "Filestash" : chunk;
const link = paths.slice(0, idx + 1).join("/") + "/";
// const minify = (function() {
// if (idx === 0) return false;
// else if (paths.length <= (document.body.clientWidth > 800 ? 5 : 4)) return false;
// else if (idx > paths.length - (document.body.clientWidth > 1000 ? 4 : 3)) return false;
// return true;
// }());
const limitSize = (word, highlight = false) => {
if (highlight === true && word.length > 30) { return word.substring(0, 12).trim() + "..." +
word.substring(word.length - 10, word.length).trim(); }
else if (word.length > 27) return word.substring(0, 20).trim() + "...";
return word;
};
const isLast = idx === paths.length - 1;
if (isLast) return `