(function(e,m){"function"===typeof define&&define.amd?define("orion/Deferred",m):"object"===typeof exports?module.exports=m():(e.orion=e.orion||{},e.orion.Deferred=m())})(this,function(){function e(){for(var c;c=f.shift();)c();d=!1}function m(c){f.push(c);d||(d=!0,g())}function q(c){return function(a){c(a)}}function h(){function c(){for(var a;a=r.shift();){var b=a.deferred,p="fulfilled"===k?"resolve":"reject";a=a[p];if("function"===typeof a)try{var c=a(l),n=c&&("object"===typeof c||"function"===typeof c)&&
c.then;if("function"===typeof n)if(c===b.promise)b.reject(new TypeError);else{var d=c.cancel;"function"===typeof d?b._parentCancel=d.bind(c):delete b._parentCancel;n.call(c,q(b.resolve),q(b.reject),q(b.progress))}else b.resolve(c)}catch(e){b.reject(e)}else b[p](l)}}function a(a){delete p._parentCancel;k="rejected";l=a;r.length&&m(c)}function n(b){function d(b){return function(a){(!k||"assumed"===k)&&b(a)}}delete p._parentCancel;try{var e=b&&("object"===typeof b||"function"===typeof b)&&b.then;if("function"===
typeof e)if(b===p)a(new TypeError);else{k="assumed";var f=b&&b.cancel;if("function"!==typeof f){var g=new h;b=g.promise;try{e(g.resolve,g.reject,g.progress)}catch(q){g.reject(q)}f=b.cancel;e=b.then}l=b;e.call(b,d(n),d(a));p._parentCancel=f.bind(b)}else k="fulfilled",l=b,r.length&&m(c)}catch(s){d(a)(s)}}function b(){var b=p._parentCancel;b?(delete p._parentCancel,b()):k||(b=Error("Cancel"),b.name="Cancel",a(b))}var l,k,r=[],p=this;this.resolve=function(b){k||n(b);return p};this.reject=function(b){k||
a(b);return p};this.progress=function(b){k||r.forEach(function(a){if(a.progress)try{a.progress(b)}catch(c){}});return p.promise};this.cancel=function(){p._parentCancel?setTimeout(b,0):b();return p};this.then=function(b,a,l){var n=new h;n._parentCancel=p.promise.cancel;r.push({resolve:b,reject:a,progress:l,deferred:n});("fulfilled"===k||"rejected"===k)&&m(c);return n.promise};this.promise={then:p.then,cancel:p.cancel}}var f=[],d=!1,g=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var c=
process.nextTick;return function(){c(e)}}if("function"===typeof MutationObserver){var a=document.createElement("div");(new MutationObserver(e)).observe(a,{attributes:!0});return function(){a.setAttribute("class","_tick")}}return function(){setTimeout(e,0)}}();h.all=function(c,a){function n(b,a){r||(k[b]=a,0===--l&&p.resolve(k))}function b(b,c){if(!r){if(a)try{n(b,a(c));return}catch(l){c=l}p.reject(c)}}var l=c.length,k=[],r=!1,p=new h;p.then(void 0,function(){r=!0;c.forEach(function(b){b.cancel&&b.cancel()})});
0===l?p.resolve(k):c.forEach(function(a,c){a.then(n.bind(void 0,c),b.bind(void 0,c))});return p.promise};h.when=function(c,a,n,b){var l;c&&"function"===typeof c.then||(l=new h,l.resolve(c),c=l.promise);return c.then(a,n,b)};return h});
define("orion/xhr",["orion/Deferred"],function(e){function m(e,h,f,d){var g="undefined"!==typeof f.response?f.response:f.responseText,c;try{c=f.status}catch(a){c=0}e={args:h,response:g,responseText:"string"===typeof g?g:null,status:c,url:e,xhr:f};"undefined"!==typeof d&&(e.error=d);return e}return function(q,h,f){f=f||{};var d=3<arguments.length&&arguments[3]?arguments[3]:new XMLHttpRequest,g=new e,c=f.headers||{},a=f.log||!1,n;"undefined"===typeof c["X-Requested-With"]&&(c["X-Requested-With"]="XMLHttpRequest");
if("undefined"!==typeof f.data&&("POST"===q||"PUT"===q))n=f.data;var b=!1,l=!1;g.promise.then(void 0,function(a){b=!0;!l&&a instanceof Error&&"Cancel"===a.name&&d.abort()});d.onabort=function(){l=!0;if(!b){var a=Error("Cancel");a.name="Cancel";g.reject(a)}};d.onload=function(){var b=m(h,f,d);200<=d.status&&400>d.status?g.resolve(b):(g.reject(b),a&&"undefined"!==typeof console&&console.log(Error(d.statusText)))};d.onerror=function(){var b=m(h,f,d);g.reject(b);a&&"undefined"!==typeof console&&console.log(Error(d.statusText))};
d.onprogress=function(b){b.xhr=d;g.progress(b)};try{d.open(q,h,!0);"string"===typeof f.responseType&&(d.responseType=f.responseType);if("number"===typeof f.timeout)if("number"===typeof d.timeout)d.timeout=f.timeout,d.addEventListener("timeout",function(b){g.reject(m(h,f,d,"Timeout exceeded"))});else{var k=setTimeout(function(){g.reject(m(h,f,d,"Timeout exceeded"))},f.timeout);g.promise.then(clearTimeout.bind(null,k),clearTimeout.bind(null,k))}Object.keys(c).forEach(function(b){d.setRequestHeader(b,
c[b])});d.send(n||null)}catch(r){g.reject(m(h,f,d,r))}return g.promise}});
define("orion/util",[],function(){var e=navigator.userAgent,m=-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident")?document.documentMode:void 0,q=parseFloat(e.split("Firefox/")[1]||e.split("Minefield/")[1])||void 0,h=-1!==e.indexOf("Opera")?parseFloat(e.split("Version/")[1]):void 0,f=parseFloat(e.split("Chrome/")[1])||void 0,d=-1!==e.indexOf("Safari")&&!f,g=parseFloat(e.split("WebKit/")[1])||void 0,c=-1!==e.indexOf("Android"),a=-1!==e.indexOf("iPad"),e=-1!==e.indexOf("iPhone"),n=a||e,b=-1!==navigator.platform.indexOf("Mac"),
l=-1!==navigator.platform.indexOf("Win"),k=-1!==navigator.platform.indexOf("Linux"),r="ontouchstart"in document.createElement("input");return{formatMessage:function(b){var a=arguments;return b.replace(/\$\{([^\}]+)\}/g,function(b,c){return a[(c<<0)+1]})},createElement:function(b,a){return b.createElementNS?b.createElementNS("http://www.w3.org/1999/xhtml",a):b.createElement(a)},isIE:m,isFirefox:q,isOpera:h,isChrome:f,isSafari:d,isWebkit:g,isAndroid:c,isIPad:a,isIPhone:e,isIOS:n,isMac:b,isWindows:l,
isLinux:k,isTouch:r,platformDelimiter:l?"\r\n":"\n"}});
define("orion/webui/littlelib",["orion/util"],function(e){function m(a,c){c||(c=document);return c.querySelectorAll(a)}function q(a){var c=a.tabIndex;0===c&&e.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&&(c=-1);return c}function h(a){if(0<=q(a))return a;if(a.hasChildNodes())for(var c=0;c<a.childNodes.length;c++){var b=h(a.childNodes[c]);if(b)return b}return null}function f(a){if(0<=
q(a))return a;if(a.hasChildNodes())for(var c=a.childNodes.length-1;0<=c;c--){var b=f(a.childNodes[c]);if(b)return b}return null}function d(a,c){if(3===a.nodeType){var b=g.exec(a.nodeValue);b&&1<b.length&&c(a,b)}if(a.hasChildNodes())for(b=0;b<a.childNodes.length;b++)d(a.childNodes[b],c)}var g=/\$\{([^\}]+)\}/,c=null;return{$:function(a,c){c||(c=document);return c.querySelector(a)},$$:m,$$array:function(a,c){return Array.prototype.slice.call(m(a,c))},node:function(a){var c=a;"string"===typeof a&&(c=
document.getElementById(a));return c},contains:function(a,c){if(!a||!c)return!1;if(a===c)return!0;var b=a.compareDocumentPosition(c);return Boolean(b&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:h,lastTabbable:f,stop:function(a){window.document.all&&(a.keyCode=0);a.preventDefault&&
(a.preventDefault(),a.stopPropagation())},processTextNodes:function(a,c){d(a,function(b,a){b.parentNode.replaceChild(document.createTextNode(c[a[1]]||a[1]),b)})},processDOMNodes:function(a,c){d(a,function(b,a){var k=c[a[1]];if(k){var r=document.createRange(),e=a.index;r.setStart(b,e);r.setEnd(b,e+a[0].length);r.deleteContents();r.insertNode(k)}})},addAutoDismiss:function(a,d){function b(b){c.forEach(function(a){var c=!1,e=a.excludeNodes.some(function(a){return document.body.contains(a)?(c=!0,a.contains(b.target)):
!1});if(c&&!e)try{a.dismiss(b)}catch(d){"undefined"!==typeof console&&console&&console.error(d&&d.message)}});c=c.filter(function(b){return b.excludeNodes.some(function(b){return document.body.contains(b)})})}null===c&&(c=[],document.addEventListener("click",b,!0),e.isIOS&&document.addEventListener("touchend",function(b){function a(){b.target.removeEventListener("click",a)}0===b.touches.length&&b.target.addEventListener("click",a)},!1));c.push({excludeNodes:a,dismiss:d})},setFramesEnabled:function(a){for(var c=
document.getElementsByTagName("iframe"),b=0;b<c.length;b++)c[b].parentNode.style.pointerEvents=a?"":"none"},removeAutoDismiss:function(a){c=c.filter(function(c){return a!==c.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 e(){if(!g){g=!0;f&&clearInterval(f);var b=a;if(g&&b.length){a=[];var l;for(l=0;l<b.length;l+=1)b[l](c)}}}function m(b){g?b(c):a.push(b);return m}var q,h,f,d="undefined"!==typeof window&&window.document,g=!d,c=d?document:null,a=[];if(d){if(document.addEventListener)document.addEventListener("DOMContentLoaded",e,!1),window.addEventListener("load",e,!1);else if(window.attachEvent){window.attachEvent("onload",e);h=document.createElement("div");try{q=null===window.frameElement}catch(n){}h.doScroll&&
q&&window.external&&(f=setInterval(function(){try{h.doScroll(),e()}catch(b){}},30))}"complete"===document.readyState&&e()}m.version="2.0.1";m.load=function(b,a,c,e){e.isBuild?c(null):m(c)};return m});
define("built-manageOpenids.js",["orion/xhr","orion/webui/littlelib","domReady!"],function(e,m){function q(b){if(confirm("Are you sure you want to remove "+b+" from the list of your external accounts?")){for(var a=c.properties.openid.split("\n"),k="",d=0;d<a.length;d++)a[d]!==b&&(k+=a[d]+"\n");c.properties.openid=k;e("PUT",c.Location,{data:JSON.stringify(c),headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){n(c.Location)},function(b){console.error(b.error)})}}function h(b){g!==b&&(n(b),
g=b)}function f(b){""!==b&&null!==b&&window.open("../mixlogin/manageopenids/openid?openid\x3d"+encodeURIComponent(b),"openid_popup","width\x3d790,height\x3d580")}function d(b,a,c){var d=document.createElement("img");d.className="loginWindow";d.id=d.alt=d.title=b;d.src=a;a=document.createElement("a");a.className="loginWindow";a.onclick=c;a.setAttribute("aria-labelledby","addExternalAccount "+b);a.appendChild(d);return a}var g,c,a,n;a=function(b){c=b;var a=m.node("openidList");a.childNodes.length&&
a.removeChild(a.childNodes[0]);b=document.createElement("table");b.classList.add("manageOpenIdsTable");a.appendChild(b);if(c.properties&&c.properties.openid){for(var a=c.properties.openid?c.properties.openid.split("\n"):[],d=a.length-1;0<=d;d--)""===a[d]&&a.splice(d,1);if(a.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<a.length;d++){var g=a[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 h=document.createElement("span");h.title=g;f.appendChild(h);f=document.createTextNode(70<g.length?g.substring(0,65)+"...":g);h.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){q(a)}.bind(this,g))}}};n=function(b){e("GET",b,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){a(JSON.parse(b.response))},function(a){console.error(a.error)})};window.handleOpenIDResponse=function(a){for(var d=c.properties.openid?c.properties.openid.split("\n"):[],
f=0;f<d.length;f++)if(d[f]===a)return;c.properties.openid=c.properties.openid?c.properties.openid+("\n"+a):a;e("PUT",c.Location,{data:JSON.stringify(c),headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){n(c.Location)},function(a){console.error(a.error)})};window.addEventListener("hashchange",function(){h(window.location.hash.substring(1))});h(window.location.hash.substring(1));e("GET","../mixlogin/manageopenids").then(function(a){a=JSON.parse(a.response).map(function(a){return d(a.Name,
a.Image,f.bind(null,a.Url))});a.push(d("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=built-manageOpenids.js.map