/*******************************************************************************
 * @license
 * 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
 ******************************************************************************/

/*******************************************************************************
 * @license
 * 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
 *******************************************************************************/

/*******************************************************************************
 * @license
 * Copyright (c) 2011, 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
 *******************************************************************************/

/**
 * @license 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

 Copyright (c) 2011, 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

 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(c,e){typeof define==="function"&&define.amd?define("orion/Deferred",e):typeof exports==="object"?module.exports=e():(c.orion=c.orion||{},c.orion.Deferred=e())})(this,function(){function c(){for(var a;a=f.shift()||i.shift();)a();j=!1}function e(a,k){(k?i:f).push(a);j||(j=!0,k?setTimeout(c,0):c())}function m(a){return function(){a.apply(null,arguments)}}function h(){}function d(){var a=Error("Cancel");a.name="Cancel";return a}function a(){function c(){for(var a;a=b.shift();){var g=a.deferred,
d=l==="resolved"?"resolve":"reject";if(typeof a[d]==="function")try{var e=a[d](k);e&&typeof e.then==="function"?(g.cancel=e.cancel||h,e.then(m(g.resolve),m(g.reject),g.progress)):g.resolve(e)}catch(f){g.reject(f)}else g[d](k)}}var k,l,b=[],g=this;this.reject=function(a){l||(l="rejected",k=a,b.length&&e(c));return g.promise};this.resolve=function(a){l||(l="resolved",k=a,b.length&&e(c));return g.promise};this.progress=function(a){l||b.forEach(function(b){b.progress&&b.progress(a)});return g.promise};
this.cancel=function(){l||g.reject(d())};this.then=function(o,d,k){var o={resolve:o,reject:d,progress:k,deferred:new a},f=o.deferred,i=!1,h=function(){i||(i=!0,e(function(){var a=f.cancel===h?g.cancel:f.cancel;typeof a==="function"&&a()},!0))};f.cancel=h;b.push(o);l&&e(c,!0);return f.promise};this.promise=Object.create(Object.prototype,{then:{value:g.then},cancel:{get:function(){return g.cancel},set:function(a){g.cancel=a}}})}var f=[],i=[],j=!1;a.all=function(d,e){function l(a,b){f||(o[a]=b,--g===
0&&c.resolve(o))}function b(a,b){if(!f){if(e)try{l(a,e(b));return}catch(g){b=g}c.reject(b)}}var g=d.length,o=[],f=!1,c=new a;c.then(null,function(){f=!0;d.forEach(function(a){a.cancel&&a.cancel()})});g===0?c.resolve(o):d.forEach(function(a,g){a.then(l.bind(null,g),b.bind(null,g))});return c.promise};a.when=function(d,e,l,b){var g;if(!(d&&typeof d.then==="function"))g=new a,g.resolve(d),d=g.promise;return d.then(e,l,b)};return a});
define("orion/xhr",["orion/Deferred"],function(c){function e(e,c,d,a){var f=typeof d.response!=="undefined"?d.response:d.responseText,i;try{i=d.status}catch(j){i=0}e={args:c,response:f,responseText:typeof f==="string"?f:null,status:i,url:e,xhr:d};if(typeof a!=="undefined")e.error=a;return e}return function(m,h,d){var d=d||{},a=arguments.length>3&&arguments[3]?arguments[3]:new XMLHttpRequest,f=new c,i=d.headers||{},j=d.log||!1,n;typeof i["X-Requested-With"]==="undefined"&&(i["X-Requested-With"]="XMLHttpRequest");
if(typeof d.data!=="undefined"&&(m==="POST"||m==="PUT"))n=d.data;a.onprogress=function(b){b.xhr=a;f.progress(b)};a.onreadystatechange=function(){if(a.readyState===4){var b=e(h,d,a),l=a.status;200<=l&&l<400?f.resolve(b):(j&&typeof console!=="undefined"&&console.log(Error(a.statusText)),f.reject(b))}};try{a.open(m,h,!0);if(typeof d.responseType==="string")a.responseType=d.responseType;if(typeof d.timeout==="number")if(typeof a.timeout==="number")a.timeout=d.timeout,a.addEventListener("timeout",function(){f.reject(e(h,
d,a,"Timeout exceeded"))});else{var k=setTimeout(function(){f.reject(e(h,d,a,"Timeout exceeded"))},d.timeout);f.then(clearTimeout.bind(null,k),clearTimeout.bind(null,k))}Object.keys(i).forEach(function(b){a.setRequestHeader(b,i[b])});a.send(n)}catch(l){f.reject(e(h,d,a,l))}return f.promise}});(function(){var c=this;if(!c.define)c.define=function(e){c.orion=c.orion||{};c.orion.PluginProvider=e();c.eclipse=c.orion;delete c.define}})();
define("orion/plugin",[],function(){return function(c){function e(a){k&&(typeof ArrayBuffer==="undefined"&&(a=JSON.stringify(a)),k===self?k.postMessage(a):k.postMessage(a,"*"))}function m(a,b){if(b&&b instanceof XMLHttpRequest){var d,e;try{d=b.status,e=b.statusText}catch(c){d=0,e=""}return{status:d||0,statusText:e}}return b}function h(a){var b=a?JSON.parse(JSON.stringify(a,m)):a;if(a instanceof Error)b.__isError=!0,b.message=b.message||a.message,b.name=b.name||a.name;return b}function d(a){return function(b){j&&
e({serviceId:a,method:"dispatchEvent",params:[b]})}}function a(a){if(a.source===k){var b=typeof a.data!=="string"?a.data:JSON.parse(a.data);if(typeof b.cancel==="string"){var g=n[b.id];g&&(delete n[b.id],g.cancel&&g.cancel(b.cancel))}else{var a=b.serviceId,c=b.method,f=b.params,j=i[a],m=j.implementation,q=m[c];c==="addEventListener"?(c=f[0],j.listeners[c]=j.listeners[c]||d(a),f=[c,j.listeners[c]]):c==="removeEventListener"&&(c=f[0],f=[c,j.listeners[c]],delete j.listeners[c]);var p={id:b.id,result:null,
error:null};try{(g=q.apply(m,f))&&typeof g.then==="function"?(n[b.id]=g,g.then(function(a){delete n[b.id];p.result=a;e(p)},function(a){if(n[b.id])delete n[b.id],p.error=h(a),e(p)},function(){e({requestId:b.id,method:"progress",params:Array.prototype.slice.call(arguments)})})):(p.result=g,e(p))}catch(r){p.error=h(r),e(p)}}}}var f=c,i=[],j=!1,n={},k=null;this.updateHeaders=function(a){if(j)throw Error("Cannot update headers. Plugin Provider is connected");f=a};this.registerServiceProvider=this.registerService=
function(a,b,c){if(j)throw Error("Cannot register service. Plugin Provider is connected");typeof a==="string"?a=[a]:Array.isArray(a)||(a=[]);var d=null,e=[];for(d in b)typeof b[d]==="function"&&e.push(d);i[i.length]={names:a,methods:e,implementation:b,properties:c||{},listeners:{}}};this.connect=function(d,b){if(!j){if(typeof window==="undefined")k=self;else if(window!==window.parent)k=window.parent;else if(window.opener!==null)k=window.opener;else{b&&b("No valid plugin target");return}addEventListener("message",
a,!1);for(var c=[],h=0;h<i.length;h++)c.push({serviceId:h,names:i[h].names,methods:i[h].methods,properties:i[h].properties});e({method:"plugin",params:[{headers:f||{},services:c}]});j=!0}d&&d()};this.disconnect=function(){j&&(removeEventListener("message",a),k=null,j=!1)}}});
define("domReady",[],function(){function c(){if(!f){f=!0;d&&clearInterval(d);var a=j;if(f&&a.length){j=[];var c;for(c=0;c<a.length;c+=1)a[c](i)}}}function e(a){f?a(i):j.push(a);return e}var m,h,d,a=typeof window!=="undefined"&&window.document,f=!a,i=a?document:null,j=[];if(a){if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(window.attachEvent){window.attachEvent("onload",c);h=document.createElement("div");try{m=window.frameElement===
null}catch(n){}h.doScroll&&m&&window.external&&(d=setInterval(function(){try{h.doScroll(),c()}catch(a){}},30))}document.readyState==="complete"&&c()}e.version="2.0.1";e.load=function(a,c,b,d){d.isBuild?b(null):e(b)};return e});
define('built-preferencesPlugin.js',["orion/xhr","orion/plugin","domReady!"],function(c,e){function m(a){this.location=a}m.prototype={get:function(a){return c("GET",this.location+a,{headers:{"Orion-Version":"1"},timeout:15E3,log:!1}).then(function(a){return a.response?JSON.parse(a.response):null})},put:function(a,d){return c("PUT",this.location+a,{data:JSON.stringify(d),headers:{"Orion-Version":"1"},contentType:"application/json;charset=UTF-8",timeout:15E3}).then(function(a){return a.response?JSON.parse(a.response):
null})}};var h=document.createElement("a");h.href="../prefs/user";var d=h.href;h.href="../mixloginstatic/LoginWindow.html";h=new e({name:"Orion Preferences",version:"1.0",description:"This plugin provides access to user preferences.",login:h.href});d=new m(d);h.registerService("orion.core.preference.provider",d,{});h.connect()});