}, { name: "network", icon: "network-activity", iconInactived: "network-activity-off", title: "cellular-data", observerSetting: "ril.data.enabled", order: { portrait: 3, landscape: 4 }, cskType: "toggle" }, {
_ = function(e) {
function t() {
o(this, t);
var e = r(this, (t.__proto__ || Object.getPrototypeOf(t)).call(this));
return e.name = "InstantSettingsStore", e.oriSettings = [{
name: "volume",
icon: "sound-max",
isShortcut: !0,
title: "volume",
order: {
portrait: 1,
landscape: 1
},
click: function(t) {
return e.volumeManagerTimer ? void("ArrowUp" !== t && "ArrowDown" !== t || (e.enterVolumeManagerMode(), navigator.volumeManager["request" + t.slice(5)]())) : (e.enterVolumeManagerMode(), void navigator.volumeManager.requestShow())
}
}, {
name: "brightness",
icon: "brightness",
isShortcut: !0,
title: "brightness",
subtitle: "percentage-number",
order: {
portrait: 2,
landscape: 2
},
cskType: "toggle",
click: e.toggleBrightness.bind(e)
}, {
name: "flashlight",
icon: "flashlight-on",
iconInactived: "flashlight-off",
title: "flashlight",
removed: !0,
order: {
portrait: 4,
landscape: 3
},
cskType: "toggle",
click: v.default.toggle.bind(v.default)
}, {
name: "camera",
icon: "camera",
isShortcut: !0,
title: "camera",
order: {
portrait: 7,
landscape: 6
},
cskType: "launch",
click: function() {
y.default.launch("manifestURL", "app://camera.gaiamobile.org/manifest.webapp")
}
}, {
name: "calculator",
icon: "settings",
isShortcut: !0,
title: "settings",
order: {
portrait: 5,
landscape: -1
},
cskType: "launch",
click: function() {
y.default.launch("manifestURL", "app://settings.gaiamobile.org/manifest.webapp")
}
}, {
name: "airplane-mode",
icon: "airplane-mode",
iconInactived: "airplane-mode-off",
title: "airplane-mode",
observerSetting: "airplaneMode.enabled",
order: {
portrait: 8,
landscape: 7
},
cskType: "toggle"
}, {
name: "wifi",
icon: "wifi-32px",
iconInactived: "wifi-off-32px",
title: "wifi-tether",
observerSetting: "tethering.wifi.enabled",
removed: !0,
order: {
portrait: 0,
landscape: 0
},
cskType: "toggle"
}, {
name: "network",
icon: "network-activity",
iconInactived: "network-activity-off",
title: "usb-tether",
observerSetting: "tethering.usb.enabled",
order: {
portrait: 3,
landscape: 4
},
cskType: "toggle"
}, {
name: "bluetooth",
icon: "bluetooth-32px",
iconInactived: "bluetooth-off-32px",
title: "bluetooth",
removed: !0,
observerSetting: "bluetooth.enabled",
order: {
portrait: 6,
landscape: 5
},
cskType: "toggle"
}], e.brightnessMap = {
100: .1,
10: .4,
40: .7,
70: 1
}, e.orderType = w.isLandscape ? "landscape" : "portrait", e
}
return s(t, e), l(t, [{
key: "start",
value: function() {
var e = this,
t = this.orderType;
this.settings = this.oriSettings.filter(function(e) {
return -1 !== e.order[t]
}).sort(function(e, n) {
return e.order[t] - n.order[t]
}), this.settings.forEach(function(t) {
t.observerSetting && !t.removed && e.initSettingObserver(t)
}), this.initSettingObserverForBrightness(), d.default.addObserver("airplaneMode.status", this), navigator.hasFeature && navigator.hasFeature("device.capability.torch").then(function(t) {
if (t) {
e.getSetting("flashlight").removed = !1, v.default.on("ready", e.updateFlashlightState.bind(e)), v.default.on("change", e.updateFlashlightState.bind(e))
}
}), navigator.hasFeature && navigator.hasFeature("device.capability.bt").then(function(t) {
if (t) {
navigator.mozBluetooth.defaultAdapter || (navigator.mozBluetooth.onattributechanged = function(e) {
e.attrs.includes("defaultAdapter") && (navigator.mozBluetooth.onattributechanged = null)
});
var n = e.getSetting("bluetooth");
n.removed = !1, e.initSettingObserver(n)
}
}), navigator.hasFeature && navigator.hasFeature("device.capability.wifi").then(function(t) {
if (t) {
var n = e.getSetting("wifi");
n.removed = !1, e.initSettingObserver(n)
}
}), this.emit("change")
}
}, {
key: "initSettingObserver",
value: function(e) {
var t = this;
d.default.addObserver(e.observerSetting, this), this["_observe_" + e.observerSetting] = function(n) {
var i = t.getSetting(e.name);
i.isActive = n, !0 === n ? i.subtitle = "on" : !1 === n ? i.subtitle = "off" : i.subtitle = n.toString(), t.emit("change")
}
}
}, {
key: "initSettingObserverForBrightness",
value: function() {
var e = this;
d.default.addObserver("screen.brightness", this), this["_observe_screen.brightness"] = function(t) {
e.getSetting("brightness").subtitleArgs = {
number: 100 * t
}, e.emit("change")
}
}
}, {
key: "_observe_airplaneMode.status",
value: function(e) {
var t = "enabling" === e || "disabling" === e;
this.getSetting("airplane-mode").isDisabled = t, this.emit("change")
}
}, {
key: "updateFlashlightState",
value: function() {
dump("cck updateFlashlightState entry");
var e = this.getSetting("flashlight"),
t = v.default.flashlightManager.flashlightEnabled;
dump("cck updateFlashlightState _flashlightEnabled=" + t), e.isActive = t, e.subtitle = t ? "on" : "off", this.emit("change")
}
}, {
key: "checkSimCardState",
value: function() {
var e = h.default.noSIMCardOnDevice() || h.default.noSIMCardConnectedToNetwork(),
t = -1 !== h.default.getSlots().map(function(e) {
return e.conn.voice.state
}).indexOf("searching"),
n = this.getSetting("network"),
i = this.getSetting("airplane-mode");
n.isDisabled = i.isActive || e, !t && e && n.isActive && this.toggleSetting(n), this.emit("change")
}
}, {
key: "addSimCardObserver",
value: function() {
var e = this;
if (!this.isSimCardObserverAdded) {
this.isSimCardObserverAdded = !0, this.checkSimCardState();
var t = window.navigator.mozMobileConnections;
t && Array.from(t).forEach(function(t) {
t.addEventListener("voicechange", e)
}, this)
}
}
}, {
key: "removeSimCardObserver",
value: function() {
var e = this;
this.isSimCardObserverAdded = !1;
var t = window.navigator.mozMobileConnections;
t && Array.from(t).forEach(function(t) {
t.removeEventListener("voicechange", e)
}, this)
}
}, {
key: "_handle_voicechange",
value: function() {
this.checkSimCardState()
}
}, {
key: "getIndex",
value: function(e) {
var t = this.settings.findIndex(function(t) {
return t.name === e
});
return t
}
}, {
key: "getSetting",
value: function(e) {
var t = this.settings.find(function(t) {
return t.name === e
});
return t
}
}, {
key: "toggleSetting",
value: function(e) {
var t = this;
e.isDisabled = !0, this.emit("change");
var n = function() {
e.isDisabled = !1, t.emit("change")
};
d.default.get(e.observerSetting).then(function(t) {
var i = {};
i[e.observerSetting] = !t, d.default.set(i).then(function() {
switch (e.name) {
case "airplane-mode":
break;
case "bluetooth":
w.toggleBletooth(t ? "disable" : "enable").then(function() {
return n()
}, function(e) {
n()
});
break;
default:
n()
}
})
})
}
}, {
key: "toggleBrightness",
value: function() {
var e = this.getSetting("brightness").subtitleArgs.number;
d.default.set({
"screen.brightness": this.brightnessMap[e] || .1
})
}
}, {
key: "enterVolumeManagerMode",
value: function() {
var e = this;
this.volumeManagerTimer && this.exitVolumeManagerMode(), this.volumeManagerTimer = setTimeout(function() {
e.exitVolumeManagerMode()
}, 2e3)
}
}, {
key: "exitVolumeManagerMode",
value: function() {
window.clearTimeout(this.volumeManagerTimer), this.volumeManagerTimer = null
}
}, {
key: "click",
value: function(e, t) {
var n = this.getSetting(e);
if (n && !n.isDisabled)
if ("toggle" === n.cskType && n.observerSetting) this.toggleSetting(n);
else if (n.click) return n.click(t), n.cskType
}
}]),