(()=>{function e(e,i,c,a){var o=this,n=e.$id,s="c8y_GenericUI_Schema_",r=[];function t(e){var t=o.context,c=_.get(e.schema,"c8y_JsonSchema"),n=RegExp("".concat(s,"(\\d+)")),a=_.find(_.keys(e.schema),function(e){return n.test(e)}),a=_.trimStart(a,s),c="".concat(c.title," /").concat(a,"/${object.instance}"),a=i.replaceObjectPlaceholders(c,t,e.key);return _.assign({managedObject:t,title:a},e)}function m(){o.matches=i.matchObjectWithSchemas(o.context,o.schemas),o.objects=_.sortBy(o.matches.map(t),"title")}function u(){_.uniq(r).forEach(function(e){return c.destroySubscription(n,e)}),r=[]}_.assign(o,{$onChanges:function(e){_.get(e,"context.currentValue.id")===_.get(e,"context.previousValue.id")&&!e.schemas||(m(),(()=>{var e,t;u(),_.get(o,"context.id")&&(e=c.realtimeActions().UPDATE,t="/managedobjects/".concat(o.context.id),c.addListener(n,t,e,function(e,t){var c,n;t=t,c=i.matchObjectWithSchemas(t,o.schemas),n=_.map(o.matches,"key"),c=_.map(c,"key"),(_.difference(c,n).length||_.difference(n,c).length)&&(o.context=a.updateManagedObject(o.context,t),m())}),c.start(n,t),r.push(t))})())},$onDestroy:function(){u()},select:function(e){o.selected=e},isSelected:function(e){return e===o.selected}})}e.$inject=["$scope","c8yGenericUi","c8yRealtime","c8yInventory"],angular.module("c8y.genericUi").component("c8yGenericUi",{templateUrl:":::PLUGIN_PATH:::/generic-ui.html",controllerAs:"vm",controller:e,bindings:{schemas:"<",context:"<"}})})();