@aics/vole-app 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/LICENSE +33 -0
  2. package/LICENSE.txt +26 -0
  3. package/README.md +45 -0
  4. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.eot +0 -0
  5. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.js +2337 -0
  6. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.svg +604 -0
  7. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.ttf +0 -0
  8. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.woff +0 -0
  9. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-500.woff2 +0 -0
  10. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.eot +0 -0
  11. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.js +2336 -0
  12. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.svg +604 -0
  13. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.ttf +0 -0
  14. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.woff +0 -0
  15. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-700.woff2 +0 -0
  16. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.eot +0 -0
  17. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.js +2337 -0
  18. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.svg +604 -0
  19. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.ttf +0 -0
  20. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.woff +0 -0
  21. package/es/aics-image-viewer/assets/fonts/open-sans/open-sans-regular.woff2 +0 -0
  22. package/es/aics-image-viewer/assets/icons/axes.js +20 -0
  23. package/es/aics-image-viewer/assets/icons/boundingBox.js +18 -0
  24. package/es/aics-image-viewer/assets/icons/camera.js +15 -0
  25. package/es/aics-image-viewer/assets/icons/channels.js +15 -0
  26. package/es/aics-image-viewer/assets/icons/closePanel.js +18 -0
  27. package/es/aics-image-viewer/assets/icons/download.js +17 -0
  28. package/es/aics-image-viewer/assets/icons/dropdownArrow.js +15 -0
  29. package/es/aics-image-viewer/assets/icons/index.js +24 -0
  30. package/es/aics-image-viewer/assets/icons/metadata.js +15 -0
  31. package/es/aics-image-viewer/assets/icons/preferences.js +15 -0
  32. package/es/aics-image-viewer/assets/icons/resetView.js +16 -0
  33. package/es/aics-image-viewer/assets/icons/svg.d.js +0 -0
  34. package/es/aics-image-viewer/assets/icons/turnTable.js +18 -0
  35. package/es/aics-image-viewer/assets/styles/animatedEllipsis.css +21 -0
  36. package/es/aics-image-viewer/assets/styles/globals.css +35 -0
  37. package/es/aics-image-viewer/assets/styles/noui-slider-override.css +1 -0
  38. package/es/aics-image-viewer/assets/styles/variables.css +1 -0
  39. package/es/aics-image-viewer/components/App/ChannelUpdater.js +96 -0
  40. package/es/aics-image-viewer/components/App/index.js +849 -0
  41. package/es/aics-image-viewer/components/App/styles.css +60 -0
  42. package/es/aics-image-viewer/components/App/types.js +1 -0
  43. package/es/aics-image-viewer/components/AxisClipSliders/index.js +285 -0
  44. package/es/aics-image-viewer/components/AxisClipSliders/styles.css +257 -0
  45. package/es/aics-image-viewer/components/BottomPanel/index.js +70 -0
  46. package/es/aics-image-viewer/components/BottomPanel/styles.css +85 -0
  47. package/es/aics-image-viewer/components/CellViewerCanvasWrapper/index.js +113 -0
  48. package/es/aics-image-viewer/components/CellViewerCanvasWrapper/styles.css +12 -0
  49. package/es/aics-image-viewer/components/ChannelsWidget.js +100 -0
  50. package/es/aics-image-viewer/components/ChannelsWidgetRow/index.js +158 -0
  51. package/es/aics-image-viewer/components/ChannelsWidgetRow/styles.css +38 -0
  52. package/es/aics-image-viewer/components/ColorPicker.js +120 -0
  53. package/es/aics-image-viewer/components/ControlPanel/index.js +180 -0
  54. package/es/aics-image-viewer/components/ControlPanel/styles.css +169 -0
  55. package/es/aics-image-viewer/components/CustomizeWidget.js +46 -0
  56. package/es/aics-image-viewer/components/ErrorAlert/index.js +144 -0
  57. package/es/aics-image-viewer/components/ErrorAlert/styles.css +22 -0
  58. package/es/aics-image-viewer/components/GlobalVolumeControls.js +38 -0
  59. package/es/aics-image-viewer/components/MetadataViewer/index.js +99 -0
  60. package/es/aics-image-viewer/components/MetadataViewer/styles.css +81 -0
  61. package/es/aics-image-viewer/components/StyleProvider/index.js +210 -0
  62. package/es/aics-image-viewer/components/TfEditor/index.js +584 -0
  63. package/es/aics-image-viewer/components/TfEditor/styles.css +88 -0
  64. package/es/aics-image-viewer/components/Toolbar/DownloadButton.js +55 -0
  65. package/es/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.js +22 -0
  66. package/es/aics-image-viewer/components/Toolbar/index.js +274 -0
  67. package/es/aics-image-viewer/components/Toolbar/styles.css +241 -0
  68. package/es/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.js +160 -0
  69. package/es/aics-image-viewer/components/ViewerStateProvider/index.js +261 -0
  70. package/es/aics-image-viewer/components/ViewerStateProvider/types.js +1 -0
  71. package/es/aics-image-viewer/components/shared/NumericInput/index.js +147 -0
  72. package/es/aics-image-viewer/components/shared/NumericInput/styles.css +64 -0
  73. package/es/aics-image-viewer/components/shared/SharedCheckBox.js +17 -0
  74. package/es/aics-image-viewer/components/shared/SliderRow/index.js +31 -0
  75. package/es/aics-image-viewer/components/shared/SliderRow/styles.css +19 -0
  76. package/es/aics-image-viewer/components/shared/SmarterSlider.js +40 -0
  77. package/es/aics-image-viewer/components/shared/ViewerIcon.js +22 -0
  78. package/es/aics-image-viewer/shared/colorPalette.js +19 -0
  79. package/es/aics-image-viewer/shared/constants.js +164 -0
  80. package/es/aics-image-viewer/shared/enums.js +18 -0
  81. package/es/aics-image-viewer/shared/types.js +6 -0
  82. package/es/aics-image-viewer/shared/utils/colorRepresentations.js +16 -0
  83. package/es/aics-image-viewer/shared/utils/controlPointsToLut.js +182 -0
  84. package/es/aics-image-viewer/shared/utils/hooks.js +51 -0
  85. package/es/aics-image-viewer/shared/utils/httpClient.js +57 -0
  86. package/es/aics-image-viewer/shared/utils/playControls.js +97 -0
  87. package/es/aics-image-viewer/shared/utils/sceneStore.js +140 -0
  88. package/es/aics-image-viewer/shared/utils/sliderValuesToImageValues.js +36 -0
  89. package/es/aics-image-viewer/shared/utils/test/viewerChannelSettings.test.js +132 -0
  90. package/es/aics-image-viewer/shared/utils/utilsService.js +54 -0
  91. package/es/aics-image-viewer/shared/utils/viewerChannelSettings.js +152 -0
  92. package/es/aics-image-viewer/shared/utils/viewerState.js +69 -0
  93. package/es/aics-image-viewer/shared/utils/webgl-debug.js +1103 -0
  94. package/es/index.js +4 -0
  95. package/package.json +130 -0
  96. package/type-declarations/aics-image-viewer/assets/icons/index.d.ts +14 -0
  97. package/type-declarations/aics-image-viewer/components/App/ChannelUpdater.d.ts +16 -0
  98. package/type-declarations/aics-image-viewer/components/App/index.d.ts +6 -0
  99. package/type-declarations/aics-image-viewer/components/App/types.d.ts +45 -0
  100. package/type-declarations/aics-image-viewer/components/AxisClipSliders/index.d.ts +24 -0
  101. package/type-declarations/aics-image-viewer/components/BottomPanel/index.d.ts +11 -0
  102. package/type-declarations/aics-image-viewer/components/CellViewerCanvasWrapper/index.d.ts +33 -0
  103. package/type-declarations/aics-image-viewer/components/ChannelsWidget.d.ts +19 -0
  104. package/type-declarations/aics-image-viewer/components/ChannelsWidgetRow/index.d.ts +17 -0
  105. package/type-declarations/aics-image-viewer/components/ColorPicker.d.ts +13 -0
  106. package/type-declarations/aics-image-viewer/components/ControlPanel/index.d.ts +20 -0
  107. package/type-declarations/aics-image-viewer/components/CustomizeWidget.d.ts +15 -0
  108. package/type-declarations/aics-image-viewer/components/ErrorAlert/index.d.ts +12 -0
  109. package/type-declarations/aics-image-viewer/components/GlobalVolumeControls.d.ts +21 -0
  110. package/type-declarations/aics-image-viewer/components/MetadataViewer/index.d.ts +7 -0
  111. package/type-declarations/aics-image-viewer/components/StyleProvider/index.d.ts +5 -0
  112. package/type-declarations/aics-image-viewer/components/TfEditor/index.d.ts +19 -0
  113. package/type-declarations/aics-image-viewer/components/Toolbar/DownloadButton.d.ts +8 -0
  114. package/type-declarations/aics-image-viewer/components/Toolbar/ViewModeRadioButtons.d.ts +8 -0
  115. package/type-declarations/aics-image-viewer/components/Toolbar/index.d.ts +31 -0
  116. package/type-declarations/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.d.ts +34 -0
  117. package/type-declarations/aics-image-viewer/components/ViewerStateProvider/index.d.ts +33 -0
  118. package/type-declarations/aics-image-viewer/components/ViewerStateProvider/types.d.ts +105 -0
  119. package/type-declarations/aics-image-viewer/components/shared/NumericInput/index.d.ts +19 -0
  120. package/type-declarations/aics-image-viewer/components/shared/SharedCheckBox.d.ts +9 -0
  121. package/type-declarations/aics-image-viewer/components/shared/SliderRow/index.d.ts +17 -0
  122. package/type-declarations/aics-image-viewer/components/shared/SmarterSlider.d.ts +5 -0
  123. package/type-declarations/aics-image-viewer/components/shared/ViewerIcon.d.ts +9 -0
  124. package/type-declarations/aics-image-viewer/shared/constants.d.ts +40 -0
  125. package/type-declarations/aics-image-viewer/shared/enums.d.ts +15 -0
  126. package/type-declarations/aics-image-viewer/shared/types.d.ts +15 -0
  127. package/type-declarations/aics-image-viewer/shared/utils/colorRepresentations.d.ts +10 -0
  128. package/type-declarations/aics-image-viewer/shared/utils/controlPointsToLut.d.ts +53 -0
  129. package/type-declarations/aics-image-viewer/shared/utils/hooks.d.ts +14 -0
  130. package/type-declarations/aics-image-viewer/shared/utils/playControls.d.ts +27 -0
  131. package/type-declarations/aics-image-viewer/shared/utils/sceneStore.d.ts +17 -0
  132. package/type-declarations/aics-image-viewer/shared/utils/sliderValuesToImageValues.d.ts +10 -0
  133. package/type-declarations/aics-image-viewer/shared/utils/viewerChannelSettings.d.ts +46 -0
  134. package/type-declarations/aics-image-viewer/shared/utils/viewerState.d.ts +10 -0
  135. package/type-declarations/index.d.ts +7 -0
