(function(a){function w(a){var b,c;for(var d in u.matchers)if(b=a.match(d)){c=u.matchers[d](a);return c}}function v(a){var b=[];for(var c=0,d;d=a[c];c++)typeof d=="string"&&(d=w(d)),l(d)&&(d=new s(v(d))),b.push(d);return b}function u(){var a=k(arguments),b;typeof a[a.length-1]=="function"&&(b=a.pop());var c=new r(v(a));b&&c.then(b);return c}function t(){var a=k(arguments),b,c;typeof a[0]=="string"&&(b=a.shift()),c=a.shift();return h=new q(b,c)}function s(a){this.deps=a}function r(a){this.deps=a}function q(a,b){this.id=a,this.body=b,typeof b=="undefined"&&(this.path=this.resolvePath(a))}function p(a,b){this.path=a,this.force=!!b}function o(){}function n(){var a=k(arguments),b=[];for(var c=0,d=a.length;c<d;c++)a[c].length>0&&b.push(a[c].replace(/\/$/,""));return b.join("/")}function m(a,b){for(var c=0,d;d=a[c];c++)if(b==d)return c;return-1}function k(a){return Array.prototype.slice.call(a)}var b=a.document,c=b.getElementsByTagName("script"),d,e=b.createElement("script"),f={},g={},h;for(var i=0,j;j=c[i];i++)if(j.src.match(/loadrunner\.js(\?|#|$)/)){d=j;break}var l=Array.isArray||function(a){return a.constructor==Array};o.prototype.then=function(a){this.started||(this.started=!0,this.start()),this.completed?a.apply(this,this.results):(this.callbacks=this.callbacks||[],this.callbacks.push(a));return this},o.prototype.start=function(){},o.prototype.complete=function(){if(!this.completed){this.results=k(arguments),this.completed=!0;if(this.callbacks)for(var a=0,b;b=this.callbacks[a];a++)b.apply(this,this.results)}},p.loaded=[],p.prototype=new o,p.prototype.start=function(){var a=this,b;if(b=f[this.path])b.then(function(){a.loaded()});else if(!this.force&&m(p.loaded,this.path)>-1)this.loaded();else{f[this.path]=a;var d=function(){a.loaded()},g=e.cloneNode(!1);g.type="text/javascript",g.async=!0,g.onload=d,g.onerror=function(){throw new Error(a.path+" not loaded")},g.onreadystatechange=function(){m(["loaded","complete"],this.readyState)>-1&&(this.onreadystatechange=null,d())},g.src=this.path,c[0].parentNode.insertBefore(g,c[0])}return this},p.prototype.loaded=function(){this.mark(),this.complete()},p.prototype.mark=function(){delete f[this.path],m(p.loaded,this.path)==-1&&p.loaded.push(this.path)},q.exports={},q.prototype=new p,q.prototype.resolvePath=function(a){return n(u.path,a+".js")},q.prototype.start=function(){var a,b,c=this;this.body?this.execute():(a=q.exports[this.id])?this.exp(a):(b=g[this.id])?b.then(function(a){c.exp(a)}):(g[this.id]=this,p.prototype.start.call(this))},q.prototype.loaded=function(){var a=this;this.mark();if(h)h.id=this.id,h.then(function(b){delete g[a.id],a.exp(b)}),h=null;else throw new Error("Module "+this.id+" was not defined in "+this.path)},q.prototype.execute=function(){var a=this;typeof this.body=="object"?this.exp(this.body):typeof this.body=="function"&&this.body(function(b){a.exp(b)})},q.prototype.exp=function(a){this.complete(this.exports=q.exports[this.id]=a)},r.prototype=new o,r.prototype.start=function(){function b(){var b=[];for(var c=0,d;d=a.deps[c];c++){if(!d.completed)return;d.results.length>0&&(b=b.concat(d.results))}a.complete.apply(a,b)}var a=this;for(var c=0,d;d=this.deps[c];c++)d.then(b);return this},s.prototype=new o,s.prototype.start=function(){var a=this,b=0,c=[];(function d(){var e=a.deps[b++];e?e.then(function(a){e.results.length>0&&c.concat(e.results),d()}):a.complete(c)})();return this},u.path="",u.matchers={},u.matchers["\\.js$"]=function(a){return new p(a.replace(/^\$/,u.path.replace(/\/$/,"")+"/"))},u.matchers["^[a-zA-Z0-9_\\-\\/]+$"]=function(a){return new q(a)},a.loadrunner={Script:p,Module:q,Collection:r,Sequence:s,Dependency:o},a.using=u,a.provide=t,d&&(u.path=d.getAttribute("data-path")||d.src.split(/loadrunner\.js/)[0]||"",(main=d.getAttribute("data-main"))&&u.apply(a,main.split(/\s*,\s*/)).then(function(){}))})(this)
