text: /*! Copyright 2013 Amazon Digital Services, Inc. All rights reserved. */
  ProfilesHandler=(function(){var a=function(f,c,b){var e="ProfileRequest";var d=this;this["getHandledType"]=function(){return e};this["getCORSupported"]=function(){return f.getCORSupported()};this["setCOR"]=function(g){return f.setCOR(g)};this["getTOSAccepted"]=function(){return f.getTOSAccepted()};this["acceptTOS"]=function(){var g=new GameCircleEvent("AcceptedTerms");g.close();return f.acceptTOS()};this["clearCachedProfile"]=function(){return c.cacheProfile("SELF",{})};this["getProfile"]=function(h,i,j){var g=$.Deferred();if(typeof i==="undefined"){var i=0}if(typeof j==="undefined"){var j=true}c.getCachedProfile("SELF").always(function(k,n){if(h){hostinterface.logMessage("ProfileHandler: getProfile result: "+JSON.stringify(k));var m=k&&k.hidden;b.setHiddenFlag(m).always(function(){g.resolve(k,n)})}else{var l=$.Deferred();f.getProfile().always(function(o,p){l.resolve(o,p)});if(JSON.stringify(k)!=="{}"&&j==false){g.resolve(k,n)}else{if(i>0){setTimeout(function(){console.log("ProfileHandler: getProfile timed out");l.resolve({},constants.NativeCallResultCode.NETWORK_ERROR)},i)}}l.always(function(o,p){hostinterface.logMessage("ProfileHandler: getProfile result: "+JSON.stringify(o));if(p!=constants.NativeCallResultCode.SUCCESS){console.log("ProfileHandler: getProfile result: SERVICE RESULT NOT OK");var q=k&&k.hidden;b.setHiddenFlag(q).always(function(){g.resolve(k,n)})}else{var r=c.cacheProfile("SELF",o);r.always(function(){console.log("UPDATED PROFILE CACHE");var s=o&&o.hidden;b.setHiddenFlag(s);g.resolve(o,p)})}})}});return g.promise()};this["getAvatars"]=function(h){var g=$.Deferred();if(h){c.getCachedAvatars().always(function(i,j){console.log("ProfileHandler: getAvatars cached result: "+JSON.stringify(i));g.resolve(i,j)})}else{f.getAvatars().always(function(i,j){console.log("ProfileHandler: getAvatars network result: "+JSON.stringify(i));if(j!=constants.NativeCallResultCode.SUCCESS){console.log("ProfileHandler: getAvatars network result: SERVICE RESULT NOT OK");c.getCachedAvatars().always(function(m,l){console.log("ProfileHandler: returning cached data for getAvatars : "+JSON.stringify(m));g.resolve(m,l)})}else{var k=c.cacheAvatars(i);k.always(function(){console.log("Updated getAvaters cache");g.resolve(i,j)})}})}return g.promise()};this["handleRequest"]=function(l){var h=$.Deferred();if(!(l instanceof Request)){console.log("ProfileHandler: handleRequest: input was not of type Request");var g=new Result(constants.NativeCallResultCode.REQUEST_ERROR,{});h.resolve(g)}else{console.log("ProfileHandler: handleRequest: message is: "+JSON.stringify(l.getType()));var i=l.getType();var m=l.getParams();var j=m.action;var k={};switch(j){case"getProfile":d.getProfile(m.cacheOnly).always(function(o,n){h.resolve(new Result(n,o))});break;case"updateProfile":f.updateProfile(m.profile).always(function(o,n){h.resolve(new Result(n,o))});break;case"updateProfileHidden":f.updateProfileHidden(m.hidden).always(function(n,o){d.getProfile().always(function(){h.resolve(new Result(o,n))});h.resolve(new Result(o,n))});break;case"getAvatars":d.getAvatars(m.cacheOnly).always(function(n,o){h.resolve(new Result(o,n))});break;case"clearCache":c.clear().always(function(n,o){h.resolve(new Result(o,n))});break;default:console.log("ProfileHandler: handleRequest: actionCode not supported: "+j);var g=new Result(constants.NativeCallResultCode.REQUEST_ERROR,{});h.resolve(g)}}console.log("ProfileHandler: handleRequest: end of call");return h.promise()}};return a}());console.log("ProfilesHandler loaded.");CORSupportedResponse=function(a){this.isUnknown=!a||!a.supportLevel||a.supportLevel=="Unknown";this.isNotSupported=a&&a.supportLevel=="Offline"};