(()=>{function e(p,d,y,e,v,g,h){var E;return{list:function(){return p.all({deviceList:d.list({pageSize:6}),currentApp:e.getCurrent(),buildTarget:p.resolve(y.appOption("target")),userApps:e.listByUser().then(i)}).then(function(e){var i,r,n=_.get(e,"currentApp.name"),c=(e.deviceList||[]).length,t=e.buildTarget,e=(E=e.userApps,[]),o=p.all({currentUser:g.current(),userHierarchyActive:v.userHierarchyActive()}).then(function(e){var i=e.currentUser,e=e.userHierarchyActive;return(g.hasRole(i,"ROLE_USER_MANAGEMENT_ADMIN")||e&&g.hasRole(i,"ROLE_USER_MANAGEMENT_CREATE"))&&k("administration")}).then(function(e){return e?_.assign({priority:2,icon:"c8y-icon c8y-icon-add-user",label:h("Add user"),url:"/apps/administration/index.html#/users/new",color:"#FEFEFE",backgroundColorClass:m("a")},i):null}),a=(e=>{var i;return i=k("devicemanagement")?_.assign({priority:2,icon:"c8y-icon c8y-icon-device-connect",label:h("Add device"),url:"/apps/devicemanagement/#/deviceregistration",color:"#FEFEFE",backgroundColorClass:m("b")},e):i})(),l={priority:({dt:{priority:2}}[t]||{}).priority||3,icon:"c8y-icon c8y-icon-device-management",label:h("Device Management"),url:"/apps/devicemanagement",color:"#EFEFEF",backgroundColorClass:m("f")},u={priority:({dt:{priority:2}}[t]||{}).priority||3,icon:"c8y-icon c8y-icon-cockpit",label:h("Cockpit"),url:"/apps/cockpit",color:"#EFEFEF",backgroundColorClass:m("e")},s={priority:2,iconSrc:":::PLUGIN_PATH:::/icons/HelpAndService.svg",label:h("Help & Service"),url:"/apps/HelpAndService",color:"#EFEFEF",backgroundColorClass:m("f")};return 0===c?void 0!==a&&(a.priority=1):c<=5?(r=1===c?1:3,e.push(d.list({pageSize:c}).then(function(e){var i=[];return _.forEach(e,function(e){i.push(((e,i,r,n)=>{var c,t=_.filter(["cockpit","devicemanagement"],k);return t.length&&(n=_.includes(t,n)?n:_.head(t),c=_.assign({priority:({dt:{priority:2}}[r]||{}).priority||3,icon:"c8y-icon c8y-icon-device",label:e.name||h("Device ")+e.id,url:"/apps/".concat(n,"/#/device/").concat(e.id),color:"#FEFEFE",backgroundColorClass:m("c")},i)),c})(e,{priority:r},t,n))}),i}))):u.priority=1,e.push((()=>{var e,i=y.getPluginService("phoneRegistrationService");return e=i?i.createAddPhoneLink():e})()),e.push(p.when(o)),e.push(p.when(a)),"devicemanagement"!==n&&k("devicemanagement")&&e.push(p.when(l)),"cockpit"!==n&&k("cockpit")&&e.push(p.when(u)),"HelpAndService"!==n&&"dt"===t&&k("HelpAndService")&&e.push(p.when(s)),p.all(e).then(_.flattenDeep).then(_.partialRight(_.filter,_.identity))})}};function k(e){return _.includes(E,e)}function m(e){return["quick-link","quick-link-".concat(e.priority),"quick-link-bgcolor-".concat(e.backgroundColorClass)]}function i(e){return _(e).map("contextPath").uniq().value()}}e.$inject=["$q","c8yDevices","c8yBase","c8yApplication","c8yUserUtil","c8yUser","gettext"],angular.module("c8y.ui").factory("c8yQuickLinks",e)})();