Registry.require(["promise","helper","asker"],function(){var e=Registry.get("promise"),l=Registry.get("helper"),m=Registry.get("asker"),c=!1,d=null,h=null,f=function(){return c?c:e.Pledge()},n=function(a){rea.permissions.onAdded.addListener(function(b){a({added:b})});rea.permissions.onRemoved.addListener(function(b){a({removed:b})})},g={permContentSettings:"contentSettings",permDownloads:"downloads",get:function(){var a=e();d={};h={};c=a.promise();rea.permissions.getAll(function(b){b.permissions&&
l.each(b.permissions,function(a,b){d[a]=!0});b.origins&&l.each(b.origins,function(a,b){h[a]=!0});c=null;a.resolve()});return a.promise()},has:function(a){return f().then(function(){return d?!!d[a]||!!h[a]:(n(function(){f().then(g.get)}),g.get().then(function(){return g.has(a)}))})},hasOrigin:function(a){Array.isArray(a)||(a=[a]);return f().then(function(){var b=e();rea.permissions.contains({origins:a},function(a){b.resolve(a)});return b.promise()})},ask:function(a,b,c){Array.isArray(a)||(a=[a]);var k=
e();rea.permissions.supported?m.askForPermission({permissions:a},b,c).done(function(b){b.granted&&(d||(d={}),d[a]=!0);k.resolve(b.granted)}):k.resolve(!1);return k.promise()},askOrigin:function(a,b,d){Array.isArray(a)||(a=[a]);var c=e();rea.permissions.supported?m.askForPermission({origins:a},b,d).done(function(a){c.resolve(a.granted)}):c.resolve(!1);return c.promise()},remove:function(a){return f().then(function(){var b=e();rea.permissions.supported?(c=b.promise(),rea.permissions.remove({permissions:[a]},
function(e){c=null;d&&(d[a]=!1);b.resolve(e)})):b.resolve(!0);return b.promise()})},addListener:n};Registry.register("permission","5946",g)});
