/** * modulr-js v1.2.5 | 2017-11-28 * A Javascript Psuedo-AMD Browser Dependency Manager * by Helcon Mabesa * MIT **/ var Modulr=function(a,b){return a.Modulr||b}(window,function(a){function b(a,b){var c=null;return c="function"==typeof a?a.apply(a,b):a}function c(a){var b=a.split("."),c=window[b.shift()],d=!1;if("undefined"!=typeof c&&(d=!0,b.length>0))for(;b.length>0;)if(c=c[b.shift()],"undefined"==typeof c){d=!1;break}return d}function d(a){var b="string"==typeof a?a.replace(/\s+/gi,""):"";return b.length>0&&"require"!==b&&"define"!==b&&"exports"!==b?!0:!1}function e(a){var b=/[^A-Za-z0-9_\-\.]/g.test(a);return"string"!=typeof a||b?!1:!0}function f(){var a=window.location,b=a.pathname.split("/");return b.pop(),b=b.join("/")+"/",g()+b}function g(){var a=window.location;return a.protocol+"//"+(a.host||a.hostname)}function h(a,b){return a=o(a),b=m(b),[a,b].join("/")}function i(a){var b=a,c=window.location.protocol;return 0!==a.indexOf("http")&&(b=c+(0!==a.indexOf("//")?"//":"")+a),b}function j(a){for(var b=[],c=0;c0;){var a=E.shift();a()}};F?F(a):a()};a(function(){D||I()});var J="undefined"!=typeof opera&&"[object Opera]"===opera.toString()?!0:!1,K=/^(complete|loaded)$/,L=function(a){function m(a){a=N(a);var b=null,c="module",d=T(a);return d?"module"===d.type?b=t[d.context].stack[d.id]:"instance"===d.type&&(b=t[d.context].instance,c="instance"):b=aa[a],"module"===c&&(b&&!b.executed&&r("module not yet executed: '"+a+"'"),b=b?"undefined"!=typeof b.factory?b.factory:b.exports:null),b}function s(b){a.baseDomain=i(a.baseDomain)||g(),a.baseUrl=a.baseUrl||f();var c=function(){ca=!0,b()};V(function(){W(a.packages,function(){c()})})}function M(){if(u[_])for(var a=t[_].instance;u[_].length>0;){var b=u[_].shift();a.define(b.ext.id,b.deps,b.factory)}}function N(b){if(a.paths)for(var c in a.paths)b=b.replace(c,a.paths[c]);return b=b.replace(/\/\//g,"/").replace(/^\//,"")}function O(a){if(C[a])for(;C[a].length>0;){var b=C[a].shift();b()}}function P(a){return aa[a]||!1}function Q(){return[o(a.baseDomain||g()),n(a.baseUrl||f())].join("/")}function R(a,b){var c=a.split(":"),d=c[0]||!1,e=c[1]||!1;if(d&&e&&t[d]){var f=t[d].instance;t[d].stack[e]?f.execModule(e,function(a){b(a)}):f.require([e],function(){f.execModule(e,function(a){b(a)})})}else q(["Not initialized >> CONTEXT: ",d," | module: ",e].join("")),b(null)}function S(a){return t[a]?t[a].instance:void r("Error getting instance: "+a)}function T(a){var b=a.indexOf(":")>-1?!0:!1,c=a.split(":"),d=c[0]||!1,e=c[1]||!1,f=!1;return b&&("getInstance"===d&&e?f={type:"instance",context:e}:d&&e&&(f={type:"module",context:d,id:e})),f}function U(){if(!a.shim)return!1;var b=[];for(var c in a.shim)b.push({id:c,info:a.shim[c]});for(var d=function(a){var b=a.id,c=a.info,d=(X(c.src),c.deps||[]);da.define(b,d,function(){return Z(c.exports)})};b.length>0;)d(b.shift())}function V(b){if(a.masterFile)if(B.indexOf(a.masterFile)>-1)b();else{var c=X(a.masterFile);A||(A=[]),-1===A.indexOf(c)?(A.push(c),$(c,null,function(){b()})):b()}else b()}function W(a,b){if(a){var c=[],d=function(a){for(var b in a)z[b]||(z[b]=a[b]),c.push({uid:b,src:a[b]})};if(p(a))for(var e=0;e0;){var c=b.shift();c()}delete y[a]},h=function(){if(0===c.length)b();else{var a=c.shift(),d=a.uid,e=X(a.src);t[d]?h():x[e]?(y[e]||(y[e]=[]),y[e].push(function(){h()})):(x[e]=d,$(e,d,function(){h(),y[e]&&g(e)},"instance"))}};h()}else b()}function X(b){var c=b;return 0!==b.indexOf("http")&&(c=0===b.indexOf("//")?i(b):a.baseDomain+("/"!==b.charAt(0)?"/":"")+b),c}function Y(b){return a.shim&&a.shim[b]?!0:!1}function Z(a){return window[a.split(".")[0]]}function $(b,c,d,e,f){f=f||{};var g=!1,h=document.createElement("script"),i=[_||"",b].join("||"),j=f.noCacheString||null,m=k(b),n=function(){var a=null;return a=m&&m.noStore===!0?!0:j===!0?null:f.noStore}(),o=function(){var a=null;return a=m&&"string"==typeof m.param?m.param:f.queryParam}(),p=function(a){if(!g&&"load"===a.type||K.test((a.currentTarget||a.srcElement).readyState)){for(g=!0;w[i].length>0;){var b=w[i].shift();b()}delete w[i],s()}},q=function(){r("error loading script: "+b)},s=function(){l(h,p,"load","onreadystatechange"),l(h,q,"error")};if(c){var t="data-modulr-module";e&&(t="data-modulr-loaded-inst"),h.setAttribute(t,c)}return h.setAttribute("data-modulr-context",_),v[i]?(w[i].push(function(){d(c)}),!1):(v[i]=!0,w[i]=[function(){d(c)}],h.type="text/javascript",h.charset="utf-8",h.async=!0,!h.attachEvent||h.attachEvent.toString&&h.attachEvent.toString().indexOf("[native code")<0||J?(h.addEventListener("load",p,!1),h.addEventListener("error",q,!1)):h.attachEvent("onreadystatechange",p),h.src=function(b){var c=b;if(m&&n&&o)c=b+(b.indexOf("?")>-1?"&":"?")+(o?o+"=":"")+(new Date).getTime();else if((a&&a.cacheParam||G)&&!j){var d=o?o:"string"==typeof a.cacheParam?a.cacheParam:G?"v":"",e=function(){var a;if(n)a=(new Date).getTime();else if(G)a=G;else{var b=new Date,c=b.getSeconds(),d=[b.getFullYear(),b.getMonth()+1,b.getDate(),b.getHours(),b.getMinutes()].join("");a=d+(30>=c?30:1)}return a}();c=b+(b.indexOf("?")>-1?"&":"?")+(d?d+"=":"")+e}return c}(b),void document.getElementsByTagName("head")[0].appendChild(h))}a=a||{},a.context=a.instance||a.context||"_",a.wait="boolean"==typeof a.wait?a.wait:!0;var _=a.context;if(e(_)||r("invalid context: '"+_+"'"),t[_])return q("WARNING: attempt to instantiate the same context: "+_+"\n. No configuration changes, returning instance instead.."),t[_].instance;t[_]={instance:this,stack:{}};var aa=t[_].stack,ba=!1,ca=!1,da=this;da.version="1.2.5",da.getConfig=function(){return a},da.setMasterLoaded=function(a){a&&B.push(a)},da.getInstance=function(a){return t[a]?t[a].instance:null},da.setExecuteListener=function(a){F||"function"!=typeof a||(F=a)},da.getLoadedScripts=function(){var a={};for(var b in v){var c=b.split("||"),d=c[0],e=c[1]||"";d&&e&&(a[d]||(a[d]=[]),a[d].push(e))}return a},da.define=function(a,b,c){d(a)||r("invalid id: '"+a+"'."),2!==arguments.length||p(b)||(c=b,b=[]),a=N(a);var e=T(a);if(e)if(t[e.context]){var f=t[e.context].instance;f.define(e.id,b,c)}else u[e.context]||(u[e.context]=[]),u[e.context].push({ext:e,deps:b,factory:c});else aa[a]||(b=b||[],aa[a]={executed:!1,exports:{},deps:b,factory:c})},da.require=function(c,d){if("string"==typeof c)return m(c);if(p(c)){var e=function(){ea.get(null,c,function(a){b(d,a)})},f=function(){ba?e():(ba=!0,s(function(){e()}))};a.wait?D?f():E.push(f):f()}},da.config=function(b){if(b.context||b.instance){var c=new L(b);return c.config&&delete c.config,c.getInstance&&delete c.getInstance,c.loadPackageList&&delete c.loadPackageList,c.setGlobalCacheParam&&delete c.setGlobalCacheParam,c.setGlobalCacheCond&&delete c.setGlobalCacheCond,c.setExecuteListener&&delete c.setExecuteListener,c.loadPackage=function(a,b){"function"!=typeof b&&r("loadPackage() requires a callback!"),p(a)||"object"!=typeof a?r("cannot load package list."):W(a,b.apply(b,da.require))},c}return ba?(q("WARNING: Instance '"+b.instance+"' already exists! no configuration changes, returning instance instead.."),da.getInstance(b.instance)):void(a=b)},da.execModule=function(a,b){var c=P(a);return"function"!=typeof b?!1:void(c?c.executed?b(ea.getModuleFactory(c)):ea.execModule(null,null,a,function(a){b(a)}):b(null))},da.loadPackageList=function(a){if(p(a)||"object"!=typeof a)r("cannot load package list.");else for(var b in a)z[b]||(z[b]=a[b])},da.setGlobalCacheParam=function(a){("string"==typeof a||"number"==typeof a)&&(G=a)},da.setGlobalCacheCond=function(a){Array.isArray(a)&&(H=H.concat(a))},da.getGlobalCacheParam=function(){return G},da.getPackageListInfo=function(){return{master:A,instances:z}},da.setReady=function(){I()},M(),U();var ea=function(){var d=function(){var d=this;d.get=function(b,c,e){var f,g=[];c?f=j(c):b&&aa[b]&&(f=j(aa[b].deps));var h=function(){if(0===f.length)e(g);else{var c=N(f.shift()),i=P(c),j=T(c);if(j)"module"===j.type?R(c,function(a){g.push("undefined"!=typeof a?a:null),h()}):"instance"===j.type&&(g.push(S(j.context)),h());else if("require"===c)g.push(da.require),h();else if("define"===c)g.push(da.define),h();else if("exports"===c)g.push(aa[b].exports),h();else if(i&&!Y(c))i.executed?(g.push(d.getModuleFactory(i)),h()):d.execModule(null,null,c,function(a){g.push(a),h()});else if(Y(c)){var k=a.shim[c];d.loadShim(c,k,function(a){g.push(a),h()})}else{var l=d.getModulePath(c);$(l,c,function(){d.execModule("load",l,c,function(a){g.push(a),h()})})}}};h()},d.loadShim=function(a,b,e){var f=X(b.src),g=P(a);c(b.exports)?(g.executed=!0,g.factory=Z(b.exports),e(g.factory)):C[f]?C[f].push(function(){d.execModule("shim",null,a,function(a){e(a)})}):(C[f]=[function(){d.execModule("shim",null,a,function(a){e(a)})}],$(f,a,function(){c(b.exports)?O(f):r("shim export not found for: '"+a+"'")},null,{noCacheString:b.noCacheString||null,noStore:b.noStore||null,queryParam:b.queryParam||null}))},d.execModule=function(a,c,e,f){var g=P(e);g?g.executed?f(d.getModuleFactory(g)):(d._execQueue||(d._execQueue={}),d._execQueue[e]||(d._execQueue[e]=[]),g.executing?d._execQueue[e].push(f):(g.executing=!0,d._execQueue[e].push(f),d.get(e,g.deps,function(a){g.factory=b(g.factory,a),g.executed=!0,g.executing=!1,d.runCallbackQueue(e,d.getModuleFactory(g))}))):(q("loading external source: "+c),f({id:e,src:c,type:"external-script"}))},d.runCallbackQueue=function(a,b){for(var c=d._execQueue[a]||[];c.length>0;){var e=c.shift();e(b)}},d.getModuleFactory=function(a){return null!==a.factory?a.factory:a.exports},d.getModulePath=function(a){var b=Q(),c=h(b,a)+".js";return c}};return new d}()};return new L}(function(){var a=function(a){function b(a){for(n=1;a=d.shift();)a()}var c,d=[],e=!1,f=document,g=f.documentElement,h=g.doScroll,i="DOMContentLoaded",j="addEventListener",k="onreadystatechange",l="readyState",m=h?/^loaded|^c/:/^loaded|c/,n=m.test(f[l]);return f[j]&&f[j](i,c=function(){f.removeEventListener(i,c,e),b()},e),h&&f.attachEvent(k,c=function(){/^c/.test(f[l])&&(f.detachEvent(k,c),b())}),ready=h?function(a){self!=top?n?a():d.push(a):function(){try{g.doScroll("left")}catch(b){return setTimeout(function(){ready(a)},50)}a()}()}:function(a){n?a():d.push(a)}}();return a}()));