@rivm-loculus-tools/sequence-editor 1.7.1 → 1.9.0

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.
Files changed (58) hide show
  1. package/dist/_chunks/EngineWorker.js +1 -1
  2. package/dist/_chunks/EngineWorker.js.map +1 -1
  3. package/dist/_chunks/SequenceEditor.js +250 -145
  4. package/dist/_chunks/SequenceEditor.js.map +1 -1
  5. package/dist/_chunks/SequenceEditorEventBusService.js.map +1 -1
  6. package/dist/_chunks/SequenceEditorPageDrawer.js +132 -127
  7. package/dist/_chunks/SequenceEditorPageDrawer.js.map +1 -1
  8. package/dist/_chunks/SequenceEditorPageHeader.js +123 -0
  9. package/dist/_chunks/SequenceEditorPageHeader.js.map +1 -0
  10. package/dist/_chunks/sequenceEditorStore.js +2 -2
  11. package/dist/_chunks/sequenceEditorStore.js.map +1 -1
  12. package/dist/_chunks/sequence_editor.js +8 -1
  13. package/dist/_chunks/sequence_editor.js.map +1 -1
  14. package/dist/assets/AlignerWorker-cbSDVRKB.js +8 -0
  15. package/dist/assets/AlignerWorker-cbSDVRKB.js.map +1 -0
  16. package/dist/assets/index--BqOy4u7.js +8 -0
  17. package/dist/assets/index--BqOy4u7.js.map +1 -0
  18. package/dist/classes/services/EditorWorkerService/EditorWorkerService.d.ts +29 -23
  19. package/dist/classes/services/EditorWorkerService/index.js +80 -69
  20. package/dist/classes/services/EditorWorkerService/index.js.map +1 -1
  21. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +4 -0
  22. package/dist/classes/workers/EngineWorker/EngineWorker.d.ts +2 -0
  23. package/dist/classes/workers/EngineWorker/index.js +6 -0
  24. package/dist/classes/workers/EngineWorker/index.js.map +1 -1
  25. package/dist/components/app/SequenceEditorApp/index.js +4 -1
  26. package/dist/components/app/SequenceEditorApp/index.js.map +1 -1
  27. package/dist/components/ui/SequenceEditorPageHeader/SequenceEditorUndoRedoButtons.d.ts +1 -0
  28. package/dist/components/ui/SequenceEditorPageHeader/index.js +1 -109
  29. package/dist/components/ui/SequenceEditorRealignModal/index.js +2 -2
  30. package/dist/components/ui/SequenceEditorRealignModal/index.js.map +1 -1
  31. package/dist/constants/index.js +5 -4
  32. package/dist/constants/keyboard.d.ts +2 -0
  33. package/dist/constants/keyboard.js +44 -7
  34. package/dist/constants/keyboard.js.map +1 -1
  35. package/dist/constants/palette.d.ts +1 -2
  36. package/dist/constants/palette.js +162 -204
  37. package/dist/constants/palette.js.map +1 -1
  38. package/dist/constants/paletteSchemaData.d.ts +4 -0
  39. package/dist/constants/paletteSchemaData.js +48 -0
  40. package/dist/constants/paletteSchemaData.js.map +1 -0
  41. package/dist/models/editor.models.d.ts +2 -0
  42. package/dist/models/editor.models.js.map +1 -1
  43. package/dist/pages/SequenceEditorMainPage/index.js +1 -0
  44. package/dist/pages/SequenceEditorMainPage/index.js.map +1 -1
  45. package/dist/stores/sequenceEditorStore/sequenceEditorStore.d.ts +2 -2
  46. package/dist/utils/EditorUtil/EditorUtil.d.ts +3 -0
  47. package/dist/utils/EditorUtil/index.js +206 -169
  48. package/dist/utils/EditorUtil/index.js.map +1 -1
  49. package/dist/utils/SequenceEditorStandardConfigUtil/index.js +1 -1
  50. package/dist/vite/paletteSchemaPlugin/index.d.ts +1 -1
  51. package/dist/vite/paletteSchemaPlugin/index.js +1 -1
  52. package/dist/vite/paletteSchemaPlugin/index.js.map +1 -1
  53. package/package.json +7 -3
  54. package/dist/assets/AlignerWorker-Cf4trdzm.js +0 -8
  55. package/dist/assets/AlignerWorker-Cf4trdzm.js.map +0 -1
  56. package/dist/assets/index-YCKQaSTQ.js +0 -8
  57. package/dist/assets/index-YCKQaSTQ.js.map +0 -1
  58. package/dist/components/ui/SequenceEditorPageHeader/index.js.map +0 -1
@@ -18,9 +18,11 @@ import { Subject as E } from "@gen-epix/ui-core/classes/Subject";
18
18
  import { DevicePixelRatioService as D } from "@gen-epix/ui-core/classes/services/DevicePixelRatioService";
19
19
  import { KeyboardShortcutService as O } from "@gen-epix/ui-core/classes/services/KeyboardShortcutService";
20
20
  import { ExportUtil as ee } from "@rivm-loculus-tools/common-frontend/utils/ExportUtil";
21
+ import { UploadToLoculusModal as te } from "@rivm-loculus-tools/common-frontend/components/loculus/UploadToLoculusModal";
22
+ import { WindowService as ne } from "@gen-epix/ui-core/classes/services/WindowService";
21
23
  import { withDialog as k } from "@gen-epix/ui-core-components/hoc/withDialog";
