dsc-auth
Version:
An Oauth platform built on Qr Codes for DSC
631 lines (569 loc) • 29 kB
JavaScript
(function(FuseBox){FuseBox.$fuse$=FuseBox;
FuseBox.target = "browser";
FuseBox.pkg("default", {}, function(___scope___){
___scope___.file("client.js", function(exports, require, module, __filename, __dirname){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
let Authentication = new index_1.default("PegkrfzjTWDtjSHpTypTgXAmsBTAnexo");
Authentication.init((details) => {
console.log(details);
}, true);
Authentication.getQr().then((image) => {
let img = document.createElement('img');
img.src = "data:image/png;base64," + image;
document.body.appendChild(img);
});
});
___scope___.file("index.js", function(exports, require, module, __filename, __dirname){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Auth {
constructor(API_KEY) {
this.isInitialized = false;
this.endpoint = "secure-stream-87726.herokuapp.com";
this.key = API_KEY;
this.socket = new WebSocket(`wss://${this.endpoint}/qr`);
this.init = this.init.bind(this);
this.getQr = this.getQr.bind(this);
this.destroy = this.destroy.bind(this);
this.continousPing = this.continousPing.bind(this);
}
continousPing() {
this.cPing = setInterval(() => {
this.socket.send("ping");
}, 40000);
}
init(detailsHandler, ping = false) {
this.isInitialized = true;
this.shouldPing = ping;
this.onRecieveUserDetails = this.onRecieveUserDetails.bind(this, detailsHandler);
}
destroy() {
clearInterval(this.cPing);
this.socket.close();
}
getQr() {
let self = this;
if (!self.isInitialized) {
throw "The module is not initialized; call init(...) before getQr()";
}
return new Promise(function (resolve, reject) {
self.socket.onopen = function () {
self.socket.send(JSON.stringify({
"project_name": "Frontend-test",
"api_key": self.key,
"domain_name": "localhost"
}));
if (self.shouldPing)
self.continousPing();
self.socket.onmessage = function (event) {
let data = JSON.parse(event.data);
if (data.ImageQR !== undefined) {
resolve(data.ImageQR);
}
else if (data.message === "success") {
self.onRecieveUserDetails(data);
}
};
};
});
}
onRecieveUserDetails(userDetailsHandler, data) {
let self = this;
userDetailsHandler(data.details);
self.destroy();
}
}
exports.default = Auth;
});
return ___scope___.entry = "client.js";
});
FuseBox.pkg("events", {}, function(___scope___){
___scope___.file("index.js", function(exports, require, module, __filename, __dirname){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
if (FuseBox.isServer) {
module.exports = global.require("events");
} else {
function EventEmitter() {
this._events = this._events || {};
this._maxListeners = this._maxListeners || undefined;
}
module.exports = EventEmitter;
// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._maxListeners = undefined;
// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
EventEmitter.defaultMaxListeners = 10;
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function(n) {
if (!isNumber(n) || n < 0 || isNaN(n))
throw TypeError("n must be a positive number");
this._maxListeners = n;
return this;
};
EventEmitter.prototype.emit = function(type) {
var er, handler, len, args, i, listeners;
if (!this._events)
this._events = {};
// If there is no 'error' event listener then throw.
if (type === "error") {
if (!this._events.error ||
(isObject(this._events.error) && !this._events.error.length)) {
er = arguments[1];
if (er instanceof Error) {
throw er; // Unhandled 'error' event
}
throw TypeError("Uncaught, unspecified \"error\" event.");
}
}
handler = this._events[type];
if (isUndefined(handler))
return false;
if (isFunction(handler)) {
switch (arguments.length) {
// fast cases
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
// slower
default:
args = Array.prototype.slice.call(arguments, 1);
handler.apply(this, args);
}
} else if (isObject(handler)) {
args = Array.prototype.slice.call(arguments, 1);
listeners = handler.slice();
len = listeners.length;
for (i = 0; i < len; i++)
listeners[i].apply(this, args);
}
return true;
};
EventEmitter.prototype.addListener = function(type, listener) {
var m;
if (!isFunction(listener))
throw TypeError("listener must be a function");
if (!this._events)
this._events = {};
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (this._events.newListener)
this.emit("newListener", type,
isFunction(listener.listener) ?
listener.listener : listener);
if (!this._events[type])
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
else if (isObject(this._events[type]))
// If we've already got an array, just append.
this._events[type].push(listener);
else
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
// Check for listener leak
if (isObject(this._events[type]) && !this._events[type].warned) {
if (!isUndefined(this._maxListeners)) {
m = this._maxListeners;
} else {
m = EventEmitter.defaultMaxListeners;
}
if (m && m > 0 && this._events[type].length > m) {
this._events[type].warned = true;
console.error("(node) warning: possible EventEmitter memory " +
"leak detected. %d listeners added. " +
"Use emitter.setMaxListeners() to increase limit.",
this._events[type].length);
if (typeof console.trace === "function") {
// not supported in IE 10
console.trace();
}
}
}
return this;
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.once = function(type, listener) {
if (!isFunction(listener))
throw TypeError("listener must be a function");
var fired = false;
function g() {
this.removeListener(type, g);
if (!fired) {
fired = true;
listener.apply(this, arguments);
}
}
g.listener = listener;
this.on(type, g);
return this;
};
// emits a 'removeListener' event iff the listener was removed
EventEmitter.prototype.removeListener = function(type, listener) {
var list, position, length, i;
if (!isFunction(listener))
throw TypeError("listener must be a function");
if (!this._events || !this._events[type])
return this;
list = this._events[type];
length = list.length;
position = -1;
if (list === listener ||
(isFunction(list.listener) && list.listener === listener)) {
delete this._events[type];
if (this._events.removeListener)
this.emit("removeListener", type, listener);
} else if (isObject(list)) {
for (i = length; i-- > 0;) {
if (list[i] === listener ||
(list[i].listener && list[i].listener === listener)) {
position = i;
break;
}
}
if (position < 0)
return this;
if (list.length === 1) {
list.length = 0;
delete this._events[type];
} else {
list.splice(position, 1);
}
if (this._events.removeListener)
this.emit("removeListener", type, listener);
}
return this;
};
EventEmitter.prototype.removeAllListeners = function(type) {
var key, listeners;
if (!this._events)
return this;
// not listening for removeListener, no need to emit
if (!this._events.removeListener) {
if (arguments.length === 0)
this._events = {};
else if (this._events[type])
delete this._events[type];
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
for (key in this._events) {
if (key === "removeListener") continue;
this.removeAllListeners(key);
}
this.removeAllListeners("removeListener");
this._events = {};
return this;
}
listeners = this._events[type];
if (isFunction(listeners)) {
this.removeListener(type, listeners);
} else if (listeners) {
// LIFO order
while (listeners.length)
this.removeListener(type, listeners[listeners.length - 1]);
}
delete this._events[type];
return this;
};
EventEmitter.prototype.listeners = function(type) {
var ret;
if (!this._events || !this._events[type])
ret = [];
else if (isFunction(this._events[type]))
ret = [this._events[type]];
else
ret = this._events[type].slice();
return ret;
};
EventEmitter.prototype.listenerCount = function(type) {
if (this._events) {
var evlistener = this._events[type];
if (isFunction(evlistener))
return 1;
else if (evlistener)
return evlistener.length;
}
return 0;
};
EventEmitter.listenerCount = function(emitter, type) {
return emitter.listenerCount(type);
};
function isFunction(arg) {
return typeof arg === "function";
}
function isNumber(arg) {
return typeof arg === "number";
}
function isObject(arg) {
return typeof arg === "object" && arg !== null;
}
function isUndefined(arg) {
return arg === void 0;
}
}
});
return ___scope___.entry = "index.js";
});
FuseBox.pkg("fusebox-hot-reload", {}, function(___scope___){
___scope___.file("index.js", function(exports, require, module, __filename, __dirname){
"use strict";
/**
* @module listens to `source-changed` socket events and actions hot reload
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Client = require('fusebox-websocket').SocketClient, bundleErrors = {}, outputElement = document.createElement('div'), styleElement = document.createElement('style'), minimizeToggleId = 'fuse-box-toggle-minimized', hideButtonId = 'fuse-box-hide', expandedOutputClass = 'fuse-box-expanded-output', localStoragePrefix = '__fuse-box_';
function storeSetting(key, value) {
localStorage[localStoragePrefix + key] = value;
}
function getSetting(key) {
return localStorage[localStoragePrefix + key] === 'true' ? true : false;
}
var outputInBody = false, outputMinimized = getSetting(minimizeToggleId), outputHidden = false;
outputElement.id = 'fuse-box-output';
styleElement.innerHTML = "\n #" + outputElement.id + ", #" + outputElement.id + " * {\n box-sizing: border-box;\n }\n #" + outputElement.id + " {\n z-index: 999999999999;\n position: fixed;\n top: 10px;\n right: 10px;\n width: 400px;\n overflow: auto;\n background: #fdf3f1;\n border: 1px solid #eca494;\n border-radius: 5px;\n font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n box-shadow: 0px 3px 6px 1px rgba(0,0,0,.15);\n }\n #" + outputElement.id + "." + expandedOutputClass + " {\n height: auto;\n width: auto;\n left: 10px;\n max-height: calc(100vh - 50px);\n }\n #" + outputElement.id + " .fuse-box-errors {\n display: none;\n }\n #" + outputElement.id + "." + expandedOutputClass + " .fuse-box-errors {\n display: block;\n border-top: 1px solid #eca494;\n padding: 0 10px;\n }\n #" + outputElement.id + " button {\n border: 1px solid #eca494;\n padding: 5px 10px;\n border-radius: 4px;\n margin-left: 5px;\n background-color: white;\n color: black;\n box-shadow: 0px 2px 2px 0px rgba(0,0,0,.05);\n }\n #" + outputElement.id + " .fuse-box-header {\n padding: 10px;\n }\n #" + outputElement.id + " .fuse-box-header h4 {\n display: inline-block;\n margin: 4px;\n }";
styleElement.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(styleElement);
function displayBundleErrors() {
var errorMessages = Object.keys(bundleErrors).reduce(function (allMessages, bundleName) {
var bundleMessages = bundleErrors[bundleName];
return allMessages.concat(bundleMessages.map(function (message) {
var messageOutput = message
.replace(/\n/g, '<br>')
.replace(/\t/g, ' &nbps;&npbs;&nbps;')
.replace(/ /g, ' ');
return "<pre>" + messageOutput + "</pre>";
}));
}, []), errorOutput = errorMessages.join('');
if (errorOutput && !outputHidden) {
outputElement.innerHTML = "\n <div class=\"fuse-box-header\" style=\"\">\n <h4 style=\"\">Fuse Box Bundle Errors (" + errorMessages.length + "):</h4>\n <div style=\"float: right;\">\n <button id=\"" + minimizeToggleId + "\">" + (outputMinimized ? 'Expand' : 'Minimize') + "</button>\n <button id=\"" + hideButtonId + "\">Hide</button>\n </div>\n </div>\n <div class=\"fuse-box-errors\">\n " + errorOutput + "\n </div>\n ";
document.body.appendChild(outputElement);
outputElement.className = outputMinimized ? '' : expandedOutputClass;
outputInBody = true;
document.getElementById(minimizeToggleId).onclick = function () {
outputMinimized = !outputMinimized;
storeSetting(minimizeToggleId, outputMinimized);
displayBundleErrors();
};
document.getElementById(hideButtonId).onclick = function () {
outputHidden = true;
displayBundleErrors();
};
}
else if (outputInBody) {
document.body.removeChild(outputElement);
outputInBody = false;
}
}
exports.connect = function (port, uri, reloadFullPage) {
if (FuseBox.isServer) {
return;
}
port = port || window.location.port;
var client = new Client({
port: port,
uri: uri,
});
client.connect();
client.on('page-reload', function (data) {
return window.location.reload();
});
client.on('page-hmr', function (data) {
FuseBox.flush();
FuseBox.dynamic(data.path, data.content);
if (FuseBox.mainFile) {
try {
FuseBox.import(FuseBox.mainFile);
}
catch (e) {
if (typeof e === 'string') {
if (/not found/.test(e)) {
return window.location.reload();
}
}
console.error(e);
}
}
});
client.on('source-changed', function (data) {
console.info("%cupdate \"" + data.path + "\"", 'color: #237abe');
if (reloadFullPage) {
return window.location.reload();
}
/**
* If a plugin handles this request then we don't have to do anything
**/
for (var index = 0; index < FuseBox.plugins.length; index++) {
var plugin = FuseBox.plugins[index];
if (plugin.hmrUpdate && plugin.hmrUpdate(data)) {
return;
}
}
if (data.type === "hosted-css") {
var fileId = data.path.replace(/^\//, '').replace(/[\.\/]+/g, '-');
var existing = document.getElementById(fileId);
if (existing) {
existing.setAttribute("href", data.path + "?" + new Date().getTime());
}
else {
var node = document.createElement('link');
node.id = fileId;
node.type = 'text/css';
node.rel = 'stylesheet';
node.href = data.path;
document.getElementsByTagName('head')[0].appendChild(node);
}
}
if (data.type === 'js' || data.type === "css") {
FuseBox.flush();
FuseBox.dynamic(data.path, data.content);
if (FuseBox.mainFile) {
try {
FuseBox.import(FuseBox.mainFile);
}
catch (e) {
if (typeof e === 'string') {
if (/not found/.test(e)) {
return window.location.reload();
}
}
console.error(e);
}
}
}
});
client.on('error', function (error) {
console.log(error);
});
client.on('bundle-error', function (_a) {
var bundleName = _a.bundleName, message = _a.message;
console.error("Bundle error in " + bundleName + ": " + message);
var errorsForBundle = bundleErrors[bundleName] || [];
errorsForBundle.push(message);
bundleErrors[bundleName] = errorsForBundle;
displayBundleErrors();
});
client.on('update-bundle-errors', function (_a) {
var bundleName = _a.bundleName, messages = _a.messages;
messages.forEach(function (message) { return console.error("Bundle error in " + bundleName + ": " + message); });
bundleErrors[bundleName] = messages;
displayBundleErrors();
});
};
});
return ___scope___.entry = "index.js";
});
FuseBox.pkg("fusebox-websocket", {}, function(___scope___){
___scope___.file("index.js", function(exports, require, module, __filename, __dirname){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var events = require('events');
var SocketClient = /** @class */ (function () {
function SocketClient(opts) {
opts = opts || {};
var port = opts.port || window.location.port;
var protocol = location.protocol === 'https:' ? 'wss://' : 'ws://';
var domain = location.hostname || 'localhost';
this.url = opts.host || "" + protocol + domain + ":" + port;
if (opts.uri) {
this.url = opts.uri;
}
this.authSent = false;
this.emitter = new events.EventEmitter();
}
SocketClient.prototype.reconnect = function (fn) {
var _this = this;
setTimeout(function () {
_this.emitter.emit('reconnect', { message: 'Trying to reconnect' });
_this.connect(fn);
}, 5000);
};
SocketClient.prototype.on = function (event, fn) {
this.emitter.on(event, fn);
};
SocketClient.prototype.connect = function (fn) {
var _this = this;
console.log('%cConnecting to fusebox HMR at ' + this.url, 'color: #237abe');
setTimeout(function () {
_this.client = new WebSocket(_this.url);
_this.bindEvents(fn);
}, 0);
};
SocketClient.prototype.close = function () {
this.client.close();
};
SocketClient.prototype.send = function (eventName, data) {
if (this.client.readyState === 1) {
this.client.send(JSON.stringify({ event: eventName, data: data || {} }));
}
};
SocketClient.prototype.error = function (data) {
this.emitter.emit('error', data);
};
/** Wires up the socket client messages to be emitted on our event emitter */
SocketClient.prototype.bindEvents = function (fn) {
var _this = this;
this.client.onopen = function (event) {
console.log('%cConnected', 'color: #237abe');
if (fn) {
fn(_this);
}
};
this.client.onerror = function (event) {
_this.error({ reason: event.reason, message: 'Socket error' });
};
this.client.onclose = function (event) {
_this.emitter.emit('close', { message: 'Socket closed' });
if (event.code !== 1011) {
_this.reconnect(fn);
}
};
this.client.onmessage = function (event) {
var data = event.data;
if (data) {
var item = JSON.parse(data);
_this.emitter.emit(item.type, item.data);
_this.emitter.emit('*', item);
}
};
};
return SocketClient;
}());
exports.SocketClient = SocketClient;
});
return ___scope___.entry = "index.js";
});
FuseBox.import("fusebox-hot-reload").connect(4444, "", false)
FuseBox.import("default/client.js");
FuseBox.main("default/client.js");
})
(function(e){function r(e){var r=e.charCodeAt(0),n=e.charCodeAt(1);if((m||58!==n)&&(r>=97&&r<=122||64===r)){if(64===r){var t=e.split("/"),i=t.splice(2,t.length).join("/");return[t[0]+"/"+t[1],i||void 0]}var o=e.indexOf("/");if(o===-1)return[e];var a=e.substring(0,o),f=e.substring(o+1);return[a,f]}}function n(e){return e.substring(0,e.lastIndexOf("/"))||"./"}function t(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=[],t=0,i=arguments.length;t<i;t++)n=n.concat(arguments[t].split("/"));for(var o=[],t=0,i=n.length;t<i;t++){var a=n[t];a&&"."!==a&&(".."===a?o.pop():o.push(a))}return""===n[0]&&o.unshift(""),o.join("/")||(o.length?"/":".")}function i(e){var r=e.match(/\.(\w{1,})$/);return r&&r[1]?e:e+".js"}function o(e){if(m){var r,n=document,t=n.getElementsByTagName("head")[0];/\.css$/.test(e)?(r=n.createElement("link"),r.rel="stylesheet",r.type="text/css",r.href=e):(r=n.createElement("script"),r.type="text/javascript",r.src=e,r.async=!0),t.insertBefore(r,t.firstChild)}}function a(e,r){for(var n in e)e.hasOwnProperty(n)&&r(n,e[n])}function f(e){return{server:require(e)}}function u(e,n){var o=n.path||"./",a=n.pkg||"default",u=r(e);if(u&&(o="./",a=u[0],n.v&&n.v[a]&&(a=a+"@"+n.v[a]),e=u[1]),e)if(126===e.charCodeAt(0))e=e.slice(2,e.length),o="./";else if(!m&&(47===e.charCodeAt(0)||58===e.charCodeAt(1)))return f(e);var s=x[a];if(!s){if(m&&"electron"!==_.target)throw"Package not found "+a;return f(a+(e?"/"+e:""))}e=e?e:"./"+s.s.entry;var l,d=t(o,e),c=i(d),p=s.f[c];return!p&&c.indexOf("*")>-1&&(l=c),p||l||(c=t(d,"/","index.js"),p=s.f[c],p||"."!==d||(c=s.s&&s.s.entry||"index.js",p=s.f[c]),p||(c=d+".js",p=s.f[c]),p||(p=s.f[d+".jsx"]),p||(c=d+"/index.jsx",p=s.f[c])),{file:p,wildcard:l,pkgName:a,versions:s.v,filePath:d,validPath:c}}function s(e,r,n){if(void 0===n&&(n={}),!m)return r(/\.(js|json)$/.test(e)?h.require(e):"");if(n&&n.ajaxed===e)return console.error(e,"does not provide a module");var i=new XMLHttpRequest;i.onreadystatechange=function(){if(4==i.readyState)if(200==i.status){var n=i.getResponseHeader("Content-Type"),o=i.responseText;/json/.test(n)?o="module.exports = "+o:/javascript/.test(n)||(o="module.exports = "+JSON.stringify(o));var a=t("./",e);_.dynamic(a,o),r(_.import(e,{ajaxed:e}))}else console.error(e,"not found on request"),r(void 0)},i.open("GET",e,!0),i.send()}function l(e,r){var n=y[e];if(n)for(var t in n){var i=n[t].apply(null,r);if(i===!1)return!1}}function d(e){if(null!==e&&["function","object","array"].indexOf(typeof e)!==-1&&!e.hasOwnProperty("default"))return Object.isFrozen(e)?void(e.default=e):void Object.defineProperty(e,"default",{value:e,writable:!0,enumerable:!1})}function c(e,r){if(void 0===r&&(r={}),58===e.charCodeAt(4)||58===e.charCodeAt(5))return o(e);var t=u(e,r);if(t.server)return t.server;var i=t.file;if(t.wildcard){var a=new RegExp(t.wildcard.replace(/\*/g,"@").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&").replace(/@@/g,".*").replace(/@/g,"[a-z0-9$_-]+"),"i"),f=x[t.pkgName];if(f){var p={};for(var v in f.f)a.test(v)&&(p[v]=c(t.pkgName+"/"+v));return p}}if(!i){var g="function"==typeof r,y=l("async",[e,r]);if(y===!1)return;return s(e,function(e){return g?r(e):null},r)}var w=t.pkgName;if(i.locals&&i.locals.module)return i.locals.module.exports;var b=i.locals={},j=n(t.validPath);b.exports={},b.module={exports:b.exports},b.require=function(e,r){var n=c(e,{pkg:w,path:j,v:t.versions});return _.sdep&&d(n),n},m||!h.require.main?b.require.main={filename:"./",paths:[]}:b.require.main=h.require.main;var k=[b.module.exports,b.require,b.module,t.validPath,j,w];return l("before-import",k),i.fn.apply(k[0],k),l("after-import",k),b.module.exports}if(e.FuseBox)return e.FuseBox;var p="undefined"!=typeof ServiceWorkerGlobalScope,v="undefined"!=typeof WorkerGlobalScope,m="undefined"!=typeof window&&"undefined"!=typeof window.navigator||v||p,h=m?v||p?{}:window:global;m&&(h.global=v||p?{}:window),e=m&&"undefined"==typeof __fbx__dnm__?e:module.exports;var g=m?v||p?{}:window.__fsbx__=window.__fsbx__||{}:h.$fsbx=h.$fsbx||{};m||(h.require=require);var x=g.p=g.p||{},y=g.e=g.e||{},_=function(){function r(){}return r.global=function(e,r){return void 0===r?h[e]:void(h[e]=r)},r.import=function(e,r){return c(e,r)},r.on=function(e,r){y[e]=y[e]||[],y[e].push(r)},r.exists=function(e){try{var r=u(e,{});return void 0!==r.file}catch(e){return!1}},r.remove=function(e){var r=u(e,{}),n=x[r.pkgName];n&&n.f[r.validPath]&&delete n.f[r.validPath]},r.main=function(e){return this.mainFile=e,r.import(e,{})},r.expose=function(r){var n=function(n){var t=r[n].alias,i=c(r[n].pkg);"*"===t?a(i,function(r,n){return e[r]=n}):"object"==typeof t?a(t,function(r,n){return e[n]=i[r]}):e[t]=i};for(var t in r)n(t)},r.dynamic=function(r,n,t){this.pkg(t&&t.pkg||"default",{},function(t){t.file(r,function(r,t,i,o,a){var f=new Function("__fbx__dnm__","exports","require","module","__filename","__dirname","__root__",n);f(!0,r,t,i,o,a,e)})})},r.flush=function(e){var r=x.default;for(var n in r.f)e&&!e(n)||delete r.f[n].locals},r.pkg=function(e,r,n){if(x[e])return n(x[e].s);var t=x[e]={};return t.f={},t.v=r,t.s={file:function(e,r){return t.f[e]={fn:r}}},n(t.s)},r.addPlugin=function(e){this.plugins.push(e)},r.packages=x,r.isBrowser=m,r.isServer=!m,r.plugins=[],r}();return m||(h.FuseBox=_),e.FuseBox=_}(this))