var h,aa=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b},ba=function(a,b){function c(){}c.prototype=b.prototype;a.Ub=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.Rb=function(a,c,g){for(var d=Array(arguments.length-2),e=2;e<arguments.length;e++)d[e-2]=arguments[e];return b.prototype[c].apply(a,d)}};var k={Qb:{}},n,ca=!1,p=function(a){try{ca&&window.console&&window.console.log&&window.console.log(a)}catch(b){}},q=function(a,b){if(!a)return-1;if(a.indexOf)return a.indexOf(b,void 0);for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},r=function(a,b){function c(){}if(!a)throw"Child class cannot be empty.";if(!b)throw"Parent class cannot be empty.";c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a},da=function(a){return"[object Function]"===Object.prototype.toString.call(a)},
ea=function(a){var b=[],c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];if(null===d||void 0===d)d="";b.push(encodeURIComponent(c)+"="+encodeURIComponent(d))}return b.join("&")},fa=function(a){a=(new RegExp("[&#]"+a+"=([^&]*)")).exec(window.location.hash);return null==a?"":decodeURIComponent(a[1].replace(/\+/g," "))},ga=function(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent("on"+b,c);else throw"Add event handler for "+b+" failed.";},ha=function(a,b){a=
(a||"").split(" ");b=(b||"").split(" ");for(var c=0;c<b.length;c++)if(b[c]&&0>q(a,b[c]))return!1;return!0},ia=function(){if("undefined"!=typeof n)return n;var a=window.localStorage?window.localStorage:void 0;if(!a)return n=!1;try{a.setItem("test","test"),a.removeItem("test"),n=!0}catch(b){n=!1}return n},ja=function(){var a=navigator.userAgent.toLowerCase();return-1!=a.indexOf("msie")&&8==parseInt(a.split("msie")[1],10)},t=function(){return Object.hasOwnProperty.call(window,"ActiveXObject")&&!window.ActiveXObject},
ka=function(){var a=navigator.userAgent;return!!a&&/Edge\/\d+/.test(a)},la=function(){var a=navigator.userAgent,b;if(b=!!a&&-1!=a.indexOf("CriOS"))b=-1,(a=a.match(/CriOS\/(\d+)/))&&a[1]&&(b=parseInt(a[1],10)||-1),b=48>b;return b},ma=function(){var a=navigator.userAgent.toLowerCase();return-1<a.indexOf("safari/")&&0>a.indexOf("chrome/")&&0>a.indexOf("crios/")&&0>a.indexOf("android")},u=function(a){this.xa=a||[];this.A={}};
u.prototype.addEventListener=function(a,b){if(!(0<=q(this.xa,a)))throw"Unrecognized event type: "+a;if(!da(b))throw"The listener for event '"+a+"' is not a function.";this.A[a]||(this.A[a]=[]);0>q(this.A[a],b)&&this.A[a].push(b)};u.prototype.removeEventListener=function(a,b){if(!(0<=q(this.xa,a)))throw"Unrecognized event type: "+a;da(b)&&this.A[a]&&this.A[a].length&&(b=q(this.A[a],b),0<=b&&this.A[a].splice(b,1))};
u.prototype.dispatchEvent=function(a){var b=a.type;if(!(b&&0<=q(this.xa,b)))throw"Failed to dispatch unrecognized event type: "+b;if(this.A[b]&&this.A[b].length)for(var c=0,d=this.A[b].length;c<d;c++)this.A[b][c](a)};var v=v||{};v.G=function(a){a=encodeURIComponent(a);var b=v.Ja();if(b&&(a=b.match("(^|;) ?"+a+"=([^;]*)(;|$)"))&&2<a.length&&(a=a[2]))return decodeURIComponent(a)};v.kb=function(a){var b;(a=v.G(a))&&(b=String(na(a)));return b};v.Ja=function(){return document.cookie};
v.Kb=function(a){document.cookie=a};k=k||{};
k.sb=function(a,b){if(!0===k.na)a();else{var c=2;var d=function(){c--;0==c&&(k.na=!0,a())};var e=function(a){b(a)};switch(oa()){case "sessionStorage":k.ba=new w;k.ba.D(d,e);break;case "inMemoryStorage":k.ba=new y;k.ba.D(d,e);break;default:d=Error("Unsupported storage type: "+oa());b(d);return}switch(pa()){case "localStorage":k.M=new z;k.M.D(d,e);break;case "indexedDb":k.M=new A;k.M.D(d,e);break;case "cookieStorage":k.M=new B;k.M.D(d,e);break;default:d=Error("Unsupported storage type: "+pa()),b(d)}}};
k.La=function(){if(!k.na)throw Error("Storages are not initialized yet!");return k.M};k.qb=function(){if(!k.na)throw Error("Storages are not initialized yet!");return k.ba};var z=function(){};z.prototype.D=function(a,b){ia()?(this.Z=window.localStorage,a()):b&&b(Error("localStorage is not available in the current environment."))};z.prototype.getItem=function(a,b){b(this.Z.getItem(a))};z.prototype.setItem=function(a,b,c){void 0===b||null===b?this.Z.removeItem(a):this.Z.setItem(a,b);c&&c()};
z.prototype.removeItem=function(a,b){this.Z.removeItem(a);b&&b()};var A=function(){};A.prototype.D=function(a,b){var c=this,d=window.indexedDB.open("oauth");d.onsuccess=function(b){c.ia=b.target.result;a()};d.onupgradeneeded=function(a){a.target.result.createObjectStore("oauth")};d.onerror=function(a){a=a.target.errorCode;b&&b(Error("IndexedDb initialization failed: "+a))}};A.prototype.getItem=function(a,b){var c=this.ia.transaction("oauth","readwrite").objectStore("oauth").get(a);c.onsuccess=function(){b(c.result)}};
A.prototype.setItem=function(a,b,c){var d=this.ia.transaction("oauth","readwrite").objectStore("oauth");if(void 0===b||null===b)d["delete"](a);else d.put(b,a);d.transaction.oncomplete=function(){c&&c()}};A.prototype.removeItem=function(a,b){var c=this.ia.transaction("oauth","readwrite").objectStore("oauth");c["delete"](a);c.transaction.oncomplete=function(){b&&b()}};var y=function(){};y.prototype.D=function(a){this.ua={};a()};y.prototype.getItem=function(a,b){b(this.ua[a]||null)};
y.prototype.setItem=function(a,b,c){this.ua[a]=b;c&&c()};y.prototype.removeItem=function(a,b){delete this.ua[a];b&&b()};var w=function(){};w.prototype.D=function(a,b){ia()?(this.aa=window.sessionStorage,a()):b&&b(Error("sessionStorage is not available in the current environment."))};w.prototype.getItem=function(a,b){b(this.aa.getItem(a))};w.prototype.setItem=function(a,b,c){void 0===b||null===b?this.aa.removeItem(a):this.aa.setItem(a,b);c&&c()};
w.prototype.removeItem=function(a,b){this.aa.removeItem(a);b&&b()};var B=function(){this.xb=C.Va};B.prototype.D=function(a,b){navigator.cookieEnabled?a():b&&b(Error("Cookies are not enabled in current environment."))};B.prototype.getItem=function(a,b){for(var c=null,d=qa(a),e=0;e<d.length;e++)if(d[e].key==a){c=d[e].value;break}b(c)};
B.prototype.setItem=function(a,b,c){var d=C.ka(a.split(C.h)[0]);if(d){var e=ra(d);b={key:a,value:b};for(var g=0;g<e.length;g++)if(e[g].key==a){e.splice(g,1);break}e.push(b);sa(this,d,e)}c&&c()};B.prototype.removeItem=function(a,b){for(var c=qa(a),d=0;d<c.length;d++)if(c[d].key==a){c.splice(d,1);break}(a=C.ka(a.split(C.h)[0]))&&sa(this,a,c);b&&b()};
var qa=function(a){return(a=C.ka(a.split(C.h)[0]))?ra(a):[]},ra=function(a){a=v.G(a);return k.cb(a||null)},sa=function(a,b,c){var d=k.fb(c);d.length>a.xb?(c.splice(0,1),0<c.length?sa(a,b,c):p("Failed to write Cookie based cache due to the big size.")):k.Sa(b,d)};k.bb=function(a){try{return atob(a)}catch(b){return a}};k.eb=function(a){try{return btoa(a)}catch(b){return a}};
k.cb=function(a){if(!a)return[];a=k.bb(a);try{return JSON.parse(a).items||[]}catch(b){return p("Error while parsing items from cookie:"+b.message),[]}};k.fb=function(a){return k.eb(JSON.stringify({items:a}))};k.Sa=function(a,b){var c=window.location.hostname,d=window.location.pathname;a=encodeURIComponent(a)+"="+encodeURIComponent(b)+"; domain="+c+";";-1!=navigator.userAgent.toLowerCase().indexOf("msie")||t()||(a+=" path="+d+";");"https:"==window.location.protocol&&(a+=" secure;");v.Kb(a)};
k.Tb=function(a){var b=v.Ja();if(b)for(var b=b.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g,"").split(/\s*(?:\=[^;]*)?;\s*/),c=0;c<b.length;c++){var d=decodeURIComponent(b[c]);0==d.indexOf(a)&&k.Sa(d,"")}};var D=function(a){this.Oa=a;u.call(this,["storageValueChanged"])};r(D,u);var ta=function(a,b){k.La().getItem(a.Oa,b)};D.prototype.addListener=function(a){this.addEventListener("storageValueChanged",a)};
D.prototype.start=function(){var a=this;ta(this,function(b){a.Bb=b;a.Pa=0;a.oa=window.setInterval(ua(a),200)})};D.prototype.stop=function(){void 0!==this.oa&&(clearInterval(this.oa),this.oa=void 0)};
var ua=function(a){return function(){a.Pa++;ta(a,function(b){b!=a.Bb?(a.dispatchEvent({type:"storageValueChanged",key:a.Oa,newValue:b}),a.stop()):1500<=a.Pa&&a.stop()})}},na=function(a){var b=0,c;if(a){var d=0;for(c=a.length;d<c;d++){var e=a.charCodeAt(d);b=(b<<5)-b+e;b|=0}}return b},E=function(a){return!!a&&0<=a.indexOf(C.h)},va=function(a,b){if(!a&&!b)return!0;if(!a||!b)return!1;a=a.extraQueryParams;b=b.extraQueryParams;if(!a&&!b)return!0;if(!a||!b||Object.keys&&Object.keys(a).length!=Object.keys(b).length)return!1;
for(var c in a)if(a[c]!==b[c])return!1;if(!Object.keys)for(c in b)if(a[c]!==b[c])return!1;return!0},C=C||{};C.ga="SID";C.Ea="SSID";C.Ua=100;C.Ga="/oauth2/sessionstate/action/updateState";C.ya="/oauth2/sessionstate/action/checkOrigin";C.Da="/oauth2/permission/action/refresh";C.Ca="/oauth2/permission/action/code";C.fa="/oauth2/permission/action/listSessions";C.Ya="/o/oauth2/revoke";C.h="::";C.ea="_ss_";C.Ba="_tr_";C.S="oauth2_ss";C.za="oauth2_cs";C.Fa="oauth2_tr";C.Wa="oauth2_is";C.R="oauth2_ar";
C.Aa="oauth2c_";C.Va=1500;C.Pb=function(){var a={ea:1,Ba:2,S:3,za:4,Fa:5,R:6},b;for(b in a)if(a=C[b],!a||0<=a.indexOf(C.h))throw"Invalid value for 'oauth2.spi."+b+"'.";};C.Pb();C.Xa=512;C.Za=function(a){var b;(b=void 0===a.hint)||(b=a.hint,b=(""===b?!0:b?"string"==typeof b||"object"==typeof b&&b.constructor===String:!1)&&a.hint.length<=C.Xa);return!a.id&&b};C.ob=function(){return"https:"==window.location.protocol?C.Ea:C.ga};
C.ka=function(a){switch(a){case C.R:return C.Aa+C.R;case C.S:return C.Aa+C.S;default:return null}};var pa=function(){return ma()&&!ia()||t()&&!window.indexedDB?"cookieStorage":t()||ka()?"indexedDb":"localStorage"},oa=function(){return ma()&&!ia()?"inMemoryStorage":"sessionStorage"},v=v||{};v.da="cookieValueChanged";var wa=function(a,b){this.Ia=a;this.tb=b;u.call(this,[v.da])};r(wa,u);wa.prototype.G=function(){return v.G(this.Ia)};var F=function(a){return v.kb(a.Ia)};
wa.prototype.addListener=function(a){this.addEventListener(v.da,a)};
var za=function(a){xa(a);a.$=a.G();a.va=window.setInterval(ya(a),a.tb);p("IDP Session Cookie monitor is started.")},xa=function(a){void 0!==a.va&&(window.clearInterval(a.va),a.va=void 0,p("IDP Session Cookie monitor is stoped."))},ya=function(a){return function(){var b=a.G();if(a.$!=b){var c={type:v.da,newHash:b&&na(b),oldHash:a.$&&na(a.$)};a.$=b;a.dispatchEvent(c)}}},Aa=function(a,b){this.a=a;this.Ta=b},Ba=function(a,b,c){var d=C.Ya,e=new XMLHttpRequest;e.onreadystatechange=function(){if(4==e.readyState&&
200==e.status){var a;e.responseText&&(a=window.JSON.parse(e.responseText));c(a)}};e.open("POST",d,!0);e.setRequestHeader("Content-type","application/x-www-form-urlencoded");var g="xsrfToken=";a.Ta&&(g+=a.Ta);if(b)for(var f in b)f&&b[f]&&(g+="&"+f+"="+encodeURIComponent(b[f]));p("Call "+d+" with postData: "+g);e.send(g)},G=function(a,b,c,d,e){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(4==g.readyState&&200==g.status){var a;g.responseText&&(a=window.JSON.parse(g.responseText));d(a)}};
if(b=ea(b))a+=0>a.indexOf("?")?"?":"&",a+=b;g.open("GET",a,!0);e&&(g.withCredentials=!0);if(c)for(var f in c)if(c.hasOwnProperty(f)){e=c[f];if(null===e||void 0===e)e="";g.setRequestHeader(f,e)}p("Call "+a+" with Get method.");g.send()},Ca=function(a,b,c){G(C.ya,{origin:a.a,client_id:b},null,c,!1)},Da=function(a,b,c){b&&b.length?G(C.Ga,{login_hint:b.join(" "),origin:a.a},null,c,!1):c({activeHints:{}})},Ea=function(a,b,c){b.origin=a.a;delete b.redirect_uri;delete b.app_package_name;G(C.Da,b,null,c,
!1)},Fa=function(a,b,c){b.origin=a.a;delete b.redirect_uri;delete b.app_package_name;delete b.response_type;G(C.Ca,b,null,c,!1)},Ga=function(a,b,c){b.origin=a.a;delete b.redirect_uri;delete b.response_type;delete b.app_package_name;delete b.login_hint;G(C.fa,b,null,c,!1)},Ha=function(a,b,c){Ba(a,{token:b},c)},k=k||{},Ia=function(){};Ia.prototype.v=function(){return!1};var Ja={};
k.Db=function(){var a=new H;if(!a)throw"policy cannot be empty.";if(k.Ma("DEFAULT"))throw"Duplicate policyName [DEFAULT].";Ja.DEFAULT=a};k.Ma=function(a){for(var b in Ja)if(a==b)return!0;return!1};k.Ka=function(a){return a&&k.Ma(a)?a:"DEFAULT"};k.lb=function(a){return Ja[k.Ka(a)]};k.v=function(a,b,c,d){return k.lb(d).v(a,b,c)};k.Sb=function(a,b,c,d){if(!k.v(a,b,c,d))throw"permission_error";};var Ka=function(){};r(Ka,Ia);Ka.prototype.v=function(a,b,c){a=c?this.la(a):this.ma(a);return 0<=q(a,b)};
Ka.prototype.ma=function(a){var b=[];if(a&&(b.push(a),"http://"==a.substring(0,7)||"https://"==a.substring(0,8))){var c=document.createElement("a");c.href=a;a!=c.protocol+"//"+c.hostname&&b.push(c.protocol+"//"+c.hostname);"https:"==c.protocol&&b.push("http://"+c.hostname)}return b};
Ka.prototype.la=function(a){var b=[];if(a){b.push(a);var c=document.createElement("a");c.href=a;if("http:"==c.protocol||"https:"==c.protocol)for(a=c.hostname.split(".");1<a.length;)b.push(c.protocol+"//"+a.join(".")),"https:"==c.protocol&&b.push("http://"+a.join(".")),a.shift()}return b};var H=function(){};r(H,Ia);H.prototype.v=function(a,b,c){a=c?this.la(a):this.ma(a);return 0<=q(a,b)};
H.prototype.ma=function(a){var b=[];if(a&&(b.push(a),"https://"==a.substring(0,8))){var c=document.createElement("a");c.href=a;""!=c.port&&0!=c.port&&443!=c.port||b.push("http://"+c.hostname)}return b};
H.prototype.la=function(a){var b=[];if(a){var c=document.createElement("a");c.href=a;if("https:"==c.protocol&&(""==c.port||0==c.port||443==c.port)||"http:"==c.protocol&&(""==c.port||0==c.port||80==c.port))for(a=c.hostname.split(".");1<a.length;)b.push(c.protocol+"//"+a.join(".")),"https:"==c.protocol&&b.push("http://"+a.join(".")),a.shift();else b.push(a)}return b};k.Db();var I=function(){};I.prototype.qa=function(){return!0};var J=function(a){return a.qa()?k.qb():k.La()};
I.prototype.g=function(){throw Error("unimplemented abstract method");};I.prototype.F=function(){throw Error("unimplemented abstract method");};I.prototype.j=function(){throw Error("unimplemented abstract method");};I.prototype.i=function(){throw Error("unimplemented abstract method");};var K=function(){};r(K,I);
K.prototype.j=function(a,b,c){var d=this,e=this.g(a);J(this).getItem(e,function(a){if(a)try{var f=window.JSON.parse(a);if(f.cookieHash!=b){J(d).removeItem(e,function(){c(void 0)});return}var g=f&&f.cachedValue}catch(l){}c(g)})};K.prototype.i=function(a,b,c,d){a=this.g(a);void 0===b||null===b?J(this).removeItem(a,d):(b=JSON.stringify({cookieHash:c,cachedValue:b}),J(this).setItem(a,b,d))};var L=function(){};r(L,I);
L.prototype.j=function(a,b,c){J(this).getItem(this.g(a),function(a){if(a)try{var b=window.JSON.parse(a);var d=b&&b.cachedValue}catch(f){}c(d)})};L.prototype.i=function(a,b,c,d){a=this.g(a);void 0===b||null===b?J(this).removeItem(a,d):(b=JSON.stringify({cachedValue:b}),J(this).setItem(a,b,d))};var M=function(){};r(M,L);M.prototype.qa=function(){return!1};M.prototype.g=function(a){return[C.R,a.origin,a.clientId,a.id].join(C.h)};
M.prototype.F=function(a){var b={};a&&(a=a.split(C.h),4==a.length&&(b.origin=a[1],b.clientId=a[2],b.id=a[3]));return b};var La=function(){};r(La,K);La.prototype.g=function(a){return[C.za,a.origin,a.clientId].join(C.h)};La.prototype.F=function(a){a=a.split(C.h);var b={};3==a.length&&(b.origin=a[1],b.clientId=a[2]);return b};var N=function(){};r(N,K);N.prototype.g=function(a){return[C.Wa,a.origin,a.clientId].join(C.h)};
N.prototype.j=function(a,b,c){var d=this;K.prototype.j.call(this,a,b,function(b){b&&b.expires_at?6E4>b.expires_at-(new Date).getTime()?J(d).removeItem(d.g(a),c):ha(b.scope,a.scope)&&ha(a.scope,b.scope)?(b.expires_in=Math.floor((b.expires_at-(new Date).getTime())/1E3),c&&c(b)):J(d).removeItem(d.g(a),c):c&&c(void 0)})};N.prototype.i=function(a,b,c,d){var e;b&&b.expires_at&&18E4<b.expires_at-(new Date).getTime()&&(e=b);K.prototype.i.call(this,a,e,c,d)};var O=function(){};r(O,L);O.prototype.qa=function(){return!1};
O.prototype.g=function(a){return[C.S,a.domain,a.U?"1":"0",k.Ka(a.H),a.id||C.ea].join(C.h)};O.prototype.F=function(a){a=a.split(C.h);var b={};5==a.length&&(b.domain=a[1],b.U="1"==a[2],b.H=a[3],b.id=a[4]);"DEFAULT"==b.H&&delete b.H;b.id==C.ea&&delete b.id;return b};var P=function(a){this.Ab=a||C.Fa};r(P,K);P.prototype.g=function(a){return[this.Ab,a.origin,a.clientId,a.id||C.Ba].join(C.h)};
P.prototype.j=function(a,b,c){var d=this;K.prototype.j.call(this,a,b,function(b){b&&b.O&&b.O.expires_at?a.wb!=b.O.login_hint?J(d).removeItem(d.g(a),c):6E4>b.O.expires_at-(new Date).getTime()?J(d).removeItem(d.g(a),c):ha(b.O.scope,a.scope)?ha(b.responseType,a.responseType)?(b=b.O,b.expires_in=Math.floor((b.expires_at-(new Date).getTime())/1E3),c&&c(b)):J(d).removeItem(d.g(a),c):J(d).removeItem(d.g(a),c):c&&c(void 0)})};
P.prototype.i=function(a,b,c,d){var e;b&&b.expires_at&&18E4<b.expires_at-(new Date).getTime()&&(e={O:b,responseType:a.responseType});K.prototype.i.call(this,a,e,c,d)};var Ma=function(a,b){this.a=a;this.sa=b;this.X={};this.W={}},Na=function(a,b){if(!b)throw"message object cannot be null.";b.rpcToken=a.sa;b=JSON.stringify(b);p("IDP IFrame sends message: "+b);window.parent.postMessage(b,a.a)},Q=function(a,b,c){b&&Na(a,{id:b,result:c})};
Ma.prototype.Cb=function(a){if(a.source==window.parent&&a.origin==this.a){p("IDP Session State IFrame receive message:"+a.data);try{var b=window.JSON.parse(a.data)}catch(c){return}(b.rpcToken||this.sa)&&b.rpcToken!=this.sa?p("RPC token mismatch."):b&&b.method&&this.X[b.method]?(a=this.X[b.method],a.rpcIdRequired&&!b.id?p("Bad request."):a.validator&&!a.validator(b)?(p("Bad request."),Na(this,{id:b.id,error:"bad_request"})):a.handler(b)):p("Bad request.")}};
var R=function(a,b){if(b&&b.type&&a.W[b.type]){var c=a.W[b.type].filter;c&&!c(b)||Na(a,{method:"fireIdpEvent",params:b})}else p("Invalid event type.")},Oa=function(a,b){a.X={};a.W={};if(b){if(b.rpcs)for(var c=0;c<b.rpcs.length;c++){var d=b.rpcs[c];if(!d.method||!d.handler)throw"Error in RPC policy: method or handler is empty.";if(a.X[d.method])throw"Error in RPC policy: duplicate entry for RPC '"+d.method+"'.";a.X[d.method]={handler:d.handler,rpcIdRequired:d.rpcIdRequired,validator:d.validator}}if(b.events)for(c=
0;c<b.events.length;c++){d=b.events[c];if(!d.type)throw"Error in Event policy: type is empty.";if(a.W[d.type])throw"Error in Event policy: duplicate entry for type '"+d.type+"'.";a.W[d.type]={filter:d.filter}}}},Pa=function(a,b,c,d){R(a,{type:"sessionStateChanged",clientId:b,user:c,sessionState:d})},Qa=function(a){var b=new O,c=C.S+C.h;return function(d){if(d.key&&0===d.key.indexOf(c)){var e=b.F(d.key);if(k.v(a.a,e.domain,e.U,e.H)){var g;if(d.newValue)try{var f=JSON.parse(d.newValue);f&&(g=f.cachedValue)}catch(m){return}R(a,
{type:"sessionSelectorChanged",newValue:g,crossSubDomains:e.U,domain:e.domain,policy:e.H,id:e.id})}}}},Ra=function(a){var b=new M,c=[C.R,a.a].join(C.h)+C.h;return function(d){if(!d.key&&ja()){var e=null,g=[];for(d=0;d<window.localStorage.length;d++){var f=window.localStorage.key(d);if(0===f.indexOf(c))if(e)g.push(f);else{var m=window.localStorage.getItem(f);g.push(f);if(m){try{var l=window.JSON.parse(m)}catch(x){continue}l&&l.cachedValue&&(e=b.F(f),e={type:"authResult",clientId:e.clientId,id:e.id,
authResult:l.cachedValue})}}}for(d=0;d<g.length;d++)window.localStorage.removeItem(g[d]);(l=e)&&R(a,l)}else if(d.key&&0===d.key.indexOf(c)&&d.newValue){try{g=window.JSON.parse(d.newValue)}catch(x){return}g&&g.cachedValue&&(l=b.F(d.key),l={type:"authResult",clientId:l.clientId,id:l.id,authResult:g.cachedValue},R(a,l))}}},Sa=function(a,b){this.a=a;this.s=b;this.Ha=new La;this.Qa=new O;this.wa=new P;this.L=new N},Ta=function(a,b,c,d,e){a.Ha.i({origin:a.a,clientId:b},{user:c.B,session:c.B?c.I:void 0},
d,e)},Ua=function(a,b,c){a.Ha.j({origin:a.a,clientId:b},F(a.s),c)},Va=function(a,b,c,d,e,g,f){a.wa.j({wb:b,origin:a.a,clientId:c,responseType:d,scope:e,id:g},F(a.s),f)},Wa=function(a,b,c,d,e,g,f){a.wa.i({origin:a.a,clientId:c,responseType:d,id:g},e,b,f)},Xa=function(a,b,c){var d=a.wa;a={origin:a.a,clientId:b};J(d).removeItem(d.g(a),c)},Ya=function(a,b,c,d,e,g){if(!a.v(b,c,e))throw"Permission denied for '"+a.a+"' to read session selector for domain '"+b+"'.";a.Qa.j({domain:b,U:c,H:e,id:d},void 0,function(a){g&&
g(a)})},Za=function(a,b,c,d,e,g,f){if(!a.v(b,c,g))throw"Permission denied for '"+a.a+"' to write session selector for domain '"+b+"'.";a.Qa.i({domain:b,U:c,H:g,id:e},d,void 0,f)};Sa.prototype.v=function(a,b,c){return k.v(this.a,a,b,c)};
var $a=function(a,b,c,d){a.L.j({origin:a.a,clientId:b,scope:c},F(a.s),d)},ab=function(a,b,c,d,e){a.L.i({origin:a.a,clientId:c},d,b,e)},bb=function(a,b,c){this.K=a;this.b=b;this.f=c},cb=function(a,b,c){a.B?c&&void 0!==c[a.B]?(c=c[a.B],va(a.I,c)||(a.I=c,Ta(a.f,a.K,a,b,function(){Pa(a.b,a.K,a.B,a.I)}))):a.I&&(a.I=void 0,Ta(a.f,a.K,a,b,function(){Pa(a.b,a.K,a.B,void 0)})):b&&Pa(a.b,a.K,a.B,void 0)},eb=function(a,b,c,d){this.s=a;this.b=b;this.c=c;this.f=d;this.V=void 0;this.u={};this.ta=[];var e=this;
this.s.addListener(function(a){db(e,a)})},fb=function(a){var b=[],c;for(c in a.u){var d=a.u[c].B;d&&b.push(d)}return b},db=function(a,b){if(b.newHash)Da(a.c,fb(a),function(c){for(var d in a.u)cb(a.u[d],b.newHash,c&&c.activeHints)});else for(var c in a.u)cb(a.u[c],b.newHash,void 0)},gb=function(a,b,c,d,e){var g=a.u[b];g||(g=new bb(b,a.b,a.f),a.u[b]=g);a=g;b=c.login_hint;c=c.session_state;a.B!=b?(a.B=b,a.I=b?c:void 0,Ta(a.f,a.K,a,d,e)):e&&e()},hb=function(a,b,c){var d=a.u[b];d?c(!0):Ua(a.f,b,function(e){e?
(d=new bb(b,a.b,a.f),a.u[b]=d,d.B=e.user,d.I=e.session,c(!0)):Ca(a.c,b,function(d){d&&d.valid?(d=new bb(b,a.b,a.f),a.u[b]=d,Ta(a.f,b,d,F(a.s),function(){c(!0)})):c(!1)})})},ib=function(a,b){t()||ka()||la()?a.ta.push(b):ga(ja()?document:window,"storage",b)},S=function(a,b,c){this.a=a;this.b=new Ma(a,b);this.s=new wa(C.ga,C.Ua);this.c=new Aa(a,c);this.f=new Sa(a,this.s);this.C=new eb(this.s,this.b,this.c,this.f)};h=S.prototype;
h.start=function(){var a=this,b=function(){a.b.Cb.apply(a.b,arguments)},c=function(){R(a.b,{type:"idpReady"});p("Initialize IDP IFrame successfully.")},d=function(c){var d=window;if(d.removeEventListener)d.removeEventListener("message",b,!1);else if(d.detachEvent)d.detachEvent("onmessage",b);else throw"Remove event handler for message failed.";xa(a.s);R(a.b,{type:"idpError",error:c.message})};try{Oa(this.b,this.ha()),ga(window,"message",b),ib(this.C,Qa(this.b)),ib(this.C,Ra(this.b)),za(this.s),k.sb(c,
d)}catch(e){d(e)}};h.yb=function(a){var b=this;hb(this.C,(a.params||{}).clientId,function(c){Q(b.b,a.id,c)})};
h.hb=function(a){var b=a.params||{},c=this,d=function(b){Q(c.b,a.id,b)},e=b.clientId,g=b.loginHint,f=b.request,m=b.sessionSelector;f.client_id=e;f.login_hint=g;f.ss_domain=m.domain;var l=F(this.s);if(l){var x=function(a){a&&!a.error&&a.login_hint?(a.first_issued_at=(new Date).getTime(),a.expires_at=a.first_issued_at+1E3*a.expires_in,a.session_state||(a.session_state={}),a.scope||(a.scope=f.scope),b.skipCache?gb(c.C,e,a,l,function(){d(a)}):Wa(c.f,l,e,f.response_type,a,b.id,function(){gb(c.C,e,a,l,
function(){d(a)})})):(a=a||{},d(a))};b.forceRefresh?Ea(this.c,f,x):Va(this.f,g,e,f.response_type,f.scope,b.id,function(a){a&&18E4<a.expires_at-(new Date).getTime()?gb(c.C,e,a,l,function(){d(a)}):Ea(c.c,f,x)})}else Q(c.b,a.id,{error:"user_logged_out"})};h.mb=function(a){var b=this,c=function(c){Q(b.b,a.id,c)};if(F(this.s)){var d=a.params||{},e=d.request,g=d.sessionSelector;e.client_id=d.clientId;e.login_hint=d.loginHint;e.ss_domain=g.domain;Fa(this.c,e,c)}else c({error:"user_logged_out"})};
h.Eb=function(a){var b=a.params||{},c=b.clientId,d=this;Ha(this.c,b.token,function(b){Xa(d.f,c,function(){Q(d.b,a.id,b)})})};h.Nb=function(a){if(t()||ka()||la()){var b=a.params||{},c=(new M).g({clientId:b.clientId,id:b.id,origin:b.origin}),b=this.C;if(t()||ka()||la()){b.V&&b.V.stop();b.V=new D(c);for(c=0;c<b.ta.length;c++)b.V.addListener(b.ta[c]);b.V.start()}}Q(this.b,a.id,!0)};h.gb=function(a){var b=this,c=a.params||{};Ya(this.f,c.domain,c.crossSubDomains,c.id,c.policy,function(c){Q(b.b,a.id,c)})};
h.Lb=function(a){var b=a.params||{},c=b.hint,d=!!b.disabled,e=b.domain,g=b.crossSubDomains,f=b.id,m=b.policy,l=this;if(c||d)var x={hint:c,disabled:d};Za(this.f,e,g,x,f,m,function(){R(l.b,{type:"sessionSelectorChanged",newValue:x,domain:e,crossSubDomains:g,id:f,policy:m});Q(l.b,a.id,!0)})};
h.ub=function(a){var b=a.params||{},c=this,d=function(b){Q(c.b,a.id,b)},e=b.clientId,g=b.request,f=b.sessionSelector;g.client_id=e;g.response_type="id_token";g.ss_domain=f.domain;var m=F(this.s);if(m){var l=function(a){a&&!a.error?(a.first_issued_at=(new Date).getTime(),a.expires_at=a.first_issued_at+1E3*a.expires_in,a.scope=g.scope,ab(c.f,m,e,a,function(){d(a)})):(a=a||{error:"No response returned from Server."},d(a))};b.forceRefresh?Ga(this.c,g,l):$a(this.f,e,g.scope,function(a){a?d(a):Ga(c.c,g,
l)})}else d({scope:g.scope,sessions:[]})};h.zb=function(a){a=a&&a.params||{};return a.clientId&&!E(a.clientId)};h.rb=function(a){var b=a&&a.params||{};a=b.loginHint;var c=!E(b.id),d=b.clientId&&!E(b.clientId),e=!!b.request,g=e&&b.request.scope;(b=(e=e&&b.request.response_type)&&0<=b.request.response_type.indexOf("code"))&&p("Bad request: 'code' response_type is not supported.");return a&&c&&d&&g&&e&&!b};
h.nb=function(a){a=a&&a.params||{};var b=!E(a.id),c=a.clientId&&!E(a.clientId),d=!!a.request&&a.request.scope;return a.loginHint&&b&&c&&d};h.pb=function(a){a=a&&a.params||{};var b=a.domain&&!E(a.domain),c=!E(a.policy);return!E(a.id)&&b&&c&&this.f.v(a.domain,!!a.crossSubDomains,a.policy)};h.Mb=function(a){a=a&&a.params||{};var b=a.domain&&!E(a.domain),c=!E(a.policy);return!E(a.id)&&b&&c&&this.f.v(a.domain,!!a.crossSubDomains,a.policy)&&C.Za(a)};
h.vb=function(a){a=a&&a.params||{};var b=a.clientId&&!E(a.clientId),c=!!a.request&&a.request.scope;return!E(a.id)&&b&&c};h.Hb=function(a){a=a&&a.params||{};var b=!!a.token,c=a.clientId&&!E(a.clientId);return!E(a.id)&&b&&c};h.Ob=function(a){a=a&&a.params||{};var b=a.origin&&!E(a.origin),c=a.id&&!E(a.id);return a.clientId&&!E(a.clientId)&&b&&c};h.Jb=function(a){var b;if(b=a.clientId)a=a.clientId,b=!(!a||!this.C.u[a]);return b};
h.$a=function(a){var b;if(b=a.clientId)b=a.clientId,b=!(!b||!this.C.u[b]);return b&&a.id&&a.authResult};h.Ib=function(a){return a.domain&&this.f.v(a.domain,a.crossSubDomains,a.policy)};var T=function(a,b){return function(){return b.apply(a,arguments)}};S.prototype.ha=function(){var a={rpcs:[],events:[]};jb(this,a);return a};
var jb=function(a,b){b.rpcs.push({method:"monitorClient",handler:T(a,a.yb),rpcIdRequired:!1,validator:T(a,a.zb)});b.rpcs.push({method:"getTokenResponse",handler:T(a,a.hb),rpcIdRequired:!0,validator:T(a,a.rb)});b.rpcs.push({method:"getOnlineCode",handler:T(a,a.mb),rpcIdRequired:!0,validator:T(a,a.nb)});b.rpcs.push({method:"getSessionSelector",handler:T(a,a.gb),rpcIdRequired:!0,validator:T(a,a.pb)});b.rpcs.push({method:"setSessionSelector",handler:T(a,a.Lb),rpcIdRequired:!1,validator:T(a,a.Mb)});b.rpcs.push({method:"listIdpSessions",
handler:T(a,a.ub),rpcIdRequired:!0,validator:T(a,a.vb)});b.rpcs.push({method:"revoke",handler:T(a,a.Eb),validator:T(a,a.Hb)});b.rpcs.push({method:"startPolling",handler:T(a,a.Nb),validator:T(a,a.Ob)});b.events.push({type:"idpReady"});b.events.push({type:"idpError"});b.events.push({type:"sessionStateChanged",filter:T(a,a.Jb)});b.events.push({type:"sessionSelectorChanged",filter:T(a,a.Ib)});b.events.push({type:"authResult",filter:T(a,a.$a)})};var kb=function(a){if(Error.captureStackTrace)Error.captureStackTrace(this,kb);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))};ba(kb,Error);var lb=function(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")};var mb=function(a,b){b.unshift(a);kb.call(this,lb.apply(null,b));b.shift()};ba(mb,kb);var nb=function(a,b,c){if(!a){var d="Assertion failed";if(b){d+=": "+b;var e=Array.prototype.slice.call(arguments,2)}throw new mb(""+d,e||[]);}};var ob=function(a){for(var b=[],c=0,d=0;d<a.length;d++){for(var e=a.charCodeAt(d);255<e;)b[c++]=e&255,e>>=8;b[c++]=e}return b};var pb=null;var qb=function(){this.m=-1};var U=function(a,b,c){this.m=-1;this.w=a;this.m=c||a.m||16;this.Na=Array(this.m);this.ra=Array(this.m);a=b;a.length>this.m&&(this.w.update(a),a=this.w.digest(),this.w.reset());for(c=0;c<this.m;c++)b=c<a.length?a[c]:0,this.Na[c]=b^92,this.ra[c]=b^54;this.w.update(this.ra)};ba(U,qb);U.prototype.reset=function(){this.w.reset();this.w.update(this.ra)};U.prototype.update=function(a,b){this.w.update(a,b)};
U.prototype.digest=function(){var a=this.w.digest();this.w.reset();this.w.update(this.Na);this.w.update(a);return this.w.digest()};var rb=function(){this.m=64;this.l=Array(4);this.ab=Array(this.m);this.ca=this.T=0;this.reset()};ba(rb,qb);rb.prototype.reset=function(){this.l[0]=1732584193;this.l[1]=4023233417;this.l[2]=2562383102;this.l[3]=271733878;this.ca=this.T=0};
var sb=function(a,b,c){c||(c=0);var d=Array(16);if("string"==typeof b)for(var e=0;16>e;++e)d[e]=b.charCodeAt(c++)|b.charCodeAt(c++)<<8|b.charCodeAt(c++)<<16|b.charCodeAt(c++)<<24;else for(e=0;16>e;++e)d[e]=b[c++]|b[c++]<<8|b[c++]<<16|b[c++]<<24;b=a.l[0];c=a.l[1];var e=a.l[2],g=a.l[3];var f=b+(g^c&(e^g))+d[0]+3614090360&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[1]+3905402710&4294967295;g=b+(f<<12&4294967295|f>>>20);f=e+(c^g&(b^c))+d[2]+606105819&4294967295;e=g+(f<<17&4294967295|f>>>
15);f=c+(b^e&(g^b))+d[3]+3250441966&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(g^c&(e^g))+d[4]+4118548399&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[5]+1200080426&4294967295;g=b+(f<<12&4294967295|f>>>20);f=e+(c^g&(b^c))+d[6]+2821735955&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e&(g^b))+d[7]+4249261313&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(g^c&(e^g))+d[8]+1770035416&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[9]+2336552879&4294967295;g=b+(f<<12&4294967295|
f>>>20);f=e+(c^g&(b^c))+d[10]+4294925233&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e&(g^b))+d[11]+2304563134&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(g^c&(e^g))+d[12]+1804603682&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[13]+4254626195&4294967295;g=b+(f<<12&4294967295|f>>>20);f=e+(c^g&(b^c))+d[14]+2792965006&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e&(g^b))+d[15]+1236535329&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(e^g&(c^e))+d[1]+4129170786&4294967295;b=c+(f<<
5&4294967295|f>>>27);f=g+(c^e&(b^c))+d[6]+3225465664&4294967295;g=b+(f<<9&4294967295|f>>>23);f=e+(b^c&(g^b))+d[11]+643717713&4294967295;e=g+(f<<14&4294967295|f>>>18);f=c+(g^b&(e^g))+d[0]+3921069994&4294967295;c=e+(f<<20&4294967295|f>>>12);f=b+(e^g&(c^e))+d[5]+3593408605&4294967295;b=c+(f<<5&4294967295|f>>>27);f=g+(c^e&(b^c))+d[10]+38016083&4294967295;g=b+(f<<9&4294967295|f>>>23);f=e+(b^c&(g^b))+d[15]+3634488961&4294967295;e=g+(f<<14&4294967295|f>>>18);f=c+(g^b&(e^g))+d[4]+3889429448&4294967295;c=
e+(f<<20&4294967295|f>>>12);f=b+(e^g&(c^e))+d[9]+568446438&4294967295;b=c+(f<<5&4294967295|f>>>27);f=g+(c^e&(b^c))+d[14]+3275163606&4294967295;g=b+(f<<9&4294967295|f>>>23);f=e+(b^c&(g^b))+d[3]+4107603335&4294967295;e=g+(f<<14&4294967295|f>>>18);f=c+(g^b&(e^g))+d[8]+1163531501&4294967295;c=e+(f<<20&4294967295|f>>>12);f=b+(e^g&(c^e))+d[13]+2850285829&4294967295;b=c+(f<<5&4294967295|f>>>27);f=g+(c^e&(b^c))+d[2]+4243563512&4294967295;g=b+(f<<9&4294967295|f>>>23);f=e+(b^c&(g^b))+d[7]+1735328473&4294967295;
e=g+(f<<14&4294967295|f>>>18);f=c+(g^b&(e^g))+d[12]+2368359562&4294967295;c=e+(f<<20&4294967295|f>>>12);f=b+(c^e^g)+d[5]+4294588738&4294967295;b=c+(f<<4&4294967295|f>>>28);f=g+(b^c^e)+d[8]+2272392833&4294967295;g=b+(f<<11&4294967295|f>>>21);f=e+(g^b^c)+d[11]+1839030562&4294967295;e=g+(f<<16&4294967295|f>>>16);f=c+(e^g^b)+d[14]+4259657740&4294967295;c=e+(f<<23&4294967295|f>>>9);f=b+(c^e^g)+d[1]+2763975236&4294967295;b=c+(f<<4&4294967295|f>>>28);f=g+(b^c^e)+d[4]+1272893353&4294967295;g=b+(f<<11&4294967295|
f>>>21);f=e+(g^b^c)+d[7]+4139469664&4294967295;e=g+(f<<16&4294967295|f>>>16);f=c+(e^g^b)+d[10]+3200236656&4294967295;c=e+(f<<23&4294967295|f>>>9);f=b+(c^e^g)+d[13]+681279174&4294967295;b=c+(f<<4&4294967295|f>>>28);f=g+(b^c^e)+d[0]+3936430074&4294967295;g=b+(f<<11&4294967295|f>>>21);f=e+(g^b^c)+d[3]+3572445317&4294967295;e=g+(f<<16&4294967295|f>>>16);f=c+(e^g^b)+d[6]+76029189&4294967295;c=e+(f<<23&4294967295|f>>>9);f=b+(c^e^g)+d[9]+3654602809&4294967295;b=c+(f<<4&4294967295|f>>>28);f=g+(b^c^e)+d[12]+
3873151461&4294967295;g=b+(f<<11&4294967295|f>>>21);f=e+(g^b^c)+d[15]+530742520&4294967295;e=g+(f<<16&4294967295|f>>>16);f=c+(e^g^b)+d[2]+3299628645&4294967295;c=e+(f<<23&4294967295|f>>>9);f=b+(e^(c|~g))+d[0]+4096336452&4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[7]+1126891415&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[14]+2878612391&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[5]+4237533241&4294967295;c=e+(f<<21&4294967295|f>>>11);f=b+(e^(c|~g))+d[12]+1700485571&
4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[3]+2399980690&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[10]+4293915773&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[1]+2240044497&4294967295;c=e+(f<<21&4294967295|f>>>11);f=b+(e^(c|~g))+d[8]+1873313359&4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[15]+4264355552&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[6]+2734768916&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[13]+1309151649&
4294967295;c=e+(f<<21&4294967295|f>>>11);f=b+(e^(c|~g))+d[4]+4149444226&4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[11]+3174756917&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[2]+718787259&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[9]+3951481745&4294967295;a.l[0]=a.l[0]+b&4294967295;a.l[1]=a.l[1]+(e+(f<<21&4294967295|f>>>11))&4294967295;a.l[2]=a.l[2]+e&4294967295;a.l[3]=a.l[3]+g&4294967295};
rb.prototype.update=function(a,b){void 0===b&&(b=a.length);for(var c=b-this.m,d=this.ab,e=this.T,g=0;g<b;){if(0==e)for(;g<=c;)sb(this,a,g),g+=this.m;if("string"==typeof a)for(;g<b;){if(d[e++]=a.charCodeAt(g++),e==this.m){sb(this,d);e=0;break}}else for(;g<b;)if(d[e++]=a[g++],e==this.m){sb(this,d);e=0;break}}this.T=e;this.ca+=b};
rb.prototype.digest=function(){var a=Array((56>this.T?this.m:2*this.m)-this.T);a[0]=128;for(var b=1;b<a.length-8;++b)a[b]=0;for(var c=8*this.ca,b=a.length-8;b<a.length;++b)a[b]=c&255,c/=256;this.update(a);a=Array(16);for(b=c=0;4>b;++b)for(var d=0;32>d;d+=8)a[c++]=this.l[b]>>>d&255;return a};var tb=function(a,b){for(var c=0;c<a.length;c++)for(var d=0;d<b.length;d++)if(a[c]&&b[d]&&a[c].toLowerCase()===b[d].toLowerCase())return!0;return!1};var vb=function(a,b,c){b.origin=a.a;b.privileged=!0;b.redirect_uri=void 0;b.response_type=void 0;G(C.fa,b,ub(a),c,!1)},wb=function(a,b,c,d){G((window.NOW_SERVER_BASE_URL||"https://clients1.google.com")+"/nowapi/webauth",{origin:a.a,client_id:b,user_ids:c.join(";")},ub(a),d,!0)},xb=function(a,b,c){G("/o/oauth2/auth",{origin:a.a,client_id:b.client_id,login_hint:b.login_hint,response_type:"code",access_type:"offline",scope:"https://www.googleapis.com/auth/googlenow.publish",redirect_uri:"xhr",timestamp:b.timestamp,
signature:b.signature,signed_by:"google_now"},ub(a),c,!1)},V=function(a,b,c){G((window.NOW_SERVER_BASE_URL||"https://clients1.google.com")+"/nowapi/webAuthApiAnalytics",{origin:a.a,client_id:b,status:c},ub(a),function(){},!0)},ub=function(a){var b={},c=v.G(C.ob());if(c){a=a.a;if(!a||!c)throw Error("RP origin and session cookie value cannot be empty.");c=new U(new rb,ob(c));a=ob(a);c.reset();c.update(a);c=c.digest();a=aa(c);nb("array"==a||"object"==a&&"number"==typeof c.length,"encodeByteArray takes an array as a parameter");
if(!pb)for(pb={},a=0;65>a;a++)pb[a]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(a);a=pb;for(var d=[],e=0;e<c.length;e+=3){var g=c[e],f=e+1<c.length,m=f?c[e+1]:0,l=e+2<c.length,x=l?c[e+2]:0,Bb=g>>2,g=(g&3)<<4|m>>4,m=(m&15)<<2|x>>6,x=x&63;l||(x=64,f||(m=64));d.push(a[Bb],a[g],a[m],a[x])}b["X-Csrf-Token"]=d.join("")}return b};var W=function(){};r(W,L);W.prototype.g=function(a){return["now_as",a.P,a.clientId||"ALL_CLIENTS"].join(C.h)};W.prototype.F=function(a){var b={};if(a){a=a.split(C.h);if("now_as"!==a[0]||3!=a.length)throw Error("Invalid assertion cache key.");b.P=a[1];b.clientId="ALL_CLIENTS"==a[2]?void 0:a[2]}return b};W.prototype.j=function(a,b,c){var d=this;L.prototype.j.call(this,a,b,function(b){b&&b.e?b.e<(new Date).getTime()?J(d).removeItem(d.g(a),c):c&&c(b.o):c&&c(void 0)})};
W.prototype.i=function(a,b,c,d){if(void 0!==b){var e=!!b;if(e&&!a.clientId)throw Error("Cannot cache all clients enabled for a user.");b={};b.o=e;b.e=(new Date).getTime()+864E5}L.prototype.i.call(this,a,b,c,d)};var yb=function(a,b,c,d){var e={P:b,clientId:c};a.j({P:b},void 0,function(b){!1===b?d(!1):a.j(e,void 0,d)})},zb=function(a,b,c,d){a.i({P:b},void 0,void 0,function(){a.i({P:b,clientId:c},!0,void 0,d)})},Ab=function(a,b,c,d,e){a.i({P:b,clientId:d?void 0:c},!1,void 0,e)};var Cb=function(){};r(Cb,K);Cb.prototype.g=function(a){return["now_gs",a.origin,a.clientId].join(C.h)};Cb.prototype.j=function(a,b,c){var d=this;K.prototype.j.call(this,a,b,function(b){if(b&&b.expires_at)if(b.expires_at<=(new Date).getTime())J(d).removeItem(d.g(a),function(){c&&c(e)});else{b.expires_at=void 0;var e=b}c&&c(e)})};Cb.prototype.i=function(a,b,c,d){b&&(b.expires_at=(new Date).getTime()+864E5);K.prototype.i.call(this,a,b,c,d)};S.prototype.ib=function(a){var b=this;if(!Db(this,"getCode",a.id)){var c=Eb(this,a);if(3<c.ja.length)X(c,"THROTTLED","At most 3 email addresses can be used."),V(this.c,c.clientId,1);else if(c.Y){var d=function(a){a.length?Fb(b,c,a,function(a){Gb(b,c,a.auth_request)}):(X(c,"DISABLED"),V(b.c,c.clientId,4))},e=function(a){"AUTH_EXISTS"==a.message&&(X(c,"AUTHORIZATION_EXISTS","Authorization already granted for the user."),V(b.c,c.clientId,3))};Hb(this,c,!1,function(a){Ib(b,c,a,void 0,d,e)})}else X(c,
"DISABLED"),V(this.c,c.clientId,2)}};S.prototype.Fb=function(a){var b=this;if(!Db(this,"revokeNow",a.id)){var c=Eb(this,a);3<c.ja.length&&X(c,"THROTTLED","At most 3 email addresses can be used.");if(c.Y){var d=function(a){if(a.length)for(var d=a.length,e=0;e<a.length;e++)Jb(b,c.clientId,a[e],function(a){(a=a&&a.access_token)?Ha(b.c,a,function(){d--;d||c.N({})}):(d--,d||c.N({}))});else c.N({})},e=function(){};Hb(this,c,!0,function(a){Ib(b,c,a,!0,d,e)})}else c.N({})}};
var Db=function(a,b,c){a.pa=a.pa||{};if(!a.pa[b])return a.pa[b]=!0,!1;Q(a.b,c,{error:"THROTTLED",detail:"The "+b+"() method has already been invoked."});return!0},Eb=function(a,b){var c=b.params||{},d={clientId:c.clientId,ja:c.emails,N:function(c){Q(a.b,b.id,c)}};d.Y=F(a.s);d.Ra={origin:a.a,clientId:c.clientId};return d},Hb=function(a,b,c,d){a.L||(a.L=new Cb);var e=function(c){c&&c.sessions?a.L.i(b.Ra,c,b.Y,function(){d(c)}):X(b,"OTHER","Failed to get Google session information.")},g={client_id:b.clientId,
scope:"https://www.googleapis.com/auth/googlenow.publish"};c?vb(a.c,g,e):a.L.j(b.Ra,b.Y,function(b){b?d(b):vb(a.c,g,e)})},Ib=function(a,b,c,d,e,g){a.J||(a.J=new W);var f=function(a){e&&e(a)},m=function(){var a=Error("AUTH_EXISTS");g&&g(a)};if(c.sessions&&c.sessions.length){var l=function(c,e){if(0==c.length)f(e);else{var g=c.shift();g.emails&&tb(b.ja,g.emails)?d&&g.login_hint?(e.push(g.login_hint),l(c,e)):d?l(c,e):g.login_hint?m():g.obfuscatedGaiaId?yb(a.J,g.obfuscatedGaiaId,b.clientId,function(a){a?
m():(void 0===a&&e.push(g.obfuscatedGaiaId),l(c,e))}):l(c,e):l(c,e)}};l(c.sessions.slice(0),[])}else f([])},Fb=function(a,b,c,d){a.J||(a.J=new W);wb(a.c,b.clientId,c,function(e){if(e&&"DISABLED"!=e.status)"THROTTLED"==e.status?(X(b,"THROTTLED","Throttled by Google Now server."),V(a.c,b.clientId,7)):"OK"==e.status&&Kb(a,b,e,c)?zb(a.J,e.auth_request.login_hint,b.clientId,function(){d(e)}):(X(b,"OTHER","Unexpected response from Google Now server."),V(a.c,b.clientId,8));else{var g=!1,f=!1;if(e.users&&
e.users.length){var m=function(c,d){if(0==c.length)d();else{var e=c.shift();e.user_id?Ab(a.J,e.user_id,b.clientId,e.disabled_for_all_clients,function(){e.disabled_for_all_clients?f=!0:g=!0;m(c,d)}):m(c,d)}};m(e.users.slice(0),function(){X(b,"DISABLED");V(a.c,b.clientId,f&&!g?5:6)})}else X(b,"DISABLED"),V(a.c,b.clientId,f&&!g?5:6)}})},Kb=function(a,b,c,d){c=c.auth_request;return!!c&&c.origin==a.a&&c.client_id==b.clientId&&0<c.timestamp&&!!c.signature&&"google_now"==c.signed_by&&0<=q(d,c.login_hint)},
Gb=function(a,b,c){xb(a.c,c,function(c){c&&c.code?(b.N({code:c.code}),V(a.c,b.clientId,9)):c&&"immediate_failed"==c.error&&"policy_enforced"==c.error_subtype?(X(b,"AUTHORIZATION_EXISTS","Failed to issue code due to existing authorization."),V(a.c,b.clientId,10)):(X(b,"OTHER",c.error||"Failed to get code."),V(a.c,b.clientId,11))})},Jb=function(a,b,c,d){Ea(a.c,{client_id:b,login_hint:c,response_type:"token",scope:"https://www.googleapis.com/auth/googlenow.publish"},d)},X=function(a,b,c){a.N({error:b,
detail:c})};S.prototype.jb=function(a){a=a&&a.params||{};var b=a.emails,b=b&&b.length&&"[object Array]"===Object.prototype.toString.call(b);return a.clientId&&!E(a.clientId)&&b};S.prototype.Gb=function(a){a=a&&a.params||{};var b=a.emails,b=b&&b.length&&"[object Array]"===Object.prototype.toString.call(b);return a.clientId&&!E(a.clientId)&&b};S.prototype.ha=function(){var a={rpcs:[],events:[]};Lb(this,a);return a};
var Lb=function(a,b){b.rpcs.push({method:"now:getCode",handler:T(a,a.ib),rpcIdRequired:!0,validator:T(a,a.jb)});b.rpcs.push({method:"now:revoke",handler:T(a,a.Fb),rpcIdRequired:!0,validator:T(a,a.Gb)})};S.prototype.ha=function(){var a={rpcs:[],events:[]};jb(this,a);Lb(this,a);return a};C.ga="APISID";C.Ea="SAPISID";C.Ga="/o/oauth2/iframerpc?action=sessionState";C.ya="/o/oauth2/iframerpc?action=checkOrigin";C.Da="/o/oauth2/iframerpc?action=issueToken";C.Ca="/o/oauth2/iframerpc?action=issueOnlineCode";C.fa="/o/oauth2/iframerpc?action=listSessions";
var Mb=function(){var a=fa("origin");if(!a)throw"Failed to get parent origin from URL hash!";var b=fa("rpcToken");if(!b)throw"Failed to get rpcToken from URL hash!";var c=fa("debug");ca="0"!=c&&!!c;(new S(a,b)).start()},Nb=["lso","startIdpIFrame"],Y=this;Nb[0]in Y||!Y.execScript||Y.execScript("var "+Nb[0]);for(var Z;Nb.length&&(Z=Nb.shift());)Nb.length||void 0===Mb?Y=Y[Z]&&Y[Z]!==Object.prototype[Z]?Y[Z]:Y[Z]={}:Y[Z]=Mb;