22
24
  // ../../../../node_modules/.pnpm/use-debounce@10.1.1_react@19.3.1/node_modules/use-debounce/dist/index.module.js
23
- function te(e, t, n, r) {
25
+ function re(e, t, n, r) {
24
26
  var i = this, a = g(null), o = g(0), s = g(0), c = g(null), l = g([]), u = g(), d = g(), f = g(e), p = g(!0), _ = g(), v = g();
25
27
  f.current = e;
26
28
  var y = typeof window < "u", b = !t && t !== 0 && y;
@@ -87,8 +89,8 @@ function te(e, t, n, r) {
87
89
  }, [C]), D;
88
90
  }
89
91
  // src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx
90
- var ne = () => {
91
- let n = S(), r = t(e, (e) => e.isRealigning), i = t(e, (e) => e.latestMessage), a = t(e, (e) => e.meta), o = t(e, (e) => e.selection), s = h(() => l.getStatusBarSelectionStats(o, a), [a, o]);
92
+ var ie = () => {
93
+ let n = S(), r = t(e, (e) => e.isRealigning), i = t(e, (e) => e.latestMessage), a = t(e, (e) => e.engineMeta), o = t(e, (e) => e.selection), s = h(() => l.getStatusBarSelectionStats(o, a), [a, o]);
92
94
  return /* @__PURE__ */ w(v, {
93
95
  sx: {
94
96
  backgroundColor: x(n.palette.background.paper, .1),
@@ -132,8 +134,8 @@ var ne = () => {
132
134
  ]
133
135
  })
134
136
  });
135
- }, A = /^(?:\d+|,\d+|\d+,\d+)$/, re = k(({ onActionsChange: e, onClose: t, onGotoPosition: n }) => {
136
- let [r, i] = _(""), a = g(null), o = r === "" || A.test(r);
137
+ }, ae = /^(?:\d+|,\d+|\d+,\d+)$/, oe = k(({ onActionsChange: e, onClose: t, onGotoPosition: n }) => {
138
+ let [r, i] = _(""), a = g(null), o = r === "" || ae.test(r);
137
139
  m(() => {
138
140
  a.current?.focus();
139
141
  }, []);
@@ -186,25 +188,30 @@ var ne = () => {
186
188
  fullWidth: !0,
187
189
  maxWidth: "xs",
188
190
  testId: "SequenceEditorGotoPositionDialog"
189
- }), j = () => {
190
- let y = t(e, (e) => e.isRealigning), b = t(e, (e) => e.rawFasta), x = t(e, (e) => e.setIsRealigning), k = t(e, (e) => e.setLatestMessage), A = t(e, (e) => e.setMeta), j = t(e, (e) => e.setSelection), ie = g(null), ae = g(null), M = h(() => C.resolve(u), []), N = g(null), P = g(null), oe = g(null), F = g(null), I = g(null), L = g(null), [R, se] = _({
191
+ }), se = () => {
192
+ let y = t(e, (e) => e.isRealigning), b = t(e, (e) => e.rawFasta), x = t(e, (e) => e.setEngineMeta), k = t(e, (e) => e.setSelection), ae = g(null), se = g(null), ce = g(null), A = h(() => C.resolve(u), []), j = g(null), M = g(null), le = g(null), N = g(null), P = g(null), F = g(null), ue = g(null), [I, de] = _({
191
193
  height: 0,
192
194
  width: 0
193
- }), [ce, le] = _(() => C.resolve(D).data), [ue, de] = _(0), [fe, pe] = _(0), z = h(() => new E({
195
+ }), [fe, pe] = _(() => C.resolve(D).data), L = g(0), R = g(0), z = h(() => new E({
194
196
  scrollLeft: 0,
195
197
  scrollTop: 0
196
- }), []), me = g(R), B = h(() => new E(null), []), V = h(() => new E(null), []), H = g(null), U = g(null), W = h(() => new E(n), []), G = h(() => new E(null), []), K = g(null), q = g(0), J = g(null), he = g(!1), Y = S();
198
+ }), []), me = g(I), B = h(() => new E(null), []), V = h(() => new E(null), []), H = g(null), U = g(null), W = h(() => new E(n), []), G = h(() => new E(null), []), K = g(null), q = g(0), J = g(null), he = g(!1), Y = S();
197
199
  m(() => {
198
- y ? ae.current?.open() : ae.current?.close();
200
+ y ? ce.current?.open() : ce.current?.close();
199
201
  }, [y]);
200
202
  let X = p(() => {
201
- let e = W.data, t = B.data;
202
- if (!e || !t) return;
203
- let n = e.labelWidth + e.cellWidth + t.alignmentWidth * e.cellWidth, r = e.rulerHeight + t.sequenceCount * e.cellHeight;
204
- pe(n), de(r);
205
- }, [W, B]), Z = p(async () => {
206
- let e = await C.resolve(u).getMetaData();
207
- return B.next(e), e;
203
+ let e = ue.current;
204
+ if (!e) return;
205
+ let t = W.data, n = B.data;
206
+ if (t && n) {
207
+ let e = t.labelWidth + t.cellWidth + n.alignmentWidth * t.cellWidth, r = t.rulerHeight + n.sequenceCount * t.cellHeight;
208
+ R.current !== e && (R.current = e), L.current !== r && (L.current = r);
209
+ }
210
+ let { height: r, width: i } = me.current, a = `${Math.max(R.current, i)}px`, o = `${Math.max(L.current, r)}px`;
211
+ e.style.width !== a && (e.style.width = a), e.style.height !== o && (e.style.height = o);
212
+ }, [W, B]), Z = p(async (e) => {
213
+ let t = C.resolve(u).getMetaData(e), n = await t;
214
+ return t.abortSignal?.aborted ? null : (B.next(n), n);
208
215
  }, [B]), Q = p(() => {
209
216
  let e = W.data, t = B.data;
210
217
  if (!t || !e) return;
@@ -230,44 +237,47 @@ var ne = () => {
230
237
  B,
231
238
  z,
232
239
  V
233
- ]), ge = te((e, t) => {
234
- se({
240
+ ]), ge = re((e, t) => {
241
+ de({
235
242
  height: t,
236
243
  width: e
237
244
  });
238
245
  }, 0, { trailing: !0 });
239
246
  m(() => {
240
- me.current = R, Q();
241
- }, [R, Q]);
242
- let $ = R.width > 0 ? R.width / 2 : 120;
247
+ me.current = I, X(), Q();
248
+ }, [
249
+ I,
250
+ X,
251
+ Q
252
+ ]);
253
+ let $ = I.width > 0 ? I.width / 2 : 120;
243
254
  m(() => {
244
- let e = [B.subscribe((e) => {
245
- A(e);
255
+ let t = [B.subscribe((e) => {
256
+ x(e);
246
257
  }), G.subscribe((e) => {
247
- j(e);
258
+ k(e);
248
259
  })];
249
260
  return () => {
250
- e.forEach((e) => e()), k(null), A(null), j(null);
261
+ t.forEach((e) => e()), e.getState().setLatestMessage(null), x(null), k(null);
251
262
  };
252
263
  }, [
253
264
  B,
254
265
  G,
255
- k,
256
- A,
257
- j
266
+ x,
267
+ k
258
268
  ]), m(() => {
259
- if (R.width <= 0) return;
269
+ if (I.width <= 0) return;
260
270
  let e = W.data;
261
271
  e.labelWidth > $ && W.next({
262
272
  ...e,
263
273
  labelWidth: $
264
274
  });
265
275
  }, [
266
- R.width,
276
+ I.width,
267
277
  W,
268
278
  $
269
279
  ]), m(() => {
270
- let e = L.current;
280
+ let e = F.current;
271
281
  if (!e) return;
272
282
  let t = new ResizeObserver(([e]) => {
273
283
  if (!e) return;
@@ -275,99 +285,112 @@ var ne = () => {
275
285
  ge(n, t);
276
286
  });
277
287
  return t.observe(e), () => t.disconnect();
278
- }, [M, ge]), m(() => {
279
- (async () => {
288
+ }, [A, ge]), m(() => {
289
+ let e = new AbortController();
290
+ return (async () => {
280
291
  H.current = null, U.current = null, z.next({
281
292
  scrollLeft: 0,
282
293
  scrollTop: 0
283
- }), G.next(null), await M.initialize(), await M.loadFasta(b), await Z(), Q();
284
- })().catch((e) => {
285
- console.error(e);
286
- });
294
+ }), G.next(null);
295
+ let t = A.initialize(e.signal);
296
+ if (await t, t.abortSignal?.aborted) return;
297
+ let n = A.reset(e.signal);
298
+ if (await n, n.abortSignal?.aborted) return;
299
+ let r = A.loadFasta(b, e.signal);
300
+ await r, !r.abortSignal?.aborted && await Z(e.signal);
301
+ })().catch((t) => {
302
+ e.signal.aborted || console.error(t);
303
+ }), () => e.abort();
287
304
  }, [
288
- M,
305
+ A,
289
306
  b,
290
307
  z,
291
308
  G,
292
309
  Z,
293
310
  Q
294
311
  ]), m(() => {
295
- let t = null, n = !0, r = null, i = null, a = async () => {
312
+ let t = null, n = !0, r = null, i = null, a = null, o = async () => {
296
313
  if (n && !he.current) {
297
314
  he.current = !0;
298
315
  try {
299
316
  for (; n && J.current;) {
300
- let a = J.current;
317
+ let o = J.current;
301
318
  J.current = null;
302
- let o = q.current;
319
+ let s = q.current, c = r;
320
+ if (!c || c.signal.aborted) return;
303
321
  if (!U.current || !l.isWithinGridRange({
304
322
  cachedGridRange: U.current.range,
305
- visibleGridRange: a.visibleGridRange.visible
323
+ visibleGridRange: o.visibleGridRange.visible
306
324
  })) {
307
325
  let e = [];
308
- for (let t = a.visibleGridRange.cache.startRow; t <= a.visibleGridRange.cache.endRow; t++) e.push(await M.name(t));
309
- if (!n) return;
326
+ for (let t = o.visibleGridRange.cache.startRow; t <= o.visibleGridRange.cache.endRow; t++) {
327
+ let n = A.name(t, c.signal);
328
+ if (e.push(await n), n.abortSignal?.aborted) return;
329
+ }
330
+ if (!n || c.signal.aborted) return;
310
331
  U.current = {
311
- range: a.visibleGridRange.cache,
332
+ range: o.visibleGridRange.cache,
312
333
  rowNames: e
313
334
  };
314
335
  }
315
336
  if (!H.current || !l.isWithinGridRange({
316
337
  cachedGridRange: H.current.range,
317
- visibleGridRange: a.visibleGridRange.visible
338
+ visibleGridRange: o.visibleGridRange.visible
318
339
  })) {
319
- let e = await C.resolve(u).viewport({
320
- endCol: a.visibleGridRange.cache.endCol,
321
- endRow: a.visibleGridRange.cache.endRow,
322
- startCol: a.visibleGridRange.cache.startCol,
323
- startRow: a.visibleGridRange.cache.startRow
324
- });
325
- if (!n) return;
340
+ let e = A.viewport({
341
+ endCol: o.visibleGridRange.cache.endCol,
342
+ endRow: o.visibleGridRange.cache.endRow,
343
+ startCol: o.visibleGridRange.cache.startCol,
344
+ startRow: o.visibleGridRange.cache.startRow
345
+ }, c.signal), t = await e;
346
+ if (!n || e.abortSignal?.aborted) return;
326
347
  H.current = {
327
- range: a.visibleGridRange.cache,
328
- viewportResult: e
348
+ range: o.visibleGridRange.cache,
349
+ viewportResult: t
329
350
  };
330
351
  }
331
- o === q.current && (t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
332
- n && o === q.current && N.current && e.getState().nucleotidePalette && H.current && B.data && U.current && (P.current = l.drawCanvas({
333
- canvasElement: N.current,
352
+ s === q.current && (t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
353
+ n && s === q.current && j.current && e.getState().nucleotidePalette && H.current && B.data && U.current && (M.current = l.drawCanvas({
354
+ canvasElement: j.current,
334
355
  devicePixelRatio: C.resolve(D).data,
335
- geometry: a.geometry,
356
+ geometry: o.geometry,
336
357
  meta: B.data,
337
358
  palette: e.getState().nucleotidePalette,
338
359
  rowNames: U.current.rowNames,
339
360
  rowNamesStartRow: U.current.range.startRow,
340
- scrollLeft: a.scrollLeft,
341
- scrollTop: a.scrollTop,
342
- searchResult: r,
343
- searchResultHighlightedIndex: i,
361
+ scrollLeft: o.scrollLeft,
362
+ scrollTop: o.scrollTop,
363
+ searchResult: i,
364
+ searchResultHighlightedIndex: a,
344
365
  selection: G.data,
345
366
  viewport: H.current.viewportResult,
346
- viewportHeight: a.viewportHeight,
347
- viewportWidth: a.viewportWidth
367
+ viewportHeight: o.viewportHeight,
368
+ viewportWidth: o.viewportWidth
348
369
  }));
349
370
  }));
350
371
  }
372
+ } catch (e) {
373
+ if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
351
374
  } finally {
352
- he.current = !1, n && J.current && a();
375
+ he.current = !1, n && J.current && o();
353
376
  }
354
377
  }
355
- }, o = [e.subscribe((e, t) => {
378
+ }, s = [e.subscribe((e, t) => {
356
379
  let n = !1;
357
- e.searchResult !== t.searchResult && (r = e.searchResult, n = !0), e.searchResultHighlightedIndex !== t.searchResultHighlightedIndex && (i = e.searchResultHighlightedIndex, l.scrollToSearchResult({
380
+ e.searchResult !== t.searchResult && (i = e.searchResult, n = !0), e.searchResultHighlightedIndex !== t.searchResultHighlightedIndex && (a = e.searchResultHighlightedIndex, l.scrollToSearchResult({
358
381
  geometry: W.data,
359
- scrollContainer: L.current,
382
+ scrollContainer: F.current,
360
383
  searchResult: e.searchResult,
361
384
  searchResultHighlightedIndex: e.searchResultHighlightedIndex
362
385
  }), n = !0), n && Q();
363
386
  }), V.subscribe((e) => {
364
- e && (J.current = e, q.current += 1, a());
387
+ e && (r?.abort(), r = new AbortController(), J.current = e, q.current += 1, o());
365
388
  })];
366
389
  return () => {
367
- n = !1, J.current = null, t !== null && cancelAnimationFrame(t), q.current += 1, o.forEach((e) => e());
390
+ n = !1, r?.abort(), J.current = null, t !== null && cancelAnimationFrame(t), q.current += 1, s.forEach((e) => e());
368
391
  };
369
392
  }, [
370
- M,
393
+ A,
371
394
  W,
372
395
  B,
373
396
  G,
@@ -387,14 +410,14 @@ var ne = () => {
387
410
  }),
388
411
  G.subscribe(() => Q()),
389
412
  C.resolve(D).subscribe((e) => {
390
- le(e), X(), Q();
413
+ pe(e), X(), Q();
391
414
  })
392
415
  ];
393
416
  return () => {
394
417
  t.forEach((e) => e());
395
418
  };
396
419
  }, [
397
- M,
420
+ A,
398
421
  W,
399
422
  B,
400
423
  z,
@@ -407,9 +430,10 @@ var ne = () => {
407
430
  r.has(t) && (e.preventDefault(), C.resolve(i).emit("onMutateSelection", t));
408
431
  }, t = (e) => C.resolve(O).registerShortcut({
409
432
  callback: e.callback,
410
- element: I.current,
433
+ element: P.current,
411
434
  ...e.shortcut
412
435
  }), n = [
436
+ t(s.copySelection),
413
437
  t(s.expandSelectionLeft),
414
438
  t(s.expandSelectionRight),
415
439
  t(s.expandSelectionUp),
@@ -431,17 +455,20 @@ var ne = () => {
431
455
  t(s.insertGap),
432
456
  t(s.deleteBackward),
433
457
  t(s.deleteSelection),
458
+ t(s.deleteRows),
459
+ t(s.deleteRowsMac),
434
460
  t(s.deleteBase),
461
+ t(s.pasteFasta),
435
462
  t(s.undo),
436
463
  t(s.redo),
437
464
  t(s.gotoPosition),
438
465
  C.resolve(O).registerShortcut({
439
466
  callback: e,
440
- element: I.current
467
+ element: P.current
441
468
  }),
442
469
  C.resolve(O).registerShortcut({
443
470
  callback: e,
444
- element: I.current,
471
+ element: P.current,
445
472
  modifiers: [["Shift"]]
446
473
  })
447
474
  ];
@@ -450,24 +477,25 @@ var ne = () => {
450
477
  };
451
478
  }, []), m(() => {
452
479
  let t = async (e) => {
453
- let { command: t, getSelectionPostCommand: n } = e;
480
+ let { abortSignal: t, command: n, getSelectionPostCommand: r, invalidateRowNames: i } = e;
454
481
  try {
455
482
  let e = B.data?.undoDepth;
456
- await t(), H.current = null, U.current = null;
457
- let r = await Z();
458
- if (Q(), n) {
459
- if (e !== void 0 && r?.undoDepth === e) return;
460
- let t = n();
483
+ if (await n(), t?.aborted) return;
484
+ H.current = null, i && (U.current = null);
485
+ let a = await Z();
486
+ if (r) {
487
+ if (e !== void 0 && a?.undoDepth === e) return;
488
+ let t = r();
461
489
  G.next(t), K.current = t;
462
490
  }
463
491
  } catch (e) {
464
- console.error("Failed to post command:", e);
492
+ t?.aborted || console.error("Failed to post command:", e);
465
493
  }
466
494
  }, n = async (e) => {
467
495
  if (!B.data) return;
468
496
  let n = l.getMutateArguments(G.data, B.data);
469
497
  n && await t({ command: async () => {
470
- await M.mutate(n.rows, n.columns, e);
498
+ await A.mutate(n.rows, n.columns, e);
471
499
  } });
472
500
  }, r = (e) => {
473
501
  if (!B.data) return;
@@ -487,36 +515,96 @@ var ne = () => {
487
515
  let n = l.getRowsToMove(G.data, e, B.data);
488
516
  n && await t({
489
517
  command: async () => {
490
- e === a.UP ? (await M.moveRowsToTop(n), L.current && (L.current.scrollTop = 0)) : (await M.moveRowsToBottom(n), L.current && (L.current.scrollTop = L.current.scrollHeight - L.current.clientHeight));
518
+ e === a.UP ? (await A.moveRowsToTop(n), F.current && (F.current.scrollTop = 0)) : (await A.moveRowsToBottom(n), F.current && (F.current.scrollTop = F.current.scrollHeight - F.current.clientHeight));
491
519
  },
492
- getSelectionPostCommand: () => l.getMovedRowsEndSelection(G.data, e, B.data)
520
+ getSelectionPostCommand: () => l.getMovedRowsEndSelection(G.data, e, B.data),
521
+ invalidateRowNames: !0
493
522
  });
494
523
  }, u = async (e) => {
495
524
  if (!B.data) return;
496
525
  let n = l.getRowsToMove(G.data, e, B.data);
497
526
  n && await t({
498
527
  command: async () => {
499
- e === a.UP ? await M.moveRowsUp(n) : await M.moveRowsDown(n);
528
+ e === a.UP ? await A.moveRowsUp(n) : await A.moveRowsDown(n);
500
529
  },
501
- getSelectionPostCommand: () => l.getMovedRowsRelativeSelection(G.data, e, B.data)
530
+ getSelectionPostCommand: () => l.getMovedRowsRelativeSelection(G.data, e, B.data),
531
+ invalidateRowNames: !0
502
532
  });
503
533
  }, d = async (e) => {
504
534
  if (!B.data || e !== a.LEFT && e !== a.RIGHT || !G.data?.cells && (!G.data?.cols || G.data.cols.length === 0)) return;
505
535
  let n = l.getMutateArguments(G.data, B.data);
506
536
  n && n.columns.length !== 0 && n.rows.length !== 0 && await t({
507
537
  command: async () => {
508
- await M.moveHorizontal(n.rows, n.columns, e);
538
+ await A.moveHorizontal(n.rows, n.columns, e);
509
539
  },
510
540
  getSelectionPostCommand: () => l.getPostUpsertSelection(G.data, e)
511
541
  });
512
- }, f = C.resolve(i), p = [
542
+ }, f = C.resolve(i), p = null, m = null, h = async (n) => {
543
+ if (e.getState().isRealigning || !n.trimStart().startsWith(">")) return;
544
+ m?.abort();
545
+ let r = new AbortController();
546
+ m = r;
547
+ try {
548
+ await t({
549
+ abortSignal: r.signal,
550
+ command: async () => {
551
+ let t = A.loadFasta(n, r.signal);
552
+ await t, !t.abortSignal?.aborted && (e.getState().searchQuery && f.emit("onSearch", e.getState().searchQuery), e.getState().setLatestMessage("Pasted sequences from clipboard"));
553
+ },
554
+ getSelectionPostCommand: () => l.getPostPasteSequencesSelection(G.data, n),
555
+ invalidateRowNames: !0
556
+ });
557
+ } catch (t) {
558
+ r.signal.aborted || (console.error("Failed to load FASTA from clipboard:", t), e.getState().setLatestMessage("Failed to load FASTA from clipboard."));
559
+ } finally {
560
+ m === r && (m = null);
561
+ }
562
+ }, g = (e) => {
563
+ let t = e.target;
564
+ if (t instanceof HTMLElement && (t.isContentEditable || t.closest("input, textarea, select"))) return;
565
+ let n = e.clipboardData?.getData("text/plain") ?? "";
566
+ n.trimStart().startsWith(">") && (e.preventDefault(), h(n));
567
+ };
568
+ C.resolve(ne).window.addEventListener("paste", g);
569
+ let _ = [
570
+ () => C.resolve(ne).window.removeEventListener("paste", g),
513
571
  f.addEventListener("onSearch", async (t) => {
514
- if (!t) return;
515
- let n = await M.search(t, !0);
516
- e.getState().setSearchResult(n);
572
+ if (!t) {
573
+ p?.abort();
574
+ return;
575
+ }
576
+ p?.abort();
577
+ let n = new AbortController();
578
+ p = n;
579
+ let r = A.search(t, !0, n.signal);
580
+ try {
581
+ let t = await r;
582
+ r.abortSignal?.aborted || e.getState().setSearchResult(t);
583
+ } catch (e) {
584
+ n.signal.aborted || console.error("Failed to search sequences:", e);
585
+ }
517
586
  }),
518
587
  f.addEventListener("onExpandSelection", (e) => o(e)),
519
- f.addEventListener("onGotoPosition", () => ie.current?.open({})),
588
+ f.addEventListener("onCopySelection", async () => {
589
+ let t = G.data;
590
+ if (t) try {
591
+ let n = await A.exportGappedFasta(), r = l.getSelectedFasta(n, t);
592
+ if (!r) return;
593
+ await navigator.clipboard.writeText(r), e.getState().setLatestMessage("Copied selected sequences to clipboard");
594
+ } catch (t) {
595
+ console.error("Failed to copy selected sequences:", t), e.getState().setLatestMessage("Failed to copy selected sequences to clipboard.");
596
+ }
597
+ }),
598
+ f.addEventListener("onPasteFasta", async () => {
599
+ try {
600
+ console.log("Reading FASTA from clipboard");
601
+ let e = await navigator.clipboard.readText();
602
+ await h(e);
603
+ } catch (t) {
604
+ console.error("Failed to read FASTA from clipboard:", t), e.getState().setLatestMessage("Failed to read FASTA from clipboard.");
605
+ }
606
+ }),
607
+ f.addEventListener("onGotoPosition", () => se.current?.open({})),
520
608
  f.addEventListener("onMoveSelection", (e) => r(e)),
521
609
  f.addEventListener("onMoveRows", (e) => {
522
610
  u(e);
@@ -528,19 +616,19 @@ var ne = () => {
528
616
  d(e);
529
617
  }),
530
618
  f.addEventListener("onScrollToLineStart", () => {
531
- let e = L.current;
619
+ let e = F.current;
532
620
  e && (e.scrollLeft = 0);
533
621
  }),
534
622
  f.addEventListener("onScrollToLineEnd", () => {
535
- let e = L.current;
623
+ let e = F.current;
536
624
  e && (e.scrollLeft = e.scrollWidth - e.clientWidth);
537
625
  }),
538
626
  f.addEventListener("onScrollPageUp", () => {
539
- let e = L.current;
627
+ let e = F.current;
540
628
  e && (e.scrollTop = Math.max(0, e.scrollTop - e.clientHeight));
541
629
  }),
542
630
  f.addEventListener("onScrollPageDown", () => {
543
- let e = L.current;
631
+ let e = F.current;
544
632
  e && (e.scrollTop = Math.min(e.scrollHeight - e.clientHeight, e.scrollTop + e.clientHeight));
545
633
  }),
546
634
  f.addEventListener("onInsert", () => {
@@ -548,7 +636,7 @@ var ne = () => {
548
636
  if (!B.data) return;
549
637
  let e = l.getUpsertArguments(G.data, B.data);
550
638
  e && await t({
551
- command: async () => M.insert(e.rows, e.col),
639
+ command: async () => A.insert(e.rows, e.col),
552
640
  getSelectionPostCommand: () => l.getPostUpsertSelection(G.data, a.RIGHT)
553
641
  });
554
642
  })();
@@ -558,22 +646,33 @@ var ne = () => {
558
646
  if (!B.data) return;
559
647
  let e = l.getUpsertArguments(G.data, B.data, -1);
560
648
  e && await t({
561
- command: async () => M.delete(e.rows, e.col),
649
+ command: async () => A.delete(e.rows, e.col),
562
650
  getSelectionPostCommand: () => l.getPostUpsertSelection(G.data, a.LEFT)
563
651
  });
564
652
  })();
565
653
  }),
654
+ f.addEventListener("onDeleteRows", () => {
655
+ (async () => {
656
+ let n = G.data, r = n?.rows, i = B.data;
657
+ r?.length && i && (await t({
658
+ command: async () => A.deleteRows(r),
659
+ getSelectionPostCommand: () => l.getPostDeleteRowsSelection(n, i.sequenceCount),
660
+ invalidateRowNames: !0
661
+ }), e.getState().setLatestMessage(`${r.length} row${r.length > 1 ? "s" : ""} deleted`));
662
+ })();
663
+ }),
566
664
  f.addEventListener("onMutateSelection", (e) => {
567
665
  n(e);
568
666
  }),
569
667
  f.addEventListener("onUndo", () => {
570
668
  t({
571
- command: async () => M.undo(),
572
- getSelectionPostCommand: () => null
669
+ command: async () => A.undo(),
670
+ getSelectionPostCommand: () => null,
671
+ invalidateRowNames: !0
573
672
  });
574
673
  }),
575
674
  f.addEventListener("onCancelRealign", () => {
576
- M.cancelRealign();
675
+ A.cancelRealign();
577
676
  }),
578
677
  f.addEventListener("onRealign", () => {
579
678
  e.getState().setIsRealigning(!0);
@@ -581,7 +680,7 @@ var ne = () => {
581
680
  t({
582
681
  command: async () => {
583
682
  try {
584
- await M.realign();
683
+ await A.realign();
585
684
  } catch (t) {
586
685
  if (t instanceof DOMException && t.name === "AbortError") n = !0;
587
686
  else throw e.getState().setLatestMessage(c.getEngineErrorMessage(t)), t;
@@ -589,37 +688,43 @@ var ne = () => {
589
688
  e.getState().setIsRealigning(!1);
590
689
  }
591
690
  },
592
- getSelectionPostCommand: () => n ? G.data : null
691
+ getSelectionPostCommand: () => n ? G.data : null,
692
+ invalidateRowNames: !0
593
693
  });
594
694
  }),
595
695
  f.addEventListener("onRedo", () => {
596
696
  t({
597
- command: async () => M.redo(),
598
- getSelectionPostCommand: () => null
697
+ command: async () => A.redo(),
698
+ getSelectionPostCommand: () => null,
699
+ invalidateRowNames: !0
599
700
  });
600
701
  }),
601
702
  f.addEventListener("onExportGappedFasta", async () => {
602
- console.log("Exporting gapped fasta");
603
- let e = await M.exportGappedFasta();
703
+ let e = await A.exportGappedFasta();
604
704
  ee.downloadFastaFile(e, "sequence.gapped.fasta");
605
705
  }),
606
706
  f.addEventListener("onExportUngappedFasta", async () => {
607
- console.log("Exporting ungapped fasta");
608
- let e = await M.exportUngappedFasta();
707
+ let e = await A.exportUngappedFasta();
609
708
  ee.downloadFastaFile(e, "sequence.ungapped.fasta");
709
+ }),
710
+ f.addEventListener("onExportToLoculus", async () => {
711
+ let t = await A.exportUngappedFasta(), { parsedMetadata: n, rawFasta: r } = e.getState();
712
+ ae.current?.open({
713
+ fasta: t,
714
+ metaData: n,
715
+ rawFasta: r
716
+ });
610
717
  })
611
718
  ];
612
719
  return () => {
613
- p.forEach((e) => e()), M.cancelRealign();
720
+ window.removeEventListener("paste", g), p?.abort(), m?.abort(), _.forEach((e) => e()), A.cancelRealign();
614
721
  };
615
722
  }, [
616
- M,
723
+ A,
617
724
  G,
618
725
  Z,
619
726
  Q,
620
- B,
621
- x,
622
- k
727
+ B
623
728
  ]), m(() => {
624
729
  Q();
625
730
  }, [Q]);
@@ -630,10 +735,10 @@ var ne = () => {
630
735
  scrollTop: t.scrollTop
631
736
  });
632
737
  }, [z]), ve = p((e) => {
633
- I.current?.focus();
738
+ P.current?.focus();
634
739
  let t = e.currentTarget, n = t.getBoundingClientRect(), r = e.clientX >= n.left + t.clientWidth, i = e.clientY >= n.top + t.clientHeight;
635
740
  if (r || i) return;
636
- let a = N.current, s = P.current, c = C.resolve(D).data;
741
+ let a = j.current, s = M.current, c = C.resolve(D).data;
637
742
  if (!a || !s) return;
638
743
  let u = l.getPathPropertiesFromCanvas({
639
744
  canvas: a,
@@ -645,7 +750,7 @@ var ne = () => {
645
750
  if (u.type !== o.DIVIDER) {
646
751
  if (u.type === o.LABEL && (e.metaKey || e.ctrlKey)) {
647
752
  let t = G.data?.rows ?? [], n = t.includes(u.row) ? t.filter((e) => e !== u.row) : [...t, u.row].sort((e, t) => e - t);
648
- if (e.preventDefault(), F.current = null, n.length === 0) {
753
+ if (e.preventDefault(), N.current = null, n.length === 0) {
649
754
  G.next(null), K.current = null;
650
755
  return;
651
756
  }
@@ -657,14 +762,14 @@ var ne = () => {
657
762
  startPath: u
658
763
  });
659
764
  if (!t) return;
660
- e.preventDefault(), F.current = u, G.next(t), K.current = t;
661
- } else e.preventDefault(), F.current = null, oe.current = {
765
+ e.preventDefault(), N.current = u, G.next(t), K.current = t;
766
+ } else e.preventDefault(), N.current = null, le.current = {
662
767
  startLabelWidth: W.data.labelWidth,
663
768
  startX: e.clientX
664
769
  };
665
770
  }
666
771
  }, [W, G]), ye = p((e) => {
667
- let t = N.current, n = I.current, r = C.resolve(D).data, i = oe.current;
772
+ let t = j.current, n = P.current, r = C.resolve(D).data, i = le.current;
668
773
  if (!n || !t) return;
669
774
  if (i) {
670
775
  let t = Math.min($, Math.max(120, i.startLabelWidth + e.clientX - i.startX));
@@ -674,9 +779,9 @@ var ne = () => {
674
779
  }), n.style.cursor = "col-resize";
675
780
  return;
676
781
  }
677
- let a = F.current;
782
+ let a = N.current;
678
783
  if (a) {
679
- let n = P.current;
784
+ let n = M.current;
680
785
  if (!n) return;
681
786
  let i = l.getPathPropertiesFromCanvas({
682
787
  canvas: t,
@@ -692,7 +797,7 @@ var ne = () => {
692
797
  o && (G.next(o), K.current = o);
693
798
  return;
694
799
  }
695
- let s = P.current;
800
+ let s = M.current;
696
801
  if (!s) return;
697
802
  let c = l.getPathPropertiesFromCanvas({
698
803
  canvas: t,
@@ -706,15 +811,15 @@ var ne = () => {
706
811
  $,
707
812
  G
708
813
  ]), be = p(() => {
709
- oe.current = null, F.current = null;
814
+ le.current = null, N.current = null;
710
815
  }, []), xe = p((e, t) => {
711
816
  l.scrollToPosition({
712
817
  geometry: W.data,
713
- scrollContainer: L.current,
818
+ scrollContainer: F.current,
714
819
  x: e,
715
820
  y: t
716
821
  });
717
- }, [W]), Se = Math.max(1, Math.floor(R.width * ce)), Ce = Math.max(1, Math.floor(R.height * ce));
822
+ }, [W]), Se = Math.max(1, Math.floor(I.width * fe)), Ce = Math.max(1, Math.floor(I.height * fe));
718
823
  return /* @__PURE__ */ T(v, {
719
824
  sx: {
720
825
  display: "grid",
@@ -727,7 +832,7 @@ var ne = () => {
727
832
  /* @__PURE__ */ w(d, {}),
728
833
  /* @__PURE__ */ T(v, {
729
834
  onMouseUp: be,
730
- ref: I,
835
+ ref: P,
731
836
  sx: {
732
837
  height: `calc(100% - ${Y.spacing(3)})`,
733
838
  marginBottom: Y.spacing(3),
@@ -740,7 +845,7 @@ var ne = () => {
740
845
  onMouseDown: ve,
741
846
  onMouseMove: ye,
742
847
  onScroll: _e,
743
- ref: L,
848
+ ref: F,
744
849
  sx: {
745
850
  height: "100%",
746
851
  overflowX: "scroll",
@@ -749,24 +854,23 @@ var ne = () => {
749
854
  width: "100%",
750
855
  zIndex: 1
751
856
  },
752
- children: /* @__PURE__ */ w(v, { sx: {
753
- height: `${Math.max(ue, R.height)}px`,
754
- pointerEvents: "none",
755
- width: `${Math.max(fe, R.width)}px`
756
- } })
857
+ children: /* @__PURE__ */ w(v, {
858
+ ref: ue,
859
+ sx: { pointerEvents: "none" }
860
+ })
757
861
  }),
758
862
  /* @__PURE__ */ w("canvas", {
759
863
  height: Ce,
760
- ref: N,
864
+ ref: j,
761
865
  style: {
762
866
  display: "block",
763
- height: `${R.height}px`,
867
+ height: `${I.height}px`,
764
868
  imageRendering: "pixelated",
765
869
  left: 0,
766
870
  pointerEvents: "auto",
767
871
  position: "absolute",
768
872
  top: 0,
769
- width: `${R.width}px`,
873
+ width: `${I.width}px`,
770
874
  zIndex: 0
771
875
  },
772
876
  width: Se
@@ -780,18 +884,19 @@ var ne = () => {
780
884
  width: "100%",
781
885
  zIndex: 2
782
886
  },
783
- children: /* @__PURE__ */ w(ne, {})
887
+ children: /* @__PURE__ */ w(ie, {})
784
888
  })
785
889
  ]
786
890
  }),
787
- /* @__PURE__ */ w(re, {
891
+ /* @__PURE__ */ w(oe, {
788
892
  onGotoPosition: xe,
789
- ref: ie
893
+ ref: se
790
894
  }),
791
- /* @__PURE__ */ w(f, { ref: ae })
895
+ /* @__PURE__ */ w(f, { ref: ce }),
896
+ /* @__PURE__ */ w(te, { ref: ae })
792
897
  ]
793
898
  });
794
899
  };
795
- export { j as t };
900
+ export { se as t };
796
901
 
797
902
  //# sourceMappingURL=SequenceEditor.js.map