(()=>{function n(e,t,o,i,a,c,n,s,r){var l={fragment:"",iconMap:"",label:""},u=[];function p(n){return t.all([o.childDevices(n),o.childAssets(n)]).then(_.flattenDeep)}function f(n){u=n,n=e.config.options.parentId,o.detail(n).then(a.getResData).then(d)}function d(n){var t;c.isGroup(n)||u.push(n),n=u,t=["id","name","type"],n=_.map(n,function(e){return _.reduce(t,function(n,t){return n[t]=(e.managedObject||e)[t],n},{})}),n=_.map(n,function(t){var n=_.find(e.config.options.assets,function(n){return n.id===t.id});return n&&_.assign(t,n),t}),e.assets=n}function g(n){return _.filter(n,function(n){return n.__active})}function m(n){e.config.options.iconsMap=n}function h(n,t){n.operation=t}e.assets=[],e.updateOptions=function(){e.config.options.assets=g(e.assets)},e.addCustomColumn=function(){e.config.options.customColumns.push(_.cloneDeep(l))},e.addDeviceShellOperationButton=function(){e.config.options.deviceShellOperationButtons.push({label:""})},e.addOperation=function(n){return i({templateUrl:":::PLUGIN_PATH:::/views/addOperation.html",title:s("Add operation"),controller:"addOperationCtrl",resolve:{deviceTypes:function(){return n=e.assets,_(g(n)).filter("type").map("type").uniq().value();var n},operation:function(){return n.operation||{}}}}).then(_.partial(h,n))},e.onDelete=function(n,t){n.splice(t,1)},e.addIconMap=function(){return i({templateUrl:":::PLUGIN_PATH:::/views/addIconMap.html",title:s("Add icon map"),controller:"addIconMapCtrl",resolve:{iconsMap:function(){return e.config.options.iconsMap||[]}},size:"lg"}).then(m)},e.countConfig=function(t){var n=e.$new(!0);n.type=e.config.options.data[t.name].type,n.title=r.getString("Configure column: {{label}}",t),i({templateUrl:":::PLUGIN_PATH:::/views/countConfig.html",size:"lg",scope:n}).then(function(n){e.config.options.data[t.name]=!n||{type:n}})},e.counterColumns=n,e.$watch("config.device",function(n){n&&(e.config.options.parentId=n.id,p(n.id).then(f))}),e.config.options?p(e.config.options.parentId).then(f):e.config.options={data:{availability:!0,alarms:!0,communication:!0,location:!0,lastValidMessage:!0,maintenance:!0},customColumns:[],deviceShellOperationButtons:[]}}n.$inject=["$scope","$q","c8yInventory","c8yModal","c8yBase","c8yGroups","counterColumns","gettext","gettextCatalog"],angular.module("c8y.assets").controller("AssetsConfigCtrl",n)})();