@jbrowse/plugin-circular-view 1.5.7 → 1.6.2

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.
@@ -1,17 +1,20 @@
1
1
  import React, { lazy, useState } from 'react';
2
+ import { transaction, when } from 'mobx';
2
3
  import { polarToCartesian, objectFromEntries, assembleLocString, clamp, getSession, isSessionModelWithWidgets, getContainingView, makeAbortableReaction, isAbstractMenuManager, radToDeg } from '@jbrowse/core/util';
3
4
  import Plugin from '@jbrowse/core/Plugin';
4
5
  import ViewType from '@jbrowse/core/pluggableElementTypes/ViewType';
5
6
  import DataUsageIcon from '@material-ui/icons/DataUsage';
6
7
  import { types, getParent, cast, resolveIdentifier, getRoot, getEnv, isAlive } from 'mobx-state-tree';
7
8
  import { Region } from '@jbrowse/core/util/types/mst';
8
- import { transaction } from 'mobx';
9
9
  import { readConfObject, getConf, ConfigurationSchema } from '@jbrowse/core/configuration';
10
10
  import { BaseViewModel, BaseDisplay } from '@jbrowse/core/pluggableElementTypes/models';
11
11
  import CircularChordRendererType from '@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType';
12
12
  import { isFeature } from '@jbrowse/core/util/simpleFeature';
13
13
  import { getParentRenderProps, getTrackAssemblyNames, getRpcSessionId } from '@jbrowse/core/util/tracks';
14
14
  import { observer } from 'mobx-react';
15
+ import { ErrorMessage as ErrorMessage$1, ResizeHandle } from '@jbrowse/core/ui';
16
+ import { Container, Grid, Button, makeStyles as makeStyles$1, IconButton } from '@material-ui/core';
17
+ import { grey } from '@material-ui/core/colors';
15
18
  import ZoomOut from '@material-ui/icons/ZoomOut';
16
19
  import ZoomIn from '@material-ui/icons/ZoomIn';
17
20
  import RotateLeft from '@material-ui/icons/RotateLeft';
@@ -19,11 +22,9 @@ import RotateRight from '@material-ui/icons/RotateRight';
19
22
  import LockOutline from '@material-ui/icons/LockOutlined';
20
23
  import LockOpen from '@material-ui/icons/LockOpen';
21
24
  import { TrackSelector } from '@jbrowse/core/ui/Icons';
22
- import { Container, Grid, Button, makeStyles as makeStyles$1, Typography, IconButton } from '@material-ui/core';
23
- import { grey } from '@material-ui/core/colors';
24
- import { ResizeHandle } from '@jbrowse/core/ui';
25
25
  import { makeContrasting } from '@jbrowse/core/util/color';
26
26
  import { useTheme, makeStyles } from '@material-ui/core/styles';
27
+ import ErrorMessage from '@jbrowse/core/ui/ErrorMessage';
27
28
  import AssemblySelector from '@jbrowse/core/ui/AssemblySelector';
28
29
 
29
30
  function ownKeys(object, enumerableOnly) {
@@ -133,14 +134,14 @@ function _inherits(subClass, superClass) {
133
134
  throw new TypeError("Super expression must either be null or a function");
134
135
  }
135
136
 
137
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
138
+ constructor: {
139
+ value: subClass,
140
+ writable: true,
141
+ configurable: true
142
+ }
143
+ });
136
144
  Object.defineProperty(subClass, "prototype", {
137
- value: Object.create(superClass && superClass.prototype, {
138
- constructor: {
139
- value: subClass,
140
- writable: true,
141
- configurable: true
142
- }
143
- }),
144
145
  writable: false
145
146
  });
146
147
  if (superClass) _setPrototypeOf(subClass, superClass);
@@ -380,1758 +381,1759 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
380
381
  };
381
382
  }
382
383
 
383
- function findCircleIntersectionX(y, cx, cy, r, resultArray) {
384
- var d = Math.abs(y - cy);
384
+ function createCommonjsModule(fn, module) {
385
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
386
+ }
385
387
 
386
- if (d > r) {
387
- return;
388
- }
388
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
389
+ /**
390
+ * Copyright (c) 2014-present, Facebook, Inc.
391
+ *
392
+ * This source code is licensed under the MIT license found in the
393
+ * LICENSE file in the root directory of this source tree.
394
+ */
395
+ var runtime = function (exports) {
389
396
 
390
- if (d === r) {
391
- resultArray.push([cx, y]);
392
- }
397
+ var Op = Object.prototype;
398
+ var hasOwn = Op.hasOwnProperty;
399
+ var undefined$1; // More compressible than void 0.
393
400
 
394
- var solution = Math.sqrt(r * r - d * d);
395
- resultArray.push([cx - solution, y]);
396
- resultArray.push([cx + solution, y]);
397
- }
401
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
402
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
403
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
404
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
398
405
 
399
- function findCircleIntersectionY(x, cx, cy, r, resultArray) {
400
- var d = Math.abs(x - cx);
406
+ function define(obj, key, value) {
407
+ Object.defineProperty(obj, key, {
408
+ value: value,
409
+ enumerable: true,
410
+ configurable: true,
411
+ writable: true
412
+ });
413
+ return obj[key];
414
+ }
401
415
 
402
- if (d > r) {
403
- return;
404
- }
416
+ try {
417
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
418
+ define({}, "");
419
+ } catch (err) {
420
+ define = function define(obj, key, value) {
421
+ return obj[key] = value;
422
+ };
423
+ }
405
424
 
406
- if (d === r) {
407
- resultArray.push([x, cy]);
408
- }
425
+ function wrap(innerFn, outerFn, self, tryLocsList) {
426
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
427
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
428
+ var generator = Object.create(protoGenerator.prototype);
429
+ var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
430
+ // .throw, and .return methods.
409
431
 
410
- var solution = Math.sqrt(r * r - d * d);
411
- resultArray.push([x, cy - solution]);
412
- resultArray.push([x, cy + solution]);
413
- }
432
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
433
+ return generator;
434
+ }
414
435
 
415
- function cartesianToTheta(x, y) {
416
- var theta = (Math.atan(y / x) + 2 * Math.PI) % (2 * Math.PI);
436
+ exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
437
+ // record like context.tryEntries[i].completion. This interface could
438
+ // have been (and was previously) designed to take a closure to be
439
+ // invoked without arguments, but in all the cases we care about we
440
+ // already have an existing method we want to call, so there's no need
441
+ // to create a new function object. We can even get away with assuming
442
+ // the method takes exactly one argument, since that happens to be true
443
+ // in every case, so we don't have to touch the arguments object. The
444
+ // only additional allocation required is the completion record, which
445
+ // has a stable shape and so hopefully should be cheap to allocate.
417
446
 
418
- if (x < 0) {
419
- if (y <= 0) {
420
- theta += Math.PI;
421
- } else {
422
- theta -= Math.PI;
447
+ function tryCatch(fn, obj, arg) {
448
+ try {
449
+ return {
450
+ type: "normal",
451
+ arg: fn.call(obj, arg)
452
+ };
453
+ } catch (err) {
454
+ return {
455
+ type: "throw",
456
+ arg: err
457
+ };
458
+ }
423
459
  }
424
- }
425
460
 
426
- return theta;
427
- }
461
+ var GenStateSuspendedStart = "suspendedStart";
462
+ var GenStateSuspendedYield = "suspendedYield";
463
+ var GenStateExecuting = "executing";
464
+ var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
465
+ // breaking out of the dispatch switch statement.
428
466
 
429
- function cartesianToPolar(x, y) {
430
- var rho = Math.sqrt(x * x + y * y);
467
+ var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
468
+ // .constructor.prototype properties for functions that return Generator
469
+ // objects. For full spec compliance, you may wish to configure your
470
+ // minifier not to mangle the names of these two functions.
431
471
 
432
- if (rho === 0) {
433
- return [0, 0];
434
- }
472
+ function Generator() {}
435
473
 
436
- var theta = cartesianToTheta(x, y);
437
- return [rho, theta];
438
- }
439
- var twoPi = 2 * Math.PI;
440
- function thetaRangesOverlap(r1start, r1length, r2start, r2length) {
441
- if (r1length <= 0 || r2length <= 0) {
442
- return false;
443
- }
474
+ function GeneratorFunction() {}
444
475
 
445
- if (r1length + 0.0001 >= twoPi || r2length + 0.0001 >= twoPi) {
446
- return true;
447
- } // put both range starts between 2π and 4π
476
+ function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
477
+ // don't natively support it.
448
478
 
449
479
 
450
- r1start = (r1start % twoPi + twoPi) % twoPi + twoPi;
451
- r2start = (r2start % twoPi + twoPi) % twoPi + twoPi;
480
+ var IteratorPrototype = {};
481
+ define(IteratorPrototype, iteratorSymbol, function () {
482
+ return this;
483
+ });
484
+ var getProto = Object.getPrototypeOf;
485
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
452
486
 
453
- if (r1start < r2start + r2length && r1start + r1length > r2start) {
454
- return true;
455
- } // move r2 2π to the left and check
487
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
488
+ // This environment has a native %IteratorPrototype%; use it instead
489
+ // of the polyfill.
490
+ IteratorPrototype = NativeIteratorPrototype;
491
+ }
456
492
 
493
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
494
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
495
+ define(Gp, "constructor", GeneratorFunctionPrototype);
496
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
497
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
498
+ // Iterator interface in terms of a single ._invoke method.
457
499
 
458
- r2start -= twoPi;
500
+ function defineIteratorMethods(prototype) {
501
+ ["next", "throw", "return"].forEach(function (method) {
502
+ define(prototype, method, function (arg) {
503
+ return this._invoke(method, arg);
504
+ });
505
+ });
506
+ }
459
507
 
460
- if (r1start < r2start + r2length && r1start + r1length > r2start) {
461
- return true;
462
- } // move it to the right and check
508
+ exports.isGeneratorFunction = function (genFun) {
509
+ var ctor = typeof genFun === "function" && genFun.constructor;
510
+ return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
511
+ // do is to check its .name property.
512
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
513
+ };
463
514
 
515
+ exports.mark = function (genFun) {
516
+ if (Object.setPrototypeOf) {
517
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
518
+ } else {
519
+ genFun.__proto__ = GeneratorFunctionPrototype;
520
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
521
+ }
464
522
 
465
- r2start += twoPi + twoPi;
466
- return r1start < r2start + r2length && r1start + r1length > r2start;
467
- } // return which arc range has any part of the circle visible in the viewport
523
+ genFun.prototype = Object.create(Gp);
524
+ return genFun;
525
+ }; // Within the body of any async function, `await x` is transformed to
526
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
527
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
528
+ // meant to be awaited.
468
529
 
469
- function viewportVisibleSection(viewSides, circleCenter, circleRadius) {
470
- var _viewSides = _slicedToArray(viewSides, 4),
471
- viewL = _viewSides[0],
472
- viewR = _viewSides[1],
473
- viewT = _viewSides[2],
474
- viewB = _viewSides[3];
475
530
 
476
- var _circleCenter = _slicedToArray(circleCenter, 2),
477
- cx = _circleCenter[0],
478
- cy = _circleCenter[1]; // transform coordinate system to center of circle
531
+ exports.awrap = function (arg) {
532
+ return {
533
+ __await: arg
534
+ };
535
+ };
479
536
 
537
+ function AsyncIterator(generator, PromiseImpl) {
538
+ function invoke(method, arg, resolve, reject) {
539
+ var record = tryCatch(generator[method], generator, arg);
480
540
 
481
- viewL -= cx;
482
- viewR -= cx;
483
- viewT -= cy;
484
- viewB -= cy;
485
- var centerIsInsideViewport = viewL < 0 && viewR > 0 && viewT < 0 && viewB > 0;
541
+ if (record.type === "throw") {
542
+ reject(record.arg);
543
+ } else {
544
+ var result = record.arg;
545
+ var value = result.value;
486
546
 
487
- if (centerIsInsideViewport) {
488
- var _vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
489
- var maxRho = -Infinity;
547
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
548
+ return PromiseImpl.resolve(value.__await).then(function (value) {
549
+ invoke("next", value, resolve, reject);
550
+ }, function (err) {
551
+ invoke("throw", err, resolve, reject);
552
+ });
553
+ }
490
554
 
491
- for (var i = 0; i < _vertices.length; i += 1) {
492
- var _vertices$i = _slicedToArray(_vertices[i], 2),
493
- x = _vertices$i[0],
494
- y = _vertices$i[1];
555
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
556
+ // When a yielded Promise is resolved, its final value becomes
557
+ // the .value of the Promise<{value,done}> result for the
558
+ // current iteration.
559
+ result.value = unwrapped;
560
+ resolve(result);
561
+ }, function (error) {
562
+ // If a rejected Promise was yielded, throw the rejection back
563
+ // into the async generator function so it can be handled there.
564
+ return invoke("throw", error, resolve, reject);
565
+ });
566
+ }
567
+ }
495
568
 
496
- var rho = Math.sqrt(x * x + y * y);
569
+ var previousPromise;
497
570
 
498
- if (rho > maxRho) {
499
- maxRho = rho;
500
- }
501
- }
571
+ function enqueue(method, arg) {
572
+ function callInvokeWithMethodAndArg() {
573
+ return new PromiseImpl(function (resolve, reject) {
574
+ invoke(method, arg, resolve, reject);
575
+ });
576
+ }
502
577
 
503
- return {
504
- rho: [0, Math.min(circleRadius, maxRho)],
505
- theta: [0, 2 * Math.PI]
578
+ return previousPromise = // If enqueue has been called before, then we want to wait until
579
+ // all previous Promises have been resolved before calling invoke,
580
+ // so that results are always delivered in the correct order. If
581
+ // enqueue has not been called before, then it is important to
582
+ // call invoke immediately, without waiting on a callback to fire,
583
+ // so that the async generator function has the opportunity to do
584
+ // any necessary setup in a predictable way. This predictability
585
+ // is why the Promise constructor synchronously invokes its
586
+ // executor callback, and why async functions synchronously
587
+ // execute code before the first await. Since we implement simple
588
+ // async functions in terms of async generators, it is especially
589
+ // important to get this right, even though it requires care.
590
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
591
+ // invocations of the iterator.
592
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
593
+ } // Define the unified helper method that is used to implement .next,
594
+ // .throw, and .return (see defineIteratorMethods).
595
+
596
+
597
+ this._invoke = enqueue;
598
+ }
599
+
600
+ defineIteratorMethods(AsyncIterator.prototype);
601
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
602
+ return this;
603
+ });
604
+ exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
605
+ // AsyncIterator objects; they just return a Promise for the value of
606
+ // the final result produced by the iterator.
607
+
608
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
609
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
610
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
611
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
612
+ : iter.next().then(function (result) {
613
+ return result.done ? result.value : iter.next();
614
+ });
506
615
  };
507
- } // const viewportCompletelyContainsCircle =
508
- // circleCenter[0] - viewL >= circleRadius &&
509
- // viewR - circleCenter[0] >= circleRadius &&
510
- // circleCenter[1] - viewT >= circleRadius &&
511
- // viewB - circleCenter[1] >= circleRadius
512
- // if (viewportCompletelyContainsCircle) {
513
- // return [0, 2 * Math.PI]
514
- // }
515
- // const distToCenterSquared = ([x, y]) => {
516
- // const [cx, cy] = circleCenter
517
- // const sq = n => n * n
518
- // return sq(x - cx) + sq(y - cy)
519
- // }
520
- // const circleRadiusSquared = circleRadius * circleRadius
521
- // const tlInside = distToCenterSquared([viewL, viewT]) <= circleRadiusSquared
522
- // const trInside = distToCenterSquared([viewR, viewT]) <= circleRadiusSquared
523
- // const blInside = distToCenterSquared([viewL, viewB]) <= circleRadiusSquared
524
- // const brInside = distToCenterSquared([viewR, viewB]) <= circleRadiusSquared
525
- // const noIntersection = !tlInside && !trInside && !blInside && !brInside
526
- // if (noIntersection) return undefined
527
- // const circleCompletelyContainsViewport =
528
- // tlInside && trInside && blInside && brInside
529
- // if (circleCompletelyContainsViewport) {
530
- // // viewport is in the circle, but the center is not in it, so take max
531
- // // and min of thetas to the center
532
- // const thetas = [
533
- // Math.atan(viewT / viewL),
534
- // Math.atan(viewT / viewR),
535
- // Math.atan(viewB / viewL),
536
- // Math.atan(viewB / viewR),
537
- // ]
538
- // return [Math.min(...thetas), Math.max(...thetas)]
539
- // }
540
- // if we get here, the viewport is partly in, partly out of the circle
541
- // const viewLIntersects = Math.abs(viewL - circleCenter[0]) <= circleRadius
542
- // const viewRIntersects = Math.abs(viewR - circleCenter[0]) <= circleRadius
543
- // const viewTIntersects = Math.abs(viewT - circleCenter[1]) <= circleRadius
544
- // const viewBIntersects = Math.abs(viewB - circleCenter[1]) <= circleRadius
545
- // const numIntersectingSides =
546
- // Number(viewLIntersects) +
547
- // Number(viewRIntersects) +
548
- // Number(viewTIntersects) +
549
- // Number(viewBIntersects)
550
- // if (numIntersectingSides === 4) return [0, 2 * Math.PI]
551
- // if (numIntersectingSides === 3) {
552
- // // TODO calculate the thetas of the
553
- // } else if (numIntersectingSides === 2) {
554
- // // TODO calculate the thetas of the 2 intersection points
555
- // } else if (numIntersectingSides === 1) {
556
- // // TODO calculate the thetas of the 1-2 intersection points of the line, and the angle between
557
- // }
558
- // make a list of vertices-of-interest that lie inside both shapes to examine
559
- // to determine the range covered by their intersection
560
- // transform coordinates to have the circle as the origin and find the intersections
561
- // of the circle and the view rectangle
562
616
 
