checkout.js
Version:
Easy to use checkout widget powered by Crowdstart.
1,466 lines (1,452 loc) • 1.18 MB
JavaScript
(function (global) {
var process = {
title: 'browser',
browser: true,
env: {},
argv: [],
nextTick: function (fn) {
setTimeout(fn, 0)
},
cwd: function () {
return '/'
},
chdir: function () {
}
};
// Require module
function require(file, cb) {
// Handle async require
if (typeof cb == 'function') {
return require.load(file, cb)
}
// Return module from cache
if ({}.hasOwnProperty.call(require.cache, file))
return require.cache[file];
var resolved = require.resolve(file);
if (!resolved)
throw new Error('Failed to resolve module ' + file);
var mod = {
id: file,
require: require,
filename: file,
exports: {},
loaded: false,
parent: null,
children: []
};
var dirname = file.slice(0, file.lastIndexOf('/') + 1);
require.cache[file] = mod.exports;
resolved.call(mod.exports, mod, mod.exports, dirname, file, process);
mod.loaded = true;
return require.cache[file] = mod.exports
}
require.modules = {};
require.cache = {};
require.resolve = function (file) {
return {}.hasOwnProperty.call(require.modules, file) ? require.modules[file] : void 0
};
// define normal static module
require.define = function (file, fn) {
require.modules[file] = fn
};
global.require = require;
// source: node_modules/crowdstart.js/lib/browser.js
require.define('crowdstart.js/lib/browser', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var Api, Client;
if (global.Crowdstart == null) {
global.Crowdstart = {}
}
Api = require('crowdstart.js/lib/api');
Client = require('crowdstart.js/lib/client/xhr');
Api.CLIENT = Client;
Api.BLUEPRINTS = require('crowdstart.js/lib/blueprints/browser');
Crowdstart.Api = Api;
Crowdstart.Client = Client;
module.exports = Crowdstart //# sourceMappingURL=browser.js.map
});
// source: node_modules/crowdstart.js/lib/api.js
require.define('crowdstart.js/lib/api', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var Api, isFunction, isString, newError, ref, statusOk;
ref = require('crowdstart.js/lib/utils'), isFunction = ref.isFunction, isString = ref.isString, newError = ref.newError, statusOk = ref.statusOk;
module.exports = Api = function () {
Api.BLUEPRINTS = {};
Api.CLIENT = null;
function Api(opts) {
var blueprints, client, debug, endpoint, k, key, v;
if (opts == null) {
opts = {}
}
if (!(this instanceof Api)) {
return new Api(opts)
}
endpoint = opts.endpoint, debug = opts.debug, key = opts.key, client = opts.client, blueprints = opts.blueprints;
this.debug = debug;
if (blueprints == null) {
blueprints = this.constructor.BLUEPRINTS
}
if (client) {
this.client = client
} else {
this.client = new this.constructor.CLIENT({
debug: debug,
endpoint: endpoint,
key: key
})
}
for (k in blueprints) {
v = blueprints[k];
this.addBlueprints(k, v)
}
}
Api.prototype.addBlueprints = function (api, blueprints) {
var bp, fn, name;
if (this[api] == null) {
this[api] = {}
}
fn = function (_this) {
return function (name, bp) {
var method;
if (isFunction(bp)) {
return _this[api][name] = function () {
return bp.apply(_this, arguments)
}
}
if (bp.expects == null) {
bp.expects = statusOk
}
if (bp.method == null) {
bp.method = 'POST'
}
method = function (data, cb) {
return _this.client.request(bp, data).then(function (res) {
var ref1, ref2;
if (((ref1 = res.data) != null ? ref1.error : void 0) != null) {
throw newError(data, res)
}
if (!bp.expects(res)) {
throw newError(data, res)
}
if (bp.process != null) {
bp.process.call(_this, res)
}
return (ref2 = res.data) != null ? ref2 : res.body
}).callback(cb)
};
return _this[api][name] = method
}
}(this);
for (name in blueprints) {
bp = blueprints[name];
fn(name, bp)
}
};
Api.prototype.setKey = function (key) {
return this.client.setKey(key)
};
Api.prototype.setUserKey = function (key) {
return this.client.setUserKey(key)
};
Api.prototype.deleteUserKey = function () {
return this.client.deleteUserKey()
};
Api.prototype.setStore = function (id) {
this.storeId = id;
return this.client.setStore(id)
};
return Api
}() //# sourceMappingURL=api.js.map
});
// source: node_modules/crowdstart.js/lib/utils.js
require.define('crowdstart.js/lib/utils', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
exports.isFunction = function (fn) {
return typeof fn === 'function'
};
exports.isString = function (s) {
return typeof s === 'string'
};
exports.statusOk = function (res) {
return res.status === 200
};
exports.statusCreated = function (res) {
return res.status === 201
};
exports.statusNoContent = function (res) {
return res.status === 204
};
exports.newError = function (data, res) {
var err, message, ref, ref1, ref2, ref3, ref4;
if (res == null) {
res = {}
}
message = (ref = res != null ? (ref1 = res.data) != null ? (ref2 = ref1.error) != null ? ref2.message : void 0 : void 0 : void 0) != null ? ref : 'Request failed';
err = new Error(message);
err.message = message;
err.req = data;
err.data = res.data;
err.responseText = res.data;
err.status = res.status;
err.type = (ref3 = res.data) != null ? (ref4 = ref3.error) != null ? ref4.type : void 0 : void 0;
return err
};
exports.updateQuery = function (url, key, value) {
var hash, re, separator;
re = new RegExp('([?&])' + key + '=.*?(&|#|$)(.*)', 'gi');
if (re.test(url)) {
if (value != null) {
return url.replace(re, '$1' + key + '=' + value + '$2$3')
} else {
hash = url.split('#');
url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
if (hash[1] != null) {
url += '#' + hash[1]
}
return url
}
} else {
if (value != null) {
separator = url.indexOf('?') !== -1 ? '&' : '?';
hash = url.split('#');
url = hash[0] + separator + key + '=' + value;
if (hash[1] != null) {
url += '#' + hash[1]
}
return url
} else {
return url
}
}
} //# sourceMappingURL=utils.js.map
});
// source: node_modules/crowdstart.js/lib/client/xhr.js
require.define('crowdstart.js/lib/client/xhr', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var Xhr, XhrClient, cookie, isFunction, newError, ref, updateQuery;
Xhr = require('xhr-promise-es6/lib');
Xhr.Promise = require('broken/lib');
cookie = require('js-cookie/src/js.cookie');
ref = require('crowdstart.js/lib/utils'), isFunction = ref.isFunction, newError = ref.newError, updateQuery = ref.updateQuery;
module.exports = XhrClient = function () {
XhrClient.prototype.debug = false;
XhrClient.prototype.endpoint = 'https://api.crowdstart.com';
XhrClient.prototype.sessionName = 'crwdst';
function XhrClient(opts) {
if (opts == null) {
opts = {}
}
if (!(this instanceof XhrClient)) {
return new XhrClient(opts)
}
this.key = opts.key, this.debug = opts.debug;
if (opts.endpoint) {
this.setEndpoint(opts.endpoint)
}
this.getUserKey()
}
XhrClient.prototype.setEndpoint = function (endpoint) {
return this.endpoint = endpoint.replace(/\/$/, '')
};
XhrClient.prototype.setStore = function (id) {
return this.storeId = id
};
XhrClient.prototype.setKey = function (key) {
return this.key = key
};
XhrClient.prototype.getKey = function () {
return this.userKey || this.key || this.constructor.KEY
};
XhrClient.prototype.getUserKey = function () {
var session;
if ((session = cookie.getJSON(this.sessionName)) != null) {
if (session.userKey != null) {
this.userKey = session.userKey
}
}
return this.userKey
};
XhrClient.prototype.setUserKey = function (key) {
cookie.set(this.sessionName, { userKey: key }, { expires: 7 * 24 * 3600 * 1000 });
return this.userKey = key
};
XhrClient.prototype.deleteUserKey = function () {
cookie.set(this.sessionName, { userKey: null }, { expires: 7 * 24 * 3600 * 1000 });
return this.userKey
};
XhrClient.prototype.getUrl = function (url, data, key) {
if (isFunction(url)) {
url = url.call(this, data)
}
return updateQuery(this.endpoint + url, 'token', key)
};
XhrClient.prototype.request = function (blueprint, data, key) {
var opts;
if (key == null) {
key = this.getKey()
}
opts = {
url: this.getUrl(blueprint.url, data, key),
method: blueprint.method,
data: JSON.stringify(data)
};
if (this.debug) {
console.log('--REQUEST--');
console.log(opts)
}
return new Xhr().send(opts).then(function (res) {
if (this.debug) {
console.log('--RESPONSE--');
console.log(res)
}
res.data = res.responseText;
return res
})['catch'](function (res) {
var err, error, ref1;
try {
res.data = (ref1 = res.responseText) != null ? ref1 : JSON.parse(res.xhr.responseText)
} catch (error) {
err = error
}
err = newError(data, res);
if (this.debug) {
console.log('--RESPONSE--');
console.log(res);
console.log('ERROR:', err)
}
throw err
})
};
return XhrClient
}() //# sourceMappingURL=xhr.js.map
});
// source: node_modules/xhr-promise-es6/lib/index.js
require.define('xhr-promise-es6/lib', function (module, exports, __dirname, __filename, process) {
/*
* Copyright 2015 Scott Brady
* MIT License
* https://github.com/scottbrady/xhr-promise/blob/master/LICENSE
*/
var ParseHeaders, XMLHttpRequestPromise, objectAssign;
ParseHeaders = require('parse-headers/parse-headers');
objectAssign = require('object-assign');
/*
* Module to wrap an XMLHttpRequest in a promise.
*/
module.exports = XMLHttpRequestPromise = function () {
function XMLHttpRequestPromise() {
}
XMLHttpRequestPromise.DEFAULT_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8';
XMLHttpRequestPromise.Promise = global.Promise;
/*
* XMLHttpRequestPromise.send(options) -> Promise
* - options (Object): URL, method, data, etc.
*
* Create the XHR object and wire up event handlers to use a promise.
*/
XMLHttpRequestPromise.prototype.send = function (options) {
var defaults;
if (options == null) {
options = {}
}
defaults = {
method: 'GET',
data: null,
headers: {},
async: true,
username: null,
password: null
};
options = objectAssign({}, defaults, options);
return new this.constructor.Promise(function (_this) {
return function (resolve, reject) {
var e, header, ref, value, xhr;
if (!XMLHttpRequest) {
_this._handleError('browser', reject, null, "browser doesn't support XMLHttpRequest");
return
}
if (typeof options.url !== 'string' || options.url.length === 0) {
_this._handleError('url', reject, null, 'URL is a required parameter');
return
}
_this._xhr = xhr = new XMLHttpRequest;
xhr.onload = function () {
var responseText;
_this._detachWindowUnload();
try {
responseText = _this._getResponseText()
} catch (_error) {
_this._handleError('parse', reject, null, 'invalid JSON response');
return
}
return resolve({
url: _this._getResponseUrl(),
status: xhr.status,
statusText: xhr.statusText,
responseText: responseText,
headers: _this._getHeaders(),
xhr: xhr
})
};
xhr.onerror = function () {
return _this._handleError('error', reject)
};
xhr.ontimeout = function () {
return _this._handleError('timeout', reject)
};
xhr.onabort = function () {
return _this._handleError('abort', reject)
};
_this._attachWindowUnload();
xhr.open(options.method, options.url, options.async, options.username, options.password);
if (options.data != null && !options.headers['Content-Type']) {
options.headers['Content-Type'] = _this.constructor.DEFAULT_CONTENT_TYPE
}
ref = options.headers;
for (header in ref) {
value = ref[header];
xhr.setRequestHeader(header, value)
}
try {
return xhr.send(options.data)
} catch (_error) {
e = _error;
return _this._handleError('send', reject, null, e.toString())
}
}
}(this))
};
/*
* XMLHttpRequestPromise.getXHR() -> XMLHttpRequest
*/
XMLHttpRequestPromise.prototype.getXHR = function () {
return this._xhr
};
/*
* XMLHttpRequestPromise._attachWindowUnload()
*
* Fix for IE 9 and IE 10
* Internet Explorer freezes when you close a webpage during an XHR request
* https://support.microsoft.com/kb/2856746
*
*/
XMLHttpRequestPromise.prototype._attachWindowUnload = function () {
this._unloadHandler = this._handleWindowUnload.bind(this);
if (window.attachEvent) {
return window.attachEvent('onunload', this._unloadHandler)
}
};
/*
* XMLHttpRequestPromise._detachWindowUnload()
*/
XMLHttpRequestPromise.prototype._detachWindowUnload = function () {
if (window.detachEvent) {
return window.detachEvent('onunload', this._unloadHandler)
}
};
/*
* XMLHttpRequestPromise._getHeaders() -> Object
*/
XMLHttpRequestPromise.prototype._getHeaders = function () {
return ParseHeaders(this._xhr.getAllResponseHeaders())
};
/*
* XMLHttpRequestPromise._getResponseText() -> Mixed
*
* Parses response text JSON if present.
*/
XMLHttpRequestPromise.prototype._getResponseText = function () {
var responseText;
responseText = typeof this._xhr.responseText === 'string' ? this._xhr.responseText : '';
switch (this._xhr.getResponseHeader('Content-Type')) {
case 'application/json':
case 'text/javascript':
responseText = JSON.parse(responseText + '')
}
return responseText
};
/*
* XMLHttpRequestPromise._getResponseUrl() -> String
*
* Actual response URL after following redirects.
*/
XMLHttpRequestPromise.prototype._getResponseUrl = function () {
if (this._xhr.responseURL != null) {
return this._xhr.responseURL
}
if (/^X-Request-URL:/m.test(this._xhr.getAllResponseHeaders())) {
return this._xhr.getResponseHeader('X-Request-URL')
}
return ''
};
/*
* XMLHttpRequestPromise._handleError(reason, reject, status, statusText)
* - reason (String)
* - reject (Function)
* - status (String)
* - statusText (String)
*/
XMLHttpRequestPromise.prototype._handleError = function (reason, reject, status, statusText) {
this._detachWindowUnload();
return reject({
reason: reason,
status: status || this._xhr.status,
statusText: statusText || this._xhr.statusText,
xhr: this._xhr
})
};
/*
* XMLHttpRequestPromise._handleWindowUnload()
*/
XMLHttpRequestPromise.prototype._handleWindowUnload = function () {
return this._xhr.abort()
};
return XMLHttpRequestPromise
}()
});
// source: node_modules/parse-headers/parse-headers.js
require.define('parse-headers/parse-headers', function (module, exports, __dirname, __filename, process) {
var trim = require('trim'), forEach = require('for-each'), isArray = function (arg) {
return Object.prototype.toString.call(arg) === '[object Array]'
};
module.exports = function (headers) {
if (!headers)
return {};
var result = {};
forEach(trim(headers).split('\n'), function (row) {
var index = row.indexOf(':'), key = trim(row.slice(0, index)).toLowerCase(), value = trim(row.slice(index + 1));
if (typeof result[key] === 'undefined') {
result[key] = value
} else if (isArray(result[key])) {
result[key].push(value)
} else {
result[key] = [
result[key],
value
]
}
});
return result
}
});
// source: node_modules/trim/index.js
require.define('trim', function (module, exports, __dirname, __filename, process) {
exports = module.exports = trim;
function trim(str) {
return str.replace(/^\s*|\s*$/g, '')
}
exports.left = function (str) {
return str.replace(/^\s*/, '')
};
exports.right = function (str) {
return str.replace(/\s*$/, '')
}
});
// source: node_modules/for-each/index.js
require.define('for-each', function (module, exports, __dirname, __filename, process) {
var isFunction = require('is-function');
module.exports = forEach;
var toString = Object.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty;
function forEach(list, iterator, context) {
if (!isFunction(iterator)) {
throw new TypeError('iterator must be a function')
}
if (arguments.length < 3) {
context = this
}
if (toString.call(list) === '[object Array]')
forEachArray(list, iterator, context);
else if (typeof list === 'string')
forEachString(list, iterator, context);
else
forEachObject(list, iterator, context)
}
function forEachArray(array, iterator, context) {
for (var i = 0, len = array.length; i < len; i++) {
if (hasOwnProperty.call(array, i)) {
iterator.call(context, array[i], i, array)
}
}
}
function forEachString(string, iterator, context) {
for (var i = 0, len = string.length; i < len; i++) {
// no such thing as a sparse string.
iterator.call(context, string.charAt(i), i, string)
}
}
function forEachObject(object, iterator, context) {
for (var k in object) {
if (hasOwnProperty.call(object, k)) {
iterator.call(context, object[k], k, object)
}
}
}
});
// source: node_modules/is-function/index.js
require.define('is-function', function (module, exports, __dirname, __filename, process) {
module.exports = isFunction;
var toString = Object.prototype.toString;
function isFunction(fn) {
var string = toString.call(fn);
return string === '[object Function]' || typeof fn === 'function' && string !== '[object RegExp]' || typeof window !== 'undefined' && (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt)
}
;
});
// source: node_modules/object-assign/index.js
require.define('object-assign', function (module, exports, __dirname, __filename, process) {
/* eslint-disable no-unused-vars */
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined')
}
return Object(val)
}
module.exports = Object.assign || function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key]
}
}
if (Object.getOwnPropertySymbols) {
symbols = Object.getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]]
}
}
}
}
return to
}
});
// source: node_modules/broken/lib/index.js
require.define('broken/lib', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var Promise, PromiseInspection;
Promise = require('zousan/zousan-min');
Promise.suppressUncaughtRejectionError = true;
PromiseInspection = function () {
function PromiseInspection(arg) {
this.state = arg.state, this.value = arg.value, this.reason = arg.reason
}
PromiseInspection.prototype.isFulfilled = function () {
return this.state === 'fulfilled'
};
PromiseInspection.prototype.isRejected = function () {
return this.state === 'rejected'
};
return PromiseInspection
}();
Promise.reflect = function (promise) {
return new Promise(function (resolve, reject) {
return promise.then(function (value) {
return resolve(new PromiseInspection({
state: 'fulfilled',
value: value
}))
})['catch'](function (err) {
return resolve(new PromiseInspection({
state: 'rejected',
reason: err
}))
})
})
};
Promise.settle = function (promises) {
return Promise.all(promises.map(Promise.reflect))
};
Promise.prototype.callback = function (cb) {
if (typeof cb === 'function') {
this.then(function (value) {
return cb(null, value)
});
this['catch'](function (error) {
return cb(error, null)
})
}
return this
};
module.exports = Promise //# sourceMappingURL=index.js.map
});
// source: node_modules/zousan/zousan-min.js
require.define('zousan/zousan-min', function (module, exports, __dirname, __filename, process) {
!function (t) {
'use strict';
function e(t) {
if (t) {
var e = this;
t(function (t) {
e.resolve(t)
}, function (t) {
e.reject(t)
})
}
}
function n(t, e) {
if ('function' == typeof t.y)
try {
var n = t.y.call(i, e);
t.p.resolve(n)
} catch (o) {
t.p.reject(o)
}
else
t.p.resolve(e)
}
function o(t, e) {
if ('function' == typeof t.n)
try {
var n = t.n.call(i, e);
t.p.resolve(n)
} catch (o) {
t.p.reject(o)
}
else
t.p.reject(e)
}
var r, i, c = 'fulfilled', u = 'rejected', s = 'undefined', f = function () {
function t() {
for (; e.length - n;)
e[n](), n++, n > 1024 && (e.splice(0, n), n = 0)
}
var e = [], n = 0, o = function () {
if (typeof MutationObserver !== s) {
var e = document.createElement('div'), n = new MutationObserver(t);
return n.observe(e, { attributes: !0 }), function () {
e.setAttribute('a', 0)
}
}
return typeof setImmediate !== s ? function () {
setImmediate(t)
} : function () {
setTimeout(t, 0)
}
}();
return function (t) {
e.push(t), e.length - n == 1 && o()
}
}();
e.prototype = {
resolve: function (t) {
if (this.state === r) {
if (t === this)
return this.reject(new TypeError('Attempt to resolve promise with self'));
var e = this;
if (t && ('function' == typeof t || 'object' == typeof t))
try {
var o = !0, i = t.then;
if ('function' == typeof i)
return void i.call(t, function (t) {
o && (o = !1, e.resolve(t))
}, function (t) {
o && (o = !1, e.reject(t))
})
} catch (u) {
return void (o && this.reject(u))
}
this.state = c, this.v = t, e.c && f(function () {
for (var o = 0, r = e.c.length; r > o; o++)
n(e.c[o], t)
})
}
},
reject: function (t) {
if (this.state === r) {
this.state = u, this.v = t;
var n = this.c;
n ? f(function () {
for (var e = 0, r = n.length; r > e; e++)
o(n[e], t)
}) : e.suppressUncaughtRejectionError || console.log('You upset Zousan. Please catch rejections: ', t, t.stack)
}
},
then: function (t, i) {
var u = new e, s = {
y: t,
n: i,
p: u
};
if (this.state === r)
this.c ? this.c.push(s) : this.c = [s];
else {
var l = this.state, a = this.v;
f(function () {
l === c ? n(s, a) : o(s, a)
})
}
return u
},
'catch': function (t) {
return this.then(null, t)
},
'finally': function (t) {
return this.then(t, t)
},
timeout: function (t, n) {
n = n || 'Timeout';
var o = this;
return new e(function (e, r) {
setTimeout(function () {
r(Error(n))
}, t), o.then(function (t) {
e(t)
}, function (t) {
r(t)
})
})
}
}, e.resolve = function (t) {
var n = new e;
return n.resolve(t), n
}, e.reject = function (t) {
var n = new e;
return n.reject(t), n
}, e.all = function (t) {
function n(n, c) {
'function' != typeof n.then && (n = e.resolve(n)), n.then(function (e) {
o[c] = e, r++, r == t.length && i.resolve(o)
}, function (t) {
i.reject(t)
})
}
for (var o = [], r = 0, i = new e, c = 0; c < t.length; c++)
n(t[c], c);
return t.length || i.resolve(o), i
}, typeof module != s && module.exports && (module.exports = e), t.Zousan = e, e.soon = f
}('undefined' != typeof global ? global : this)
});
// source: node_modules/js-cookie/src/js.cookie.js
require.define('js-cookie/src/js.cookie', function (module, exports, __dirname, __filename, process) {
/*!
* JavaScript Cookie v2.0.4
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(factory)
} else if (typeof exports === 'object') {
module.exports = factory()
} else {
var _OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = _OldCookies;
return api
}
}
}(function () {
function extend() {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[i];
for (var key in attributes) {
result[key] = attributes[key]
}
}
return result
}
function init(converter) {
function api(key, value, attributes) {
var result;
// Write
if (arguments.length > 1) {
attributes = extend({ path: '/' }, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date;
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 86400000);
attributes.expires = expires
}
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result
}
} catch (e) {
}
value = encodeURIComponent(String(value));
value = value.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
return document.cookie = [
key,
'=',
value,
attributes.expires && '; expires=' + attributes.expires.toUTCString(),
// use expires attribute, max-age is not supported by IE
attributes.path && '; path=' + attributes.path,
attributes.domain && '; domain=' + attributes.domain,
attributes.secure ? '; secure' : ''
].join('')
}
// Read
if (!key) {
result = {}
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var name = parts[0].replace(rdecode, decodeURIComponent);
var cookie = parts.slice(1).join('=');
if (cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1)
}
try {
cookie = converter && converter(cookie, name) || cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie)
} catch (e) {
}
}
if (key === name) {
result = cookie;
break
}
if (!key) {
result[name] = cookie
}
} catch (e) {
}
}
return result
}
api.get = api.set = api;
api.getJSON = function () {
return api.apply({ json: true }, [].slice.call(arguments))
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, { expires: -1 }))
};
api.withConverter = init;
return api
}
return init()
}))
});
// source: node_modules/crowdstart.js/lib/blueprints/browser.js
require.define('crowdstart.js/lib/blueprints/browser', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var blueprints, byId, createBlueprint, fn, i, isFunction, len, model, models, ref, ref1, statusCreated, statusNoContent, statusOk, storePrefixed, userModels;
ref = require('crowdstart.js/lib/utils'), isFunction = ref.isFunction, statusCreated = ref.statusCreated, statusNoContent = ref.statusNoContent, statusOk = ref.statusOk;
ref1 = require('crowdstart.js/lib/blueprints/url'), byId = ref1.byId, storePrefixed = ref1.storePrefixed;
createBlueprint = function (name) {
var endpoint;
endpoint = '/' + name;
return {
list: {
url: endpoint,
method: 'GET',
expects: statusOk
},
get: {
url: byId(name),
method: 'GET',
expects: statusOk
}
}
};
blueprints = {
account: {
get: {
url: '/account',
method: 'GET',
expects: statusOk
},
update: {
url: '/account',
method: 'PATCH',
expects: statusOk
},
exists: {
url: function (x) {
var ref2, ref3, ref4;
return '/account/exists/' + ((ref2 = (ref3 = (ref4 = x.email) != null ? ref4 : x.username) != null ? ref3 : x.id) != null ? ref2 : x)
},
method: 'GET',
expects: statusOk,
process: function (res) {
return res.data.exists
}
},
create: {
url: '/account/create',
method: 'POST',
expects: statusCreated
},
enable: {
url: function (x) {
var ref2;
return '/account/enable/' + ((ref2 = x.tokenId) != null ? ref2 : x)
},
method: 'POST',
expects: statusOk
},
login: {
url: '/account/login',
method: 'POST',
expects: statusOk,
process: function (res) {
this.setUserKey(res.data.token);
return res
}
},
logout: function () {
return this.deleteUserKey()
},
reset: {
url: '/account/reset',
method: 'POST',
expects: statusOk
},
confirm: {
url: function (x) {
var ref2;
return '/account/confirm/' + ((ref2 = x.tokenId) != null ? ref2 : x)
},
method: 'POST',
expects: statusOk
}
},
checkout: {
authorize: {
url: storePrefixed('/checkout/authorize'),
method: 'POST',
expects: statusOk
},
capture: {
url: storePrefixed(function (x) {
var ref2;
return '/checkout/capture/' + ((ref2 = x.orderId) != null ? ref2 : x)
}),
method: 'POST',
expects: statusOk
},
charge: {
url: storePrefixed('/checkout/charge'),
method: 'POST',
expects: statusOk
},
paypal: {
url: storePrefixed('/checkout/paypal'),
method: 'POST',
expects: statusOk
}
},
referrer: {
create: {
url: '/referrer',
method: 'POST',
expects: statusCreated
}
}
};
models = [
'collection',
'coupon',
'product',
'variant'
];
userModels = [
'order',
'subscription'
];
fn = function (model) {
return blueprints[model] = createBlueprint(model)
};
for (i = 0, len = models.length; i < len; i++) {
model = models[i];
fn(model)
}
module.exports = blueprints //# sourceMappingURL=browser.js.map
});
// source: node_modules/crowdstart.js/lib/blueprints/url.js
require.define('crowdstart.js/lib/blueprints/url', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var isFunction, sp;
isFunction = require('crowdstart.js/lib/utils').isFunction;
exports.storePrefixed = sp = function (u) {
return function (x) {
var url;
if (isFunction(u)) {
url = u(x)
} else {
url = u
}
if (this.storeId != null) {
return '/store/' + this.storeId + url
} else {
return url
}
}
};
exports.byId = function (name) {
switch (name) {
case 'coupon':
return sp(function (x) {
var ref;
return '/coupon/' + ((ref = x.code) != null ? ref : x)
});
case 'collection':
return sp(function (x) {
var ref;
return '/collection/' + ((ref = x.slug) != null ? ref : x)
});
case 'product':
return sp(function (x) {
var ref, ref1;
return '/product/' + ((ref = (ref1 = x.id) != null ? ref1 : x.slug) != null ? ref : x)
});
case 'variant':
return sp(function (x) {
var ref, ref1;
return '/variant/' + ((ref = (ref1 = x.id) != null ? ref1 : x.sku) != null ? ref : x)
});
default:
return function (x) {
var ref;
return '/' + name + '/' + ((ref = x.id) != null ? ref : x)
}
}
} //# sourceMappingURL=url.js.map
});
// source: node_modules/crowdcontrol/lib/index.js
require.define('crowdcontrol/lib', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
module.exports = {
config: require('crowdcontrol/lib/config'),
utils: require('crowdcontrol/lib/utils'),
view: require('crowdcontrol/lib/view'),
start: function (opts) {
return require('riot/riot').mount('*')
},
Events: require('crowdcontrol/lib/events')
};
if (typeof window !== 'undefined' && window !== null) {
window.crowdcontrol = module.exports
} //# sourceMappingURL=index.js.map
});
// source: node_modules/crowdcontrol/lib/config.js
require.define('crowdcontrol/lib/config', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
module.exports = {} //# sourceMappingURL=config.js.map
});
// source: node_modules/crowdcontrol/lib/utils/index.js
require.define('crowdcontrol/lib/utils', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
module.exports = {
log: require('crowdcontrol/lib/utils/log'),
mediator: require('crowdcontrol/lib/utils/mediator')
} //# sourceMappingURL=index.js.map
});
// source: node_modules/crowdcontrol/lib/utils/log.js
require.define('crowdcontrol/lib/utils/log', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var log;
log = function () {
if (log.DEBUG) {
return console.log.apply(console, arguments)
}
};
log.DEBUG = false;
log.debug = log;
log.info = function () {
return console.log.apply(console, arguments)
};
log.warn = function () {
console.log('WARN:');
return console.log.apply(console, arguments)
};
log.error = function () {
console.log('ERROR:');
console.log.apply(console, arguments);
throw new arguments[0]
};
module.exports = log //# sourceMappingURL=log.js.map
});
// source: node_modules/crowdcontrol/lib/utils/mediator.js
require.define('crowdcontrol/lib/utils/mediator', function (module, exports, __dirname, __filename, process) {
// Generated by CoffeeScript 1.10.0
var riot;
riot = require('riot/riot');
module.exports = riot.observable({}) //# sourceMappingURL=mediator.js.map
});
// source: node_modules/riot/riot.js
require.define('riot/riot', function (module, exports, __dirname, __filename, process) {
/* Riot v2.2.4, @license MIT, (c) 2015 Muut Inc. + contributors */
;
(function (window, undefined) {
'use strict';
var riot = {
version: 'v2.2.4',
settings: {}
},
//// be aware, internal usage
// counter to give a unique id to all the Tag instances
__uid = 0,
// riot specific prefixes
RIOT_PREFIX = 'riot-', RIOT_TAG = RIOT_PREFIX + 'tag',
// for typeof == '' comparisons
T_STRING = 'string', T_OBJECT = 'object', T_UNDEF = 'undefined', T_FUNCTION = 'function',
// special native tags that cannot be treated like the others
SPECIAL_TAGS_REGEX = /^(?:opt(ion|group)|tbody|col|t[rhd])$/, RESERVED_WORDS_BLACKLIST = [
'_item',
'_id',
'update',
'root',
'mount',
'unmount',
'mixin',
'isMounted',
'isLoop',
'tags',
'parent',
'opts',
'trigger',
'on',
'off',
'one'
],
// version# for IE 8-11, 0 for others
IE_VERSION = (window && window.document || {}).documentMode | 0,
// Array.isArray for IE8 is in the polyfills
isArray = Array.isArray;
riot.observable = function (el) {
el = el || {};
var callbacks = {}, _id = 0;
el.on = function (events, fn) {
if (isFunction(fn)) {
if (typeof fn.id === T_UNDEF)
fn._id = _id++;
events.replace(/\S+/g, function (name, pos) {
(callbacks[name] = callbacks[name] || []).push(fn);
fn.typed = pos > 0
})
}
return el
};
el.off = function (events, fn) {
if (events == '*')
callbacks = {};
else {
events.replace(/\S+/g, function (name) {
if (fn) {
var arr = callbacks[name];
for (var i = 0, cb; cb = arr && arr[i]; ++i) {
if (cb._id == fn._id)
arr.splice(i--, 1)
}
} else {
callbacks[name] = []
}
})
}
return el
};
// only single event supported
el.one = function (name, fn) {
function on() {
el.off(name, on);
fn.apply(el, arguments)
}
return el.on(name, on)
};
el.trigger = function (name) {
var args = [].slice.call(arguments, 1), fns = callbacks[name] || [];
for (var i = 0, fn; fn = fns[i]; ++i) {
if (!fn.busy) {
fn.busy = 1;
fn.apply(el, fn.typed ? [name].concat(args) : args);
if (fns[i] !== fn) {
i--
}
fn.busy = 0
}
}
if (callbacks.all && name != 'all') {
el.trigger.apply(el, [
'all',
name
].concat(args))
}
return el
};
return el
};
riot.mixin = function () {
var mixins = {};
return function (name, mixin) {
if (!mixin)
return mixins[name];
mixins[name] = mixin
}
}();
(function (riot, evt, win) {
// browsers only
if (!win)
return;
var loc = win.location, fns = riot.observable(), started = false, current;
function hash() {
return loc.href.split('#')[1] || '' // why not loc.hash.splice(1) ?
}
function parser(path) {
return path.split('/')
}
function emit(path) {
if (path.type)
path = hash();
if (path != current) {
fns.trigger.apply(null, ['H'].concat(parser(path)));
current = path
}
}
var r = riot.route = function (arg) {
// string
if (arg[0]) {
loc.hash = arg;
emit(arg) // function
} else {
fns.on('H', arg)
}
};
r.exec = function (fn) {
fn.apply(null, parser(hash()))
};
r.parser = function (fn) {
parser = fn
};
r.stop = function () {
if (started) {
if (win.removeEventListener)
win.removeEventListener(evt, emit, false) //@IE8 - the if()
;
else
win.detachEvent('on' + evt, emit);
//@IE8
fns.off('*');
started = false
}
};
r.start = function () {
if (!started) {
if (win.addEventListener)
win.addEventListener(evt, emit, false) //@IE8 - the if()
;
else
win.attachEvent('on' + evt, emit);
//IE8
started = true
}
};
// autostart the router
r.start()
}(riot, 'hashchange', window));
/*
//// How it works?
Three ways:
1. Expressions: tmpl('{ value }', data).
Returns the result of evaluated expression as a raw object.
2. Templates: tmpl('Hi { name } { surname }', data).
Returns a string with evaluated expressions.
3. Filters: tmpl('{ show: !done, highlight: active }', data).
Returns a space separated list of trueish keys (mainly
used for setting html classes), e.g. "show highlight".
// Template examples
tmpl('{ title || "Untitled" }', data)
tmpl('Results are { results ? "ready" : "loading" }', data)
tmpl('Today is { new Date() }', data)
tmpl('{ message.length > 140 && "Message is too long" }', data)
tmpl('This item got { Math.round(rating) } stars', data)
tmpl('<h1>{ title }</h1>{ body }', data)
// Falsy expressions in templates
In templates (as opposed to single expressions) all falsy values
except zero (undefined/null/false) will default to empty string:
tmpl('{ undefined } - { false } - { null } - { 0 }', {})
// will return: " - - - 0"
*/
var brackets = function (orig) {
var cachedBrackets, r, b, re = /[{}]/g;
return function (x) {
// make sure we use the current setting
var s = riot.settings.brackets || orig;
// recreate cached vars if needed
if (cachedBrackets !== s) {
cachedBrackets = s;
b = s.split(' ');
r = b.map(function (e) {
return e.replace(/(?=.)/g, '\\')
})
}
// if regexp given, rewrite it with current brackets (only if differ from default)
return x instanceof RegExp ? s === orig ? x : new RegExp(x.source.replace(re, function (b) {
return r[~~(b === '}')]
}), x.global ? 'g' : '') : // else, get specific bracket
b[x]
}
}('{ }');
var tmpl = function () {
var cache = {}, OGLOB = '"in d?d:' + (window ? 'window).' : 'global).'), reVars = /(['"\/])(?:[^\\]*?|\\.|.)*?\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function\s*\()|([A-Za-z_$]\w*)/g;
// build a template (or get it from cache), render with data
return function (str, data) {
return str && (cache[str] || (cache[str] = tmpl(str)))(data)
};
// create a template instance
function tmpl(s, p) {
if (s.indexOf(brackets(0)) < 0) {
// return raw text
s = s.replace(/\n|\r\n?/g, '\n');
return function () {
return s
}
}
// temporarily convert \{ and \} to a non-character
s = s.replace(brackets(/\\{/g), '').replace(brackets(/\\}/g), '');
// split string to expression and non-expresion parts
p = split(s, extract(s, brackets(/{/), brackets(/}/)));
// is it a single expression or a template? i.e. {x} or <b>{x}</b>
s = p.length === 2 && !p[0] ? // if expression, evaluate it
expr(p[1]) : // if template, evaluate all expressions in it
'[' + p.map(function (s, i) {
// is it an expression or a string (every second part is an expression)
return i % 2 ? // evaluate the expressions
expr(s, true) : // process string parts of the template:
'"' + s // preserve new lines
.replace(/\n|\r\n?/g, '\\n') // escape quotes
.replace(/"/g, '\\"') + '"'
}).join(',') + '].join("")';
return new Function('d', 'return ' + s // bring escaped { and } back
.replace(/\uFFF0/g, brackets(0)).replace(/\uFFF1/g, brackets(1)) + ';')
}
// parse { ... } expression
function expr(s, n) {
s = s // convert new lines to spaces
.replace(/\n|\r\n?/g, ' ') // trim whitespace, brackets, strip comments
.replace(brackets(/^[{ ]+|[ }]+$|\/\*.+?\*\//g), '');
// is it an object literal? i.e. { key : value }
return /^\s*[\w- "']+ *:/.test(s) ? // if object literal, return trueish keys
// e.g.: { show: isOpen(), done: item.done } -> "show done"
'[' + // extract key:val pairs, ignoring any nested objects
extract(s, // name part: name:, "name":, 'name':, name :
/["' ]*[\w- ]+["' ]*:/, // expression part: everything upto a comma followed by a name (see above) or end of line
/,(?=["' ]*[\w- ]+["' ]*:)|}|$/).map(function (pair) {
// get key, val parts
return pair.replace(/^[