UNPKG

checkout.js

Version:

Easy to use checkout widget powered by Crowdstart.

2 lines 245 kB
(function(e){function t(e,r){if("function"==typeof r)return t.load(e,r);if({}.hasOwnProperty.call(t.cache,e))return t.cache[e];var o=t.resolve(e);if(!o)throw new Error("Failed to resolve module "+e);var i={id:e,require:t,filename:e,exports:{},loaded:!1,parent:null,children:[]},a=e.slice(0,e.lastIndexOf("/")+1);return t.cache[e]=i.exports,o.call(i.exports,i,i.exports,a,e,n),i.loaded=!0,t.cache[e]=i.exports}var n={title:"browser",browser:!0,env:{},argv:[],nextTick:function(e){setTimeout(e,0)},cwd:function(){return"/"},chdir:function(){}};t.modules={},t.cache={},t.resolve=function(e){return{}.hasOwnProperty.call(t.modules,e)?t.modules[e]:void 0},t.define=function(e,n){t.modules[e]=n},e.require=t,t.define("crowdstart.js/lib/browser",function(n,r,o,i,a){var s,c;null==e.Crowdstart&&(e.Crowdstart={}),s=t("crowdstart.js/lib/api"),c=t("crowdstart.js/lib/client/xhr"),s.CLIENT=c,s.BLUEPRINTS=t("crowdstart.js/lib/blueprints/browser"),Crowdstart.Api=s,Crowdstart.Client=c,n.exports=Crowdstart}),t.define("crowdstart.js/lib/api",function(e,n,r,o,i){var a,s,c,l,u,d;u=t("crowdstart.js/lib/utils"),s=u.isFunction,c=u.isString,l=u.newError,d=u.statusOk,e.exports=a=function(){function e(t){var n,r,o,i,a,s,c;if(null==t&&(t={}),!(this instanceof e))return new e(t);i=t.endpoint,o=t.debug,s=t.key,r=t.client,n=t.blueprints,this.debug=o,null==n&&(n=this.constructor.BLUEPRINTS),r?this.client=r:this.client=new this.constructor.CLIENT({debug:o,endpoint:i,key:s});for(a in n)c=n[a],this.addBlueprints(a,c)}return e.BLUEPRINTS={},e.CLIENT=null,e.prototype.addBlueprints=function(e,t){var n,r,o;null==this[e]&&(this[e]={}),r=function(t){return function(n,r){var o;return s(r)?t[e][n]=function(){return r.apply(t,arguments)}:(null==r.expects&&(r.expects=d),null==r.method&&(r.method="POST"),o=function(e,n){return t.client.request(r,e).then(function(n){var o,i;if(null!=(null!=(o=n.data)?o.error:void 0))throw l(e,n);if(!r.expects(n))throw l(e,n);return null!=r.process&&r.process.call(t,n),null!=(i=n.data)?i:n.body}).callback(n)},t[e][n]=o)}}(this);for(o in t)n=t[o],r(o,n)},e.prototype.setKey=function(e){return this.client.setKey(e)},e.prototype.setUserKey=function(e){return this.client.setUserKey(e)},e.prototype.deleteUserKey=function(){return this.client.deleteUserKey()},e.prototype.setStore=function(e){return this.storeId=e,this.client.setStore(e)},e}()}),t.define("crowdstart.js/lib/utils",function(e,t,n,r,o){t.isFunction=function(e){return"function"==typeof e},t.isString=function(e){return"string"==typeof e},t.statusOk=function(e){return 200===e.status},t.statusCreated=function(e){return 201===e.status},t.statusNoContent=function(e){return 204===e.status},t.newError=function(e,t){var n,r,o,i,a,s,c;return null==t&&(t={}),r=null!=(o=null!=t&&null!=(i=t.data)&&null!=(a=i.error)?a.message:void 0)?o:"Request failed",n=new Error(r),n.message=r,n.req=e,n.data=t.data,n.responseText=t.data,n.status=t.status,n.type=null!=(s=t.data)&&null!=(c=s.error)?c.type:void 0,n},t.updateQuery=function(e,t,n){var r,o,i;return o=new RegExp("([?&])"+t+"=.*?(&|#|$)(.*)","gi"),o.test(e)?null!=n?e.replace(o,"$1"+t+"="+n+"$2$3"):(r=e.split("#"),e=r[0].replace(o,"$1$3").replace(/(&|\?)$/,""),null!=r[1]&&(e+="#"+r[1]),e):null!=n?(i=-1!==e.indexOf("?")?"&":"?",r=e.split("#"),e=r[0]+i+t+"="+n,null!=r[1]&&(e+="#"+r[1]),e):e}}),t.define("crowdstart.js/lib/client/xhr",function(e,n,r,o,i){var a,s,c,l,u,d,p;a=t("xhr-promise-es6/lib"),a.Promise=t("broken/lib"),c=t("js-cookie/src/js.cookie"),d=t("crowdstart.js/lib/utils"),l=d.isFunction,u=d.newError,p=d.updateQuery,e.exports=s=function(){function e(t){return null==t&&(t={}),this instanceof e?(this.key=t.key,this.debug=t.debug,t.endpoint&&this.setEndpoint(t.endpoint),void this.getUserKey()):new e(t)}return e.prototype.debug=!1,e.prototype.endpoint="https://api.crowdstart.com",e.prototype.sessionName="crwdst",e.prototype.setEndpoint=function(e){return this.endpoint=e.replace(/\/$/,"")},e.prototype.setStore=function(e){return this.storeId=e},e.prototype.setKey=function(e){return this.key=e},e.prototype.getKey=function(){return this.userKey||this.key||this.constructor.KEY},e.prototype.getUserKey=function(){var e;return null!=(e=c.getJSON(this.sessionName))&&null!=e.userKey&&(this.userKey=e.userKey),this.userKey},e.prototype.setUserKey=function(e){return c.set(this.sessionName,{userKey:e},{expires:6048e5}),this.userKey=e},e.prototype.deleteUserKey=function(){return c.set(this.sessionName,{userKey:null},{expires:6048e5}),this.userKey},e.prototype.getUrl=function(e,t,n){return l(e)&&(e=e.call(this,t)),p(this.endpoint+e,"token",n)},e.prototype.request=function(e,t,n){var r;return null==n&&(n=this.getKey()),r={url:this.getUrl(e.url,t,n),method:e.method,data:JSON.stringify(t)},this.debug&&(console.log("--REQUEST--"),console.log(r)),(new a).send(r).then(function(e){return this.debug&&(console.log("--RESPONSE--"),console.log(e)),e.data=e.responseText,e})["catch"](function(e){var n,r,o;try{e.data=null!=(o=e.responseText)?o:JSON.parse(e.xhr.responseText)}catch(r){n=r}throw n=u(t,e),this.debug&&(console.log("--RESPONSE--"),console.log(e),console.log("ERROR:",n)),n})},e}()}),t.define("xhr-promise-es6/lib",function(n,r,o,i,a){var s,c,l;s=t("parse-headers/parse-headers"),l=t("object-assign"),n.exports=c=function(){function t(){}return t.DEFAULT_CONTENT_TYPE="application/x-www-form-urlencoded; charset=UTF-8",t.Promise=e.Promise,t.prototype.send=function(e){var t;return null==e&&(e={}),t={method:"GET",data:null,headers:{},async:!0,username:null,password:null},e=l({},t,e),new this.constructor.Promise(function(t){return function(n,r){var o,i,a,s,c;if(!XMLHttpRequest)return void t._handleError("browser",r,null,"browser doesn't support XMLHttpRequest");if("string"!=typeof e.url||0===e.url.length)return void t._handleError("url",r,null,"URL is a required parameter");t._xhr=c=new XMLHttpRequest,c.onload=function(){var e;t._detachWindowUnload();try{e=t._getResponseText()}catch(o){return void t._handleError("parse",r,null,"invalid JSON response")}return n({url:t._getResponseUrl(),status:c.status,statusText:c.statusText,responseText:e,headers:t._getHeaders(),xhr:c})},c.onerror=function(){return t._handleError("error",r)},c.ontimeout=function(){return t._handleError("timeout",r)},c.onabort=function(){return t._handleError("abort",r)},t._attachWindowUnload(),c.open(e.method,e.url,e.async,e.username,e.password),null==e.data||e.headers["Content-Type"]||(e.headers["Content-Type"]=t.constructor.DEFAULT_CONTENT_TYPE),a=e.headers;for(i in a)s=a[i],c.setRequestHeader(i,s);try{return c.send(e.data)}catch(l){return o=l,t._handleError("send",r,null,o.toString())}}}(this))},t.prototype.getXHR=function(){return this._xhr},t.prototype._attachWindowUnload=function(){return this._unloadHandler=this._handleWindowUnload.bind(this),window.attachEvent?window.attachEvent("onunload",this._unloadHandler):void 0},t.prototype._detachWindowUnload=function(){return window.detachEvent?window.detachEvent("onunload",this._unloadHandler):void 0},t.prototype._getHeaders=function(){return s(this._xhr.getAllResponseHeaders())},t.prototype._getResponseText=function(){var e;switch(e="string"==typeof this._xhr.responseText?this._xhr.responseText:"",this._xhr.getResponseHeader("Content-Type")){case"application/json":case"text/javascript":e=JSON.parse(e+"")}return e},t.prototype._getResponseUrl=function(){return null!=this._xhr.responseURL?this._xhr.responseURL:/^X-Request-URL:/m.test(this._xhr.getAllResponseHeaders())?this._xhr.getResponseHeader("X-Request-URL"):""},t.prototype._handleError=function(e,t,n,r){return this._detachWindowUnload(),t({reason:e,status:n||this._xhr.status,statusText:r||this._xhr.statusText,xhr:this._xhr})},t.prototype._handleWindowUnload=function(){return this._xhr.abort()},t}()}),t.define("parse-headers/parse-headers",function(e,n,r,o,i){var a=t("trim"),s=t("for-each"),c=function(e){return"[object Array]"===Object.prototype.toString.call(e)};e.exports=function(e){if(!e)return{};var t={};return s(a(e).split("\n"),function(e){var n=e.indexOf(":"),r=a(e.slice(0,n)).toLowerCase(),o=a(e.slice(n+1));"undefined"==typeof t[r]?t[r]=o:c(t[r])?t[r].push(o):t[r]=[t[r],o]}),t}}),t.define("trim",function(e,t,n,r,o){function i(e){return e.replace(/^\s*|\s*$/g,"")}t=e.exports=i,t.left=function(e){return e.replace(/^\s*/,"")},t.right=function(e){return e.replace(/\s*$/,"")}}),t.define("for-each",function(e,n,r,o,i){function a(e,t,n){if(!u(t))throw new TypeError("iterator must be a function");arguments.length<3&&(n=this),"[object Array]"===d.call(e)?s(e,t,n):"string"==typeof e?c(e,t,n):l(e,t,n)}function s(e,t,n){for(var r=0,o=e.length;o>r;r++)p.call(e,r)&&t.call(n,e[r],r,e)}function c(e,t,n){for(var r=0,o=e.length;o>r;r++)t.call(n,e.charAt(r),r,e)}function l(e,t,n){for(var r in e)p.call(e,r)&&t.call(n,e[r],r,e)}var u=t("is-function");e.exports=a;var d=Object.prototype.toString,p=Object.prototype.hasOwnProperty}),t.define("is-function",function(e,t,n,r,o){function i(e){var t=a.call(e);return"[object Function]"===t||"function"==typeof e&&"[object RegExp]"!==t||"undefined"!=typeof window&&(e===window.setTimeout||e===window.alert||e===window.confirm||e===window.prompt)}e.exports=i;var a=Object.prototype.toString}),t.define("object-assign",function(e,t,n,r,o){"use strict";function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var n,r,o=i(e),c=1;c<arguments.length;c++){n=Object(arguments[c]);for(var l in n)a.call(n,l)&&(o[l]=n[l]);if(Object.getOwnPropertySymbols){r=Object.getOwnPropertySymbols(n);for(var u=0;u<r.length;u++)s.call(n,r[u])&&(o[r[u]]=n[r[u]])}}return o}}),t.define("broken/lib",function(e,n,r,o,i){var a,s;a=t("zousan/zousan-min"),a.suppressUncaughtRejectionError=!0,s=function(){function e(e){this.state=e.state,this.value=e.value,this.reason=e.reason}return e.prototype.isFulfilled=function(){return"fulfilled"===this.state},e.prototype.isRejected=function(){return"rejected"===this.state},e}(),a.reflect=function(e){return new a(function(t,n){return e.then(function(e){return t(new s({state:"fulfilled",value:e}))})["catch"](function(e){return t(new s({state:"rejected",reason:e}))})})},a.settle=function(e){return a.all(e.map(a.reflect))},a.prototype.callback=function(e){return"function"==typeof e&&(this.then(function(t){return e(null,t)}),this["catch"](function(t){return e(t,null)})),this},e.exports=a}),t.define("zousan/zousan-min",function(t,n,r,o,i){!function(e){"use strict";function n(e){if(e){var t=this;e(function(e){t.resolve(e)},function(e){t.reject(e)})}}function r(e,t){if("function"==typeof e.y)try{var n=e.y.call(a,t);e.p.resolve(n)}catch(r){e.p.reject(r)}else e.p.resolve(t)}function o(e,t){if("function"==typeof e.n)try{var n=e.n.call(a,t);e.p.resolve(n)}catch(r){e.p.reject(r)}else e.p.reject(t)}var i,a,s="fulfilled",c="rejected",l="undefined",u=function(){function e(){for(;t.length-n;)t[n](),n++,n>1024&&(t.splice(0,n),n=0)}var t=[],n=0,r=function(){if(typeof MutationObserver!==l){var t=document.createElement("div"),n=new MutationObserver(e);return n.observe(t,{attributes:!0}),function(){t.setAttribute("a",0)}}return typeof setImmediate!==l?function(){setImmediate(e)}:function(){setTimeout(e,0)}}();return function(e){t.push(e),t.length-n==1&&r()}}();n.prototype={resolve:function(e){if(this.state===i){if(e===this)return this.reject(new TypeError("Attempt to resolve promise with self"));var t=this;if(e&&("function"==typeof e||"object"==typeof e))try{var n=!0,o=e.then;if("function"==typeof o)return void o.call(e,function(e){n&&(n=!1,t.resolve(e))},function(e){n&&(n=!1,t.reject(e))})}catch(a){return void(n&&this.reject(a))}this.state=s,this.v=e,t.c&&u(function(){for(var n=0,o=t.c.length;o>n;n++)r(t.c[n],e)})}},reject:function(e){if(this.state===i){this.state=c,this.v=e;var t=this.c;t?u(function(){for(var n=0,r=t.length;r>n;n++)o(t[n],e)}):n.suppressUncaughtRejectionError||console.log("You upset Zousan. Please catch rejections: ",e,e.stack)}},then:function(e,t){var a=new n,c={y:e,n:t,p:a};if(this.state===i)this.c?this.c.push(c):this.c=[c];else{var l=this.state,d=this.v;u(function(){l===s?r(c,d):o(c,d)})}return a},"catch":function(e){return this.then(null,e)},"finally":function(e){return this.then(e,e)},timeout:function(e,t){t=t||"Timeout";var r=this;return new n(function(n,o){setTimeout(function(){o(Error(t))},e),r.then(function(e){n(e)},function(e){o(e)})})}},n.resolve=function(e){var t=new n;return t.resolve(e),t},n.reject=function(e){var t=new n;return t.reject(e),t},n.all=function(e){function t(t,a){"function"!=typeof t.then&&(t=n.resolve(t)),t.then(function(t){r[a]=t,o++,o==e.length&&i.resolve(r)},function(e){i.reject(e)})}for(var r=[],o=0,i=new n,a=0;a<e.length;a++)t(e[a],a);return e.length||i.resolve(r),i},typeof t!=l&&t.exports&&(t.exports=n),e.Zousan=n,n.soon=u}("undefined"!=typeof e?e:this)}),t.define("js-cookie/src/js.cookie",function(e,t,n,r,o){!function(n){if("function"==typeof define&&define.amd)define(n);else if("object"==typeof t)e.exports=n();else{var r=window.Cookies,o=window.Cookies=n();o.noConflict=function(){return window.Cookies=r,o}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(n){function r(t,o,i){var a;if(arguments.length>1){if(i=e({path:"/"},r.defaults,i),"number"==typeof i.expires){var s=new Date;s.setMilliseconds(s.getMilliseconds()+864e5*i.expires),i.expires=s}try{a=JSON.stringify(o),/^[\{\[]/.test(a)&&(o=a)}catch(c){}return o=encodeURIComponent(String(o)),o=o.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape),document.cookie=[t,"=",o,i.expires&&"; expires="+i.expires.toUTCString(),i.path&&"; path="+i.path,i.domain&&"; domain="+i.domain,i.secure?"; secure":""].join("")}t||(a={});for(var l=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,d=0;d<l.length;d++){var p=l[d].split("="),f=p[0].replace(u,decodeURIComponent),h=p.slice(1).join("=");'"'===h.charAt(0)&&(h=h.slice(1,-1));try{if(h=n&&n(h,f)||h.replace(u,decodeURIComponent),this.json)try{h=JSON.parse(h)}catch(c){}if(t===f){a=h;break}t||(a[f]=h)}catch(c){}}return a}return r.get=r.set=r,r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,n){r(t,"",e(n,{expires:-1}))},r.withConverter=t,r}return t()})}),t.define("crowdstart.js/lib/blueprints/browser",function(e,n,r,o,i){var a,s,c,l,u,d,p,f,h,m,g,v,y,b,w,x;for(m=t("crowdstart.js/lib/utils"),d=m.isFunction,v=m.statusCreated,y=m.statusNoContent,b=m.statusOk,g=t("crowdstart.js/lib/blueprints/url"),s=g.byId,w=g.storePrefixed,c=function(e){var t;return t="/"+e,{list:{url:t,method:"GET",expects:b},get:{url:s(e),method:"GET",expects:b}}},a={account:{get:{url:"/account",method:"GET",expects:b},update:{url:"/account",method:"PATCH",expects:b},exists:{url:function(e){var t,n,r;return"/account/exists/"+(null!=(t=null!=(n=null!=(r=e.email)?r:e.username)?n:e.id)?t:e)},method:"GET",expects:b,process:function(e){return e.data.exists}},create:{url:"/account/create",method:"POST",expects:v},enable:{url:function(e){var t;return"/account/enable/"+(null!=(t=e.tokenId)?t:e)},method:"POST",expects:b},login:{url:"/account/login",method:"POST",expects:b,process:function(e){return this.setUserKey(e.data.token),e}},logout:function(){return this.deleteUserKey()},reset:{url:"/account/reset",method:"POST",expects:b},confirm:{url:function(e){var t;return"/account/confirm/"+(null!=(t=e.tokenId)?t:e)},method:"POST",expects:b}},checkout:{authorize:{url:w("/checkout/authorize"),method:"POST",expects:b},capture:{url:w(function(e){var t;return"/checkout/capture/"+(null!=(t=e.orderId)?t:e)}),method:"POST",expects:b},charge:{url:w("/checkout/charge"),method:"POST",expects:b},paypal:{url:w("/checkout/paypal"),method:"POST",expects:b}},referrer:{create:{url:"/referrer",method:"POST",expects:v}}},h=["collection","coupon","product","variant"],x=["order","subscription"],l=function(e){return a[e]=c(e)},u=0,p=h.length;p>u;u++)f=h[u],l(f);e.exports=a}),t.define("crowdstart.js/lib/blueprints/url",function(e,n,r,o,i){var a,s;a=t("crowdstart.js/lib/utils").isFunction,n.storePrefixed=s=function(e){return function(t){var n;return n=a(e)?e(t):e,null!=this.storeId?"/store/"+this.storeId+n:n}},n.byId=function(e){switch(e){case"coupon":return s(function(e){var t;return"/coupon/"+(null!=(t=e.code)?t:e)});case"collection":return s(function(e){var t;return"/collection/"+(null!=(t=e.slug)?t:e)});case"product":return s(function(e){var t,n;return"/product/"+(null!=(t=null!=(n=e.id)?n:e.slug)?t:e)});case"variant":return s(function(e){var t,n;return"/variant/"+(null!=(t=null!=(n=e.id)?n:e.sku)?t:e)});default:return function(t){var n;return"/"+e+"/"+(null!=(n=t.id)?n:t)}}}}),t.define("crowdcontrol/lib",function(e,n,r,o,i){e.exports={config:t("crowdcontrol/lib/config"),utils:t("crowdcontrol/lib/utils"),view:t("crowdcontrol/lib/view"),start:function(e){return t("riot/riot").mount("*")},Events:t("crowdcontrol/lib/events")},"undefined"!=typeof window&&null!==window&&(window.crowdcontrol=e.exports)}),t.define("crowdcontrol/lib/config",function(e,t,n,r,o){e.exports={}}),t.define("crowdcontrol/lib/utils",function(e,n,r,o,i){e.exports={log:t("crowdcontrol/lib/utils/log"),mediator:t("crowdcontrol/lib/utils/mediator")}}),t.define("crowdcontrol/lib/utils/log",function(e,t,n,r,o){var i;i=function(){return i.DEBUG?console.log.apply(console,arguments):void 0},i.DEBUG=!1,i.debug=i,i.info=function(){return console.log.apply(console,arguments)},i.warn=function(){return console.log("WARN:"),console.log.apply(console,arguments)},i.error=function(){throw console.log("ERROR:"),console.log.apply(console,arguments),new arguments[0]},e.exports=i}),t.define("crowdcontrol/lib/utils/mediator",function(e,n,r,o,i){var a;a=t("riot/riot"),e.exports=a.observable({})}),t.define("riot/riot",function(e,t,n,r,o){!function(n,r){"use strict";function o(e){var t=K(0),n=e.trim().slice(t.length).match(/^\s*(\S+?)\s*(?:,\s*(\S+))?\s+in\s+(.+)$/);return n?{key:n[1],pos:n[2],val:t+n[3]}:{val:e}}function i(e,t,n){var r={};return r[e.key]=t,e.pos&&(r[e.pos]=n),r}function a(e,t,n){m(e,"each");var r,a=b(e),s=e.outerHTML,c=!!Z[a],u=Z[a]||{tmpl:s},d=e.parentNode,p=document.createComment("riot placeholder"),f=[],h=g(e);d.insertBefore(p,e),n=o(n),t.one("premount",function(){d.stub&&(d=t.root),e.parentNode.removeChild(e)}).on("update",function(){var o=G(n.val,t);V(o)||(r=o?JSON.stringify(o):"",o=o?Object.keys(o).map(function(e){return i(n,e,o[e])}):[]);for(var s=document.createDocumentFragment(),m=f.length,g=o.length;m>g;)f[--m].unmount(),f.splice(m,1);for(m=0;g>m;++m){var v=!r&&n.key?i(n,o[m],m):o[m];f[m]?f[m].update(v):((f[m]=new l(u,{parent:t,isLoop:!0,hasImpl:c,root:U.test(a)?d:e.cloneNode(),item:v},e.innerHTML)).mount(),s.appendChild(f[m].root)),f[m]._item=v}d.insertBefore(s,p),h&&(t.tags[a]=f)}).one("updated",function(){var e=Object.keys(t);j(d,function(n){1!=n.nodeType||n.isLoop||n._looped||(n._visited=!1,n._looped=!0,T(n,t,e))})})}function s(e,t,n){j(e,function(e){if(1==e.nodeType){e.isLoop=e.isLoop||e.parentNode&&e.parentNode.isLoop||e.getAttribute("each")?1:0;var r=g(e);r&&!e.isLoop&&n.push(v(r,e,t)),e.isLoop||T(e,t,[])}})}function c(e,t,n){function r(e,t,r){if(t.indexOf(K(0))>=0){var o={dom:e,expr:t};n.push(w(o,r))}}j(e,function(e){var n=e.nodeType;if(3==n&&"STYLE"!=e.parentNode.tagName&&r(e,e.nodeValue),1==n){var o=e.getAttribute("each");return o?(a(e,t,o),!1):(f(e.attributes,function(t){var n=t.name,o=n.split("__")[1];return r(e,t.value,{attr:o||n,bool:o}),o?(m(e,n),!1):void 0}),g(e)?!1:void 0)}})}function l(e,t,n){function o(){var e=b&&v?u:g||u;f(S.attributes,function(t){d[t.name]=G(t.value,e)}),f(Object.keys(q),function(t){d[t]=G(q[t],e)})}function i(e){for(var t in j)typeof u[t]!==M&&(u[t]=e[t])}function a(){u.parent&&v&&f(Object.keys(u.parent),function(e){var t=!~H.indexOf(e)&&~I.indexOf(e);(typeof u[e]===M||t)&&(t||I.push(e),u[e]=u.parent[e])})}function l(e){if(f($,function(t){t[e?"mount":"unmount"]()}),g){var t=e?"on":"off";v?g[t]("unmount",u.unmount):g[t]("update",u.update)[t]("unmount",u.unmount)}}var u=L.observable(this),d=A(t.opts)||{},m=W(e.tmpl),g=t.parent,v=t.isLoop,b=t.hasImpl,j=x(t.item),C=[],$=[],S=t.root,T=e.fn,O=S.tagName.toLowerCase(),q={},I=[];T&&S._tag&&S._tag.unmount(!0),this.isMounted=!1,S.isLoop=v,S._tag=this,this._id=P++,w(this,{parent:g,root:S,opts:d,tags:{}},j),f(S.attributes,function(e){var t=e.value;K(/{.*}/).test(t)&&(q[e.name]=t)}),m.innerHTML&&!/^(select|optgroup|table|tbody|tr|col(?:group)?)$/.test(O)&&(m.innerHTML=E(m.innerHTML,n)),this.update=function(e){e=x(e),a(),e&&typeof j===N&&(i(e),j=e),w(u,e),o(),u.trigger("update",e),p(C,u),u.trigger("updated")},this.mixin=function(){f(arguments,function(e){e=typeof e===R?L.mixin(e):e,f(Object.keys(e),function(t){"init"!=t&&(u[t]=h(e[t])?e[t].bind(u):e[t])}),e.init&&e.init.bind(u)()})},this.mount=function(){if(o(),T&&T.call(u,d),c(m,u,C),l(!0),(e.attrs||b)&&(_(e.attrs,function(e,t){S.setAttribute(e,t)}),c(u.root,u,C)),(!u.parent||v)&&u.update(j),u.trigger("premount"),v&&!b)u.root=S=m.firstChild;else{for(;m.firstChild;)S.appendChild(m.firstChild);S.stub&&(u.root=S=g.root)}!u.parent||u.parent.isMounted?(u.isMounted=!0,u.trigger("mount")):u.parent.one("mount",function(){k(u.root)||(u.parent.isMounted=u.isMounted=!0,u.trigger("mount"))})},this.unmount=function(e){var t,n=S,o=n.parentNode;if(o){if(g)t=y(g),V(t.tags[O])?f(t.tags[O],function(e,n){e._id==u._id&&t.tags[O].splice(n,1)}):t.tags[O]=r;else for(;n.firstChild;)n.removeChild(n.firstChild);e?o.removeAttribute("riot-tag"):o.removeChild(n)}u.trigger("unmount"),l(),u.off("*"),S._tag=null},s(m,this,$)}function u(e,t,r,o){r[e]=function(e){var i,a=o._item,s=o.parent;if(!a)for(;s&&!a;)a=s._item,s=s.parent;e=e||n.event;try{e.currentTarget=r,e.target||(e.target=e.srcElement),e.which||(e.which=e.charCode||e.keyCode)}catch(c){}e.item=a,t.call(o,e)===!0||/radio|check/.test(r.type)||(e.preventDefault&&e.preventDefault(),e.returnValue=!1),e.preventUpdate||(i=a?y(s):o,i.update())}}function d(e,t,n){e&&(e.insertBefore(n,t),e.removeChild(t))}function p(e,t){f(e,function(e,n){var r=e.dom,o=e.attr,i=G(e.expr,t),a=e.dom.parentNode;if(e.bool?i=i?o:!1:null==i&&(i=""),a&&"TEXTAREA"==a.tagName&&(i=(""+i).replace(/riot-/g,"")),e.value!==i){if(e.value=i,!o)return void(r.nodeValue=""+i);if(m(r,o),h(i))u(o,i,r,t);else if("if"==o){var s=e.stub,c=function(){d(s.parentNode,s,r)},l=function(){d(r.parentNode,r,s)};i?s&&(c(),r.inStub=!1,k(r)||j(r,function(e){e._tag&&!e._tag.isMounted&&(e._tag.isMounted=!!e._tag.trigger("mount"))})):(s=e.stub=s||document.createTextNode(""),r.parentNode?l():(t.parent||t).one("updated",l),r.inStub=!0)}else if(/^(show|hide)$/.test(o))"hide"==o&&(i=!i),r.style.display=i?"":"none";else if("value"==o)r.value=i;else if(O(o,D)&&o!=F)i&&r.setAttribute(o.slice(D.length),i);else{if(e.bool&&(r[o]=i,!i))return;typeof i!==N&&r.setAttribute(o,i)}}})}function f(e,t){for(var n,r=0,o=(e||[]).length;o>r;r++)n=e[r],null!=n&&t(n,r)===!1&&r--;return e}function h(e){return typeof e===z||!1}function m(e,t){e.removeAttribute(t)}function g(e){return e.tagName&&Z[e.getAttribute(F)||e.tagName.toLowerCase()]}function v(e,t,n){var r,o=new l(e,{root:t,parent:n},t.innerHTML),i=b(t),a=y(n);return o.parent=a,r=a.tags[i],r?(V(r)||(a.tags[i]=[r]),~a.tags[i].indexOf(o)||a.tags[i].push(o)):a.tags[i]=o,t.innerHTML="",o}function y(e){for(var t=e;!g(t.root)&&t.parent;)t=t.parent;return t}function b(e){var t=g(e),n=e.getAttribute("name"),r=n&&n.indexOf(K(0))<0?n:t?t.name:e.tagName.toLowerCase();return r}function w(e){for(var t,n=arguments,r=1;r<n.length;++r)if(t=n[r])for(var o in t)e[o]=t[o];return e}function x(e){if(!(e instanceof l||e&&typeof e.trigger==z))return e;var t={};for(var n in e)~H.indexOf(n)||(t[n]=e[n]);return t}function j(e,t){if(e){if(t(e)===!1)return;for(e=e.firstChild;e;)j(e,t),e=e.nextSibling}}function _(e,t){for(var n,r=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g;n=r.exec(e);)t(n[1].toLowerCase(),n[2]||n[3]||n[4])}function k(e){for(;e;){if(e.inStub)return!0;e=e.parentNode}return!1}function C(e){return document.createElement(e)}function E(e,t){return e.replace(/<(yield)\/?>(<\/\1>)?/gi,t||"")}function $(e,t){return(t||document).querySelectorAll(e)}function S(e,t){return(t||document).querySelector(e)}function A(e){function t(){}return t.prototype=e,new t}function T(e,t,n){if(!e._visited){var r,o=e.getAttribute("id")||e.getAttribute("name");o&&(n.indexOf(o)<0&&(r=t[o],r?V(r)?r.push(e):t[o]=[r,e]:t[o]=e),e._visited=!0)}}function O(e,t){return e.slice(0,t.length)===t}function q(e){if(!L.render){Y||(Y=C("style"),Y.setAttribute("type","text/css"));var t=document.head||document.getElementsByTagName("head")[0];if(Y.styleSheet?Y.styleSheet.cssText+=e:Y.innerHTML+=e,!Y._rendered)if(Y.styleSheet)document.body.appendChild(Y);else{var n=S("style[type=riot]");n?(n.parentNode.insertBefore(Y,n),n.parentNode.removeChild(n)):t.appendChild(Y)}Y._rendered=!0}}function I(e,t,n){var r=Z[t],o=e._innerHTML=e._innerHTML||e.innerHTML;return e.innerHTML="",r&&e&&(r=new l(r,{root:e,opts:n},o)),r&&r.mount?(r.mount(),X.push(r),r.on("unmount",function(){X.splice(X.indexOf(r),1)})):void 0}var L={version:"v2.2.4",settings:{}},P=0,D="riot-",F=D+"tag",R="string",N="object",M="undefined",z="function",U=/^(?:opt(ion|group)|tbody|col|t[rhd])$/,H=["_item","_id","update","root","mount","unmount","mixin","isMounted","isLoop","tags","parent","opts","trigger","on","off","one"],B=0|(n&&n.document||{}).documentMode,V=Array.isArray;L.observable=function(e){e=e||{};var t={},n=0;return e.on=function(r,o){return h(o)&&(typeof o.id===M&&(o._id=n++),r.replace(/\S+/g,function(e,n){(t[e]=t[e]||[]).push(o),o.typed=n>0})),e},e.off=function(n,r){return"*"==n?t={}:n.replace(/\S+/g,function(e){if(r)for(var n,o=t[e],i=0;n=o&&o[i];++i)n._id==r._id&&o.splice(i--,1);else t[e]=[]}),e},e.one=function(t,n){function r(){e.off(t,r),n.apply(e,arguments)}return e.on(t,r)},e.trigger=function(n){for(var r,o=[].slice.call(arguments,1),i=t[n]||[],a=0;r=i[a];++a)r.busy||(r.busy=1,r.apply(e,r.typed?[n].concat(o):o),i[a]!==r&&a--,r.busy=0);return t.all&&"all"!=n&&e.trigger.apply(e,["all",n].concat(o)),e},e},L.mixin=function(){var e={};return function(t,n){return n?void(e[t]=n):e[t]}}(),function(e,t,n){function r(){return s.href.split("#")[1]||""}function o(e){return e.split("/")}function i(e){e.type&&(e=r()),e!=a&&(c.trigger.apply(null,["H"].concat(o(e))),a=e)}if(n){var a,s=n.location,c=e.observable(),l=!1,u=e.route=function(e){e[0]?(s.hash=e,i(e)):c.on("H",e)};u.exec=function(e){e.apply(null,o(r()))},u.parser=function(e){o=e},u.stop=function(){l&&(n.removeEventListener?n.removeEventListener(t,i,!1):n.detachEvent("on"+t,i),c.off("*"),l=!1)},u.start=function(){l||(n.addEventListener?n.addEventListener(t,i,!1):n.attachEvent("on"+t,i),l=!0)},u.start()}}(L,"hashchange",n);var Y,K=function(e){var t,n,r,o=/[{}]/g;return function(i){var a=L.settings.brackets||e;return t!==a&&(t=a,r=a.split(" "),n=r.map(function(e){return e.replace(/(?=.)/g,"\\")})),i instanceof RegExp?a===e?i:new RegExp(i.source.replace(o,function(e){return n[~~("}"===e)]}),i.global?"g":""):r[i]}}("{ }"),G=function(){function e(e,n){return e.indexOf(K(0))<0?(e=e.replace(/\n|\r\n?/g,"\n"),function(){return e}):(e=e.replace(K(/\\{/g),"￰").replace(K(/\\}/g),"￱"),n=o(e,i(e,K(/{/),K(/}/))),e=2!==n.length||n[0]?"["+n.map(function(e,n){return n%2?t(e,!0):'"'+e.replace(/\n|\r\n?/g,"\\n").replace(/"/g,'\\"')+'"'}).join(",")+'].join("")':t(n[1]),new Function("d","return "+e.replace(/\uFFF0/g,K(0)).replace(/\uFFF1/g,K(1))+";"))}function t(e,t){return e=e.replace(/\n|\r\n?/g," ").replace(K(/^[{ ]+|[ }]+$|\/\*.+?\*\//g),""),/^\s*[\w- "']+ *:/.test(e)?"["+i(e,/["' ]*[\w- ]+["' ]*:/,/,(?=["' ]*[\w- ]+["' ]*:)|}|$/).map(function(e){return e.replace(/^[ "']*(.+?)[ "']*: *(.+?),? *$/,function(e,t,n){return n.replace(/[^&|=!><]+/g,r)+'?"'+t+'":"",'})}).join("")+'].join(" ").trim()':r(e,t)}function r(e,t){return e=e.trim(),e?"(function(v){try{v="+e.replace(c,function(e,t,n){return n?'(("'+n+s+n+")":e})+"}catch(e){}return "+(t===!0?'!v&&v!==0?"":v':"v")+"}).call(d)":""}function o(e,t){var n=[];return t.map(function(t,r){r=e.indexOf(t),n.push(e.slice(0,r),t),e=e.slice(r+t.length)}),e&&n.push(e),n}function i(e,t,n){var r,o=0,i=[],a=new RegExp("("+t.source+")|("+n.source+")","g");return e.replace(a,function(t,n,a,s){!o&&n&&(r=s),o+=n?1:-1,o||null==a||i.push(e.slice(r,s+a.length))}),i}var a={},s='"in d?d:'+(n?"window).":"global)."),c=/(['"\/])(?:[^\\]*?|\\.|.)*?\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function\s*\()|([A-Za-z_$]\w*)/g;return function(t,n){return t&&(a[t]||(a[t]=e(t)))(n)}}(),W=function(e){function t(t){var i=t&&t.match(/^\s*<([-\w]+)/),a=i&&i[1].toLowerCase(),s=r[a]||o,c=C(s);return c.stub=!0,e&&a&&(i=a.match(U))?n(c,t,a,!!i[1]):c.innerHTML=t,c}function n(e,t,n,r){var i,a=C(o),s=r?"select>":"table>";a.innerHTML="<"+s+t+"</"+s,i=a.getElementsByTagName(n)[0],i&&e.appendChild(i)}var r={tr:"tbody",th:"tr",td:"tr",tbody:"table",col:"colgroup"},o="div";return e=e&&10>e,t}(B),X=[],Z={};L.tag=function(e,t,n,r,o){return h(r)&&(o=r,/^[\w\-]+\s?=/.test(n)?(r=n,n=""):r=""),n&&(h(n)?o=n:q(n)),Z[e]={name:e,tmpl:t,attrs:r,fn:o},e},L.mount=function(e,t,n){function r(e){var t="";return f(e,function(e){t+=", *["+F+'="'+e.trim()+'"]'}),t}function o(){var e=Object.keys(Z);return e+r(e)}function i(e){var r;if(e.tagName){!t||(r=e.getAttribute(F))&&r==t||e.setAttribute(F,t);var o=I(e,t||e.getAttribute(F)||e.tagName.toLowerCase(),n);o&&c.push(o)}else e.length&&f(e,i)}var a,s,c=[];if(typeof t===N&&(n=t,t=0),typeof e===R?("*"===e?e=s=o():e+=r(e.split(",")),a=$(e)):a=e,"*"===t){if(t=s||o(),a.tagName)a=$(t,a);else{var l=[];f(a,function(e){l.push($(t,e))}),a=l}t=0}return a.tagName?i(a):f(a,i),c},L.update=function(){return f(X,function(e){e.update()})},L.mountTo=L.mount,L.util={brackets:K,tmpl:G},typeof t===N?e.exports=L:"function"==typeof define&&define.amd?define(function(){return n.riot=L}):n.riot=L}("undefined"!=typeof window?window:void 0)}),t.define("crowdcontrol/lib/view",function(e,n,r,o,i){e.exports={form:t("crowdcontrol/lib/view/form"),View:t("crowdcontrol/lib/view/view")}}),t.define("crowdcontrol/lib/view/form",function(e,n,r,o,i){var a,s,c,l,u,d,p,f,h,m,g,v,y,b,w,x,j,_,k=function(e,t){function n(){this.constructor=e}for(var r in t)C.call(t,r)&&(e[r]=t[r]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e},C={}.hasOwnProperty;p=t("broken/lib"),g=t("is-array"),v=t("is-function"),y=t("is-number"),b=t("is-object"),x=t("riot/riot"),a=t("crowdcontrol/lib/events"),h=t("crowdcontrol/lib/view/view"),w=t("crowdcontrol/lib/utils/log"),j=function(e){var t,n,r,o,i,a,s,c;for(s=e.split(" "),t={},n=0,o=s.length;o>n;n++)a=s[n],a.indexOf(":")>=0?(i=a.split(":"),r=i[0],c=i[1],t[r]=c):t[a]=!0;return t},u=function(){function e(e,t,n,r){this.name=e,this["default"]=null!=t?t:"",this.placeholder=null!=n?n:"",null==r&&(r=""),this.hints=j(r)}return e.prototype.name="",e.prototype["default"]="",e.prototype.placeholder="",e.prototype.hints=null,e}(),c=function(){function e(e,t,n){this.tag=e,this.model=t,this.validator=n}return e.prototype.tag="",e.prototype.model={},e.prototype.validator=function(){},e.prototype.obs=null,e}(),f=function(){function e(e,t){this.predicate=e,this.validatorFn=t}return e}(),l=function(){function e(e,t){this.predicate=e,this.tagName=t}return e}(),m={tagLookup:[],validatorLookup:[],defaultTagName:"form-input",errorTag:"form-error",registerValidator:function(e,t){return v(t)?this.validatorLookup.push(new f(e,t)):void 0},registerTag:function(e,t){return this.tagLookup.push(new l(e,t))},deleteTag:function(e){var t,n,r,o,i,a;for(i=this.tagLookup,a=[],t=n=0,r=i.length;r>n;t=++n)o=i[t],o.tagName===e?a.push(this.tagLookup[t]=null):a.push(void 0); return a},deleteValidator:function(e,t){var n,r,o,i,a,s;for(a=this.validatorLookup,s=[],n=r=0,o=a.length;o>r;n=++r)i=a[n],i.validatorFn===t?s.push(this.validatorLookup[n]=null):s.push(void 0);return s},render:function(e){var t,n,r,o,i,a,s;for(o={},t=function(e){return function(t,n){var r,i,a,s,l,u,d,f,h,m,g,v;for(f=e.validatorLookup,i=0,a=f.length;a>i;i++)l=f[i],l.predicate(n)&&(v=l.validatorFn,function(e){return t.push(function(t){var r,o,i;return r=t[0],o=t[1],i=new p(function(e,n){return e(t)}),i.then(function(t){return e.call(n,t[0],t[1])}).then(function(e){return r[o]=e,new p(function(e,n){return e(t)})})})}(v));for(t.push(function(e){var t,n;return t=e[0],n=e[1],new p(function(e,r){return e(t[n])})}),g=function(e,n){var r,o,i;for(i=new p(function(t,r){return t([e,n])}),o=0,r=t.length;r>o;o++)v=t[o],i=i.then(v);return i},r=!1,h=e.tagLookup,u=0,s=h.length;s>u;u++)if(l=h[u],null!=l&&l.predicate(n)){m=l.tagName,r=!0;break}return r||(m=e.defaultTagName),d={name:n.name,value:n["default"],placeholder:n.placeholder,cfg:n},o[n.name]=new c(m,d,g)}}(this),n=i=0,a=e.length;a>i;n=++i)r=e[n],null!=r&&(s=[],t(s,r));return o}},a.Input={Result:"input-result",Get:"input-get",Set:"input-set",Change:"input-change",Error:"input-error",ClearError:"input-clear-error"},d=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}var n;return k(t,e),t.prototype.getValue=function(e){return e.value},t.prototype.errorHtml='<div class="error-container" if="{ hasError() }">\n <div class="error-message">{ error }</div>\n</div>',t.prototype.init=function(){return this.html+=this.errorHtml},t.prototype.events=(n={},n[""+a.Input.Set]=function(){return this._set.apply(this,arguments)},n[""+a.Input.Error]=function(){return this._error.apply(this,arguments)},n[""+a.Input.ClearError]=function(){return this._clearError.apply(this,arguments)},n),t.prototype._clearError=function(e){return e===this.model.name?(this.clearError(),this.update()):void 0},t.prototype._error=function(e,t){return e===this.model.name?(this.setError(t),this.update()):void 0},t.prototype._set=function(e,t){return e===this.model.name?(this.clearError(),this.model.value=t,this.update()):void 0},t.prototype.change=function(e){var t;return t=this.getValue(e.target),(""===t||t!==this.model.value)&&this.obs.trigger(a.Input.Change,this.model.name,t),this.model.value=t},t.prototype.hasError=function(){var e;return e=this.error,null!=e&&null!=e.length&&e.length>0},t.prototype.setError=function(e){return this.error=e},t.prototype.clearError=function(){return this.setError(null)},t.prototype.js=function(e){return this.model=e.input.model},t}(h),x.tag("control","",function(e){var t;return t=e.input,null!=t?(e.obs=t.obs,x.mount(this.root,t.tag,e)):void 0}),a.Form={SubmitSuccess:"form-submit-success",SubmitFailed:"form-submit-failed"},s=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}var n;return k(t,e),t.prototype.inputConfigs=null,t.prototype.events=(n={},n[""+a.Input.Get]=function(){return this._result.apply(this,arguments)},n[""+a.Input.Change]=function(){return this._change.apply(this,arguments)},n),t.prototype._change=function(e,t){var n,r,o,i;return this.fullyValidated=!1,i=this._set(this.model,e,t),o=i[0],r=i[1],n=this.inputs[e],null!=n?n.validator(o,r).then(function(t){return function(n){return t.obs.trigger(a.Input.Set,e,n)}}(this))["catch"](function(t){return function(n){return w("Validation error has occured",n.stack),t.obs.trigger(a.Input.Error,e,n.message)}}(this)):void 0},t.prototype._result=function(e){return this.obs.trigger(a.Input.Result,this._get(this.model,e))},t.prototype._submit=function(e){},t.prototype.submit=function(e){var t,n,r,o,i,s,c,l;if(null!=e&&e.preventDefault(),this.fullyValidated)return void this._submit(e);i=[],s=[],c=this.inputs;for(o in c)t=c[o],i.push(o),l=this._find(this.model,o),r=l[0],n=l[1],s.push(t.validator(r,n));return p.settle(s).then(function(t){return function(n){var r,o,s,c,l;for(c=!1,r=o=0,s=n.length;s>o;r=++o)l=n[r],l.isRejected()&&(c=!0,t.obs.trigger(a.Input.Error,i[r],l.reason.message));return c?void t.obs.trigger(a.Form.SubmitFailed,t.model):(t.fullyValidated=!0,t.obs.trigger(a.Form.SubmitSuccess,t.model),t._submit(e))}}(this))},t.prototype._get=function(e,t){var n,r,o,i,a;if(a=t.split("."),1===a.length)return e[t];for(n=e,r=0,o=a.length;o>r;r++){if(i=a[r],null==n[i])return;n=n[i]}return n[lastName]},t.prototype._set=function(e,t,n){var r,o,i;return i=this._find(e,t),r=i[0],o=i[1],r[o]=n,[r,o]},t.prototype._find=function(e,t){var n,r,o,i,a,s;if(s=t.split("."),1===s.length)return[e,t];for(o=s.pop(),n=e,r=0,i=s.length;i>r;r++)a=s[r],null==n[a]?(y(a)?n[a]=[]:n[a]={},n=n[a]):n=n[a];return[n,o]},t.prototype.js=function(){return this.initFormGroup()},t.prototype.initFormGroup=function(){var e,t,n;if(null!=this.inputConfigs){null==this.inputs?this.inputs=t=m.render(this.inputConfigs):t=this.inputs;for(n in t)e=t[n],e.obs=this.obs;return this.fullyValidated=!1,_(this.model,function(e,n){return null!=t[e]?t[e].model.value=n:void 0})}},t}(h),_=function(e,t,n){var r,o,i;if(null==n&&(n=""),g(e)||b(e)){o=[];for(r in e)i=e[r],o.push(_(i,t,""===n?r:n+"."+r));return o}return t(n,e)},e.exports={helpers:m,FormView:s,InputView:d,Input:c,InputConfig:u,tokenize:j}}),t.define("is-array",function(e,t,n,r,o){var i=Array.isArray,a=Object.prototype.toString;e.exports=i||function(e){return!!e&&"[object Array]"==a.call(e)}}),t.define("is-number",function(e,n,r,o,i){"use strict";var a=t("kind-of");e.exports=function(e){var t=a(e);if("number"!==t&&"string"!==t)return!1;var n=+e;return n-n+1>=0&&""!==e}}),t.define("kind-of",function(e,n,r,o,i){var a=t("is-buffer"),s=Object.prototype.toString;e.exports=function(e){if("undefined"==typeof e)return"undefined";if(null===e)return"null";if(e===!0||e===!1||e instanceof Boolean)return"boolean";if("string"==typeof e||e instanceof String)return"string";if("number"==typeof e||e instanceof Number)return"number";if("function"==typeof e||e instanceof Function)return"function";if("undefined"!=typeof Array.isArray&&Array.isArray(e))return"array";if(e instanceof RegExp)return"regexp";if(e instanceof Date)return"date";var t=s.call(e);return"[object RegExp]"===t?"regexp":"[object Date]"===t?"date":"[object Arguments]"===t?"arguments":"undefined"!=typeof Buffer&&a(e)?"buffer":"[object Set]"===t?"set":"[object WeakSet]"===t?"weakset":"[object Map]"===t?"map":"[object WeakMap]"===t?"weakmap":"[object Symbol]"===t?"symbol":"[object Int8Array]"===t?"int8array":"[object Uint8Array]"===t?"uint8array":"[object Uint8ClampedArray]"===t?"uint8clampedarray":"[object Int16Array]"===t?"int16array":"[object Uint16Array]"===t?"uint16array":"[object Int32Array]"===t?"int32array":"[object Uint32Array]"===t?"uint32array":"[object Float32Array]"===t?"float32array":"[object Float64Array]"===t?"float64array":"object"}}),t.define("is-buffer",function(e,t,n,r,o){e.exports=function(e){return!(null==e||!(e._isBuffer||e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)))}}),t.define("is-object",function(e,t,n,r,o){"use strict";e.exports=function(e){return"object"==typeof e&&null!==e}}),t.define("crowdcontrol/lib/events",function(e,t,n,r,o){e.exports={}}),t.define("crowdcontrol/lib/view/view",function(e,n,r,o,i){var a,s,c,l,u;c=t("is-function"),s=t("extend"),l=t("riot/riot"),u=t("crowdcontrol/lib/utils"),a=function(){function e(){var t,n,r,o;for(n=Object.getPrototypeOf(this),t=n,r={};t!==e.prototype;)t=Object.getPrototypeOf(t),n.events=s({},t.events||{},n.events),s(r,t||{},n);s(n,r),o=this,this.init(),l.tag(this.tag,this.html,this.css,this.attrs,function(e){var t,n,r,i,a,s,u,d,p;s=Object.getPrototypeOf(e);for(r in e)p=e[r],null!=s[r]&&null==p&&(e[r]=s[r]);if(null!=o){u=Object.getPrototypeOf(o);for(r in u)p=u[r],c(p)?!function(e){return function(t){var n;return null!=e[r]?(n=e[r],e[r]=function(){return n.apply(e,arguments),t.apply(e,arguments)}):e[r]=function(){return t.apply(e,arguments)}}}(this)(p):this[r]=p}if(this.model=e.model||this.model,null==this.model&&(this.model={}),a=this.obs=e.obs,null==this.obs&&(a=this.obs={},l.observable(a)),null!=o.events){d=o.events,t=function(e){return function(t,n){return a.on(t,function(){return n.apply(e,arguments)})}}(this);for(i in d)n=d[i],t(i,n)}return this.js?this.js(e):void 0})}return e.register=function(){return new this},e.prototype.tag="",e.prototype.html="",e.prototype.css="",e.prototype.attrs="",e.prototype.events=null,e.prototype.mixins=null,e.prototype.model=null,e.prototype.init=function(){},e.prototype.js=function(){},e}(),e.exports=a}),t.define("extend",function(e,t,n,r,o){"use strict";var i=Object.prototype.hasOwnProperty,a=Object.prototype.toString,s=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===a.call(e)},c=function(e){if(!e||"[object Object]"!==a.call(e))return!1;var t=i.call(e,"constructor"),n=e.constructor&&e.constructor.prototype&&i.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!n)return!1;var r;for(r in e);return"undefined"==typeof r||i.call(e,r)};e.exports=function l(){var e,t,n,r,o,i,a=arguments[0],u=1,d=arguments.length,p=!1;for("boolean"==typeof a?(p=a,a=arguments[1]||{},u=2):("object"!=typeof a&&"function"!=typeof a||null==a)&&(a={});d>u;++u)if(e=arguments[u],null!=e)for(t in e)n=a[t],r=e[t],a!==r&&(p&&r&&(c(r)||(o=s(r)))?(o?(o=!1,i=n&&s(n)?n:[]):i=n&&c(n)?n:{},a[t]=l(p,i,r)):"undefined"!=typeof r&&(a[t]=r));return a}}),t.define("raf",function(e,n,r,o,i){for(var a=t("performance-now/lib/performance-now"),s="undefined"==typeof window?{}:window,c=["moz","webkit"],l="AnimationFrame",u=s["request"+l],d=s["cancel"+l]||s["cancelRequest"+l],p=0;p<c.length&&!u;p++)u=s[c[p]+"Request"+l],d=s[c[p]+"Cancel"+l]||s[c[p]+"CancelRequest"+l];if(!u||!d){var f=0,h=0,m=[],g=1e3/60;u=function(e){if(0===m.length){var t=a(),n=Math.max(0,g-(t-f));f=n+t,setTimeout(function(){var e=m.slice(0);m.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(f)}catch(n){setTimeout(function(){throw n},0)}},Math.round(n))}return m.push({handle:++h,callback:e,cancelled:!1}),h},d=function(e){for(var t=0;t<m.length;t++)m[t].handle===e&&(m[t].cancelled=!0)}}e.exports=function(e){return u.call(s,e)},e.exports.cancel=function(){d.apply(s,arguments)}}),t.define("performance-now/lib/performance-now",function(e,t,n,r,o){(function(){var t,n,r;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof o&&null!==o&&o.hrtime?(e.exports=function(){return(t()-r)/1e6},n=o.hrtime,t=function(){var e;return e=n(),1e9*e[0]+e[1]},r=t()):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)}),t.define("./Users/dtai/work/verus/checkout/vendor/js/select2",function(e,t,n,r,o){!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)}(function(e){var t=function(){if(e&&e.fn&&e.fn.select2&&e.fn.select2.amd)var t=e.fn.select2.amd;var t;return function(){if(!t||!t.requirejs){t?n=t:t={};var e,n,r;!function(t){function o(e,t){return w.call(e,t)}function i(e,t){var n,r,o,i,a,s,c,l,u,d,p,f=t&&t.split("/"),h=y.map,m=h&&h["*"]||{};if(e&&"."===e.charAt(0))if(t){for(f=f.slice(0,f.length-1),e=e.split("/"),a=e.length-1,y.nodeIdCompat&&j.test(e[a])&&(e[a]=e[a].replace(j,"")),e=f.concat(e),u=0;u<e.length;u+=1)if(p=e[u],"."===p)e.splice(u,1),u-=1;else if(".."===p){if(1===u&&(".."===e[2]||".."===e[0]))break;u>0&&(e.splice(u-1,2),u-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((f||m)&&h){for(n=e.split("/"),u=n.length;u>0;u-=1){if(r=n.slice(0,u).join("/"),f)for(d=f.length;d>0;d-=1)if(o=h[f.slice(0,d).join("/")],o&&(o=o[r])){i=o,s=u;break}if(i)break;!c&&m&&m[r]&&(c=m[r],l=u)}!i&&c&&(i=c,s=l),i&&(n.splice(0,s,i),e=n.join("/"))}return e}function a(e,n){return function(){return f.apply(t,x.call(arguments,0).concat([e,n]))}}function s(e){return function(t){return i(t,e)}}function c(e){return function(t){g[e]=t}}function l(e){if(o(v,e)){var n=v[e];delete v[e],b[e]=!0,p.apply(t,n)}if(!o(g,e)&&!o(b,e))throw new Error("No "+e);return g[e]}function u(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function d(e){return function(){return y&&y.config&&y.config[e]||{}}}var p,f,h,m,g={},v={},y={},b={},w=Object.prototype.hasOwnProperty,x=[].slice,j=/\.js$/;h=function(e,t){var n,r=u(e),o=r[0];return e=r[1],o&&(o=i(o,t),n=l(o)),o?e=n&&n.normalize?n.normalize(e,s(t)):i(e,t):(e=i(e,t),r=u(e),o=r[0],e=r[1],o&&(n=l(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:n}},m={require:function(e){return a(e)},exports:function(e){var t=g[e];return"undefined"!=typeof t?t:g[e]={}},module:function(e){return{id:e,uri:"",exports:g[e],config:d(e)}}},p=function(e,n,r,i){var s,u,d,p,f,y,w=[],x=typeof r;if(i=i||e,"undefined"===x||"function"===x){for(n=!n.length&&r.length?["require","exports","module"]:n,f=0;f<n.length;f+=1)if(p=h(n[f],i),u=p.f,"require"===u)w[f]=m.require(e);else if("exports"===u)w[f]=m.exports(e),y=!0;else if("module"===u)s=w[f]=m.module(e);else if(o(g,u)||o(v,u)||o(b,u))w[f]=l(u);else{if(!p.p)throw new Error(e+" missing "+u);p.p.load(p.n,a(i,!0),c(u),{}),w[f]=g[u]}d=r?r.apply(g[e],w):void 0,e&&(s&&s.exports!==t&&s.exports!==g[e]?g[e]=s.exports:d===t&&y||(g[e]=d))}else e&&(g[e]=r)},e=n=f=function(e,n,r,o,i){if("string"==typeof e)return m[e]?m[e](n):l(h(e,n).f);if(!e.splice){if(y=e,y.deps&&f(y.deps,y.callback),!n)return;n.splice?(e=n,n=r,r=null):e=t}return n=n||function(){},"function"==typeof r&&(r=o,o=i),o?p(t,e,n,r):setTimeout(function(){p(t,e,n,r)},4),f},f.config=function(e){return f(e)},e._defined=g,r=function(e,t,n){t.splice||(n=t,t=[]),o(g,e)||o(v,e)||(v[e]=[e,t,n])},r.amd={jQuery:!0}}(),t.requirejs=e,t.require=n,t.define=r}}(),t.define("almond",function(){}),t.define("jquery",[],function(){var t=e||$;return null==t&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),t}),t.define("select2/utils",["jquery"],function(e){function t(e){var t=e.prototype,n=[];for(var r in t){var o=t[r];"function"==typeof o&&"constructor"!==r&&n.push(r)}return n}var n={};n.Extend=function(e,t){function n(){this.constructor=e}var r={}.hasOwnProperty;for(var o in t)r.call(t,o)&&(e[o]=t[o]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e},n.Decorate=function(e,n){function r(){var t=Array.prototype.unshift,r=n.prototype.constructor.length,o=e.prototype.constructor;r>0&&(t.call(arguments,e.prototype.constructor),o=n.prototype.constructor),o.apply(this,arguments)}function o(){this.constructor=r}var i=t(n),a=t(e);n.displayName=e.displayName,r.prototype=new o;for(var s=0;s<a.length;s++){var c=a[s];r.prototype[c]=e.prototype[c]}for(var l=(function(e){var t=function(){};e in r.prototype&&(t=r.prototype[e]);var o=n.prototype[e];return function(){var e=Array.prototype.unshift;return e.call(arguments,t),o.apply(this,arguments)}}),u=0;u<i.length;u++){var d=i[u];r.prototype[d]=l(d)}return r};var r=function(){this.listeners={}};return r.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},r.prototype.trigger=function(e){var t=Array.prototype.slice;this.listeners=this.listeners||{},e in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},r.prototype.invoke=function(e,t){for(var n=0,r=e.length;r>n;n++)e[n].apply(this,t)},n.Observable=r,n.generateChars=function(e){for(var t="",n=0;e>n;n++){var r=Math.floor(36*Math.random());t+=r.toString(36)}return t},n.bind=function(e,t){return function(){e.apply(t,arguments)}},n._convertData=function(e){for(var t in e){var n=t.split("-"),r=e;if(1!==n.length){for(var o=0;o<n.length;o++){var i=n[o];i=i.substring(0,1).toLowerCase()+i.substring(1),i in r||(r[i]={}),o==n.length-1&&(r[i]=e[t]),r=r[i]}delete e[t]}}return e},n.hasScroll=function(t,n){var r=e(n),o=n.style.overflowX,i=n.style.overflowY;return o!==i||"hidden"!==i&&"visible"!==i?"scroll"===o||"scroll"===i?!0:r.innerHeight()<n.scrollHeight||r.innerWidth()<n.scrollWidth:!1},n.escapeMarkup=function(e){var t={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},n.appendMany=function(t,n){if("1.7"===e.fn.jquery.substr(0,3)){var r=e();e.map(n,function(e){r=r.add(e)}),n=r}t.append(n)},n}),t.define("select2/results",["jquery","./utils"],function(e,t){function n(e,t,r){this.$element=e,this.data=r,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,t.Observable),n.prototype.render=function(){var t=e('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&t.attr("aria-multiselectable","true"),this.$results=t,t},n.prototype.clear=function(){this.$results.empty()},n.prototype.displayMessage=function(t){var n=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var r=e('<li role="treeitem" class="select2-results__option"></li>'),o=this.options.get("translations").get(t.message);r.append(n(o(t.args))),this.$results.append(r)},n.prototype.append=function(e){this.hideLoading();var t=[];if(null==e.results||0===e.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var r=e.results[n],o=this.option(r);t.push(o)}this.$results.append(t)},n.prototype.position=function(e,t){var n=t.find(".select2-results");n.append(e)},n.prototype.sort=function(e){var t=this.options.get("sorter");return t(e)},n.prototype.setClasses=function(){var t=this;this.data.current(function(n){var r=e.map(n,function(e){return e.id.toString()}),o=t.$results