617
+ function makeInvokeMethod(innerFn, self, context) {
618
+ var state = GenStateSuspendedStart;
619
+ return function invoke(method, arg) {
620
+ if (state === GenStateExecuting) {
621
+ throw new Error("Generator is already running");
622
+ }
563
623
 
564
- var vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
565
- findCircleIntersectionY(viewL, 0, 0, circleRadius, vertices);
566
- findCircleIntersectionY(viewR, 0, 0, circleRadius, vertices);
567
- findCircleIntersectionX(viewT, 0, 0, circleRadius, vertices);
568
- findCircleIntersectionX(viewB, 0, 0, circleRadius, vertices); // for each edge, also look at the closest point to center if it is inside the circle
624
+ if (state === GenStateCompleted) {
625
+ if (method === "throw") {
626
+ throw arg;
627
+ } // Be forgiving, per 25.3.3.3.3 of the spec:
628
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
569
629
 
570
- if (-viewL < circleRadius) {
571
- vertices.push([viewL, 0]);
572
- }
573
630
 
574
- if (viewR < circleRadius) {
575
- vertices.push([viewR, 0]);
576
- }
631
+ return doneResult();
632
+ }
577
633
 
578
- if (-viewT < circleRadius) {
579
- vertices.push([0, viewT]);
580
- }
634
+ context.method = method;
635
+ context.arg = arg;
581
636
 
582
- if (viewB < circleRadius) {
583
- vertices.push([0, viewB]);
584
- } // const verticesOriginal = vertices.map(([x, y]) => [x + cx, y + cy])
585
- // now convert them all to polar and take the max and min of rho and theta
586
- // const viewportCenterTheta = cartesianToTheta(viewR + viewL, viewT + viewB)
637
+ while (true) {
638
+ var delegate = context.delegate;
587
639
 
640
+ if (delegate) {
641
+ var delegateResult = maybeInvokeDelegate(delegate, context);
588
642
 
589
- var reflect = viewL >= 0 ? -1 : 1; // viewportCenterTheta < Math.PI / 2 || viewportCenterTheta > 1.5 * Math.PI
590
- // ? -1
591
- // : 1
643
+ if (delegateResult) {
644
+ if (delegateResult === ContinueSentinel) continue;
645
+ return delegateResult;
646
+ }
647
+ }
592
648
 
593
- var rhoMin = Infinity;
594
- var rhoMax = -Infinity;
595
- var thetaMin = Infinity;
596
- var thetaMax = -Infinity;
649
+ if (context.method === "next") {
650
+ // Setting context._sent for legacy support of Babel's
651
+ // function.sent implementation.
652
+ context.sent = context._sent = context.arg;
653
+ } else if (context.method === "throw") {
654
+ if (state === GenStateSuspendedStart) {
655
+ state = GenStateCompleted;
656
+ throw context.arg;
657
+ }
597
658
 
598
- for (var _i = 0; _i < vertices.length; _i += 1) {
599
- // ignore vertex if outside the viewport
600
- var _vertices$_i = _slicedToArray(vertices[_i], 2),
601
- vx = _vertices$_i[0],
602
- vy = _vertices$_i[1];
659
+ context.dispatchException(context.arg);
660
+ } else if (context.method === "return") {
661
+ context.abrupt("return", context.arg);
662
+ }
603
663
 
604
- if (vx >= viewL && vx <= viewR && vy >= viewT && vy <= viewB) {
605
- var _cartesianToPolar = cartesianToPolar(vx * reflect, vy * reflect),
606
- _cartesianToPolar2 = _slicedToArray(_cartesianToPolar, 2),
607
- _rho = _cartesianToPolar2[0],
608
- theta = _cartesianToPolar2[1]; // ignore vertex if outside the circle
664
+ state = GenStateExecuting;
665
+ var record = tryCatch(innerFn, self, context);
609
666
 
667
+ if (record.type === "normal") {
668
+ // If an exception is thrown from innerFn, we leave state ===
669
+ // GenStateExecuting and loop back for another invocation.
670
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
610
671
 
611
- if (_rho <= circleRadius + 0.001) {
612
- // ignore theta if rho is 0
613
- if (theta < thetaMin && _rho > 0.0001) {
614
- thetaMin = theta;
615
- }
672
+ if (record.arg === ContinueSentinel) {
673
+ continue;
674
+ }
616
675
 
617
- if (theta > thetaMax && _rho > 0.0001) {
618
- thetaMax = theta;
619
- }
676
+ return {
677
+ value: record.arg,
678
+ done: context.done
679
+ };
680
+ } else if (record.type === "throw") {
681
+ state = GenStateCompleted; // Dispatch the exception by looping back around to the
682
+ // context.dispatchException(context.arg) call above.
620
683
 
621
- if (_rho < rhoMin) {
622
- rhoMin = _rho;
684
+ context.method = "throw";
685
+ context.arg = record.arg;
686
+ }
623
687
  }
688
+ };
689
+ } // Call delegate.iterator[context.method](context.arg) and handle the
690
+ // result, either by returning a { value, done } result from the
691
+ // delegate iterator, or by modifying context.method and context.arg,
692
+ // setting context.delegate to null, and returning the ContinueSentinel.
624
693
 
625
- if (_rho > rhoMax) {
626
- rhoMax = _rho;
694
+
695
+ function maybeInvokeDelegate(delegate, context) {
696
+ var method = delegate.iterator[context.method];
697
+
698
+ if (method === undefined$1) {
699
+ // A .throw or .return when the delegate iterator has no .throw
700
+ // method always terminates the yield* loop.
701
+ context.delegate = null;
702
+
703
+ if (context.method === "throw") {
704
+ // Note: ["return"] must be used for ES3 parsing compatibility.
705
+ if (delegate.iterator["return"]) {
706
+ // If the delegate iterator has a return method, give it a
707
+ // chance to clean up.
708
+ context.method = "return";
709
+ context.arg = undefined$1;
710
+ maybeInvokeDelegate(delegate, context);
711
+
712
+ if (context.method === "throw") {
713
+ // If maybeInvokeDelegate(context) changed context.method from
714
+ // "return" to "throw", let that override the TypeError below.
715
+ return ContinueSentinel;
716
+ }
717
+ }
718
+
719
+ context.method = "throw";
720
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
627
721
  }
722
+
723
+ return ContinueSentinel;
628
724
  }
629
- }
630
- }
631
725
 
632
- if (reflect === -1) {
633
- thetaMin += Math.PI;
634
- thetaMax += Math.PI;
635
- }
726
+ var record = tryCatch(method, delegate.iterator, context.arg);
636
727
 
637
- if (thetaMin > 2 * Math.PI && thetaMax > 2 * Math.PI) {
638
- thetaMin -= 2 * Math.PI;
639
- thetaMax -= 2 * Math.PI;
640
- }
728
+ if (record.type === "throw") {
729
+ context.method = "throw";
730
+ context.arg = record.arg;
731
+ context.delegate = null;
732
+ return ContinueSentinel;
733
+ }
641
734
 
642
- return {
643
- rho: [rhoMin, Math.min(circleRadius, rhoMax)],
644
- theta: [thetaMin, thetaMax]
645
- };
646
- }
735
+ var info = record.arg;
647
736
 
648
- var Slice = /*#__PURE__*/function () {
649
- function Slice(view, region, currentRadianOffset, radianWidth) {
650
- _classCallCheck(this, Slice);
737
+ if (!info) {
738
+ context.method = "throw";
739
+ context.arg = new TypeError("iterator result is not an object");
740
+ context.delegate = null;
741
+ return ContinueSentinel;
742
+ }
651
743
 
652
- this.region = region;
653
- this.radianWidth = radianWidth;
654
- var bpPerRadian = view.bpPerRadian;
655
- this.key = assembleLocString(region);
656
- this.offsetRadians = currentRadianOffset;
657
- this.bpPerRadian = bpPerRadian;
658
- this.flipped = false;
659
- this.startRadians = this.offsetRadians;
660
- this.endRadians = region.widthBp / this.bpPerRadian + this.offsetRadians;
661
- Object.freeze(this);
662
- }
744
+ if (info.done) {
745
+ // Assign the result of the finished delegate to the temporary
746
+ // variable specified by delegate.resultName (see delegateYield).
747
+ context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
663
748
 
664
- _createClass(Slice, [{
665
- key: "bpToXY",
666
- value: function bpToXY(bp, radiusPx) {
667
- var offsetBp;
749
+ context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
750
+ // exception, let the outer generator proceed normally. If
751
+ // context.method was "next", forget context.arg since it has been
752
+ // "consumed" by the delegate iterator. If context.method was
753
+ // "return", allow the original .return call to continue in the
754
+ // outer generator.
668
755
 
669
- if (this.region.elided) {
670
- offsetBp = this.region.widthBp / 2;
671
- } else if (this.flipped) {
672
- offsetBp = this.region.end - bp;
756
+ if (context.method !== "return") {
757
+ context.method = "next";
758
+ context.arg = undefined$1;
759
+ }
673
760
  } else {
674
- offsetBp = bp - this.region.start;
675
- }
761
+ // Re-yield the result returned by the delegate method.
762
+ return info;
763
+ } // The delegate iterator is finished, so forget it and continue with
764
+ // the outer generator.
676
765
 
677
- var totalRadians = offsetBp / this.bpPerRadian + this.offsetRadians;
678
- return polarToCartesian(radiusPx, totalRadians);
679
- }
680
- }, {
681
- key: "toJSON",
682
- value: function toJSON() {
683
- return objectFromEntries(Object.entries(this));
684
- }
685
- }]);
686
766
 
687
- return Slice;
688
- }(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
767
+ context.delegate = null;
768
+ return ContinueSentinel;
769
+ } // Define Generator.prototype.{next,throw,return} in terms of the
770
+ // unified ._invoke helper method.
689
771
 
690
- function calculateStaticSlices(self) {
691
- var slices = [];
692
- var currentRadianOffset = 0;
693
772
 
694
- var _iterator = _createForOfIteratorHelper(self.elidedRegions),
695
- _step;
773
+ defineIteratorMethods(Gp);
774
+ define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
775
+ // @@iterator function is called on it. Some browsers' implementations of the
776
+ // iterator prototype chain incorrectly implement this, causing the Generator
777
+ // object to not be returned from this call. This ensures that doesn't happen.
778
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
696
779
 
697
- try {
698
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
699
- var region = _step.value;
700
- var radianWidth = region.widthBp / self.bpPerRadian + self.spacingPx / self.pxPerRadian;
701
- slices.push(new Slice(self, region, currentRadianOffset, radianWidth));
702
- currentRadianOffset += radianWidth;
703
- }
704
- } catch (err) {
705
- _iterator.e(err);
706
- } finally {
707
- _iterator.f();
708
- }
780
+ define(Gp, iteratorSymbol, function () {
781
+ return this;
782
+ });
783
+ define(Gp, "toString", function () {
784
+ return "[object Generator]";
785
+ });
709
786
 
710
- return slices;
711
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
787
+ function pushTryEntry(locs) {
788
+ var entry = {
789
+ tryLoc: locs[0]
790
+ };
712
791
 
792
+ if (1 in locs) {
793
+ entry.catchLoc = locs[1];
794
+ }
713
795
 
714
- function sliceIsVisible(self, slice) {
715
- var _self$visibleSection$ = _slicedToArray(self.visibleSection.theta, 2),
716
- visibleThetaMin = _self$visibleSection$[0],
717
- visibleThetaMax = _self$visibleSection$[1];
796
+ if (2 in locs) {
797
+ entry.finallyLoc = locs[2];
798
+ entry.afterLoc = locs[3];
799
+ }
718
800
 
719
- return thetaRangesOverlap(slice.offsetRadians + self.offsetRadians, slice.radianWidth, visibleThetaMin, visibleThetaMax - visibleThetaMin);
720
- }
801
+ this.tryEntries.push(entry);
802
+ }
721
803
 
722
- function CircularView(pluginManager) {
723
- var minHeight = 40;
724
- var minWidth = 100;
725
- var defaultHeight = 400;
726
- return types.compose(BaseViewModel, types.model('CircularView', {
727
- type: types.literal('CircularView'),
728
- offsetRadians: -Math.PI / 2,
729
- bpPerPx: 2000000,
730
- tracks: types.array(pluginManager.pluggableMstType('track', 'stateModel')),
731
- hideVerticalResizeHandle: false,
732
- hideTrackSelectorButton: false,
733
- lockedFitToWindow: true,
734
- disableImportForm: false,
735
- height: types.optional(types.refinement('trackHeight', types.number, function (n) {
736
- return n >= minHeight;
737
- }), defaultHeight),
738
- minimumRadiusPx: 25,
739
- spacingPx: 10,
740
- paddingPx: 80,
741
- lockedPaddingPx: 100,
742
- minVisibleWidth: 6,
743
- minimumBlockWidth: 20,
744
- displayedRegions: types.array(Region),
745
- scrollX: 0,
746
- scrollY: 0,
747
- trackSelectorType: 'hierarchical'
748
- })["volatile"](function () {
749
- return {
750
- width: 800
751
- };
752
- }).views(function (self) {
753
- return {
754
- get staticSlices() {
755
- return calculateStaticSlices(self);
756
- },
804
+ function resetTryEntry(entry) {
805
+ var record = entry.completion || {};
806
+ record.type = "normal";
807
+ delete record.arg;
808
+ entry.completion = record;
809
+ }
757
810
 
758
- get visibleStaticSlices() {
759
- return this.staticSlices.filter(sliceIsVisible.bind(this, self));
760
- },
811
+ function Context(tryLocsList) {
812
+ // The root entry object (effectively a try statement without a catch
813
+ // or a finally block) gives us a place to store values thrown from
814
+ // locations where there is no enclosing try statement.
815
+ this.tryEntries = [{
816
+ tryLoc: "root"
817
+ }];
818
+ tryLocsList.forEach(pushTryEntry, this);
819
+ this.reset(true);
820
+ }
761
821
 
762
- get visibleSection() {
763
- return viewportVisibleSection([self.scrollX, self.scrollX + self.width, self.scrollY, self.scrollY + self.height], this.centerXY, this.radiusPx);
764
- },
822
+ exports.keys = function (object) {
823
+ var keys = [];
765
824
 
766
- get circumferencePx() {
767
- var elidedBp = 0;
825
+ for (var key in object) {
826
+ keys.push(key);
827
+ }
768
828
 
769
- var _iterator = _createForOfIteratorHelper(this.elidedRegions),
770
- _step;
829
+ keys.reverse(); // Rather than returning an object with a next method, we keep
830
+ // things simple and return the next function itself.
771
831
 
772
- try {
773
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
774
- var r = _step.value;
775
- elidedBp += r.widthBp;
832
+ return function next() {
833
+ while (keys.length) {
834
+ var key = keys.pop();
835
+
836
+ if (key in object) {
837
+ next.value = key;
838
+ next.done = false;
839
+ return next;
776
840
  }
777
- } catch (err) {
778
- _iterator.e(err);
779
- } finally {
780
- _iterator.f();
781
- }
841
+ } // To avoid creating an additional object, we just hang the .value
842
+ // and .done properties off the next function object itself. This
843
+ // also ensures that the minifier will not anonymize the function.
782
844
 
783
- return elidedBp / self.bpPerPx + self.spacingPx * this.elidedRegions.length;
784
- },
785
845
 
786
- get radiusPx() {
787
- return this.circumferencePx / (2 * Math.PI);
788
- },
846
+ next.done = true;
847
+ return next;
848
+ };
849
+ };
789
850
 
790
- get bpPerRadian() {
791
- return self.bpPerPx * this.radiusPx;
792
- },
851
+ function values(iterable) {
852
+ if (iterable) {
853
+ var iteratorMethod = iterable[iteratorSymbol];
793
854
 
794
- get pxPerRadian() {
795
- return this.radiusPx;
796
- },
855
+ if (iteratorMethod) {
856
+ return iteratorMethod.call(iterable);
857
+ }
797
858
 
798
- get centerXY() {
799
- return [this.radiusPx + self.paddingPx, this.radiusPx + self.paddingPx];
800
- },
859
+ if (typeof iterable.next === "function") {
860
+ return iterable;
861
+ }
801
862
 
802
- get totalBp() {
803
- var total = 0;
863
+ if (!isNaN(iterable.length)) {
864
+ var i = -1,
865
+ next = function next() {
866
+ while (++i < iterable.length) {
867
+ if (hasOwn.call(iterable, i)) {
868
+ next.value = iterable[i];
869
+ next.done = false;
870
+ return next;
871
+ }
872
+ }
804
873
 
805
- var _iterator2 = _createForOfIteratorHelper(self.displayedRegions),
806
- _step2;
874
+ next.value = undefined$1;
875
+ next.done = true;
876
+ return next;
877
+ };
807
878
 
808
- try {
809
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
810
- var region = _step2.value;
811
- total += region.end - region.start;
812
- }
813
- } catch (err) {
814
- _iterator2.e(err);
815
- } finally {
816
- _iterator2.f();
879
+ return next.next = next;
817
880
  }
881
+ } // Return an iterator with no values.
818
882
 
819
- return total;
820
- },
821
883
 
822
- get maximumRadiusPx() {
823
- return self.lockedFitToWindow ? Math.min(self.width, self.height) / 2 - self.lockedPaddingPx : 1000000;
824
- },
884
+ return {
885
+ next: doneResult
886
+ };
887
+ }
825
888
 
826
- get maxBpPerPx() {
827
- var minCircumferencePx = 2 * Math.PI * self.minimumRadiusPx;
828
- return this.totalBp / minCircumferencePx;
829
- },
889
+ exports.values = values;
830
890
 
831
- get minBpPerPx() {
832
- // min depends on window dimensions, clamp between old min(0.01) and max
833
- var maxCircumferencePx = 2 * Math.PI * this.maximumRadiusPx;
834
- return clamp(this.totalBp / maxCircumferencePx, 0.0000000001, this.maxBpPerPx);
835
- },
891
+ function doneResult() {
892
+ return {
893
+ value: undefined$1,
894
+ done: true
895
+ };
896
+ }
836
897
 
837
- get atMaxBpPerPx() {
838
- return self.bpPerPx >= this.maxBpPerPx;
839
- },
898
+ Context.prototype = {
899
+ constructor: Context,
900
+ reset: function reset(skipTempReset) {
901
+ this.prev = 0;
902
+ this.next = 0; // Resetting context._sent for legacy support of Babel's
903
+ // function.sent implementation.
840
904
 
841
- get atMinBpPerPx() {
842
- return self.bpPerPx <= this.minBpPerPx;
843
- },
905
+ this.sent = this._sent = undefined$1;
906
+ this.done = false;
907
+ this.delegate = null;
908
+ this.method = "next";
909
+ this.arg = undefined$1;
910
+ this.tryEntries.forEach(resetTryEntry);
844
911
 
845
- get tooSmallToLock() {
846
- return this.minBpPerPx <= 0.0000000001;
912
+ if (!skipTempReset) {
913
+ for (var name in this) {
914
+ // Not sure about the optimal order of these conditions:
915
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
916
+ this[name] = undefined$1;
917
+ }
918
+ }
919
+ }
847
920
  },
921
+ stop: function stop() {
922
+ this.done = true;
923
+ var rootEntry = this.tryEntries[0];
924
+ var rootRecord = rootEntry.completion;
848
925
 
849
- get figureDimensions() {
850
- return [this.radiusPx * 2 + 2 * self.paddingPx, this.radiusPx * 2 + 2 * self.paddingPx];
851
- },
926
+ if (rootRecord.type === "throw") {
927
+ throw rootRecord.arg;
928
+ }
852
929
 
853
- get figureWidth() {
854
- return this.figureDimensions[0];
930
+ return this.rval;
855
931
  },
932
+ dispatchException: function dispatchException(exception) {
933
+ if (this.done) {
934
+ throw exception;
935
+ }
856
936
 
857
- get figureHeight() {
858
- return this.figureDimensions[1];
859
- },
937
+ var context = this;
860
938
 
861
- // this is displayedRegions, post-processed to
862
- // elide regions that are too small to see reasonably
863
- get elidedRegions() {
864
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
865
- var visible = [];
866
- self.displayedRegions.forEach(function (region) {
867
- var widthBp = region.end - region.start;
868
- var widthPx = widthBp / self.bpPerPx;
939
+ function handle(loc, caught) {
940
+ record.type = "throw";
941
+ record.arg = exception;
942
+ context.next = loc;
869
943
 
870
- if (widthPx < self.minVisibleWidth) {
871
- // too small to see, collapse into a single elision region
872
- var lastVisible = visible[visible.length - 1];
944
+ if (caught) {
945
+ // If the dispatched exception was caught by a catch block,
946
+ // then let that catch block handle the exception normally.
947
+ context.method = "next";
948
+ context.arg = undefined$1;
949
+ }
873
950
 
874
- if (lastVisible && lastVisible.elided) {
875
- lastVisible.regions.push(_objectSpread2({}, region));
876
- lastVisible.widthBp += widthBp;
951
+ return !!caught;
952
+ }
953
+
954
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
955
+ var entry = this.tryEntries[i];
956
+ var record = entry.completion;
957
+
958
+ if (entry.tryLoc === "root") {
959
+ // Exception thrown outside of any try block that could handle
960
+ // it, so set the completion value of the entire function to
961
+ // throw the exception.
962
+ return handle("end");
963
+ }
964
+
965
+ if (entry.tryLoc <= this.prev) {
966
+ var hasCatch = hasOwn.call(entry, "catchLoc");
967
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
968
+
969
+ if (hasCatch && hasFinally) {
970
+ if (this.prev < entry.catchLoc) {
971
+ return handle(entry.catchLoc, true);
972
+ } else if (this.prev < entry.finallyLoc) {
973
+ return handle(entry.finallyLoc);
974
+ }
975
+ } else if (hasCatch) {
976
+ if (this.prev < entry.catchLoc) {
977
+ return handle(entry.catchLoc, true);
978
+ }
979
+ } else if (hasFinally) {
980
+ if (this.prev < entry.finallyLoc) {
981
+ return handle(entry.finallyLoc);
982
+ }
877
983
  } else {
878
- visible.push({
879
- elided: true,
880
- widthBp: widthBp,
881
- regions: [_objectSpread2({}, region)]
882
- });
984
+ throw new Error("try statement without catch or finally");
883
985
  }
884
- } else {
885
- // big enough to see, display it
886
- visible.push(_objectSpread2(_objectSpread2({}, region), {}, {
887
- widthBp: widthBp
888
- }));
889
986
  }
890
- }); // remove any single-region elisions
891
-
892
- for (var i = 0; i < visible.length; i += 1) {
893
- var v = visible[i];
987
+ }
988
+ },
989
+ abrupt: function abrupt(type, arg) {
990
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
991
+ var entry = this.tryEntries[i];
894
992
 
895
- if (v.elided && v.regions.length === 1) {
896
- delete v.elided;
897
- visible[i] = _objectSpread2(_objectSpread2({}, v), v.regions[0]);
993
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
994
+ var finallyEntry = entry;
995
+ break;
898
996
  }
899
997
  }
900
998
 
901
- return visible;
999
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1000
+ // Ignore the finally entry if control is not jumping to a
1001
+ // location outside the try/catch block.
1002
+ finallyEntry = null;
1003
+ }
1004
+
1005
+ var record = finallyEntry ? finallyEntry.completion : {};
1006
+ record.type = type;
1007
+ record.arg = arg;
1008
+
1009
+ if (finallyEntry) {
1010
+ this.method = "next";
1011
+ this.next = finallyEntry.finallyLoc;
1012
+ return ContinueSentinel;
1013
+ }
1014
+
1015
+ return this.complete(record);
902
1016
  },
1017
+ complete: function complete(record, afterLoc) {
1018
+ if (record.type === "throw") {
1019
+ throw record.arg;
1020
+ }
903
1021
 
904
- get assemblyNames() {
905
- var assemblyNames = [];
906
- self.displayedRegions.forEach(function (displayedRegion) {
907
- if (!assemblyNames.includes(displayedRegion.assemblyName)) {
908
- assemblyNames.push(displayedRegion.assemblyName);
909
- }
910
- });
911
- return assemblyNames;
1022
+ if (record.type === "break" || record.type === "continue") {
1023
+ this.next = record.arg;
1024
+ } else if (record.type === "return") {
1025
+ this.rval = this.arg = record.arg;
1026
+ this.method = "return";
1027
+ this.next = "end";
1028
+ } else if (record.type === "normal" && afterLoc) {
1029
+ this.next = afterLoc;
1030
+ }
1031
+
1032
+ return ContinueSentinel;
912
1033
  },
1034
+ finish: function finish(finallyLoc) {
1035
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1036
+ var entry = this.tryEntries[i];
913
1037
 
914
- get initialized() {
915
- var _getSession = getSession(self),
916
- assemblyManager = _getSession.assemblyManager; // if the assemblyManager is tracking a given assembly name, wait for
917
- // it to be loaded. this is done by looking in the assemblyManager's
918
- // assembly list, and then waiting on it's initialized state which is
919
- // updated later
1038
+ if (entry.finallyLoc === finallyLoc) {
1039
+ this.complete(entry.completion, entry.afterLoc);
1040
+ resetTryEntry(entry);
1041
+ return ContinueSentinel;
1042
+ }
1043
+ }
1044
+ },
1045
+ "catch": function _catch(tryLoc) {
1046
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1047
+ var entry = this.tryEntries[i];
920
1048
 
1049
+ if (entry.tryLoc === tryLoc) {
1050
+ var record = entry.completion;
921
1051
 
922
- var assembliesInitialized = this.assemblyNames.every(function (assemblyName) {
923
- var _assemblyManager$asse;
1052
+ if (record.type === "throw") {
1053
+ var thrown = record.arg;
1054
+ resetTryEntry(entry);
1055
+ }
924
1056
 
925
- if ((_assemblyManager$asse = assemblyManager.assemblyList) !== null && _assemblyManager$asse !== void 0 && _assemblyManager$asse.map(function (asm) {
926
- return asm.name;
927
- }).includes(assemblyName)) {
928
- return (assemblyManager.get(assemblyName) || {}).initialized;
1057
+ return thrown;
929
1058
  }
1059
+ } // The context.catch method must only be called with a location
1060
+ // argument that corresponds to a known catch block.
930
1061
 
931
- return true;
932
- });
933
- return assembliesInitialized;
934
- }
935
1062
 
936
- };
937
- })["volatile"](function () {
938
- return {
939
- error: undefined
940
- };
941
- }).actions(function (self) {
942
- return {
943
- // toggle action with a flag stating which mode it's in
944
- setWidth: function setWidth(newWidth) {
945
- self.width = Math.max(newWidth, minWidth);
946
- return self.width;
947
- },
948
- setHeight: function setHeight(newHeight) {
949
- self.height = Math.max(newHeight, minHeight);
950
- return self.height;
951
- },
952
- resizeHeight: function resizeHeight(distance) {
953
- var oldHeight = self.height;
954
- var newHeight = this.setHeight(self.height + distance);
955
- this.setModelViewWhenAdjust(!self.tooSmallToLock);
956
- return newHeight - oldHeight;
1063
+ throw new Error("illegal catch attempt");
957
1064
  },
958
- resizeWidth: function resizeWidth(distance) {
959
- var oldWidth = self.width;
960
- var newWidth = this.setWidth(self.width + distance);
961
- this.setModelViewWhenAdjust(!self.tooSmallToLock);
962
- return newWidth - oldWidth;
963
- },
964
- rotateClockwiseButton: function rotateClockwiseButton() {
965
- this.rotateClockwise(Math.PI / 6);
966
- },
967
- rotateCounterClockwiseButton: function rotateCounterClockwiseButton() {
968
- this.rotateCounterClockwise(Math.PI / 6);
969
- },
970
- rotateClockwise: function rotateClockwise() {
971
- var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.17;
972
- self.offsetRadians += distance;
973
- },
974
- rotateCounterClockwise: function rotateCounterClockwise() {
975
- var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.17;
976
- self.offsetRadians -= distance;
977
- },
978
- zoomInButton: function zoomInButton() {
979
- this.setBpPerPx(self.bpPerPx / 1.4);
980
- },
981
- zoomOutButton: function zoomOutButton() {
982
- this.setBpPerPx(self.bpPerPx * 1.4);
983
- },
984
- setBpPerPx: function setBpPerPx(newVal) {
985
- self.bpPerPx = clamp(newVal, self.minBpPerPx, self.maxBpPerPx);
986
- },
987
- setModelViewWhenAdjust: function setModelViewWhenAdjust(secondCondition) {
988
- if (self.lockedFitToWindow && secondCondition) {
989
- this.setBpPerPx(self.minBpPerPx);
990
- }
991
- },
992
- closeView: function closeView() {
993
- getParent(self, 2).removeView(self);
994
- },
995
- setDisplayedRegions: function setDisplayedRegions(regions) {
996
- var previouslyEmpty = self.displayedRegions.length === 0;
997
- self.displayedRegions = cast(regions);
998
-
999
- if (previouslyEmpty) {
1000
- this.setBpPerPx(self.minBpPerPx);
1001
- } else {
1002
- this.setBpPerPx(self.bpPerPx);
1003
- }
1004
- },
1005
- activateTrackSelector: function activateTrackSelector() {
1006
- if (self.trackSelectorType === 'hierarchical') {
1007
- var session = getSession(self);
1008
-
1009
- if (isSessionModelWithWidgets(session)) {
1010
- var selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', {
1011
- view: self
1012
- });
1013
- session.showWidget(selector);
1014
- return selector;
1015
- }
1016
- }
1017
-
1018
- throw new Error("invalid track selector type ".concat(self.trackSelectorType));
1019
- },
1020
- toggleTrack: function toggleTrack(trackId) {
1021
- // if we have any tracks with that configuration, turn them off
1022
- var hiddenCount = this.hideTrack(trackId); // if none had that configuration, turn one on
1023
-
1024
- if (!hiddenCount) {
1025
- this.showTrack(trackId);
1026
- }
1027
- },
1028
- setError: function setError(error) {
1029
- console.error(error);
1030
- self.error = error;
1031
- },
1032
- showTrack: function showTrack(trackId) {
1033
- var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1034
- var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
1035
- var configuration = resolveIdentifier(trackConfigSchema, getRoot(self), trackId);
1036
- var trackType = pluginManager.getTrackType(configuration.type);
1037
-
1038
- if (!trackType) {
1039
- throw new Error("unknown track type ".concat(configuration.type));
1040
- }
1041
-
1042
- var viewType = pluginManager.getViewType(self.type);
1043
- var supportedDisplays = viewType.displayTypes.map(function (displayType) {
1044
- return displayType.name;
1045
- });
1046
- var displayConf = configuration.displays.find(function (d) {
1047
- return supportedDisplays.includes(d.type);
1048
- });
1049
- var track = trackType.stateModel.create(_objectSpread2(_objectSpread2({}, initialSnapshot), {}, {
1050
- type: configuration.type,
1051
- configuration: configuration,
1052
- displays: [{
1053
- type: displayConf.type,
1054
- configuration: displayConf
1055
- }]
1056
- }));
1057
- self.tracks.push(track);
1058
- },
1059
- addTrackConf: function addTrackConf(configuration) {
1060
- var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1061
- var type = configuration.type;
1062
- var name = readConfObject(configuration, 'name');
1063
- var trackType = pluginManager.getTrackType(type);
1064
-
1065
- if (!trackType) {
1066
- throw new Error("unknown track type ".concat(configuration.type));
1067
- }
1068
-
1069
- var viewType = pluginManager.getViewType(self.type);
1070
- var supportedDisplays = viewType.displayTypes.map(function (displayType) {
1071
- return displayType.name;
1072
- });
1073
- var displayConf = configuration.displays.find(function (d) {
1074
- return supportedDisplays.includes(d.type);
1075
- });
1076
- var track = trackType.stateModel.create(_objectSpread2(_objectSpread2({}, initialSnapshot), {}, {
1077
- name: name,
1078
- type: type,
1079
- configuration: configuration,
1080
- displays: [{
1081
- type: displayConf.type,
1082
- configuration: displayConf
1083
- }]
1084
- }));
1085
- self.tracks.push(track);
1086
- },
1087
- hideTrack: function hideTrack(trackId) {
1088
- var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
1089
- var configuration = resolveIdentifier(trackConfigSchema, getRoot(self), trackId); // if we have any tracks with that configuration, turn them off
1090
-
1091
- var shownTracks = self.tracks.filter(function (t) {
1092
- return t.configuration === configuration;
1093
- });
1094
- transaction(function () {
1095
- return shownTracks.forEach(function (t) {
1096
- return self.tracks.remove(t);
1097
- });
1098
- });
1099
- return shownTracks.length;
1100
- },
1101
- toggleFitToWindowLock: function toggleFitToWindowLock() {
1102
- self.lockedFitToWindow = !self.lockedFitToWindow; // when going unlocked -> locked and circle is cut off, set to the locked minBpPerPx
1103
-
1104
- this.setModelViewWhenAdjust(self.atMinBpPerPx);
1105
- return self.lockedFitToWindow;
1106
- }
1107
- };
1108
- }));
1109
- }
1110
- /*
1111
- PLANS
1112
-
1113
- - tracks
1114
- - ruler tick marks
1115
- - set viewport scroll from state snapshot
1116
-
1117
- */
1065
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1066
+ this.delegate = {
1067
+ iterator: values(iterable),
1068
+ resultName: resultName,
1069
+ nextLoc: nextLoc
1070
+ };
1118
1071
 
1119
- var ChordDisplayLoadingFactory = (function (pluginManager) {
1120
- var lib = pluginManager.lib;
1121
- var React = lib.react;
1122
- var useState = React.useState,
1123
- useEffect = React.useEffect;
1124
- var makeStyles = lib['@material-ui/core/styles'].makeStyles;
1125
- var observer = lib['mobx-react'].observer;
1126
- var useStyles = makeStyles(function (theme) {
1127
- var offset = 2;
1128
- var duration = 1.4;
1129
- return {
1130
- path: {
1131
- strokeDasharray: 187,
1132
- strokeDashoffset: 50,
1133
- animation: "$dash ".concat(duration, "s ease-in-out infinite, $colors ").concat(duration * 4, "s ease-in-out infinite")
1134
- },
1135
- '@keyframes colors': {
1136
- '0%': {
1137
- stroke: theme.palette.primary.light
1138
- },
1139
- '25%': {
1140
- stroke: theme.palette.secondary.light
1141
- },
1142
- '50%': {
1143
- stroke: theme.palette.tertiary.light
1144
- },
1145
- '75%': {
1146
- stroke: theme.palette.quaternary.light
1147
- },
1148
- '100%': {
1149
- stroke: theme.palette.primary.light
1150
- }
1151
- },
1152
- '@keyframes dash': {
1153
- '0%': {
1154
- strokeDashoffset: offset
1155
- },
1156
- '50%': {
1157
- strokeDashoffset: offset / 4,
1158
- transform: 'rotate(135deg)'
1159
- },
1160
- '100%': {
1161
- strokeDashoffset: offset,
1162
- transform: 'rotate(720deg)'
1072
+ if (this.method === "next") {
1073
+ // Deliberately forget the last sent value so that we don't
1074
+ // accidentally pass it on to the delegate.
1075
+ this.arg = undefined$1;
1163
1076
  }
1164
- }
1165
- };
1166
- }); // 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
1167
-
1168
- var Loading = observer(function (_ref) {
1169
- var radius = _ref.model.renderProps.radius;
1170
- var classes = useStyles(); // only show the loading message after 400ms to prevent excessive flickering
1171
-
1172
- var _useState = useState(false),
1173
- _useState2 = _slicedToArray(_useState, 2),
1174
- shown = _useState2[0],
1175
- setShown = _useState2[1];
1176
1077
 
1177
- useEffect(function () {
1178
- var timeout = setTimeout(function () {
1179
- return setShown(true);
1180
- }, 400);
1181
- return function () {
1182
- return clearTimeout(timeout);
1183
- };
1184
- });
1185
- return !shown ? null : React.createElement("g", null, React.createElement("defs", null, React.createElement("pattern", {
1186
- id: "diagonalHatch",
1187
- width: "10",
1188
- height: "10",
1189
- patternTransform: "rotate(45 0 0)",
1190
- patternUnits: "userSpaceOnUse"
1191
- }, React.createElement("line", {
1192
- x1: "0",
1193
- y1: "0",
1194
- x2: "0",
1195
- y2: "10",
1196
- style: {
1197
- stroke: 'rgba(255,255,255,0.5)',
1198
- strokeWidth: 10
1078
+ return ContinueSentinel;
1199
1079
  }
1200
- }))), React.createElement("circle", {
1201
- cx: "0",
1202
- cy: "0",
1203
- r: radius,
1204
- fill: "#f1f1f1"
1205
- }), React.createElement("circle", {
1206
- cx: "0",
1207
- cy: "0",
1208
- r: radius,
1209
- fill: "url(#diagonalHatch)"
1210
- }), React.createElement("text", {
1211
- x: "0",
1212
- y: "0",
1213
- transform: "rotate(90 0 0)",
1214
- dominantBaseline: "middle",
1215
- textAnchor: "middle"
1216
- }, "Loading\u2026"), React.createElement("circle", {
1217
- className: classes.path,
1218
- fill: "none",
1219
- strokeWidth: "4",
1220
- strokeLinecap: "round",
1221
- cx: "0",
1222
- cy: "0",
1223
- r: "60"
1224
- }));
1225
- });
1226
- return Loading;
1227
- });
1228
-
1229
- var ChordDisplayErrorFactory = (function (_ref) {
1230
- var jbrequire = _ref.jbrequire;
1231
- var React = jbrequire('react');
1232
-
1233
- var _jbrequire = jbrequire('@material-ui/core/styles'),
1234
- makeStyles = _jbrequire.makeStyles;
1235
-
1236
- var _jbrequire2 = jbrequire('mobx-react'),
1237
- observer = _jbrequire2.observer;
1080
+ }; // Regardless of whether this script is executing as a CommonJS module
1081
+ // or not, return the runtime object so that we can declare the variable
1082
+ // regeneratorRuntime in the outer scope, which allows this module to be
1083
+ // injected easily by `bin/regenerator --include-runtime script.js`.
1238
1084
 
1239
- var useStyles = makeStyles({
1240
- errorMessage: {},
1241
- errorBackground: {},
1242
- errorText: {}
1243
- }); // 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
1085
+ return exports;
1086
+ }( // If this script is executing as a CommonJS module, use module.exports
1087
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
1088
+ // object. Either way, the resulting object will be used to initialize
1089
+ // the regeneratorRuntime variable at the top of this file.
1090
+ module.exports );
1244
1091
 
1245
- var DisplayError = observer(function (_ref2) {
1246
- var _ref2$model = _ref2.model,
1247
- radius = _ref2$model.renderProps.radius,
1248
- error = _ref2$model.error;
1249
- var classes = useStyles();
1250
- return /*#__PURE__*/React.createElement("g", {
1251
- className: classes.errorMessage
1252
- }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("pattern", {
1253
- id: "diagonalHatch",
1254
- width: "10",
1255
- height: "10",
1256
- patternTransform: "rotate(45 0 0)",
1257
- patternUnits: "userSpaceOnUse"
1258
- }, /*#__PURE__*/React.createElement("line", {
1259
- x1: "0",
1260
- y1: "0",
1261
- x2: "0",
1262
- y2: "10",
1263
- style: {
1264
- stroke: 'rgba(255,0,0,0.5)',
1265
- strokeWidth: 10
1266
- }
1267
- }))), /*#__PURE__*/React.createElement("circle", {
1268
- className: classes.errorBackground,
1269
- cx: "0",
1270
- cy: "0",
1271
- r: radius,
1272
- fill: "#ffb4b4"
1273
- }), /*#__PURE__*/React.createElement("circle", {
1274
- className: classes.errorPattern,
1275
- cx: "0",
1276
- cy: "0",
1277
- r: radius,
1278
- fill: "url(#diagonalHatch)"
1279
- }), /*#__PURE__*/React.createElement("text", {
1280
- className: classes.errorText,
1281
- x: "0",
1282
- y: "0",
1283
- transform: "rotate(90 0 0)",
1284
- dominantBaseline: "middle",
1285
- textAnchor: "middle"
1286
- }, String(error)));
1287
- });
1288
- return DisplayError;
1092
+ try {
1093
+ regeneratorRuntime = runtime;
1094
+ } catch (accidentalStrictMode) {
1095
+ // This module should not be running in strict mode, so the above
1096
+ // assignment should always work unless something is misconfigured. Just
1097
+ // in case runtime.js accidentally runs in strict mode, in modern engines
1098
+ // we can explicitly access globalThis. In older engines we can escape
1099
+ // strict mode using a global Function call. This could conceivably fail
1100
+ // if a Content Security Policy forbids using Function, but in that case
1101
+ // the proper solution is to fix the accidental strict mode problem. If
1102
+ // you've misconfigured your bundler to force strict mode and applied a
1103
+ // CSP to forbid Function, and you're not willing to fix either of those
1104
+ // problems, please detail your unique predicament in a GitHub issue.
1105
+ if (typeof globalThis === "object") {
1106
+ globalThis.regeneratorRuntime = runtime;
1107
+ } else {
1108
+ Function("r", "regeneratorRuntime = r")(runtime);
1109
+ }
1110
+ }
1289
1111
  });
1290
1112
 
1291
- var RpcRenderedSvgGroupF = (function (_ref) {
1292
- var jbrequire = _ref.jbrequire;
1293
- var React = jbrequire('react');
1294
-
1295
- var _jbrequire = jbrequire('mobx-state-tree'),
1296
- isAlive = _jbrequire.isAlive;
1113
+ function findCircleIntersectionX(y, cx, cy, r, resultArray) {
1114
+ var d = Math.abs(y - cy);
1297
1115
 
1298
- var useEffect = React.useEffect,
1299
- useRef = React.useRef;
1116
+ if (d > r) {
1117
+ return;
1118
+ }
1300
1119
 
1301
- var _jbrequire2 = jbrequire('mobx-react'),
1302
- observer = _jbrequire2.observer,
1303
- MobxPropTypes = _jbrequire2.PropTypes;
1120
+ if (d === r) {
1121
+ resultArray.push([cx, y]);
1122
+ }
1304
1123
 
1305
- var _jbrequire3 = jbrequire('react-dom'),
1306
- unmountComponentAtNode = _jbrequire3.unmountComponentAtNode,
1307
- hydrate = _jbrequire3.hydrate;
1124
+ var solution = Math.sqrt(r * r - d * d);
1125
+ resultArray.push([cx - solution, y]);
1126
+ resultArray.push([cx + solution, y]);
1127
+ }
1308
1128
 
1309
- var _jbrequire4 = jbrequire('@jbrowse/core/util'),
1310
- rIC = _jbrequire4.rIC;
1129
+ function findCircleIntersectionY(x, cx, cy, r, resultArray) {
1130
+ var d = Math.abs(x - cx);
1311
1131
 
1312
- function RpcRenderedSvgGroup(_ref2) {
1313
- var model = _ref2.model;
1314
- var data = model.data,
1315
- html = model.html,
1316
- filled = model.filled,
1317
- renderingComponent = model.renderingComponent;
1318
- var ssrContainerNode = useRef(null);
1319
- useEffect(function () {
1320
- var domNode = ssrContainerNode.current;
1132
+ if (d > r) {
1133
+ return;
1134
+ }
1321
1135
 
1322
- function doHydrate() {
1323
- if (domNode && filled) {
1324
- if (domNode && domNode.innerHTML) {
1325
- domNode.style.display = 'none';
1326
- unmountComponentAtNode(domNode);
1327
- } // setting outline:none fixes react "focusable" element issue. see
1328
- // https://github.com/GMOD/jbrowse-components/issues/2160
1136
+ if (d === r) {
1137
+ resultArray.push([x, cy]);
1138
+ }
1329
1139
 
1140
+ var solution = Math.sqrt(r * r - d * d);
1141
+ resultArray.push([x, cy - solution]);
1142
+ resultArray.push([x, cy + solution]);
1143
+ }
1330
1144
 
1331
- domNode.style.outline = 'none';
1332
- domNode.innerHTML = html; // use requestIdleCallback to defer main-thread rendering
1333
- // and hydration for when we have some free time. helps
1334
- // keep the framerate up.
1145
+ function cartesianToTheta(x, y) {
1146
+ var theta = (Math.atan(y / x) + 2 * Math.PI) % (2 * Math.PI);
1335
1147
 
1336
- rIC(function () {
1337
- if (!isAlive(model)) {
1338
- return;
1339
- }
1148
+ if (x < 0) {
1149
+ if (y <= 0) {
1150
+ theta += Math.PI;
1151
+ } else {
1152
+ theta -= Math.PI;
1153
+ }
1154
+ }
1340
1155
 
1341
- var mainThreadRendering = React.createElement(renderingComponent, _objectSpread2(_objectSpread2({}, data), model.renderProps()), null);
1342
- rIC(function () {
1343
- if (!isAlive(model)) {
1344
- return;
1345
- }
1156
+ return theta;
1157
+ }
1346
1158
 
1347
- hydrate(mainThreadRendering, domNode);
1348
- });
1349
- });
1350
- }
1351
- }
1159
+ function cartesianToPolar(x, y) {
1160
+ var rho = Math.sqrt(x * x + y * y);
1352
1161
 
1353
- doHydrate();
1354
- return function () {
1355
- if (domNode) {
1356
- unmountComponentAtNode(domNode);
1357
- }
1358
- };
1359
- });
1360
- return /*#__PURE__*/React.createElement("g", {
1361
- ref: ssrContainerNode
1362
- });
1162
+ if (rho === 0) {
1163
+ return [0, 0];
1363
1164
  }
1364
1165
 
1365
- RpcRenderedSvgGroup.propTypes = {
1366
- model: MobxPropTypes.observableObject.isRequired
1367
- };
1368
- return observer(RpcRenderedSvgGroup);
1369
- });
1166
+ var theta = cartesianToTheta(x, y);
1167
+ return [rho, theta];
1168
+ }
1169
+ var twoPi = 2 * Math.PI;
1170
+ function thetaRangesOverlap(r1start, r1length, r2start, r2length) {
1171
+ if (r1length <= 0 || r2length <= 0) {
1172
+ return false;
1173
+ }
1370
1174
 
1371
- var BaseChordDisplay = (function (_ref) {
1372
- var lib = _ref.lib,
1373
- load = _ref.load;
1374
- var React = lib.react;
1375
- var _lib$mobxReact = lib['mobx-react'],
1376
- observer = _lib$mobxReact.observer,
1377
- MobxPropTypes = _lib$mobxReact.PropTypes;
1378
- var Loading = load(ChordDisplayLoadingFactory);
1379
- var DisplayError = load(ChordDisplayErrorFactory);
1380
- var RpcRenderedSvgGroup = load(RpcRenderedSvgGroupF); // eslint-disable-next-line @typescript-eslint/no-explicit-any
1175
+ if (r1length + 0.0001 >= twoPi || r2length + 0.0001 >= twoPi) {
1176
+ return true;
1177
+ } // put both range starts between 2π and 4π
1381
1178
 
1382
- function BaseChordDisplay(_ref2) {
1383
- var display = _ref2.display;
1384
1179
 
1385
- if (display.error) {
1386
- return React.createElement(DisplayError, {
1387
- model: display
1388
- });
1389
- }
1180
+ r1start = (r1start % twoPi + twoPi) % twoPi + twoPi;
1181
+ r2start = (r2start % twoPi + twoPi) % twoPi + twoPi;
1390
1182
 
1391
- if (!display.filled) {
1392
- return React.createElement(Loading, {
1393
- model: display
1394
- });
1395
- }
1183
+ if (r1start < r2start + r2length && r1start + r1length > r2start) {
1184
+ return true;
1185
+ } // move r2 2π to the left and check
1396
1186
 
1397
- return React.createElement(RpcRenderedSvgGroup, {
1398
- model: display
1399
- });
1400
- }
1401
1187
 
1402
- BaseChordDisplay.propTypes = {
1403
- display: MobxPropTypes.observableObject.isRequired
1404
- };
1405
- return observer(BaseChordDisplay);
1406
- });
1188
+ r2start -= twoPi;
1407
1189
 
1408
- function createCommonjsModule(fn, module) {
1409
- return module = { exports: {} }, fn(module, module.exports), module.exports;
1410
- }
1190
+ if (r1start < r2start + r2length && r1start + r1length > r2start) {
1191
+ return true;
1192
+ } // move it 2π to the right and check
1411
1193
 
1412
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1413
- /**
1414
- * Copyright (c) 2014-present, Facebook, Inc.
1415
- *
1416
- * This source code is licensed under the MIT license found in the
1417
- * LICENSE file in the root directory of this source tree.
1418
- */
1419
- var runtime = function (exports) {
1420
1194
 
1421
- var Op = Object.prototype;
1422
- var hasOwn = Op.hasOwnProperty;
1423
- var undefined$1; // More compressible than void 0.
1195
+ r2start += twoPi + twoPi;
1196
+ return r1start < r2start + r2length && r1start + r1length > r2start;
1197
+ } // return which arc range has any part of the circle visible in the viewport
1424
1198
 
1425
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
1426
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
1427
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
1428
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1199
+ function viewportVisibleSection(viewSides, circleCenter, circleRadius) {
1200
+ var _viewSides = _slicedToArray(viewSides, 4),
1201
+ viewL = _viewSides[0],
1202
+ viewR = _viewSides[1],
1203
+ viewT = _viewSides[2],
1204
+ viewB = _viewSides[3];
1429
1205
 
1430
- function define(obj, key, value) {
1431
- Object.defineProperty(obj, key, {
1432
- value: value,
1433
- enumerable: true,
1434
- configurable: true,
1435
- writable: true
1436
- });
1437
- return obj[key];
1438
- }
1206
+ var _circleCenter = _slicedToArray(circleCenter, 2),
1207
+ cx = _circleCenter[0],
1208
+ cy = _circleCenter[1]; // transform coordinate system to center of circle
1439
1209
 
1440
- try {
1441
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
1442
- define({}, "");
1443
- } catch (err) {
1444
- define = function define(obj, key, value) {
1445
- return obj[key] = value;
1446
- };
1447
- }
1448
1210
 
1449
- function wrap(innerFn, outerFn, self, tryLocsList) {
1450
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
1451
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
1452
- var generator = Object.create(protoGenerator.prototype);
1453
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
1454
- // .throw, and .return methods.
1211
+ viewL -= cx;
1212
+ viewR -= cx;
1213
+ viewT -= cy;
1214
+ viewB -= cy;
1215
+ var centerIsInsideViewport = viewL < 0 && viewR > 0 && viewT < 0 && viewB > 0;
1455
1216
 
1456
- generator._invoke = makeInvokeMethod(innerFn, self, context);
1457
- return generator;
1458
- }
1217
+ if (centerIsInsideViewport) {
1218
+ var _vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
1219
+ var maxRho = -Infinity;
1459
1220
 
1460
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
1461
- // record like context.tryEntries[i].completion. This interface could
1462
- // have been (and was previously) designed to take a closure to be
1463
- // invoked without arguments, but in all the cases we care about we
1464
- // already have an existing method we want to call, so there's no need
1465
- // to create a new function object. We can even get away with assuming
1466
- // the method takes exactly one argument, since that happens to be true
1467
- // in every case, so we don't have to touch the arguments object. The
1468
- // only additional allocation required is the completion record, which
1469
- // has a stable shape and so hopefully should be cheap to allocate.
1221
+ for (var i = 0; i < _vertices.length; i += 1) {
1222
+ var _vertices$i = _slicedToArray(_vertices[i], 2),
1223
+ x = _vertices$i[0],
1224
+ y = _vertices$i[1];
1470
1225
 
1471
- function tryCatch(fn, obj, arg) {
1472
- try {
1473
- return {
1474
- type: "normal",
1475
- arg: fn.call(obj, arg)
1476
- };
1477
- } catch (err) {
1478
- return {
1479
- type: "throw",
1480
- arg: err
1481
- };
1226
+ var rho = Math.sqrt(x * x + y * y);
1227
+
1228
+ if (rho > maxRho) {
1229
+ maxRho = rho;
1482
1230
  }
1483
1231
  }
1484
1232
 
1485
- var GenStateSuspendedStart = "suspendedStart";
1486
- var GenStateSuspendedYield = "suspendedYield";
1487
- var GenStateExecuting = "executing";
1488
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
1489
- // breaking out of the dispatch switch statement.
1233
+ return {
1234
+ rho: [0, Math.min(circleRadius, maxRho)],
1235
+ theta: [0, 2 * Math.PI]
1236
+ };
1237
+ } // const viewportCompletelyContainsCircle =
1238
+ // circleCenter[0] - viewL >= circleRadius &&
1239
+ // viewR - circleCenter[0] >= circleRadius &&
1240
+ // circleCenter[1] - viewT >= circleRadius &&
1241
+ // viewB - circleCenter[1] >= circleRadius
1242
+ // if (viewportCompletelyContainsCircle) {
1243
+ // return [0, 2 * Math.PI]
1244
+ // }
1245
+ // const distToCenterSquared = ([x, y]) => {
1246
+ // const [cx, cy] = circleCenter
1247
+ // const sq = n => n * n
1248
+ // return sq(x - cx) + sq(y - cy)
1249
+ // }
1250
+ // const circleRadiusSquared = circleRadius * circleRadius
1251
+ // const tlInside = distToCenterSquared([viewL, viewT]) <= circleRadiusSquared
1252
+ // const trInside = distToCenterSquared([viewR, viewT]) <= circleRadiusSquared
1253
+ // const blInside = distToCenterSquared([viewL, viewB]) <= circleRadiusSquared
1254
+ // const brInside = distToCenterSquared([viewR, viewB]) <= circleRadiusSquared
1255
+ // const noIntersection = !tlInside && !trInside && !blInside && !brInside
1256
+ // if (noIntersection) return undefined
1257
+ // const circleCompletelyContainsViewport =
1258
+ // tlInside && trInside && blInside && brInside
1259
+ // if (circleCompletelyContainsViewport) {
1260
+ // // viewport is in the circle, but the center is not in it, so take max
1261
+ // // and min of thetas to the center
1262
+ // const thetas = [
1263
+ // Math.atan(viewT / viewL),
1264
+ // Math.atan(viewT / viewR),
1265
+ // Math.atan(viewB / viewL),
1266
+ // Math.atan(viewB / viewR),
1267
+ // ]
1268
+ // return [Math.min(...thetas), Math.max(...thetas)]
1269
+ // }
1270
+ // if we get here, the viewport is partly in, partly out of the circle
1271
+ // const viewLIntersects = Math.abs(viewL - circleCenter[0]) <= circleRadius
1272
+ // const viewRIntersects = Math.abs(viewR - circleCenter[0]) <= circleRadius
1273
+ // const viewTIntersects = Math.abs(viewT - circleCenter[1]) <= circleRadius
1274
+ // const viewBIntersects = Math.abs(viewB - circleCenter[1]) <= circleRadius
1275
+ // const numIntersectingSides =
1276
+ // Number(viewLIntersects) +
1277
+ // Number(viewRIntersects) +
1278
+ // Number(viewTIntersects) +
1279
+ // Number(viewBIntersects)
1280
+ // if (numIntersectingSides === 4) return [0, 2 * Math.PI]
1281
+ // if (numIntersectingSides === 3) {
1282
+ // // TODO calculate the thetas of the
1283
+ // } else if (numIntersectingSides === 2) {
1284
+ // // TODO calculate the thetas of the 2 intersection points
1285
+ // } else if (numIntersectingSides === 1) {
1286
+ // // TODO calculate the thetas of the 1-2 intersection points of the line, and the angle between
1287
+ // }
1288
+ // make a list of vertices-of-interest that lie inside both shapes to examine
1289
+ // to determine the range covered by their intersection
1290
+ // transform coordinates to have the circle as the origin and find the intersections
1291
+ // of the circle and the view rectangle
1292
+
1490
1293
 
1491
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
1492
- // .constructor.prototype properties for functions that return Generator
1493
- // objects. For full spec compliance, you may wish to configure your
1494
- // minifier not to mangle the names of these two functions.
1294
+ var vertices = [[viewL, viewT], [viewR, viewT], [viewL, viewB], [viewR, viewB]];
1295
+ findCircleIntersectionY(viewL, 0, 0, circleRadius, vertices);
1296
+ findCircleIntersectionY(viewR, 0, 0, circleRadius, vertices);
1297
+ findCircleIntersectionX(viewT, 0, 0, circleRadius, vertices);
1298
+ findCircleIntersectionX(viewB, 0, 0, circleRadius, vertices); // for each edge, also look at the closest point to center if it is inside the circle
1495
1299
 
1496
- function Generator() {}
1300
+ if (-viewL < circleRadius) {
1301
+ vertices.push([viewL, 0]);
1302
+ }
1497
1303
 
1498
- function GeneratorFunction() {}
1304
+ if (viewR < circleRadius) {
1305
+ vertices.push([viewR, 0]);
1306
+ }
1499
1307
 
1500
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
1501
- // don't natively support it.
1308
+ if (-viewT < circleRadius) {
1309
+ vertices.push([0, viewT]);
1310
+ }
1502
1311
 
1312
+ if (viewB < circleRadius) {
1313
+ vertices.push([0, viewB]);
1314
+ } // const verticesOriginal = vertices.map(([x, y]) => [x + cx, y + cy])
1315
+ // now convert them all to polar and take the max and min of rho and theta
1316
+ // const viewportCenterTheta = cartesianToTheta(viewR + viewL, viewT + viewB)
1503
1317
 
1504
- var IteratorPrototype = {};
1505
- define(IteratorPrototype, iteratorSymbol, function () {
1506
- return this;
1507
- });
1508
- var getProto = Object.getPrototypeOf;
1509
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1510
1318
 
1511
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
1512
- // This environment has a native %IteratorPrototype%; use it instead
1513
- // of the polyfill.
1514
- IteratorPrototype = NativeIteratorPrototype;
1515
- }
1319
+ var reflect = viewL >= 0 ? -1 : 1; // viewportCenterTheta < Math.PI / 2 || viewportCenterTheta > 1.5 * Math.PI
1320
+ // ? -1
1321
+ // : 1
1516
1322
 
1517
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1518
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
1519
- define(Gp, "constructor", GeneratorFunctionPrototype);
1520
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
1521
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
1522
- // Iterator interface in terms of a single ._invoke method.
1323
+ var rhoMin = Infinity;
1324
+ var rhoMax = -Infinity;
1325
+ var thetaMin = Infinity;
1326
+ var thetaMax = -Infinity;
1523
1327
 
1524
- function defineIteratorMethods(prototype) {
1525
- ["next", "throw", "return"].forEach(function (method) {
1526
- define(prototype, method, function (arg) {
1527
- return this._invoke(method, arg);
1528
- });
1529
- });
1530
- }
1328
+ for (var _i = 0; _i < vertices.length; _i += 1) {
1329
+ // ignore vertex if outside the viewport
1330
+ var _vertices$_i = _slicedToArray(vertices[_i], 2),
1331
+ vx = _vertices$_i[0],
1332
+ vy = _vertices$_i[1];
1531
1333
 
1532
- exports.isGeneratorFunction = function (genFun) {
1533
- var ctor = typeof genFun === "function" && genFun.constructor;
1534
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
1535
- // do is to check its .name property.
1536
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
1537
- };
1334
+ if (vx >= viewL && vx <= viewR && vy >= viewT && vy <= viewB) {
1335
+ var _cartesianToPolar = cartesianToPolar(vx * reflect, vy * reflect),
1336
+ _cartesianToPolar2 = _slicedToArray(_cartesianToPolar, 2),
1337
+ _rho = _cartesianToPolar2[0],
1338
+ theta = _cartesianToPolar2[1]; // ignore vertex if outside the circle
1538
1339
 
1539
- exports.mark = function (genFun) {
1540
- if (Object.setPrototypeOf) {
1541
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
1542
- } else {
1543
- genFun.__proto__ = GeneratorFunctionPrototype;
1544
- define(genFun, toStringTagSymbol, "GeneratorFunction");
1545
- }
1546
1340
 
1547
- genFun.prototype = Object.create(Gp);
1548
- return genFun;
1549
- }; // Within the body of any async function, `await x` is transformed to
1550
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
1551
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
1552
- // meant to be awaited.
1341
+ if (_rho <= circleRadius + 0.001) {
1342
+ // ignore theta if rho is 0
1343
+ if (theta < thetaMin && _rho > 0.0001) {
1344
+ thetaMin = theta;
1345
+ }
1553
1346
 
1347
+ if (theta > thetaMax && _rho > 0.0001) {
1348
+ thetaMax = theta;
1349
+ }
1554
1350
 
1555
- exports.awrap = function (arg) {
1556
- return {
1557
- __await: arg
1558
- };
1559
- };
1351
+ if (_rho < rhoMin) {
1352
+ rhoMin = _rho;
1353
+ }
1560
1354
 
1561
- function AsyncIterator(generator, PromiseImpl) {
1562
- function invoke(method, arg, resolve, reject) {
1563
- var record = tryCatch(generator[method], generator, arg);
1355
+ if (_rho > rhoMax) {
1356
+ rhoMax = _rho;
1357
+ }
1358
+ }
1359
+ }
1360
+ }
1564
1361
 
1565
- if (record.type === "throw") {
1566
- reject(record.arg);
1567
- } else {
1568
- var result = record.arg;
1569
- var value = result.value;
1362
+ if (reflect === -1) {
1363
+ thetaMin += Math.PI;
1364
+ thetaMax += Math.PI;
1365
+ }
1570
1366
 
1571
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
1572
- return PromiseImpl.resolve(value.__await).then(function (value) {
1573
- invoke("next", value, resolve, reject);
1574
- }, function (err) {
1575
- invoke("throw", err, resolve, reject);
1576
- });
1577
- }
1367
+ if (thetaMin > 2 * Math.PI && thetaMax > 2 * Math.PI) {
1368
+ thetaMin -= 2 * Math.PI;
1369
+ thetaMax -= 2 * Math.PI;
1370
+ }
1578
1371
 
1579
- return PromiseImpl.resolve(value).then(function (unwrapped) {
1580
- // When a yielded Promise is resolved, its final value becomes
1581
- // the .value of the Promise<{value,done}> result for the
1582
- // current iteration.
1583
- result.value = unwrapped;
1584
- resolve(result);
1585
- }, function (error) {
1586
- // If a rejected Promise was yielded, throw the rejection back
1587
- // into the async generator function so it can be handled there.
1588
- return invoke("throw", error, resolve, reject);
1589
- });
1590
- }
1591
- }
1372
+ return {
1373
+ rho: [rhoMin, Math.min(circleRadius, rhoMax)],
1374
+ theta: [thetaMin, thetaMax]
1375
+ };
1376
+ }
1592
1377
 
1593
- var previousPromise;
1378
+ var Slice = /*#__PURE__*/function () {
1379
+ function Slice(view, region, currentRadianOffset, radianWidth) {
1380
+ _classCallCheck(this, Slice);
1594
1381
 
1595
- function enqueue(method, arg) {
1596
- function callInvokeWithMethodAndArg() {
1597
- return new PromiseImpl(function (resolve, reject) {
1598
- invoke(method, arg, resolve, reject);
1599
- });
1600
- }
1382
+ this.region = region;
1383
+ this.radianWidth = radianWidth;
1384
+ var bpPerRadian = view.bpPerRadian;
1385
+ this.key = assembleLocString(region);
1386
+ this.offsetRadians = currentRadianOffset;
1387
+ this.bpPerRadian = bpPerRadian;
1388
+ this.flipped = false;
1389
+ this.startRadians = this.offsetRadians;
1390
+ this.endRadians = region.widthBp / this.bpPerRadian + this.offsetRadians;
1391
+ Object.freeze(this);
1392
+ }
1601
1393
 
1602
- return previousPromise = // If enqueue has been called before, then we want to wait until
1603
- // all previous Promises have been resolved before calling invoke,
1604
- // so that results are always delivered in the correct order. If
1605
- // enqueue has not been called before, then it is important to
1606
- // call invoke immediately, without waiting on a callback to fire,
1607
- // so that the async generator function has the opportunity to do
1608
- // any necessary setup in a predictable way. This predictability
1609
- // is why the Promise constructor synchronously invokes its
1610
- // executor callback, and why async functions synchronously
1611
- // execute code before the first await. Since we implement simple
1612
- // async functions in terms of async generators, it is especially
1613
- // important to get this right, even though it requires care.
1614
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
1615
- // invocations of the iterator.
1616
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1617
- } // Define the unified helper method that is used to implement .next,
1618
- // .throw, and .return (see defineIteratorMethods).
1394
+ _createClass(Slice, [{
1395
+ key: "bpToXY",
1396
+ value: function bpToXY(bp, radiusPx) {
1397
+ var offsetBp;
1619
1398
 
1399
+ if (this.region.elided) {
1400
+ offsetBp = this.region.widthBp / 2;
1401
+ } else if (this.flipped) {
1402
+ offsetBp = this.region.end - bp;
1403
+ } else {
1404
+ offsetBp = bp - this.region.start;
1405
+ }
1620
1406
 
1621
- this._invoke = enqueue;
1407
+ var totalRadians = offsetBp / this.bpPerRadian + this.offsetRadians;
1408
+ return polarToCartesian(radiusPx, totalRadians);
1409
+ }
1410
+ }, {
1411
+ key: "toJSON",
1412
+ value: function toJSON() {
1413
+ return objectFromEntries(Object.entries(this));
1622
1414
  }
1415
+ }]);
1623
1416
 
1624
- defineIteratorMethods(AsyncIterator.prototype);
1625
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1626
- return this;
1627
- });
1628
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
1629
- // AsyncIterator objects; they just return a Promise for the value of
1630
- // the final result produced by the iterator.
1417
+ return Slice;
1418
+ }(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
1631
1419
 
1632
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1633
- if (PromiseImpl === void 0) PromiseImpl = Promise;
1634
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1635
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
1636
- : iter.next().then(function (result) {
1637
- return result.done ? result.value : iter.next();
1638
- });
1639
- };
1420
+ function calculateStaticSlices(self) {
1421
+ var slices = [];
1422
+ var currentRadianOffset = 0;
1640
1423
 
1641
- function makeInvokeMethod(innerFn, self, context) {
1642
- var state = GenStateSuspendedStart;
1643
- return function invoke(method, arg) {
1644
- if (state === GenStateExecuting) {
1645
- throw new Error("Generator is already running");
1646
- }
1424
+ var _iterator = _createForOfIteratorHelper(self.elidedRegions),
1425
+ _step;
1426
+
1427
+ try {
1428
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1429
+ var region = _step.value;
1430
+ var radianWidth = region.widthBp / self.bpPerRadian + self.spacingPx / self.pxPerRadian;
1431
+ slices.push(new Slice(self, region, currentRadianOffset, radianWidth));
1432
+ currentRadianOffset += radianWidth;
1433
+ }
1434
+ } catch (err) {
1435
+ _iterator.e(err);
1436
+ } finally {
1437
+ _iterator.f();
1438
+ }
1439
+
1440
+ return slices;
1441
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
1647
1442
 
1648
- if (state === GenStateCompleted) {
1649
- if (method === "throw") {
1650
- throw arg;
1651
- } // Be forgiving, per 25.3.3.3.3 of the spec:
1652
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
1653
1443
 
1444
+ function sliceIsVisible(self, slice) {
1445
+ var _self$visibleSection$ = _slicedToArray(self.visibleSection.theta, 2),
1446
+ visibleThetaMin = _self$visibleSection$[0],
1447
+ visibleThetaMax = _self$visibleSection$[1];
1654
1448
 
1655
- return doneResult();
1656
- }
1449
+ return thetaRangesOverlap(slice.offsetRadians + self.offsetRadians, slice.radianWidth, visibleThetaMin, visibleThetaMax - visibleThetaMin);
1450
+ }
1657
1451
 
1658
- context.method = method;
1659
- context.arg = arg;
1452
+ function CircularView(pluginManager) {
1453
+ var minHeight = 40;
1454
+ var minWidth = 100;
1455
+ var defaultHeight = 400;
1456
+ return types.compose(BaseViewModel, types.model('CircularView', {
1457
+ type: types.literal('CircularView'),
1458
+ offsetRadians: -Math.PI / 2,
1459
+ bpPerPx: 2000000,
1460
+ tracks: types.array(pluginManager.pluggableMstType('track', 'stateModel')),
1461
+ hideVerticalResizeHandle: false,
1462
+ hideTrackSelectorButton: false,
1463
+ lockedFitToWindow: true,
1464
+ disableImportForm: false,
1465
+ height: types.optional(types.refinement('trackHeight', types.number, function (n) {
1466
+ return n >= minHeight;
1467
+ }), defaultHeight),
1468
+ minimumRadiusPx: 25,
1469
+ spacingPx: 10,
1470
+ paddingPx: 80,
1471
+ lockedPaddingPx: 100,
1472
+ minVisibleWidth: 6,
1473
+ minimumBlockWidth: 20,
1474
+ displayedRegions: types.array(Region),
1475
+ scrollX: 0,
1476
+ scrollY: 0,
1477
+ trackSelectorType: 'hierarchical'
1478
+ })["volatile"](function () {
1479
+ return {
1480
+ width: 0
1481
+ };
1482
+ }).views(function (self) {
1483
+ return {
1484
+ get staticSlices() {
1485
+ return calculateStaticSlices(self);
1486
+ },
1660
1487
 
1661
- while (true) {
1662
- var delegate = context.delegate;
1488
+ get visibleStaticSlices() {
1489
+ return this.staticSlices.filter(sliceIsVisible.bind(this, self));
1490
+ },
1663
1491
 
1664
- if (delegate) {
1665
- var delegateResult = maybeInvokeDelegate(delegate, context);
1492
+ get visibleSection() {
1493
+ return viewportVisibleSection([self.scrollX, self.scrollX + self.width, self.scrollY, self.scrollY + self.height], this.centerXY, this.radiusPx);
1494
+ },
1666
1495
 
1667
- if (delegateResult) {
1668
- if (delegateResult === ContinueSentinel) continue;
1669
- return delegateResult;
1670
- }
1671
- }
1496
+ get circumferencePx() {
1497
+ var elidedBp = 0;
1672
1498
 
1673
- if (context.method === "next") {
1674
- // Setting context._sent for legacy support of Babel's
1675
- // function.sent implementation.
1676
- context.sent = context._sent = context.arg;
1677
- } else if (context.method === "throw") {
1678
- if (state === GenStateSuspendedStart) {
1679
- state = GenStateCompleted;
1680
- throw context.arg;
1681
- }
1499
+ var _iterator = _createForOfIteratorHelper(this.elidedRegions),
1500
+ _step;
1682
1501
 
1683
- context.dispatchException(context.arg);
1684
- } else if (context.method === "return") {
1685
- context.abrupt("return", context.arg);
1502
+ try {
1503
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1504
+ var r = _step.value;
1505
+ elidedBp += r.widthBp;
1686
1506
  }
1507
+ } catch (err) {
1508
+ _iterator.e(err);
1509
+ } finally {
1510
+ _iterator.f();
1511
+ }
1687
1512
 
1688
- state = GenStateExecuting;
1689
- var record = tryCatch(innerFn, self, context);
1513
+ return elidedBp / self.bpPerPx + self.spacingPx * this.elidedRegions.length;
1514
+ },
1690
1515
 
1691
- if (record.type === "normal") {
1692
- // If an exception is thrown from innerFn, we leave state ===
1693
- // GenStateExecuting and loop back for another invocation.
1694
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
1516
+ get radiusPx() {
1517
+ return this.circumferencePx / (2 * Math.PI);
1518
+ },
1695
1519
 
1696
- if (record.arg === ContinueSentinel) {
1697
- continue;
1698
- }
1520
+ get bpPerRadian() {
1521
+ return self.bpPerPx * this.radiusPx;
1522
+ },
1699
1523
 
1700
- return {
1701
- value: record.arg,
1702
- done: context.done
1703
- };
1704
- } else if (record.type === "throw") {
1705
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
1706
- // context.dispatchException(context.arg) call above.
1524
+ get pxPerRadian() {
1525
+ return this.radiusPx;
1526
+ },
1707
1527
 
1708
- context.method = "throw";
1709
- context.arg = record.arg;
1528
+ get centerXY() {
1529
+ return [this.radiusPx + self.paddingPx, this.radiusPx + self.paddingPx];
1530
+ },
1531
+
1532
+ get totalBp() {
1533
+ var total = 0;
1534
+
1535
+ var _iterator2 = _createForOfIteratorHelper(self.displayedRegions),
1536
+ _step2;
1537
+
1538
+ try {
1539
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1540
+ var region = _step2.value;
1541
+ total += region.end - region.start;
1710
1542
  }
1543
+ } catch (err) {
1544
+ _iterator2.e(err);
1545
+ } finally {
1546
+ _iterator2.f();
1711
1547
  }
1712
- };
1713
- } // Call delegate.iterator[context.method](context.arg) and handle the
1714
- // result, either by returning a { value, done } result from the
1715
- // delegate iterator, or by modifying context.method and context.arg,
1716
- // setting context.delegate to null, and returning the ContinueSentinel.
1717
1548
 
1549
+ return total;
1550
+ },
1718
1551
 
1719
- function maybeInvokeDelegate(delegate, context) {
1720
- var method = delegate.iterator[context.method];
1552
+ get maximumRadiusPx() {
1553
+ return self.lockedFitToWindow ? Math.min(self.width, self.height) / 2 - self.lockedPaddingPx : 1000000;
1554
+ },
1721
1555
 
1722
- if (method === undefined$1) {
1723
- // A .throw or .return when the delegate iterator has no .throw
1724
- // method always terminates the yield* loop.
1725
- context.delegate = null;
1556
+ get maxBpPerPx() {
1557
+ var minCircumferencePx = 2 * Math.PI * self.minimumRadiusPx;
1558
+ return this.totalBp / minCircumferencePx;
1559
+ },
1726
1560
 
1727
- if (context.method === "throw") {
1728
- // Note: ["return"] must be used for ES3 parsing compatibility.
1729
- if (delegate.iterator["return"]) {
1730
- // If the delegate iterator has a return method, give it a
1731
- // chance to clean up.
1732
- context.method = "return";
1733
- context.arg = undefined$1;
1734
- maybeInvokeDelegate(delegate, context);
1561
+ get minBpPerPx() {
1562
+ // min depends on window dimensions, clamp between old min(0.01) and max
1563
+ var maxCircumferencePx = 2 * Math.PI * this.maximumRadiusPx;
1564
+ return clamp(this.totalBp / maxCircumferencePx, 0.0000000001, this.maxBpPerPx);
1565
+ },
1735
1566
 
1736
- if (context.method === "throw") {
1737
- // If maybeInvokeDelegate(context) changed context.method from
1738
- // "return" to "throw", let that override the TypeError below.
1739
- return ContinueSentinel;
1740
- }
1741
- }
1567
+ get atMaxBpPerPx() {
1568
+ return self.bpPerPx >= this.maxBpPerPx;
1569
+ },
1742
1570
 
1743
- context.method = "throw";
1744
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
1745
- }
1571
+ get atMinBpPerPx() {
1572
+ return self.bpPerPx <= this.minBpPerPx;
1573
+ },
1746
1574
 
1747
- return ContinueSentinel;
1748
- }
1575
+ get tooSmallToLock() {
1576
+ return this.minBpPerPx <= 0.0000000001;
1577
+ },
1749
1578
 
1750
- var record = tryCatch(method, delegate.iterator, context.arg);
1579
+ get figureDimensions() {
1580
+ return [this.radiusPx * 2 + 2 * self.paddingPx, this.radiusPx * 2 + 2 * self.paddingPx];
1581
+ },
1751
1582
 
1752
- if (record.type === "throw") {
1753
- context.method = "throw";
1754
- context.arg = record.arg;
1755
- context.delegate = null;
1756
- return ContinueSentinel;
1757
- }
1583
+ get figureWidth() {
1584
+ return this.figureDimensions[0];
1585
+ },
1758
1586
 
1759
- var info = record.arg;
1587
+ get figureHeight() {
1588
+ return this.figureDimensions[1];
1589
+ },
1760
1590
 
1761
- if (!info) {
1762
- context.method = "throw";
1763
- context.arg = new TypeError("iterator result is not an object");
1764
- context.delegate = null;
1765
- return ContinueSentinel;
1766
- }
1591
+ // this is displayedRegions, post-processed to
1592
+ // elide regions that are too small to see reasonably
1593
+ get elidedRegions() {
1594
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1595
+ var visible = [];
1596
+ self.displayedRegions.forEach(function (region) {
1597
+ var widthBp = region.end - region.start;
1598
+ var widthPx = widthBp / self.bpPerPx;
1767
1599
 
1768
- if (info.done) {
1769
- // Assign the result of the finished delegate to the temporary
1770
- // variable specified by delegate.resultName (see delegateYield).
1771
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
1600
+ if (widthPx < self.minVisibleWidth) {
1601
+ // too small to see, collapse into a single elision region
1602
+ var lastVisible = visible[visible.length - 1];
1772
1603
 
1773
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
1774
- // exception, let the outer generator proceed normally. If
1775
- // context.method was "next", forget context.arg since it has been
1776
- // "consumed" by the delegate iterator. If context.method was
1777
- // "return", allow the original .return call to continue in the
1778
- // outer generator.
1604
+ if (lastVisible && lastVisible.elided) {
1605
+ lastVisible.regions.push(_objectSpread2({}, region));
1606
+ lastVisible.widthBp += widthBp;
1607
+ } else {
1608
+ visible.push({
1609
+ elided: true,
1610
+ widthBp: widthBp,
1611
+ regions: [_objectSpread2({}, region)]
1612
+ });
1613
+ }
1614
+ } else {
1615
+ // big enough to see, display it
1616
+ visible.push(_objectSpread2(_objectSpread2({}, region), {}, {
1617
+ widthBp: widthBp
1618
+ }));
1619
+ }
1620
+ }); // remove any single-region elisions
1779
1621
 
1780
- if (context.method !== "return") {
1781
- context.method = "next";
1782
- context.arg = undefined$1;
1622
+ for (var i = 0; i < visible.length; i += 1) {
1623
+ var v = visible[i];
1624
+
1625
+ if (v.elided && v.regions.length === 1) {
1626
+ delete v.elided;
1627
+ visible[i] = _objectSpread2(_objectSpread2({}, v), v.regions[0]);
1628
+ }
1783
1629
  }
1784
- } else {
1785
- // Re-yield the result returned by the delegate method.
1786
- return info;
1787
- } // The delegate iterator is finished, so forget it and continue with
1788
- // the outer generator.
1789
1630
 
1631
+ return visible;
1632
+ },
1790
1633
 
1791
- context.delegate = null;
1792
- return ContinueSentinel;
1793
- } // Define Generator.prototype.{next,throw,return} in terms of the
1794
- // unified ._invoke helper method.
1634
+ get assemblyNames() {
1635
+ var assemblyNames = [];
1636
+ self.displayedRegions.forEach(function (displayedRegion) {
1637
+ if (!assemblyNames.includes(displayedRegion.assemblyName)) {
1638
+ assemblyNames.push(displayedRegion.assemblyName);
1639
+ }
1640
+ });
1641
+ return assemblyNames;
1642
+ },
1795
1643
 
1644
+ get initialized() {
1645
+ var _getSession = getSession(self),
1646
+ assemblyManager = _getSession.assemblyManager; // if the assemblyManager is tracking a given assembly name, wait for
1647
+ // it to be loaded. this is done by looking in the assemblyManager's
1648
+ // assembly list, and then waiting on it's initialized state which is
1649
+ // updated later
1796
1650
 
1797
- defineIteratorMethods(Gp);
1798
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
1799
- // @@iterator function is called on it. Some browsers' implementations of the
1800
- // iterator prototype chain incorrectly implement this, causing the Generator
1801
- // object to not be returned from this call. This ensures that doesn't happen.
1802
- // See https://github.com/facebook/regenerator/issues/274 for more details.
1803
1651
 
1804
- define(Gp, iteratorSymbol, function () {
1805
- return this;
1806
- });
1807
- define(Gp, "toString", function () {
1808
- return "[object Generator]";
1809
- });
1652
+ return this.assemblyNames.every(function (assemblyName) {
1653
+ var _assemblyManager$asse;
1810
1654
 
1811
- function pushTryEntry(locs) {
1812
- var entry = {
1813
- tryLoc: locs[0]
1814
- };
1655
+ if ((_assemblyManager$asse = assemblyManager.assemblyList) !== null && _assemblyManager$asse !== void 0 && _assemblyManager$asse.map(function (asm) {
1656
+ return asm.name;
1657
+ }).includes(assemblyName)) {
1658
+ var _assemblyManager$get;
1815
1659
 
1816
- if (1 in locs) {
1817
- entry.catchLoc = locs[1];
1818
- }
1660
+ return (_assemblyManager$get = assemblyManager.get(assemblyName)) === null || _assemblyManager$get === void 0 ? void 0 : _assemblyManager$get.initialized;
1661
+ }
1819
1662
 
1820
- if (2 in locs) {
1821
- entry.finallyLoc = locs[2];
1822
- entry.afterLoc = locs[3];
1663
+ return true;
1664
+ });
1823
1665
  }
1824
1666
 
1825
- this.tryEntries.push(entry);
1826
- }
1667
+ };
1668
+ })["volatile"](function () {
1669
+ return {
1670
+ error: undefined
1671
+ };
1672
+ }).actions(function (self) {
1673
+ return {
1674
+ // toggle action with a flag stating which mode it's in
1675
+ setWidth: function setWidth(newWidth) {
1676
+ self.width = Math.max(newWidth, minWidth);
1677
+ return self.width;
1678
+ },
1679
+ setHeight: function setHeight(newHeight) {
1680
+ self.height = Math.max(newHeight, minHeight);
1681
+ return self.height;
1682
+ },
1683
+ resizeHeight: function resizeHeight(distance) {
1684
+ var oldHeight = self.height;
1685
+ var newHeight = this.setHeight(self.height + distance);
1686
+ this.setModelViewWhenAdjust(!self.tooSmallToLock);
1687
+ return newHeight - oldHeight;
1688
+ },
1689
+ resizeWidth: function resizeWidth(distance) {
1690
+ var oldWidth = self.width;
1691
+ var newWidth = this.setWidth(self.width + distance);
1692
+ this.setModelViewWhenAdjust(!self.tooSmallToLock);
1693
+ return newWidth - oldWidth;
1694
+ },
1695
+ rotateClockwiseButton: function rotateClockwiseButton() {
1696
+ this.rotateClockwise(Math.PI / 6);
1697
+ },
1698
+ rotateCounterClockwiseButton: function rotateCounterClockwiseButton() {
1699
+ this.rotateCounterClockwise(Math.PI / 6);
1700
+ },
1701
+ rotateClockwise: function rotateClockwise() {
1702
+ var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.17;
1703
+ self.offsetRadians += distance;
1704
+ },
1705
+ rotateCounterClockwise: function rotateCounterClockwise() {
1706
+ var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.17;
1707
+ self.offsetRadians -= distance;
1708
+ },
1709
+ zoomInButton: function zoomInButton() {
1710
+ this.setBpPerPx(self.bpPerPx / 1.4);
1711
+ },
1712
+ zoomOutButton: function zoomOutButton() {
1713
+ this.setBpPerPx(self.bpPerPx * 1.4);
1714
+ },
1715
+ setBpPerPx: function setBpPerPx(newVal) {
1716
+ self.bpPerPx = clamp(newVal, self.minBpPerPx, self.maxBpPerPx);
1717
+ },
1718
+ setModelViewWhenAdjust: function setModelViewWhenAdjust(secondCondition) {
1719
+ if (self.lockedFitToWindow && secondCondition) {
1720
+ this.setBpPerPx(self.minBpPerPx);
1721
+ }
1722
+ },
1723
+ closeView: function closeView() {
1724
+ getParent(self, 2).removeView(self);
1725
+ },
1726
+ setDisplayedRegions: function setDisplayedRegions(regions) {
1727
+ var previouslyEmpty = self.displayedRegions.length === 0;
1728
+ self.displayedRegions = cast(regions);
1827
1729
 
1828
- function resetTryEntry(entry) {
1829
- var record = entry.completion || {};
1830
- record.type = "normal";
1831
- delete record.arg;
1832
- entry.completion = record;
1833
- }
1730
+ if (previouslyEmpty) {
1731
+ this.setBpPerPx(self.minBpPerPx);
1732
+ } else {
1733
+ this.setBpPerPx(self.bpPerPx);
1734
+ }
1735
+ },
1736
+ activateTrackSelector: function activateTrackSelector() {
1737
+ if (self.trackSelectorType === 'hierarchical') {
1738
+ var session = getSession(self);
1834
1739
 
1835
- function Context(tryLocsList) {
1836
- // The root entry object (effectively a try statement without a catch
1837
- // or a finally block) gives us a place to store values thrown from
1838
- // locations where there is no enclosing try statement.
1839
- this.tryEntries = [{
1840
- tryLoc: "root"
1841
- }];
1842
- tryLocsList.forEach(pushTryEntry, this);
1843
- this.reset(true);
1844
- }
1740
+ if (isSessionModelWithWidgets(session)) {
1741
+ var selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', {
1742
+ view: self
1743
+ });
1744
+ session.showWidget(selector);
1745
+ return selector;
1746
+ }
1747
+ }
1845
1748
 
1846
- exports.keys = function (object) {
1847
- var keys = [];
1749
+ throw new Error("invalid track selector type ".concat(self.trackSelectorType));
1750
+ },
1751
+ toggleTrack: function toggleTrack(trackId) {
1752
+ // if we have any tracks with that configuration, turn them off
1753
+ var hiddenCount = this.hideTrack(trackId); // if none had that configuration, turn one on
1848
1754
 
1849
- for (var key in object) {
1850
- keys.push(key);
1851
- }
1755
+ if (!hiddenCount) {
1756
+ this.showTrack(trackId);
1757
+ }
1758
+ },
1759
+ setError: function setError(error) {
1760
+ console.error(error);
1761
+ self.error = error;
1762
+ },
1763
+ showTrack: function showTrack(trackId) {
1764
+ var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1765
+ var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
1766
+ var configuration = resolveIdentifier(trackConfigSchema, getRoot(self), trackId);
1767
+ var trackType = pluginManager.getTrackType(configuration.type);
1852
1768
 
1853
- keys.reverse(); // Rather than returning an object with a next method, we keep
1854
- // things simple and return the next function itself.
1769
+ if (!trackType) {
1770
+ throw new Error("unknown track type ".concat(configuration.type));
1771
+ }
1855
1772
 
1856
- return function next() {
1857
- while (keys.length) {
1858
- var key = keys.pop();
1773
+ var viewType = pluginManager.getViewType(self.type);
1774
+ var supportedDisplays = viewType.displayTypes.map(function (displayType) {
1775
+ return displayType.name;
1776
+ });
1777
+ var displayConf = configuration.displays.find(function (d) {
1778
+ return supportedDisplays.includes(d.type);
1779
+ });
1780
+ var track = trackType.stateModel.create(_objectSpread2(_objectSpread2({}, initialSnapshot), {}, {
1781
+ type: configuration.type,
1782
+ configuration: configuration,
1783
+ displays: [{
1784
+ type: displayConf.type,
1785
+ configuration: displayConf
1786
+ }]
1787
+ }));
1788
+ self.tracks.push(track);
1789
+ },
1790
+ addTrackConf: function addTrackConf(configuration) {
1791
+ var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1792
+ var type = configuration.type;
1793
+ var name = readConfObject(configuration, 'name');
1794
+ var trackType = pluginManager.getTrackType(type);
1859
1795
 
1860
- if (key in object) {
1861
- next.value = key;
1862
- next.done = false;
1863
- return next;
1864
- }
1865
- } // To avoid creating an additional object, we just hang the .value
1866
- // and .done properties off the next function object itself. This
1867
- // also ensures that the minifier will not anonymize the function.
1796
+ if (!trackType) {
1797
+ throw new Error("unknown track type ".concat(configuration.type));
1798
+ }
1868
1799
 
1800
+ var viewType = pluginManager.getViewType(self.type);
1801
+ var supportedDisplays = viewType.displayTypes.map(function (displayType) {
1802
+ return displayType.name;
1803
+ });
1804
+ var displayConf = configuration.displays.find(function (d) {
1805
+ return supportedDisplays.includes(d.type);
1806
+ });
1807
+ var track = trackType.stateModel.create(_objectSpread2(_objectSpread2({}, initialSnapshot), {}, {
1808
+ name: name,
1809
+ type: type,
1810
+ configuration: configuration,
1811
+ displays: [{
1812
+ type: displayConf.type,
1813
+ configuration: displayConf
1814
+ }]
1815
+ }));
1816
+ self.tracks.push(track);
1817
+ },
1818
+ hideTrack: function hideTrack(trackId) {
1819
+ var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
1820
+ var configuration = resolveIdentifier(trackConfigSchema, getRoot(self), trackId); // if we have any tracks with that configuration, turn them off
1869
1821
 
1870
- next.done = true;
1871
- return next;
1872
- };
1822
+ var shownTracks = self.tracks.filter(function (t) {
1823
+ return t.configuration === configuration;
1824
+ });
1825
+ transaction(function () {
1826
+ return shownTracks.forEach(function (t) {
1827
+ return self.tracks.remove(t);
1828
+ });
1829
+ });
1830
+ return shownTracks.length;
1831
+ },
1832
+ toggleFitToWindowLock: function toggleFitToWindowLock() {
1833
+ self.lockedFitToWindow = !self.lockedFitToWindow; // when going unlocked -> locked and circle is cut off, set to the locked minBpPerPx
1834
+
1835
+ this.setModelViewWhenAdjust(self.atMinBpPerPx);
1836
+ return self.lockedFitToWindow;
1837
+ }
1873
1838
  };
1839
+ }));
1840
+ }
1841
+ /*
1842
+ PLANS
1874
1843
 
1875
- function values(iterable) {
1876
- if (iterable) {
1877
- var iteratorMethod = iterable[iteratorSymbol];
1844
+ - tracks
1845
+ - ruler tick marks
1846
+ - set viewport scroll from state snapshot
1878
1847
 
1879
- if (iteratorMethod) {
1880
- return iteratorMethod.call(iterable);
1881
- }
1848
+ */
1882
1849
 
1883
- if (typeof iterable.next === "function") {
1884
- return iterable;
1850
+ var ChordDisplayLoadingFactory = (function (pluginManager) {
1851
+ var lib = pluginManager.lib;
1852
+ var React = lib.react;
1853
+ var useState = React.useState,
1854
+ useEffect = React.useEffect;
1855
+ var makeStyles = lib['@material-ui/core/styles'].makeStyles;
1856
+ var observer = lib['mobx-react'].observer;
1857
+ var useStyles = makeStyles(function (theme) {
1858
+ var offset = 2;
1859
+ var duration = 1.4;
1860
+ return {
1861
+ path: {
1862
+ strokeDasharray: 187,
1863
+ strokeDashoffset: 50,
1864
+ animation: "$dash ".concat(duration, "s ease-in-out infinite, $colors ").concat(duration * 4, "s ease-in-out infinite")
1865
+ },
1866
+ '@keyframes colors': {
1867
+ '0%': {
1868
+ stroke: theme.palette.primary.light
1869
+ },
1870
+ '25%': {
1871
+ stroke: theme.palette.secondary.light
1872
+ },
1873
+ '50%': {
1874
+ stroke: theme.palette.tertiary.light
1875
+ },
1876
+ '75%': {
1877
+ stroke: theme.palette.quaternary.light
1878
+ },
1879
+ '100%': {
1880
+ stroke: theme.palette.primary.light
1885
1881
  }
1886
-
1887
- if (!isNaN(iterable.length)) {
1888
- var i = -1,
1889
- next = function next() {
1890
- while (++i < iterable.length) {
1891
- if (hasOwn.call(iterable, i)) {
1892
- next.value = iterable[i];
1893
- next.done = false;
1894
- return next;
1895
- }
1896
- }
1897
-
1898
- next.value = undefined$1;
1899
- next.done = true;
1900
- return next;
1901
- };
1902
-
1903
- return next.next = next;
1882
+ },
1883
+ '@keyframes dash': {
1884
+ '0%': {
1885
+ strokeDashoffset: offset
1886
+ },
1887
+ '50%': {
1888
+ strokeDashoffset: offset / 4,
1889
+ transform: 'rotate(135deg)'
1890
+ },
1891
+ '100%': {
1892
+ strokeDashoffset: offset,
1893
+ transform: 'rotate(720deg)'
1904
1894
  }
1905
- } // Return an iterator with no values.
1906
-
1895
+ }
1896
+ };
1897
+ }); // 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
1907
1898
 
1908
- return {
1909
- next: doneResult
1910
- };
1911
- }
1899
+ var Loading = observer(function (_ref) {
1900
+ var radius = _ref.model.renderProps.radius;
1901
+ var classes = useStyles(); // only show the loading message after 400ms to prevent excessive flickering
1912
1902
 
1913
- exports.values = values;
1903
+ var _useState = useState(false),
1904
+ _useState2 = _slicedToArray(_useState, 2),
1905
+ shown = _useState2[0],
1906
+ setShown = _useState2[1];
1914
1907
 
1915
- function doneResult() {
1916
- return {
1917
- value: undefined$1,
1918
- done: true
1908
+ useEffect(function () {
1909
+ var timeout = setTimeout(function () {
1910
+ return setShown(true);
1911
+ }, 400);
1912
+ return function () {
1913
+ return clearTimeout(timeout);
1919
1914
  };
1920
- }
1921
-
1922
- Context.prototype = {
1923
- constructor: Context,
1924
- reset: function reset(skipTempReset) {
1925
- this.prev = 0;
1926
- this.next = 0; // Resetting context._sent for legacy support of Babel's
1927
- // function.sent implementation.
1928
-
1929
- this.sent = this._sent = undefined$1;
1930
- this.done = false;
1931
- this.delegate = null;
1932
- this.method = "next";
1933
- this.arg = undefined$1;
1934
- this.tryEntries.forEach(resetTryEntry);
1935
-
1936
- if (!skipTempReset) {
1937
- for (var name in this) {
1938
- // Not sure about the optimal order of these conditions:
1939
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
1940
- this[name] = undefined$1;
1941
- }
1942
- }
1943
- }
1944
- },
1945
- stop: function stop() {
1946
- this.done = true;
1947
- var rootEntry = this.tryEntries[0];
1948
- var rootRecord = rootEntry.completion;
1915
+ });
1916
+ return !shown ? null : React.createElement("g", null, React.createElement("defs", null, React.createElement("pattern", {
1917
+ id: "diagonalHatch",
1918
+ width: "10",
1919
+ height: "10",
1920
+ patternTransform: "rotate(45 0 0)",
1921
+ patternUnits: "userSpaceOnUse"
1922
+ }, React.createElement("line", {
1923
+ x1: "0",
1924
+ y1: "0",
1925
+ x2: "0",
1926
+ y2: "10",
1927
+ style: {
1928
+ stroke: 'rgba(255,255,255,0.5)',
1929
+ strokeWidth: 10
1930
+ }
1931
+ }))), React.createElement("circle", {
1932
+ cx: "0",
1933
+ cy: "0",
1934
+ r: radius,
1935
+ fill: "#f1f1f1"
1936
+ }), React.createElement("circle", {
1937
+ cx: "0",
1938
+ cy: "0",
1939
+ r: radius,
1940
+ fill: "url(#diagonalHatch)"
1941
+ }), React.createElement("text", {
1942
+ x: "0",
1943
+ y: "0",
1944
+ transform: "rotate(90 0 0)",
1945
+ dominantBaseline: "middle",
1946
+ textAnchor: "middle"
1947
+ }, "Loading\u2026"), React.createElement("circle", {
1948
+ className: classes.path,
1949
+ fill: "none",
1950
+ strokeWidth: "4",
1951
+ strokeLinecap: "round",
1952
+ cx: "0",
1953
+ cy: "0",
1954
+ r: "60"
1955
+ }));
1956
+ });
1957
+ return Loading;
1958
+ });
1949
1959
 
1950
- if (rootRecord.type === "throw") {
1951
- throw rootRecord.arg;
1952
- }
1960
+ var ChordDisplayErrorFactory = (function (_ref) {
1961
+ var jbrequire = _ref.jbrequire;
1962
+ var React = jbrequire('react');
1953
1963
 
1954
- return this.rval;
1955
- },
1956
- dispatchException: function dispatchException(exception) {
1957
- if (this.done) {
1958
- throw exception;
1959
- }
1964
+ var _jbrequire = jbrequire('@material-ui/core/styles'),
1965
+ makeStyles = _jbrequire.makeStyles;
1960
1966
 
1961
- var context = this;
1967
+ var _jbrequire2 = jbrequire('mobx-react'),
1968
+ observer = _jbrequire2.observer;
1962
1969
 
1963
- function handle(loc, caught) {
1964
- record.type = "throw";
1965
- record.arg = exception;
1966
- context.next = loc;
1970
+ var useStyles = makeStyles({
1971
+ errorMessage: {},
1972
+ errorBackground: {},
1973
+ errorText: {}
1974
+ }); // 'repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,.5) 5px, rgba(255,255,255,.5) 10px)',
1967
1975
 
1968
- if (caught) {
1969
- // If the dispatched exception was caught by a catch block,
1970
- // then let that catch block handle the exception normally.
1971
- context.method = "next";
1972
- context.arg = undefined$1;
1973
- }
1976
+ var DisplayError = observer(function (_ref2) {
1977
+ var _ref2$model = _ref2.model,
1978
+ radius = _ref2$model.renderProps.radius,
1979
+ error = _ref2$model.error;
1980
+ var classes = useStyles();
1981
+ return /*#__PURE__*/React.createElement("g", {
1982
+ className: classes.errorMessage
1983
+ }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("pattern", {
1984
+ id: "diagonalHatch",
1985
+ width: "10",
1986
+ height: "10",
1987
+ patternTransform: "rotate(45 0 0)",
1988
+ patternUnits: "userSpaceOnUse"
1989
+ }, /*#__PURE__*/React.createElement("line", {
1990
+ x1: "0",
1991
+ y1: "0",
1992
+ x2: "0",
1993
+ y2: "10",
1994
+ style: {
1995
+ stroke: 'rgba(255,0,0,0.5)',
1996
+ strokeWidth: 10
1997
+ }
1998
+ }))), /*#__PURE__*/React.createElement("circle", {
1999
+ className: classes.errorBackground,
2000
+ cx: "0",
2001
+ cy: "0",
2002
+ r: radius,
2003
+ fill: "#ffb4b4"
2004
+ }), /*#__PURE__*/React.createElement("circle", {
2005
+ className: classes.errorPattern,
2006
+ cx: "0",
2007
+ cy: "0",
2008
+ r: radius,
2009
+ fill: "url(#diagonalHatch)"
2010
+ }), /*#__PURE__*/React.createElement("text", {
2011
+ className: classes.errorText,
2012
+ x: "0",
2013
+ y: "0",
2014
+ transform: "rotate(90 0 0)",
2015
+ dominantBaseline: "middle",
2016
+ textAnchor: "middle"
2017
+ }, String(error)));
2018
+ });
2019
+ return DisplayError;
2020
+ });
1974
2021
 
1975
- return !!caught;
1976
- }
2022
+ var RpcRenderedSvgGroupF = (function (_ref) {
2023
+ var jbrequire = _ref.jbrequire;
2024
+ var React = jbrequire('react');
1977
2025
 
1978
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1979
- var entry = this.tryEntries[i];
1980
- var record = entry.completion;
2026
+ var _jbrequire = jbrequire('mobx-state-tree'),
2027
+ isAlive = _jbrequire.isAlive;
1981
2028
 
1982
- if (entry.tryLoc === "root") {
1983
- // Exception thrown outside of any try block that could handle
1984
- // it, so set the completion value of the entire function to
1985
- // throw the exception.
1986
- return handle("end");
1987
- }
2029
+ var useEffect = React.useEffect,
2030
+ useRef = React.useRef;
1988
2031
 
1989
- if (entry.tryLoc <= this.prev) {
1990
- var hasCatch = hasOwn.call(entry, "catchLoc");
1991
- var hasFinally = hasOwn.call(entry, "finallyLoc");
2032
+ var _jbrequire2 = jbrequire('mobx-react'),
2033
+ observer = _jbrequire2.observer,
2034
+ MobxPropTypes = _jbrequire2.PropTypes;
1992
2035
 
1993
- if (hasCatch && hasFinally) {
1994
- if (this.prev < entry.catchLoc) {
1995
- return handle(entry.catchLoc, true);
1996
- } else if (this.prev < entry.finallyLoc) {
1997
- return handle(entry.finallyLoc);
1998
- }
1999
- } else if (hasCatch) {
2000
- if (this.prev < entry.catchLoc) {
2001
- return handle(entry.catchLoc, true);
2002
- }
2003
- } else if (hasFinally) {
2004
- if (this.prev < entry.finallyLoc) {
2005
- return handle(entry.finallyLoc);
2006
- }
2007
- } else {
2008
- throw new Error("try statement without catch or finally");
2009
- }
2010
- }
2011
- }
2012
- },
2013
- abrupt: function abrupt(type, arg) {
2014
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2015
- var entry = this.tryEntries[i];
2036
+ var _jbrequire3 = jbrequire('react-dom'),
2037
+ unmountComponentAtNode = _jbrequire3.unmountComponentAtNode,
2038
+ hydrate = _jbrequire3.hydrate;
2016
2039
 
2017
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
2018
- var finallyEntry = entry;
2019
- break;
2020
- }
2021
- }
2040
+ var _jbrequire4 = jbrequire('@jbrowse/core/util'),
2041
+ rIC = _jbrequire4.rIC;
2022
2042
 
2023
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
2024
- // Ignore the finally entry if control is not jumping to a
2025
- // location outside the try/catch block.
2026
- finallyEntry = null;
2027
- }
2043
+ function RpcRenderedSvgGroup(_ref2) {
2044
+ var model = _ref2.model;
2045
+ var data = model.data,
2046
+ html = model.html,
2047
+ filled = model.filled,
2048
+ renderingComponent = model.renderingComponent;
2049
+ var ssrContainerNode = useRef(null);
2050
+ useEffect(function () {
2051
+ var domNode = ssrContainerNode.current;
2028
2052
 
2029
- var record = finallyEntry ? finallyEntry.completion : {};
2030
- record.type = type;
2031
- record.arg = arg;
2053
+ function doHydrate() {
2054
+ if (domNode && filled) {
2055
+ if (domNode && domNode.innerHTML) {
2056
+ domNode.style.display = 'none';
2057
+ unmountComponentAtNode(domNode);
2058
+ } // setting outline:none fixes react "focusable" element issue. see
2059
+ // https://github.com/GMOD/jbrowse-components/issues/2160
2032
2060
 
2033
- if (finallyEntry) {
2034
- this.method = "next";
2035
- this.next = finallyEntry.finallyLoc;
2036
- return ContinueSentinel;
2037
- }
2038
2061
 
2039
- return this.complete(record);
2040
- },
2041
- complete: function complete(record, afterLoc) {
2042
- if (record.type === "throw") {
2043
- throw record.arg;
2044
- }
2062
+ domNode.style.outline = 'none';
2063
+ domNode.innerHTML = html; // use requestIdleCallback to defer main-thread rendering
2064
+ // and hydration for when we have some free time. helps
2065
+ // keep the framerate up.
2045
2066
 
2046
- if (record.type === "break" || record.type === "continue") {
2047
- this.next = record.arg;
2048
- } else if (record.type === "return") {
2049
- this.rval = this.arg = record.arg;
2050
- this.method = "return";
2051
- this.next = "end";
2052
- } else if (record.type === "normal" && afterLoc) {
2053
- this.next = afterLoc;
2054
- }
2067
+ rIC(function () {
2068
+ if (!isAlive(model)) {
2069
+ return;
2070
+ }
2055
2071
 
2056
- return ContinueSentinel;
2057
- },
2058
- finish: function finish(finallyLoc) {
2059
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2060
- var entry = this.tryEntries[i];
2072
+ var mainThreadRendering = React.createElement(renderingComponent, _objectSpread2(_objectSpread2({}, data), model.renderProps()), null);
2073
+ rIC(function () {
2074
+ if (!isAlive(model)) {
2075
+ return;
2076
+ }
2061
2077
 
2062
- if (entry.finallyLoc === finallyLoc) {
2063
- this.complete(entry.completion, entry.afterLoc);
2064
- resetTryEntry(entry);
2065
- return ContinueSentinel;
2066
- }
2078
+ hydrate(mainThreadRendering, domNode);
2079
+ });
2080
+ });
2067
2081
  }
2068
- },
2069
- "catch": function _catch(tryLoc) {
2070
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2071
- var entry = this.tryEntries[i];
2072
-
2073
- if (entry.tryLoc === tryLoc) {
2074
- var record = entry.completion;
2075
-
2076
- if (record.type === "throw") {
2077
- var thrown = record.arg;
2078
- resetTryEntry(entry);
2079
- }
2080
-
2081
- return thrown;
2082
- }
2083
- } // The context.catch method must only be called with a location
2084
- // argument that corresponds to a known catch block.
2082
+ }
2085
2083
 
2084
+ doHydrate();
2085
+ return function () {
2086
+ if (domNode) {
2087
+ unmountComponentAtNode(domNode);
2088
+ }
2089
+ };
2090
+ });
2091
+ return /*#__PURE__*/React.createElement("g", {
2092
+ ref: ssrContainerNode
2093
+ });
2094
+ }
2086
2095
 
2087
- throw new Error("illegal catch attempt");
2088
- },
2089
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
2090
- this.delegate = {
2091
- iterator: values(iterable),
2092
- resultName: resultName,
2093
- nextLoc: nextLoc
2094
- };
2096
+ RpcRenderedSvgGroup.propTypes = {
2097
+ model: MobxPropTypes.observableObject.isRequired
2098
+ };
2099
+ return observer(RpcRenderedSvgGroup);
2100
+ });
2095
2101
 
2096
- if (this.method === "next") {
2097
- // Deliberately forget the last sent value so that we don't
2098
- // accidentally pass it on to the delegate.
2099
- this.arg = undefined$1;
2100
- }
2102
+ var BaseChordDisplay = (function (_ref) {
2103
+ var lib = _ref.lib,
2104
+ load = _ref.load;
2105
+ var React = lib.react;
2106
+ var _lib$mobxReact = lib['mobx-react'],
2107
+ observer = _lib$mobxReact.observer,
2108
+ MobxPropTypes = _lib$mobxReact.PropTypes;
2109
+ var Loading = load(ChordDisplayLoadingFactory);
2110
+ var DisplayError = load(ChordDisplayErrorFactory);
2111
+ var RpcRenderedSvgGroup = load(RpcRenderedSvgGroupF); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2101
2112
 
2102
- return ContinueSentinel;
2103
- }
2104
- }; // Regardless of whether this script is executing as a CommonJS module
2105
- // or not, return the runtime object so that we can declare the variable
2106
- // regeneratorRuntime in the outer scope, which allows this module to be
2107
- // injected easily by `bin/regenerator --include-runtime script.js`.
2113
+ function BaseChordDisplay(_ref2) {
2114
+ var display = _ref2.display;
2108
2115
 
2109
- return exports;
2110
- }( // If this script is executing as a CommonJS module, use module.exports
2111
- // as the regeneratorRuntime namespace. Otherwise create a new empty
2112
- // object. Either way, the resulting object will be used to initialize
2113
- // the regeneratorRuntime variable at the top of this file.
2114
- module.exports );
2116
+ if (display.error) {
2117
+ return React.createElement(DisplayError, {
2118
+ model: display
2119
+ });
2120
+ }
2115
2121
 
2116
- try {
2117
- regeneratorRuntime = runtime;
2118
- } catch (accidentalStrictMode) {
2119
- // This module should not be running in strict mode, so the above
2120
- // assignment should always work unless something is misconfigured. Just
2121
- // in case runtime.js accidentally runs in strict mode, in modern engines
2122
- // we can explicitly access globalThis. In older engines we can escape
2123
- // strict mode using a global Function call. This could conceivably fail
2124
- // if a Content Security Policy forbids using Function, but in that case
2125
- // the proper solution is to fix the accidental strict mode problem. If
2126
- // you've misconfigured your bundler to force strict mode and applied a
2127
- // CSP to forbid Function, and you're not willing to fix either of those
2128
- // problems, please detail your unique predicament in a GitHub issue.
2129
- if (typeof globalThis === "object") {
2130
- globalThis.regeneratorRuntime = runtime;
2131
- } else {
2132
- Function("r", "regeneratorRuntime = r")(runtime);
2122
+ if (!display.filled) {
2123
+ return React.createElement(Loading, {
2124
+ model: display
2125
+ });
2133
2126
  }
2127
+
2128
+ return React.createElement(RpcRenderedSvgGroup, {
2129
+ model: display
2130
+ });
2134
2131
  }
2132
+
2133
+ BaseChordDisplay.propTypes = {
2134
+ display: MobxPropTypes.observableObject.isRequired
2135
+ };
2136
+ return observer(BaseChordDisplay);
2135
2137
  });
