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