(function(c,b){var a={};"object"==typeof c&&(a=c,c=a.mode);global.WIDGETS&&WIDGETS.back&&WIDGETS.back.remove();Bangle.btnWatches&&(Bangle.btnWatches.forEach(clearWatch),delete Bangle.btnWatches);Bangle.swipeHandler&&(Bangle.removeListener("swipe",Bangle.swipeHandler),delete Bangle.swipeHandler);Bangle.touchHandler&&(Bangle.removeListener("touch",Bangle.touchHandler),delete Bangle.touchHandler);Bangle.uiRemove&&(Bangle.uiRemove(),delete Bangle.uiRemove);if(c){if("updown"== c)Bangle.btnWatches=[setWatch(function(){b(-1)},BTN1,{repeat:1,edge:"falling"}),setWatch(function(){b(1)},BTN3,{repeat:1,edge:"falling"}),setWatch(function(){b()},BTN2,{repeat:1,edge:"falling"})];else if("leftright"==c)Bangle.btnWatches=[setWatch(function(){b(-1)},BTN1,{repeat:1,edge:"falling"}),setWatch(function(){b(1)},BTN3,{repeat:1,edge:"falling"}),setWatch(function(){b()},BTN2,{repeat:1,edge:"falling"})],Bangle.swipeHandler=d=>{b(d)},Bangle.on("swipe",Bangle.swipeHandler),Bangle.touchHandler= d=>{b()},Bangle.on("touch",Bangle.touchHandler);else if("clock"==c)Bangle.CLOCK=1,Bangle.btnWatches=[setWatch(Bangle.showLauncher,BTN2,{repeat:1,edge:"falling"})];else if("clockupdown"==c)Bangle.CLOCK=1,Bangle.btnWatches=[setWatch(function(){b(-1)},BTN1,{repeat:1,edge:"falling"}),setWatch(function(){b(1)},BTN3,{repeat:1,edge:"falling"}),setWatch(Bangle.showLauncher,BTN2,{repeat:1,edge:"falling"})];else if("custom"==c)a.touch&&(Bangle.touchHandler=a.touch,Bangle.on("touch",Bangle.touchHandler)),a.swipe&& (Bangle.swipeHandler=a.swipe,Bangle.on("swipe",Bangle.swipeHandler)),a.btn&&(Bangle.btnWatches=[setWatch(function(){a.btn(1)},BTN1,{repeat:1,edge:"falling"}),setWatch(function(){a.btn(2)},BTN2,{repeat:1,edge:"falling"}),setWatch(function(){a.btn(3)},BTN3,{repeat:1,edge:"falling"})]);else throw Error("Unknown UI mode");if(a.back){var e=d=>{1==d&&a.back()};Bangle.on("touch",e);WIDGETS=Object.assign({back:{area:"tl",width:24,draw:d=>g.reset().setColor("#f00").drawImage(atob("GBiBAAAYAAH/gAf/4A//8B//+D///D///H/P/n+H/n8P/n4f/vwAP/wAP34f/n8P/n+H/n/P/j///D///B//+A//8Af/4AH/gAAYAA=="), d.x,d.y),remove:()=>{Bangle.removeListener("touch",e);g.reset().clearRect({x:WIDGETS.back.x,y:WIDGETS.back.y,w:24,h:24});delete WIDGETS.back;Bangle.drawWidgets()}}},global.WIDGETS);Bangle.drawWidgets()}}})