/*

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 


 Copyright (c) 2014 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 


 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation
 RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
 Available via the MIT or new BSD license.
 see: http://github.com/requirejs/domReady for details

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors: IBM Corporation - initial API and implementation
 RequireJS i18n 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
 Available via the MIT or new BSD license.
 see: http://github.com/requirejs/i18n for details

 Copyright (c) 2012 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials are made 
 available under the terms of the Eclipse Public License v1.0 
 (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 

 Contributors:
     IBM Corporation - initial API and implementation
*/
(function(){function d(c,b,d,f,a,k){b[c]&&(d.push(c),(!0===b[c]||1===b[c])&&f.push(a+c+"/"+k))}function g(c,b,d,f,a){b=f+b+"/"+a;require._fileExists(c.toUrl(b+".js"))&&d.push(b)}function l(c,b,d){for(var f in b)b.hasOwnProperty(f)&&(!c.hasOwnProperty(f)||d)?c[f]=b[f]:"object"===typeof b[f]&&l(c[f],b[f],d)}var n=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;define("i18n",["module"],function(c){var b=c.config?c.config():{},b=b||{};return{version:"2.0.1+",load:function(c,f,a,k){k=k||{};k.locale&&(b.locale=
k.locale);var s=n.exec(c),m=s[1],h=s[4],r=s[5],e=h.split("-"),p=[],v={},t,u="";s[5]?(m=s[1],c=m+r):(r=s[4],h=b.locale,h||(h=b.locale="undefined"===typeof navigator?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),e=h.split("-"));if(k.isBuild){p.push(c);g(f,"root",p,m,r);for(t=0;t<e.length;t++)k=e[t],u+=(u?"-":"")+k,g(f,u,p,m,r);f(p,function(){a()})}else f([c],function(h){var b=[],k;d("root",h,b,p,m,r);for(t=0;t<e.length;t++)k=e[t],u+=(u?"-":"")+k,d(u,h,b,p,m,r);f(p,function(){var e,
p,k;for(e=b.length-1;-1<e&&b[e];e--){k=b[e];p=h[k];if(!0===p||1===p)p=f(m+k+"/"+r);l(v,p)}a(v)})})}}})})();
define("orion/i18n",[],function(){return{load:function(d,g,l,n){n=n||{};var c=/(^.*(?:^|\/)nls(?:\/|$))([^\/]*)\/?([^\/]*)/,b=c.exec(d);if(b){if(!g.defined||g.defined(d))try{l(g(d));return}catch(q){}if(n.isBuild||n.isTest)l({});else if(g.specified&&!g.specified("orion/bootstrap"))l({});else{var f=b[1],a=b[3]?b[2]:"",k=b[3]||b[2];g(["orion/bootstrap"],function(s){s.startup().then(function(m){var h=m.serviceRegistry;m=h.getServiceReferences("orion.i18n.message");if(a)m.some(function(a){return d===a.getProperty("name")?
(h.getService(a).getMessageBundle().then(function(a){l(a)},function(){l({})}),!0):!1})||l({});else{var r={},e;m.forEach(function(p){var h=p.getProperty("name");if((b=c.exec(h))&&f===b[1]&&k===(b[3]||b[2]))if(a=b[3]?b[2]:""){if((p=n.locale||("undefined"!==typeof navigator?navigator.language||navigator.userLanguage:null))&&0===p.toLowerCase().indexOf(a.toLowerCase()))r[a]=!0,(!g.specified||!g.specified(h))&&define(h,["orion/i18n!"+h],function(a){return a})}else e=p});!g.specified||!g.specified(d)?e?
h.getService(e).getMessageBundle().then(function(a){Object.keys(r).forEach(function(e){"undefined"===typeof a[e]&&(a[e]=r[e])});define(d,[],a);l(a)},function(){define(d,[],r);l(r)}):(define(d,[],r),l(r)):l(r)}})})}}else l(null)}}});define("orion/mixloginstatic/nls/root/messages",{AddExternalAccount:"Add external account:"});
define("orion/mixloginstatic/nls/messages",["orion/i18n!orion/mixloginstatic/nls/messages","orion/mixloginstatic/nls/root/messages"],function(d,g){var l={root:g};Object.keys(d).forEach(function(g){"undefined"===typeof l[g]&&(l[g]=d[g])});return l});
(function(d,g){"function"===typeof define&&define.amd?define("orion/Deferred",g):"object"===typeof exports?module.exports=g():(d.orion=d.orion||{},d.orion.Deferred=g())})(this,function(){function d(){for(var f;f=c.shift();)f();b=!1}function g(f){c.push(f);b||(b=!0,q())}function l(b){return function(a){b(a)}}function n(){function b(){for(var a;a=r.shift();){var e=a.deferred,k="fulfilled"===h?"resolve":"reject";a=a[k];if("function"===typeof a)try{var f=a(m),s=f&&("object"===typeof f||"function"===typeof f)&&
f.then;if("function"===typeof s)if(f===e.promise)e.reject(new TypeError);else{var c=f.cancel;"function"===typeof c?e._parentCancel=c.bind(f):delete e._parentCancel;s.call(f,l(e.resolve),l(e.reject),l(e.progress))}else e.resolve(f)}catch(d){e.reject(d)}else e[k](m)}}function a(a){delete e._parentCancel;h="rejected";m=a;r.length&&g(b)}function k(p){function s(a){return function(e){(!h||"assumed"===h)&&a(e)}}delete e._parentCancel;try{var c=p&&("object"===typeof p||"function"===typeof p)&&p.then;if("function"===
typeof c)if(p===e)a(new TypeError);else{h="assumed";var d=p&&p.cancel;if("function"!==typeof d){var l=new n;p=l.promise;try{c(l.resolve,l.reject,l.progress)}catch(q){l.reject(q)}d=p.cancel;c=p.then}m=p;c.call(p,s(k),s(a));e._parentCancel=d.bind(p)}else h="fulfilled",m=p,r.length&&g(b)}catch(w){s(a)(w)}}function s(){var b=e._parentCancel;b?(delete e._parentCancel,b()):h||(b=Error("Cancel"),b.name="Cancel",a(b))}var m,h,r=[],e=this;this.resolve=function(a){h||k(a);return e};this.reject=function(b){h||
a(b);return e};this.progress=function(a){h||r.forEach(function(e){if(e.progress)try{e.progress(a)}catch(b){}});return e.promise};this.cancel=function(){e._parentCancel?setTimeout(s,0):s();return e};this.then=function(a,m,k){var c=new n;c._parentCancel=e.promise.cancel;r.push({resolve:a,reject:m,progress:k,deferred:c});("fulfilled"===h||"rejected"===h)&&g(b);return c.promise};this.promise={then:e.then,cancel:e.cancel}}var c=[],b=!1,q=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var b=
process.nextTick;return function(){b(d)}}if("function"===typeof MutationObserver){var a=document.createElement("div");(new MutationObserver(d)).observe(a,{attributes:!0});return function(){a.setAttribute("class","_tick")}}return function(){setTimeout(d,0)}}();n.all=function(b,a){function k(a,b){r||(h[a]=b,0===--m&&e.resolve(h))}function c(b,h){if(!r){if(a)try{k(b,a(h));return}catch(m){h=m}e.reject(h)}}var m=b.length,h=[],r=!1,e=new n;e.then(void 0,function(){r=!0;b.forEach(function(a){a.cancel&&a.cancel()})});
0===m?e.resolve(h):b.forEach(function(a,e){a.then(k.bind(void 0,e),c.bind(void 0,e))});return e.promise};n.when=function(b,a,k,c){var m;b&&"function"===typeof b.then||(m=new n,m.resolve(b),b=m.promise);return b.then(a,k,c)};return n});
define("orion/xhr",["orion/Deferred"],function(d){function g(d,g,c,b){var q="undefined"!==typeof c.response?c.response:c.responseText,f;try{f=c.status}catch(a){f=0}d={args:g,response:q,responseText:"string"===typeof q?q:null,status:f,url:d,xhr:c};"undefined"!==typeof b&&(d.error=b);return d}return function(l,n,c){c=c||{};var b=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,q=new d,f=c.headers||{},a=c.log||!1,k;"undefined"===typeof f["X-Requested-With"]&&(f["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof c.data&&("POST"===l||"PUT"===l))k=c.data;var s=!1,m=!1;q.promise.then(void 0,function(a){s=!0;!m&&(a instanceof Error&&"Cancel"===a.name)&&b.abort()});b.onabort=function(){m=!0;if(!s){var a=Error("Cancel");a.name="Cancel";q.reject(a)}};b.onload=function(){var e=g(n,c,b);200<=b.status&&400>b.status?q.resolve(e):(q.reject(e),a&&"undefined"!==typeof console&&console.log(Error(b.statusText)))};b.onerror=function(){var e=g(n,c,b);q.reject(e);a&&"undefined"!==typeof console&&console.log(Error(b.statusText))};
b.onprogress=function(a){a.xhr=b;q.progress(a)};try{b.open(l,n,!0);"string"===typeof c.responseType&&(b.responseType=c.responseType);if("number"===typeof c.timeout)if("number"===typeof b.timeout)b.timeout=c.timeout,b.addEventListener("timeout",function(a){q.reject(g(n,c,b,"Timeout exceeded"))});else{var h=setTimeout(function(){q.reject(g(n,c,b,"Timeout exceeded"))},c.timeout);q.promise.then(clearTimeout.bind(null,h),clearTimeout.bind(null,h))}Object.keys(f).forEach(function(a){b.setRequestHeader(a,
f[a])});b.send(k||null)}catch(r){q.reject(g(n,c,b,r))}return q.promise}});
define("orion/util",[],function(){var d=navigator.userAgent,g=-1!==d.indexOf("MSIE")||-1!==d.indexOf("Trident")?document.documentMode:void 0,l=parseFloat(d.split("Firefox/")[1]||d.split("Minefield/")[1])||void 0,n=-1!==d.indexOf("Opera")?parseFloat(d.split("Version/")[1]):void 0,c=parseFloat(d.split("Chrome/")[1])||void 0,b=-1!==d.indexOf("Safari")&&!c,q=parseFloat(d.split("WebKit/")[1])||void 0,f=-1!==d.indexOf("Android"),a=-1!==d.indexOf("iPad"),d=-1!==d.indexOf("iPhone"),k=a||d,s=-1!==navigator.platform.indexOf("Mac"),
m=-1!==navigator.platform.indexOf("Win"),h=-1!==navigator.platform.indexOf("Linux"),r="undefined"!==typeof document&&"ontouchstart"in document.createElement("input");return{formatMessage:function(a){var b=arguments;return a.replace(/\$\{([^\}]+)\}/g,function(a,e){return b[(e<<0)+1]})},createElement:function(a,b){return a.createElementNS?a.createElementNS("http://www.w3.org/1999/xhtml",b):a.createElement(b)},isIE:g,isFirefox:l,isOpera:n,isChrome:c,isSafari:b,isWebkit:q,isAndroid:f,isIPad:a,isIPhone:d,
isIOS:k,isMac:s,isWindows:m,isLinux:h,isTouch:r,platformDelimiter:m?"\r\n":"\n"}});
define("orion/webui/littlelib",["orion/util"],function(d){function g(a,b){b||(b=document);return b.querySelectorAll(a)}function l(a){var b=a.tabIndex;0===b&&d.isIE&&!{a:!0,body:!0,button:!0,frame:!0,iframe:!0,img:!0,input:!0,isindex:!0,object:!0,select:!0,textarea:!0}[a.nodeName.toLowerCase()]&&!a.attributes.tabIndex&&(b=-1);return b}function n(a){if(0<=l(a))return a;if(a.hasChildNodes())for(var b=0;b<a.childNodes.length;b++){var c=n(a.childNodes[b]);if(c)return c}return null}function c(a){if(0<=
l(a))return a;if(a.hasChildNodes())for(var b=a.childNodes.length-1;0<=b;b--){var d=c(a.childNodes[b]);if(d)return d}return null}function b(a,c){if(3===a.nodeType){var d=q.exec(a.nodeValue);d&&1<d.length&&c(a,d)}if(a.hasChildNodes())for(d=0;d<a.childNodes.length;d++)b(a.childNodes[d],c)}var q=/\$\{([^\}]+)\}/,f=null;return{$:function(a,b){b||(b=document);return b.querySelector(a)},$$:g,$$array:function(a,b){return Array.prototype.slice.call(g(a,b))},node:function(a){var b=a;"string"===typeof a&&(b=
document.getElementById(a));return b},contains:function(a,b){if(!a||!b)return!1;if(a===b)return!0;var c=a.compareDocumentPosition(b);return Boolean(c&16)},bounds:function(a){a=a.getBoundingClientRect();return{left:a.left+document.documentElement.scrollLeft,top:a.top+document.documentElement.scrollTop,width:a.width,height:a.height}},empty:function(a){for(;a.hasChildNodes();)a.removeChild(a.firstChild)},firstTabbable:n,lastTabbable:c,stop:function(a){window.document.all&&(a.keyCode=0);a.preventDefault&&
(a.preventDefault(),a.stopPropagation())},processTextNodes:function(a,c){b(a,function(a,b){a.parentNode.replaceChild(document.createTextNode(c[b[1]]||b[1]),a)})},processDOMNodes:function(a,c){b(a,function(a,b){var h=c[b[1]];if(h){var d=document.createRange(),e=b.index;d.setStart(a,e);d.setEnd(a,e+b[0].length);d.deleteContents();d.insertNode(h)}})},addAutoDismiss:function(a,b){function c(a){f.forEach(function(b){var c=!1,e=b.excludeNodes.some(function(b){return document.body.contains(b)?(c=!0,b.contains(a.target)):
!1});if(c&&!e)try{b.dismiss(a)}catch(d){"undefined"!==typeof console&&console&&console.error(d&&d.message)}});f=f.filter(function(a){return a.excludeNodes.some(function(a){return document.body.contains(a)})})}null===f&&(f=[],document.addEventListener("click",c,!0),d.isIOS&&document.addEventListener("touchend",function(a){function b(){a.target.removeEventListener("click",b)}0===a.touches.length&&a.target.addEventListener("click",b)},!1));f.push({excludeNodes:a,dismiss:b})},setFramesEnabled:function(a){for(var b=
document.getElementsByTagName("iframe"),c=0;c<b.length;c++)b[c].parentNode.style.pointerEvents=a?"":"none"},removeAutoDismiss:function(a){f=f.filter(function(b){return a!==b.dismiss})},KEY:{BKSPC:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DEL:46}}});
define("domReady",[],function(){function d(){if(!q){q=!0;c&&clearInterval(c);var b=a;if(q&&b.length){a=[];var d;for(d=0;d<b.length;d+=1)b[d](f)}}}function g(b){q?b(f):a.push(b);return g}var l,n,c,b="undefined"!==typeof window&&window.document,q=!b,f=b?document:null,a=[];if(b){if(document.addEventListener)document.addEventListener("DOMContentLoaded",d,!1),window.addEventListener("load",d,!1);else if(window.attachEvent){window.attachEvent("onload",d);n=document.createElement("div");try{l=null===window.frameElement}catch(k){}n.doScroll&&
(l&&window.external)&&(c=setInterval(function(){try{n.doScroll(),d()}catch(a){}},30))}"complete"===document.readyState&&d()}g.version="2.0.1";g.load=function(a,b,c,d){d.isBuild?c(null):g(c)};return g});
define("mixloginstatic/manageOpenids",["i18n!orion/mixloginstatic/nls/messages","orion/xhr","orion/webui/littlelib","domReady!"],function(d,g,l){function n(b){if(confirm("Are you sure you want to remove "+b+" from the list of your external accounts?")){for(var c=a.properties.openid.split("\n"),d="",e=0;e<c.length;e++)c[e]!==b&&(d+=c[e]+"\n");a.properties.openid=d;g("PUT",a.Location,{data:JSON.stringify(a),headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){s(a.Location)},function(a){console.error(a.error)})}}
function c(a){f!==a&&(s(a),f=a)}function b(a){""!==a&&null!==a&&window.open("../mixlogin/manageopenids/openid?openid\x3d"+encodeURIComponent(a),"openid_popup","width\x3d790,height\x3d580")}function q(a,b,c){var e=document.createElement("img");e.className="loginWindow";e.id=e.alt=e.title=a;e.src=b;b=document.createElement("a");b.className="loginWindow";b.onclick=c;b.setAttribute("aria-labelledby","addExternalAccount "+a);b.appendChild(e);return b}var f,a,k,s;k=function(b){a=b;var c=l.node("openidList");
c.childNodes.length&&c.removeChild(c.childNodes[0]);b=document.createElement("table");b.classList.add("manageOpenIdsTable");c.appendChild(b);if(a.properties&&a.properties.openid){for(var c=a.properties.openid?a.properties.openid.split("\n"):[],d=c.length-1;0<=d;d--)""===c[d]&&c.splice(d,1);if(c.length){d=document.createElement("thead");d.classList.add("navTableHeading");b.appendChild(d);var e=document.createElement("tr");d.appendChild(e);var f=document.createElement("td");f.classList.add("navColumn");
f.innerHTML="\x3ch2\x3eExternal Id\x3c/h2\x3e";e.appendChild(f)}for(d=0;d<c.length;d++){var g=c[d],e=document.createElement("tr");e.classList.add(0===d%2?"lightTreeTableRow":"darkTreeTableRow");e.classList.add("manageOpenIdRow");e.style.verticalAlign="baseline";b.appendChild(e);f=document.createElement("td");f.classList.add("navColumn");e.appendChild(f);var k=document.createElement("span");k.title=g;f.appendChild(k);f=document.createTextNode(70<g.length?g.substring(0,65)+"...":g);k.appendChild(f);
f=document.createElement("td");f.classList.add("navColumn");e.appendChild(f);e=document.createElement("a");e.classList.add("removeOpenId");e.id="remlink"+d;e.innerHTML="Remove";e.style.visibility="hidden";e.title="Remove "+g;f.appendChild(e);e.addEventListener("click",function(a){n(a)}.bind(this,g))}}};s=function(a){g("GET",a,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){k(JSON.parse(a.response))},function(a){console.error(a.error)})};window.handleOpenIDResponse=function(b){for(var c=
a.properties.openid?a.properties.openid.split("\n"):[],d=0;d<c.length;d++)if(c[d]===b)return;a.properties.openid=a.properties.openid?a.properties.openid+("\n"+b):b;g("PUT",a.Location,{data:JSON.stringify(a),headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){s(a.Location)},function(a){console.error(a.error)})};window.addEventListener("hashchange",function(){c(window.location.hash.substring(1))});c(window.location.hash.substring(1));(function(){var a=document.getElementById("newOpenId"),
b=document.createElement("h2");b.style.margin="10px 5px 10px 0";b.style.cssFloat="left";b.id="addExternalAccount";b.innerHTML=d.AddExternalAccount;a.appendChild(b)})();g("GET","../mixlogin/manageopenids").then(function(a){a=JSON.parse(a.response).map(function(a){return q(a.Name,a.Image,b.bind(null,a.Url))});a.push(q("Mozilla Persona","../mixloginstatic/images/persona.png",alert.bind(null,"To link your account with a Persona, set your Orion email address above to match your Persona email address.")));
var c=document.getElementById("newOpenId");a.forEach(function(a){c.appendChild(a);c.appendChild(document.createTextNode(" "))})})});
//@ sourceMappingURL=manageOpenids.js.map