"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var aleph_core_js_1 = require("../aleph.core.js");
var chunk_1519ad9e_js_1 = require("./chunk-1519ad9e.js");
var AlControlPanel = function () { function e() { this.boundingBoxVisible = !1, this.displayMode = chunk_1519ad9e_js_1.a.MESH, this.optionsEnabled = !0, this.optionsVisible = !0, this.orientation = chunk_1519ad9e_js_1.b.CORONAL, this.graphEnabled = !1, this.graphVisible = !0; } return e.prototype._boundingBoxVisible = function (e) { this.boundingBoxVisible = e, this.boundingBoxVisibleChanged.emit(e); }, e.prototype._displayMode = function (e) { this.displayMode = e, this.displayModeChanged.emit(e); }, e.prototype._graphEnabled = function (e) { this.graphEnabled = e, this.graphEnabledChanged.emit(e); }, e.prototype._orientation = function (e) { this.orientation = e, this.orientationChanged.emit(e); }, e.prototype._slicesIndex = function (e) { this.slicesIndex = e, this.slicesIndexChanged.emit(e); }, e.prototype._slicesWindowCenter = function (e) { this.slicesWindowCenter = e, this.slicesWindowCenterChanged.emit(e); }, e.prototype._slicesWindowWidth = function (e) { this.slicesWindowWidth = e, this.slicesWindowWidthChanged.emit(e); }, e.prototype._volumeSteps = function (e) { this.volumeSteps = e, this.volumeStepsChanged.emit(e); }, e.prototype._volumeWindowCenter = function (e) { this.volumeWindowCenter = e, this.volumeWindowCenterChanged.emit(e); }, e.prototype._volumeWindowWidth = function (e) { this.volumeWindowWidth = e, this.volumeWindowWidthChanged.emit(e); }, e.prototype.renderDisplayModeToggle = function () { var e = this; return this.displayMode !== chunk_1519ad9e_js_1.a.MESH ? aleph_core_js_1.h("ion-item", { id: "mode" }, aleph_core_js_1.h("ion-icon", { name: "eye", slot: "start" }), aleph_core_js_1.h("select", { slot: "end", onChange: function (t) { return e._displayMode(t.srcElement.value); } }, aleph_core_js_1.h("option", { selected: this.displayMode === chunk_1519ad9e_js_1.a.SLICES, value: chunk_1519ad9e_js_1.a.SLICES }, "Slices"), aleph_core_js_1.h("option", { selected: this.displayMode === chunk_1519ad9e_js_1.a.VOLUME, value: chunk_1519ad9e_js_1.a.VOLUME }, "Volume"))) : null; }, e.prototype.renderNodesToggle = function () { var e = this; return this.graphVisible ? aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "add-circle", slot: "start" }), aleph_core_js_1.h("ion-toggle", { slot: "end", checked: this.graphEnabled, onIonChange: function (t) { return e._graphEnabled(t.detail.checked); } })) : null; }, e.prototype.renderBoundingBoxEnabled = function () { var e = this; return aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "cube", slot: "start" }), aleph_core_js_1.h("ion-toggle", { slot: "end", checked: this.boundingBoxVisible, onIonChange: function (t) { return e._boundingBoxVisible(t.detail.checked); } })); }, e.prototype._reverseNumber = function (e, t, n) { return n + t - e; }, e.prototype.renderOptions = function () { var e = this; switch (this.displayMode) {
    case chunk_1519ad9e_js_1.a.SLICES:
        if (!this.stackhelper || this.stackhelper && !this.stackhelper.slice)
            break;
        var t, n = Object.keys(chunk_1519ad9e_js_1.b).indexOf(this.orientation.toUpperCase()), i = this.stackhelper.stack.zCosine;
        t = 1 === Math.round(i.x) ? 1 : 1 === Math.round(i.y) ? 2 : 0;
        var o, s = Math.round((n + t) % 3), a = Math.round((n + t + 2) % 3), l = this.stackhelper.stack.dimensionsIJK[Object.keys(this.stackhelper.stack.dimensionsIJK)[a]] - 1;
        o = void 0 === this.slicesIndex ? Math.floor(l / 2) : this.slicesIndex;
        var r = this.stackhelper.stack.minMax[1] - this.stackhelper.stack.minMax[0], d = void 0;
        d = void 0 === this.slicesWindowWidth ? r / 2 : this.slicesWindowWidth;
        var u = this.stackhelper.stack.minMax[0], c = this.stackhelper.stack.minMax[1], p = void 0;
        return p = void 0 === this.slicesWindowCenter ? c / 2 : this.slicesWindowCenter, this.stackhelper.orientation = s, this.stackhelper.index = o, this.stackhelper.slice.windowWidth = d, this.stackhelper.slice.windowCenter = p, this.optionsVisible && this.optionsEnabled ? aleph_core_js_1.h("div", null, this.renderBoundingBoxEnabled(), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "swap", slot: "start" }), aleph_core_js_1.h("ion-range", { slot: "end", min: "0", max: l, value: o, onIonChange: function (t) { return e._slicesIndex(t.detail.value); } })), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "compass", slot: "start" }), aleph_core_js_1.h("select", { slot: "end", onChange: function (t) { return e._orientation(t.srcElement.value); } }, aleph_core_js_1.h("option", { selected: this.orientation === chunk_1519ad9e_js_1.b.CORONAL, value: chunk_1519ad9e_js_1.b.CORONAL }, "Coronal (x)"), aleph_core_js_1.h("option", { selected: this.orientation === chunk_1519ad9e_js_1.b.SAGGITAL, value: chunk_1519ad9e_js_1.b.SAGGITAL }, "Saggital (y)"), aleph_core_js_1.h("option", { selected: this.orientation === chunk_1519ad9e_js_1.b.AXIAL, value: chunk_1519ad9e_js_1.b.AXIAL }, "Axial (z)"))), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "sunny", slot: "start" }), aleph_core_js_1.h("ion-range", { slot: "end", min: u, max: c, value: this._reverseNumber(p, u, c), onIonChange: function (t) { return e._slicesWindowCenter(e._reverseNumber(t.detail.value, u, c)); } })), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "contrast", slot: "start" }), aleph_core_js_1.h("ion-range", { slot: "end", min: 1, max: r, value: this._reverseNumber(d, 1, r), onIonChange: function (t) { return e._slicesWindowWidth(e._reverseNumber(t.detail.value, 1, r)); } }))) : null;
    case chunk_1519ad9e_js_1.a.VOLUME:
        if (!this.stackhelper || this.stackhelper && !this.stackhelper.uniforms)
            break;
        var m, b = this.stackhelper.stack.minMax[1] - this.stackhelper.stack.minMax[0];
        d = void 0, d = void 0 === this.volumeWindowWidth ? b / 2 : this.volumeWindowWidth;
        var g = this.stackhelper.stack.minMax[0], v = this.stackhelper.stack.minMax[1];
        return p = void 0, p = void 0 === this.volumeWindowCenter ? v / 2 : this.volumeWindowCenter, this.stackhelper.uniforms.uSteps.value = m = void 0 === this.volumeSteps ? 8 : this.volumeSteps, this.stackhelper.windowWidth = d, this.stackhelper.windowCenter = p, aleph_core_js_1.h("div", null, this.renderBoundingBoxEnabled(), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "swap", slot: "start" }), aleph_core_js_1.h("ion-range", { slot: "end", min: 1, max: 128, value: m, onMouseUp: function (t) { return e._volumeSteps(t.srcElement.value); } })), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "sunny", slot: "start" }), aleph_core_js_1.h("ion-range", { slot: "end", min: g, max: v, value: p, onMouseUp: function (t) { return e._volumeWindowCenter(t.srcElement.value); } })), aleph_core_js_1.h("ion-item", null, aleph_core_js_1.h("ion-icon", { name: "contrast", slot: "start" }), aleph_core_js_1.h("ion-range", { slot: "end", min: 1, max: b, value: d, onMouseUp: function (t) { return e._volumeWindowWidth(t.srcElement.value); } })));
    case chunk_1519ad9e_js_1.a.MESH: return this.renderBoundingBoxEnabled();
} return null; }, e.prototype.render = function () { return [this.renderDisplayModeToggle(), this.renderNodesToggle(), this.renderOptions()]; }, Object.defineProperty(e, "is", { get: function () { return "al-control-panel"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "encapsulation", { get: function () { return "shadow"; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "properties", { get: function () { return { boundingBoxVisible: { type: Boolean, attr: "bounding-box-visible", mutable: !0 }, displayMode: { type: String, attr: "display-mode", mutable: !0 }, graphEnabled: { type: Boolean, attr: "graph-enabled", mutable: !0 }, graphVisible: { type: Boolean, attr: "graph-visible", mutable: !0 }, optionsEnabled: { type: Boolean, attr: "options-enabled", mutable: !0 }, optionsVisible: { type: Boolean, attr: "options-visible", mutable: !0 }, orientation: { type: String, attr: "orientation", mutable: !0 }, slicesIndex: { type: Number, attr: "slices-index", mutable: !0 }, slicesWindowCenter: { type: Number, attr: "slices-window-center", mutable: !0 }, slicesWindowWidth: { type: Number, attr: "slices-window-width", mutable: !0 }, stackhelper: { type: "Any", attr: "stackhelper", mutable: !0 }, volumeSteps: { type: Number, attr: "volume-steps", mutable: !0 }, volumeWindowCenter: { type: Number, attr: "volume-window-center", mutable: !0 }, volumeWindowWidth: { type: Number, attr: "volume-window-width", mutable: !0 } }; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "events", { get: function () { return [{ name: "boundingBoxVisibleChanged", method: "boundingBoxVisibleChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "displayModeChanged", method: "displayModeChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "optionsEnabledChanged", method: "optionsEnabledChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "orientationChanged", method: "orientationChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "slicesIndexChanged", method: "slicesIndexChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "slicesWindowCenterChanged", method: "slicesWindowCenterChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "slicesWindowWidthChanged", method: "slicesWindowWidthChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "graphEnabledChanged", method: "graphEnabledChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "volumeStepsChanged", method: "volumeStepsChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "volumeWindowCenterChanged", method: "volumeWindowCenterChanged", bubbles: !0, cancelable: !0, composed: !0 }, { name: "volumeWindowWidthChanged", method: "volumeWindowWidthChanged", bubbles: !0, cancelable: !0, composed: !0 }]; }, enumerable: !0, configurable: !0 }), Object.defineProperty(e, "style", { get: function () { return "ion-item{--border-width:0 0 0 0;--inner-border-width:0 0 0 0}ion-item select{padding:5px;min-width:100px}"; }, enumerable: !0, configurable: !0 }), e; }();
exports.AlControlPanel = AlControlPanel;
