@nice2dev/ui-science 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/index.cjs +69 -0
- package/dist/index.d.ts +1461 -0
- package/dist/index.mjs +4820 -0
- package/package.json +70 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4820 @@
|
|
|
1
|
+
var st = Object.defineProperty;
|
|
2
|
+
var at = (e, t, n) => t in e ? st(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var ve = (e, t, n) => at(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsx as o, jsxs as u, Fragment as Ae } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as Ue, useContext as Ze, useState as E, useCallback as P, useMemo as K, useRef as ze, useEffect as Ye } from "react";
|
|
6
|
+
class lt {
|
|
7
|
+
constructor(t) {
|
|
8
|
+
ve(this, "config");
|
|
9
|
+
ve(this, "notebooks", /* @__PURE__ */ new Map());
|
|
10
|
+
this.config = t;
|
|
11
|
+
}
|
|
12
|
+
/** Create new notebook */
|
|
13
|
+
async createNotebook(t) {
|
|
14
|
+
const n = {
|
|
15
|
+
id: this.generateId(),
|
|
16
|
+
name: t.name || "Untitled Notebook",
|
|
17
|
+
description: t.description,
|
|
18
|
+
project: t.project,
|
|
19
|
+
owner: t.owner || "current-user",
|
|
20
|
+
collaborators: t.collaborators || [],
|
|
21
|
+
entries: [],
|
|
22
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
24
|
+
isArchived: !1,
|
|
25
|
+
settings: t.settings || {
|
|
26
|
+
requireSignatures: !0,
|
|
27
|
+
requireWitness: !1,
|
|
28
|
+
autoLockAfterSign: !0,
|
|
29
|
+
defaultEntryType: "experiment",
|
|
30
|
+
customFields: [],
|
|
31
|
+
templates: []
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return this.notebooks.set(n.id, n), n;
|
|
35
|
+
}
|
|
36
|
+
/** Get notebook by ID */
|
|
37
|
+
async getNotebook(t) {
|
|
38
|
+
return this.notebooks.get(t) || null;
|
|
39
|
+
}
|
|
40
|
+
/** List all notebooks */
|
|
41
|
+
async listNotebooks() {
|
|
42
|
+
return Array.from(this.notebooks.values());
|
|
43
|
+
}
|
|
44
|
+
/** Create new entry */
|
|
45
|
+
async createEntry(t, n) {
|
|
46
|
+
const r = this.notebooks.get(t);
|
|
47
|
+
if (!r)
|
|
48
|
+
throw new Error(`Notebook not found: ${t}`);
|
|
49
|
+
const i = {
|
|
50
|
+
id: this.generateId(),
|
|
51
|
+
notebookId: t,
|
|
52
|
+
type: n.type || r.settings.defaultEntryType,
|
|
53
|
+
status: "draft",
|
|
54
|
+
title: n.title || "Untitled Entry",
|
|
55
|
+
objective: n.objective,
|
|
56
|
+
hypothesis: n.hypothesis,
|
|
57
|
+
methods: n.methods,
|
|
58
|
+
results: n.results,
|
|
59
|
+
conclusions: n.conclusions,
|
|
60
|
+
sections: n.sections || [],
|
|
61
|
+
attachments: [],
|
|
62
|
+
tags: n.tags || [],
|
|
63
|
+
linkedEntries: n.linkedEntries || [],
|
|
64
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66
|
+
createdBy: "current-user",
|
|
67
|
+
lastModifiedBy: "current-user",
|
|
68
|
+
version: 1,
|
|
69
|
+
signatures: [],
|
|
70
|
+
comments: []
|
|
71
|
+
};
|
|
72
|
+
return r.entries.push(i), r.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), i;
|
|
73
|
+
}
|
|
74
|
+
/** Update entry */
|
|
75
|
+
async updateEntry(t, n, r) {
|
|
76
|
+
const i = this.notebooks.get(t);
|
|
77
|
+
if (!i)
|
|
78
|
+
throw new Error(`Notebook not found: ${t}`);
|
|
79
|
+
const s = i.entries.findIndex((c) => c.id === n);
|
|
80
|
+
if (s === -1)
|
|
81
|
+
throw new Error(`Entry not found: ${n}`);
|
|
82
|
+
const a = i.entries[s];
|
|
83
|
+
if (a.status === "locked")
|
|
84
|
+
throw new Error("Cannot modify locked entry");
|
|
85
|
+
const l = {
|
|
86
|
+
...a,
|
|
87
|
+
...r,
|
|
88
|
+
id: a.id,
|
|
89
|
+
notebookId: t,
|
|
90
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
91
|
+
lastModifiedBy: "current-user",
|
|
92
|
+
version: a.version + 1
|
|
93
|
+
};
|
|
94
|
+
return i.entries[s] = l, i.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), l;
|
|
95
|
+
}
|
|
96
|
+
/** Sign entry */
|
|
97
|
+
async signEntry(t, n, r) {
|
|
98
|
+
const i = this.notebooks.get(t);
|
|
99
|
+
if (!i)
|
|
100
|
+
throw new Error(`Notebook not found: ${t}`);
|
|
101
|
+
const s = i.entries.find((l) => l.id === n);
|
|
102
|
+
if (!s)
|
|
103
|
+
throw new Error(`Entry not found: ${n}`);
|
|
104
|
+
const a = {
|
|
105
|
+
...r,
|
|
106
|
+
signedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
107
|
+
signatureHash: this.generateSignatureHash(s, r.userId)
|
|
108
|
+
};
|
|
109
|
+
return s.signatures.push(a), i.settings.autoLockAfterSign && r.role === "author" && (s.status = "signed"), s.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), s;
|
|
110
|
+
}
|
|
111
|
+
/** Add attachment to entry */
|
|
112
|
+
async addAttachment(t, n, r) {
|
|
113
|
+
const i = this.notebooks.get(t);
|
|
114
|
+
if (!i)
|
|
115
|
+
throw new Error(`Notebook not found: ${t}`);
|
|
116
|
+
const s = i.entries.find((l) => l.id === n);
|
|
117
|
+
if (!s)
|
|
118
|
+
throw new Error(`Entry not found: ${n}`);
|
|
119
|
+
const a = {
|
|
120
|
+
id: this.generateId(),
|
|
121
|
+
name: r.name,
|
|
122
|
+
type: r.type,
|
|
123
|
+
size: r.size,
|
|
124
|
+
url: URL.createObjectURL(r),
|
|
125
|
+
uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
126
|
+
uploadedBy: "current-user"
|
|
127
|
+
};
|
|
128
|
+
return s.attachments.push(a), s.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), a;
|
|
129
|
+
}
|
|
130
|
+
/** Search entries */
|
|
131
|
+
async searchEntries(t, n) {
|
|
132
|
+
var s, a, l, c, h, p;
|
|
133
|
+
const r = [], i = t.toLowerCase();
|
|
134
|
+
for (const m of this.notebooks.values())
|
|
135
|
+
if (!(n != null && n.notebookId && m.id !== n.notebookId))
|
|
136
|
+
for (const y of m.entries)
|
|
137
|
+
n != null && n.type && y.type !== n.type || n != null && n.status && y.status !== n.status || (s = n == null ? void 0 : n.tags) != null && s.length && !n.tags.some(($) => y.tags.includes($)) || n != null && n.dateFrom && y.createdAt < n.dateFrom || n != null && n.dateTo && y.createdAt > n.dateTo || (y.title.toLowerCase().includes(i) || (a = y.objective) != null && a.toLowerCase().includes(i) || (l = y.hypothesis) != null && l.toLowerCase().includes(i) || (c = y.methods) != null && c.toLowerCase().includes(i) || (h = y.results) != null && h.toLowerCase().includes(i) || (p = y.conclusions) != null && p.toLowerCase().includes(i)) && r.push(y);
|
|
138
|
+
return r;
|
|
139
|
+
}
|
|
140
|
+
/** Export entry to PDF/HTML */
|
|
141
|
+
async exportEntry(t, n, r) {
|
|
142
|
+
const i = this.notebooks.get(t);
|
|
143
|
+
if (!i)
|
|
144
|
+
throw new Error(`Notebook not found: ${t}`);
|
|
145
|
+
const s = i.entries.find((l) => l.id === n);
|
|
146
|
+
if (!s)
|
|
147
|
+
throw new Error(`Entry not found: ${n}`);
|
|
148
|
+
const a = this.generateEntryHTML(s, i);
|
|
149
|
+
return r === "html" ? new Blob([a], { type: "text/html" }) : new Blob([a], { type: "text/html" });
|
|
150
|
+
}
|
|
151
|
+
generateEntryHTML(t, n) {
|
|
152
|
+
return `
|
|
153
|
+
<!DOCTYPE html>
|
|
154
|
+
<html>
|
|
155
|
+
<head>
|
|
156
|
+
<meta charset="utf-8">
|
|
157
|
+
<title>${t.title}</title>
|
|
158
|
+
<style>
|
|
159
|
+
body { font-family: 'Times New Roman', serif; max-width: 800px; margin: 0 auto; padding: 20px; }
|
|
160
|
+
h1 { border-bottom: 2px solid #333; }
|
|
161
|
+
.meta { color: #666; font-size: 0.9em; }
|
|
162
|
+
.section { margin: 20px 0; }
|
|
163
|
+
.signatures { border-top: 1px solid #ccc; margin-top: 40px; padding-top: 20px; }
|
|
164
|
+
</style>
|
|
165
|
+
</head>
|
|
166
|
+
<body>
|
|
167
|
+
<h1>${t.title}</h1>
|
|
168
|
+
<div class="meta">
|
|
169
|
+
<p>Notebook: ${n.name}</p>
|
|
170
|
+
<p>Entry ID: ${t.id}</p>
|
|
171
|
+
<p>Type: ${t.type}</p>
|
|
172
|
+
<p>Created: ${new Date(t.createdAt).toLocaleString()}</p>
|
|
173
|
+
<p>Version: ${t.version}</p>
|
|
174
|
+
</div>
|
|
175
|
+
${t.objective ? `<div class="section"><h2>Objective</h2><p>${t.objective}</p></div>` : ""}
|
|
176
|
+
${t.hypothesis ? `<div class="section"><h2>Hypothesis</h2><p>${t.hypothesis}</p></div>` : ""}
|
|
177
|
+
${t.methods ? `<div class="section"><h2>Methods</h2><p>${t.methods}</p></div>` : ""}
|
|
178
|
+
${t.results ? `<div class="section"><h2>Results</h2><p>${t.results}</p></div>` : ""}
|
|
179
|
+
${t.conclusions ? `<div class="section"><h2>Conclusions</h2><p>${t.conclusions}</p></div>` : ""}
|
|
180
|
+
${t.signatures.length > 0 ? `
|
|
181
|
+
<div class="signatures">
|
|
182
|
+
<h2>Signatures</h2>
|
|
183
|
+
${t.signatures.map(
|
|
184
|
+
(r) => `
|
|
185
|
+
<p><strong>${r.userName}</strong> (${r.role}) - ${new Date(r.signedAt).toLocaleString()}</p>
|
|
186
|
+
`
|
|
187
|
+
).join("")}
|
|
188
|
+
</div>
|
|
189
|
+
` : ""}
|
|
190
|
+
</body>
|
|
191
|
+
</html>
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
generateId() {
|
|
195
|
+
return Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
196
|
+
}
|
|
197
|
+
generateSignatureHash(t, n) {
|
|
198
|
+
const r = JSON.stringify({ entry: t, userId: n, timestamp: Date.now() });
|
|
199
|
+
return Buffer.from(r).toString("base64").substring(0, 32);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function Kt(e) {
|
|
203
|
+
return new lt(e);
|
|
204
|
+
}
|
|
205
|
+
const Ke = Ue(null);
|
|
206
|
+
function Xe() {
|
|
207
|
+
const e = Ze(Ke);
|
|
208
|
+
if (!e)
|
|
209
|
+
throw new Error("useLabNotebook must be used within LabNotebookProvider");
|
|
210
|
+
return e;
|
|
211
|
+
}
|
|
212
|
+
function ct({
|
|
213
|
+
service: e,
|
|
214
|
+
children: t
|
|
215
|
+
}) {
|
|
216
|
+
const [n, r] = E([]), [i, s] = E(null), [a, l] = E(null), c = P(async () => {
|
|
217
|
+
const $ = await e.listNotebooks();
|
|
218
|
+
r($);
|
|
219
|
+
}, [e]), h = K(
|
|
220
|
+
() => n.find(($) => $.id === i) || null,
|
|
221
|
+
[n, i]
|
|
222
|
+
), p = K(
|
|
223
|
+
() => (h == null ? void 0 : h.entries.find(($) => $.id === a)) || null,
|
|
224
|
+
[h, a]
|
|
225
|
+
), m = P(($) => {
|
|
226
|
+
s($), l(null);
|
|
227
|
+
}, []), y = {
|
|
228
|
+
service: e,
|
|
229
|
+
notebooks: n,
|
|
230
|
+
currentNotebook: h,
|
|
231
|
+
currentEntry: p,
|
|
232
|
+
setCurrentNotebook: m,
|
|
233
|
+
setCurrentEntry: l,
|
|
234
|
+
refresh: c
|
|
235
|
+
};
|
|
236
|
+
return /* @__PURE__ */ o(Ke.Provider, { value: y, children: t });
|
|
237
|
+
}
|
|
238
|
+
const q = {
|
|
239
|
+
container: {
|
|
240
|
+
display: "flex",
|
|
241
|
+
height: "100%",
|
|
242
|
+
backgroundColor: "#f5f5f5",
|
|
243
|
+
fontFamily: "'Inter', sans-serif"
|
|
244
|
+
},
|
|
245
|
+
sidebar: {
|
|
246
|
+
width: "280px",
|
|
247
|
+
backgroundColor: "#fff",
|
|
248
|
+
borderRight: "1px solid #e0e0e0",
|
|
249
|
+
display: "flex",
|
|
250
|
+
flexDirection: "column"
|
|
251
|
+
},
|
|
252
|
+
main: {
|
|
253
|
+
flex: 1,
|
|
254
|
+
display: "flex",
|
|
255
|
+
flexDirection: "column",
|
|
256
|
+
overflow: "hidden"
|
|
257
|
+
},
|
|
258
|
+
header: {
|
|
259
|
+
padding: "16px 24px",
|
|
260
|
+
borderBottom: "1px solid #e0e0e0",
|
|
261
|
+
backgroundColor: "#fff"
|
|
262
|
+
},
|
|
263
|
+
content: {
|
|
264
|
+
flex: 1,
|
|
265
|
+
padding: "24px",
|
|
266
|
+
overflow: "auto"
|
|
267
|
+
},
|
|
268
|
+
entryCard: {
|
|
269
|
+
padding: "12px 16px",
|
|
270
|
+
borderBottom: "1px solid #eee",
|
|
271
|
+
cursor: "pointer",
|
|
272
|
+
transition: "background-color 0.15s"
|
|
273
|
+
},
|
|
274
|
+
badge: {
|
|
275
|
+
display: "inline-block",
|
|
276
|
+
padding: "2px 8px",
|
|
277
|
+
borderRadius: "4px",
|
|
278
|
+
fontSize: "11px",
|
|
279
|
+
fontWeight: 500,
|
|
280
|
+
textTransform: "uppercase"
|
|
281
|
+
},
|
|
282
|
+
input: {
|
|
283
|
+
width: "100%",
|
|
284
|
+
padding: "8px 12px",
|
|
285
|
+
border: "1px solid #ddd",
|
|
286
|
+
borderRadius: "4px",
|
|
287
|
+
fontSize: "14px"
|
|
288
|
+
},
|
|
289
|
+
textarea: {
|
|
290
|
+
width: "100%",
|
|
291
|
+
padding: "12px",
|
|
292
|
+
border: "1px solid #ddd",
|
|
293
|
+
borderRadius: "4px",
|
|
294
|
+
fontSize: "14px",
|
|
295
|
+
minHeight: "100px",
|
|
296
|
+
resize: "vertical"
|
|
297
|
+
},
|
|
298
|
+
button: {
|
|
299
|
+
padding: "8px 16px",
|
|
300
|
+
backgroundColor: "#1976d2",
|
|
301
|
+
color: "#fff",
|
|
302
|
+
border: "none",
|
|
303
|
+
borderRadius: "4px",
|
|
304
|
+
cursor: "pointer",
|
|
305
|
+
fontSize: "14px"
|
|
306
|
+
}
|
|
307
|
+
}, Be = {
|
|
308
|
+
draft: "#9e9e9e",
|
|
309
|
+
"in-progress": "#2196f3",
|
|
310
|
+
completed: "#4caf50",
|
|
311
|
+
reviewed: "#ff9800",
|
|
312
|
+
signed: "#9c27b0",
|
|
313
|
+
locked: "#f44336"
|
|
314
|
+
}, Je = {
|
|
315
|
+
experiment: "🧪",
|
|
316
|
+
protocol: "📋",
|
|
317
|
+
observation: "👁",
|
|
318
|
+
calculation: "🔢",
|
|
319
|
+
meeting: "👥",
|
|
320
|
+
report: "📊",
|
|
321
|
+
note: "📝"
|
|
322
|
+
};
|
|
323
|
+
function Jt({
|
|
324
|
+
service: e,
|
|
325
|
+
className: t,
|
|
326
|
+
style: n
|
|
327
|
+
}) {
|
|
328
|
+
return /* @__PURE__ */ o(ct, { service: e, children: /* @__PURE__ */ u("div", { className: t, style: { ...q.container, ...n }, children: [
|
|
329
|
+
/* @__PURE__ */ o(dt, {}),
|
|
330
|
+
/* @__PURE__ */ o(ut, {})
|
|
331
|
+
] }) });
|
|
332
|
+
}
|
|
333
|
+
function dt() {
|
|
334
|
+
const { notebooks: e, currentNotebook: t, setCurrentNotebook: n, service: r, refresh: i } = Xe(), [s, a] = E(!1), [l, c] = E(""), h = async () => {
|
|
335
|
+
l.trim() && (await r.createNotebook({ name: l.trim() }), await i(), c(""), a(!1));
|
|
336
|
+
};
|
|
337
|
+
return /* @__PURE__ */ u("div", { style: q.sidebar, children: [
|
|
338
|
+
/* @__PURE__ */ o("div", { style: { padding: "16px", borderBottom: "1px solid #e0e0e0" }, children: /* @__PURE__ */ o("h2", { style: { margin: 0, fontSize: "18px" }, children: "📓 Lab Notebooks" }) }),
|
|
339
|
+
/* @__PURE__ */ o("div", { style: { flex: 1, overflow: "auto" }, children: e.map((p) => /* @__PURE__ */ u(
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
onClick: () => n(p.id),
|
|
343
|
+
style: {
|
|
344
|
+
...q.entryCard,
|
|
345
|
+
backgroundColor: (t == null ? void 0 : t.id) === p.id ? "#e3f2fd" : "transparent"
|
|
346
|
+
},
|
|
347
|
+
children: [
|
|
348
|
+
/* @__PURE__ */ o("div", { style: { fontWeight: 500 }, children: p.name }),
|
|
349
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", color: "#666", marginTop: "4px" }, children: [
|
|
350
|
+
p.entries.length,
|
|
351
|
+
" entries"
|
|
352
|
+
] })
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
p.id
|
|
356
|
+
)) }),
|
|
357
|
+
/* @__PURE__ */ o("div", { style: { padding: "16px", borderTop: "1px solid #e0e0e0" }, children: s ? /* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
|
|
358
|
+
/* @__PURE__ */ o(
|
|
359
|
+
"input",
|
|
360
|
+
{
|
|
361
|
+
type: "text",
|
|
362
|
+
value: l,
|
|
363
|
+
onChange: (p) => c(p.target.value),
|
|
364
|
+
placeholder: "Notebook name",
|
|
365
|
+
style: q.input,
|
|
366
|
+
autoFocus: !0
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
370
|
+
/* @__PURE__ */ o("button", { onClick: h, style: q.button, children: "Create" }),
|
|
371
|
+
/* @__PURE__ */ o(
|
|
372
|
+
"button",
|
|
373
|
+
{
|
|
374
|
+
onClick: () => a(!1),
|
|
375
|
+
style: { ...q.button, backgroundColor: "#9e9e9e" },
|
|
376
|
+
children: "Cancel"
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
] })
|
|
380
|
+
] }) : /* @__PURE__ */ o("button", { onClick: () => a(!0), style: { ...q.button, width: "100%" }, children: "+ New Notebook" }) })
|
|
381
|
+
] });
|
|
382
|
+
}
|
|
383
|
+
function ut() {
|
|
384
|
+
const { currentNotebook: e, currentEntry: t, setCurrentEntry: n, service: r, refresh: i } = Xe(), [s, a] = E(!1);
|
|
385
|
+
if (!e)
|
|
386
|
+
return /* @__PURE__ */ o("div", { style: { ...q.main, justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ u("div", { style: { textAlign: "center", color: "#666" }, children: [
|
|
387
|
+
/* @__PURE__ */ o("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "📓" }),
|
|
388
|
+
/* @__PURE__ */ o("div", { style: { fontSize: "18px" }, children: "Select a notebook to get started" })
|
|
389
|
+
] }) });
|
|
390
|
+
const l = async (c) => {
|
|
391
|
+
const h = await r.createEntry(e.id, c);
|
|
392
|
+
await i(), n(h.id), a(!1);
|
|
393
|
+
};
|
|
394
|
+
return /* @__PURE__ */ u("div", { style: q.main, children: [
|
|
395
|
+
/* @__PURE__ */ o("div", { style: q.header, children: /* @__PURE__ */ u("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
396
|
+
/* @__PURE__ */ o("h1", { style: { margin: 0, fontSize: "20px" }, children: e.name }),
|
|
397
|
+
/* @__PURE__ */ o("button", { onClick: () => a(!0), style: q.button, children: "+ New Entry" })
|
|
398
|
+
] }) }),
|
|
399
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", flex: 1, overflow: "hidden" }, children: [
|
|
400
|
+
/* @__PURE__ */ o("div", { style: { width: "300px", borderRight: "1px solid #e0e0e0", overflow: "auto" }, children: e.entries.map((c) => /* @__PURE__ */ u(
|
|
401
|
+
"div",
|
|
402
|
+
{
|
|
403
|
+
onClick: () => n(c.id),
|
|
404
|
+
style: {
|
|
405
|
+
...q.entryCard,
|
|
406
|
+
backgroundColor: (t == null ? void 0 : t.id) === c.id ? "#e3f2fd" : "transparent"
|
|
407
|
+
},
|
|
408
|
+
children: [
|
|
409
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px", alignItems: "center" }, children: [
|
|
410
|
+
/* @__PURE__ */ o("span", { children: Je[c.type] }),
|
|
411
|
+
/* @__PURE__ */ o("span", { style: { fontWeight: 500 }, children: c.title })
|
|
412
|
+
] }),
|
|
413
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px", marginTop: "8px" }, children: [
|
|
414
|
+
/* @__PURE__ */ o(
|
|
415
|
+
"span",
|
|
416
|
+
{
|
|
417
|
+
style: {
|
|
418
|
+
...q.badge,
|
|
419
|
+
backgroundColor: `${Be[c.status]}20`,
|
|
420
|
+
color: Be[c.status]
|
|
421
|
+
},
|
|
422
|
+
children: c.status
|
|
423
|
+
}
|
|
424
|
+
),
|
|
425
|
+
/* @__PURE__ */ o("span", { style: { fontSize: "12px", color: "#666" }, children: new Date(c.updatedAt).toLocaleDateString() })
|
|
426
|
+
] })
|
|
427
|
+
]
|
|
428
|
+
},
|
|
429
|
+
c.id
|
|
430
|
+
)) }),
|
|
431
|
+
/* @__PURE__ */ o("div", { style: q.content, children: t ? /* @__PURE__ */ o(ht, { entry: t }) : s ? /* @__PURE__ */ o(pt, { onSubmit: l, onCancel: () => a(!1) }) : /* @__PURE__ */ o("div", { style: { textAlign: "center", color: "#666", marginTop: "100px" }, children: "Select an entry or create a new one" }) })
|
|
432
|
+
] })
|
|
433
|
+
] });
|
|
434
|
+
}
|
|
435
|
+
function ht({ entry: e }) {
|
|
436
|
+
const { service: t, currentNotebook: n, refresh: r } = Xe(), [i, s] = E(!1), [a, l] = E(e), c = e.status === "locked" || e.status === "signed", h = async () => {
|
|
437
|
+
n && (await t.updateEntry(n.id, e.id, a), await r(), s(!1));
|
|
438
|
+
}, p = async () => {
|
|
439
|
+
n && (await t.signEntry(n.id, e.id, {
|
|
440
|
+
userId: "current-user",
|
|
441
|
+
userName: "Current User",
|
|
442
|
+
role: "author"
|
|
443
|
+
}), await r());
|
|
444
|
+
};
|
|
445
|
+
return /* @__PURE__ */ u("div", { children: [
|
|
446
|
+
/* @__PURE__ */ u(
|
|
447
|
+
"div",
|
|
448
|
+
{
|
|
449
|
+
style: {
|
|
450
|
+
display: "flex",
|
|
451
|
+
justifyContent: "space-between",
|
|
452
|
+
alignItems: "flex-start",
|
|
453
|
+
marginBottom: "24px"
|
|
454
|
+
},
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ u("div", { children: [
|
|
457
|
+
/* @__PURE__ */ o("h2", { style: { margin: 0 }, children: e.title }),
|
|
458
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px", marginTop: "8px" }, children: [
|
|
459
|
+
/* @__PURE__ */ o(
|
|
460
|
+
"span",
|
|
461
|
+
{
|
|
462
|
+
style: {
|
|
463
|
+
...q.badge,
|
|
464
|
+
backgroundColor: `${Be[e.status]}20`,
|
|
465
|
+
color: Be[e.status]
|
|
466
|
+
},
|
|
467
|
+
children: e.status
|
|
468
|
+
}
|
|
469
|
+
),
|
|
470
|
+
/* @__PURE__ */ u("span", { style: { fontSize: "12px", color: "#666" }, children: [
|
|
471
|
+
"v",
|
|
472
|
+
e.version
|
|
473
|
+
] })
|
|
474
|
+
] })
|
|
475
|
+
] }),
|
|
476
|
+
!c && /* @__PURE__ */ o("div", { style: { display: "flex", gap: "8px" }, children: i ? /* @__PURE__ */ u(Ae, { children: [
|
|
477
|
+
/* @__PURE__ */ o("button", { onClick: h, style: q.button, children: "Save" }),
|
|
478
|
+
/* @__PURE__ */ o(
|
|
479
|
+
"button",
|
|
480
|
+
{
|
|
481
|
+
onClick: () => {
|
|
482
|
+
s(!1), l(e);
|
|
483
|
+
},
|
|
484
|
+
style: { ...q.button, backgroundColor: "#9e9e9e" },
|
|
485
|
+
children: "Cancel"
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
] }) : /* @__PURE__ */ u(Ae, { children: [
|
|
489
|
+
/* @__PURE__ */ o("button", { onClick: () => s(!0), style: q.button, children: "Edit" }),
|
|
490
|
+
/* @__PURE__ */ o(
|
|
491
|
+
"button",
|
|
492
|
+
{
|
|
493
|
+
onClick: p,
|
|
494
|
+
style: { ...q.button, backgroundColor: "#9c27b0" },
|
|
495
|
+
children: "Sign"
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
] }) })
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
),
|
|
502
|
+
i ? /* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
503
|
+
/* @__PURE__ */ u("div", { children: [
|
|
504
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Title" }),
|
|
505
|
+
/* @__PURE__ */ o(
|
|
506
|
+
"input",
|
|
507
|
+
{
|
|
508
|
+
type: "text",
|
|
509
|
+
value: a.title,
|
|
510
|
+
onChange: (m) => l({ ...a, title: m.target.value }),
|
|
511
|
+
style: q.input
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
] }),
|
|
515
|
+
/* @__PURE__ */ u("div", { children: [
|
|
516
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Objective" }),
|
|
517
|
+
/* @__PURE__ */ o(
|
|
518
|
+
"textarea",
|
|
519
|
+
{
|
|
520
|
+
value: a.objective || "",
|
|
521
|
+
onChange: (m) => l({ ...a, objective: m.target.value }),
|
|
522
|
+
style: q.textarea
|
|
523
|
+
}
|
|
524
|
+
)
|
|
525
|
+
] }),
|
|
526
|
+
/* @__PURE__ */ u("div", { children: [
|
|
527
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Methods" }),
|
|
528
|
+
/* @__PURE__ */ o(
|
|
529
|
+
"textarea",
|
|
530
|
+
{
|
|
531
|
+
value: a.methods || "",
|
|
532
|
+
onChange: (m) => l({ ...a, methods: m.target.value }),
|
|
533
|
+
style: q.textarea
|
|
534
|
+
}
|
|
535
|
+
)
|
|
536
|
+
] }),
|
|
537
|
+
/* @__PURE__ */ u("div", { children: [
|
|
538
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Results" }),
|
|
539
|
+
/* @__PURE__ */ o(
|
|
540
|
+
"textarea",
|
|
541
|
+
{
|
|
542
|
+
value: a.results || "",
|
|
543
|
+
onChange: (m) => l({ ...a, results: m.target.value }),
|
|
544
|
+
style: q.textarea
|
|
545
|
+
}
|
|
546
|
+
)
|
|
547
|
+
] }),
|
|
548
|
+
/* @__PURE__ */ u("div", { children: [
|
|
549
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Conclusions" }),
|
|
550
|
+
/* @__PURE__ */ o(
|
|
551
|
+
"textarea",
|
|
552
|
+
{
|
|
553
|
+
value: a.conclusions || "",
|
|
554
|
+
onChange: (m) => l({ ...a, conclusions: m.target.value }),
|
|
555
|
+
style: q.textarea
|
|
556
|
+
}
|
|
557
|
+
)
|
|
558
|
+
] })
|
|
559
|
+
] }) : /* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column", gap: "24px" }, children: [
|
|
560
|
+
e.objective && /* @__PURE__ */ u("section", { children: [
|
|
561
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0", color: "#1976d2" }, children: "Objective" }),
|
|
562
|
+
/* @__PURE__ */ o("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: e.objective })
|
|
563
|
+
] }),
|
|
564
|
+
e.hypothesis && /* @__PURE__ */ u("section", { children: [
|
|
565
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0", color: "#1976d2" }, children: "Hypothesis" }),
|
|
566
|
+
/* @__PURE__ */ o("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: e.hypothesis })
|
|
567
|
+
] }),
|
|
568
|
+
e.methods && /* @__PURE__ */ u("section", { children: [
|
|
569
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0", color: "#1976d2" }, children: "Methods" }),
|
|
570
|
+
/* @__PURE__ */ o("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: e.methods })
|
|
571
|
+
] }),
|
|
572
|
+
e.results && /* @__PURE__ */ u("section", { children: [
|
|
573
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0", color: "#1976d2" }, children: "Results" }),
|
|
574
|
+
/* @__PURE__ */ o("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: e.results })
|
|
575
|
+
] }),
|
|
576
|
+
e.conclusions && /* @__PURE__ */ u("section", { children: [
|
|
577
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0", color: "#1976d2" }, children: "Conclusions" }),
|
|
578
|
+
/* @__PURE__ */ o("p", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: e.conclusions })
|
|
579
|
+
] }),
|
|
580
|
+
e.signatures.length > 0 && /* @__PURE__ */ u("section", { children: [
|
|
581
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0", color: "#9c27b0" }, children: "Signatures" }),
|
|
582
|
+
e.signatures.map((m, y) => /* @__PURE__ */ u(
|
|
583
|
+
"div",
|
|
584
|
+
{
|
|
585
|
+
style: {
|
|
586
|
+
padding: "8px",
|
|
587
|
+
backgroundColor: "#f5f5f5",
|
|
588
|
+
borderRadius: "4px",
|
|
589
|
+
marginBottom: "8px"
|
|
590
|
+
},
|
|
591
|
+
children: [
|
|
592
|
+
/* @__PURE__ */ o("strong", { children: m.userName }),
|
|
593
|
+
" (",
|
|
594
|
+
m.role,
|
|
595
|
+
")",
|
|
596
|
+
/* @__PURE__ */ o("div", { style: { fontSize: "12px", color: "#666" }, children: new Date(m.signedAt).toLocaleString() })
|
|
597
|
+
]
|
|
598
|
+
},
|
|
599
|
+
y
|
|
600
|
+
))
|
|
601
|
+
] }),
|
|
602
|
+
e.attachments.length > 0 && /* @__PURE__ */ u("section", { children: [
|
|
603
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 8px 0" }, children: "Attachments" }),
|
|
604
|
+
e.attachments.map((m) => /* @__PURE__ */ u(
|
|
605
|
+
"a",
|
|
606
|
+
{
|
|
607
|
+
href: m.url,
|
|
608
|
+
target: "_blank",
|
|
609
|
+
rel: "noopener noreferrer",
|
|
610
|
+
style: { display: "block", color: "#1976d2", textDecoration: "none" },
|
|
611
|
+
children: [
|
|
612
|
+
"📎 ",
|
|
613
|
+
m.name,
|
|
614
|
+
" (",
|
|
615
|
+
(m.size / 1024).toFixed(1),
|
|
616
|
+
" KB)"
|
|
617
|
+
]
|
|
618
|
+
},
|
|
619
|
+
m.id
|
|
620
|
+
))
|
|
621
|
+
] })
|
|
622
|
+
] })
|
|
623
|
+
] });
|
|
624
|
+
}
|
|
625
|
+
function pt({
|
|
626
|
+
onSubmit: e,
|
|
627
|
+
onCancel: t
|
|
628
|
+
}) {
|
|
629
|
+
const [n, r] = E({
|
|
630
|
+
title: "",
|
|
631
|
+
type: "experiment",
|
|
632
|
+
objective: ""
|
|
633
|
+
});
|
|
634
|
+
return /* @__PURE__ */ u("form", { onSubmit: (s) => {
|
|
635
|
+
var a;
|
|
636
|
+
s.preventDefault(), (a = n.title) != null && a.trim() && e(n);
|
|
637
|
+
}, style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
638
|
+
/* @__PURE__ */ o("h2", { style: { margin: 0 }, children: "New Entry" }),
|
|
639
|
+
/* @__PURE__ */ u("div", { children: [
|
|
640
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Type" }),
|
|
641
|
+
/* @__PURE__ */ o(
|
|
642
|
+
"select",
|
|
643
|
+
{
|
|
644
|
+
value: n.type,
|
|
645
|
+
onChange: (s) => r({ ...n, type: s.target.value }),
|
|
646
|
+
style: q.input,
|
|
647
|
+
children: Object.entries(Je).map(([s, a]) => /* @__PURE__ */ u("option", { value: s, children: [
|
|
648
|
+
a,
|
|
649
|
+
" ",
|
|
650
|
+
s
|
|
651
|
+
] }, s))
|
|
652
|
+
}
|
|
653
|
+
)
|
|
654
|
+
] }),
|
|
655
|
+
/* @__PURE__ */ u("div", { children: [
|
|
656
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Title *" }),
|
|
657
|
+
/* @__PURE__ */ o(
|
|
658
|
+
"input",
|
|
659
|
+
{
|
|
660
|
+
type: "text",
|
|
661
|
+
value: n.title,
|
|
662
|
+
onChange: (s) => r({ ...n, title: s.target.value }),
|
|
663
|
+
placeholder: "Enter entry title",
|
|
664
|
+
style: q.input,
|
|
665
|
+
required: !0
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
] }),
|
|
669
|
+
/* @__PURE__ */ u("div", { children: [
|
|
670
|
+
/* @__PURE__ */ o("label", { style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: "Objective" }),
|
|
671
|
+
/* @__PURE__ */ o(
|
|
672
|
+
"textarea",
|
|
673
|
+
{
|
|
674
|
+
value: n.objective,
|
|
675
|
+
onChange: (s) => r({ ...n, objective: s.target.value }),
|
|
676
|
+
placeholder: "What is the goal of this entry?",
|
|
677
|
+
style: q.textarea
|
|
678
|
+
}
|
|
679
|
+
)
|
|
680
|
+
] }),
|
|
681
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
682
|
+
/* @__PURE__ */ o("button", { type: "submit", style: q.button, children: "Create Entry" }),
|
|
683
|
+
/* @__PURE__ */ o(
|
|
684
|
+
"button",
|
|
685
|
+
{
|
|
686
|
+
type: "button",
|
|
687
|
+
onClick: t,
|
|
688
|
+
style: { ...q.button, backgroundColor: "#9e9e9e" },
|
|
689
|
+
children: "Cancel"
|
|
690
|
+
}
|
|
691
|
+
)
|
|
692
|
+
] })
|
|
693
|
+
] });
|
|
694
|
+
}
|
|
695
|
+
const $e = {
|
|
696
|
+
/** Calculate mean */
|
|
697
|
+
mean(e) {
|
|
698
|
+
return e.length === 0 ? NaN : e.reduce((t, n) => t + n, 0) / e.length;
|
|
699
|
+
},
|
|
700
|
+
/** Calculate median */
|
|
701
|
+
median(e) {
|
|
702
|
+
if (e.length === 0)
|
|
703
|
+
return NaN;
|
|
704
|
+
const t = [...e].sort((r, i) => r - i), n = Math.floor(t.length / 2);
|
|
705
|
+
return t.length % 2 !== 0 ? t[n] : (t[n - 1] + t[n]) / 2;
|
|
706
|
+
},
|
|
707
|
+
/** Calculate variance */
|
|
708
|
+
variance(e, t = !1) {
|
|
709
|
+
if (e.length === 0)
|
|
710
|
+
return NaN;
|
|
711
|
+
const n = this.mean(e), r = e.map((s) => Math.pow(s - n, 2)), i = t ? e.length : e.length - 1;
|
|
712
|
+
return r.reduce((s, a) => s + a, 0) / i;
|
|
713
|
+
},
|
|
714
|
+
/** Calculate standard deviation */
|
|
715
|
+
std(e, t = !1) {
|
|
716
|
+
return Math.sqrt(this.variance(e, t));
|
|
717
|
+
},
|
|
718
|
+
/** Calculate mode */
|
|
719
|
+
mode(e) {
|
|
720
|
+
const t = /* @__PURE__ */ new Map();
|
|
721
|
+
let n = 0, r = e[0];
|
|
722
|
+
for (const i of e) {
|
|
723
|
+
const s = (t.get(i) || 0) + 1;
|
|
724
|
+
t.set(i, s), s > n && (n = s, r = i);
|
|
725
|
+
}
|
|
726
|
+
return r;
|
|
727
|
+
},
|
|
728
|
+
/** Calculate percentile */
|
|
729
|
+
percentile(e, t) {
|
|
730
|
+
if (e.length === 0)
|
|
731
|
+
return NaN;
|
|
732
|
+
const n = [...e].sort((l, c) => l - c), r = t / 100 * (n.length - 1), i = Math.floor(r), s = Math.ceil(r), a = r - i;
|
|
733
|
+
return n[i] * (1 - a) + n[s] * a;
|
|
734
|
+
},
|
|
735
|
+
/** Calculate quartiles */
|
|
736
|
+
quartiles(e) {
|
|
737
|
+
return {
|
|
738
|
+
q1: this.percentile(e, 25),
|
|
739
|
+
q2: this.percentile(e, 50),
|
|
740
|
+
q3: this.percentile(e, 75)
|
|
741
|
+
};
|
|
742
|
+
},
|
|
743
|
+
/** Calculate skewness */
|
|
744
|
+
skewness(e) {
|
|
745
|
+
const t = e.length;
|
|
746
|
+
if (t < 3)
|
|
747
|
+
return NaN;
|
|
748
|
+
const n = this.mean(e), r = this.std(e), i = e.map((s) => Math.pow((s - n) / r, 3));
|
|
749
|
+
return t / ((t - 1) * (t - 2)) * i.reduce((s, a) => s + a, 0);
|
|
750
|
+
},
|
|
751
|
+
/** Calculate kurtosis */
|
|
752
|
+
kurtosis(e) {
|
|
753
|
+
const t = e.length;
|
|
754
|
+
if (t < 4)
|
|
755
|
+
return NaN;
|
|
756
|
+
const n = this.mean(e), r = this.std(e), s = e.map((a) => Math.pow((a - n) / r, 4)).reduce((a, l) => a + l, 0);
|
|
757
|
+
return t * (t + 1) / ((t - 1) * (t - 2) * (t - 3)) * s - 3 * Math.pow(t - 1, 2) / ((t - 2) * (t - 3));
|
|
758
|
+
},
|
|
759
|
+
/** Correlation coefficient (Pearson) */
|
|
760
|
+
correlation(e, t) {
|
|
761
|
+
if (e.length !== t.length || e.length < 2)
|
|
762
|
+
return NaN;
|
|
763
|
+
const n = e.length, r = this.mean(e), i = this.mean(t);
|
|
764
|
+
let s = 0, a = 0, l = 0;
|
|
765
|
+
for (let c = 0; c < n; c++) {
|
|
766
|
+
const h = e[c] - r, p = t[c] - i;
|
|
767
|
+
s += h * p, a += h * h, l += p * p;
|
|
768
|
+
}
|
|
769
|
+
return s / Math.sqrt(a * l);
|
|
770
|
+
},
|
|
771
|
+
/** Correlation matrix */
|
|
772
|
+
correlationMatrix(e) {
|
|
773
|
+
const t = Object.keys(e), n = {};
|
|
774
|
+
for (const r of t) {
|
|
775
|
+
n[r] = {};
|
|
776
|
+
for (const i of t)
|
|
777
|
+
n[r][i] = this.correlation(e[r], e[i]);
|
|
778
|
+
}
|
|
779
|
+
return n;
|
|
780
|
+
},
|
|
781
|
+
/** Covariance */
|
|
782
|
+
covariance(e, t, n = !1) {
|
|
783
|
+
if (e.length !== t.length || e.length < 2)
|
|
784
|
+
return NaN;
|
|
785
|
+
const r = e.length, i = this.mean(e), s = this.mean(t);
|
|
786
|
+
let a = 0;
|
|
787
|
+
for (let l = 0; l < r; l++)
|
|
788
|
+
a += (e[l] - i) * (t[l] - s);
|
|
789
|
+
return a / (n ? r : r - 1);
|
|
790
|
+
},
|
|
791
|
+
/** Simple linear regression */
|
|
792
|
+
linearRegression(e, t) {
|
|
793
|
+
if (e.length !== t.length || e.length < 2)
|
|
794
|
+
throw new Error("Invalid input arrays");
|
|
795
|
+
const n = e.length, r = this.mean(e), i = this.mean(t);
|
|
796
|
+
let s = 0, a = 0;
|
|
797
|
+
for (let $ = 0; $ < n; $++)
|
|
798
|
+
s += (e[$] - r) * (t[$] - i), a += Math.pow(e[$] - r, 2);
|
|
799
|
+
const l = s / a, c = i - l * r;
|
|
800
|
+
let h = 0, p = 0;
|
|
801
|
+
for (let $ = 0; $ < n; $++) {
|
|
802
|
+
const w = l * e[$] + c;
|
|
803
|
+
h += Math.pow(t[$] - i, 2), p += Math.pow(t[$] - w, 2);
|
|
804
|
+
}
|
|
805
|
+
const m = 1 - p / h, y = `y = ${l.toFixed(4)}x + ${c.toFixed(4)}`;
|
|
806
|
+
return { slope: l, intercept: c, r2: m, equation: y };
|
|
807
|
+
},
|
|
808
|
+
/** T-test (two-sample) */
|
|
809
|
+
tTest(e, t) {
|
|
810
|
+
const n = e.length, r = t.length, i = this.mean(e), s = this.mean(t), a = this.variance(e), l = this.variance(t), c = Math.sqrt(a / n + l / r), h = (i - s) / c, p = Math.pow(a / n + l / r, 2) / (Math.pow(a / n, 2) / (n - 1) + Math.pow(l / r, 2) / (r - 1)), m = 2 * (1 - this.normalCDF(Math.abs(h)));
|
|
811
|
+
return {
|
|
812
|
+
tStatistic: h,
|
|
813
|
+
pValue: m,
|
|
814
|
+
degreesOfFreedom: p,
|
|
815
|
+
meanDiff: i - s
|
|
816
|
+
};
|
|
817
|
+
},
|
|
818
|
+
/** Normal CDF approximation */
|
|
819
|
+
normalCDF(e) {
|
|
820
|
+
const t = 0.254829592, n = -0.284496736, r = 1.421413741, i = -1.453152027, s = 1.061405429, a = 0.3275911, l = e < 0 ? -1 : 1;
|
|
821
|
+
e = Math.abs(e) / Math.sqrt(2);
|
|
822
|
+
const c = 1 / (1 + a * e), h = 1 - ((((s * c + i) * c + r) * c + n) * c + t) * c * Math.exp(-e * e);
|
|
823
|
+
return 0.5 * (1 + l * h);
|
|
824
|
+
},
|
|
825
|
+
/** Chi-square test */
|
|
826
|
+
chiSquare(e, t) {
|
|
827
|
+
if (e.length !== t.length)
|
|
828
|
+
throw new Error("Arrays must have same length");
|
|
829
|
+
let n = 0;
|
|
830
|
+
for (let s = 0; s < e.length; s++)
|
|
831
|
+
n += Math.pow(e[s] - t[s], 2) / t[s];
|
|
832
|
+
const r = e.length - 1;
|
|
833
|
+
return {
|
|
834
|
+
chiSquare: n,
|
|
835
|
+
pValue: 0.05,
|
|
836
|
+
degreesOfFreedom: r
|
|
837
|
+
};
|
|
838
|
+
},
|
|
839
|
+
/** Z-score normalization */
|
|
840
|
+
zScore(e) {
|
|
841
|
+
const t = this.mean(e), n = this.std(e);
|
|
842
|
+
return e.map((r) => (r - t) / n);
|
|
843
|
+
},
|
|
844
|
+
/** Min-max normalization */
|
|
845
|
+
minMaxNormalize(e, t = 0, n = 1) {
|
|
846
|
+
const r = Math.min(...e), s = Math.max(...e) - r;
|
|
847
|
+
return e.map((a) => t + (a - r) / s * (n - t));
|
|
848
|
+
},
|
|
849
|
+
/** Describe dataset */
|
|
850
|
+
describe(e) {
|
|
851
|
+
const t = e.filter((r) => r != null && !isNaN(r)), n = this.quartiles(t);
|
|
852
|
+
return {
|
|
853
|
+
count: t.length,
|
|
854
|
+
mean: this.mean(t),
|
|
855
|
+
median: n.q2,
|
|
856
|
+
std: this.std(t),
|
|
857
|
+
min: Math.min(...t),
|
|
858
|
+
max: Math.max(...t),
|
|
859
|
+
q1: n.q1,
|
|
860
|
+
q3: n.q3,
|
|
861
|
+
skewness: this.skewness(t),
|
|
862
|
+
kurtosis: this.kurtosis(t),
|
|
863
|
+
mode: this.mode(t),
|
|
864
|
+
variance: this.variance(t)
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
class ft {
|
|
869
|
+
constructor(t = {}) {
|
|
870
|
+
ve(this, "config");
|
|
871
|
+
ve(this, "datasets", /* @__PURE__ */ new Map());
|
|
872
|
+
ve(this, "analyses", /* @__PURE__ */ new Map());
|
|
873
|
+
this.config = {
|
|
874
|
+
maxRowsInMemory: 1e5,
|
|
875
|
+
...t
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
/** Import data from CSV */
|
|
879
|
+
async importCSV(t, n) {
|
|
880
|
+
const r = (n == null ? void 0 : n.delimiter) || ",", i = (n == null ? void 0 : n.header) !== !1, s = t.split(`
|
|
881
|
+
`).filter((y) => y.trim());
|
|
882
|
+
if (s.length === 0)
|
|
883
|
+
throw new Error("Empty CSV content");
|
|
884
|
+
const a = (y) => {
|
|
885
|
+
const $ = [];
|
|
886
|
+
let w = "", j = !1;
|
|
887
|
+
for (const J of y)
|
|
888
|
+
J === '"' ? j = !j : J === r && !j ? ($.push(w.trim()), w = "") : w += J;
|
|
889
|
+
return $.push(w.trim()), $;
|
|
890
|
+
}, l = a(s[0]), c = i ? l : l.map((y, $) => `col_${$ + 1}`), h = i ? 1 : 0, p = [];
|
|
891
|
+
for (let y = h; y < s.length; y++) {
|
|
892
|
+
const $ = a(s[y]), w = {};
|
|
893
|
+
for (let j = 0; j < c.length; j++) {
|
|
894
|
+
const J = $[j], te = parseFloat(J);
|
|
895
|
+
w[c[j]] = !isNaN(te) && J !== "" ? te : J;
|
|
896
|
+
}
|
|
897
|
+
p.push(w);
|
|
898
|
+
}
|
|
899
|
+
return this.createDataset({
|
|
900
|
+
name: (n == null ? void 0 : n.name) || "Imported CSV",
|
|
901
|
+
data: p,
|
|
902
|
+
source: { type: "csv" }
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
/** Import data from JSON */
|
|
906
|
+
async importJSON(t, n) {
|
|
907
|
+
const r = typeof t == "string" ? JSON.parse(t) : t;
|
|
908
|
+
if (!Array.isArray(r))
|
|
909
|
+
throw new Error("JSON must be an array of objects");
|
|
910
|
+
return this.createDataset({
|
|
911
|
+
name: (n == null ? void 0 : n.name) || "Imported JSON",
|
|
912
|
+
data: r,
|
|
913
|
+
source: { type: "json" }
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
/** Create dataset */
|
|
917
|
+
createDataset(t) {
|
|
918
|
+
const { name: n, data: r, description: i, source: s } = t, a = this.inferColumns(r), l = {
|
|
919
|
+
id: this.generateId(),
|
|
920
|
+
name: n,
|
|
921
|
+
description: i,
|
|
922
|
+
columns: a,
|
|
923
|
+
data: r,
|
|
924
|
+
rowCount: r.length,
|
|
925
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
926
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
927
|
+
source: s
|
|
928
|
+
};
|
|
929
|
+
return this.datasets.set(l.id, l), l;
|
|
930
|
+
}
|
|
931
|
+
inferColumns(t) {
|
|
932
|
+
if (t.length === 0)
|
|
933
|
+
return [];
|
|
934
|
+
const n = /* @__PURE__ */ new Set();
|
|
935
|
+
t.forEach((i) => Object.keys(i).forEach((s) => n.add(s)));
|
|
936
|
+
const r = [];
|
|
937
|
+
for (const i of n) {
|
|
938
|
+
const s = t.map((p) => p[i]), a = s.filter((p) => p != null), l = new Set(a);
|
|
939
|
+
let c = "mixed";
|
|
940
|
+
a.every((p) => typeof p == "number") ? c = "number" : a.every((p) => typeof p == "string") ? c = l.size < a.length * 0.5 ? "category" : "string" : a.every((p) => typeof p == "boolean") ? c = "boolean" : a.every((p) => p instanceof Date || !isNaN(Date.parse(p))) && (c = "date");
|
|
941
|
+
const h = {
|
|
942
|
+
name: i,
|
|
943
|
+
type: c,
|
|
944
|
+
nullable: s.some((p) => p == null),
|
|
945
|
+
unique: l.size,
|
|
946
|
+
missing: s.length - a.length
|
|
947
|
+
};
|
|
948
|
+
if (c === "number") {
|
|
949
|
+
const p = a.filter((m) => typeof m == "number");
|
|
950
|
+
h.stats = $e.describe(p);
|
|
951
|
+
}
|
|
952
|
+
r.push(h);
|
|
953
|
+
}
|
|
954
|
+
return r;
|
|
955
|
+
}
|
|
956
|
+
/** Run analysis */
|
|
957
|
+
runAnalysis(t, n, r = {}) {
|
|
958
|
+
const i = this.datasets.get(t);
|
|
959
|
+
if (!i)
|
|
960
|
+
throw new Error(`Dataset not found: ${t}`);
|
|
961
|
+
const s = performance.now();
|
|
962
|
+
let a;
|
|
963
|
+
switch (n) {
|
|
964
|
+
case "descriptive":
|
|
965
|
+
a = this.descriptiveAnalysis(i, r);
|
|
966
|
+
break;
|
|
967
|
+
case "correlation":
|
|
968
|
+
a = this.correlationAnalysis(i, r);
|
|
969
|
+
break;
|
|
970
|
+
case "regression":
|
|
971
|
+
a = this.regressionAnalysis(
|
|
972
|
+
i,
|
|
973
|
+
r
|
|
974
|
+
);
|
|
975
|
+
break;
|
|
976
|
+
case "ttest":
|
|
977
|
+
a = this.tTestAnalysis(i, r);
|
|
978
|
+
break;
|
|
979
|
+
case "distribution":
|
|
980
|
+
a = this.distributionAnalysis(
|
|
981
|
+
i,
|
|
982
|
+
r
|
|
983
|
+
);
|
|
984
|
+
break;
|
|
985
|
+
default:
|
|
986
|
+
throw new Error(`Unsupported analysis type: ${n}`);
|
|
987
|
+
}
|
|
988
|
+
const l = performance.now() - s, c = {
|
|
989
|
+
id: this.generateId(),
|
|
990
|
+
datasetId: t,
|
|
991
|
+
type: n,
|
|
992
|
+
parameters: r,
|
|
993
|
+
result: a,
|
|
994
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
995
|
+
executionTimeMs: l
|
|
996
|
+
};
|
|
997
|
+
return this.analyses.set(c.id, c), c;
|
|
998
|
+
}
|
|
999
|
+
descriptiveAnalysis(t, n) {
|
|
1000
|
+
const r = n.columns || t.columns.filter((s) => s.type === "number").map((s) => s.name), i = {};
|
|
1001
|
+
for (const s of r) {
|
|
1002
|
+
const a = t.data.map((l) => l[s]).filter((l) => typeof l == "number");
|
|
1003
|
+
i[s] = $e.describe(a);
|
|
1004
|
+
}
|
|
1005
|
+
return i;
|
|
1006
|
+
}
|
|
1007
|
+
correlationAnalysis(t, n) {
|
|
1008
|
+
const r = n.columns || t.columns.filter((s) => s.type === "number").map((s) => s.name), i = {};
|
|
1009
|
+
for (const s of r)
|
|
1010
|
+
i[s] = t.data.map((a) => a[s]).filter((a) => typeof a == "number");
|
|
1011
|
+
return {
|
|
1012
|
+
matrix: $e.correlationMatrix(i),
|
|
1013
|
+
columns: r
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
regressionAnalysis(t, n) {
|
|
1017
|
+
const { xColumn: r, yColumn: i } = n, s = t.data.map((l) => l[r]).filter((l) => typeof l == "number"), a = t.data.map((l) => l[i]).filter((l) => typeof l == "number");
|
|
1018
|
+
return $e.linearRegression(s, a);
|
|
1019
|
+
}
|
|
1020
|
+
tTestAnalysis(t, n) {
|
|
1021
|
+
const { column: r, groupColumn: i } = n, s = /* @__PURE__ */ new Map();
|
|
1022
|
+
for (const l of t.data) {
|
|
1023
|
+
const c = l[i], h = l[r];
|
|
1024
|
+
typeof h == "number" && (s.has(c) || s.set(c, []), s.get(c).push(h));
|
|
1025
|
+
}
|
|
1026
|
+
const a = Array.from(s.keys());
|
|
1027
|
+
if (a.length !== 2)
|
|
1028
|
+
throw new Error("T-test requires exactly 2 groups");
|
|
1029
|
+
return $e.tTest(s.get(a[0]), s.get(a[1]));
|
|
1030
|
+
}
|
|
1031
|
+
distributionAnalysis(t, n) {
|
|
1032
|
+
const { column: r, bins: i = 10 } = n, s = t.data.map((m) => m[r]).filter((m) => typeof m == "number"), a = Math.min(...s), c = (Math.max(...s) - a) / i, h = new Array(i).fill(0), p = [];
|
|
1033
|
+
for (let m = 0; m <= i; m++)
|
|
1034
|
+
p.push(a + m * c);
|
|
1035
|
+
for (const m of s) {
|
|
1036
|
+
const y = Math.min(Math.floor((m - a) / c), i - 1);
|
|
1037
|
+
h[y]++;
|
|
1038
|
+
}
|
|
1039
|
+
return {
|
|
1040
|
+
histogram: h,
|
|
1041
|
+
binEdges: p,
|
|
1042
|
+
stats: $e.describe(s)
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
/** Apply transformation */
|
|
1046
|
+
transform(t, n) {
|
|
1047
|
+
const r = this.datasets.get(t);
|
|
1048
|
+
if (!r)
|
|
1049
|
+
throw new Error(`Dataset not found: ${t}`);
|
|
1050
|
+
let i = [...r.data];
|
|
1051
|
+
switch (n.type) {
|
|
1052
|
+
case "filter":
|
|
1053
|
+
i = this.applyFilter(i, n);
|
|
1054
|
+
break;
|
|
1055
|
+
case "sort":
|
|
1056
|
+
i = this.applySort(i, n);
|
|
1057
|
+
break;
|
|
1058
|
+
case "fillna":
|
|
1059
|
+
i = this.applyFillNA(i, n);
|
|
1060
|
+
break;
|
|
1061
|
+
case "dropna":
|
|
1062
|
+
i = this.applyDropNA(i, n);
|
|
1063
|
+
break;
|
|
1064
|
+
case "normalize":
|
|
1065
|
+
i = this.applyNormalize(i, n);
|
|
1066
|
+
break;
|
|
1067
|
+
case "standardize":
|
|
1068
|
+
i = this.applyStandardize(i, n);
|
|
1069
|
+
break;
|
|
1070
|
+
default:
|
|
1071
|
+
throw new Error(`Unsupported transformation: ${n.type}`);
|
|
1072
|
+
}
|
|
1073
|
+
return this.createDataset({
|
|
1074
|
+
name: `${r.name} (transformed)`,
|
|
1075
|
+
data: i
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
applyFilter(t, n) {
|
|
1079
|
+
const { column: r, parameters: i } = n, { operator: s, value: a } = i;
|
|
1080
|
+
return t.filter((l) => {
|
|
1081
|
+
const c = l[r];
|
|
1082
|
+
switch (s) {
|
|
1083
|
+
case "==":
|
|
1084
|
+
return c === a;
|
|
1085
|
+
case "!=":
|
|
1086
|
+
return c !== a;
|
|
1087
|
+
case ">":
|
|
1088
|
+
return c > a;
|
|
1089
|
+
case ">=":
|
|
1090
|
+
return c >= a;
|
|
1091
|
+
case "<":
|
|
1092
|
+
return c < a;
|
|
1093
|
+
case "<=":
|
|
1094
|
+
return c <= a;
|
|
1095
|
+
case "contains":
|
|
1096
|
+
return String(c).includes(a);
|
|
1097
|
+
case "startswith":
|
|
1098
|
+
return String(c).startsWith(a);
|
|
1099
|
+
default:
|
|
1100
|
+
return !0;
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
applySort(t, n) {
|
|
1105
|
+
const { column: r, parameters: i } = n, s = i.ascending !== !1;
|
|
1106
|
+
return [...t].sort((a, l) => {
|
|
1107
|
+
const c = a[r], h = l[r];
|
|
1108
|
+
return c < h ? s ? -1 : 1 : c > h ? s ? 1 : -1 : 0;
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
applyFillNA(t, n) {
|
|
1112
|
+
const { column: r, parameters: i } = n, s = i.value;
|
|
1113
|
+
return t.map((a) => ({
|
|
1114
|
+
...a,
|
|
1115
|
+
[r]: a[r] ?? s
|
|
1116
|
+
}));
|
|
1117
|
+
}
|
|
1118
|
+
applyDropNA(t, n) {
|
|
1119
|
+
const r = n.columns || [n.column];
|
|
1120
|
+
return t.filter((i) => r.every((s) => i[s] != null));
|
|
1121
|
+
}
|
|
1122
|
+
applyNormalize(t, n) {
|
|
1123
|
+
const { column: r } = n, i = t.map((c) => c[r]).filter((c) => typeof c == "number"), s = Math.min(...i), l = Math.max(...i) - s;
|
|
1124
|
+
return t.map((c) => ({
|
|
1125
|
+
...c,
|
|
1126
|
+
[r]: typeof c[r] == "number" ? (c[r] - s) / l : c[r]
|
|
1127
|
+
}));
|
|
1128
|
+
}
|
|
1129
|
+
applyStandardize(t, n) {
|
|
1130
|
+
const { column: r } = n, i = t.map((l) => l[r]).filter((l) => typeof l == "number"), s = $e.mean(i), a = $e.std(i);
|
|
1131
|
+
return t.map((l) => ({
|
|
1132
|
+
...l,
|
|
1133
|
+
[r]: typeof l[r] == "number" ? (l[r] - s) / a : l[r]
|
|
1134
|
+
}));
|
|
1135
|
+
}
|
|
1136
|
+
/** Export dataset */
|
|
1137
|
+
exportCSV(t) {
|
|
1138
|
+
const n = this.datasets.get(t);
|
|
1139
|
+
if (!n)
|
|
1140
|
+
throw new Error(`Dataset not found: ${t}`);
|
|
1141
|
+
const r = n.columns.map((s) => s.name), i = n.data.map(
|
|
1142
|
+
(s) => r.map((a) => {
|
|
1143
|
+
const l = s[a];
|
|
1144
|
+
return l == null ? "" : typeof l == "string" && (l.includes(",") || l.includes('"')) ? `"${l.replace(/"/g, '""')}"` : String(l);
|
|
1145
|
+
}).join(",")
|
|
1146
|
+
);
|
|
1147
|
+
return [r.join(","), ...i].join(`
|
|
1148
|
+
`);
|
|
1149
|
+
}
|
|
1150
|
+
/** Get dataset */
|
|
1151
|
+
getDataset(t) {
|
|
1152
|
+
return this.datasets.get(t);
|
|
1153
|
+
}
|
|
1154
|
+
/** List datasets */
|
|
1155
|
+
listDatasets() {
|
|
1156
|
+
return Array.from(this.datasets.values());
|
|
1157
|
+
}
|
|
1158
|
+
generateId() {
|
|
1159
|
+
return Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
function Gt(e) {
|
|
1163
|
+
return new ft(e);
|
|
1164
|
+
}
|
|
1165
|
+
function Qt({
|
|
1166
|
+
service: e,
|
|
1167
|
+
className: t,
|
|
1168
|
+
style: n
|
|
1169
|
+
}) {
|
|
1170
|
+
const [r, i] = E([]), [s, a] = E(null), [l, c] = E("data"), h = P(() => {
|
|
1171
|
+
i(e.listDatasets());
|
|
1172
|
+
}, [e]), p = K(
|
|
1173
|
+
() => r.find((y) => y.id === s),
|
|
1174
|
+
[r, s]
|
|
1175
|
+
), m = async (y) => {
|
|
1176
|
+
var j;
|
|
1177
|
+
const $ = (j = y.target.files) == null ? void 0 : j[0];
|
|
1178
|
+
if (!$)
|
|
1179
|
+
return;
|
|
1180
|
+
const w = await $.text();
|
|
1181
|
+
$.name.endsWith(".csv") ? await e.importCSV(w, { name: $.name }) : $.name.endsWith(".json") && await e.importJSON(w, { name: $.name }), h();
|
|
1182
|
+
};
|
|
1183
|
+
return /* @__PURE__ */ u(
|
|
1184
|
+
"div",
|
|
1185
|
+
{
|
|
1186
|
+
className: t,
|
|
1187
|
+
style: {
|
|
1188
|
+
display: "flex",
|
|
1189
|
+
flexDirection: "column",
|
|
1190
|
+
height: "100%",
|
|
1191
|
+
fontFamily: "'Inter', sans-serif",
|
|
1192
|
+
...n
|
|
1193
|
+
},
|
|
1194
|
+
children: [
|
|
1195
|
+
/* @__PURE__ */ u(
|
|
1196
|
+
"div",
|
|
1197
|
+
{
|
|
1198
|
+
style: {
|
|
1199
|
+
padding: "12px 16px",
|
|
1200
|
+
borderBottom: "1px solid #e0e0e0",
|
|
1201
|
+
display: "flex",
|
|
1202
|
+
gap: "12px",
|
|
1203
|
+
alignItems: "center"
|
|
1204
|
+
},
|
|
1205
|
+
children: [
|
|
1206
|
+
/* @__PURE__ */ u(
|
|
1207
|
+
"label",
|
|
1208
|
+
{
|
|
1209
|
+
style: {
|
|
1210
|
+
padding: "8px 16px",
|
|
1211
|
+
backgroundColor: "#1976d2",
|
|
1212
|
+
color: "white",
|
|
1213
|
+
borderRadius: "4px",
|
|
1214
|
+
cursor: "pointer"
|
|
1215
|
+
},
|
|
1216
|
+
children: [
|
|
1217
|
+
"Import Data",
|
|
1218
|
+
/* @__PURE__ */ o(
|
|
1219
|
+
"input",
|
|
1220
|
+
{
|
|
1221
|
+
type: "file",
|
|
1222
|
+
accept: ".csv,.json",
|
|
1223
|
+
onChange: m,
|
|
1224
|
+
style: { display: "none" }
|
|
1225
|
+
}
|
|
1226
|
+
)
|
|
1227
|
+
]
|
|
1228
|
+
}
|
|
1229
|
+
),
|
|
1230
|
+
/* @__PURE__ */ u(
|
|
1231
|
+
"select",
|
|
1232
|
+
{
|
|
1233
|
+
value: s || "",
|
|
1234
|
+
onChange: (y) => a(y.target.value || null),
|
|
1235
|
+
style: { padding: "8px 12px", borderRadius: "4px", border: "1px solid #ddd" },
|
|
1236
|
+
children: [
|
|
1237
|
+
/* @__PURE__ */ o("option", { value: "", children: "Select dataset..." }),
|
|
1238
|
+
r.map((y) => /* @__PURE__ */ u("option", { value: y.id, children: [
|
|
1239
|
+
y.name,
|
|
1240
|
+
" (",
|
|
1241
|
+
y.rowCount,
|
|
1242
|
+
" rows)"
|
|
1243
|
+
] }, y.id))
|
|
1244
|
+
]
|
|
1245
|
+
}
|
|
1246
|
+
),
|
|
1247
|
+
p && /* @__PURE__ */ o("div", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: ["data", "stats", "analysis"].map((y) => /* @__PURE__ */ o(
|
|
1248
|
+
"button",
|
|
1249
|
+
{
|
|
1250
|
+
onClick: () => c(y),
|
|
1251
|
+
style: {
|
|
1252
|
+
padding: "8px 16px",
|
|
1253
|
+
backgroundColor: l === y ? "#1976d2" : "transparent",
|
|
1254
|
+
color: l === y ? "white" : "#333",
|
|
1255
|
+
border: "1px solid #ddd",
|
|
1256
|
+
borderRadius: "4px",
|
|
1257
|
+
cursor: "pointer",
|
|
1258
|
+
textTransform: "capitalize"
|
|
1259
|
+
},
|
|
1260
|
+
children: y
|
|
1261
|
+
},
|
|
1262
|
+
y
|
|
1263
|
+
)) })
|
|
1264
|
+
]
|
|
1265
|
+
}
|
|
1266
|
+
),
|
|
1267
|
+
/* @__PURE__ */ o("div", { style: { flex: 1, overflow: "auto", padding: "16px" }, children: p ? l === "data" ? /* @__PURE__ */ o(mt, { dataset: p }) : l === "stats" ? /* @__PURE__ */ o(yt, { dataset: p }) : /* @__PURE__ */ o(gt, { dataset: p, service: e }) : /* @__PURE__ */ u("div", { style: { textAlign: "center", color: "#666", padding: "48px" }, children: [
|
|
1268
|
+
/* @__PURE__ */ o("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "📊" }),
|
|
1269
|
+
/* @__PURE__ */ o("div", { style: { fontSize: "18px" }, children: "Import a dataset or select an existing one to begin" })
|
|
1270
|
+
] }) })
|
|
1271
|
+
]
|
|
1272
|
+
}
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
function mt({ dataset: e }) {
|
|
1276
|
+
const [t, n] = E(0), r = 50, i = Math.ceil(e.rowCount / r), s = e.data.slice(t * r, (t + 1) * r);
|
|
1277
|
+
return /* @__PURE__ */ u("div", { children: [
|
|
1278
|
+
/* @__PURE__ */ o("div", { style: { overflowX: "auto", marginBottom: "16px" }, children: /* @__PURE__ */ u("table", { style: { borderCollapse: "collapse", width: "100%", fontSize: "13px" }, children: [
|
|
1279
|
+
/* @__PURE__ */ o("thead", { children: /* @__PURE__ */ u("tr", { style: { backgroundColor: "#f5f5f5" }, children: [
|
|
1280
|
+
/* @__PURE__ */ o("th", { style: { padding: "8px 12px", border: "1px solid #ddd", textAlign: "left" }, children: "#" }),
|
|
1281
|
+
e.columns.map((a) => /* @__PURE__ */ u(
|
|
1282
|
+
"th",
|
|
1283
|
+
{
|
|
1284
|
+
style: { padding: "8px 12px", border: "1px solid #ddd", textAlign: "left" },
|
|
1285
|
+
children: [
|
|
1286
|
+
a.name,
|
|
1287
|
+
/* @__PURE__ */ o("div", { style: { fontSize: "10px", color: "#666", fontWeight: "normal" }, children: a.type })
|
|
1288
|
+
]
|
|
1289
|
+
},
|
|
1290
|
+
a.name
|
|
1291
|
+
))
|
|
1292
|
+
] }) }),
|
|
1293
|
+
/* @__PURE__ */ o("tbody", { children: s.map((a, l) => /* @__PURE__ */ u("tr", { children: [
|
|
1294
|
+
/* @__PURE__ */ o("td", { style: { padding: "8px 12px", border: "1px solid #ddd", color: "#666" }, children: t * r + l + 1 }),
|
|
1295
|
+
e.columns.map((c) => /* @__PURE__ */ o("td", { style: { padding: "8px 12px", border: "1px solid #ddd" }, children: a[c.name] != null ? String(a[c.name]) : /* @__PURE__ */ o("span", { style: { color: "#ccc" }, children: "null" }) }, c.name))
|
|
1296
|
+
] }, l)) })
|
|
1297
|
+
] }) }),
|
|
1298
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px", alignItems: "center", justifyContent: "center" }, children: [
|
|
1299
|
+
/* @__PURE__ */ o("button", { onClick: () => n(0), disabled: t === 0, children: "First" }),
|
|
1300
|
+
/* @__PURE__ */ o("button", { onClick: () => n(t - 1), disabled: t === 0, children: "Prev" }),
|
|
1301
|
+
/* @__PURE__ */ u("span", { children: [
|
|
1302
|
+
"Page ",
|
|
1303
|
+
t + 1,
|
|
1304
|
+
" of ",
|
|
1305
|
+
i
|
|
1306
|
+
] }),
|
|
1307
|
+
/* @__PURE__ */ o("button", { onClick: () => n(t + 1), disabled: t >= i - 1, children: "Next" }),
|
|
1308
|
+
/* @__PURE__ */ o("button", { onClick: () => n(i - 1), disabled: t >= i - 1, children: "Last" })
|
|
1309
|
+
] })
|
|
1310
|
+
] });
|
|
1311
|
+
}
|
|
1312
|
+
function yt({ dataset: e }) {
|
|
1313
|
+
const t = e.columns.filter((n) => n.type === "number");
|
|
1314
|
+
return /* @__PURE__ */ o(
|
|
1315
|
+
"div",
|
|
1316
|
+
{
|
|
1317
|
+
style: {
|
|
1318
|
+
display: "grid",
|
|
1319
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))",
|
|
1320
|
+
gap: "16px"
|
|
1321
|
+
},
|
|
1322
|
+
children: t.map((n) => /* @__PURE__ */ u(
|
|
1323
|
+
"div",
|
|
1324
|
+
{
|
|
1325
|
+
style: { padding: "16px", backgroundColor: "#f9f9f9", borderRadius: "8px" },
|
|
1326
|
+
children: [
|
|
1327
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px 0" }, children: n.name }),
|
|
1328
|
+
n.stats && /* @__PURE__ */ o("table", { style: { width: "100%", fontSize: "13px" }, children: /* @__PURE__ */ o("tbody", { children: Object.entries(n.stats).map(([r, i]) => /* @__PURE__ */ u("tr", { children: [
|
|
1329
|
+
/* @__PURE__ */ o("td", { style: { padding: "4px 0", color: "#666" }, children: r }),
|
|
1330
|
+
/* @__PURE__ */ o("td", { style: { padding: "4px 0", textAlign: "right", fontFamily: "monospace" }, children: typeof i == "number" ? i.toFixed(4) : String(i) })
|
|
1331
|
+
] }, r)) }) })
|
|
1332
|
+
]
|
|
1333
|
+
},
|
|
1334
|
+
n.name
|
|
1335
|
+
))
|
|
1336
|
+
}
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
function gt({
|
|
1340
|
+
dataset: e,
|
|
1341
|
+
service: t
|
|
1342
|
+
}) {
|
|
1343
|
+
const [n, r] = E("descriptive"), [i, s] = E(null);
|
|
1344
|
+
return /* @__PURE__ */ u("div", { children: [
|
|
1345
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "12px", marginBottom: "24px" }, children: [
|
|
1346
|
+
/* @__PURE__ */ u(
|
|
1347
|
+
"select",
|
|
1348
|
+
{
|
|
1349
|
+
value: n,
|
|
1350
|
+
onChange: (l) => r(l.target.value),
|
|
1351
|
+
style: { padding: "8px 12px", borderRadius: "4px", border: "1px solid #ddd" },
|
|
1352
|
+
children: [
|
|
1353
|
+
/* @__PURE__ */ o("option", { value: "descriptive", children: "Descriptive Statistics" }),
|
|
1354
|
+
/* @__PURE__ */ o("option", { value: "correlation", children: "Correlation Matrix" }),
|
|
1355
|
+
/* @__PURE__ */ o("option", { value: "distribution", children: "Distribution Analysis" })
|
|
1356
|
+
]
|
|
1357
|
+
}
|
|
1358
|
+
),
|
|
1359
|
+
/* @__PURE__ */ o(
|
|
1360
|
+
"button",
|
|
1361
|
+
{
|
|
1362
|
+
onClick: () => {
|
|
1363
|
+
const l = t.runAnalysis(e.id, n, {});
|
|
1364
|
+
s(l);
|
|
1365
|
+
},
|
|
1366
|
+
style: {
|
|
1367
|
+
padding: "8px 16px",
|
|
1368
|
+
backgroundColor: "#1976d2",
|
|
1369
|
+
color: "white",
|
|
1370
|
+
border: "none",
|
|
1371
|
+
borderRadius: "4px",
|
|
1372
|
+
cursor: "pointer"
|
|
1373
|
+
},
|
|
1374
|
+
children: "Run Analysis"
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
] }),
|
|
1378
|
+
i && /* @__PURE__ */ u("div", { style: { padding: "16px", backgroundColor: "#f9f9f9", borderRadius: "8px" }, children: [
|
|
1379
|
+
/* @__PURE__ */ u("h3", { style: { margin: "0 0 12px 0" }, children: [
|
|
1380
|
+
"Results (",
|
|
1381
|
+
i.executionTimeMs.toFixed(2),
|
|
1382
|
+
"ms)"
|
|
1383
|
+
] }),
|
|
1384
|
+
/* @__PURE__ */ o("pre", { style: { margin: 0, overflow: "auto", fontSize: "12px" }, children: JSON.stringify(i.result, null, 2) })
|
|
1385
|
+
] })
|
|
1386
|
+
] });
|
|
1387
|
+
}
|
|
1388
|
+
const Te = {
|
|
1389
|
+
apa: (e) => {
|
|
1390
|
+
const t = xt(e.authors), n = e.year ? ` (${e.year}).` : ".", r = e.title;
|
|
1391
|
+
let i = "";
|
|
1392
|
+
e.type === "article" && e.journal ? (i = ` *${e.journal}*`, e.volume && (i += `, *${e.volume}*`), e.issue && (i += `(${e.issue})`), e.pages && (i += `, ${e.pages}`), i += ".") : e.type === "book" && (i = e.publisher ? ` ${e.publisher}.` : "");
|
|
1393
|
+
const s = e.doi ? ` https://doi.org/${e.doi}` : "";
|
|
1394
|
+
return `${t}${n} ${r}.${i}${s}`;
|
|
1395
|
+
},
|
|
1396
|
+
mla: (e) => {
|
|
1397
|
+
const t = Ge(e.authors), n = `"${e.title}."`;
|
|
1398
|
+
let r = "";
|
|
1399
|
+
return e.type === "article" && e.journal && (r = ` *${e.journal}*`, e.volume && (r += `, vol. ${e.volume}`), e.issue && (r += `, no. ${e.issue}`), e.year && (r += `, ${e.year}`), e.pages && (r += `, pp. ${e.pages}`), r += "."), `${t} ${n}${r}`;
|
|
1400
|
+
},
|
|
1401
|
+
chicago: (e) => {
|
|
1402
|
+
const t = bt(e.authors), n = `"${e.title}."`;
|
|
1403
|
+
let r = "";
|
|
1404
|
+
return e.type === "article" && e.journal && (r = ` *${e.journal}*`, e.volume && (r += ` ${e.volume}`), e.issue && (r += `, no. ${e.issue}`), e.year && (r += ` (${e.year})`), e.pages && (r += `: ${e.pages}`), r += "."), `${t} ${n}${r}`;
|
|
1405
|
+
},
|
|
1406
|
+
harvard: (e) => {
|
|
1407
|
+
const t = vt(e.authors), n = e.year ? ` (${e.year})` : "", r = `'${e.title}'`;
|
|
1408
|
+
let i = "";
|
|
1409
|
+
return e.type === "article" && e.journal && (i = `, *${e.journal}*`, e.volume && (i += `, ${e.volume}`), e.issue && (i += `(${e.issue})`), e.pages && (i += `, pp. ${e.pages}`), i += "."), `${t}${n} ${r}${i}`;
|
|
1410
|
+
},
|
|
1411
|
+
ieee: (e) => {
|
|
1412
|
+
const t = $t(e.authors), n = `"${e.title},"`;
|
|
1413
|
+
let r = "";
|
|
1414
|
+
return e.type === "article" && e.journal && (r = ` *${e.journal}*`, e.volume && (r += `, vol. ${e.volume}`), e.issue && (r += `, no. ${e.issue}`), e.pages && (r += `, pp. ${e.pages}`), e.year && (r += `, ${e.year}`), r += "."), `${t} ${n}${r}`;
|
|
1415
|
+
},
|
|
1416
|
+
vancouver: (e) => {
|
|
1417
|
+
const t = Mt(e.authors), n = e.title;
|
|
1418
|
+
let r = "";
|
|
1419
|
+
return e.type === "article" && e.journal && (r = ` ${e.journal}`, e.year && (r += `. ${e.year}`), e.volume && (r += `;${e.volume}`), e.issue && (r += `(${e.issue})`), e.pages && (r += `:${e.pages}`), r += "."), `${t}. ${n}.${r}`;
|
|
1420
|
+
},
|
|
1421
|
+
nature: (e) => {
|
|
1422
|
+
const t = Qe(e.authors), n = e.title;
|
|
1423
|
+
let r = "";
|
|
1424
|
+
return e.type === "article" && e.journal && (r = ` *${e.journal}*`, e.volume && (r += ` **${e.volume}**`), e.pages && (r += `, ${e.pages}`), e.year && (r += ` (${e.year})`), r += "."), `${t} ${n}.${r}`;
|
|
1425
|
+
},
|
|
1426
|
+
science: (e) => {
|
|
1427
|
+
const t = wt(e.authors), n = e.title;
|
|
1428
|
+
let r = "";
|
|
1429
|
+
return e.type === "article" && e.journal && (r = ` *${e.journal}*`, e.volume && (r += ` **${e.volume}**`), e.pages && (r += `, ${e.pages}`), e.year && (r += ` (${e.year})`), r += "."), `${t}, ${n}.${r}`;
|
|
1430
|
+
},
|
|
1431
|
+
bibtex: (e) => {
|
|
1432
|
+
const t = Ct(e), n = e.type === "article" ? "article" : e.type === "book" ? "book" : "misc";
|
|
1433
|
+
let i = ` author = {${e.authors.map((s) => `${s.family}, ${s.given}`).join(" and ")}},
|
|
1434
|
+
`;
|
|
1435
|
+
return i += ` title = {${e.title}},
|
|
1436
|
+
`, e.year && (i += ` year = {${e.year}},
|
|
1437
|
+
`), e.journal && (i += ` journal = {${e.journal}},
|
|
1438
|
+
`), e.volume && (i += ` volume = {${e.volume}},
|
|
1439
|
+
`), e.issue && (i += ` number = {${e.issue}},
|
|
1440
|
+
`), e.pages && (i += ` pages = {${e.pages}},
|
|
1441
|
+
`), e.publisher && (i += ` publisher = {${e.publisher}},
|
|
1442
|
+
`), e.doi && (i += ` doi = {${e.doi}},
|
|
1443
|
+
`), e.isbn && (i += ` isbn = {${e.isbn}},
|
|
1444
|
+
`), `@${n}{${t},
|
|
1445
|
+
${i}}`;
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
function xt(e) {
|
|
1449
|
+
if (e.length === 0)
|
|
1450
|
+
return "";
|
|
1451
|
+
if (e.length === 1)
|
|
1452
|
+
return `${e[0].family}, ${e[0].given.charAt(0)}.`;
|
|
1453
|
+
if (e.length === 2)
|
|
1454
|
+
return `${e[0].family}, ${e[0].given.charAt(0)}., & ${e[1].family}, ${e[1].given.charAt(0)}.`;
|
|
1455
|
+
if (e.length <= 7) {
|
|
1456
|
+
const r = e.slice(0, -1).map((s) => `${s.family}, ${s.given.charAt(0)}.`).join(", "), i = e[e.length - 1];
|
|
1457
|
+
return `${r}, & ${i.family}, ${i.given.charAt(0)}.`;
|
|
1458
|
+
}
|
|
1459
|
+
const t = e.slice(0, 6).map((r) => `${r.family}, ${r.given.charAt(0)}.`).join(", "), n = e[e.length - 1];
|
|
1460
|
+
return `${t}, ... ${n.family}, ${n.given.charAt(0)}.`;
|
|
1461
|
+
}
|
|
1462
|
+
function Ge(e) {
|
|
1463
|
+
return e.length === 0 ? "" : e.length === 1 ? `${e[0].family}, ${e[0].given}.` : e.length === 2 ? `${e[0].family}, ${e[0].given}, and ${e[1].given} ${e[1].family}.` : `${e[0].family}, ${e[0].given}, et al.`;
|
|
1464
|
+
}
|
|
1465
|
+
function bt(e) {
|
|
1466
|
+
return Ge(e);
|
|
1467
|
+
}
|
|
1468
|
+
function vt(e) {
|
|
1469
|
+
return e.length === 0 ? "" : e.length === 1 ? `${e[0].family}, ${e[0].given.charAt(0)}.` : e.length === 2 ? `${e[0].family}, ${e[0].given.charAt(0)}. and ${e[1].family}, ${e[1].given.charAt(0)}.` : `${e[0].family}, ${e[0].given.charAt(0)}. et al.`;
|
|
1470
|
+
}
|
|
1471
|
+
function $t(e) {
|
|
1472
|
+
return e.length === 0 ? "" : e.map((t) => `${t.given.charAt(0)}. ${t.family}`).join(", ");
|
|
1473
|
+
}
|
|
1474
|
+
function Mt(e) {
|
|
1475
|
+
if (e.length === 0)
|
|
1476
|
+
return "";
|
|
1477
|
+
const t = e.slice(0, 6).map((n) => `${n.family} ${n.given.charAt(0)}`);
|
|
1478
|
+
return e.length > 6 ? t.join(", ") + ", et al" : t.join(", ");
|
|
1479
|
+
}
|
|
1480
|
+
function Qe(e) {
|
|
1481
|
+
if (e.length === 0)
|
|
1482
|
+
return "";
|
|
1483
|
+
if (e.length <= 5) {
|
|
1484
|
+
const t = e.map((r) => `${r.family}, ${r.given.charAt(0)}.`), n = t.pop();
|
|
1485
|
+
return t.length > 0 ? `${t.join(", ")} & ${n}` : n;
|
|
1486
|
+
}
|
|
1487
|
+
return `${e[0].family}, ${e[0].given.charAt(0)}. et al.`;
|
|
1488
|
+
}
|
|
1489
|
+
function wt(e) {
|
|
1490
|
+
return Qe(e);
|
|
1491
|
+
}
|
|
1492
|
+
function Ct(e) {
|
|
1493
|
+
var i;
|
|
1494
|
+
const t = ((i = e.authors[0]) == null ? void 0 : i.family.toLowerCase()) || "unknown", n = e.year || "0000", r = e.title.split(" ")[0].toLowerCase().replace(/[^a-z]/g, "");
|
|
1495
|
+
return `${t}${n}${r}`;
|
|
1496
|
+
}
|
|
1497
|
+
class St {
|
|
1498
|
+
constructor(t = {}) {
|
|
1499
|
+
ve(this, "config");
|
|
1500
|
+
ve(this, "citations", /* @__PURE__ */ new Map());
|
|
1501
|
+
ve(this, "collections", /* @__PURE__ */ new Map());
|
|
1502
|
+
this.config = t, this.collections.set("all", {
|
|
1503
|
+
id: "all",
|
|
1504
|
+
name: "All References",
|
|
1505
|
+
citationCount: 0,
|
|
1506
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
/** Add citation */
|
|
1510
|
+
addCitation(t) {
|
|
1511
|
+
const n = {
|
|
1512
|
+
id: this.generateId(),
|
|
1513
|
+
type: t.type || "misc",
|
|
1514
|
+
title: t.title || "Untitled",
|
|
1515
|
+
authors: t.authors || [],
|
|
1516
|
+
year: t.year,
|
|
1517
|
+
month: t.month,
|
|
1518
|
+
day: t.day,
|
|
1519
|
+
journal: t.journal,
|
|
1520
|
+
volume: t.volume,
|
|
1521
|
+
issue: t.issue,
|
|
1522
|
+
pages: t.pages,
|
|
1523
|
+
publisher: t.publisher,
|
|
1524
|
+
edition: t.edition,
|
|
1525
|
+
doi: t.doi,
|
|
1526
|
+
isbn: t.isbn,
|
|
1527
|
+
issn: t.issn,
|
|
1528
|
+
pmid: t.pmid,
|
|
1529
|
+
arxiv: t.arxiv,
|
|
1530
|
+
url: t.url,
|
|
1531
|
+
abstract: t.abstract,
|
|
1532
|
+
keywords: t.keywords,
|
|
1533
|
+
language: t.language,
|
|
1534
|
+
accessed: t.accessed,
|
|
1535
|
+
booktitle: t.booktitle,
|
|
1536
|
+
conference: t.conference,
|
|
1537
|
+
location: t.location,
|
|
1538
|
+
school: t.school,
|
|
1539
|
+
degree: t.degree,
|
|
1540
|
+
notes: t.notes,
|
|
1541
|
+
tags: t.tags || [],
|
|
1542
|
+
collections: t.collections || ["all"],
|
|
1543
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1544
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1545
|
+
sourceDatabase: t.sourceDatabase
|
|
1546
|
+
};
|
|
1547
|
+
return this.citations.set(n.id, n), this.updateCollectionCounts(), n;
|
|
1548
|
+
}
|
|
1549
|
+
/** Update citation */
|
|
1550
|
+
updateCitation(t, n) {
|
|
1551
|
+
const r = this.citations.get(t);
|
|
1552
|
+
if (!r)
|
|
1553
|
+
throw new Error(`Citation not found: ${t}`);
|
|
1554
|
+
const i = {
|
|
1555
|
+
...r,
|
|
1556
|
+
...n,
|
|
1557
|
+
id: r.id,
|
|
1558
|
+
createdAt: r.createdAt,
|
|
1559
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1560
|
+
};
|
|
1561
|
+
return this.citations.set(t, i), this.updateCollectionCounts(), i;
|
|
1562
|
+
}
|
|
1563
|
+
/** Delete citation */
|
|
1564
|
+
deleteCitation(t) {
|
|
1565
|
+
this.citations.delete(t), this.updateCollectionCounts();
|
|
1566
|
+
}
|
|
1567
|
+
/** Get citation */
|
|
1568
|
+
getCitation(t) {
|
|
1569
|
+
return this.citations.get(t);
|
|
1570
|
+
}
|
|
1571
|
+
/** Search citations */
|
|
1572
|
+
searchCitations(t, n) {
|
|
1573
|
+
const r = t.toLowerCase();
|
|
1574
|
+
return Array.from(this.citations.values()).filter((i) => {
|
|
1575
|
+
var s, a, l, c, h;
|
|
1576
|
+
return n != null && n.collection && !((s = i.collections) != null && s.includes(n.collection)) || n != null && n.type && i.type !== n.type || n != null && n.year && i.year !== n.year || (a = n == null ? void 0 : n.tags) != null && a.length && !n.tags.some((p) => {
|
|
1577
|
+
var m;
|
|
1578
|
+
return (m = i.tags) == null ? void 0 : m.includes(p);
|
|
1579
|
+
}) ? !1 : !!(i.title.toLowerCase().includes(r) || i.authors.some(
|
|
1580
|
+
(p) => p.family.toLowerCase().includes(r) || p.given.toLowerCase().includes(r)
|
|
1581
|
+
) || (l = i.journal) != null && l.toLowerCase().includes(r) || (c = i.abstract) != null && c.toLowerCase().includes(r) || (h = i.doi) != null && h.toLowerCase().includes(r));
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
/** List all citations */
|
|
1585
|
+
listCitations(t) {
|
|
1586
|
+
const n = Array.from(this.citations.values());
|
|
1587
|
+
return t && t !== "all" ? n.filter((r) => {
|
|
1588
|
+
var i;
|
|
1589
|
+
return (i = r.collections) == null ? void 0 : i.includes(t);
|
|
1590
|
+
}) : n;
|
|
1591
|
+
}
|
|
1592
|
+
/** Create collection */
|
|
1593
|
+
createCollection(t) {
|
|
1594
|
+
const n = {
|
|
1595
|
+
id: this.generateId(),
|
|
1596
|
+
name: t.name || "Untitled Collection",
|
|
1597
|
+
description: t.description,
|
|
1598
|
+
parentId: t.parentId,
|
|
1599
|
+
color: t.color,
|
|
1600
|
+
citationCount: 0,
|
|
1601
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1602
|
+
};
|
|
1603
|
+
return this.collections.set(n.id, n), n;
|
|
1604
|
+
}
|
|
1605
|
+
/** List collections */
|
|
1606
|
+
listCollections() {
|
|
1607
|
+
return Array.from(this.collections.values());
|
|
1608
|
+
}
|
|
1609
|
+
/** Format citation */
|
|
1610
|
+
formatCitation(t, n) {
|
|
1611
|
+
const r = this.citations.get(t);
|
|
1612
|
+
if (!r)
|
|
1613
|
+
throw new Error(`Citation not found: ${t}`);
|
|
1614
|
+
return Te[n](r);
|
|
1615
|
+
}
|
|
1616
|
+
/** Format multiple citations as bibliography */
|
|
1617
|
+
formatBibliography(t, n) {
|
|
1618
|
+
return t.map((i, s) => {
|
|
1619
|
+
const a = this.citations.get(i);
|
|
1620
|
+
if (!a)
|
|
1621
|
+
return null;
|
|
1622
|
+
const l = Te[n](a);
|
|
1623
|
+
return n === "bibtex" ? l : ["ieee", "vancouver"].includes(n) ? `[${s + 1}] ${l}` : l;
|
|
1624
|
+
}).filter(Boolean).join(`
|
|
1625
|
+
|
|
1626
|
+
`);
|
|
1627
|
+
}
|
|
1628
|
+
/** Import from BibTeX */
|
|
1629
|
+
importBibtex(t) {
|
|
1630
|
+
const n = [], r = /@(\w+)\{([^,]+),([^@]+)\}/g;
|
|
1631
|
+
let i;
|
|
1632
|
+
for (; (i = r.exec(t)) !== null; ) {
|
|
1633
|
+
const s = i[1].toLowerCase(), a = this.parseBibtexFields(i[3]), l = this.addCitation({
|
|
1634
|
+
type: s === "article" ? "article" : s === "book" ? "book" : "misc",
|
|
1635
|
+
title: a.title || "",
|
|
1636
|
+
authors: this.parseBibtexAuthors(a.author || ""),
|
|
1637
|
+
year: a.year ? parseInt(a.year, 10) : void 0,
|
|
1638
|
+
journal: a.journal,
|
|
1639
|
+
volume: a.volume,
|
|
1640
|
+
issue: a.number,
|
|
1641
|
+
pages: a.pages,
|
|
1642
|
+
publisher: a.publisher,
|
|
1643
|
+
doi: a.doi,
|
|
1644
|
+
isbn: a.isbn,
|
|
1645
|
+
url: a.url,
|
|
1646
|
+
abstract: a.abstract
|
|
1647
|
+
});
|
|
1648
|
+
n.push(l);
|
|
1649
|
+
}
|
|
1650
|
+
return n;
|
|
1651
|
+
}
|
|
1652
|
+
parseBibtexFields(t) {
|
|
1653
|
+
const n = {}, r = /(\w+)\s*=\s*\{([^}]*)\}/g;
|
|
1654
|
+
let i;
|
|
1655
|
+
for (; (i = r.exec(t)) !== null; )
|
|
1656
|
+
n[i[1].toLowerCase()] = i[2].trim();
|
|
1657
|
+
return n;
|
|
1658
|
+
}
|
|
1659
|
+
parseBibtexAuthors(t) {
|
|
1660
|
+
return t.split(" and ").map((n) => {
|
|
1661
|
+
const r = n.trim().split(",");
|
|
1662
|
+
if (r.length >= 2)
|
|
1663
|
+
return { family: r[0].trim(), given: r[1].trim() };
|
|
1664
|
+
const i = n.trim().split(" ");
|
|
1665
|
+
return {
|
|
1666
|
+
given: i.slice(0, -1).join(" "),
|
|
1667
|
+
family: i[i.length - 1]
|
|
1668
|
+
};
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
/** Export as BibTeX */
|
|
1672
|
+
exportBibtex(t) {
|
|
1673
|
+
return (t ? t.map((r) => this.citations.get(r)).filter(Boolean) : Array.from(this.citations.values())).map((r) => Te.bibtex(r)).join(`
|
|
1674
|
+
|
|
1675
|
+
`);
|
|
1676
|
+
}
|
|
1677
|
+
/** Search external databases */
|
|
1678
|
+
async searchDatabase(t, n, r = 10) {
|
|
1679
|
+
var i, s;
|
|
1680
|
+
try {
|
|
1681
|
+
if (t === "crossref")
|
|
1682
|
+
return await this.searchCrossref(n, r);
|
|
1683
|
+
if (t === "pubmed")
|
|
1684
|
+
return await this.searchPubMed(n, r);
|
|
1685
|
+
throw new Error(`Unknown database: ${t}`);
|
|
1686
|
+
} catch (a) {
|
|
1687
|
+
return (s = (i = this.config).onError) == null || s.call(i, a), { source: t, total: 0, results: [] };
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
async searchCrossref(t, n) {
|
|
1691
|
+
const r = new URLSearchParams({
|
|
1692
|
+
query: t,
|
|
1693
|
+
rows: String(n)
|
|
1694
|
+
});
|
|
1695
|
+
this.config.crossrefEmail && r.set("mailto", this.config.crossrefEmail);
|
|
1696
|
+
const i = await fetch(`https://api.crossref.org/works?${r}`);
|
|
1697
|
+
if (!i.ok)
|
|
1698
|
+
throw new Error(`Crossref API error: ${i.status}`);
|
|
1699
|
+
const s = await i.json(), a = s.message.items.map((l) => {
|
|
1700
|
+
var c, h, p, m, y, $;
|
|
1701
|
+
return {
|
|
1702
|
+
type: "article",
|
|
1703
|
+
title: ((c = l.title) == null ? void 0 : c[0]) || "",
|
|
1704
|
+
authors: (l.author || []).map((w) => ({
|
|
1705
|
+
given: w.given || "",
|
|
1706
|
+
family: w.family || "",
|
|
1707
|
+
orcid: w.ORCID
|
|
1708
|
+
})),
|
|
1709
|
+
year: (m = (p = (h = l.published) == null ? void 0 : h["date-parts"]) == null ? void 0 : p[0]) == null ? void 0 : m[0],
|
|
1710
|
+
journal: (y = l["container-title"]) == null ? void 0 : y[0],
|
|
1711
|
+
volume: l.volume,
|
|
1712
|
+
issue: l.issue,
|
|
1713
|
+
pages: l.page,
|
|
1714
|
+
doi: l.DOI,
|
|
1715
|
+
issn: ($ = l.ISSN) == null ? void 0 : $[0],
|
|
1716
|
+
publisher: l.publisher,
|
|
1717
|
+
abstract: l.abstract,
|
|
1718
|
+
sourceDatabase: "crossref"
|
|
1719
|
+
};
|
|
1720
|
+
});
|
|
1721
|
+
return {
|
|
1722
|
+
source: "crossref",
|
|
1723
|
+
total: s.message["total-results"],
|
|
1724
|
+
results: a
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
async searchPubMed(t, n) {
|
|
1728
|
+
const r = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=${encodeURIComponent(t)}&retmax=${n}&retmode=json`, i = await fetch(r);
|
|
1729
|
+
if (!i.ok)
|
|
1730
|
+
throw new Error(`PubMed API error: ${i.status}`);
|
|
1731
|
+
const s = await i.json(), a = s.esearchresult.idlist;
|
|
1732
|
+
if (a.length === 0)
|
|
1733
|
+
return { source: "pubmed", total: 0, results: [] };
|
|
1734
|
+
const l = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id=${a.join(",")}&retmode=json`, c = await fetch(l);
|
|
1735
|
+
if (!c.ok)
|
|
1736
|
+
throw new Error(`PubMed API error: ${c.status}`);
|
|
1737
|
+
const h = await c.json(), p = a.map((m) => {
|
|
1738
|
+
var $;
|
|
1739
|
+
const y = h.result[m];
|
|
1740
|
+
return {
|
|
1741
|
+
type: "article",
|
|
1742
|
+
title: y.title || "",
|
|
1743
|
+
authors: (y.authors || []).map((w) => {
|
|
1744
|
+
const j = w.name.split(" ");
|
|
1745
|
+
return {
|
|
1746
|
+
family: j.pop() || "",
|
|
1747
|
+
given: j.join(" ")
|
|
1748
|
+
};
|
|
1749
|
+
}),
|
|
1750
|
+
year: y.pubdate ? parseInt(y.pubdate.split(" ")[0], 10) : void 0,
|
|
1751
|
+
journal: y.source,
|
|
1752
|
+
volume: y.volume,
|
|
1753
|
+
issue: y.issue,
|
|
1754
|
+
pages: y.pages,
|
|
1755
|
+
pmid: m,
|
|
1756
|
+
doi: ($ = y.elocationid) == null ? void 0 : $.replace("doi: ", ""),
|
|
1757
|
+
sourceDatabase: "pubmed"
|
|
1758
|
+
};
|
|
1759
|
+
});
|
|
1760
|
+
return {
|
|
1761
|
+
source: "pubmed",
|
|
1762
|
+
total: parseInt(s.esearchresult.count, 10),
|
|
1763
|
+
results: p
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
/** Fetch citation by DOI */
|
|
1767
|
+
async fetchByDOI(t) {
|
|
1768
|
+
var n, r, i, s, a;
|
|
1769
|
+
try {
|
|
1770
|
+
const l = await fetch(`https://api.crossref.org/works/${encodeURIComponent(t)}`);
|
|
1771
|
+
if (!l.ok)
|
|
1772
|
+
return null;
|
|
1773
|
+
const h = (await l.json()).message;
|
|
1774
|
+
return this.addCitation({
|
|
1775
|
+
type: "article",
|
|
1776
|
+
title: ((n = h.title) == null ? void 0 : n[0]) || "",
|
|
1777
|
+
authors: (h.author || []).map((p) => ({
|
|
1778
|
+
given: p.given || "",
|
|
1779
|
+
family: p.family || "",
|
|
1780
|
+
orcid: p.ORCID
|
|
1781
|
+
})),
|
|
1782
|
+
year: (s = (i = (r = h.published) == null ? void 0 : r["date-parts"]) == null ? void 0 : i[0]) == null ? void 0 : s[0],
|
|
1783
|
+
journal: (a = h["container-title"]) == null ? void 0 : a[0],
|
|
1784
|
+
volume: h.volume,
|
|
1785
|
+
issue: h.issue,
|
|
1786
|
+
pages: h.page,
|
|
1787
|
+
doi: h.DOI,
|
|
1788
|
+
publisher: h.publisher,
|
|
1789
|
+
abstract: h.abstract,
|
|
1790
|
+
sourceDatabase: "crossref"
|
|
1791
|
+
});
|
|
1792
|
+
} catch {
|
|
1793
|
+
return null;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
updateCollectionCounts() {
|
|
1797
|
+
for (const t of this.collections.values())
|
|
1798
|
+
t.id === "all" ? t.citationCount = this.citations.size : t.citationCount = Array.from(this.citations.values()).filter(
|
|
1799
|
+
(n) => {
|
|
1800
|
+
var r;
|
|
1801
|
+
return (r = n.collections) == null ? void 0 : r.includes(t.id);
|
|
1802
|
+
}
|
|
1803
|
+
).length;
|
|
1804
|
+
}
|
|
1805
|
+
generateId() {
|
|
1806
|
+
return Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
function Ht(e) {
|
|
1810
|
+
return new St(e);
|
|
1811
|
+
}
|
|
1812
|
+
const He = Ue(null);
|
|
1813
|
+
function et() {
|
|
1814
|
+
const e = Ze(He);
|
|
1815
|
+
if (!e)
|
|
1816
|
+
throw new Error("useCitation must be used within CitationProvider");
|
|
1817
|
+
return e;
|
|
1818
|
+
}
|
|
1819
|
+
const he = {
|
|
1820
|
+
container: {
|
|
1821
|
+
display: "flex",
|
|
1822
|
+
height: "100%",
|
|
1823
|
+
fontFamily: "'Inter', sans-serif",
|
|
1824
|
+
fontSize: "14px"
|
|
1825
|
+
},
|
|
1826
|
+
sidebar: {
|
|
1827
|
+
width: "240px",
|
|
1828
|
+
backgroundColor: "#f5f5f5",
|
|
1829
|
+
borderRight: "1px solid #e0e0e0",
|
|
1830
|
+
display: "flex",
|
|
1831
|
+
flexDirection: "column"
|
|
1832
|
+
},
|
|
1833
|
+
main: {
|
|
1834
|
+
flex: 1,
|
|
1835
|
+
display: "flex",
|
|
1836
|
+
flexDirection: "column",
|
|
1837
|
+
overflow: "hidden"
|
|
1838
|
+
},
|
|
1839
|
+
toolbar: {
|
|
1840
|
+
padding: "12px 16px",
|
|
1841
|
+
borderBottom: "1px solid #e0e0e0",
|
|
1842
|
+
display: "flex",
|
|
1843
|
+
gap: "12px",
|
|
1844
|
+
alignItems: "center"
|
|
1845
|
+
},
|
|
1846
|
+
list: {
|
|
1847
|
+
flex: 1,
|
|
1848
|
+
overflow: "auto"
|
|
1849
|
+
},
|
|
1850
|
+
listItem: {
|
|
1851
|
+
padding: "12px 16px",
|
|
1852
|
+
borderBottom: "1px solid #eee",
|
|
1853
|
+
cursor: "pointer"
|
|
1854
|
+
},
|
|
1855
|
+
detail: {
|
|
1856
|
+
width: "400px",
|
|
1857
|
+
borderLeft: "1px solid #e0e0e0",
|
|
1858
|
+
overflow: "auto",
|
|
1859
|
+
padding: "16px"
|
|
1860
|
+
},
|
|
1861
|
+
input: {
|
|
1862
|
+
padding: "8px 12px",
|
|
1863
|
+
border: "1px solid #ddd",
|
|
1864
|
+
borderRadius: "4px",
|
|
1865
|
+
fontSize: "14px"
|
|
1866
|
+
},
|
|
1867
|
+
button: {
|
|
1868
|
+
padding: "8px 16px",
|
|
1869
|
+
backgroundColor: "#1976d2",
|
|
1870
|
+
color: "white",
|
|
1871
|
+
border: "none",
|
|
1872
|
+
borderRadius: "4px",
|
|
1873
|
+
cursor: "pointer"
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
function en({ service: e, className: t, style: n }) {
|
|
1877
|
+
const [r, i] = E([]), [s, a] = E([]), [l, c] = E("all"), [h, p] = E(null), [m, y] = E(""), [$, w] = E("apa"), j = P(() => {
|
|
1878
|
+
i(e.listCitations(l)), a(e.listCollections());
|
|
1879
|
+
}, [e, l]), J = K(() => m ? e.searchCitations(m, { collection: l }) : r, [r, m, l, e]), te = K(
|
|
1880
|
+
() => r.find((L) => L.id === h),
|
|
1881
|
+
[r, h]
|
|
1882
|
+
), V = {
|
|
1883
|
+
service: e,
|
|
1884
|
+
citations: r,
|
|
1885
|
+
collections: s,
|
|
1886
|
+
selectedCollection: l,
|
|
1887
|
+
setSelectedCollection: c,
|
|
1888
|
+
selectedCitation: h,
|
|
1889
|
+
setSelectedCitation: p,
|
|
1890
|
+
searchQuery: m,
|
|
1891
|
+
setSearchQuery: y,
|
|
1892
|
+
citationStyle: $,
|
|
1893
|
+
setCitationStyle: w,
|
|
1894
|
+
refresh: j
|
|
1895
|
+
};
|
|
1896
|
+
return /* @__PURE__ */ o(He.Provider, { value: V, children: /* @__PURE__ */ u("div", { className: t, style: { ...he.container, ...n }, children: [
|
|
1897
|
+
/* @__PURE__ */ u("div", { style: he.sidebar, children: [
|
|
1898
|
+
/* @__PURE__ */ o("div", { style: { padding: "16px", fontWeight: 600 }, children: "Collections" }),
|
|
1899
|
+
s.map((L) => /* @__PURE__ */ u(
|
|
1900
|
+
"div",
|
|
1901
|
+
{
|
|
1902
|
+
onClick: () => {
|
|
1903
|
+
c(L.id), j();
|
|
1904
|
+
},
|
|
1905
|
+
style: {
|
|
1906
|
+
...he.listItem,
|
|
1907
|
+
backgroundColor: l === L.id ? "#e3f2fd" : "transparent"
|
|
1908
|
+
},
|
|
1909
|
+
children: [
|
|
1910
|
+
/* @__PURE__ */ o("div", { children: L.name }),
|
|
1911
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", color: "#666" }, children: [
|
|
1912
|
+
L.citationCount,
|
|
1913
|
+
" items"
|
|
1914
|
+
] })
|
|
1915
|
+
]
|
|
1916
|
+
},
|
|
1917
|
+
L.id
|
|
1918
|
+
))
|
|
1919
|
+
] }),
|
|
1920
|
+
/* @__PURE__ */ u("div", { style: he.main, children: [
|
|
1921
|
+
/* @__PURE__ */ u("div", { style: he.toolbar, children: [
|
|
1922
|
+
/* @__PURE__ */ o(
|
|
1923
|
+
"input",
|
|
1924
|
+
{
|
|
1925
|
+
type: "text",
|
|
1926
|
+
placeholder: "Search references...",
|
|
1927
|
+
value: m,
|
|
1928
|
+
onChange: (L) => y(L.target.value),
|
|
1929
|
+
style: { ...he.input, flex: 1 }
|
|
1930
|
+
}
|
|
1931
|
+
),
|
|
1932
|
+
/* @__PURE__ */ u(
|
|
1933
|
+
"select",
|
|
1934
|
+
{
|
|
1935
|
+
value: $,
|
|
1936
|
+
onChange: (L) => w(L.target.value),
|
|
1937
|
+
style: he.input,
|
|
1938
|
+
children: [
|
|
1939
|
+
/* @__PURE__ */ o("option", { value: "apa", children: "APA" }),
|
|
1940
|
+
/* @__PURE__ */ o("option", { value: "mla", children: "MLA" }),
|
|
1941
|
+
/* @__PURE__ */ o("option", { value: "chicago", children: "Chicago" }),
|
|
1942
|
+
/* @__PURE__ */ o("option", { value: "harvard", children: "Harvard" }),
|
|
1943
|
+
/* @__PURE__ */ o("option", { value: "ieee", children: "IEEE" }),
|
|
1944
|
+
/* @__PURE__ */ o("option", { value: "vancouver", children: "Vancouver" }),
|
|
1945
|
+
/* @__PURE__ */ o("option", { value: "bibtex", children: "BibTeX" })
|
|
1946
|
+
]
|
|
1947
|
+
}
|
|
1948
|
+
),
|
|
1949
|
+
/* @__PURE__ */ o(kt, {})
|
|
1950
|
+
] }),
|
|
1951
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", flex: 1, overflow: "hidden" }, children: [
|
|
1952
|
+
/* @__PURE__ */ u("div", { style: he.list, children: [
|
|
1953
|
+
J.map((L) => /* @__PURE__ */ u(
|
|
1954
|
+
"div",
|
|
1955
|
+
{
|
|
1956
|
+
onClick: () => p(L.id),
|
|
1957
|
+
style: {
|
|
1958
|
+
...he.listItem,
|
|
1959
|
+
backgroundColor: h === L.id ? "#e3f2fd" : "transparent"
|
|
1960
|
+
},
|
|
1961
|
+
children: [
|
|
1962
|
+
/* @__PURE__ */ o("div", { style: { fontWeight: 500, marginBottom: "4px" }, children: L.title }),
|
|
1963
|
+
/* @__PURE__ */ u("div", { style: { fontSize: "12px", color: "#666" }, children: [
|
|
1964
|
+
L.authors.map((H) => H.family).join(", "),
|
|
1965
|
+
L.year && ` (${L.year})`
|
|
1966
|
+
] }),
|
|
1967
|
+
L.journal && /* @__PURE__ */ o("div", { style: { fontSize: "12px", color: "#888", fontStyle: "italic" }, children: L.journal })
|
|
1968
|
+
]
|
|
1969
|
+
},
|
|
1970
|
+
L.id
|
|
1971
|
+
)),
|
|
1972
|
+
J.length === 0 && /* @__PURE__ */ o("div", { style: { padding: "24px", textAlign: "center", color: "#666" }, children: "No references found" })
|
|
1973
|
+
] }),
|
|
1974
|
+
te && /* @__PURE__ */ o("div", { style: he.detail, children: /* @__PURE__ */ o(Dt, { citation: te }) })
|
|
1975
|
+
] })
|
|
1976
|
+
] })
|
|
1977
|
+
] }) });
|
|
1978
|
+
}
|
|
1979
|
+
function kt() {
|
|
1980
|
+
const { service: e, refresh: t } = et(), [n, r] = E(!1), [i, s] = E(""), [a, l] = E(!1), c = async () => {
|
|
1981
|
+
if (i.trim()) {
|
|
1982
|
+
l(!0);
|
|
1983
|
+
try {
|
|
1984
|
+
await e.fetchByDOI(i.trim()), t(), s(""), r(!1);
|
|
1985
|
+
} finally {
|
|
1986
|
+
l(!1);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
return /* @__PURE__ */ u(Ae, { children: [
|
|
1991
|
+
/* @__PURE__ */ o("button", { onClick: () => r(!0), style: he.button, children: "+ Add Reference" }),
|
|
1992
|
+
n && /* @__PURE__ */ o(
|
|
1993
|
+
"div",
|
|
1994
|
+
{
|
|
1995
|
+
style: {
|
|
1996
|
+
position: "fixed",
|
|
1997
|
+
inset: 0,
|
|
1998
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
1999
|
+
display: "flex",
|
|
2000
|
+
alignItems: "center",
|
|
2001
|
+
justifyContent: "center",
|
|
2002
|
+
zIndex: 1e3
|
|
2003
|
+
},
|
|
2004
|
+
onClick: () => r(!1),
|
|
2005
|
+
children: /* @__PURE__ */ u(
|
|
2006
|
+
"div",
|
|
2007
|
+
{
|
|
2008
|
+
style: {
|
|
2009
|
+
backgroundColor: "white",
|
|
2010
|
+
padding: "24px",
|
|
2011
|
+
borderRadius: "8px",
|
|
2012
|
+
width: "400px"
|
|
2013
|
+
},
|
|
2014
|
+
onClick: (h) => h.stopPropagation(),
|
|
2015
|
+
children: [
|
|
2016
|
+
/* @__PURE__ */ o("h3", { style: { margin: "0 0 16px 0" }, children: "Add Reference by DOI" }),
|
|
2017
|
+
/* @__PURE__ */ o(
|
|
2018
|
+
"input",
|
|
2019
|
+
{
|
|
2020
|
+
type: "text",
|
|
2021
|
+
value: i,
|
|
2022
|
+
onChange: (h) => s(h.target.value),
|
|
2023
|
+
placeholder: "Enter DOI (e.g., 10.1000/xyz123)",
|
|
2024
|
+
style: { ...he.input, width: "100%", marginBottom: "16px" }
|
|
2025
|
+
}
|
|
2026
|
+
),
|
|
2027
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "8px", justifyContent: "flex-end" }, children: [
|
|
2028
|
+
/* @__PURE__ */ o(
|
|
2029
|
+
"button",
|
|
2030
|
+
{
|
|
2031
|
+
onClick: () => r(!1),
|
|
2032
|
+
style: { ...he.button, backgroundColor: "#9e9e9e" },
|
|
2033
|
+
children: "Cancel"
|
|
2034
|
+
}
|
|
2035
|
+
),
|
|
2036
|
+
/* @__PURE__ */ o("button", { onClick: c, disabled: a, style: he.button, children: a ? "Loading..." : "Add" })
|
|
2037
|
+
] })
|
|
2038
|
+
]
|
|
2039
|
+
}
|
|
2040
|
+
)
|
|
2041
|
+
}
|
|
2042
|
+
)
|
|
2043
|
+
] });
|
|
2044
|
+
}
|
|
2045
|
+
function Dt({ citation: e }) {
|
|
2046
|
+
const { service: t, citationStyle: n } = et(), [r, i] = E(!1), s = K(
|
|
2047
|
+
() => t.formatCitation(e.id, n),
|
|
2048
|
+
[t, e.id, n]
|
|
2049
|
+
), a = () => {
|
|
2050
|
+
navigator.clipboard.writeText(s), i(!0), setTimeout(() => i(!1), 2e3);
|
|
2051
|
+
};
|
|
2052
|
+
return /* @__PURE__ */ u("div", { children: [
|
|
2053
|
+
/* @__PURE__ */ o("h2", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: e.title }),
|
|
2054
|
+
/* @__PURE__ */ o("div", { style: { color: "#666", marginBottom: "16px" }, children: e.authors.map((l) => `${l.given} ${l.family}`).join(", ") }),
|
|
2055
|
+
/* @__PURE__ */ u("div", { style: { marginBottom: "16px" }, children: [
|
|
2056
|
+
/* @__PURE__ */ u(
|
|
2057
|
+
"div",
|
|
2058
|
+
{
|
|
2059
|
+
style: {
|
|
2060
|
+
display: "flex",
|
|
2061
|
+
justifyContent: "space-between",
|
|
2062
|
+
alignItems: "center",
|
|
2063
|
+
marginBottom: "8px"
|
|
2064
|
+
},
|
|
2065
|
+
children: [
|
|
2066
|
+
/* @__PURE__ */ u("strong", { children: [
|
|
2067
|
+
"Formatted (",
|
|
2068
|
+
n.toUpperCase(),
|
|
2069
|
+
")"
|
|
2070
|
+
] }),
|
|
2071
|
+
/* @__PURE__ */ o(
|
|
2072
|
+
"button",
|
|
2073
|
+
{
|
|
2074
|
+
onClick: a,
|
|
2075
|
+
style: { ...he.button, padding: "4px 8px", fontSize: "12px" },
|
|
2076
|
+
children: r ? "Copied!" : "Copy"
|
|
2077
|
+
}
|
|
2078
|
+
)
|
|
2079
|
+
]
|
|
2080
|
+
}
|
|
2081
|
+
),
|
|
2082
|
+
/* @__PURE__ */ o(
|
|
2083
|
+
"div",
|
|
2084
|
+
{
|
|
2085
|
+
style: {
|
|
2086
|
+
padding: "12px",
|
|
2087
|
+
backgroundColor: "#f5f5f5",
|
|
2088
|
+
borderRadius: "4px",
|
|
2089
|
+
whiteSpace: "pre-wrap",
|
|
2090
|
+
fontSize: "13px"
|
|
2091
|
+
},
|
|
2092
|
+
dangerouslySetInnerHTML: {
|
|
2093
|
+
__html: s.replace(/\*([^*]+)\*/g, "<em>$1</em>")
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
)
|
|
2097
|
+
] }),
|
|
2098
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column", gap: "8px", fontSize: "13px" }, children: [
|
|
2099
|
+
e.journal && /* @__PURE__ */ u("div", { children: [
|
|
2100
|
+
/* @__PURE__ */ o("strong", { children: "Journal:" }),
|
|
2101
|
+
" ",
|
|
2102
|
+
e.journal
|
|
2103
|
+
] }),
|
|
2104
|
+
e.year && /* @__PURE__ */ u("div", { children: [
|
|
2105
|
+
/* @__PURE__ */ o("strong", { children: "Year:" }),
|
|
2106
|
+
" ",
|
|
2107
|
+
e.year
|
|
2108
|
+
] }),
|
|
2109
|
+
e.volume && /* @__PURE__ */ u("div", { children: [
|
|
2110
|
+
/* @__PURE__ */ o("strong", { children: "Volume:" }),
|
|
2111
|
+
" ",
|
|
2112
|
+
e.volume,
|
|
2113
|
+
e.issue && `(${e.issue})`
|
|
2114
|
+
] }),
|
|
2115
|
+
e.pages && /* @__PURE__ */ u("div", { children: [
|
|
2116
|
+
/* @__PURE__ */ o("strong", { children: "Pages:" }),
|
|
2117
|
+
" ",
|
|
2118
|
+
e.pages
|
|
2119
|
+
] }),
|
|
2120
|
+
e.doi && /* @__PURE__ */ u("div", { children: [
|
|
2121
|
+
/* @__PURE__ */ o("strong", { children: "DOI:" }),
|
|
2122
|
+
" ",
|
|
2123
|
+
/* @__PURE__ */ o("a", { href: `https://doi.org/${e.doi}`, target: "_blank", rel: "noopener noreferrer", children: e.doi })
|
|
2124
|
+
] }),
|
|
2125
|
+
e.pmid && /* @__PURE__ */ u("div", { children: [
|
|
2126
|
+
/* @__PURE__ */ o("strong", { children: "PMID:" }),
|
|
2127
|
+
" ",
|
|
2128
|
+
/* @__PURE__ */ o(
|
|
2129
|
+
"a",
|
|
2130
|
+
{
|
|
2131
|
+
href: `https://pubmed.ncbi.nlm.nih.gov/${e.pmid}`,
|
|
2132
|
+
target: "_blank",
|
|
2133
|
+
rel: "noopener noreferrer",
|
|
2134
|
+
children: e.pmid
|
|
2135
|
+
}
|
|
2136
|
+
)
|
|
2137
|
+
] }),
|
|
2138
|
+
e.abstract && /* @__PURE__ */ u("div", { style: { marginTop: "8px" }, children: [
|
|
2139
|
+
/* @__PURE__ */ o("strong", { children: "Abstract:" }),
|
|
2140
|
+
/* @__PURE__ */ o("p", { style: { margin: "8px 0 0 0", color: "#444" }, children: e.abstract })
|
|
2141
|
+
] })
|
|
2142
|
+
] })
|
|
2143
|
+
] });
|
|
2144
|
+
}
|
|
2145
|
+
const At = {
|
|
2146
|
+
series: [],
|
|
2147
|
+
xAxes: [],
|
|
2148
|
+
yAxes: [],
|
|
2149
|
+
annotations: [],
|
|
2150
|
+
selectedSeries: [],
|
|
2151
|
+
zoom: { x: null, y: null },
|
|
2152
|
+
cursor: null,
|
|
2153
|
+
hoveredPoint: null
|
|
2154
|
+
};
|
|
2155
|
+
function Fe(e) {
|
|
2156
|
+
return e.reduce((t, n) => t + n, 0) / e.length;
|
|
2157
|
+
}
|
|
2158
|
+
function zt(e) {
|
|
2159
|
+
const t = [...e].sort((r, i) => r - i), n = Math.floor(t.length / 2);
|
|
2160
|
+
return t.length % 2 ? t[n] : (t[n - 1] + t[n]) / 2;
|
|
2161
|
+
}
|
|
2162
|
+
function Re(e) {
|
|
2163
|
+
const t = Fe(e), n = e.map((r) => Math.pow(r - t, 2));
|
|
2164
|
+
return Math.sqrt(Fe(n));
|
|
2165
|
+
}
|
|
2166
|
+
function Ft(e) {
|
|
2167
|
+
return Re(e) / Math.sqrt(e.length);
|
|
2168
|
+
}
|
|
2169
|
+
function It(e) {
|
|
2170
|
+
const t = Fe(e), n = Ft(e), r = 1.96;
|
|
2171
|
+
return [t - r * n, t + r * n];
|
|
2172
|
+
}
|
|
2173
|
+
function Nt(e) {
|
|
2174
|
+
const t = e.length, n = e.map((w) => typeof w.x == "number" ? w.x : 0), r = e.map((w) => w.y), i = n.reduce((w, j) => w + j, 0), s = r.reduce((w, j) => w + j, 0), a = n.reduce((w, j, J) => w + j * r[J], 0), l = n.reduce((w, j) => w + j * j, 0), c = (t * a - i * s) / (t * l - i * i), h = (s - c * i) / t, p = s / t, m = r.reduce((w, j) => w + Math.pow(j - p, 2), 0), $ = 1 - r.reduce((w, j, J) => w + Math.pow(j - (c * n[J] + h), 2), 0) / m;
|
|
2175
|
+
return { slope: c, intercept: h, r2: $ };
|
|
2176
|
+
}
|
|
2177
|
+
function Et(e, t) {
|
|
2178
|
+
const n = Fe(e), r = Fe(t), i = Re(e) ** 2, s = Re(t) ** 2, a = e.length, l = t.length, c = ((a - 1) * i + (l - 1) * s) / (a + l - 2), h = Math.sqrt(c * (1 / a + 1 / l)), p = (n - r) / h, m = Math.exp(-0.717 * Math.abs(p) - 0.416 * p * p);
|
|
2179
|
+
return { t: p, p: m, significant: m < 0.05 };
|
|
2180
|
+
}
|
|
2181
|
+
function _e(e, t, n, r = 5) {
|
|
2182
|
+
const s = (t - e) / (r - 1);
|
|
2183
|
+
return Array.from({ length: r }, (a, l) => e + l * s);
|
|
2184
|
+
}
|
|
2185
|
+
function qe(e, t) {
|
|
2186
|
+
return Math.abs(e) >= 1e6 ? (e / 1e6).toFixed(1) + "M" : Math.abs(e) >= 1e3 ? (e / 1e3).toFixed(1) + "K" : Math.abs(e) < 0.01 ? e.toExponential(2) : e.toFixed(2).replace(/\.?0+$/, "");
|
|
2187
|
+
}
|
|
2188
|
+
function tn({
|
|
2189
|
+
series: e,
|
|
2190
|
+
title: t,
|
|
2191
|
+
subtitle: n,
|
|
2192
|
+
width: r = "100%",
|
|
2193
|
+
height: i = 400,
|
|
2194
|
+
type: s = "scatter",
|
|
2195
|
+
xAxis: a,
|
|
2196
|
+
yAxis: l,
|
|
2197
|
+
statOverlays: c = [],
|
|
2198
|
+
annotations: h = [],
|
|
2199
|
+
legend: p = { show: !0, position: "top", orientation: "horizontal", interactive: !0 },
|
|
2200
|
+
tooltip: m = { enabled: !0, mode: "point" },
|
|
2201
|
+
zoom: y = { enabled: !0, mode: "xy", wheel: !0, drag: !0, resetButton: !0 },
|
|
2202
|
+
export: $,
|
|
2203
|
+
statisticalTests: w = [],
|
|
2204
|
+
gridLines: j = !0,
|
|
2205
|
+
aspectRatio: J,
|
|
2206
|
+
animation: te = !0,
|
|
2207
|
+
theme: V = "light",
|
|
2208
|
+
onPointClick: L,
|
|
2209
|
+
onPointHover: H,
|
|
2210
|
+
onZoomChange: oe,
|
|
2211
|
+
onAnnotationChange: U,
|
|
2212
|
+
className: de,
|
|
2213
|
+
style: pe
|
|
2214
|
+
}) {
|
|
2215
|
+
const se = ze(null);
|
|
2216
|
+
ze(null);
|
|
2217
|
+
const [ne, _] = E({
|
|
2218
|
+
...At,
|
|
2219
|
+
series: e,
|
|
2220
|
+
annotations: h
|
|
2221
|
+
}), [ce, ue] = E({ width: 0, height: 0 }), [ye, xe] = E({ x: null, y: null }), [Y, Z] = E(
|
|
2222
|
+
null
|
|
2223
|
+
), [ae, G] = E(
|
|
2224
|
+
new Set(e.map((d) => d.id))
|
|
2225
|
+
), S = K(() => {
|
|
2226
|
+
const d = e.filter((M) => ae.has(M.id) && M.visible !== !1);
|
|
2227
|
+
if (d.length === 0)
|
|
2228
|
+
return { xMin: 0, xMax: 1, yMin: 0, yMax: 1 };
|
|
2229
|
+
let x = 1 / 0, C = -1 / 0, N = 1 / 0, I = -1 / 0;
|
|
2230
|
+
for (const M of d)
|
|
2231
|
+
for (const A of M.data) {
|
|
2232
|
+
const O = typeof A.x == "number" ? A.x : 0;
|
|
2233
|
+
if (x = Math.min(x, O), C = Math.max(C, O), N = Math.min(N, A.y), I = Math.max(I, A.y), A.error) {
|
|
2234
|
+
const [X, le] = Array.isArray(A.error) ? A.error : [-A.error, A.error];
|
|
2235
|
+
N = Math.min(N, A.y + X), I = Math.max(I, A.y + le);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
const W = (C - x) * 0.05 || 0.5, g = (I - N) * 0.05 || 0.5;
|
|
2239
|
+
return {
|
|
2240
|
+
xMin: x - W,
|
|
2241
|
+
xMax: C + W,
|
|
2242
|
+
yMin: N - g,
|
|
2243
|
+
yMax: I + g
|
|
2244
|
+
};
|
|
2245
|
+
}, [e, ae]), Q = K(() => {
|
|
2246
|
+
const d = {};
|
|
2247
|
+
for (const x of e) {
|
|
2248
|
+
if (!ae.has(x.id))
|
|
2249
|
+
continue;
|
|
2250
|
+
const C = x.data.map((N) => N.y);
|
|
2251
|
+
c.includes("mean") && (d[`${x.id}_mean`] = Fe(C)), c.includes("median") && (d[`${x.id}_median`] = zt(C)), c.includes("std-dev") && (d[`${x.id}_std`] = Re(C)), c.includes("regression") && (d[`${x.id}_regression`] = Nt(x.data)), c.includes("confidence-interval") && (d[`${x.id}_ci95`] = It(C));
|
|
2252
|
+
}
|
|
2253
|
+
return d;
|
|
2254
|
+
}, [e, ae, c]), ee = K(() => w.map((d) => {
|
|
2255
|
+
if (d.type === "t-test" && d.series.length === 2) {
|
|
2256
|
+
const x = e.find((N) => N.id === d.series[0]), C = e.find((N) => N.id === d.series[1]);
|
|
2257
|
+
if (x && C) {
|
|
2258
|
+
const N = Et(
|
|
2259
|
+
x.data.map((I) => I.y),
|
|
2260
|
+
C.data.map((I) => I.y)
|
|
2261
|
+
);
|
|
2262
|
+
return {
|
|
2263
|
+
...d,
|
|
2264
|
+
result: {
|
|
2265
|
+
statistic: N.t,
|
|
2266
|
+
pValue: N.p,
|
|
2267
|
+
significant: N.significant,
|
|
2268
|
+
interpretation: N.significant ? `Significant difference (p = ${N.p.toFixed(4)})` : `No significant difference (p = ${N.p.toFixed(4)})`
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
return d;
|
|
2274
|
+
}), [w, e]), re = P((d) => {
|
|
2275
|
+
G((x) => {
|
|
2276
|
+
const C = new Set(x);
|
|
2277
|
+
return C.has(d) ? C.delete(d) : C.add(d), C;
|
|
2278
|
+
});
|
|
2279
|
+
}, []), ie = P(() => {
|
|
2280
|
+
xe({ x: null, y: null }), oe == null || oe(null, null);
|
|
2281
|
+
}, [oe]), z = K(() => {
|
|
2282
|
+
switch (V) {
|
|
2283
|
+
case "dark":
|
|
2284
|
+
return ["#60a5fa", "#f472b6", "#34d399", "#fbbf24", "#a78bfa", "#fb923c"];
|
|
2285
|
+
case "publication":
|
|
2286
|
+
return ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b"];
|
|
2287
|
+
case "presentation":
|
|
2288
|
+
return ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899"];
|
|
2289
|
+
default:
|
|
2290
|
+
return ["#2563eb", "#dc2626", "#16a34a", "#ca8a04", "#7c3aed", "#db2777"];
|
|
2291
|
+
}
|
|
2292
|
+
}, [V]), k = K(() => {
|
|
2293
|
+
switch (V) {
|
|
2294
|
+
case "dark":
|
|
2295
|
+
return {
|
|
2296
|
+
bg: "#1f2937",
|
|
2297
|
+
text: "#f3f4f6",
|
|
2298
|
+
grid: "#374151",
|
|
2299
|
+
axis: "#9ca3af",
|
|
2300
|
+
tooltip: "#374151"
|
|
2301
|
+
};
|
|
2302
|
+
case "publication":
|
|
2303
|
+
return {
|
|
2304
|
+
bg: "#ffffff",
|
|
2305
|
+
text: "#000000",
|
|
2306
|
+
grid: "#e5e5e5",
|
|
2307
|
+
axis: "#333333",
|
|
2308
|
+
tooltip: "#ffffff"
|
|
2309
|
+
};
|
|
2310
|
+
default:
|
|
2311
|
+
return {
|
|
2312
|
+
bg: "#ffffff",
|
|
2313
|
+
text: "#1f2937",
|
|
2314
|
+
grid: "#e5e7eb",
|
|
2315
|
+
axis: "#4b5563",
|
|
2316
|
+
tooltip: "#ffffff"
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
}, [V]);
|
|
2320
|
+
return /* @__PURE__ */ u(
|
|
2321
|
+
"div",
|
|
2322
|
+
{
|
|
2323
|
+
ref: se,
|
|
2324
|
+
className: `nice-scientific-chart nice-scientific-chart--${V} ${de || ""}`,
|
|
2325
|
+
style: {
|
|
2326
|
+
width: r,
|
|
2327
|
+
height: J ? "auto" : i,
|
|
2328
|
+
aspectRatio: J == null ? void 0 : J.toString(),
|
|
2329
|
+
backgroundColor: k.bg,
|
|
2330
|
+
color: k.text,
|
|
2331
|
+
fontFamily: V === "publication" ? "Times New Roman, serif" : "system-ui, sans-serif",
|
|
2332
|
+
...pe
|
|
2333
|
+
},
|
|
2334
|
+
children: [
|
|
2335
|
+
t && /* @__PURE__ */ u(
|
|
2336
|
+
"div",
|
|
2337
|
+
{
|
|
2338
|
+
className: "nice-scientific-chart__title",
|
|
2339
|
+
style: {
|
|
2340
|
+
textAlign: "center",
|
|
2341
|
+
fontWeight: "bold",
|
|
2342
|
+
fontSize: "1.25rem",
|
|
2343
|
+
padding: "0.5rem"
|
|
2344
|
+
},
|
|
2345
|
+
children: [
|
|
2346
|
+
t,
|
|
2347
|
+
n && /* @__PURE__ */ o("div", { style: { fontSize: "0.875rem", fontWeight: "normal", color: k.axis }, children: n })
|
|
2348
|
+
]
|
|
2349
|
+
}
|
|
2350
|
+
),
|
|
2351
|
+
p.show && /* @__PURE__ */ o(
|
|
2352
|
+
"div",
|
|
2353
|
+
{
|
|
2354
|
+
className: "nice-scientific-chart__legend",
|
|
2355
|
+
style: {
|
|
2356
|
+
display: "flex",
|
|
2357
|
+
flexDirection: p.orientation === "vertical" ? "column" : "row",
|
|
2358
|
+
flexWrap: "wrap",
|
|
2359
|
+
gap: "0.5rem",
|
|
2360
|
+
padding: "0.5rem",
|
|
2361
|
+
justifyContent: "center"
|
|
2362
|
+
},
|
|
2363
|
+
children: e.map((d, x) => /* @__PURE__ */ u(
|
|
2364
|
+
"button",
|
|
2365
|
+
{
|
|
2366
|
+
onClick: () => p.interactive && re(d.id),
|
|
2367
|
+
style: {
|
|
2368
|
+
display: "flex",
|
|
2369
|
+
alignItems: "center",
|
|
2370
|
+
gap: "0.25rem",
|
|
2371
|
+
background: "none",
|
|
2372
|
+
border: "none",
|
|
2373
|
+
cursor: p.interactive ? "pointer" : "default",
|
|
2374
|
+
opacity: ae.has(d.id) ? 1 : 0.4,
|
|
2375
|
+
color: "inherit",
|
|
2376
|
+
fontSize: "0.875rem"
|
|
2377
|
+
},
|
|
2378
|
+
children: [
|
|
2379
|
+
/* @__PURE__ */ o(
|
|
2380
|
+
"span",
|
|
2381
|
+
{
|
|
2382
|
+
style: {
|
|
2383
|
+
width: 12,
|
|
2384
|
+
height: 12,
|
|
2385
|
+
borderRadius: 2,
|
|
2386
|
+
backgroundColor: d.color || z[x % z.length]
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
),
|
|
2390
|
+
d.name
|
|
2391
|
+
]
|
|
2392
|
+
},
|
|
2393
|
+
d.id
|
|
2394
|
+
))
|
|
2395
|
+
}
|
|
2396
|
+
),
|
|
2397
|
+
/* @__PURE__ */ u(
|
|
2398
|
+
"div",
|
|
2399
|
+
{
|
|
2400
|
+
className: "nice-scientific-chart__canvas",
|
|
2401
|
+
style: { flex: 1, position: "relative", minHeight: 200 },
|
|
2402
|
+
children: [
|
|
2403
|
+
/* @__PURE__ */ u("svg", { width: "100%", height: "100%", style: { overflow: "visible" }, children: [
|
|
2404
|
+
j && /* @__PURE__ */ u("g", { className: "nice-scientific-chart__grid", stroke: k.grid, strokeWidth: 1, children: [
|
|
2405
|
+
[0, 0.25, 0.5, 0.75, 1].map((d) => /* @__PURE__ */ o(
|
|
2406
|
+
"line",
|
|
2407
|
+
{
|
|
2408
|
+
x1: "10%",
|
|
2409
|
+
y1: `${d * 100}%`,
|
|
2410
|
+
x2: "95%",
|
|
2411
|
+
y2: `${d * 100}%`,
|
|
2412
|
+
strokeDasharray: "2,2"
|
|
2413
|
+
},
|
|
2414
|
+
`h-${d}`
|
|
2415
|
+
)),
|
|
2416
|
+
[0, 0.25, 0.5, 0.75, 1].map((d) => /* @__PURE__ */ o(
|
|
2417
|
+
"line",
|
|
2418
|
+
{
|
|
2419
|
+
x1: `${10 + d * 85}%`,
|
|
2420
|
+
y1: "5%",
|
|
2421
|
+
x2: `${10 + d * 85}%`,
|
|
2422
|
+
y2: "90%",
|
|
2423
|
+
strokeDasharray: "2,2"
|
|
2424
|
+
},
|
|
2425
|
+
`v-${d}`
|
|
2426
|
+
))
|
|
2427
|
+
] }),
|
|
2428
|
+
e.filter((d) => ae.has(d.id) && d.visible !== !1).map((d, x) => {
|
|
2429
|
+
var I, W, g;
|
|
2430
|
+
const C = d.color || z[x % z.length], N = d.type || s;
|
|
2431
|
+
return /* @__PURE__ */ o("g", { className: "nice-scientific-chart__series", children: N === "scatter" || N === "line" ? /* @__PURE__ */ u(Ae, { children: [
|
|
2432
|
+
N === "line" && d.data.length > 1 && /* @__PURE__ */ o(
|
|
2433
|
+
"polyline",
|
|
2434
|
+
{
|
|
2435
|
+
fill: "none",
|
|
2436
|
+
stroke: C,
|
|
2437
|
+
strokeWidth: ((I = d.line) == null ? void 0 : I.width) || 2,
|
|
2438
|
+
strokeDasharray: ((W = d.line) == null ? void 0 : W.style) === "dashed" ? "5,5" : ((g = d.line) == null ? void 0 : g.style) === "dotted" ? "2,2" : void 0,
|
|
2439
|
+
points: d.data.map((M, A) => {
|
|
2440
|
+
const O = 10 + ((typeof M.x == "number" ? M.x : A) - S.xMin) / (S.xMax - S.xMin) * 85, X = 90 - (M.y - S.yMin) / (S.yMax - S.yMin) * 85;
|
|
2441
|
+
return `${O}%,${X}%`;
|
|
2442
|
+
}).join(" ")
|
|
2443
|
+
}
|
|
2444
|
+
),
|
|
2445
|
+
d.data.map((M, A) => {
|
|
2446
|
+
var fe, be, ge, me, we;
|
|
2447
|
+
const O = 10 + ((typeof M.x == "number" ? M.x : A) - S.xMin) / (S.xMax - S.xMin) * 85, X = 90 - (M.y - S.yMin) / (S.yMax - S.yMin) * 85, le = M.size || ((fe = d.marker) == null ? void 0 : fe.size) || 6;
|
|
2448
|
+
return /* @__PURE__ */ u("g", { className: "nice-scientific-chart__point", children: [
|
|
2449
|
+
M.error && /* @__PURE__ */ o(
|
|
2450
|
+
"line",
|
|
2451
|
+
{
|
|
2452
|
+
x1: `${O}%`,
|
|
2453
|
+
y1: `${90 - (M.y + (Array.isArray(M.error) ? M.error[1] : M.error) - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2454
|
+
x2: `${O}%`,
|
|
2455
|
+
y2: `${90 - (M.y - (Array.isArray(M.error) ? Math.abs(M.error[0]) : M.error) - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2456
|
+
stroke: C,
|
|
2457
|
+
strokeWidth: 1
|
|
2458
|
+
}
|
|
2459
|
+
),
|
|
2460
|
+
/* @__PURE__ */ o(
|
|
2461
|
+
"circle",
|
|
2462
|
+
{
|
|
2463
|
+
cx: `${O}%`,
|
|
2464
|
+
cy: `${X}%`,
|
|
2465
|
+
r: le / 2,
|
|
2466
|
+
fill: M.color || ((be = d.marker) == null ? void 0 : be.fillColor) || C,
|
|
2467
|
+
stroke: ((ge = d.marker) == null ? void 0 : ge.strokeColor) || C,
|
|
2468
|
+
strokeWidth: ((me = d.marker) == null ? void 0 : me.strokeWidth) || 1,
|
|
2469
|
+
opacity: ((we = d.marker) == null ? void 0 : we.opacity) ?? 1,
|
|
2470
|
+
style: { cursor: L ? "pointer" : void 0 },
|
|
2471
|
+
onMouseEnter: () => {
|
|
2472
|
+
Z({ seriesId: d.id, pointIndex: A }), H == null || H(M, d);
|
|
2473
|
+
},
|
|
2474
|
+
onMouseLeave: () => {
|
|
2475
|
+
Z(null), H == null || H(null, null);
|
|
2476
|
+
},
|
|
2477
|
+
onClick: (Ce) => L == null ? void 0 : L(M, d, Ce)
|
|
2478
|
+
}
|
|
2479
|
+
)
|
|
2480
|
+
] }, A);
|
|
2481
|
+
}),
|
|
2482
|
+
Q[`${d.id}_regression`] && /* @__PURE__ */ o(
|
|
2483
|
+
"line",
|
|
2484
|
+
{
|
|
2485
|
+
x1: "10%",
|
|
2486
|
+
y1: `${90 - (Q[`${d.id}_regression`].intercept + Q[`${d.id}_regression`].slope * S.xMin - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2487
|
+
x2: "95%",
|
|
2488
|
+
y2: `${90 - (Q[`${d.id}_regression`].intercept + Q[`${d.id}_regression`].slope * S.xMax - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2489
|
+
stroke: C,
|
|
2490
|
+
strokeWidth: 1,
|
|
2491
|
+
strokeDasharray: "5,3",
|
|
2492
|
+
opacity: 0.7
|
|
2493
|
+
}
|
|
2494
|
+
),
|
|
2495
|
+
Q[`${d.id}_mean`] && /* @__PURE__ */ o(
|
|
2496
|
+
"line",
|
|
2497
|
+
{
|
|
2498
|
+
x1: "10%",
|
|
2499
|
+
y1: `${90 - (Q[`${d.id}_mean`] - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2500
|
+
x2: "95%",
|
|
2501
|
+
y2: `${90 - (Q[`${d.id}_mean`] - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2502
|
+
stroke: C,
|
|
2503
|
+
strokeWidth: 1,
|
|
2504
|
+
strokeDasharray: "10,5",
|
|
2505
|
+
opacity: 0.5
|
|
2506
|
+
}
|
|
2507
|
+
)
|
|
2508
|
+
] }) : null }, d.id);
|
|
2509
|
+
}),
|
|
2510
|
+
/* @__PURE__ */ u("g", { className: "nice-scientific-chart__axes", stroke: k.axis, strokeWidth: 1, children: [
|
|
2511
|
+
/* @__PURE__ */ o("line", { x1: "10%", y1: "90%", x2: "95%", y2: "90%" }),
|
|
2512
|
+
/* @__PURE__ */ o("line", { x1: "10%", y1: "5%", x2: "10%", y2: "90%" }),
|
|
2513
|
+
_e(S.xMin, S.xMax, "linear", 6).map((d, x) => /* @__PURE__ */ u("g", { children: [
|
|
2514
|
+
/* @__PURE__ */ o("line", { x1: `${10 + x * 17}%`, y1: "90%", x2: `${10 + x * 17}%`, y2: "92%" }),
|
|
2515
|
+
/* @__PURE__ */ o(
|
|
2516
|
+
"text",
|
|
2517
|
+
{
|
|
2518
|
+
x: `${10 + x * 17}%`,
|
|
2519
|
+
y: "96%",
|
|
2520
|
+
textAnchor: "middle",
|
|
2521
|
+
fill: k.axis,
|
|
2522
|
+
fontSize: "0.75rem",
|
|
2523
|
+
children: qe(d)
|
|
2524
|
+
}
|
|
2525
|
+
)
|
|
2526
|
+
] }, `x-${x}`)),
|
|
2527
|
+
_e(S.yMin, S.yMax, "linear", 6).map((d, x) => /* @__PURE__ */ u("g", { children: [
|
|
2528
|
+
/* @__PURE__ */ o("line", { x1: "8%", y1: `${90 - x * 17}%`, x2: "10%", y2: `${90 - x * 17}%` }),
|
|
2529
|
+
/* @__PURE__ */ o(
|
|
2530
|
+
"text",
|
|
2531
|
+
{
|
|
2532
|
+
x: "7%",
|
|
2533
|
+
y: `${90 - x * 17}%`,
|
|
2534
|
+
textAnchor: "end",
|
|
2535
|
+
dominantBaseline: "middle",
|
|
2536
|
+
fill: k.axis,
|
|
2537
|
+
fontSize: "0.75rem",
|
|
2538
|
+
children: qe(d)
|
|
2539
|
+
}
|
|
2540
|
+
)
|
|
2541
|
+
] }, `y-${x}`))
|
|
2542
|
+
] }),
|
|
2543
|
+
h.filter((d) => d.visible !== !1).map((d) => {
|
|
2544
|
+
var x, C, N, I, W, g, M;
|
|
2545
|
+
return /* @__PURE__ */ u("g", { className: "nice-scientific-chart__annotation", children: [
|
|
2546
|
+
d.type === "text" && d.text && /* @__PURE__ */ o(
|
|
2547
|
+
"text",
|
|
2548
|
+
{
|
|
2549
|
+
x: `${10 + (d.position.x - S.xMin) / (S.xMax - S.xMin) * 85}%`,
|
|
2550
|
+
y: `${90 - (d.position.y - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2551
|
+
fill: ((x = d.style) == null ? void 0 : x.color) || k.text,
|
|
2552
|
+
fontSize: ((C = d.style) == null ? void 0 : C.fontSize) || 12,
|
|
2553
|
+
fontWeight: (N = d.style) == null ? void 0 : N.fontWeight,
|
|
2554
|
+
children: d.text
|
|
2555
|
+
}
|
|
2556
|
+
),
|
|
2557
|
+
d.type === "line" && /* @__PURE__ */ o(
|
|
2558
|
+
"line",
|
|
2559
|
+
{
|
|
2560
|
+
x1: `${10 + (d.position.x - S.xMin) / (S.xMax - S.xMin) * 85}%`,
|
|
2561
|
+
y1: `${90 - (d.position.y - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2562
|
+
x2: `${10 + (d.position.x2 - S.xMin) / (S.xMax - S.xMin) * 85}%`,
|
|
2563
|
+
y2: `${90 - (d.position.y2 - S.yMin) / (S.yMax - S.yMin) * 85}%`,
|
|
2564
|
+
stroke: ((I = d.style) == null ? void 0 : I.color) || k.text,
|
|
2565
|
+
strokeWidth: ((W = d.style) == null ? void 0 : W.lineWidth) || 1,
|
|
2566
|
+
strokeDasharray: ((g = d.style) == null ? void 0 : g.lineStyle) === "dashed" ? "5,5" : ((M = d.style) == null ? void 0 : M.lineStyle) === "dotted" ? "2,2" : void 0
|
|
2567
|
+
}
|
|
2568
|
+
)
|
|
2569
|
+
] }, d.id);
|
|
2570
|
+
})
|
|
2571
|
+
] }),
|
|
2572
|
+
m.enabled && Y && /* @__PURE__ */ o(
|
|
2573
|
+
"div",
|
|
2574
|
+
{
|
|
2575
|
+
className: "nice-scientific-chart__tooltip",
|
|
2576
|
+
style: {
|
|
2577
|
+
position: "absolute",
|
|
2578
|
+
padding: "0.5rem",
|
|
2579
|
+
background: k.tooltip,
|
|
2580
|
+
border: `1px solid ${k.grid}`,
|
|
2581
|
+
borderRadius: 4,
|
|
2582
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
2583
|
+
pointerEvents: "none",
|
|
2584
|
+
fontSize: "0.75rem"
|
|
2585
|
+
},
|
|
2586
|
+
children: (() => {
|
|
2587
|
+
const d = e.find((C) => C.id === Y.seriesId), x = d == null ? void 0 : d.data[Y.pointIndex];
|
|
2588
|
+
return !d || !x ? null : m.format ? m.format(x, d) : /* @__PURE__ */ u(Ae, { children: [
|
|
2589
|
+
/* @__PURE__ */ o("div", { style: { fontWeight: "bold" }, children: d.name }),
|
|
2590
|
+
/* @__PURE__ */ u("div", { children: [
|
|
2591
|
+
"X: ",
|
|
2592
|
+
x.x instanceof Date ? x.x.toISOString() : String(x.x)
|
|
2593
|
+
] }),
|
|
2594
|
+
/* @__PURE__ */ u("div", { children: [
|
|
2595
|
+
"Y: ",
|
|
2596
|
+
x.y.toFixed(4)
|
|
2597
|
+
] }),
|
|
2598
|
+
x.error && /* @__PURE__ */ u("div", { children: [
|
|
2599
|
+
"Error: ±",
|
|
2600
|
+
Array.isArray(x.error) ? `${x.error[0]}, +${x.error[1]}` : x.error
|
|
2601
|
+
] })
|
|
2602
|
+
] });
|
|
2603
|
+
})()
|
|
2604
|
+
}
|
|
2605
|
+
)
|
|
2606
|
+
]
|
|
2607
|
+
}
|
|
2608
|
+
),
|
|
2609
|
+
ee.some((d) => d.result) && /* @__PURE__ */ u(
|
|
2610
|
+
"div",
|
|
2611
|
+
{
|
|
2612
|
+
className: "nice-scientific-chart__stats",
|
|
2613
|
+
style: {
|
|
2614
|
+
padding: "0.5rem",
|
|
2615
|
+
fontSize: "0.75rem",
|
|
2616
|
+
borderTop: `1px solid ${k.grid}`
|
|
2617
|
+
},
|
|
2618
|
+
children: [
|
|
2619
|
+
/* @__PURE__ */ o("strong", { children: "Statistical Tests:" }),
|
|
2620
|
+
ee.filter((d) => d.result).map((d, x) => /* @__PURE__ */ u("div", { children: [
|
|
2621
|
+
d.type,
|
|
2622
|
+
": ",
|
|
2623
|
+
d.result.interpretation
|
|
2624
|
+
] }, x))
|
|
2625
|
+
]
|
|
2626
|
+
}
|
|
2627
|
+
),
|
|
2628
|
+
y.enabled && y.resetButton && (ye.x || ye.y) && /* @__PURE__ */ o(
|
|
2629
|
+
"button",
|
|
2630
|
+
{
|
|
2631
|
+
onClick: ie,
|
|
2632
|
+
style: {
|
|
2633
|
+
position: "absolute",
|
|
2634
|
+
top: 8,
|
|
2635
|
+
right: 8,
|
|
2636
|
+
padding: "0.25rem 0.5rem",
|
|
2637
|
+
fontSize: "0.75rem",
|
|
2638
|
+
background: k.bg,
|
|
2639
|
+
border: `1px solid ${k.grid}`,
|
|
2640
|
+
borderRadius: 4,
|
|
2641
|
+
cursor: "pointer"
|
|
2642
|
+
},
|
|
2643
|
+
children: "Reset Zoom"
|
|
2644
|
+
}
|
|
2645
|
+
),
|
|
2646
|
+
$ && $.formats.length > 0 && /* @__PURE__ */ u(
|
|
2647
|
+
"div",
|
|
2648
|
+
{
|
|
2649
|
+
className: "nice-scientific-chart__export",
|
|
2650
|
+
style: { padding: "0.5rem", borderTop: `1px solid ${k.grid}` },
|
|
2651
|
+
children: [
|
|
2652
|
+
/* @__PURE__ */ o("span", { style: { fontSize: "0.75rem", marginRight: "0.5rem" }, children: "Export:" }),
|
|
2653
|
+
$.formats.map((d) => /* @__PURE__ */ o(
|
|
2654
|
+
"button",
|
|
2655
|
+
{
|
|
2656
|
+
style: {
|
|
2657
|
+
marginRight: "0.25rem",
|
|
2658
|
+
padding: "0.25rem 0.5rem",
|
|
2659
|
+
fontSize: "0.75rem",
|
|
2660
|
+
background: "none",
|
|
2661
|
+
border: `1px solid ${k.grid}`,
|
|
2662
|
+
borderRadius: 4,
|
|
2663
|
+
cursor: "pointer"
|
|
2664
|
+
},
|
|
2665
|
+
children: d.toUpperCase()
|
|
2666
|
+
},
|
|
2667
|
+
d
|
|
2668
|
+
))
|
|
2669
|
+
]
|
|
2670
|
+
}
|
|
2671
|
+
)
|
|
2672
|
+
]
|
|
2673
|
+
}
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
const Pe = {
|
|
2677
|
+
rotationX: 25,
|
|
2678
|
+
rotationY: -45,
|
|
2679
|
+
rotationZ: 0,
|
|
2680
|
+
zoom: 1,
|
|
2681
|
+
panX: 0,
|
|
2682
|
+
panY: 0
|
|
2683
|
+
};
|
|
2684
|
+
function jt(e, t) {
|
|
2685
|
+
const n = t * Math.PI / 180, r = Math.cos(n), i = Math.sin(n);
|
|
2686
|
+
return {
|
|
2687
|
+
x: e.x,
|
|
2688
|
+
y: e.y * r - e.z * i,
|
|
2689
|
+
z: e.y * i + e.z * r
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
function Bt(e, t) {
|
|
2693
|
+
const n = t * Math.PI / 180, r = Math.cos(n), i = Math.sin(n);
|
|
2694
|
+
return {
|
|
2695
|
+
x: e.x * r + e.z * i,
|
|
2696
|
+
y: e.y,
|
|
2697
|
+
z: -e.x * i + e.z * r
|
|
2698
|
+
};
|
|
2699
|
+
}
|
|
2700
|
+
function Rt(e, t) {
|
|
2701
|
+
const n = t * Math.PI / 180, r = Math.cos(n), i = Math.sin(n);
|
|
2702
|
+
return {
|
|
2703
|
+
x: e.x * r - e.y * i,
|
|
2704
|
+
y: e.x * i + e.y * r,
|
|
2705
|
+
z: e.z
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
function Me(e, t, n) {
|
|
2709
|
+
let r = jt(e, n.rotationX);
|
|
2710
|
+
r = Bt(r, n.rotationY), r = Rt(r, n.rotationZ);
|
|
2711
|
+
const i = r.z + t, s = t / Math.max(i, 0.1);
|
|
2712
|
+
return {
|
|
2713
|
+
x: (r.x * s * n.zoom + n.panX) * 100 + 50,
|
|
2714
|
+
y: (-r.y * s * n.zoom + n.panY) * 100 + 50,
|
|
2715
|
+
depth: i
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
function ke(e, t, n, r) {
|
|
2719
|
+
const i = Math.max(0, Math.min(1, (e - t) / (n - t))), s = {
|
|
2720
|
+
viridis: [
|
|
2721
|
+
[68, 1, 84],
|
|
2722
|
+
[59, 82, 139],
|
|
2723
|
+
[33, 145, 140],
|
|
2724
|
+
[94, 201, 98],
|
|
2725
|
+
[253, 231, 37]
|
|
2726
|
+
],
|
|
2727
|
+
plasma: [
|
|
2728
|
+
[13, 8, 135],
|
|
2729
|
+
[126, 3, 168],
|
|
2730
|
+
[204, 71, 120],
|
|
2731
|
+
[248, 149, 64],
|
|
2732
|
+
[240, 249, 33]
|
|
2733
|
+
],
|
|
2734
|
+
inferno: [
|
|
2735
|
+
[0, 0, 4],
|
|
2736
|
+
[87, 16, 110],
|
|
2737
|
+
[188, 55, 84],
|
|
2738
|
+
[249, 142, 9],
|
|
2739
|
+
[252, 255, 164]
|
|
2740
|
+
],
|
|
2741
|
+
magma: [
|
|
2742
|
+
[0, 0, 4],
|
|
2743
|
+
[81, 18, 124],
|
|
2744
|
+
[183, 55, 121],
|
|
2745
|
+
[254, 159, 109],
|
|
2746
|
+
[252, 253, 191]
|
|
2747
|
+
],
|
|
2748
|
+
cividis: [
|
|
2749
|
+
[0, 32, 77],
|
|
2750
|
+
[57, 86, 109],
|
|
2751
|
+
[128, 133, 121],
|
|
2752
|
+
[200, 178, 107],
|
|
2753
|
+
[253, 231, 55]
|
|
2754
|
+
],
|
|
2755
|
+
jet: [
|
|
2756
|
+
[0, 0, 127],
|
|
2757
|
+
[0, 0, 255],
|
|
2758
|
+
[0, 255, 255],
|
|
2759
|
+
[255, 255, 0],
|
|
2760
|
+
[255, 0, 0],
|
|
2761
|
+
[127, 0, 0]
|
|
2762
|
+
],
|
|
2763
|
+
rainbow: [
|
|
2764
|
+
[150, 0, 90],
|
|
2765
|
+
[0, 0, 200],
|
|
2766
|
+
[0, 200, 200],
|
|
2767
|
+
[0, 200, 0],
|
|
2768
|
+
[200, 200, 0],
|
|
2769
|
+
[200, 0, 0]
|
|
2770
|
+
],
|
|
2771
|
+
coolwarm: [
|
|
2772
|
+
[59, 76, 192],
|
|
2773
|
+
[98, 130, 234],
|
|
2774
|
+
[221, 221, 221],
|
|
2775
|
+
[220, 170, 132],
|
|
2776
|
+
[180, 4, 38]
|
|
2777
|
+
],
|
|
2778
|
+
RdBu: [
|
|
2779
|
+
[103, 0, 31],
|
|
2780
|
+
[178, 24, 43],
|
|
2781
|
+
[244, 165, 130],
|
|
2782
|
+
[247, 247, 247],
|
|
2783
|
+
[146, 197, 222],
|
|
2784
|
+
[33, 102, 172],
|
|
2785
|
+
[5, 48, 97]
|
|
2786
|
+
],
|
|
2787
|
+
spectral: [
|
|
2788
|
+
[158, 1, 66],
|
|
2789
|
+
[213, 62, 79],
|
|
2790
|
+
[253, 174, 97],
|
|
2791
|
+
[255, 255, 191],
|
|
2792
|
+
[171, 221, 164],
|
|
2793
|
+
[43, 131, 186],
|
|
2794
|
+
[94, 79, 162]
|
|
2795
|
+
],
|
|
2796
|
+
turbo: [
|
|
2797
|
+
[48, 18, 59],
|
|
2798
|
+
[86, 121, 245],
|
|
2799
|
+
[51, 185, 131],
|
|
2800
|
+
[192, 212, 49],
|
|
2801
|
+
[249, 141, 10],
|
|
2802
|
+
[122, 4, 3]
|
|
2803
|
+
],
|
|
2804
|
+
grayscale: [
|
|
2805
|
+
[0, 0, 0],
|
|
2806
|
+
[255, 255, 255]
|
|
2807
|
+
]
|
|
2808
|
+
}, a = s[r] || s.viridis, l = i * (a.length - 1), c = Math.floor(l), h = l - c;
|
|
2809
|
+
if (c >= a.length - 1) {
|
|
2810
|
+
const j = a[a.length - 1];
|
|
2811
|
+
return `rgb(${j[0]}, ${j[1]}, ${j[2]})`;
|
|
2812
|
+
}
|
|
2813
|
+
const p = a[c], m = a[c + 1], y = Math.round(p[0] + h * (m[0] - p[0])), $ = Math.round(p[1] + h * (m[1] - p[1])), w = Math.round(p[2] + h * (m[2] - p[2]));
|
|
2814
|
+
return `rgb(${y}, ${$}, ${w})`;
|
|
2815
|
+
}
|
|
2816
|
+
function nn({
|
|
2817
|
+
data: e,
|
|
2818
|
+
title: t,
|
|
2819
|
+
width: n = "100%",
|
|
2820
|
+
height: r = 500,
|
|
2821
|
+
scene: i = {},
|
|
2822
|
+
showColorBar: s = !0,
|
|
2823
|
+
animation: a,
|
|
2824
|
+
showLegend: l = !0,
|
|
2825
|
+
legendPosition: c = "top-right",
|
|
2826
|
+
enableRotation: h = !0,
|
|
2827
|
+
enableZoom: p = !0,
|
|
2828
|
+
enablePan: m = !0,
|
|
2829
|
+
showAxes: y = !0,
|
|
2830
|
+
showAxisLabels: $ = !0,
|
|
2831
|
+
focalLength: w = 3,
|
|
2832
|
+
theme: j = "light",
|
|
2833
|
+
onCameraChange: J,
|
|
2834
|
+
onPointClick: te,
|
|
2835
|
+
onPointHover: V,
|
|
2836
|
+
className: L,
|
|
2837
|
+
style: H
|
|
2838
|
+
}) {
|
|
2839
|
+
const oe = ze(null), [U, de] = E(Pe), [pe, se] = E(!1), [ne, _] = E(
|
|
2840
|
+
null
|
|
2841
|
+
), [ce, ue] = E(
|
|
2842
|
+
null
|
|
2843
|
+
), [ye, xe] = E(0), Y = K(() => {
|
|
2844
|
+
let z = 1 / 0, k = -1 / 0, d = 1 / 0, x = -1 / 0, C = 1 / 0, N = -1 / 0, I = 1 / 0, W = -1 / 0;
|
|
2845
|
+
for (const M of e)
|
|
2846
|
+
if (M.type === "scatter3d")
|
|
2847
|
+
for (const A of M.points)
|
|
2848
|
+
z = Math.min(z, A.x), k = Math.max(k, A.x), d = Math.min(d, A.y), x = Math.max(x, A.y), C = Math.min(C, A.z), N = Math.max(N, A.z), typeof A.color == "number" && (I = Math.min(I, A.color), W = Math.max(W, A.color));
|
|
2849
|
+
else if (M.type === "surface" || M.type === "wireframe") {
|
|
2850
|
+
const A = M;
|
|
2851
|
+
for (const O of A.xData)
|
|
2852
|
+
z = Math.min(z, O), k = Math.max(k, O);
|
|
2853
|
+
for (const O of A.yData)
|
|
2854
|
+
d = Math.min(d, O), x = Math.max(x, O);
|
|
2855
|
+
for (const O of A.zData)
|
|
2856
|
+
for (const X of O)
|
|
2857
|
+
C = Math.min(C, X), N = Math.max(N, X), I = Math.min(I, X), W = Math.max(W, X);
|
|
2858
|
+
}
|
|
2859
|
+
const g = Math.max(k - z, x - d, N - C) || 1;
|
|
2860
|
+
return { xMin: z, xMax: k, yMin: d, yMax: x, zMin: C, zMax: N, colorMin: I, colorMax: W, maxRange: g };
|
|
2861
|
+
}, [e]), Z = P(
|
|
2862
|
+
(z) => {
|
|
2863
|
+
const k = 2 / Y.maxRange;
|
|
2864
|
+
return {
|
|
2865
|
+
x: (z.x - (Y.xMin + Y.xMax) / 2) * k,
|
|
2866
|
+
y: (z.y - (Y.yMin + Y.yMax) / 2) * k,
|
|
2867
|
+
z: (z.z - (Y.zMin + Y.zMax) / 2) * k
|
|
2868
|
+
};
|
|
2869
|
+
},
|
|
2870
|
+
[Y]
|
|
2871
|
+
), ae = P(
|
|
2872
|
+
(z) => {
|
|
2873
|
+
!h && !m || (se(!0), _({ x: z.clientX, y: z.clientY, viewState: { ...U } }));
|
|
2874
|
+
},
|
|
2875
|
+
[h, m, U]
|
|
2876
|
+
), G = P(
|
|
2877
|
+
(z) => {
|
|
2878
|
+
if (!pe || !ne)
|
|
2879
|
+
return;
|
|
2880
|
+
const k = z.clientX - ne.x, d = z.clientY - ne.y;
|
|
2881
|
+
z.shiftKey && m ? de({
|
|
2882
|
+
...ne.viewState,
|
|
2883
|
+
panX: ne.viewState.panX + k * 2e-3,
|
|
2884
|
+
panY: ne.viewState.panY + d * 2e-3
|
|
2885
|
+
}) : h && de({
|
|
2886
|
+
...ne.viewState,
|
|
2887
|
+
rotationY: ne.viewState.rotationY + k * 0.5,
|
|
2888
|
+
rotationX: ne.viewState.rotationX + d * 0.5
|
|
2889
|
+
});
|
|
2890
|
+
},
|
|
2891
|
+
[pe, ne, h, m]
|
|
2892
|
+
), S = P(() => {
|
|
2893
|
+
se(!1), _(null);
|
|
2894
|
+
}, []), Q = P(
|
|
2895
|
+
(z) => {
|
|
2896
|
+
if (!p)
|
|
2897
|
+
return;
|
|
2898
|
+
z.preventDefault();
|
|
2899
|
+
const k = z.deltaY > 0 ? 0.9 : 1.1;
|
|
2900
|
+
de((d) => ({
|
|
2901
|
+
...d,
|
|
2902
|
+
zoom: Math.max(0.1, Math.min(10, d.zoom * k))
|
|
2903
|
+
}));
|
|
2904
|
+
},
|
|
2905
|
+
[p]
|
|
2906
|
+
), ee = K(() => {
|
|
2907
|
+
switch (j) {
|
|
2908
|
+
case "dark":
|
|
2909
|
+
return { bg: "#1a1a2e", text: "#e0e0e0", axis: "#555", grid: "#333" };
|
|
2910
|
+
case "scientific":
|
|
2911
|
+
return { bg: "#f8f8f8", text: "#333", axis: "#666", grid: "#ddd" };
|
|
2912
|
+
default:
|
|
2913
|
+
return { bg: "#ffffff", text: "#333", axis: "#888", grid: "#e0e0e0" };
|
|
2914
|
+
}
|
|
2915
|
+
}, [j]), re = K(() => {
|
|
2916
|
+
var k;
|
|
2917
|
+
const z = [];
|
|
2918
|
+
for (const d of e)
|
|
2919
|
+
if (d.type === "scatter3d") {
|
|
2920
|
+
const x = d, C = x.points.map((N) => {
|
|
2921
|
+
var A, O, X, le, fe;
|
|
2922
|
+
const I = Z(N), W = Me(I, w, U);
|
|
2923
|
+
let g = (A = x.marker) == null ? void 0 : A.color;
|
|
2924
|
+
if (Array.isArray((O = x.marker) == null ? void 0 : O.color)) {
|
|
2925
|
+
const be = x.points.indexOf(N);
|
|
2926
|
+
g = ke(
|
|
2927
|
+
x.marker.color[be],
|
|
2928
|
+
Y.colorMin,
|
|
2929
|
+
Y.colorMax,
|
|
2930
|
+
((X = x.marker) == null ? void 0 : X.colorScale) || "viridis"
|
|
2931
|
+
);
|
|
2932
|
+
} else typeof N.color == "number" && (g = ke(
|
|
2933
|
+
N.color,
|
|
2934
|
+
Y.colorMin,
|
|
2935
|
+
Y.colorMax,
|
|
2936
|
+
((le = x.marker) == null ? void 0 : le.colorScale) || "viridis"
|
|
2937
|
+
));
|
|
2938
|
+
const M = Array.isArray(N.size) ? N.size[0] : N.size || ((fe = x.marker) == null ? void 0 : fe.size) || 5;
|
|
2939
|
+
return {
|
|
2940
|
+
...W,
|
|
2941
|
+
color: g,
|
|
2942
|
+
size: M,
|
|
2943
|
+
original: N
|
|
2944
|
+
};
|
|
2945
|
+
});
|
|
2946
|
+
z.push({ type: "scatter", points: C, data: d });
|
|
2947
|
+
} else if (d.type === "surface" || d.type === "wireframe") {
|
|
2948
|
+
const x = d, C = [];
|
|
2949
|
+
for (let N = 0; N < x.xData.length; N++)
|
|
2950
|
+
for (let I = 0; I < x.yData.length; I++) {
|
|
2951
|
+
const W = {
|
|
2952
|
+
x: x.xData[N],
|
|
2953
|
+
y: x.yData[I],
|
|
2954
|
+
z: x.zData[N][I]
|
|
2955
|
+
}, g = Z(W), M = Me(g, w, U), A = ke(
|
|
2956
|
+
((k = x.colorData) == null ? void 0 : k[N][I]) ?? x.zData[N][I],
|
|
2957
|
+
Y.colorMin,
|
|
2958
|
+
Y.colorMax,
|
|
2959
|
+
x.colorScale || "viridis"
|
|
2960
|
+
);
|
|
2961
|
+
C.push({ ...M, color: A, size: 3, original: W });
|
|
2962
|
+
}
|
|
2963
|
+
z.push({ type: d.type, points: C, data: d });
|
|
2964
|
+
}
|
|
2965
|
+
for (const d of z)
|
|
2966
|
+
d.points.sort((x, C) => x.depth - C.depth);
|
|
2967
|
+
return z;
|
|
2968
|
+
}, [e, U, w, Z, Y]), ie = K(() => {
|
|
2969
|
+
var d, x, C;
|
|
2970
|
+
if (!y)
|
|
2971
|
+
return null;
|
|
2972
|
+
const z = 1.2, k = {
|
|
2973
|
+
x: [
|
|
2974
|
+
Me({ x: -z, y: 0, z: 0 }, w, U),
|
|
2975
|
+
Me({ x: z, y: 0, z: 0 }, w, U)
|
|
2976
|
+
],
|
|
2977
|
+
y: [
|
|
2978
|
+
Me({ x: 0, y: -z, z: 0 }, w, U),
|
|
2979
|
+
Me({ x: 0, y: z, z: 0 }, w, U)
|
|
2980
|
+
],
|
|
2981
|
+
z: [
|
|
2982
|
+
Me({ x: 0, y: 0, z: -z }, w, U),
|
|
2983
|
+
Me({ x: 0, y: 0, z }, w, U)
|
|
2984
|
+
]
|
|
2985
|
+
};
|
|
2986
|
+
return /* @__PURE__ */ u("g", { className: "nice-3d-plot__axes", children: [
|
|
2987
|
+
/* @__PURE__ */ o(
|
|
2988
|
+
"line",
|
|
2989
|
+
{
|
|
2990
|
+
x1: `${k.x[0].x}%`,
|
|
2991
|
+
y1: `${k.x[0].y}%`,
|
|
2992
|
+
x2: `${k.x[1].x}%`,
|
|
2993
|
+
y2: `${k.x[1].y}%`,
|
|
2994
|
+
stroke: "#e74c3c",
|
|
2995
|
+
strokeWidth: 1.5
|
|
2996
|
+
}
|
|
2997
|
+
),
|
|
2998
|
+
$ && /* @__PURE__ */ o(
|
|
2999
|
+
"text",
|
|
3000
|
+
{
|
|
3001
|
+
x: `${k.x[1].x + 2}%`,
|
|
3002
|
+
y: `${k.x[1].y}%`,
|
|
3003
|
+
fill: "#e74c3c",
|
|
3004
|
+
fontSize: "12",
|
|
3005
|
+
children: ((d = i.xAxis) == null ? void 0 : d.title) || "X"
|
|
3006
|
+
}
|
|
3007
|
+
),
|
|
3008
|
+
/* @__PURE__ */ o(
|
|
3009
|
+
"line",
|
|
3010
|
+
{
|
|
3011
|
+
x1: `${k.y[0].x}%`,
|
|
3012
|
+
y1: `${k.y[0].y}%`,
|
|
3013
|
+
x2: `${k.y[1].x}%`,
|
|
3014
|
+
y2: `${k.y[1].y}%`,
|
|
3015
|
+
stroke: "#2ecc71",
|
|
3016
|
+
strokeWidth: 1.5
|
|
3017
|
+
}
|
|
3018
|
+
),
|
|
3019
|
+
$ && /* @__PURE__ */ o(
|
|
3020
|
+
"text",
|
|
3021
|
+
{
|
|
3022
|
+
x: `${k.y[1].x}%`,
|
|
3023
|
+
y: `${k.y[1].y - 2}%`,
|
|
3024
|
+
fill: "#2ecc71",
|
|
3025
|
+
fontSize: "12",
|
|
3026
|
+
textAnchor: "middle",
|
|
3027
|
+
children: ((x = i.yAxis) == null ? void 0 : x.title) || "Y"
|
|
3028
|
+
}
|
|
3029
|
+
),
|
|
3030
|
+
/* @__PURE__ */ o(
|
|
3031
|
+
"line",
|
|
3032
|
+
{
|
|
3033
|
+
x1: `${k.z[0].x}%`,
|
|
3034
|
+
y1: `${k.z[0].y}%`,
|
|
3035
|
+
x2: `${k.z[1].x}%`,
|
|
3036
|
+
y2: `${k.z[1].y}%`,
|
|
3037
|
+
stroke: "#3498db",
|
|
3038
|
+
strokeWidth: 1.5
|
|
3039
|
+
}
|
|
3040
|
+
),
|
|
3041
|
+
$ && /* @__PURE__ */ o(
|
|
3042
|
+
"text",
|
|
3043
|
+
{
|
|
3044
|
+
x: `${k.z[1].x + 2}%`,
|
|
3045
|
+
y: `${k.z[1].y}%`,
|
|
3046
|
+
fill: "#3498db",
|
|
3047
|
+
fontSize: "12",
|
|
3048
|
+
children: ((C = i.zAxis) == null ? void 0 : C.title) || "Z"
|
|
3049
|
+
}
|
|
3050
|
+
)
|
|
3051
|
+
] });
|
|
3052
|
+
}, [y, $, U, w, i]);
|
|
3053
|
+
return /* @__PURE__ */ u(
|
|
3054
|
+
"div",
|
|
3055
|
+
{
|
|
3056
|
+
ref: oe,
|
|
3057
|
+
className: `nice-3d-plot nice-3d-plot--${j} ${L || ""}`,
|
|
3058
|
+
style: {
|
|
3059
|
+
width: n,
|
|
3060
|
+
height: r,
|
|
3061
|
+
backgroundColor: ee.bg,
|
|
3062
|
+
color: ee.text,
|
|
3063
|
+
position: "relative",
|
|
3064
|
+
overflow: "hidden",
|
|
3065
|
+
userSelect: "none",
|
|
3066
|
+
cursor: pe ? "grabbing" : "grab",
|
|
3067
|
+
...H
|
|
3068
|
+
},
|
|
3069
|
+
onMouseDown: ae,
|
|
3070
|
+
onMouseMove: G,
|
|
3071
|
+
onMouseUp: S,
|
|
3072
|
+
onMouseLeave: S,
|
|
3073
|
+
onWheel: Q,
|
|
3074
|
+
children: [
|
|
3075
|
+
t && /* @__PURE__ */ o(
|
|
3076
|
+
"div",
|
|
3077
|
+
{
|
|
3078
|
+
style: { position: "absolute", top: 8, left: 8, fontWeight: "bold", fontSize: "1.1rem" },
|
|
3079
|
+
children: t
|
|
3080
|
+
}
|
|
3081
|
+
),
|
|
3082
|
+
/* @__PURE__ */ u("svg", { width: "100%", height: "100%", style: { position: "absolute", top: 0, left: 0 }, children: [
|
|
3083
|
+
ie,
|
|
3084
|
+
re.map((z, k) => /* @__PURE__ */ u("g", { className: "nice-3d-plot__data", children: [
|
|
3085
|
+
z.type === "scatter" && z.points.map((d, x) => {
|
|
3086
|
+
var C;
|
|
3087
|
+
return /* @__PURE__ */ o(
|
|
3088
|
+
"circle",
|
|
3089
|
+
{
|
|
3090
|
+
cx: `${d.x}%`,
|
|
3091
|
+
cy: `${d.y}%`,
|
|
3092
|
+
r: d.size || 4,
|
|
3093
|
+
fill: d.color || "#3498db",
|
|
3094
|
+
opacity: ((C = z.data.marker) == null ? void 0 : C.opacity) ?? 0.8,
|
|
3095
|
+
style: { cursor: te ? "pointer" : void 0 },
|
|
3096
|
+
onMouseEnter: () => {
|
|
3097
|
+
ue({ point: d.original, dataIndex: k }), V == null || V(d.original, k);
|
|
3098
|
+
},
|
|
3099
|
+
onMouseLeave: () => {
|
|
3100
|
+
ue(null), V == null || V(null, k);
|
|
3101
|
+
},
|
|
3102
|
+
onClick: () => te == null ? void 0 : te(d.original, k)
|
|
3103
|
+
},
|
|
3104
|
+
x
|
|
3105
|
+
);
|
|
3106
|
+
}),
|
|
3107
|
+
(z.type === "surface" || z.type === "wireframe") && z.points.map((d, x) => /* @__PURE__ */ o(
|
|
3108
|
+
"rect",
|
|
3109
|
+
{
|
|
3110
|
+
x: `${d.x - 1}%`,
|
|
3111
|
+
y: `${d.y - 1}%`,
|
|
3112
|
+
width: "2%",
|
|
3113
|
+
height: "2%",
|
|
3114
|
+
fill: d.color || "#3498db",
|
|
3115
|
+
opacity: z.data.opacity ?? 0.7
|
|
3116
|
+
},
|
|
3117
|
+
x
|
|
3118
|
+
))
|
|
3119
|
+
] }, z.data.id || k))
|
|
3120
|
+
] }),
|
|
3121
|
+
l && e.length > 1 && /* @__PURE__ */ o(
|
|
3122
|
+
"div",
|
|
3123
|
+
{
|
|
3124
|
+
style: {
|
|
3125
|
+
position: "absolute",
|
|
3126
|
+
padding: "8px",
|
|
3127
|
+
background: "rgba(255,255,255,0.9)",
|
|
3128
|
+
borderRadius: 4,
|
|
3129
|
+
fontSize: "0.8rem",
|
|
3130
|
+
...c === "top-right" && { top: 8, right: 8 },
|
|
3131
|
+
...c === "top-left" && { top: 8, left: 8 },
|
|
3132
|
+
...c === "bottom-right" && { bottom: 8, right: 8 },
|
|
3133
|
+
...c === "bottom-left" && { bottom: 8, left: 8 }
|
|
3134
|
+
},
|
|
3135
|
+
children: e.map((z, k) => /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
3136
|
+
/* @__PURE__ */ o("span", { style: { width: 12, height: 12, background: "#3498db", borderRadius: 2 } }),
|
|
3137
|
+
z.name
|
|
3138
|
+
] }, z.id || k))
|
|
3139
|
+
}
|
|
3140
|
+
),
|
|
3141
|
+
s && /* @__PURE__ */ u(
|
|
3142
|
+
"div",
|
|
3143
|
+
{
|
|
3144
|
+
style: {
|
|
3145
|
+
position: "absolute",
|
|
3146
|
+
right: 16,
|
|
3147
|
+
top: "50%",
|
|
3148
|
+
transform: "translateY(-50%)",
|
|
3149
|
+
width: 16,
|
|
3150
|
+
height: 150,
|
|
3151
|
+
background: `linear-gradient(to top, ${ke(0, 0, 1, "viridis")}, ${ke(0.5, 0, 1, "viridis")}, ${ke(1, 0, 1, "viridis")})`,
|
|
3152
|
+
borderRadius: 2,
|
|
3153
|
+
border: "1px solid #ccc"
|
|
3154
|
+
},
|
|
3155
|
+
children: [
|
|
3156
|
+
/* @__PURE__ */ o("div", { style: { position: "absolute", top: -16, right: 20, fontSize: "0.7rem" }, children: Y.colorMax.toFixed(2) }),
|
|
3157
|
+
/* @__PURE__ */ o("div", { style: { position: "absolute", bottom: -16, right: 20, fontSize: "0.7rem" }, children: Y.colorMin.toFixed(2) })
|
|
3158
|
+
]
|
|
3159
|
+
}
|
|
3160
|
+
),
|
|
3161
|
+
ce && /* @__PURE__ */ u(
|
|
3162
|
+
"div",
|
|
3163
|
+
{
|
|
3164
|
+
style: {
|
|
3165
|
+
position: "absolute",
|
|
3166
|
+
bottom: 8,
|
|
3167
|
+
left: 8,
|
|
3168
|
+
background: "rgba(0,0,0,0.8)",
|
|
3169
|
+
color: "#fff",
|
|
3170
|
+
padding: "4px 8px",
|
|
3171
|
+
borderRadius: 4,
|
|
3172
|
+
fontSize: "0.75rem"
|
|
3173
|
+
},
|
|
3174
|
+
children: [
|
|
3175
|
+
"X: ",
|
|
3176
|
+
ce.point.x.toFixed(4),
|
|
3177
|
+
", Y: ",
|
|
3178
|
+
ce.point.y.toFixed(4),
|
|
3179
|
+
", Z:",
|
|
3180
|
+
" ",
|
|
3181
|
+
ce.point.z.toFixed(4)
|
|
3182
|
+
]
|
|
3183
|
+
}
|
|
3184
|
+
),
|
|
3185
|
+
/* @__PURE__ */ o("div", { style: { position: "absolute", bottom: 8, right: 8, display: "flex", gap: 4 }, children: /* @__PURE__ */ o(
|
|
3186
|
+
"button",
|
|
3187
|
+
{
|
|
3188
|
+
onClick: () => de(Pe),
|
|
3189
|
+
style: { padding: "4px 8px", fontSize: "0.75rem", cursor: "pointer" },
|
|
3190
|
+
children: "Reset View"
|
|
3191
|
+
}
|
|
3192
|
+
) })
|
|
3193
|
+
]
|
|
3194
|
+
}
|
|
3195
|
+
);
|
|
3196
|
+
}
|
|
3197
|
+
const tt = {
|
|
3198
|
+
H: "#FFFFFF",
|
|
3199
|
+
C: "#909090",
|
|
3200
|
+
N: "#3050F8",
|
|
3201
|
+
O: "#FF0D0D",
|
|
3202
|
+
S: "#FFFF30",
|
|
3203
|
+
P: "#FF8000",
|
|
3204
|
+
F: "#90E050",
|
|
3205
|
+
Cl: "#1FF01F",
|
|
3206
|
+
Br: "#A62929",
|
|
3207
|
+
I: "#940094",
|
|
3208
|
+
He: "#D9FFFF",
|
|
3209
|
+
Ne: "#B3E3F5",
|
|
3210
|
+
Ar: "#80D1E3",
|
|
3211
|
+
Kr: "#5CB8D1",
|
|
3212
|
+
Xe: "#429EB0",
|
|
3213
|
+
Li: "#CC80FF",
|
|
3214
|
+
Na: "#AB5CF2",
|
|
3215
|
+
K: "#8F40D4",
|
|
3216
|
+
Rb: "#702EB0",
|
|
3217
|
+
Cs: "#57178F",
|
|
3218
|
+
Be: "#C2FF00",
|
|
3219
|
+
Mg: "#8AFF00",
|
|
3220
|
+
Ca: "#3DFF00",
|
|
3221
|
+
Sr: "#00FF00",
|
|
3222
|
+
Ba: "#00C900",
|
|
3223
|
+
B: "#FFB5B5",
|
|
3224
|
+
Al: "#BFA6A6",
|
|
3225
|
+
Ga: "#C28F8F",
|
|
3226
|
+
In: "#A67573",
|
|
3227
|
+
Tl: "#A6544D",
|
|
3228
|
+
Si: "#F0C8A0",
|
|
3229
|
+
Ge: "#668F8F",
|
|
3230
|
+
Sn: "#668080",
|
|
3231
|
+
Pb: "#575961",
|
|
3232
|
+
As: "#BD80E3",
|
|
3233
|
+
Sb: "#9E63B5",
|
|
3234
|
+
Bi: "#9E4FB5",
|
|
3235
|
+
Se: "#FFA100",
|
|
3236
|
+
Te: "#D47A00",
|
|
3237
|
+
Po: "#AB5C00",
|
|
3238
|
+
Fe: "#E06633",
|
|
3239
|
+
Co: "#F090A0",
|
|
3240
|
+
Ni: "#50D050",
|
|
3241
|
+
Cu: "#C88033",
|
|
3242
|
+
Zn: "#7D80B0",
|
|
3243
|
+
Mn: "#9C7AC7",
|
|
3244
|
+
Cr: "#8A99C7",
|
|
3245
|
+
V: "#A6A6AB",
|
|
3246
|
+
Ti: "#BFC2C7",
|
|
3247
|
+
Sc: "#E6E6E6",
|
|
3248
|
+
Au: "#FFD123",
|
|
3249
|
+
Ag: "#C0C0C0",
|
|
3250
|
+
Pt: "#D0D0E0",
|
|
3251
|
+
Pd: "#006985",
|
|
3252
|
+
Ru: "#248F8F",
|
|
3253
|
+
Rh: "#0A7D8C",
|
|
3254
|
+
Os: "#266696",
|
|
3255
|
+
Ir: "#175487"
|
|
3256
|
+
}, je = {
|
|
3257
|
+
H: 0.31,
|
|
3258
|
+
C: 0.77,
|
|
3259
|
+
N: 0.71,
|
|
3260
|
+
O: 0.66,
|
|
3261
|
+
S: 1.05,
|
|
3262
|
+
P: 1.07,
|
|
3263
|
+
F: 0.57,
|
|
3264
|
+
Cl: 1.02,
|
|
3265
|
+
Br: 1.2,
|
|
3266
|
+
I: 1.39,
|
|
3267
|
+
He: 0.28,
|
|
3268
|
+
Ne: 0.58,
|
|
3269
|
+
Ar: 1.06,
|
|
3270
|
+
Li: 1.28,
|
|
3271
|
+
Na: 1.66,
|
|
3272
|
+
K: 2.03,
|
|
3273
|
+
Mg: 1.41,
|
|
3274
|
+
Ca: 1.76,
|
|
3275
|
+
Fe: 1.26,
|
|
3276
|
+
Zn: 1.22,
|
|
3277
|
+
Cu: 1.28,
|
|
3278
|
+
Ni: 1.24
|
|
3279
|
+
}, Lt = {
|
|
3280
|
+
H: 1.2,
|
|
3281
|
+
C: 1.7,
|
|
3282
|
+
N: 1.55,
|
|
3283
|
+
O: 1.52,
|
|
3284
|
+
S: 1.8,
|
|
3285
|
+
P: 1.8,
|
|
3286
|
+
F: 1.47,
|
|
3287
|
+
Cl: 1.75,
|
|
3288
|
+
Br: 1.85,
|
|
3289
|
+
I: 1.98,
|
|
3290
|
+
He: 1.4,
|
|
3291
|
+
Ne: 1.54,
|
|
3292
|
+
Ar: 1.88,
|
|
3293
|
+
Li: 1.82,
|
|
3294
|
+
Na: 2.27,
|
|
3295
|
+
K: 2.75,
|
|
3296
|
+
Mg: 1.73,
|
|
3297
|
+
Ca: 2.31,
|
|
3298
|
+
Fe: 2,
|
|
3299
|
+
Zn: 1.39,
|
|
3300
|
+
Cu: 1.4,
|
|
3301
|
+
Ni: 1.63
|
|
3302
|
+
};
|
|
3303
|
+
function Ve(e) {
|
|
3304
|
+
const t = [], n = [], r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
3305
|
+
let s = "Unknown";
|
|
3306
|
+
const a = e.split(`
|
|
3307
|
+
`);
|
|
3308
|
+
for (const l of a) {
|
|
3309
|
+
const c = l.substring(0, 6).trim();
|
|
3310
|
+
if (c === "HEADER")
|
|
3311
|
+
s = l.substring(10, 50).trim() || s;
|
|
3312
|
+
else if (c === "ATOM" || c === "HETATM") {
|
|
3313
|
+
const h = parseInt(l.substring(6, 11).trim(), 10), p = l.substring(12, 16).trim(), m = l.substring(17, 20).trim(), y = l.substring(21, 22).trim() || "A", $ = parseInt(l.substring(22, 26).trim(), 10), w = parseFloat(l.substring(30, 38).trim()), j = parseFloat(l.substring(38, 46).trim()), J = parseFloat(l.substring(46, 54).trim()), te = parseFloat(l.substring(54, 60).trim()) || 1, V = parseFloat(l.substring(60, 66).trim()) || 0, L = l.substring(76, 78).trim() || p.replace(/\d/g, "").substring(0, 1), H = {
|
|
3314
|
+
id: t.length,
|
|
3315
|
+
serial: h,
|
|
3316
|
+
name: p,
|
|
3317
|
+
element: L.toUpperCase(),
|
|
3318
|
+
residueName: m,
|
|
3319
|
+
residueSeq: $,
|
|
3320
|
+
chainId: y,
|
|
3321
|
+
x: w,
|
|
3322
|
+
y: j,
|
|
3323
|
+
z: J,
|
|
3324
|
+
occupancy: te,
|
|
3325
|
+
bFactor: V,
|
|
3326
|
+
color: tt[L.toUpperCase()] || "#808080",
|
|
3327
|
+
radius: je[L.toUpperCase()] || 1.5
|
|
3328
|
+
};
|
|
3329
|
+
t.push(H);
|
|
3330
|
+
const oe = `${y}_${$}_${m}`;
|
|
3331
|
+
r.has(oe) || r.set(oe, {
|
|
3332
|
+
id: r.size,
|
|
3333
|
+
name: m,
|
|
3334
|
+
seq: $,
|
|
3335
|
+
chainId: y,
|
|
3336
|
+
atoms: []
|
|
3337
|
+
}), r.get(oe).atoms.push(H.id), i.has(y) || i.set(y, { id: y, residues: [] });
|
|
3338
|
+
} else if (c === "CONECT") {
|
|
3339
|
+
const h = l.substring(6).trim().split(/\s+/).map(Number), p = h[0], m = t.find((y) => y.serial === p);
|
|
3340
|
+
if (m)
|
|
3341
|
+
for (let y = 1; y < h.length; y++) {
|
|
3342
|
+
const $ = h[y], w = t.find((j) => j.serial === $);
|
|
3343
|
+
w && m.id < w.id && n.push({
|
|
3344
|
+
id: n.length,
|
|
3345
|
+
atom1: m.id,
|
|
3346
|
+
atom2: w.id,
|
|
3347
|
+
order: 1
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
if (n.length === 0)
|
|
3353
|
+
for (let l = 0; l < t.length; l++)
|
|
3354
|
+
for (let c = l + 1; c < t.length; c++) {
|
|
3355
|
+
const h = t[l], p = t[c], m = h.x - p.x, y = h.y - p.y, $ = h.z - p.z, w = Math.sqrt(m * m + y * y + $ * $), j = (je[h.element] || 1.5) + (je[p.element] || 1.5) + 0.4;
|
|
3356
|
+
w < j && w > 0.4 && n.push({
|
|
3357
|
+
id: n.length,
|
|
3358
|
+
atom1: l,
|
|
3359
|
+
atom2: c,
|
|
3360
|
+
order: 1,
|
|
3361
|
+
length: w
|
|
3362
|
+
});
|
|
3363
|
+
}
|
|
3364
|
+
return {
|
|
3365
|
+
id: "mol_" + Date.now(),
|
|
3366
|
+
name: s,
|
|
3367
|
+
atoms: t,
|
|
3368
|
+
bonds: n,
|
|
3369
|
+
residues: Array.from(r.values()),
|
|
3370
|
+
chains: Array.from(i.values())
|
|
3371
|
+
};
|
|
3372
|
+
}
|
|
3373
|
+
function Wt(e, t, n, r, i, s) {
|
|
3374
|
+
const a = ($) => $ * Math.PI / 180, l = t * Math.cos(a(r)) - n * Math.sin(a(r)), c = t * Math.sin(a(r)) + n * Math.cos(a(r)), h = e * Math.cos(a(i)) + c * Math.sin(a(i)), p = -e * Math.sin(a(i)) + c * Math.cos(a(i)), m = h * Math.cos(a(s)) - l * Math.sin(a(s)), y = h * Math.sin(a(s)) + l * Math.cos(a(s));
|
|
3375
|
+
return [m, y, p];
|
|
3376
|
+
}
|
|
3377
|
+
function Ee(e, t, n, r, i, s) {
|
|
3378
|
+
const a = e - i.x, l = t - i.y, c = n - i.z, [h, p, m] = Wt(a, l, c, r.rotX, r.rotY, r.rotZ), y = 500, $ = y / (y + m * 50);
|
|
3379
|
+
return {
|
|
3380
|
+
x: 50 + h * s * r.zoom * $ + r.panX,
|
|
3381
|
+
y: 50 - p * s * r.zoom * $ + r.panY,
|
|
3382
|
+
depth: m
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
function rn({
|
|
3386
|
+
molecule: e,
|
|
3387
|
+
format: t = "pdb",
|
|
3388
|
+
style: n = "ball-stick",
|
|
3389
|
+
colorScheme: r = "element",
|
|
3390
|
+
showHydrogens: i = !0,
|
|
3391
|
+
showWaters: s = !1,
|
|
3392
|
+
showLabels: a = !1,
|
|
3393
|
+
labelType: l = "element",
|
|
3394
|
+
width: c = "100%",
|
|
3395
|
+
height: h = 500,
|
|
3396
|
+
backgroundColor: p = "#000000",
|
|
3397
|
+
enableRotation: m = !0,
|
|
3398
|
+
enableZoom: y = !0,
|
|
3399
|
+
showControls: $ = !0,
|
|
3400
|
+
measurements: w = [],
|
|
3401
|
+
surfaces: j = [],
|
|
3402
|
+
labels: J = [],
|
|
3403
|
+
selection: te,
|
|
3404
|
+
highlightColor: V = "#FFFF00",
|
|
3405
|
+
spin: L = !1,
|
|
3406
|
+
spinSpeed: H = 0.5,
|
|
3407
|
+
onAtomClick: oe,
|
|
3408
|
+
onAtomHover: U,
|
|
3409
|
+
onSelectionChange: de,
|
|
3410
|
+
className: pe,
|
|
3411
|
+
styleOverride: se
|
|
3412
|
+
}) {
|
|
3413
|
+
const ne = ze(null), [_, ce] = E(null), [ue, ye] = E({
|
|
3414
|
+
rotX: 0,
|
|
3415
|
+
rotY: 0,
|
|
3416
|
+
rotZ: 0,
|
|
3417
|
+
zoom: 1,
|
|
3418
|
+
panX: 0,
|
|
3419
|
+
panY: 0
|
|
3420
|
+
}), [xe, Y] = E(!1), [Z, ae] = E(
|
|
3421
|
+
null
|
|
3422
|
+
), [G, S] = E(null), [Q, ee] = E(n);
|
|
3423
|
+
Ye(() => {
|
|
3424
|
+
if (!e) {
|
|
3425
|
+
ce(null);
|
|
3426
|
+
return;
|
|
3427
|
+
}
|
|
3428
|
+
typeof e == "string" ? (t === "pdb" || console.warn(`Format ${t} parsing not implemented, using PDB parser`), ce(Ve(e))) : ce(e);
|
|
3429
|
+
}, [e, t]), Ye(() => {
|
|
3430
|
+
if (!L)
|
|
3431
|
+
return;
|
|
3432
|
+
const g = setInterval(() => {
|
|
3433
|
+
ye((M) => ({ ...M, rotY: (M.rotY + H) % 360 }));
|
|
3434
|
+
}, 16);
|
|
3435
|
+
return () => clearInterval(g);
|
|
3436
|
+
}, [L, H]);
|
|
3437
|
+
const { center: re, scale: ie } = K(() => {
|
|
3438
|
+
if (!_ || _.atoms.length === 0)
|
|
3439
|
+
return { center: { x: 0, y: 0, z: 0 }, scale: 1 };
|
|
3440
|
+
let g = 1 / 0, M = -1 / 0, A = 1 / 0, O = -1 / 0, X = 1 / 0, le = -1 / 0;
|
|
3441
|
+
for (const me of _.atoms)
|
|
3442
|
+
g = Math.min(g, me.x), M = Math.max(M, me.x), A = Math.min(A, me.y), O = Math.max(O, me.y), X = Math.min(X, me.z), le = Math.max(le, me.z);
|
|
3443
|
+
const fe = {
|
|
3444
|
+
x: (g + M) / 2,
|
|
3445
|
+
y: (A + O) / 2,
|
|
3446
|
+
z: (X + le) / 2
|
|
3447
|
+
}, be = Math.max(M - g, O - A, le - X), ge = be > 0 ? 35 / be : 1;
|
|
3448
|
+
return { center: fe, scale: ge };
|
|
3449
|
+
}, [_]), z = K(() => _ ? _.atoms.filter((g) => !i && g.element === "H" || !s && g.residueName === "HOH" ? !1 : g.visible !== !1).map((g) => ({
|
|
3450
|
+
atom: g,
|
|
3451
|
+
...Ee(g.x, g.y, g.z, ue, re, ie)
|
|
3452
|
+
})).sort((g, M) => g.depth - M.depth) : [], [_, ue, re, ie, i, s]), k = K(() => _ ? _.bonds.filter((g) => g.visible !== !1).map((g) => {
|
|
3453
|
+
const M = _.atoms[g.atom1], A = _.atoms[g.atom2];
|
|
3454
|
+
if (!M || !A || !i && (M.element === "H" || A.element === "H"))
|
|
3455
|
+
return null;
|
|
3456
|
+
const O = Ee(M.x, M.y, M.z, ue, re, ie), X = Ee(A.x, A.y, A.z, ue, re, ie);
|
|
3457
|
+
return {
|
|
3458
|
+
bond: g,
|
|
3459
|
+
x1: O.x,
|
|
3460
|
+
y1: O.y,
|
|
3461
|
+
x2: X.x,
|
|
3462
|
+
y2: X.y,
|
|
3463
|
+
depth: (O.depth + X.depth) / 2,
|
|
3464
|
+
color1: M.color,
|
|
3465
|
+
color2: A.color
|
|
3466
|
+
};
|
|
3467
|
+
}).filter(Boolean).sort((g, M) => g.depth - M.depth) : [], [_, ue, re, ie, i]), d = P(
|
|
3468
|
+
(g) => {
|
|
3469
|
+
m && (Y(!0), ae({ x: g.clientX, y: g.clientY, view: { ...ue } }));
|
|
3470
|
+
},
|
|
3471
|
+
[m, ue]
|
|
3472
|
+
), x = P(
|
|
3473
|
+
(g) => {
|
|
3474
|
+
if (!xe || !Z)
|
|
3475
|
+
return;
|
|
3476
|
+
const M = g.clientX - Z.x, A = g.clientY - Z.y;
|
|
3477
|
+
g.shiftKey ? ye({
|
|
3478
|
+
...Z.view,
|
|
3479
|
+
panX: Z.view.panX + M * 0.1,
|
|
3480
|
+
panY: Z.view.panY + A * 0.1
|
|
3481
|
+
}) : ye({
|
|
3482
|
+
...Z.view,
|
|
3483
|
+
rotY: Z.view.rotY + M * 0.5,
|
|
3484
|
+
rotX: Z.view.rotX + A * 0.5
|
|
3485
|
+
});
|
|
3486
|
+
},
|
|
3487
|
+
[xe, Z]
|
|
3488
|
+
), C = P(() => {
|
|
3489
|
+
Y(!1), ae(null);
|
|
3490
|
+
}, []), N = P(
|
|
3491
|
+
(g) => {
|
|
3492
|
+
if (!y)
|
|
3493
|
+
return;
|
|
3494
|
+
g.preventDefault();
|
|
3495
|
+
const M = g.deltaY > 0 ? 0.9 : 1.1;
|
|
3496
|
+
ye((A) => ({ ...A, zoom: Math.max(0.1, Math.min(10, A.zoom * M)) }));
|
|
3497
|
+
},
|
|
3498
|
+
[y]
|
|
3499
|
+
), I = P(
|
|
3500
|
+
(g) => {
|
|
3501
|
+
switch (Q) {
|
|
3502
|
+
case "space-filling":
|
|
3503
|
+
return (Lt[g.element] || 1.5) * 4;
|
|
3504
|
+
case "ball-stick":
|
|
3505
|
+
return (je[g.element] || 0.5) * 3;
|
|
3506
|
+
case "stick":
|
|
3507
|
+
case "wireframe":
|
|
3508
|
+
return 2;
|
|
3509
|
+
default:
|
|
3510
|
+
return 4;
|
|
3511
|
+
}
|
|
3512
|
+
},
|
|
3513
|
+
[Q]
|
|
3514
|
+
), W = P(
|
|
3515
|
+
(g) => (Q === "wireframe" ? 1 : Q === "stick" ? 3 : 2) * (g.order || 1),
|
|
3516
|
+
[Q]
|
|
3517
|
+
);
|
|
3518
|
+
return _ ? /* @__PURE__ */ u(
|
|
3519
|
+
"div",
|
|
3520
|
+
{
|
|
3521
|
+
ref: ne,
|
|
3522
|
+
className: `nice-molecular-viewer ${pe || ""}`,
|
|
3523
|
+
style: {
|
|
3524
|
+
width: c,
|
|
3525
|
+
height: h,
|
|
3526
|
+
backgroundColor: p,
|
|
3527
|
+
position: "relative",
|
|
3528
|
+
overflow: "hidden",
|
|
3529
|
+
cursor: xe ? "grabbing" : "grab",
|
|
3530
|
+
...se
|
|
3531
|
+
},
|
|
3532
|
+
onMouseDown: d,
|
|
3533
|
+
onMouseMove: x,
|
|
3534
|
+
onMouseUp: C,
|
|
3535
|
+
onMouseLeave: C,
|
|
3536
|
+
onWheel: N,
|
|
3537
|
+
children: [
|
|
3538
|
+
/* @__PURE__ */ u("svg", { width: "100%", height: "100%", style: { position: "absolute" }, children: [
|
|
3539
|
+
Q !== "space-filling" && k.map((g, M) => /* @__PURE__ */ o(
|
|
3540
|
+
"line",
|
|
3541
|
+
{
|
|
3542
|
+
x1: `${g.x1}%`,
|
|
3543
|
+
y1: `${g.y1}%`,
|
|
3544
|
+
x2: `${g.x2}%`,
|
|
3545
|
+
y2: `${g.y2}%`,
|
|
3546
|
+
stroke: g.bond.color || "#888888",
|
|
3547
|
+
strokeWidth: W(g.bond),
|
|
3548
|
+
strokeLinecap: "round"
|
|
3549
|
+
},
|
|
3550
|
+
`bond-${M}`
|
|
3551
|
+
)),
|
|
3552
|
+
z.map(({ atom: g, x: M, y: A }) => {
|
|
3553
|
+
var fe;
|
|
3554
|
+
const O = (fe = te == null ? void 0 : te.atoms) == null ? void 0 : fe.includes(g.id), X = (G == null ? void 0 : G.id) === g.id, le = I(g);
|
|
3555
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
3556
|
+
/* @__PURE__ */ o(
|
|
3557
|
+
"circle",
|
|
3558
|
+
{
|
|
3559
|
+
cx: `${M}%`,
|
|
3560
|
+
cy: `${A}%`,
|
|
3561
|
+
r: le,
|
|
3562
|
+
fill: g.color || tt[g.element] || "#808080",
|
|
3563
|
+
stroke: O ? V : X ? "#FFFFFF" : "none",
|
|
3564
|
+
strokeWidth: O || X ? 2 : 0,
|
|
3565
|
+
style: { cursor: "pointer" },
|
|
3566
|
+
onMouseEnter: () => {
|
|
3567
|
+
S(g), U == null || U(g);
|
|
3568
|
+
},
|
|
3569
|
+
onMouseLeave: () => {
|
|
3570
|
+
S(null), U == null || U(null);
|
|
3571
|
+
},
|
|
3572
|
+
onClick: () => oe == null ? void 0 : oe(g)
|
|
3573
|
+
}
|
|
3574
|
+
),
|
|
3575
|
+
a && /* @__PURE__ */ o(
|
|
3576
|
+
"text",
|
|
3577
|
+
{
|
|
3578
|
+
x: `${M}%`,
|
|
3579
|
+
y: `${A - le * 0.15}%`,
|
|
3580
|
+
fill: "#FFFFFF",
|
|
3581
|
+
fontSize: "10",
|
|
3582
|
+
textAnchor: "middle",
|
|
3583
|
+
dominantBaseline: "middle",
|
|
3584
|
+
style: { pointerEvents: "none" },
|
|
3585
|
+
children: l === "element" ? g.element : l === "name" ? g.name : l === "residue" ? g.residueName : l === "chain" ? g.chainId : l === "serial" ? g.serial : g.element
|
|
3586
|
+
}
|
|
3587
|
+
)
|
|
3588
|
+
] }, `atom-${g.id}`);
|
|
3589
|
+
}),
|
|
3590
|
+
w.map((g) => {
|
|
3591
|
+
if (g.atoms.length < 2)
|
|
3592
|
+
return null;
|
|
3593
|
+
const M = _.atoms[g.atoms[0]], A = _.atoms[g.atoms[1]];
|
|
3594
|
+
if (!M || !A)
|
|
3595
|
+
return null;
|
|
3596
|
+
const O = Ee(M.x, M.y, M.z, ue, re, ie), X = Ee(A.x, A.y, A.z, ue, re, ie);
|
|
3597
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
3598
|
+
/* @__PURE__ */ o(
|
|
3599
|
+
"line",
|
|
3600
|
+
{
|
|
3601
|
+
x1: `${O.x}%`,
|
|
3602
|
+
y1: `${O.y}%`,
|
|
3603
|
+
x2: `${X.x}%`,
|
|
3604
|
+
y2: `${X.y}%`,
|
|
3605
|
+
stroke: g.color || "#FFFF00",
|
|
3606
|
+
strokeWidth: 1,
|
|
3607
|
+
strokeDasharray: "3,3"
|
|
3608
|
+
}
|
|
3609
|
+
),
|
|
3610
|
+
/* @__PURE__ */ u(
|
|
3611
|
+
"text",
|
|
3612
|
+
{
|
|
3613
|
+
x: `${(O.x + X.x) / 2}%`,
|
|
3614
|
+
y: `${(O.y + X.y) / 2 - 1}%`,
|
|
3615
|
+
fill: g.color || "#FFFF00",
|
|
3616
|
+
fontSize: "10",
|
|
3617
|
+
textAnchor: "middle",
|
|
3618
|
+
children: [
|
|
3619
|
+
g.value.toFixed(2),
|
|
3620
|
+
" ",
|
|
3621
|
+
g.unit
|
|
3622
|
+
]
|
|
3623
|
+
}
|
|
3624
|
+
)
|
|
3625
|
+
] }, g.id);
|
|
3626
|
+
})
|
|
3627
|
+
] }),
|
|
3628
|
+
/* @__PURE__ */ u("div", { style: { position: "absolute", top: 8, left: 8, color: "#FFF", fontSize: "0.8rem" }, children: [
|
|
3629
|
+
/* @__PURE__ */ o("div", { style: { fontWeight: "bold" }, children: _.name }),
|
|
3630
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3631
|
+
_.atoms.length,
|
|
3632
|
+
" atoms, ",
|
|
3633
|
+
_.bonds.length,
|
|
3634
|
+
" bonds"
|
|
3635
|
+
] }),
|
|
3636
|
+
_.formula && /* @__PURE__ */ u("div", { children: [
|
|
3637
|
+
"Formula: ",
|
|
3638
|
+
_.formula
|
|
3639
|
+
] })
|
|
3640
|
+
] }),
|
|
3641
|
+
G && /* @__PURE__ */ u(
|
|
3642
|
+
"div",
|
|
3643
|
+
{
|
|
3644
|
+
style: {
|
|
3645
|
+
position: "absolute",
|
|
3646
|
+
bottom: 8,
|
|
3647
|
+
left: 8,
|
|
3648
|
+
background: "rgba(0,0,0,0.8)",
|
|
3649
|
+
color: "#FFF",
|
|
3650
|
+
padding: "4px 8px",
|
|
3651
|
+
borderRadius: 4,
|
|
3652
|
+
fontSize: "0.75rem"
|
|
3653
|
+
},
|
|
3654
|
+
children: [
|
|
3655
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3656
|
+
/* @__PURE__ */ o("b", { children: G.element }),
|
|
3657
|
+
" (",
|
|
3658
|
+
G.name,
|
|
3659
|
+
")"
|
|
3660
|
+
] }),
|
|
3661
|
+
G.residueName && /* @__PURE__ */ u("div", { children: [
|
|
3662
|
+
"Residue: ",
|
|
3663
|
+
G.residueName,
|
|
3664
|
+
" ",
|
|
3665
|
+
G.residueSeq
|
|
3666
|
+
] }),
|
|
3667
|
+
G.chainId && /* @__PURE__ */ u("div", { children: [
|
|
3668
|
+
"Chain: ",
|
|
3669
|
+
G.chainId
|
|
3670
|
+
] }),
|
|
3671
|
+
/* @__PURE__ */ u("div", { children: [
|
|
3672
|
+
"Position: (",
|
|
3673
|
+
G.x.toFixed(2),
|
|
3674
|
+
", ",
|
|
3675
|
+
G.y.toFixed(2),
|
|
3676
|
+
",",
|
|
3677
|
+
" ",
|
|
3678
|
+
G.z.toFixed(2),
|
|
3679
|
+
")"
|
|
3680
|
+
] })
|
|
3681
|
+
]
|
|
3682
|
+
}
|
|
3683
|
+
),
|
|
3684
|
+
$ && /* @__PURE__ */ u(
|
|
3685
|
+
"div",
|
|
3686
|
+
{
|
|
3687
|
+
style: {
|
|
3688
|
+
position: "absolute",
|
|
3689
|
+
top: 8,
|
|
3690
|
+
right: 8,
|
|
3691
|
+
display: "flex",
|
|
3692
|
+
flexDirection: "column",
|
|
3693
|
+
gap: 4
|
|
3694
|
+
},
|
|
3695
|
+
children: [
|
|
3696
|
+
/* @__PURE__ */ u(
|
|
3697
|
+
"select",
|
|
3698
|
+
{
|
|
3699
|
+
value: Q,
|
|
3700
|
+
onChange: (g) => ee(g.target.value),
|
|
3701
|
+
style: { padding: "2px 4px", fontSize: "0.75rem" },
|
|
3702
|
+
children: [
|
|
3703
|
+
/* @__PURE__ */ o("option", { value: "ball-stick", children: "Ball & Stick" }),
|
|
3704
|
+
/* @__PURE__ */ o("option", { value: "space-filling", children: "Space Filling" }),
|
|
3705
|
+
/* @__PURE__ */ o("option", { value: "stick", children: "Stick" }),
|
|
3706
|
+
/* @__PURE__ */ o("option", { value: "wireframe", children: "Wireframe" })
|
|
3707
|
+
]
|
|
3708
|
+
}
|
|
3709
|
+
),
|
|
3710
|
+
/* @__PURE__ */ o(
|
|
3711
|
+
"button",
|
|
3712
|
+
{
|
|
3713
|
+
onClick: () => ye({ rotX: 0, rotY: 0, rotZ: 0, zoom: 1, panX: 0, panY: 0 }),
|
|
3714
|
+
style: { padding: "2px 4px", fontSize: "0.75rem", cursor: "pointer" },
|
|
3715
|
+
children: "Reset View"
|
|
3716
|
+
}
|
|
3717
|
+
)
|
|
3718
|
+
]
|
|
3719
|
+
}
|
|
3720
|
+
)
|
|
3721
|
+
]
|
|
3722
|
+
}
|
|
3723
|
+
) : /* @__PURE__ */ o(
|
|
3724
|
+
"div",
|
|
3725
|
+
{
|
|
3726
|
+
className: `nice-molecular-viewer nice-molecular-viewer--empty ${pe || ""}`,
|
|
3727
|
+
style: {
|
|
3728
|
+
width: c,
|
|
3729
|
+
height: h,
|
|
3730
|
+
backgroundColor: p,
|
|
3731
|
+
display: "flex",
|
|
3732
|
+
alignItems: "center",
|
|
3733
|
+
justifyContent: "center",
|
|
3734
|
+
color: "#666",
|
|
3735
|
+
...se
|
|
3736
|
+
},
|
|
3737
|
+
children: "Load a molecule (PDB, MOL, SDF)"
|
|
3738
|
+
}
|
|
3739
|
+
);
|
|
3740
|
+
}
|
|
3741
|
+
function Ot(e) {
|
|
3742
|
+
let t = 0, n = 0;
|
|
3743
|
+
function r() {
|
|
3744
|
+
var l;
|
|
3745
|
+
const s = { id: `node_${n++}` };
|
|
3746
|
+
if (e[t] === "(")
|
|
3747
|
+
for (t++, s.children = []; ; ) {
|
|
3748
|
+
const c = r();
|
|
3749
|
+
if (c && (c.parent = s.id, s.children.push(c)), e[t] === ",") {
|
|
3750
|
+
t++;
|
|
3751
|
+
continue;
|
|
3752
|
+
}
|
|
3753
|
+
if (e[t] === ")") {
|
|
3754
|
+
t++;
|
|
3755
|
+
break;
|
|
3756
|
+
}
|
|
3757
|
+
if (t >= e.length)
|
|
3758
|
+
break;
|
|
3759
|
+
}
|
|
3760
|
+
let a = "";
|
|
3761
|
+
for (; t < e.length && !"[:,;()".includes(e[t]); )
|
|
3762
|
+
a += e[t++];
|
|
3763
|
+
if (a.trim()) {
|
|
3764
|
+
const c = a.match(/^([^[\]]+)?(?:\[([^\]]+)\])?$/);
|
|
3765
|
+
if (c) {
|
|
3766
|
+
if (s.name = ((l = c[1]) == null ? void 0 : l.trim()) || void 0, c[2]) {
|
|
3767
|
+
const h = parseFloat(c[2]);
|
|
3768
|
+
isNaN(h) || (s.bootstrap = h);
|
|
3769
|
+
}
|
|
3770
|
+
} else
|
|
3771
|
+
s.name = a.trim();
|
|
3772
|
+
}
|
|
3773
|
+
if (e[t] === ":") {
|
|
3774
|
+
t++;
|
|
3775
|
+
let c = "";
|
|
3776
|
+
for (; t < e.length && !"[,;()".includes(e[t]); )
|
|
3777
|
+
c += e[t++];
|
|
3778
|
+
const h = parseFloat(c);
|
|
3779
|
+
isNaN(h) || (s.branchLength = h);
|
|
3780
|
+
}
|
|
3781
|
+
return s;
|
|
3782
|
+
}
|
|
3783
|
+
return e.replace(/\s+/g, "").replace(/;$/, "") ? r() : null;
|
|
3784
|
+
}
|
|
3785
|
+
function nt(e, t = []) {
|
|
3786
|
+
if (t.push(e), e.children)
|
|
3787
|
+
for (const n of e.children)
|
|
3788
|
+
nt(n, t);
|
|
3789
|
+
return t;
|
|
3790
|
+
}
|
|
3791
|
+
function rt(e) {
|
|
3792
|
+
return !e.children || e.children.length === 0 ? 1 : e.children.reduce((t, n) => t + rt(n), 0);
|
|
3793
|
+
}
|
|
3794
|
+
function it(e, t, n) {
|
|
3795
|
+
if (!e.children || e.children.length === 0 || e.collapsed)
|
|
3796
|
+
return t.set(e.id, n.value), n.value += 1, t.get(e.id);
|
|
3797
|
+
let r = 1 / 0, i = -1 / 0;
|
|
3798
|
+
for (const a of e.children) {
|
|
3799
|
+
const l = it(a, t, n);
|
|
3800
|
+
r = Math.min(r, l), i = Math.max(i, l);
|
|
3801
|
+
}
|
|
3802
|
+
const s = (r + i) / 2;
|
|
3803
|
+
return t.set(e.id, s), s;
|
|
3804
|
+
}
|
|
3805
|
+
function ot(e, t, n = 0) {
|
|
3806
|
+
const r = n + (e.branchLength || 1);
|
|
3807
|
+
if (t.set(e.id, r), e.children && !e.collapsed)
|
|
3808
|
+
for (const i of e.children)
|
|
3809
|
+
ot(i, t, r);
|
|
3810
|
+
}
|
|
3811
|
+
function on({
|
|
3812
|
+
tree: e,
|
|
3813
|
+
layout: t = "rectangular",
|
|
3814
|
+
branchStyle: n = "rectangular",
|
|
3815
|
+
nodeShape: r = "circle",
|
|
3816
|
+
nodeSize: i = 5,
|
|
3817
|
+
showBranchLengths: s = !1,
|
|
3818
|
+
showBootstrap: a = !1,
|
|
3819
|
+
bootstrapThreshold: l = 70,
|
|
3820
|
+
showLeafLabels: c = !0,
|
|
3821
|
+
showInternalLabels: h = !1,
|
|
3822
|
+
labelFontSize: p = 11,
|
|
3823
|
+
branchWidth: m = 1.5,
|
|
3824
|
+
branchColor: y = "#666666",
|
|
3825
|
+
nodeColor: $ = "#333333",
|
|
3826
|
+
highlightColor: w = "#2196F3",
|
|
3827
|
+
clades: j = [],
|
|
3828
|
+
annotations: J = [],
|
|
3829
|
+
colorScale: te,
|
|
3830
|
+
width: V = "100%",
|
|
3831
|
+
height: L = 500,
|
|
3832
|
+
padding: H = 40,
|
|
3833
|
+
enableZoom: oe = !0,
|
|
3834
|
+
enablePan: U = !0,
|
|
3835
|
+
showControls: de = !0,
|
|
3836
|
+
onNodeClick: pe,
|
|
3837
|
+
onNodeHover: se,
|
|
3838
|
+
onBranchClick: ne,
|
|
3839
|
+
className: _,
|
|
3840
|
+
style: ce
|
|
3841
|
+
}) {
|
|
3842
|
+
const ue = ze(null), [ye, xe] = E(1), [Y, Z] = E({ x: 0, y: 0 }), [ae, G] = E(!1), [S, Q] = E(null), [ee, re] = E(null), [ie, z] = E(t), [k, d] = E(/* @__PURE__ */ new Set()), x = K(() => e ? typeof e == "string" ? Ot(e) : e : null, [e]), C = K(() => {
|
|
3843
|
+
if (!x)
|
|
3844
|
+
return null;
|
|
3845
|
+
const v = (D) => {
|
|
3846
|
+
var B;
|
|
3847
|
+
return {
|
|
3848
|
+
...D,
|
|
3849
|
+
collapsed: k.has(D.id),
|
|
3850
|
+
children: (B = D.children) == null ? void 0 : B.map(v)
|
|
3851
|
+
};
|
|
3852
|
+
};
|
|
3853
|
+
return v(x);
|
|
3854
|
+
}, [x, k]), { positions: N, leafCount: I, maxX: W } = K(() => {
|
|
3855
|
+
if (!C)
|
|
3856
|
+
return { positions: { x: /* @__PURE__ */ new Map(), y: /* @__PURE__ */ new Map() }, leafCount: 0, maxX: 0 };
|
|
3857
|
+
const v = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), B = rt(C);
|
|
3858
|
+
it(C, D, { value: 0 }), ot(C, v, 0);
|
|
3859
|
+
const f = Math.max(...Array.from(v.values()));
|
|
3860
|
+
return { positions: { x: v, y: D }, leafCount: B, maxX: f || 1 };
|
|
3861
|
+
}, [C]), g = K(() => C ? nt(C) : [], [C]), M = typeof V == "number" ? V : 800, A = typeof L == "number" ? L : 500, O = M - H * 2, X = A - H * 2, le = (v) => H + v / W * O * 0.7, fe = (v) => H + v / (I - 1 || 1) * X, be = (v, D) => {
|
|
3862
|
+
const B = D / (I - 1 || 1) * 2 * Math.PI - Math.PI / 2, f = v / W * Math.min(O, X) * 0.4;
|
|
3863
|
+
return {
|
|
3864
|
+
x: M / 2 + f * Math.cos(B),
|
|
3865
|
+
y: A / 2 + f * Math.sin(B)
|
|
3866
|
+
};
|
|
3867
|
+
}, ge = (v) => {
|
|
3868
|
+
const D = N.x.get(v) || 0, B = N.y.get(v) || 0;
|
|
3869
|
+
return ie === "radial" || ie === "circular" ? be(D, B) : { x: le(D), y: fe(B) };
|
|
3870
|
+
}, me = P(
|
|
3871
|
+
(v) => {
|
|
3872
|
+
U && (G(!0), Q({ x: v.clientX, y: v.clientY, pan: { ...Y } }));
|
|
3873
|
+
},
|
|
3874
|
+
[U, Y]
|
|
3875
|
+
), we = P(
|
|
3876
|
+
(v) => {
|
|
3877
|
+
if (!ae || !S)
|
|
3878
|
+
return;
|
|
3879
|
+
const D = v.clientX - S.x, B = v.clientY - S.y;
|
|
3880
|
+
Z({ x: S.pan.x + D, y: S.pan.y + B });
|
|
3881
|
+
},
|
|
3882
|
+
[ae, S]
|
|
3883
|
+
), Ce = P(() => {
|
|
3884
|
+
G(!1), Q(null);
|
|
3885
|
+
}, []), Le = P(
|
|
3886
|
+
(v) => {
|
|
3887
|
+
if (!oe)
|
|
3888
|
+
return;
|
|
3889
|
+
v.preventDefault();
|
|
3890
|
+
const D = v.deltaY > 0 ? 0.9 : 1.1;
|
|
3891
|
+
xe((B) => Math.max(0.1, Math.min(5, B * D)));
|
|
3892
|
+
},
|
|
3893
|
+
[oe]
|
|
3894
|
+
), We = P((v) => {
|
|
3895
|
+
d((D) => {
|
|
3896
|
+
const B = new Set(D);
|
|
3897
|
+
return B.has(v) ? B.delete(v) : B.add(v), B;
|
|
3898
|
+
});
|
|
3899
|
+
}, []), Oe = (v, D) => {
|
|
3900
|
+
const B = ge(v.id), f = ge(D.id);
|
|
3901
|
+
if (ie === "radial" || ie === "circular")
|
|
3902
|
+
return /* @__PURE__ */ o(
|
|
3903
|
+
"line",
|
|
3904
|
+
{
|
|
3905
|
+
x1: B.x,
|
|
3906
|
+
y1: B.y,
|
|
3907
|
+
x2: f.x,
|
|
3908
|
+
y2: f.y,
|
|
3909
|
+
stroke: D.color || y,
|
|
3910
|
+
strokeWidth: m
|
|
3911
|
+
}
|
|
3912
|
+
);
|
|
3913
|
+
switch (n) {
|
|
3914
|
+
case "rectangular":
|
|
3915
|
+
return /* @__PURE__ */ o(
|
|
3916
|
+
"path",
|
|
3917
|
+
{
|
|
3918
|
+
d: `M${B.x},${B.y} H${f.x} V${f.y}`,
|
|
3919
|
+
stroke: D.color || y,
|
|
3920
|
+
strokeWidth: m,
|
|
3921
|
+
fill: "none"
|
|
3922
|
+
}
|
|
3923
|
+
);
|
|
3924
|
+
case "diagonal":
|
|
3925
|
+
return /* @__PURE__ */ o(
|
|
3926
|
+
"line",
|
|
3927
|
+
{
|
|
3928
|
+
x1: B.x,
|
|
3929
|
+
y1: B.y,
|
|
3930
|
+
x2: f.x,
|
|
3931
|
+
y2: f.y,
|
|
3932
|
+
stroke: D.color || y,
|
|
3933
|
+
strokeWidth: m
|
|
3934
|
+
}
|
|
3935
|
+
);
|
|
3936
|
+
case "curved":
|
|
3937
|
+
const b = (B.x + f.x) / 2;
|
|
3938
|
+
return /* @__PURE__ */ o(
|
|
3939
|
+
"path",
|
|
3940
|
+
{
|
|
3941
|
+
d: `M${B.x},${B.y} C${b},${B.y} ${b},${f.y} ${f.x},${f.y}`,
|
|
3942
|
+
stroke: D.color || y,
|
|
3943
|
+
strokeWidth: m,
|
|
3944
|
+
fill: "none"
|
|
3945
|
+
}
|
|
3946
|
+
);
|
|
3947
|
+
default:
|
|
3948
|
+
return /* @__PURE__ */ o(
|
|
3949
|
+
"line",
|
|
3950
|
+
{
|
|
3951
|
+
x1: B.x,
|
|
3952
|
+
y1: B.y,
|
|
3953
|
+
x2: f.x,
|
|
3954
|
+
y2: f.y,
|
|
3955
|
+
stroke: D.color || y,
|
|
3956
|
+
strokeWidth: m
|
|
3957
|
+
}
|
|
3958
|
+
);
|
|
3959
|
+
}
|
|
3960
|
+
}, Ie = (v) => {
|
|
3961
|
+
const D = ge(v.id), B = !v.children || v.children.length === 0 || v.collapsed, f = (ee == null ? void 0 : ee.id) === v.id, b = f ? i * 1.5 : i, T = (() => {
|
|
3962
|
+
switch (r) {
|
|
3963
|
+
case "circle":
|
|
3964
|
+
return /* @__PURE__ */ o("circle", { cx: D.x, cy: D.y, r: b });
|
|
3965
|
+
case "square":
|
|
3966
|
+
return /* @__PURE__ */ o("rect", { x: D.x - b, y: D.y - b, width: b * 2, height: b * 2 });
|
|
3967
|
+
case "triangle":
|
|
3968
|
+
const F = b * 1.5;
|
|
3969
|
+
return /* @__PURE__ */ o(
|
|
3970
|
+
"polygon",
|
|
3971
|
+
{
|
|
3972
|
+
points: `${D.x},${D.y - F} ${D.x - F},${D.y + F} ${D.x + F},${D.y + F}`
|
|
3973
|
+
}
|
|
3974
|
+
);
|
|
3975
|
+
case "diamond":
|
|
3976
|
+
return /* @__PURE__ */ o(
|
|
3977
|
+
"polygon",
|
|
3978
|
+
{
|
|
3979
|
+
points: `${D.x},${D.y - b} ${D.x + b},${D.y} ${D.x},${D.y + b} ${D.x - b},${D.y}`
|
|
3980
|
+
}
|
|
3981
|
+
);
|
|
3982
|
+
case "none":
|
|
3983
|
+
return null;
|
|
3984
|
+
default:
|
|
3985
|
+
return /* @__PURE__ */ o("circle", { cx: D.x, cy: D.y, r: b });
|
|
3986
|
+
}
|
|
3987
|
+
})();
|
|
3988
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
3989
|
+
T && /* @__PURE__ */ o(
|
|
3990
|
+
"g",
|
|
3991
|
+
{
|
|
3992
|
+
fill: v.highlighted ? w : v.color || $,
|
|
3993
|
+
stroke: f ? w : "none",
|
|
3994
|
+
strokeWidth: 2,
|
|
3995
|
+
style: { cursor: "pointer" },
|
|
3996
|
+
onMouseEnter: () => {
|
|
3997
|
+
re(v), se == null || se(v);
|
|
3998
|
+
},
|
|
3999
|
+
onMouseLeave: () => {
|
|
4000
|
+
re(null), se == null || se(null);
|
|
4001
|
+
},
|
|
4002
|
+
onClick: () => pe == null ? void 0 : pe(v),
|
|
4003
|
+
onDoubleClick: () => {
|
|
4004
|
+
v.children && v.children.length > 0 && We(v.id);
|
|
4005
|
+
},
|
|
4006
|
+
children: T
|
|
4007
|
+
}
|
|
4008
|
+
),
|
|
4009
|
+
v.collapsed && v.children && /* @__PURE__ */ o(
|
|
4010
|
+
"polygon",
|
|
4011
|
+
{
|
|
4012
|
+
points: `${D.x + 8},${D.y - 6} ${D.x + 20},${D.y} ${D.x + 8},${D.y + 6}`,
|
|
4013
|
+
fill: $,
|
|
4014
|
+
opacity: 0.5
|
|
4015
|
+
}
|
|
4016
|
+
),
|
|
4017
|
+
B && c && v.name && /* @__PURE__ */ o(
|
|
4018
|
+
"text",
|
|
4019
|
+
{
|
|
4020
|
+
x: D.x + i + 5,
|
|
4021
|
+
y: D.y,
|
|
4022
|
+
fontSize: p,
|
|
4023
|
+
fill: "#333",
|
|
4024
|
+
dominantBaseline: "middle",
|
|
4025
|
+
children: v.name
|
|
4026
|
+
}
|
|
4027
|
+
),
|
|
4028
|
+
!B && h && v.name && /* @__PURE__ */ o(
|
|
4029
|
+
"text",
|
|
4030
|
+
{
|
|
4031
|
+
x: D.x,
|
|
4032
|
+
y: D.y - i - 3,
|
|
4033
|
+
fontSize: p * 0.9,
|
|
4034
|
+
fill: "#666",
|
|
4035
|
+
textAnchor: "middle",
|
|
4036
|
+
children: v.name
|
|
4037
|
+
}
|
|
4038
|
+
),
|
|
4039
|
+
a && v.bootstrap !== void 0 && v.bootstrap >= l && /* @__PURE__ */ o(
|
|
4040
|
+
"text",
|
|
4041
|
+
{
|
|
4042
|
+
x: D.x,
|
|
4043
|
+
y: D.y - i - 2,
|
|
4044
|
+
fontSize: p * 0.8,
|
|
4045
|
+
fill: "#E91E63",
|
|
4046
|
+
textAnchor: "middle",
|
|
4047
|
+
children: v.bootstrap.toFixed(0)
|
|
4048
|
+
}
|
|
4049
|
+
)
|
|
4050
|
+
] }, v.id);
|
|
4051
|
+
}, Ne = (v) => {
|
|
4052
|
+
const D = [];
|
|
4053
|
+
if (v.children && !v.collapsed)
|
|
4054
|
+
for (const B of v.children)
|
|
4055
|
+
D.push(/* @__PURE__ */ o("g", { children: Oe(v, B) }, `branch-${v.id}-${B.id}`)), D.push(...Ne(B));
|
|
4056
|
+
return D;
|
|
4057
|
+
};
|
|
4058
|
+
return C ? /* @__PURE__ */ u(
|
|
4059
|
+
"div",
|
|
4060
|
+
{
|
|
4061
|
+
ref: ue,
|
|
4062
|
+
className: `nice-phylogenetic-tree ${_ || ""}`,
|
|
4063
|
+
style: {
|
|
4064
|
+
width: V,
|
|
4065
|
+
height: L,
|
|
4066
|
+
position: "relative",
|
|
4067
|
+
overflow: "hidden",
|
|
4068
|
+
background: "#FAFAFA",
|
|
4069
|
+
border: "1px solid #E0E0E0",
|
|
4070
|
+
borderRadius: 4,
|
|
4071
|
+
cursor: ae ? "grabbing" : "grab",
|
|
4072
|
+
...ce
|
|
4073
|
+
},
|
|
4074
|
+
onMouseDown: me,
|
|
4075
|
+
onMouseMove: we,
|
|
4076
|
+
onMouseUp: Ce,
|
|
4077
|
+
onMouseLeave: Ce,
|
|
4078
|
+
onWheel: Le,
|
|
4079
|
+
children: [
|
|
4080
|
+
/* @__PURE__ */ u(
|
|
4081
|
+
"svg",
|
|
4082
|
+
{
|
|
4083
|
+
width: "100%",
|
|
4084
|
+
height: "100%",
|
|
4085
|
+
style: {
|
|
4086
|
+
transform: `translate(${Y.x}px, ${Y.y}px) scale(${ye})`,
|
|
4087
|
+
transformOrigin: "center center"
|
|
4088
|
+
},
|
|
4089
|
+
children: [
|
|
4090
|
+
j.map((v) => {
|
|
4091
|
+
const D = g.filter((R) => v.nodeIds.includes(R.id));
|
|
4092
|
+
if (D.length === 0)
|
|
4093
|
+
return null;
|
|
4094
|
+
const B = D.map((R) => ge(R.id)), f = Math.min(...B.map((R) => R.x)) - 10, b = Math.max(...B.map((R) => R.x)) + 10, T = Math.min(...B.map((R) => R.y)) - 10, F = Math.max(...B.map((R) => R.y)) + 10;
|
|
4095
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
4096
|
+
/* @__PURE__ */ o(
|
|
4097
|
+
"rect",
|
|
4098
|
+
{
|
|
4099
|
+
x: f,
|
|
4100
|
+
y: T,
|
|
4101
|
+
width: b - f,
|
|
4102
|
+
height: F - T,
|
|
4103
|
+
fill: v.background || `${v.color}20` || "#E3F2FD",
|
|
4104
|
+
stroke: v.color || "#2196F3",
|
|
4105
|
+
strokeWidth: 1,
|
|
4106
|
+
strokeDasharray: "4,2",
|
|
4107
|
+
rx: 4
|
|
4108
|
+
}
|
|
4109
|
+
),
|
|
4110
|
+
v.showLabel && /* @__PURE__ */ o(
|
|
4111
|
+
"text",
|
|
4112
|
+
{
|
|
4113
|
+
x: b + 5,
|
|
4114
|
+
y: (T + F) / 2,
|
|
4115
|
+
fontSize: 10,
|
|
4116
|
+
fill: v.color || "#666",
|
|
4117
|
+
dominantBaseline: "middle",
|
|
4118
|
+
children: v.name
|
|
4119
|
+
}
|
|
4120
|
+
)
|
|
4121
|
+
] }, v.id);
|
|
4122
|
+
}),
|
|
4123
|
+
Ne(C),
|
|
4124
|
+
g.map((v) => Ie(v)),
|
|
4125
|
+
J.map((v) => {
|
|
4126
|
+
if (!g.find((b) => b.id === v.nodeId))
|
|
4127
|
+
return null;
|
|
4128
|
+
const B = ge(v.nodeId), f = {
|
|
4129
|
+
left: { x: -10, y: 0 },
|
|
4130
|
+
right: { x: 10, y: 0 },
|
|
4131
|
+
above: { x: 0, y: -10 },
|
|
4132
|
+
below: { x: 0, y: 10 }
|
|
4133
|
+
}[v.position || "right"];
|
|
4134
|
+
return /* @__PURE__ */ o(
|
|
4135
|
+
"text",
|
|
4136
|
+
{
|
|
4137
|
+
x: B.x + f.x,
|
|
4138
|
+
y: B.y + f.y,
|
|
4139
|
+
fontSize: v.fontSize || 9,
|
|
4140
|
+
fill: v.color || "#FF5722",
|
|
4141
|
+
textAnchor: v.position === "left" ? "end" : v.position === "right" ? "start" : "middle",
|
|
4142
|
+
dominantBaseline: "middle",
|
|
4143
|
+
children: v.text
|
|
4144
|
+
},
|
|
4145
|
+
`ann-${v.nodeId}`
|
|
4146
|
+
);
|
|
4147
|
+
})
|
|
4148
|
+
]
|
|
4149
|
+
}
|
|
4150
|
+
),
|
|
4151
|
+
/* @__PURE__ */ u("div", { style: { position: "absolute", top: 8, left: 8, fontSize: "0.75rem", color: "#666" }, children: [
|
|
4152
|
+
g.length,
|
|
4153
|
+
" nodes • ",
|
|
4154
|
+
I,
|
|
4155
|
+
" leaves"
|
|
4156
|
+
] }),
|
|
4157
|
+
ee && /* @__PURE__ */ u(
|
|
4158
|
+
"div",
|
|
4159
|
+
{
|
|
4160
|
+
style: {
|
|
4161
|
+
position: "absolute",
|
|
4162
|
+
bottom: 8,
|
|
4163
|
+
left: 8,
|
|
4164
|
+
background: "rgba(255,255,255,0.95)",
|
|
4165
|
+
padding: "4px 8px",
|
|
4166
|
+
borderRadius: 4,
|
|
4167
|
+
fontSize: "0.75rem",
|
|
4168
|
+
boxShadow: "0 1px 4px rgba(0,0,0,0.1)"
|
|
4169
|
+
},
|
|
4170
|
+
children: [
|
|
4171
|
+
/* @__PURE__ */ o("div", { children: /* @__PURE__ */ o("b", { children: ee.name || ee.id }) }),
|
|
4172
|
+
ee.branchLength !== void 0 && /* @__PURE__ */ u("div", { children: [
|
|
4173
|
+
"Branch length: ",
|
|
4174
|
+
ee.branchLength.toFixed(4)
|
|
4175
|
+
] }),
|
|
4176
|
+
ee.bootstrap !== void 0 && /* @__PURE__ */ u("div", { children: [
|
|
4177
|
+
"Bootstrap: ",
|
|
4178
|
+
ee.bootstrap
|
|
4179
|
+
] }),
|
|
4180
|
+
ee.children && /* @__PURE__ */ u("div", { children: [
|
|
4181
|
+
"Children: ",
|
|
4182
|
+
ee.children.length
|
|
4183
|
+
] })
|
|
4184
|
+
]
|
|
4185
|
+
}
|
|
4186
|
+
),
|
|
4187
|
+
de && /* @__PURE__ */ u(
|
|
4188
|
+
"div",
|
|
4189
|
+
{
|
|
4190
|
+
style: {
|
|
4191
|
+
position: "absolute",
|
|
4192
|
+
top: 8,
|
|
4193
|
+
right: 8,
|
|
4194
|
+
display: "flex",
|
|
4195
|
+
flexDirection: "column",
|
|
4196
|
+
gap: 4
|
|
4197
|
+
},
|
|
4198
|
+
children: [
|
|
4199
|
+
/* @__PURE__ */ u(
|
|
4200
|
+
"select",
|
|
4201
|
+
{
|
|
4202
|
+
value: ie,
|
|
4203
|
+
onChange: (v) => z(v.target.value),
|
|
4204
|
+
style: { padding: "2px 4px", fontSize: "0.75rem" },
|
|
4205
|
+
children: [
|
|
4206
|
+
/* @__PURE__ */ o("option", { value: "rectangular", children: "Rectangular" }),
|
|
4207
|
+
/* @__PURE__ */ o("option", { value: "radial", children: "Radial" }),
|
|
4208
|
+
/* @__PURE__ */ o("option", { value: "diagonal", children: "Diagonal" })
|
|
4209
|
+
]
|
|
4210
|
+
}
|
|
4211
|
+
),
|
|
4212
|
+
/* @__PURE__ */ o(
|
|
4213
|
+
"button",
|
|
4214
|
+
{
|
|
4215
|
+
onClick: () => {
|
|
4216
|
+
xe(1), Z({ x: 0, y: 0 });
|
|
4217
|
+
},
|
|
4218
|
+
style: { padding: "2px 4px", fontSize: "0.75rem", cursor: "pointer" },
|
|
4219
|
+
children: "Reset View"
|
|
4220
|
+
}
|
|
4221
|
+
),
|
|
4222
|
+
/* @__PURE__ */ o(
|
|
4223
|
+
"button",
|
|
4224
|
+
{
|
|
4225
|
+
onClick: () => d(/* @__PURE__ */ new Set()),
|
|
4226
|
+
style: { padding: "2px 4px", fontSize: "0.75rem", cursor: "pointer" },
|
|
4227
|
+
children: "Expand All"
|
|
4228
|
+
}
|
|
4229
|
+
)
|
|
4230
|
+
]
|
|
4231
|
+
}
|
|
4232
|
+
)
|
|
4233
|
+
]
|
|
4234
|
+
}
|
|
4235
|
+
) : /* @__PURE__ */ o(
|
|
4236
|
+
"div",
|
|
4237
|
+
{
|
|
4238
|
+
className: `nice-phylogenetic-tree nice-phylogenetic-tree--empty ${_ || ""}`,
|
|
4239
|
+
style: {
|
|
4240
|
+
width: V,
|
|
4241
|
+
height: L,
|
|
4242
|
+
display: "flex",
|
|
4243
|
+
alignItems: "center",
|
|
4244
|
+
justifyContent: "center",
|
|
4245
|
+
background: "#F5F5F5",
|
|
4246
|
+
color: "#666",
|
|
4247
|
+
border: "1px dashed #CCC",
|
|
4248
|
+
borderRadius: 4,
|
|
4249
|
+
...ce
|
|
4250
|
+
},
|
|
4251
|
+
children: "Load a phylogenetic tree (Newick format)"
|
|
4252
|
+
}
|
|
4253
|
+
);
|
|
4254
|
+
}
|
|
4255
|
+
const De = (e) => e * Math.PI / 180;
|
|
4256
|
+
function Tt(e, t, n, r) {
|
|
4257
|
+
const i = (t + 180) / 360 * n, s = De(e), a = Math.log(Math.tan(Math.PI / 4 + s / 2)), l = r / 2 - n * a / (2 * Math.PI);
|
|
4258
|
+
return { x: i, y: l };
|
|
4259
|
+
}
|
|
4260
|
+
function Xt(e, t, n, r) {
|
|
4261
|
+
const i = (t + 180) / 360 * n, s = (90 - e) / 180 * r;
|
|
4262
|
+
return { x: i, y: s };
|
|
4263
|
+
}
|
|
4264
|
+
function Yt(e, t, n, r, i, s) {
|
|
4265
|
+
const a = De(e), l = De(t), c = De(i), h = De(s);
|
|
4266
|
+
if (Math.sin(c) * Math.sin(a) + Math.cos(c) * Math.cos(a) * Math.cos(l - h) < 0)
|
|
4267
|
+
return { x: 0, y: 0, visible: !1 };
|
|
4268
|
+
const m = Math.min(n, r) / 2 - 10, y = n / 2 + m * Math.cos(a) * Math.sin(l - h), $ = r / 2 - m * (Math.cos(c) * Math.sin(a) - Math.sin(c) * Math.cos(a) * Math.cos(l - h));
|
|
4269
|
+
return { x: y, y: $, visible: !0 };
|
|
4270
|
+
}
|
|
4271
|
+
function _t(e, t, n, r) {
|
|
4272
|
+
const i = [
|
|
4273
|
+
[0, 1, 0],
|
|
4274
|
+
[5, 0.9986, 0.062],
|
|
4275
|
+
[10, 0.9954, 0.124],
|
|
4276
|
+
[15, 0.99, 0.186],
|
|
4277
|
+
[20, 0.9822, 0.248],
|
|
4278
|
+
[25, 0.973, 0.31],
|
|
4279
|
+
[30, 0.96, 0.372],
|
|
4280
|
+
[35, 0.9427, 0.434],
|
|
4281
|
+
[40, 0.9216, 0.4958],
|
|
4282
|
+
[45, 0.8962, 0.5571],
|
|
4283
|
+
[50, 0.8679, 0.6176],
|
|
4284
|
+
[55, 0.835, 0.6769],
|
|
4285
|
+
[60, 0.7986, 0.7346],
|
|
4286
|
+
[65, 0.7597, 0.7903],
|
|
4287
|
+
[70, 0.7186, 0.8435],
|
|
4288
|
+
[75, 0.6732, 0.8936],
|
|
4289
|
+
[80, 0.6213, 0.9394],
|
|
4290
|
+
[85, 0.5722, 0.9761],
|
|
4291
|
+
[90, 0.5322, 1]
|
|
4292
|
+
], s = Math.abs(e);
|
|
4293
|
+
let a = 1, l = 0;
|
|
4294
|
+
for (let m = 0; m < i.length - 1; m++)
|
|
4295
|
+
if (s >= i[m][0] && s <= i[m + 1][0]) {
|
|
4296
|
+
const y = (s - i[m][0]) / 5;
|
|
4297
|
+
a = i[m][1] + y * (i[m + 1][1] - i[m][1]), l = i[m][2] + y * (i[m + 1][2] - i[m][2]);
|
|
4298
|
+
break;
|
|
4299
|
+
}
|
|
4300
|
+
const c = n / (2 * Math.PI), h = n / 2 + c * De(t) * a, p = r / 2 - c * l * 1.3523 * Math.sign(e);
|
|
4301
|
+
return { x: h, y: p };
|
|
4302
|
+
}
|
|
4303
|
+
const qt = `
|
|
4304
|
+
M 50,30 L 55,28 60,30 65,35 60,40 55,42 50,40 Z
|
|
4305
|
+
M 70,25 L 80,23 85,28 87,35 85,45 78,50 72,48 68,40 70,32 Z
|
|
4306
|
+
M 55,55 L 58,52 65,55 68,60 65,70 58,75 52,70 50,60 Z
|
|
4307
|
+
M 80,55 L 90,50 92,60 88,70 80,75 75,65 Z
|
|
4308
|
+
M 15,30 L 25,28 32,32 35,38 30,45 22,48 15,42 12,35 Z
|
|
4309
|
+
M 30,55 L 35,50 40,52 42,58 38,65 32,68 28,62 Z
|
|
4310
|
+
`;
|
|
4311
|
+
function sn({
|
|
4312
|
+
projection: e = "equirectangular",
|
|
4313
|
+
layers: t = [],
|
|
4314
|
+
markers: n = [],
|
|
4315
|
+
polylines: r = [],
|
|
4316
|
+
polygons: i = [],
|
|
4317
|
+
heatmap: s,
|
|
4318
|
+
bounds: a,
|
|
4319
|
+
center: l = { lat: 0, lng: 0 },
|
|
4320
|
+
zoom: c = 1,
|
|
4321
|
+
showGraticule: h = !0,
|
|
4322
|
+
graticuleInterval: p = 30,
|
|
4323
|
+
showCoastlines: m = !0,
|
|
4324
|
+
showBorders: y = !1,
|
|
4325
|
+
landColor: $ = "#D4E6C3",
|
|
4326
|
+
oceanColor: w = "#A8D4E6",
|
|
4327
|
+
borderColor: j = "#999999",
|
|
4328
|
+
graticuleColor: J = "#CCCCCC",
|
|
4329
|
+
width: te = "100%",
|
|
4330
|
+
height: V = 400,
|
|
4331
|
+
enablePan: L = !0,
|
|
4332
|
+
enableZoom: H = !0,
|
|
4333
|
+
showControls: oe = !0,
|
|
4334
|
+
scaleBar: U = { show: !0, position: "bottom-left" },
|
|
4335
|
+
legend: de,
|
|
4336
|
+
showLayerControl: pe = !1,
|
|
4337
|
+
onMarkerClick: se,
|
|
4338
|
+
onMarkerHover: ne,
|
|
4339
|
+
onMapClick: _,
|
|
4340
|
+
onPolygonClick: ce,
|
|
4341
|
+
onBoundsChange: ue,
|
|
4342
|
+
className: ye,
|
|
4343
|
+
style: xe
|
|
4344
|
+
}) {
|
|
4345
|
+
var Ne, v, D, B;
|
|
4346
|
+
const Y = ze(null), [Z, ae] = E(l), [G, S] = E(c), [Q, ee] = E(!1), [re, ie] = E(null), [z, k] = E(null), [d, x] = E(e), [C, N] = E(
|
|
4347
|
+
new Set(t.filter((f) => f.visible !== !1).map((f) => f.id))
|
|
4348
|
+
), I = typeof te == "number" ? te : 800, W = typeof V == "number" ? V : 400, g = P(
|
|
4349
|
+
(f, b) => {
|
|
4350
|
+
switch (d) {
|
|
4351
|
+
case "mercator":
|
|
4352
|
+
return Tt(f, b, I, W);
|
|
4353
|
+
case "orthographic":
|
|
4354
|
+
return Yt(f, b, I, W, Z.lat, Z.lng);
|
|
4355
|
+
case "robinson":
|
|
4356
|
+
return _t(f, b, I, W);
|
|
4357
|
+
case "equirectangular":
|
|
4358
|
+
default:
|
|
4359
|
+
return Xt(f, b, I, W);
|
|
4360
|
+
}
|
|
4361
|
+
},
|
|
4362
|
+
[d, I, W, Z]
|
|
4363
|
+
), M = P(
|
|
4364
|
+
(f, b) => {
|
|
4365
|
+
const T = f / I * 360 - 180, F = 90 - b / W * 180;
|
|
4366
|
+
return { lat: Math.max(-90, Math.min(90, F)), lng: Math.max(-180, Math.min(180, T)) };
|
|
4367
|
+
},
|
|
4368
|
+
[I, W]
|
|
4369
|
+
), A = K(() => {
|
|
4370
|
+
const f = [];
|
|
4371
|
+
for (let b = -90 + p; b < 90; b += p) {
|
|
4372
|
+
let T = "";
|
|
4373
|
+
for (let F = -180; F <= 180; F += 5) {
|
|
4374
|
+
const R = g(b, F);
|
|
4375
|
+
R.visible !== !1 && (T += T === "" ? `M${R.x},${R.y}` : ` L${R.x},${R.y}`);
|
|
4376
|
+
}
|
|
4377
|
+
T && f.push(T);
|
|
4378
|
+
}
|
|
4379
|
+
for (let b = -180; b <= 180; b += p) {
|
|
4380
|
+
let T = "";
|
|
4381
|
+
for (let F = -90; F <= 90; F += 5) {
|
|
4382
|
+
const R = g(F, b);
|
|
4383
|
+
R.visible !== !1 && (T += T === "" ? `M${R.x},${R.y}` : ` L${R.x},${R.y}`);
|
|
4384
|
+
}
|
|
4385
|
+
T && f.push(T);
|
|
4386
|
+
}
|
|
4387
|
+
return f;
|
|
4388
|
+
}, [g, p]), O = K(() => {
|
|
4389
|
+
if (d === "orthographic") {
|
|
4390
|
+
const f = Math.min(I, W) / 2 - 10;
|
|
4391
|
+
return `M${I / 2 + f},${W / 2}
|
|
4392
|
+
A${f},${f} 0 1,1 ${I / 2 - f},${W / 2}
|
|
4393
|
+
A${f},${f} 0 1,1 ${I / 2 + f},${W / 2}`;
|
|
4394
|
+
}
|
|
4395
|
+
return null;
|
|
4396
|
+
}, [d, I, W]), X = K(() => {
|
|
4397
|
+
const f = [...n];
|
|
4398
|
+
for (const b of t)
|
|
4399
|
+
C.has(b.id) && b.markers && f.push(...b.markers);
|
|
4400
|
+
return f;
|
|
4401
|
+
}, [n, t, C]), le = K(() => {
|
|
4402
|
+
const f = [...r];
|
|
4403
|
+
for (const b of t)
|
|
4404
|
+
C.has(b.id) && b.polylines && f.push(...b.polylines);
|
|
4405
|
+
return f;
|
|
4406
|
+
}, [r, t, C]), fe = K(() => {
|
|
4407
|
+
const f = [...i];
|
|
4408
|
+
for (const b of t)
|
|
4409
|
+
C.has(b.id) && b.polygons && f.push(...b.polygons);
|
|
4410
|
+
return f;
|
|
4411
|
+
}, [i, t, C]), be = P(
|
|
4412
|
+
(f) => {
|
|
4413
|
+
L && (ee(!0), ie({ x: f.clientX, y: f.clientY, center: { ...Z } }));
|
|
4414
|
+
},
|
|
4415
|
+
[L, Z]
|
|
4416
|
+
), ge = P(
|
|
4417
|
+
(f) => {
|
|
4418
|
+
if (!Q || !re)
|
|
4419
|
+
return;
|
|
4420
|
+
const b = f.clientX - re.x, T = f.clientY - re.y, F = -(b / I) * 360 / G, R = T / W * 180 / G;
|
|
4421
|
+
ae({
|
|
4422
|
+
lat: Math.max(-85, Math.min(85, re.center.lat + R)),
|
|
4423
|
+
lng: (re.center.lng + F + 180) % 360 - 180
|
|
4424
|
+
});
|
|
4425
|
+
},
|
|
4426
|
+
[Q, re, I, W, G]
|
|
4427
|
+
), me = P(() => {
|
|
4428
|
+
ee(!1), ie(null);
|
|
4429
|
+
}, []), we = P(
|
|
4430
|
+
(f) => {
|
|
4431
|
+
if (!H)
|
|
4432
|
+
return;
|
|
4433
|
+
f.preventDefault();
|
|
4434
|
+
const b = f.deltaY > 0 ? 0.9 : 1.1;
|
|
4435
|
+
S((T) => Math.max(0.5, Math.min(20, T * b)));
|
|
4436
|
+
},
|
|
4437
|
+
[H]
|
|
4438
|
+
), Ce = P(
|
|
4439
|
+
(f) => {
|
|
4440
|
+
var R;
|
|
4441
|
+
if (!_)
|
|
4442
|
+
return;
|
|
4443
|
+
const b = (R = Y.current) == null ? void 0 : R.getBoundingClientRect();
|
|
4444
|
+
if (!b)
|
|
4445
|
+
return;
|
|
4446
|
+
const T = f.clientX - b.left, F = f.clientY - b.top;
|
|
4447
|
+
_(M(T, F));
|
|
4448
|
+
},
|
|
4449
|
+
[_, M]
|
|
4450
|
+
), Le = (f) => {
|
|
4451
|
+
const b = g(f.position.lat, f.position.lng);
|
|
4452
|
+
if (b.visible === !1)
|
|
4453
|
+
return null;
|
|
4454
|
+
const T = (z == null ? void 0 : z.id) === f.id, F = (f.size || 8) * (T ? 1.3 : 1), R = (() => {
|
|
4455
|
+
switch (f.shape) {
|
|
4456
|
+
case "square":
|
|
4457
|
+
return /* @__PURE__ */ o("rect", { x: b.x - F / 2, y: b.y - F / 2, width: F, height: F });
|
|
4458
|
+
case "triangle":
|
|
4459
|
+
return /* @__PURE__ */ o(
|
|
4460
|
+
"polygon",
|
|
4461
|
+
{
|
|
4462
|
+
points: `${b.x},${b.y - F} ${b.x - F},${b.y + F / 2} ${b.x + F},${b.y + F / 2}`
|
|
4463
|
+
}
|
|
4464
|
+
);
|
|
4465
|
+
case "diamond":
|
|
4466
|
+
return /* @__PURE__ */ o(
|
|
4467
|
+
"polygon",
|
|
4468
|
+
{
|
|
4469
|
+
points: `${b.x},${b.y - F} ${b.x + F},${b.y} ${b.x},${b.y + F} ${b.x - F},${b.y}`
|
|
4470
|
+
}
|
|
4471
|
+
);
|
|
4472
|
+
case "pin":
|
|
4473
|
+
return /* @__PURE__ */ o(
|
|
4474
|
+
"path",
|
|
4475
|
+
{
|
|
4476
|
+
d: `M${b.x},${b.y}
|
|
4477
|
+
c0,-${F * 1.5} -${F},-${F * 2} -${F},-${F * 2.5}
|
|
4478
|
+
a${F},${F} 0 1,1 ${F * 2},0
|
|
4479
|
+
c0,${F * 0.5} -${F},${F} -${F},${F * 2.5}`
|
|
4480
|
+
}
|
|
4481
|
+
);
|
|
4482
|
+
case "circle":
|
|
4483
|
+
default:
|
|
4484
|
+
return /* @__PURE__ */ o("circle", { cx: b.x, cy: b.y, r: F / 2 });
|
|
4485
|
+
}
|
|
4486
|
+
})();
|
|
4487
|
+
return /* @__PURE__ */ u(
|
|
4488
|
+
"g",
|
|
4489
|
+
{
|
|
4490
|
+
fill: f.color || "#E91E63",
|
|
4491
|
+
stroke: T ? "#000" : "#FFF",
|
|
4492
|
+
strokeWidth: T ? 2 : 1,
|
|
4493
|
+
style: { cursor: "pointer" },
|
|
4494
|
+
onMouseEnter: () => {
|
|
4495
|
+
k(f), ne == null || ne(f);
|
|
4496
|
+
},
|
|
4497
|
+
onMouseLeave: () => {
|
|
4498
|
+
k(null), ne == null || ne(null);
|
|
4499
|
+
},
|
|
4500
|
+
onClick: (Se) => {
|
|
4501
|
+
Se.stopPropagation(), se == null || se(f);
|
|
4502
|
+
},
|
|
4503
|
+
children: [
|
|
4504
|
+
R,
|
|
4505
|
+
f.label && /* @__PURE__ */ o("text", { x: b.x + F, y: b.y, fontSize: 10, fill: "#333", dominantBaseline: "middle", children: f.label })
|
|
4506
|
+
]
|
|
4507
|
+
},
|
|
4508
|
+
f.id
|
|
4509
|
+
);
|
|
4510
|
+
}, We = (f) => {
|
|
4511
|
+
if (f.path.length < 2)
|
|
4512
|
+
return null;
|
|
4513
|
+
const b = f.path.map((T, F) => {
|
|
4514
|
+
const R = g(T.lat, T.lng);
|
|
4515
|
+
return R.visible === !1 ? "" : F === 0 ? `M${R.x},${R.y}` : `L${R.x},${R.y}`;
|
|
4516
|
+
}).filter(Boolean).join(" ");
|
|
4517
|
+
return b ? /* @__PURE__ */ o(
|
|
4518
|
+
"path",
|
|
4519
|
+
{
|
|
4520
|
+
d: b,
|
|
4521
|
+
fill: "none",
|
|
4522
|
+
stroke: f.color || "#2196F3",
|
|
4523
|
+
strokeWidth: f.width || 2,
|
|
4524
|
+
strokeDasharray: f.style === "dashed" ? "8,4" : f.style === "dotted" ? "2,2" : void 0,
|
|
4525
|
+
markerEnd: f.arrows ? "url(#arrow)" : void 0
|
|
4526
|
+
},
|
|
4527
|
+
f.id
|
|
4528
|
+
) : null;
|
|
4529
|
+
}, Oe = (f) => {
|
|
4530
|
+
if (f.path.length < 3)
|
|
4531
|
+
return null;
|
|
4532
|
+
const b = f.path.map((T, F) => {
|
|
4533
|
+
const R = g(T.lat, T.lng);
|
|
4534
|
+
return R.visible === !1 ? "" : F === 0 ? `M${R.x},${R.y}` : `L${R.x},${R.y}`;
|
|
4535
|
+
}).filter(Boolean).join(" ") + " Z";
|
|
4536
|
+
return /* @__PURE__ */ o(
|
|
4537
|
+
"path",
|
|
4538
|
+
{
|
|
4539
|
+
d: b,
|
|
4540
|
+
fill: f.fillColor || "#4CAF5040",
|
|
4541
|
+
stroke: f.strokeColor || "#4CAF50",
|
|
4542
|
+
strokeWidth: f.strokeWidth || 1,
|
|
4543
|
+
fillOpacity: f.fillOpacity || 0.5,
|
|
4544
|
+
style: { cursor: "pointer" },
|
|
4545
|
+
onClick: () => ce == null ? void 0 : ce(f)
|
|
4546
|
+
},
|
|
4547
|
+
f.id
|
|
4548
|
+
);
|
|
4549
|
+
}, Ie = K(() => {
|
|
4550
|
+
if (!U.show)
|
|
4551
|
+
return null;
|
|
4552
|
+
const f = 111, b = I / 360 * G, T = f / b, F = T * 100, R = Math.pow(10, Math.floor(Math.log10(F))), Se = R * (F / R >= 5 ? 5 : F / R >= 2 ? 2 : 1);
|
|
4553
|
+
return {
|
|
4554
|
+
width: Se / T,
|
|
4555
|
+
label: Se >= 1e3 ? `${Se / 1e3} km` : `${Se} km`
|
|
4556
|
+
};
|
|
4557
|
+
}, [U.show, I, G]);
|
|
4558
|
+
return /* @__PURE__ */ u(
|
|
4559
|
+
"div",
|
|
4560
|
+
{
|
|
4561
|
+
ref: Y,
|
|
4562
|
+
className: `nice-geographic-map ${ye || ""}`,
|
|
4563
|
+
style: {
|
|
4564
|
+
width: te,
|
|
4565
|
+
height: V,
|
|
4566
|
+
position: "relative",
|
|
4567
|
+
overflow: "hidden",
|
|
4568
|
+
background: w,
|
|
4569
|
+
border: "1px solid #CCC",
|
|
4570
|
+
borderRadius: 4,
|
|
4571
|
+
cursor: Q ? "grabbing" : "grab",
|
|
4572
|
+
...xe
|
|
4573
|
+
},
|
|
4574
|
+
onMouseDown: be,
|
|
4575
|
+
onMouseMove: ge,
|
|
4576
|
+
onMouseUp: me,
|
|
4577
|
+
onMouseLeave: me,
|
|
4578
|
+
onWheel: we,
|
|
4579
|
+
onClick: Ce,
|
|
4580
|
+
children: [
|
|
4581
|
+
/* @__PURE__ */ u("svg", { width: "100%", height: "100%", children: [
|
|
4582
|
+
/* @__PURE__ */ o("defs", { children: /* @__PURE__ */ o("marker", { id: "arrow", markerWidth: "10", markerHeight: "10", refX: "9", refY: "3", orient: "auto", children: /* @__PURE__ */ o("path", { d: "M0,0 L0,6 L9,3 z", fill: "#2196F3" }) }) }),
|
|
4583
|
+
d === "orthographic" && O && /* @__PURE__ */ u(Ae, { children: [
|
|
4584
|
+
/* @__PURE__ */ o("path", { d: O, fill: w, stroke: "#999", strokeWidth: 1 }),
|
|
4585
|
+
/* @__PURE__ */ o(
|
|
4586
|
+
"circle",
|
|
4587
|
+
{
|
|
4588
|
+
cx: I / 2,
|
|
4589
|
+
cy: W / 2,
|
|
4590
|
+
r: Math.min(I, W) / 2 - 11,
|
|
4591
|
+
fill: $,
|
|
4592
|
+
opacity: 0.3
|
|
4593
|
+
}
|
|
4594
|
+
)
|
|
4595
|
+
] }),
|
|
4596
|
+
h && A.map((f, b) => /* @__PURE__ */ o(
|
|
4597
|
+
"path",
|
|
4598
|
+
{
|
|
4599
|
+
d: f,
|
|
4600
|
+
fill: "none",
|
|
4601
|
+
stroke: J,
|
|
4602
|
+
strokeWidth: 0.5,
|
|
4603
|
+
strokeOpacity: 0.7
|
|
4604
|
+
},
|
|
4605
|
+
`graticule-${b}`
|
|
4606
|
+
)),
|
|
4607
|
+
m && d !== "orthographic" && /* @__PURE__ */ o("g", { transform: `scale(${I / 100}, ${W / 100})`, children: /* @__PURE__ */ o(
|
|
4608
|
+
"path",
|
|
4609
|
+
{
|
|
4610
|
+
d: qt,
|
|
4611
|
+
fill: $,
|
|
4612
|
+
stroke: j,
|
|
4613
|
+
strokeWidth: 0.2
|
|
4614
|
+
}
|
|
4615
|
+
) }),
|
|
4616
|
+
fe.map(Oe),
|
|
4617
|
+
le.map(We),
|
|
4618
|
+
X.map(Le)
|
|
4619
|
+
] }),
|
|
4620
|
+
Ie && /* @__PURE__ */ u(
|
|
4621
|
+
"div",
|
|
4622
|
+
{
|
|
4623
|
+
style: {
|
|
4624
|
+
position: "absolute",
|
|
4625
|
+
[(Ne = U.position) != null && Ne.includes("bottom") ? "bottom" : "top"]: 8,
|
|
4626
|
+
[(v = U.position) != null && v.includes("right") ? "right" : "left"]: 8,
|
|
4627
|
+
background: "rgba(255,255,255,0.9)",
|
|
4628
|
+
padding: "4px 8px",
|
|
4629
|
+
borderRadius: 4,
|
|
4630
|
+
fontSize: "0.7rem"
|
|
4631
|
+
},
|
|
4632
|
+
children: [
|
|
4633
|
+
/* @__PURE__ */ o(
|
|
4634
|
+
"div",
|
|
4635
|
+
{
|
|
4636
|
+
style: {
|
|
4637
|
+
width: Ie.width,
|
|
4638
|
+
height: 4,
|
|
4639
|
+
background: "#333",
|
|
4640
|
+
marginBottom: 2
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
),
|
|
4644
|
+
/* @__PURE__ */ o("div", { children: Ie.label })
|
|
4645
|
+
]
|
|
4646
|
+
}
|
|
4647
|
+
),
|
|
4648
|
+
de && /* @__PURE__ */ u(
|
|
4649
|
+
"div",
|
|
4650
|
+
{
|
|
4651
|
+
style: {
|
|
4652
|
+
position: "absolute",
|
|
4653
|
+
[(D = de.position) != null && D.includes("bottom") ? "bottom" : "top"]: 8,
|
|
4654
|
+
[(B = de.position) != null && B.includes("left") ? "left" : "right"]: 8,
|
|
4655
|
+
background: "rgba(255,255,255,0.95)",
|
|
4656
|
+
padding: 8,
|
|
4657
|
+
borderRadius: 4,
|
|
4658
|
+
fontSize: "0.75rem",
|
|
4659
|
+
minWidth: 100
|
|
4660
|
+
},
|
|
4661
|
+
children: [
|
|
4662
|
+
de.title && /* @__PURE__ */ o("div", { style: { fontWeight: "bold", marginBottom: 4 }, children: de.title }),
|
|
4663
|
+
de.items.map((f, b) => /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 }, children: [
|
|
4664
|
+
f.shape === "line" ? /* @__PURE__ */ o("div", { style: { width: 16, height: 2, background: f.color } }) : /* @__PURE__ */ o(
|
|
4665
|
+
"div",
|
|
4666
|
+
{
|
|
4667
|
+
style: {
|
|
4668
|
+
width: 12,
|
|
4669
|
+
height: 12,
|
|
4670
|
+
background: f.color,
|
|
4671
|
+
borderRadius: f.shape === "circle" ? "50%" : 0
|
|
4672
|
+
}
|
|
4673
|
+
}
|
|
4674
|
+
),
|
|
4675
|
+
/* @__PURE__ */ o("span", { children: f.label })
|
|
4676
|
+
] }, b))
|
|
4677
|
+
]
|
|
4678
|
+
}
|
|
4679
|
+
),
|
|
4680
|
+
(z == null ? void 0 : z.tooltip) && /* @__PURE__ */ o(
|
|
4681
|
+
"div",
|
|
4682
|
+
{
|
|
4683
|
+
style: {
|
|
4684
|
+
position: "absolute",
|
|
4685
|
+
top: g(z.position.lat, z.position.lng).y - 30,
|
|
4686
|
+
left: g(z.position.lat, z.position.lng).x,
|
|
4687
|
+
transform: "translateX(-50%)",
|
|
4688
|
+
background: "rgba(0,0,0,0.8)",
|
|
4689
|
+
color: "#FFF",
|
|
4690
|
+
padding: "4px 8px",
|
|
4691
|
+
borderRadius: 4,
|
|
4692
|
+
fontSize: "0.75rem",
|
|
4693
|
+
pointerEvents: "none",
|
|
4694
|
+
whiteSpace: "nowrap"
|
|
4695
|
+
},
|
|
4696
|
+
children: z.tooltip
|
|
4697
|
+
}
|
|
4698
|
+
),
|
|
4699
|
+
/* @__PURE__ */ u(
|
|
4700
|
+
"div",
|
|
4701
|
+
{
|
|
4702
|
+
style: {
|
|
4703
|
+
position: "absolute",
|
|
4704
|
+
bottom: 8,
|
|
4705
|
+
right: 8,
|
|
4706
|
+
background: "rgba(255,255,255,0.9)",
|
|
4707
|
+
padding: "2px 6px",
|
|
4708
|
+
borderRadius: 4,
|
|
4709
|
+
fontSize: "0.7rem",
|
|
4710
|
+
color: "#666"
|
|
4711
|
+
},
|
|
4712
|
+
children: [
|
|
4713
|
+
Z.lat.toFixed(2),
|
|
4714
|
+
"°, ",
|
|
4715
|
+
Z.lng.toFixed(2),
|
|
4716
|
+
"°"
|
|
4717
|
+
]
|
|
4718
|
+
}
|
|
4719
|
+
),
|
|
4720
|
+
pe && t.length > 0 && /* @__PURE__ */ u(
|
|
4721
|
+
"div",
|
|
4722
|
+
{
|
|
4723
|
+
style: {
|
|
4724
|
+
position: "absolute",
|
|
4725
|
+
top: 8,
|
|
4726
|
+
left: 8,
|
|
4727
|
+
background: "rgba(255,255,255,0.95)",
|
|
4728
|
+
padding: 8,
|
|
4729
|
+
borderRadius: 4,
|
|
4730
|
+
fontSize: "0.75rem"
|
|
4731
|
+
},
|
|
4732
|
+
children: [
|
|
4733
|
+
/* @__PURE__ */ o("div", { style: { fontWeight: "bold", marginBottom: 4 }, children: "Layers" }),
|
|
4734
|
+
t.map((f) => /* @__PURE__ */ u(
|
|
4735
|
+
"label",
|
|
4736
|
+
{
|
|
4737
|
+
style: { display: "flex", alignItems: "center", gap: 4, cursor: "pointer" },
|
|
4738
|
+
children: [
|
|
4739
|
+
/* @__PURE__ */ o(
|
|
4740
|
+
"input",
|
|
4741
|
+
{
|
|
4742
|
+
type: "checkbox",
|
|
4743
|
+
checked: C.has(f.id),
|
|
4744
|
+
onChange: (b) => {
|
|
4745
|
+
const T = new Set(C);
|
|
4746
|
+
b.target.checked ? T.add(f.id) : T.delete(f.id), N(T);
|
|
4747
|
+
}
|
|
4748
|
+
}
|
|
4749
|
+
),
|
|
4750
|
+
f.name
|
|
4751
|
+
]
|
|
4752
|
+
},
|
|
4753
|
+
f.id
|
|
4754
|
+
))
|
|
4755
|
+
]
|
|
4756
|
+
}
|
|
4757
|
+
),
|
|
4758
|
+
oe && /* @__PURE__ */ u(
|
|
4759
|
+
"div",
|
|
4760
|
+
{
|
|
4761
|
+
style: {
|
|
4762
|
+
position: "absolute",
|
|
4763
|
+
top: 8,
|
|
4764
|
+
right: 8,
|
|
4765
|
+
display: "flex",
|
|
4766
|
+
flexDirection: "column",
|
|
4767
|
+
gap: 4
|
|
4768
|
+
},
|
|
4769
|
+
children: [
|
|
4770
|
+
/* @__PURE__ */ u(
|
|
4771
|
+
"select",
|
|
4772
|
+
{
|
|
4773
|
+
value: d,
|
|
4774
|
+
onChange: (f) => x(f.target.value),
|
|
4775
|
+
style: { padding: "2px 4px", fontSize: "0.75rem" },
|
|
4776
|
+
children: [
|
|
4777
|
+
/* @__PURE__ */ o("option", { value: "equirectangular", children: "Equirectangular" }),
|
|
4778
|
+
/* @__PURE__ */ o("option", { value: "mercator", children: "Mercator" }),
|
|
4779
|
+
/* @__PURE__ */ o("option", { value: "orthographic", children: "Orthographic" }),
|
|
4780
|
+
/* @__PURE__ */ o("option", { value: "robinson", children: "Robinson" })
|
|
4781
|
+
]
|
|
4782
|
+
}
|
|
4783
|
+
),
|
|
4784
|
+
/* @__PURE__ */ o(
|
|
4785
|
+
"button",
|
|
4786
|
+
{
|
|
4787
|
+
onClick: () => {
|
|
4788
|
+
S(1), ae({ lat: 0, lng: 0 });
|
|
4789
|
+
},
|
|
4790
|
+
style: { padding: "2px 4px", fontSize: "0.75rem", cursor: "pointer" },
|
|
4791
|
+
children: "Reset View"
|
|
4792
|
+
}
|
|
4793
|
+
)
|
|
4794
|
+
]
|
|
4795
|
+
}
|
|
4796
|
+
)
|
|
4797
|
+
]
|
|
4798
|
+
}
|
|
4799
|
+
);
|
|
4800
|
+
}
|
|
4801
|
+
export {
|
|
4802
|
+
St as CitationService,
|
|
4803
|
+
ft as DataAnalysisService,
|
|
4804
|
+
ct as LabNotebookProvider,
|
|
4805
|
+
lt as LabNotebookService,
|
|
4806
|
+
nn as Nice3DPlot,
|
|
4807
|
+
en as NiceCitation,
|
|
4808
|
+
Qt as NiceDataAnalysis,
|
|
4809
|
+
sn as NiceGeographicMap,
|
|
4810
|
+
Jt as NiceLabNotebook,
|
|
4811
|
+
rn as NiceMolecularViewer,
|
|
4812
|
+
on as NicePhylogeneticTree,
|
|
4813
|
+
tn as NiceScientificChart,
|
|
4814
|
+
$e as Stats,
|
|
4815
|
+
Ht as createCitationService,
|
|
4816
|
+
Gt as createDataAnalysisService,
|
|
4817
|
+
Kt as createLabNotebookService,
|
|
4818
|
+
et as useCitation,
|
|
4819
|
+
Xe as useLabNotebook
|
|
4820
|
+
};
|