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

 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

 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(b,h){typeof define==="function"&&define.amd?define("orion/Deferred",h):typeof exports==="object"?module.exports=h():(b.orion=b.orion||{},b.orion.Deferred=h())})(this,function(){function b(){for(var a;a=e.shift()||f.shift();)a();c=!1}function h(a,d){(d?f:e).push(a);c||(c=!0,d?setTimeout(b,0):b())}function k(a){return function(){a.apply(null,arguments)}}function i(){}function g(){var a=Error("Cancel");a.name="Cancel";return a}function d(){function a(){for(var a;a=o.shift();){var c=a.deferred,
d=m==="resolved"?"resolve":"reject";if(typeof a[d]==="function")try{var b=a[d](f);b&&typeof b.then==="function"?(c.cancel=b.cancel||i,b.then(k(c.resolve),k(c.reject),c.progress)):c.resolve(b)}catch(g){c.reject(g)}else c[d](f)}}var f,m,o=[],c=this;this.reject=function(d){m||(m="rejected",f=d,o.length&&h(a));return c.promise};this.resolve=function(d){m||(m="resolved",f=d,o.length&&h(a));return c.promise};this.progress=function(a){m||o.forEach(function(c){c.progress&&c.progress(a)});return c.promise};
this.cancel=function(){m||c.reject(g())};this.then=function(f,b,g){var f={resolve:f,reject:b,progress:g,deferred:new d},e=f.deferred,l=!1,i=function(){l||(l=!0,h(function(){var a=e.cancel===i?c.cancel:e.cancel;typeof a==="function"&&a()},!0))};e.cancel=i;o.push(f);m&&h(a,!0);return e.promise};this.promise=Object.create(Object.prototype,{then:{value:c.then},cancel:{get:function(){return c.cancel},set:function(a){c.cancel=a}}})}var e=[],f=[],c=!1;d.all=function(a,c){function f(a,c){e||(h[a]=c,--g===
0&&i.resolve(h))}function b(a,d){if(!e){if(c)try{f(a,c(d));return}catch(o){d=o}i.reject(d)}}var g=a.length,h=[],e=!1,i=new d;i.then(null,function(){e=!0;a.forEach(function(a){a.cancel&&a.cancel()})});g===0?i.resolve(h):a.forEach(function(a,c){a.then(f.bind(null,c),b.bind(null,c))});return i.promise};d.when=function(a,c,f,b){var g;if(!(a&&typeof a.then==="function"))g=new d,g.resolve(a),a=g.promise;return a.then(c,f,b)};return d});
define("orion/xhr",["orion/Deferred"],function(b){function h(b,h,g,d){var e=typeof g.response!=="undefined"?g.response:g.responseText,f;try{f=g.status}catch(c){f=0}b={args:h,response:e,responseText:typeof e==="string"?e:null,status:f,url:b,xhr:g};if(typeof d!=="undefined")b.error=d;return b}return function(k,i,g){var g=g||{},d=arguments.length>3&&arguments[3]?arguments[3]:new XMLHttpRequest,e=new b,f=g.headers||{},c=g.log||!1,a;typeof f["X-Requested-With"]==="undefined"&&(f["X-Requested-With"]="XMLHttpRequest");
if(typeof g.data!=="undefined"&&(k==="POST"||k==="PUT"))a=g.data;d.onprogress=function(a){a.xhr=d;e.progress(a)};d.onreadystatechange=function(){if(d.readyState===4){var a=h(i,g,d),f=d.status;200<=f&&f<400?e.resolve(a):(c&&typeof console!=="undefined"&&console.log(Error(d.statusText)),e.reject(a))}};try{d.open(k,i,!0);if(typeof g.responseType==="string")d.responseType=g.responseType;if(typeof g.timeout==="number")if(typeof d.timeout==="number")d.timeout=g.timeout,d.addEventListener("timeout",function(){e.reject(h(i,
g,d,"Timeout exceeded"))});else{var l=setTimeout(function(){e.reject(h(i,g,d,"Timeout exceeded"))},g.timeout);e.then(clearTimeout.bind(null,l),clearTimeout.bind(null,l))}Object.keys(f).forEach(function(a){d.setRequestHeader(a,f[a])});d.send(a)}catch(m){e.reject(h(i,g,d,m))}return e.promise}});(function(){var b=this;if(!b.define)b.define=function(h){b.orion=b.orion||{};b.orion.PluginProvider=h();b.eclipse=b.orion;delete b.define}})();
define("orion/plugin",[],function(){return function(b){function h(a){l&&(typeof ArrayBuffer==="undefined"&&(a=JSON.stringify(a)),l===self?l.postMessage(a):l.postMessage(a,"*"))}function k(a,c){if(c&&c instanceof XMLHttpRequest){var f,d;try{f=c.status,d=c.statusText}catch(b){f=0,d=""}return{status:f||0,statusText:d}}return c}function i(a){var c=a?JSON.parse(JSON.stringify(a,k)):a;if(a instanceof Error)c.__isError=!0,c.message=c.message||a.message,c.name=c.name||a.name;return c}function g(a){return function(f){c&&
h({serviceId:a,method:"dispatchEvent",params:[f]})}}function d(c){if(c.source===l){var d=typeof c.data!=="string"?c.data:JSON.parse(c.data);if(typeof d.cancel==="string"){var b=a[d.id];b&&(delete a[d.id],b.cancel&&b.cancel(d.cancel))}else{var c=d.serviceId,e=d.method,k=d.params,p=f[c],q=p.implementation,s=q[e];e==="addEventListener"?(e=k[0],p.listeners[e]=p.listeners[e]||g(c),k=[e,p.listeners[e]]):e==="removeEventListener"&&(e=k[0],k=[e,p.listeners[e]],delete p.listeners[e]);var n={id:d.id,result:null,
error:null};try{(b=s.apply(q,k))&&typeof b.then==="function"?(a[d.id]=b,b.then(function(c){delete a[d.id];n.result=c;h(n)},function(c){if(a[d.id])delete a[d.id],n.error=i(c),h(n)},function(){h({requestId:d.id,method:"progress",params:Array.prototype.slice.call(arguments)})})):(n.result=b,h(n))}catch(t){n.error=i(t),h(n)}}}}var e=b,f=[],c=!1,a={},l=null;this.updateHeaders=function(a){if(c)throw Error("Cannot update headers. Plugin Provider is connected");e=a};this.registerServiceProvider=this.registerService=
function(a,d,b){if(c)throw Error("Cannot register service. Plugin Provider is connected");typeof a==="string"?a=[a]:Array.isArray(a)||(a=[]);var e=null,g=[];for(e in d)typeof d[e]==="function"&&g.push(e);f[f.length]={names:a,methods:g,implementation:d,properties:b||{},listeners:{}}};this.connect=function(a,b){if(!c){if(typeof window==="undefined")l=self;else if(window!==window.parent)l=window.parent;else if(window.opener!==null)l=window.opener;else{b&&b("No valid plugin target");return}addEventListener("message",
d,!1);for(var g=[],i=0;i<f.length;i++)g.push({serviceId:i,names:f[i].names,methods:f[i].methods,properties:f[i].properties});h({method:"plugin",params:[{headers:e||{},services:g}]});c=!0}a&&a()};this.disconnect=function(){c&&(removeEventListener("message",d),l=null,c=!1)}}});
define("orion/operation",["orion/xhr","orion/Deferred"],function(b,h){function k(g,d,e,f){b("GET",g,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(c){c=c.response?JSON.parse(c.response):null;d.progress(c);!c.type||c.type==="loadstart"||c.type==="progress"?setTimeout(function(){k(g,d,e,f)},2E3):(c.type==="error"||c.type==="abort"?d.reject(f?f(c):c.Result):d.resolve(e?e(c):c.Result.JsonData),c.Location||b("DELETE",g,{headers:{"Orion-Version":"1"},timeout:15E3}))},function(c){var a=c;if(c.responseText!==
void 0){a=c.responseText;try{a=JSON.parse(c.responseText)}catch(b){}}a.Message!==void 0?(a.HttpCode=a.HttpCode===void 0?c.status:a.HttpCode,a.Severity=a.Severity===void 0?"Error":a.Severity,d.reject(a)):d.reject({Severity:"Error",Message:a,HttpCode:c.status})})}function i(g,d){d.then(null,function(d){d instanceof Error&&d.name==="Cancel"&&b("PUT",g,{headers:{"Orion-Version":"1"},data:JSON.stringify({abort:!0}),timeout:15E3})})}return{handle:function(b,d,e){var f=new h;i(b,f);k(b,f,d,e);return f}}});
(function(){function b(j){if(typeof j!=="string")throw new TypeError;}function h(j){return j?j.split("&"):[]}function k(j){return j.length===0?"":j.join("&")}function i(j){var a=/([^=]*)(?:=?)(.*)/.exec(j),j=a[1]?decodeURIComponent(a[1]):"",a=a[2]?decodeURIComponent(a[2]):"";return[j,a]}function g(j){var a=encodeURIComponent(j[0]);j[1]&&(a+="="+encodeURIComponent(j[1]));return a}function d(j,a){var c="",d=[],b=0;return{next:function(){if(c!==j.query)c=j.query,d=h(c);if(b<d.length){var f=i(d[b++]);
switch(a){case "keys":return f[0];case "values":return f[1];case "keys+values":return[f[0],f[1]];default:throw new TypeError;}}throw w;}}}function e(j){Object.defineProperty(this,"_url",{get:function(){return j._url}})}function f(j){var a=[];j.split("/").forEach(function(j){j===".."?a.pop():j!=="."&&a.push(j)});return a.join("/")}function c(j){return j.replace(/\s/g,function(j){return"%"+j.charCodeAt(0).toString(16)})}function a(j,a){if(typeof j!=="string")throw new TypeError;var j=c(j),d=o.exec(j);
if(!d)return null;var b={};b.scheme=d[1]||"";if(b.scheme&&!u.test(b.scheme))return null;var e=d[2];if(e&&(e=x.exec(e),b.userinfo=e[1],b.host=e[2],b.port=e[3],b.port&&!v.test(b.port)))return null;b.path=d[3];b.query=d[4];b.fragment=d[5];if(!b.scheme&&a&&(b.scheme=a.scheme,!b.host&&a.host))b.userinfo=a.userinfo,b.host=a.host,b.port=a.port,b.pathRelative=!0;if(b.pathRelative)if(b.path){if(b.path[0]!=="/")d=/^(.*\/)[^\/]*$/.exec(a.path)[1]||"/",b.path=d+b.path}else b.path=a.path;if(b.scheme)b.scheme=
b.scheme.toLowerCase();if(b.port)b.port=/[1-9]\d*$/.exec(b.port)[0];if(b.host&&b.path)b.path=f(b.path);return b}function l(j,b){var c;if(b){b=b.href||b;c=a(b);if(!c||!c.scheme)throw new SyntaxError;Object.defineProperty(this,"_baseURL",{value:c})}c=a(j,c);if(!c)throw new SyntaxError;Object.defineProperty(this,"_input",{value:j,writable:!0});Object.defineProperty(this,"_url",{value:c,writable:!0});var d=new e(this);Object.defineProperty(this,"query",{get:function(){return this._url?d:null},enumerable:!0})}
try{if(typeof window.URL==="function"&&window.URL.length!==0&&(new window.URL("http://www.w3.org")).protocol==="http:")return}catch(m){}var o=/^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/,x=/^(?:(.*)@)?(\[[^\]]*\]|[^:]*)(?::(.*))?$/,u=/^([a-zA-Z](?:[a-zA-Z0-9+-.])*)$/,v=/^\d*$/,p=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)$/,q=/^(\[[^\]\/?#\s]*\]|[^:\/?#\s]*)(?::(\d*))?$/,s=/^([^?#\s]*)$/,n=/^([^\s]*)$/,t=/^\S*$/,r=/([^:]*):?(.*)/,w=typeof StopIteration!=="undefined"?StopIteration:
Error("Stop Iteration"),y={"ftp:":"21","gopher:":"70","http:":"80","https:":"443","ws:":"80","wss:":"443"};Object.defineProperties(e.prototype,{get:{value:function(a){b(a);var c;h(this._url.query).some(function(b){b=i(b);if(b[0]===a)return c=b[1],!0});return c},enumerable:!0},set:{value:function(a,c){b(a);b(c);var d=h(this._url.query);d.some(function(b,f){var e=i(b);if(e[0]===a)return e[1]=c,d[f]=g(e),!0})||d.push(g([a,c]));this._url.query=k(d)},enumerable:!0},has:{value:function(a){b(a);return h(this._url.query).some(function(b){if(i(b)[0]===
a)return!0})},enumerable:!0},"delete":{value:function(a){b(a);var c=h(this._url.query),d=c.filter(function(b){return i(b)[0]!==a});return d.length!==c.length?(this._url.query=k(d),!0):!1},enumerable:!0},clear:{value:function(){this._url.query=""},enumerable:!0},forEach:{value:function(a,b){if(typeof a!=="function")throw new TypeError;var c=d(this._url,"keys+values");try{for(;;){var f=c.next();a.call(b,f[1],f[0],this)}}catch(e){if(e!==w)throw e;}},enumerable:!0},keys:{value:function(){return d(this._url,
"keys")},enumerable:!0},values:{value:function(){return d(this._url,"values")},enumerable:!0},items:{value:function(){return d(this._url,"keys+values")}},size:{get:function(){return h(this._url.query).length},enumerable:!0},getAll:{value:function(a){b(a);var c=[];h(this._url.query).forEach(function(b){b=i(b);b[0]===a&&c.push(b[1])});return c},enumerable:!0},append:{value:function(a,c){b(a);b(c);var d=h(this._url.query);d.push(g([a,c]));this._url.query=k(d)},enumerable:!0}});Object.defineProperties(l.prototype,
{href:{get:function(){var a;if(this._url){a=this._url;var b=a.scheme?a.scheme+":":"";a.host&&(b+="//",a.userinfo&&(b+=a.userinfo+"@"),b+=a.host,a.port&&(b+=":"+a.port));b+=a.path;a.query&&(b+="?"+a.query);a.fragment&&(b+="#"+a.fragment);a=b}else a=this._input;return a},set:function(c){b(c);this._input=c;this._url=a(this._input,this._baseURL)},enumerable:!0},origin:{get:function(){return this._url&&this._url.host?this.protocol+"//"+this.host:""},enumerable:!0},protocol:{get:function(){return this._url?
this._url.scheme+":":":"},set:function(a){b(a);if(this._url&&(a=a.slice(-1)===":"?a.substring(0,a.length-1):a,u.test(a)))this._url.scheme=a.toLowerCase()},enumerable:!0},_userinfo:{get:function(){return this._url?this._url.userinfo:""},set:function(a){b(a);if(this._url)this._url.userinfo=a}},username:{get:function(){if(!this._url)return"";var a=r.exec(this._userinfo);return decodeURIComponent(a[1]||"")},set:function(a){b(a);if(this._url){var c=r.exec(this._userinfo),a=[encodeURIComponent(a||"")];
c[2]&&a.push(c[2]);this._userinfo=a.join(":")}},enumerable:!0},password:{get:function(){if(!this._url)return"";var a=r.exec(this._userinfo);return decodeURIComponent(a[2]||"")},set:function(a){b(a);if(this._url){var c=[r.exec(this._userinfo)[1]||""];a&&c.push(encodeURIComponent(a));this._userinfo=c.join(":")}},enumerable:!0},host:{get:function(){var a="";this._url&&this._url.host&&(a+=this._url.host,this._url.port&&(a+=":"+this._url.port));return a},set:function(a){b(a);if(this._url&&(a=q.exec(a)))this._url.host=
a[1],this._url.port=/[1-9]\d*$/.exec(a[2])[0]},enumerable:!0},hostname:{get:function(){return this._url?this._url.host:""},set:function(a){b(a);if(this._url&&p.exec(a))this._url.host=a},enumerable:!0},port:{get:function(){var a=this._url?this._url.port||"":"";a&&a===y[this.protocol]&&(a="");return a},set:function(a){b(a);if(this._url&&v.exec(a))this._url.port=/[1-9]\d*$/.exec(a)[0]},enumerable:!0},pathname:{get:function(){return this._url?this._url.path:""},set:function(a){b(a);if(this._url&&s.exec(a))this._url.host&&
a&&a[0]!=="/"&&(a="/"+a),this._url.path=a?f(a):""},enumerable:!0},search:{get:function(){return this._url&&this._url.query?"?"+this._url.query:""},set:function(a){b(a);if(this._url&&(a&&a[0]==="?"&&(a=a.substring(1)),n.exec(a)))this._url.query=a},enumerable:!0},hash:{get:function(){return this._url&&this._url.fragment?"#"+this._url.fragment:""},set:function(a){b(a);if(this._url&&(a&&a[0]==="#"&&(a=a.substring(1)),t.exec(a)))this._url.fragment=a},enumerable:!0}});window.URL&&window.URL.createObjectURL&&
(Object.defineProperty(l,"createObjectURL",{value:window.URL.createObjectURL.bind(window.URL),enumerable:!1}),Object.defineProperty(l,"revokeObjectURL",{value:window.URL.revokeObjectURL.bind(window.URL),enumerable:!1}));window.URL=l})();define("orion/URL-shim",function(){});
define("domReady",[],function(){function b(){if(!e){e=!0;g&&clearInterval(g);var a=c;if(e&&a.length){c=[];var b;for(b=0;b<a.length;b+=1)a[b](f)}}}function h(a){e?a(f):c.push(a);return h}var k,i,g,d=typeof window!=="undefined"&&window.document,e=!d,f=d?document:null,c=[];if(d){if(document.addEventListener)document.addEventListener("DOMContentLoaded",b,!1),window.addEventListener("load",b,!1);else if(window.attachEvent){window.attachEvent("onload",b);i=document.createElement("div");try{k=window.frameElement===
null}catch(a){}i.doScroll&&k&&window.external&&(g=setInterval(function(){try{i.doScroll(),b()}catch(a){}},30))}document.readyState==="complete"&&b()}h.version="2.0.1";h.load=function(a,b,c,d){d.isBuild?c(null):h(c)};return h});
define('built-taskPlugin.js',"orion/xhr,orion/plugin,orion/operation,orion/Deferred,orion/URL-shim,domReady!".split(","),function(b,h,k,i){function g(b){b&&typeof b==="object"&&Object.keys(b).forEach(function(c){var a=b[c];c.indexOf("Location")!==-1?(d.href=a,b[c]=d.href):g(a)});return b}var d=document.createElement("a");d.href="../mixloginstatic/LoginWindow.html";h=new h({name:"Orion Task Management Service",version:"1.0",description:"This plugin provides access to the tasks a user is currently running or ran recently, and provides management of those tasks.",
login:d.href});d.href="../task";var e=function(b){try{if(window.location.host===parent.location.host&&window.location.protocol===parent.location.protocol)return b.substring(parent.location.href.indexOf(parent.location.host)+parent.location.host.length)}catch(c){}return b}(d.href);h.registerService("orion.core.operation",{getOperations:function(d){var c=new URL(e,window.location);d&&typeof d==="object"&&Object.keys(d).forEach(function(a){c.query.set(a,d[a])});return b("GET",c.href,{headers:{"Orion-Version":"1"},
timeout:d.Longpolling?7E4:15E3}).then(function(a){a=a.response?JSON.parse(a.response):null;g(a);return a})},getOperation:function(b){return k.handle(b)},removeCompletedOperations:function(){return b("DELETE",e,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(b){b=b.response?JSON.parse(b.response):null;g(b);return b})},removeOperation:function(d){var c=new i;b("DELETE",d,{headers:{"Orion-Version":"1"},timeout:15E3}).then(function(a){a=a.response?JSON.parse(a.response):null;g(a);c.resolve(a)},
function(a){var b=a;if(a.responseText){b=a.responseText;try{b=JSON.parse(a.responseText)}catch(d){}}b.Message?c.reject(b):c.reject({Severity:"Error",Message:b})});return c}},{name:"Tasks",pattern:e});h.connect()});