(()=>{function e(t,n){var r="c8y_objectmapping_ObjectMapping",c="".concat(r,".objectId"),o="".concat(r,".objectModel"),s="".concat(o,".resources"),i="".concat(r,".resourceMappings"),u="".concat(r,".objectInstanceActions");return{createManagedObject:function(e){var e=_.assign({resources:{}},e),t={};return _.set(t,r,{}),_.set(t,c,e.id),_.set(t,o,e),_.set(t,i,{}),_.set(t,u,{}),t},getName:function(e){var t="".concat(o,".name");return _.get(e,t)},getObjectId:function(e){return _.get(e,c)},countResources:function(e){e=_.get(e,s);return _.size(e)},updateResource:a,removeResource:function(e,t){return a(null,e,t)},updateMappingToResource:function(e,t,n){{var r;e&&(r=_.get(n,i)||{},t=e.resourceID=t.id,r[t]=e,1===_.keys(e).length&&delete r[t],0===_.keys(r).length&&(r=null),_.set(n,i,r))}return n},saveToInventory:function(e){e=_.pick(e,["id",r]);return n.save(e).then(t.getResData)},getMainProperties:function(e){return _.get(e,o)},updateMainProperties:function(e,t){e=_.merge(_.get(t,o),e);return _.set(t,c,e.id),t},getMappings:function(e){return _.get(e,i)},getMainObject:function(e){return _.get(e,o)},getResources:function(e){return _.get(e,s)},isSameResource:function(e,t){e=_.get(e,"id"),t=_.get(t,"id");return e===t},fragments:{BASE_FRAGMENT:r}};function a(e,t,n){var r=_.get(n,s)||{},c=_.get(n,i)||{},o=_.get(e,"id"),t=_.get(t,"id"),u=c[t];return o===t||_.isUndefined(t)||(delete r[t],delete c[t],u&&(u.resourceID=o)&&(c[o]=u)),o&&(r[o]=e),_.set(n,s,r),_.set(n,i,c),n}}e.$inject=["c8yBase","c8yInventory"],angular.module("c8y.deviceProtocols").factory("c8yObjectMappings",e)})();