function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}(()=>{function e(s,r,t,n,e,i,o,c){var a=c.type?e.another(e.paths[c.type]):e.another(t.dataFilePath("properties/managed-objects.json")),u=["additionParents","assetParents","deviceParents","childAdditions","childAssets","childDevices","c8y_IsDevice","__children","c8y_ui","self","parent","c8y_DataPoint","c8y_Kpi_Migrated",/^c8y_Dashboard!\d+/],p=[];function l(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],c={};return _.isObjectLike(e)&&_.forOwn(e,function(e,t){var r,n,i;r=t,_.find(p,function(e){return e instanceof RegExp?e.test(r):e===r})||_.isArray(e)||_.isObjectLike(e)&&_.isEmpty(e)||((i=_.cloneDeep(o)).push(t),n={label:t,title:t,keyPath:i,id:"c8yCustom!!".concat(i.join(".")),type:"string",schema:{}},_.isObjectLike(e)&&(n.type="object",n.printFormat="hidden",n.properties={},e=l(e,i),_.isObjectLike(e))&&_.forOwn(e,function(e,t){n.properties[t]=e}),i=_.pick(n,"properties"),n.schema={properties:{}},n.schema.properties[n.label]={type:n.type,title:n.title},"object"===n.type?n.schema.properties[n.label].properties=i.properties:(e=_.cloneDeep(n.keyPath),n.schema=h(e,n.title)),a.addCustomProperty(n),s.properties.push(n),c[t]=n)}),c}function h(e,t){var r=_.get(s.managedObject,e),n={title:t,type:void 0!==r?_typeof(r):"string"},t=e.slice().reverse();return _.reduce(t,function(e,t){var r={properties:{}};return _.isEqual(e,n)||_.assign(e,{type:"object",printFormat:"hidden"}),r.properties[t]=e,r},n)}function d(){p=_(s.properties).filter(function(e){return"c8yCustom"!==_.head(e.id.split("!!"))}).map(function(e){return 1<e.keyPath.length?_.filter(e.keyPath,function(e){return"c8y"===e.substr(0,3)}):e.keyPath}).flatten().uniq().value(),p=_.union(p,u)}function y(){s.properties=_.sortBy(s.properties,"orderKey")}function f(){s.properties=_(s.properties).reject(function(e){return c.showRootPropertiesOnly&&1<e.keyPath.length}).reject(function(e){return!c.showComputed&&e.computed}).reject(function(e){return c.hideExistingInMO&&_.has(s.managedObject,e.keyPath)}).value()}function m(){var e=r.resolve();return e=t.hasId(s.managedObject)?n.detail(s.managedObject).then(t.getResData).then(function(e){return s.withChildren?(t=e,n.getChildren(t).then(function(e){e=_.uniqBy(e,"id").concat(t);return _.reduce(e,function(e,t){return _.isObjectLike(t)?_.merge(e,t):e})})):e;var t}):e}function b(){_.forEach(s.properties,function(e){var t,n;e.orderKey=(e=e,t=!a.isComplexProperty(e)&&1===e.keyPath.length,(n=[]).push(e.computed?"z":"a"),n.push(t?"a":"z"),_.reduce(e.keyPath,function(e,t){var r=[],e=(e&&r.push(e),t&&r.push(t),r=r.join("."),_.find(s.properties,function(e){return e.keyPath.join(".")===r}));return n.push(e.label),n.push(r),r},""),n.join(","))})}function g(t){return t.computed&&t.configSchema?i.edit(t).then(function(e){return t.config=e,t},function(){return t.removed=!0,t}):r.when(t)}function P(e){var t,r,n=_.cloneDeep(e);return e.computed&&e.configSchema&&(t=String(Math.random()).substr(2),r="".concat(_.last(e.id.split("!!")),"_").concat(t),(n=_.clone(e)).config={_id:t},n.keyPath=[r]),n}function v(e){var t=j(_.map(a.getChildren(e,null),"id"));a.changeActiveProperty(t,e.__active)}function j(t){return _.filter(s.properties,function(e){return _.includes(t,e.id)})}s.properties=[],s.managedObject=c.managedObject,s.withChildren=c.withChildren,s.selectSingle=c.selectSingle,s.close=function(){function t(e){return _.omit(e,["orderKey"])}var e;return c.selectSingle?g(P(s.properties.selected)).then(function(e){return e.removed?o.dismiss():o.close(t(e))}):(e=r.all(_.map(_.map(_.filter(s.properties,"__active"),P),g)).then(function(e){return _.reject(e,"removed")}).then(function(e){return _.map(e,t)}),o.close(e))},s.onSelectProperty=function(e){var t,r;c.includeTree&&(v(e),t=e,r=a.getParent(t),r=j(_.map(r,"id")),t.__active)&&a.changeActiveProperty(r,!0),c.includeTreeChildren&&v(e)},s.buildObjectFromArray=h,s.dismiss=o.dismiss,s.isComplexProperty=a.isComplexProperty,s.isAtLeastOneSubpropertyListed=function(t){return _.some(s.properties,function(e){return e.keyPath.length>t.keyPath.length&&_.isEqual(t.keyPath,_.slice(e.keyPath,0,t.keyPath.length))})},s.selectIsDisabled=function(){return c.selectSingle?!s.properties.selected:_.every(s.properties,function(e){return!e.__active})},s.search="",s.filterByLabelOrProperty=function(e){var t,r=s.search.toLowerCase();return""===r||(t=e.keyPath,e=e.label?e.label.toLowerCase():"",t=_.isEmpty(t)?"":t.join(".").toLowerCase(),e.includes(r))||t.includes(r)},a.list().then(function(e){s.properties=e}).then(d).then(m).then(l).then(b).then(y).then(f)}e.$inject=["$scope","$q","c8yBase","c8yDevices","c8yPropertiesLibrary","c8yComputedProperties","$uibModalInstance","modalParams"],angular.module("c8y.ui").controller("schemaPropertySelectorCtrl",e)})();