2136
2138
 
2137
2139
  var _excluded = ["html"];
@@ -2516,6 +2518,65 @@ var CircularViewPlugin = /*#__PURE__*/function (_Plugin) {
2516
2518
  name: 'CircularView'
2517
2519
  });
2518
2520
  });
2521
+ pluginManager.addToExtensionPoint('LaunchView-CircularView',
2522
+ /*#__PURE__*/
2523
+ // @ts-ignore
2524
+ function () {
2525
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
2526
+ var session, assembly, _ref$tracks, tracks, assemblyManager, view, asm;
2527
+
2528
+ return runtime_1.wrap(function _callee$(_context) {
2529
+ while (1) {
2530
+ switch (_context.prev = _context.next) {
2531
+ case 0:
2532
+ session = _ref.session, assembly = _ref.assembly, _ref$tracks = _ref.tracks, tracks = _ref$tracks === void 0 ? [] : _ref$tracks;
2533
+ assemblyManager = session.assemblyManager;
2534
+ view = session.addView('CircularView', {});
2535
+ _context.next = 5;
2536
+ return when(function () {
2537
+ return view.initialized;
2538
+ });
2539
+
2540
+ case 5:
2541
+ if (assembly) {
2542
+ _context.next = 7;
2543
+ break;
2544
+ }
2545
+
2546
+ throw new Error('No assembly provided when launching circular genome view');
2547
+
2548
+ case 7:
2549
+ _context.next = 9;
2550
+ return assemblyManager.waitForAssembly(assembly);
2551
+
2552
+ case 9:
2553
+ asm = _context.sent;
2554
+
2555
+ if (asm) {
2556
+ _context.next = 12;
2557
+ break;
2558
+ }
2559
+
2560
+ throw new Error("Assembly \"".concat(assembly, "\" not found when launching circular genome view"));
2561
+
2562
+ case 12:
2563
+ view.setDisplayedRegions(asm.regions || []);
2564
+ tracks.forEach(function (track) {
2565
+ return view.showTrack(track);
2566
+ });
2567
+
2568
+ case 14:
2569
+ case "end":
2570
+ return _context.stop();
2571
+ }
2572
+ }
2573
+ }, _callee);
2574
+ }));
2575
+
2576
+ return function (_x) {
2577
+ return _ref2.apply(this, arguments);
2578
+ };
2579
+ }());
2519
2580
  }
