text: "use strict";var NG_HIDE_CLASS="ng-hide";angular.module("mm.acl",[]),angular.module("mm.acl").provider("AclService",[function(){function a(){var a;switch(b.storage){case"sessionStorage":a=j("sessionStorage");break;case"localStorage":a=j("localStorage");break;default:a=null}return!!a&&(angular.extend(c,a),!0)}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){for(var b=this.length;b--;)if(this[b]===a)return b;return-1});var b={storage:"sessionStorage",storageKey:"AclService"},c={roles:[],abilities:{}},d=function(a){return"object"==typeof c.abilities[a]},e=function(a){return d(a)?c.abilities[a]:[]},f=function(){switch(b.storage){case"sessionStorage":h("sessionStorage");break;case"localStorage":h("localStorage");break;default:return}},g=function(){switch(b.storage){case"sessionStorage":i("sessionStorage");break;case"localStorage":i("localStorage");break;default:return}},h=function(a){window[a].setItem(b.storageKey,JSON.stringify(c))},i=function(a){window[a].removeItem(b.storageKey)},j=function(a){var c=window[a].getItem(b.storageKey);return!!c&&JSON.parse(c)},k={};return k.resume=a,k.flushStorage=function(){g()},k.attachRole=function(a){c.roles.indexOf(a)===-1&&(c.roles.push(a),f())},k.detachRole=function(a){var b=c.roles.indexOf(a);b>-1&&(c.roles.splice(b,1),f())},k.flushRoles=function(){c.roles=[],f()},k.hasRole=function(a){for(var b=angular.isArray(a)?a:[a],d=b.length;d--;)if(c.roles.indexOf(b[d])===-1)return!1;return!!b.length},k.hasAnyRole=function(a){for(var b=a.length;b--;)if(k.hasRole(a[b]))return!0;return!1},k.getRoles=function(){return c.roles},k.setAbilities=function(a){c.abilities=a,f()},k.addAbility=function(a,b){c.abilities[a]||(c.abilities[a]=[]),c.abilities[a].push(b),f()},k.can=function(a){for(var b,d,f=c.roles.length;f--;)if(b=c.roles[f],d=e(b),d.indexOf(a)>-1)return!0;return!1},k.canAny=function(a){for(var b,d,f=c.roles.length,g=a.length;f--;)for(b=c.roles[f],d=e(b);g--;)if(d.indexOf(a[g])>-1)return!0;return!1},{config:function(a){angular.extend(b,a)},resume:a,$get:function(){return k}}}]).directive("aclShow",function(a){return{restrict:"A",link:function(b,c,d){b.$watch(d.aclShow,function(b){var d,e;if(!b)return void c.addClass("ng-hide");d=b.split(","),e=a.canAny(d),e?c.removeClass("ng-hide"):c.addClass("ng-hide")})}}});