taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
131 lines (130 loc) • 5.42 kB
JavaScript
import { jsx as o, jsxs as E, Fragment as O } from "react/jsx-runtime";
import { D as P } from "./Dialog-Dbk1wDAi.js";
import { bJ as R, u as p, s as f, a as b, m as A, B as x, aN as S, o as v, t as k, D as U } from "./JBrowsePanel-BNE3gNW1.js";
import { useState as m, useEffect as w } from "react";
import { g as F } from "./index-CoM8QAjP.js";
import { B as h } from "./BaseCard-uve71KMy.js";
var I = R();
const y = /* @__PURE__ */ F(I);
function $({ config: e }) {
const [s, t] = m(), [n, c] = m(), a = p.getSession(e), { rpcManager: l } = a;
w(() => {
(async () => {
try {
const i = f.readConfObject(e, "adapter"), u = await l.call(e.trackId, "CoreGetInfo", {
adapterConfig: i
});
c(u);
} catch (i) {
console.error(i), t(i);
}
})();
}, [e, l]);
const g = typeof n == "string" ? {
header: `<pre>${n.replaceAll("<", "<").replaceAll(">", ">")}</pre>`
} : n || {};
return o(h, { title: "File info", children: s ? o(b.ErrorMessage, { error: s }) : n === void 0 ? o(b.LoadingEllipses, { message: "Loading file data" }) : o(y, { attributes: g }) });
}
function M(e, s) {
for (const t in e)
t === s ? delete e[t] : typeof e[t] == "object" && M(e[t], s);
return e;
}
function B({ config: e, pluginManager: s }) {
const t = p.getSession(e), n = f.readConfObject(e);
return s.evaluateExtensionPoint("Core-customizeAbout", {
config: {
...n,
...f.getConf(t, ["formatAbout", "config"], { config: n }),
...f.readConfObject(e, ["formatAbout", "config"], { config: n })
}
}, { session: t, config: e });
}
const L = A()({
button: {
float: "right"
}
});
function T({ conf: e, setShowRefNames: s }) {
const [t, n] = m(!1), { classes: c } = L();
return E("span", { className: c.button, children: [o(x, { variant: "contained", color: "secondary", onClick: () => {
s(!0);
}, children: "Show ref names" }), o(x, { variant: "contained", onClick: () => {
const a = M(structuredClone(e), "baseUri");
S(JSON.stringify(a, null, 2)), n(!0), setTimeout(() => {
n(!1);
}, 1e3);
}, children: t ? "Copied to clipboard!" : "Copy config" })] });
}
const N = 1e4, W = A()((e) => ({
container: {
minWidth: 800
},
refNames: {
maxHeight: 300,
overflow: "auto",
flexGrow: 1,
background: e.palette.background.default
}
})), G = v(function({ config: e, onClose: s }) {
const { classes: t } = W(), [n, c] = m(), [a, l] = m(), [g, i] = m(!1), { rpcManager: u } = p.getSession(e);
w(() => {
(async () => {
try {
const r = await Promise.all([...new Set(k.getConfAssemblyNames(e))].map(async (d) => {
const D = f.readConfObject(e, "adapter");
return [
d,
await u.call(e.trackId, "CoreGetRefNames", {
adapterConfig: D,
regions: [
{
assemblyName: d
}
]
})
];
}));
l(Object.fromEntries(r));
} catch (r) {
console.error(r), c(r);
}
})();
}, [e, u]);
const C = a ? Object.entries(a) : [], j = C.flatMap(([r, d]) => [
`--- ${r} ---`,
...d.slice(0, N),
d.length > N ? `
Too many refNames to show in browser for ${r}, use "Copy ref names" button to copy to clipboard` : ""
]).filter((r) => !!r).join(`
`);
return o(b.Dialog, { open: !0, title: "Reference sequence names used in track", onClose: s, maxWidth: "xl", children: o(U, { className: t.container, children: n ? o(b.ErrorMessage, { error: n }) : a === void 0 ? o(b.LoadingEllipses, { message: "Loading refNames" }) : E(O, { children: [o(x, { variant: "contained", onClick: () => {
S(C.flatMap(([r, d]) => [
`--- ${r} ---`,
...d
]).filter((r) => !!r).join(`
`)), i(!0), setTimeout(() => {
i(!1);
}, 1e3);
}, children: g ? "Copied to clipboard!" : "Copy ref names" }), o("pre", { className: t.refNames, children: j })] }) }) });
}), q = A()({
content: {
minWidth: 800
}
}), H = v(function({ config: e }) {
const s = f.readConfObject(e), t = p.getSession(e), { classes: n } = q(), [c, a] = m(!1), l = f.getConf(t, ["formatAbout", "hideUris"]) || f.readConfObject(e, ["formatAbout", "hideUris"]), { pluginManager: g } = p.getEnv(t), i = B({
config: e,
pluginManager: g
}), u = g.evaluateExtensionPoint("Core-extraAboutPanel", null, { session: t, config: e }), C = ["displays", "baseUri", "refNames", "formatAbout"];
return E("div", { className: n.content, children: [E(h, { title: "Configuration", children: [l ? null : o(T, { conf: s, setShowRefNames: a }), o(y, { attributes: i.config, omit: [...C, "metadata"], hideUris: l })] }), i.config.metadata ? o(h, { title: "Metadata", children: o(y, { attributes: i.config.metadata, omit: C, hideUris: l }) }) : null, u ? o(h, { title: u.name, children: o(u.Component, { config: e }) }) : null, o($, { config: e }), c ? o(G, { config: e, onClose: () => {
a(!1);
} }) : null] });
});
function V({ config: e, handleClose: s }) {
const t = p.getSession(e), n = k.getTrackName(e, t), { pluginManager: c } = p.getEnv(t), a = c.evaluateExtensionPoint("Core-replaceAbout", H, { session: t, config: e });
return o(P, { open: !0, onClose: s, title: n, maxWidth: "xl", children: o(a, { config: e }) });
}
export {
V as default
};
//# sourceMappingURL=AboutDialog-ChhMe7Qv.js.map