2520
2581
  }, {
2521
2582
  key: "configure",
@@ -2723,17 +2784,10 @@ var useStyles$1 = /*#__PURE__*/makeStyles$1(function (theme) {
2723
2784
  marginBottom: theme.spacing(4)
2724
2785
  }
2725
2786
  };
2726
- });
2727
- var ErrorDisplay = /*#__PURE__*/observer(function (_ref) {
2728
- var error = _ref.error;
2729
- return /*#__PURE__*/React.createElement(Typography, {
2730
- variant: "h6",
2731
- color: "error"
2732
- }, "".concat(error));
2733
2787
  }); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2734
2788
 
2735
- var ImportForm = /*#__PURE__*/observer(function (_ref2) {
2736
- var model = _ref2.model;
2789
+ var ImportForm = /*#__PURE__*/observer(function (_ref) {
2790
+ var model = _ref.model;
2737
2791
  var classes = useStyles$1();
2738
2792
  var session = getSession(model);
2739
2793
  var modelError = model.error;
@@ -2754,7 +2808,7 @@ var ImportForm = /*#__PURE__*/observer(function (_ref2) {
2754
2808
  var assemblyError = assemblyNames.length ? assembly === null || assembly === void 0 ? void 0 : assembly.error : 'No configured assemblies';
2755
2809
  var regions = (assembly === null || assembly === void 0 ? void 0 : assembly.regions) || [];
2756
2810
  var err = assemblyError || error;
2757
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Container, {
2811
+ return /*#__PURE__*/React.createElement(Container, {
2758
2812
  className: classes.importFormContainer
2759
2813
  }, err ? /*#__PURE__*/React.createElement(Grid, {
2760
2814
  container: true,
@@ -2763,7 +2817,7 @@ var ImportForm = /*#__PURE__*/observer(function (_ref2) {
2763
2817
  alignItems: "center"
2764
2818
  }, /*#__PURE__*/React.createElement(Grid, {
2765
2819
  item: true
2766
- }, /*#__PURE__*/React.createElement(ErrorDisplay, {
2820
+ }, /*#__PURE__*/React.createElement(ErrorMessage, {
2767
2821
  error: err
2768
2822
  }))) : null, /*#__PURE__*/React.createElement(Grid, {
2769
2823
  container: true,
@@ -2782,13 +2836,13 @@ var ImportForm = /*#__PURE__*/observer(function (_ref2) {
2782
2836
  })), /*#__PURE__*/React.createElement(Grid, {
2783
2837
  item: true
2784
2838
  }, /*#__PURE__*/React.createElement(Button, {
2785
- disabled: !(regions && regions.length),
2839
+ disabled: !(regions !== null && regions !== void 0 && regions.length),
2786
2840
  onClick: function onClick() {
2787
2841
  return model.setDisplayedRegions(regions);
2788
2842
  },
2789
2843
  variant: "contained",
2790
2844
  color: "primary"
2791
- }, regions.length ? 'Open' : 'Loading…')))));
2845
+ }, regions.length ? 'Open' : 'Loading…'))));
2792
2846
  });
2793
2847
 
2794
2848
  var dragHandleHeight = 3;
@@ -2831,20 +2885,20 @@ var useStyles$2 = /*#__PURE__*/makeStyles$1(function (theme) {
2831
2885
  });
2832
2886
  var Slices = /*#__PURE__*/observer(function (_ref) {
2833
2887
  var model = _ref.model;
2834
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(React.Fragment, null, model.staticSlices.map(function (slice) {
2888
+ return /*#__PURE__*/React.createElement(React.Fragment, null, model.staticSlices.map(function (slice) {
2835
2889
  return /*#__PURE__*/React.createElement(CircularRuler, {
2836
2890
  key: assembleLocString(slice.region.elided ? slice.region.regions[0] : slice.region),
2837
2891
  model: model,
2838
2892
  slice: slice
2839
2893
  });
2840
- })), /*#__PURE__*/React.createElement(React.Fragment, null, model.tracks.map(function (track) {
2894
+ }), model.tracks.map(function (track) {
2841
2895
  var display = track.displays[0];
2842
2896
  return /*#__PURE__*/React.createElement(display.RenderingComponent, {
2843
2897
  key: display.id,
2844
2898
  display: display,
2845
2899
  view: model
2846
2900
  });
2847
- })));
2901
+ }));
2848
2902
  });
2849
2903
  var Controls = /*#__PURE__*/observer(function (_ref2) {
2850
2904
  var model = _ref2.model,
@@ -2902,11 +2956,9 @@ var CircularView$1 = /*#__PURE__*/observer(function (_ref3) {
2902
2956
  height: model.height
2903
2957
  },
2904
2958
  "data-testid": model.id
2905
- }, model.error ? /*#__PURE__*/React.createElement("p", {
2906
- style: {
2907
- color: 'red'
2908
- }
2909
- }, model.error.message) : /*#__PURE__*/React.createElement(React.Fragment, null, showImportForm ? /*#__PURE__*/React.createElement(ImportForm, {
2959
+ }, model.error ? /*#__PURE__*/React.createElement(ErrorMessage$1, {
2960
+ error: model.error
2961
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, showImportForm ? /*#__PURE__*/React.createElement(ImportForm, {
2910
2962
  model: model
2911
2963
  }) : null, /*#__PURE__*/React.createElement(React.Fragment, null, !showFigure ? null : /*#__PURE__*/React.createElement("div", {
2912
2964
  className: classes.scroller,