@@ -0,0 +1,97 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ var PLAY_STEP_INTERVAL_MS = 125;
9
+ var PlayControls = /*#__PURE__*/function () {
10
+ function PlayControls() {
11
+ _classCallCheck(this, PlayControls);
12
+ _defineProperty(this, "playingAxis", null);
13
+ _defineProperty(this, "playWaitingForLoad", false);
14
+ _defineProperty(this, "playHolding", false);
15
+ _defineProperty(this, "playTimeoutId", 0);
16
+ }
17
+ return _createClass(PlayControls, [{
18
+ key: "setPlayingAxis",
19
+ value: function setPlayingAxis(axis) {
20
+ var _this$onPlayingAxisCh;
21
+ this.playingAxis = axis;
22
+ (_this$onPlayingAxisCh = this.onPlayingAxisChanged) === null || _this$onPlayingAxisCh === void 0 || _this$onPlayingAxisCh.call(this, axis);
23
+ }
24
+ }, {
25
+ key: "playStep",
26
+ value: function playStep() {
27
+ var _this$getVolumeIsLoad;
28
+ if (!this.playingAxis || this.playHolding || !this.stepAxis) {
29
+ return;
30
+ }
31
+ // If the volume is not loaded, wait for it to load before continuing
32
+ if (!((_this$getVolumeIsLoad = this.getVolumeIsLoaded) !== null && _this$getVolumeIsLoad !== void 0 && _this$getVolumeIsLoad.call(this))) {
33
+ this.playWaitingForLoad = true;
34
+ return;
35
+ }
36
+ this.stepAxis(this.playingAxis);
37
+ this.playTimeoutId = window.setTimeout(this.playStep.bind(this), PLAY_STEP_INTERVAL_MS);
38
+ }
39
+
40
+ /** Call whenever new data is loaded to resume playback if it was paused for data loading. */
41
+ }, {
42
+ key: "onImageLoaded",
43
+ value: function onImageLoaded() {
44
+ if (this.playWaitingForLoad) {
45
+ this.playWaitingForLoad = false;
46
+ this.playStep();
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Pause playback on the currently playing axis.
52
+ * `willResume` marks this as a temporary suspension, e.g. while the user is scrubbing along the playing axis.
53
+ */
54
+ }, {
55
+ key: "pause",
56
+ value: function pause() {
57
+ var willResume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
58
+ window.clearTimeout(this.playTimeoutId);
59
+ this.playTimeoutId = 0;
60
+ this.playWaitingForLoad = false;
61
+ if (this.playingAxis !== null && !willResume) {
62
+ this.playHolding = false;
63
+ this.setPlayingAxis(null);
64
+ }
65
+ }
66
+
67
+ /** Begin playback on `axis`. */
68
+ }, {
69
+ key: "play",
70
+ value: function play(axis) {
71
+ if (this.playingAxis !== null) {
72
+ this.pause(true);
73
+ }
74
+ this.setPlayingAxis(axis);
75
+ this.playStep();
76
+ }
77
+
78
+ /** If `axis` is currently playing, begin a temporary hold on playback while other input is pending. */
79
+ }, {
80
+ key: "startHold",
81
+ value: function startHold(axis) {
82
+ this.playHolding = true;
83
+ this.pause(axis === this.playingAxis);
84
+ }
85
+
86
+ /** If a playback hold is active, end it. */
87
+ }, {
88
+ key: "endHold",
89
+ value: function endHold() {
90
+ if (this.playHolding) {
91
+ this.playHolding = false;
92
+ this.playStep();
93
+ }
94
+ }
95
+ }]);
96
+ }();
97
+ export { PlayControls as default };
@@ -0,0 +1,140 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
6
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ var SceneStore = /*#__PURE__*/function () {
12
+ function SceneStore(context, paths) {
13
+ _classCallCheck(this, SceneStore);
14
+ _defineProperty(this, "currentScene", 0);
15
+ _defineProperty(this, "syncChannels", false);
16
+ _defineProperty(this, "prefetchPriority", []);
17
+ this.paths = paths;
18
+ this.context = context;
19
+ this.loaders = new Array(paths.length).fill(undefined);
20
+ }
21
+
22
+ /** Get the loader associated with the given scene index, or create it if it doesn't exist */
23
+ return _createClass(SceneStore, [{
24
+ key: "getLoader",
25
+ value: (function () {
26
+ var _getLoader = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(scene) {
27
+ var loader, path, options;
28
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
29
+ while (1) switch (_context.prev = _context.next) {
30
+ case 0:
31
+ this.currentScene = scene;
32
+ loader = this.loaders[scene];
33
+ if (loader) {
34
+ _context.next = 12;
35
+ break;
36
+ }
37
+ path = this.paths[scene];
38
+ options = {};
39
+ if (_typeof(path) === "object" && !Array.isArray(path)) {
40
+ options.rawArrayOptions = path;
41
+ path = "";
42
+ }
43
+ _context.next = 8;
44
+ return this.context.onOpen();
45
+ case 8:
46
+ _context.next = 10;
47
+ return this.context.createLoader(path, options);
48
+ case 10:
49
+ loader = _context.sent;
50
+ this.loaders[scene] = loader;
51
+ case 12:
52
+ loader.syncMultichannelLoading(this.syncChannels);
53
+ loader.setPrefetchPriority(this.prefetchPriority);
54
+ return _context.abrupt("return", loader);
55
+ case 15:
56
+ case "end":
57
+ return _context.stop();
58
+ }
59
+ }, _callee, this);
60
+ }));
61
+ function getLoader(_x) {
62
+ return _getLoader.apply(this, arguments);
63
+ }
64
+ return getLoader;
65
+ }())
66
+ }, {
67
+ key: "loadScene",
68
+ value: function () {
69
+ var _loadScene = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(scene, image, loadSpec, onChannelLoaded) {
70
+ var loader, spec;
71
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72
+ while (1) switch (_context2.prev = _context2.next) {
73
+ case 0:
74
+ _context2.next = 2;
75
+ return this.getLoader(scene);
76
+ case 2:
77
+ loader = _context2.sent;
78
+ spec = loadSpec !== null && loadSpec !== void 0 ? loadSpec : image.loadSpecRequired;
79
+ image.loader = loader;
80
+ _context2.next = 7;
81
+ return loader.createImageInfo(spec);
82
+ case 7:
83
+ image.imageInfo.imageInfo = _context2.sent.imageInfo;
84
+ loader.loadVolumeData(image, spec, onChannelLoaded);
85
+ case 9:
86
+ case "end":
87
+ return _context2.stop();
88
+ }
89
+ }, _callee2, this);
90
+ }));
91
+ function loadScene(_x2, _x3, _x4, _x5) {
92
+ return _loadScene.apply(this, arguments);
93
+ }
94
+ return loadScene;
95
+ }()
96
+ }, {
97
+ key: "createVolume",
98
+ value: function () {
99
+ var _createVolume = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(scene, loadSpec, onChannelLoaded) {
100
+ var loader;
101
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
102
+ while (1) switch (_context3.prev = _context3.next) {
103
+ case 0:
104
+ _context3.next = 2;
105
+ return this.getLoader(scene);
106
+ case 2:
107
+ loader = _context3.sent;
108
+ return _context3.abrupt("return", loader.createVolume(loadSpec, onChannelLoaded));
109
+ case 4:
110
+ case "end":
111
+ return _context3.stop();
112
+ }
113
+ }, _callee3, this);
114
+ }));
115
+ function createVolume(_x6, _x7, _x8) {
116
+ return _createVolume.apply(this, arguments);
117
+ }
118
+ return createVolume;
119
+ }()
120
+ }, {
121
+ key: "syncMultichannelLoading",
122
+ value: function syncMultichannelLoading(sync) {
123
+ this.syncChannels = sync;
124
+ var currentLoader = this.loaders[this.currentScene];
125
+ if (currentLoader) {
126
+ currentLoader.syncMultichannelLoading(sync);
127
+ }
128
+ }
129
+ }, {
130
+ key: "setPrefetchPriority",
131
+ value: function setPrefetchPriority(priority) {
132
+ this.prefetchPriority = priority;
133
+ var currentLoader = this.loaders[this.currentScene];
134
+ if (currentLoader) {
135
+ currentLoader.setPrefetchPriority(priority);
136
+ }
137
+ }
138
+ }]);
139
+ }();
140
+ export { SceneStore as default };
@@ -0,0 +1,36 @@
1
+ export var gammaSliderToImageValues = function gammaSliderToImageValues(sliderValues) {
2
+ var min = Number(sliderValues[0]);
3
+ var mid = Number(sliderValues[1]);
4
+ var max = Number(sliderValues[2]);
5
+ if (mid > max || mid < min) {
6
+ mid = 0.5 * (min + max);
7
+ }
8
+ var div = 255;
9
+ min /= div;
10
+ max /= div;
11
+ mid /= div;
12
+ var diff = max - min;
13
+ var x = (mid - min) / diff;
14
+ var scale = 4 * x * x;
15
+ if ((mid - 0.5) * (mid - 0.5) < 0.0005) {
16
+ scale = 1.0;
17
+ }
18
+ return {
19
+ min: min,
20
+ max: max,
21
+ scale: scale
22
+ };
23
+ };
24
+
25
+ // Density and brightness are overloaded for the two supported rendering modes in the volume viewer.
26
+ // These formulae are somewhat ad-hoc based on what will subjectively look reasonable in the viewer, and should be considered tweakable.
27
+ // vole-core expects to see numbers from 0..1 for density, brightness, and alpha.
28
+ export var densitySliderToImageValue = function densitySliderToImageValue(sliderValues, _isPT) {
29
+ return +sliderValues / 100.0;
30
+ };
31
+ export var brightnessSliderToImageValue = function brightnessSliderToImageValue(sliderValues, _isPT) {
32
+ return +sliderValues / 100.0;
33
+ };
34
+ export var alphaSliderToImageValue = function alphaSliderToImageValue(sliderValues) {
35
+ return 1 - sliderValues / 100.0;
36
+ };
@@ -0,0 +1,132 @@
1
+ import { describe, expect, it } from "@jest/globals";
2
+ import { matchChannel, makeChannelIndexGrouping } from "../viewerChannelSettings";
3
+ describe("viewer settings", function () {
4
+ describe("matching names", function () {
5
+ it.each([["test1", [true, false, false]], ["test", [true, true, true]], ["^test$", [false, false, false]], ["1|2", [true, true, false]], [1, [false, true, false]]])("matches against %p", function (re, expected) {
6
+ var channelNames = ["test1", "test2", "test3"];
7
+ var setting = {
8
+ match: re
9
+ };
10
+ var result = channelNames.map(function (ch, i) {
11
+ return matchChannel(ch, i, setting);
12
+ });
13
+ expect(result).toEqual(expected);
14
+ });
15
+ });
16
+ describe("grouping channels", function () {
17
+ it("groups channels into their named groups when all match", function () {
18
+ var channelNames = ["test1", "test2", "test3"];
19
+ var settings = {
20
+ groups: [{
21
+ name: "1",
22
+ channels: [{
23
+ match: "2"
24
+ }]
25
+ }, {
26
+ name: "2",
27
+ channels: [{
28
+ match: "3"
29
+ }]
30
+ }, {
31
+ name: "3",
32
+ channels: [{
33
+ match: "1"
34
+ }]
35
+ }],
36
+ maskChannelName: ""
37
+ };
38
+ var expected = {
39
+ "1": [1],
40
+ "2": [2],
41
+ "3": [0]
42
+ };
43
+ var result = makeChannelIndexGrouping(channelNames, settings);
44
+ expect(Object.keys(result).length).toBe(3);
45
+ for (var i in result) {
46
+ expect(result[i].length).toBe(1);
47
+ expect(result[i]).toEqual(expected[i]);
48
+ }
49
+ });
50
+ it('groups channels into group "Other" when none match', function () {
51
+ var channelNames = ["test1", "test2", "test3"];
52
+ var settings = {
53
+ groups: [{
54
+ name: "1",
55
+ channels: [{
56
+ match: "z"
57
+ }]
58
+ }, {
59
+ name: "2",
60
+ channels: [{
61
+ match: "y"
62
+ }]
63
+ }, {
64
+ name: "3",
65
+ channels: [{
66
+ match: "x"
67
+ }]
68
+ }],
69
+ maskChannelName: ""
70
+ };
71
+ var expected = {
72
+ "1": [],
73
+ "2": [],
74
+ "3": [],
75
+ Other: [0, 1, 2]
76
+ };
77
+ var result = makeChannelIndexGrouping(channelNames, settings);
78
+ expect(Object.keys(result).length).toBe(4);
79
+ for (var i in result) {
80
+ expect(result[i]).toEqual(expected[i]);
81
+ }
82
+ });
83
+ it('groups channels into named groups and "Other" when only some match', function () {
84
+ var channelNames = ["test1", "test2", "test3"];
85
+ var settings = {
86
+ groups: [{
87
+ name: "1",
88
+ channels: [{
89
+ match: "1"
90
+ }]
91
+ }, {
92
+ name: "2",
93
+ channels: [{
94
+ match: "2"
95
+ }]
96
+ }, {
97
+ name: "3",
98
+ channels: [{
99
+ match: "x"
100
+ }]
101
+ }],
102
+ maskChannelName: ""
103
+ };
104
+ var expected = {
105
+ "1": [0],
106
+ "2": [1],
107
+ "3": [],
108
+ Other: [2]
109
+ };
110
+ var result = makeChannelIndexGrouping(channelNames, settings);
111
+ expect(Object.keys(result).length).toBe(4);
112
+ for (var i in result) {
113
+ expect(result[i]).toEqual(expected[i]);
114
+ }
115
+ });
116
+ it('groups all channels into group "Channels" when no groups are given', function () {
117
+ var channelNames = ["test1", "test2", "test3"];
118
+ var settings = {
119
+ groups: [],
120
+ maskChannelName: ""
121
+ };
122
+ var expected = {
123
+ Channels: [0, 1, 2]
124
+ };
125
+ var result = makeChannelIndexGrouping(channelNames, settings);
126
+ expect(Object.keys(result).length).toBe(1);
127
+ for (var i in result) {
128
+ expect(result[i]).toEqual(expected[i]);
129
+ }
130
+ });
131
+ });
132
+ });
@@ -0,0 +1,54 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ var UtilsService = /*#__PURE__*/function () {
8
+ function UtilsService() {
9
+ _classCallCheck(this, UtilsService);
10
+ }
11
+ return _createClass(UtilsService, null, [{
12
+ key: "getParameterByName",
13
+ value:
14
+ /**
15
+ *
16
+ * @param name (string) Name of query parameter to search for
17
+ * @param url (string) url string to search (if not provided, defaults to window url)
18
+ * @returns {*} value of query parameter (URI decoded).
19
+ * If query parameter not found, returns null.
20
+ * If no value provided, returns empty string
21
+ */
22
+ function getParameterByName(name, url) {
23
+ if (!url) url = window.location.href;
24
+ name = name.replace(/[[\]]/g, "\\$&");
25
+ var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
26
+ results = regex.exec(url);
27
+ if (!results) return null;
28
+ if (!results[2]) return "";
29
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
30
+ }
31
+ }, {
32
+ key: "intersects",
33
+ value: function intersects(arr1, arr2) {
34
+ if (!arr1 || !arr2) {
35
+ return false;
36
+ }
37
+ var smallerArr, largerArr;
38
+ if (arr1.length > arr2.length) {
39
+ smallerArr = arr2;
40
+ largerArr = arr1;
41
+ } else {
42
+ smallerArr = arr1;
43
+ largerArr = arr2;
44
+ }
45
+ for (var i = 0; i < smallerArr.length; i++) {
46
+ if (largerArr.indexOf(smallerArr[i]) > -1) {
47
+ return false;
48
+ }
49
+ }
50
+ return true;
51
+ }
52
+ }]);
53
+ }();
54
+ export { UtilsService as default };
@@ -0,0 +1,152 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
+ import { OTHER_CHANNEL_KEY, SINGLE_GROUP_CHANNEL_KEY } from "../constants";
9
+
10
+ /** Settings for a single channel, as passed in via props by App users */
11
+
12
+ export function matchChannel(channelName, channelIndex, c) {
13
+ // c could be a number, an array of (strings or numbers), or a single regex
14
+ if (typeof c.match === "number") {
15
+ if (c.match === channelIndex) {
16
+ return true;
17
+ }
18
+ } else if (Array.isArray(c.match)) {
19
+ var _iterator = _createForOfIteratorHelper(c.match),
20
+ _step;
21
+ try {
22
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
23
+ var r = _step.value;
24
+ if (typeof r === "number") {
25
+ if (r === channelIndex) {
26
+ return true;
27
+ }
28
+ } else {
29
+ var re = new RegExp(r);
30
+ if (re.test(channelName)) {
31
+ return true;
32
+ }
33
+ }
34
+ }
35
+ } catch (err) {
36
+ _iterator.e(err);
37
+ } finally {
38
+ _iterator.f();
39
+ }
40
+ } else if (typeof c.match === "string") {
41
+ var _re = new RegExp(c.match);
42
+ if (_re.test(channelName)) {
43
+ return true;
44
+ }
45
+ } else {
46
+ throw new Error("match is required for channel settings groups, and must be a string, number, or array of strings or numbers");
47
+ }
48
+ return false;
49
+ }
50
+ function findFirstChannelMatchOfGroup(channel, channelIndex, g) {
51
+ var _iterator2 = _createForOfIteratorHelper(g.channels),
52
+ _step2;
53
+ try {
54
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
55
+ var c = _step2.value;
56
+ if (matchChannel(channel, channelIndex, c)) {
57
+ return c;
58
+ }
59
+ }
60
+ } catch (err) {
61
+ _iterator2.e(err);
62
+ } finally {
63
+ _iterator2.f();
64
+ }
65
+ return undefined;
66
+ }
67
+ export function findFirstChannelMatch(channel, channelIndex, settings) {
68
+ if (!settings.groups) {
69
+ return undefined;
70
+ }
71
+ var _iterator3 = _createForOfIteratorHelper(settings.groups),
72
+ _step3;
73
+ try {
74
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
75
+ var g = _step3.value;
76
+ var c = findFirstChannelMatchOfGroup(channel, channelIndex, g);
77
+ if (c !== undefined) {
78
+ return c;
79
+ }
80
+ }
81
+ } catch (err) {
82
+ _iterator3.e(err);
83
+ } finally {
84
+ _iterator3.f();
85
+ }
86
+ return undefined;
87
+ }
88
+ export function getDisplayName(name, index, settings) {
89
+ if (settings) {
90
+ var c = findFirstChannelMatch(name, index, settings);
91
+ if (c) {
92
+ return c.name || name;
93
+ }
94
+ }
95
+ return name;
96
+ }
97
+ export function makeChannelIndexGrouping(channels, settings) {
98
+ if (!channels) {
99
+ return {};
100
+ }
101
+ if (!settings) {
102
+ // return all channels
103
+ return _defineProperty({}, SINGLE_GROUP_CHANNEL_KEY, channels.map(function (_val, index) {
104
+ return index;
105
+ }));
106
+ }
107
+ var groups = settings.groups;
108
+ var grouping = {};
109
+ var channelsMatched = [];
110
+ // this is kinda inefficient but we want to ensure the order as specified in viewerChannelSettings
111
+ if (groups !== undefined) {
112
+ var _iterator4 = _createForOfIteratorHelper(groups),
113
+ _step4;
114
+ try {
115
+ var _loop = function _loop() {
116
+ var g = _step4.value;
117
+ grouping[g.name] = [];
118
+ g.channels.forEach(function (groupMatch) {
119
+ // check all channels against the match
120
+ channels.forEach(function (channel, index) {
121
+ // make sure channel was not already matched someplace.
122
+ if (!channelsMatched.includes(index)) {
123
+ if (matchChannel(channel, index, groupMatch)) {
124
+ grouping[g.name].push(index);
125
+ channelsMatched.push(index);
126
+ }
127
+ }
128
+ });
129
+ });
130
+ };
131
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
132
+ _loop();
133
+ }
134
+ } catch (err) {
135
+ _iterator4.e(err);
136
+ } finally {
137
+ _iterator4.f();
138
+ }
139
+ }
140
+ // now any channels not still matched go in the catchall group.
141
+ if (channelsMatched.length < channels.length) {
142
+ var remainderGroupName = groups.length === 0 ? SINGLE_GROUP_CHANNEL_KEY : OTHER_CHANNEL_KEY;
143
+ grouping[remainderGroupName] = [];
144
+ channels.forEach(function (channel, index) {
145
+ // make sure channel was not already matched someplace.
146
+ if (!channelsMatched.includes(index)) {
147
+ grouping[remainderGroupName].push(index);
148
+ }
149
+ });
150
+ }
151
+ return grouping;
152
+ }