!function(){"use strict";function e(e,i){var r=this;r.applyPreset=function(r){e.applyPreset(r.target.id),0==e.isInitialized?(document.getElementById("Luminosity").checked=!0,i.script("channelInitialization()").then(function(r){console.log("in applyPreset, layerID",+r),e.mergedLayerID=Number(JSON.parse(r).mergedLayerID),e.originalLayerID=Number(JSON.parse(r).originalLayerID),e.isInitialized=!0,i.runFilter()})):i.hasLayersError().then(function(e){e?i.reset(!0):i.runFilter()})},r.picker=function(r){var n=function(){i.script("selectLayer()").then(function(e){return i.script("openPicker()")}).then(function(r){if(r=JSON.parse(r),r.error){if(console.log("in RES.ERROR",r.error),e.isInitialized)return void i.evalScript("selectMask()");e.isInitialized=!0}else e.applyPicker(r),i.runFilter(),e.isInitialized=!0})};e.isInitialized?i.hasLayersError().then(function(e){e?i.reset(!0):n()}):i.script("channelInitialization()").then(function(i){document.getElementById("Luminosity").checked=!0,e.mergedLayerID=Number(JSON.parse(i).mergedLayerID),e.originalLayerID=Number(JSON.parse(i).originalLayerID)}).then(function(e){n()})}}angular.module("app").controller("PresetController",e),e.$inject=["tk","ps"]}();