@jbrowse/plugin-circular-view 1.5.9 → 1.6.4

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