var recurly=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/build/",t(t.s=36)}([function(e,t,n){(function(r){function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}}function a(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function u(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function s(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}t=e.exports=n(40),t.log=a,t.formatArgs=o,t.save=u,t.load=s,t.useColors=i,t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(s())}).call(t,n(39))},function(e,t,n){"use strict";function r(e,t){return r.get(e,t)}var i=n(23);e.exports=r,r.map={},r.baseURL="",r.doc=function(e){r.baseURL=e},r.get=function(e,t){if(e in r.map)return new r.map[e](t);throw new Error("invalid error: "+e)},r.add=function(e,t){function n(n){Error.call(this),this.name=this.code=e,t.message instanceof Function?this.message=t.message(n):this.message=t.message,i(this,n||{}),t.help&&(this.help=r.baseURL+t.help,this.message+=" (need help? "+this.help+")")}return t=t||{},n.prototype=new Error,r.map[e]=n},r.doc("https://docs.recurly.com/js"),r.add("already-configured",{message:"Configuration may only be set once.",help:"#identify-your-site"}),r.add("config-missing-public-key",{message:"The publicKey setting is required.",help:"#identify-your-site"}),r.add("config-missing-fields",{message:"The fields setting is required."}),r.add("missing-hosted-field-target",{message:function(e){return"Target element not found for "+e.type+" field using selector '"+e.selector+"'"}}),r.add("api-error",{message:"There was an error with your request."}),r.add("api-timeout",{message:"The API request timed out."}),r.add("validation",{message:"There was an error validating your request."}),r.add("missing-callback",{message:"Missing callback"}),r.add("invalid-options",{message:"Options must be an object"}),r.add("invalid-option",{message:function(e){return"Option "+e.name+" must be "+e.expect}}),r.add("missing-plan",{message:"A plan must be specified."}),r.add("missing-coupon",{message:"A coupon must be specified."}),r.add("invalid-item",{message:"The given item does not appear to be a valid recurly plan, coupon, addon, or taxable address."}),r.add("invalid-addon",{message:"The given addon_code is not among the valid addons for the specified plan."}),r.add("invalid-currency",{message:function(e){return"The given currency ("+e.currency+") is not among the valid codes for the specified plan(s): "+e.allowed+"."}}),r.add("invalid-plan-currency",{message:function(e){return"The requested plan ("+e.planCode+") does not support the possible checkout currencies: "+e.currencies+"."}}),r.add("invalid-subscription-currency",{message:"The given subscription does not support the currencies of this Checkout instance's existing subscriptions"}),r.add("unremovable-item",{message:"The given item cannot be removed."}),r.add("fraud-data-collector-request-failed",{message:function(e){return"There was an error getting the data collector fields: "+e.error}}),r.add("fraud-data-collector-missing-form",{message:function(e){return"There was an error finding a form to inject the data collector fields using selector '"+e.selector+"'"}}),r.add("gift-card-currency-mismatch",{message:"The giftcard currency does not match the given currency."}),r.add("apple-pay-not-supported",{message:"Apple Pay is not supported by this device or browser."}),r.add("apple-pay-not-available",{message:"Apple Pay is supported by this device, but the customer has not configured Apple Pay."}),r.add("apple-pay-config-missing",{message:function(e){return"Missing Apple Pay configuration option: '"+e.opt+"'"}}),r.add("apple-pay-config-invalid",{message:function(e){return"Apple Pay configuration option '"+e.opt+"' is not among your available options: "+e.set+".\n Please refer to your site configuration if the available options is incorrect."}}),r.add("apple-pay-factory-only",{message:"Apple Pay must be initialized by calling recurly.ApplePay"}),r.add("apple-pay-init-error",{message:function(e){var t="Apple Pay did not initialize due to a fatal error";return e.err&&(t+=": "+e.err.message),t}}),r.add("apple-pay-payment-failure",{message:"Apply Pay could not charge the customer"}),r.add("paypal-factory-only",{message:"PayPal must be initialized by calling recurly.PayPal"}),r.add("paypal-config-missing",{message:function(e){return"Missing PayPal configuration option: '"+e.opt+"'"}}),r.add("paypal-load-error",{message:"Client libraries failed to load"}),r.add("paypal-client-error",{message:"PayPal encountered an unexpected error"}),r.add("paypal-tokenize-error",{message:"An error occurred while attempting to generate the PayPal token"}),r.add("paypal-tokenize-recurly-error",{message:"An error occurred while attempting to generate the Recurly token"}),r.add("paypal-braintree-not-ready",{message:"Braintree PayPal is not yet ready to create a checkout flow"}),r.add("paypal-braintree-api-error",{message:"Braintree API experienced an error"}),r.add("paypal-braintree-tokenize-braintree-error",{message:"An error occurred while attempting to generate the Braintree token"}),r.add("paypal-braintree-tokenize-recurly-error",{message:"An error occurred while attempting to generate the Braintree token within Recurly"})},function(e,t){function n(e){if(e)return r(e)}function r(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},n.prototype.once=function(e,t){function n(){r.off(e,n),t.apply(this,arguments)}var r=this;return this._callbacks=this._callbacks||{},n.fn=t,this.on(e,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[e];if(!n)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var r,i=0;i0&&void 0!==arguments[0]?arguments[0]:12;return Math.random().toString(36).substr(2,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r},function(e,t,n){"use strict";e.exports=n(44)},function(e,t,n){"use strict";function r(){}function i(e){try{return e.then}catch(e){return m=e,b}}function o(e,t){try{return e(t)}catch(e){return m=e,b}}function a(e,t,n){try{e(t,n)}catch(e){return m=e,b}}function u(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._45=0,this._81=0,this._65=null,this._54=null,e!==r&&y(e,this)}function s(e,t,n){return new e.constructor(function(i,o){var a=new u(r);a.then(i,o),c(e,new h(t,n,a))})}function c(e,t){for(;3===e._81;)e=e._65;if(u._10&&u._10(e),0===e._81)return 0===e._45?(e._45=1,void(e._54=t)):1===e._45?(e._45=2,void(e._54=[e._54,t])):void e._54.push(t);l(e,t)}function l(e,t){v(function(){var n=1===e._81?t.onFulfilled:t.onRejected;if(null===n)return void(1===e._81?f(t.promise,e._65):d(t.promise,e._65));var r=o(n,e._65);r===b?d(t.promise,m):f(t.promise,r)})}function f(e,t){if(t===e)return d(e,new TypeError("A promise cannot be resolved with itself."));if(t&&("object"==typeof t||"function"==typeof t)){var n=i(t);if(n===b)return d(e,m);if(n===e.then&&t instanceof u)return e._81=3,e._65=t,void p(e);if("function"==typeof n)return void y(n.bind(t),e)}e._81=1,e._65=t,p(e)}function d(e,t){e._81=2,e._65=t,u._97&&u._97(e,t),p(e)}function p(e){if(1===e._45&&(c(e,e._54),e._54=null),2===e._45){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{},n="input";~["button","select"].indexOf(e.type)&&(n=e.type,delete e.type);var r=t.document.createElement(n);return"type"in e||(e.type="text"),"style"in e||(e.style="position: absolute; top: 0px; left: -1000px; opacity: 0;"),Object.keys(e).forEach(function(t){return r.setAttribute(t,e[t])}),r}var d=n(54),p=n(4);e.exports={createHiddenInput:f,data:u,element:r,findNodeInParents:l,value:i}}).call(t,n(3))},function(e,t,n){function r(e){return function(t){for(var n in e)if(t[n]!=e[n])return!1;return!0}}var i=n(64);e.exports=function(e,t){"function"!=typeof t&&(t=Object(t)===t?r(t):i(t));for(var n=0,o=e.length;n1&&void 0!==arguments[1]?arguments[1]:{},r=n.internal,i=void 0!==r&&r;return this.debug("reprice"),new v.default(function(e,n){new t.Calculations(t,function(n){if(JSON.stringify(n)===JSON.stringify(t.price))return e(n);t.price=n,i||t.emit("change:external",n),t.emit("change",n),e(n)})},this).nodeify(e)}},{key:"remove",value:function(e,t){var n=this,r=void 0;return this.debug("remove"),new v.default(function(t,i){var o=Object.keys(e)[0],a=e[o];if(!~Object.keys(n.items).indexOf(o))return n.error((0,b.default)("invalid-item"),i);if(Array.isArray(n.items[o])){var s=n.items[o].indexOf(u(n.items[o],{code:a}));~s&&(r=n.items[o].splice(s))}else{if(!n.items[o]||a!==n.items[o].code&&!0!==a)return n.error((0,b.default)("unremovable-item",{type:o,id:a,reason:"does not exist on this pricing instance."}),i);r=n.items[o],delete n.items[o]}t()},this).nodeify(t)}},{key:"itemUpdateFactory",value:function(e,t){var n=this;return function(r,i){if(JSON.stringify(t)===JSON.stringify(n.items[e]))return r(n.items[e]);n.items[e]=t,_("set."+e),n.emit("set."+e,t),r(t)}}},{key:"error",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments[2];return r&&r.split(".").reduce(function(n,r){return t.emit(n+"."+r,e)},"error"),this.emit("error",e),n(e)}},{key:"Calculations",get:function(){throw new Error("Not implemented")}},{key:"PRICING_METHODS",get:function(){return["reset","remove","reprice"]}},{key:"hasPrice",get:function(){return!!this.price}},{key:"totalNow",get:function(){return(0,w.default)(this.hasPrice?this.price.now.total:0)}},{key:"subtotalPreDiscountNow",get:function(){var e=parseFloat(this.price.now.subtotal)+parseFloat(this.price.now.discount);return(0,w.default)(this.hasPrice?e:0)}},{key:"currencyCode",get:function(){return this.items.currency||""}},{key:"currencySymbol",get:function(){return(0,l.default)(this.currencyCode)}}]),t}(d.default);t.Pricing=O},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n1?r-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:{},r=n.id,a=void 0===r?(0,w.default)():r;i(this,t);var u=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return u.id=a,u.debug=_,u}return a(t,e),s(t,[{key:"reset",value:function(){c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"reset",this).call(this),this.items.addons=[]}},{key:"attach",value:function(e){var t=this;return this.attachment&&this.attachment.detach(),this.attachment=new v.default(this,e),this.attachment.once("ready",function(){return t.emit("attached")}),this.attachment}},{key:"plan",value:function(){var e=this,t=this.resolvePlanOptions.apply(this,arguments),n=t.currentPlan,r=t.quantity,i=t.planCode,o=(t.options,t.done);return new d.default(function(t,o){if(n&&n.code===i)return n.quantity=r,t(n);e.recurly.plan(i,function(n,i){if(n)return e.error(n,o,"plan");var a=function(){_("set.plan"),e.emit("set.plan",i),t(i)};i.quantity=r,e.items.plan=i,e.items.currency in i.price||e.currency(Object.keys(i.price)[0]),e.items.coupon?e.coupon(e.items.coupon.code).then(a,a):a()})},this).nodeify(o)}},{key:"addon",value:function(e,t,n){var r=this;return"function"==typeof t&&(n=t,t=void 0),t=t||{},new d.default(function(n,i){if(!r.items.plan)return r.error((0,b.default)("missing-plan"),i,"addon");var o=(0,l.findByCode)(r.items.plan.addons,e);if(!o)return r.error((0,b.default)("invalid-addon",{planCode:r.items.plan.code,addonCode:e}),i,"addon");var a=u(t,o),s=(0,l.findByCode)(r.items.addons,e);0===a&&r.remove({addon:e}),s?s.quantity=a:(s=JSON.parse(JSON.stringify(o)),s.quantity=a,r.items.addons.push(s)),_("set.addon"),r.emit("set.addon",s),n(s)},this).nodeify(n)}},{key:"giftcard",value:function(e,t){function n(e){_("set.gift_card"),i.items.gift_card=e,i.emit("set.gift_card",e)}function r(e){_("unset.gift_card"),delete i.items.gift_card,i.emit("unset.gift_card")}var i=this;return new d.default(function(t,o){if(r(),!e)return t();i.recurly.giftcard({giftcard:e},function(e,a){return e&&"not-found"===e.code&&r(),e?i.error(e,o,"gift_card"):i.items.currency!==a.currency?(r(),i.error((0,b.default)("gift-card-currency-mismatch"),o,"gift_card")):(n(a),void t(a))})},this).nodeify(t)}},{key:"coupon",value:function(e,t){var n=this,r=function(){_("unset.coupon"),delete n.items.coupon,n.emit("unset.coupon")};return new d.default(function(t,i){if(!n.items.plan)return n.error((0,b.default)("missing-plan"),i,"coupon");if(n.items.coupon&&n.remove({coupon:n.items.coupon.code}),!e)return r(),t();var o=function(e,o){return e&&"not-found"===e.code&&r(),e?n.error(e,i,"coupon"):n.couponIsValidForSubscription(o)?(_("set.coupon"),n.items.coupon=o,n.emit("set.coupon",o),t(o),void 0):n.error("invalid-coupon-for-subscription",i,"coupon")};"string"==typeof e?n.recurly.coupon({plan:n.items.plan.code,coupon:e},o):o(null,e)},this).nodeify(t)}},{key:"address",value:function(e,t){return new d.default(this.itemUpdateFactory("address",e),this).nodeify(t)}},{key:"shippingAddress",value:function(e,t){return new d.default(this.itemUpdateFactory("shipping_address",e),this).nodeify(t)}},{key:"tax",value:function(e,t){return new d.default(this.itemUpdateFactory("tax",e),this).nodeify(t)}},{key:"currency",value:function(e,t){var n=this,r=this.items.plan,i=this.items.currency;return new d.default(function(t,o){return i===e?t(i):!r||e in r.price?(n.items.currency=e,_("set.currency"),n.emit("set.currency",e),void t(e)):n.error((0,b.default)("invalid-currency",{currency:e,allowed:Object.keys(r.price)}),o,"currency")},this).nodeify(t)}},{key:"couponIsValidForSubscription",value:function(e){return!!e&&(!!e.applies_to_plans&&(!!e.applies_to_all_plans||!!~e.plans.indexOf(this.items.plan.code)))}},{key:"resolvePlanOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2],r=this.items.plan,i=void 0;return"function"==typeof t&&(n=t,t={}),r&&r.quantity&&(i=r.quantity),t.quantity&&(i=parseInt(t.quantity,10)),(!i||i<1)&&(i=1),{currentPlan:r,quantity:i,planCode:e,options:t,done:n}}},{key:"Calculations",get:function(){return h.default}},{key:"PRICING_METHODS",get:function(){return c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"PRICING_METHODS",this).concat(["addon","address","coupon","currency","giftcard","plan","shippingAddress","tax"])}},{key:"isValid",get:function(){return!(!this.items.plan||!this.price)}},{key:"taxCode",get:function(){if(this.items.tax)return this.items.tax.taxCode||this.items.tax.tax_code}},{key:"taxExempt",get:function(){return this.items.plan&&this.items.plan.tax_exempt}}]),t}(l.Pricing);t.default=O},function(e,t,n){function r(e){switch(i(e)){case"object":var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=r(e[n]));return t;case"array":for(var t=new Array(e.length),o=0,a=e.length;o-1&&e%1==0&&e<=w}function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){return!!e&&"object"==typeof e}function g(){return!1}var w=9007199254740991,_="[object Arguments]",O="[object Function]",j="[object GeneratorFunction]",x="[object Map]",k="[object Set]",C=/[\\^$.*+?()[\]{}|]/g,P=/^\[object .+?Constructor\]$/,S="object"==typeof e&&e&&e.Object===Object&&e,E="object"==typeof self&&self&&self.Object===Object&&self,F=S||E||Function("return this")(),A="object"==typeof t&&t&&!t.nodeType&&t,T=A&&"object"==typeof n&&n&&!n.nodeType&&n,M=T&&T.exports===A,I=Function.prototype,N=Object.prototype,R=F["__core-js_shared__"],L=function(){var e=/[^.]+$/.exec(R&&R.keys&&R.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),D=I.toString,q=N.hasOwnProperty,B=N.toString,z=RegExp("^"+D.call(q).replace(C,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),U=M?F.Buffer:void 0,V=N.propertyIsEnumerable,$=U?U.isBuffer:void 0,H=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),K=u(F,"DataView"),G=u(F,"Map"),W=u(F,"Promise"),J=u(F,"Set"),Z=u(F,"WeakMap"),Y=!V.call({valueOf:1},"valueOf"),X=l(K),Q=l(G),ee=l(W),te=l(J),ne=l(Z),re=o;(K&&"[object DataView]"!=re(new K(new ArrayBuffer(1)))||G&&re(new G)!=x||W&&"[object Promise]"!=re(W.resolve())||J&&re(new J)!=k||Z&&"[object WeakMap]"!=re(new Z))&&(re=function(e){var t=B.call(e),n="[object Object]"==t?e.constructor:void 0,r=n?l(n):void 0;if(r)switch(r){case X:return"[object DataView]";case Q:return x;case ee:return"[object Promise]";case te:return k;case ne:return"[object WeakMap]"}return t});var ie=Array.isArray,oe=$||g;n.exports=h}).call(t,n(3),n(81)(e))},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1?e():this.once("ready",e)}},{key:"configure",value:function(e){if(te("configure"),e=(0,h.default)(e),"string"==typeof e&&(e={publicKey:e}),e=c(e),e.publicKey)this.config.publicKey=e.publicKey;else if(!this.config.publicKey)throw(0,C.default)("config-missing-public-key");e.api&&(this.config.api=e.api),e.currency&&(this.config.currency=e.currency),"cors"in e&&(this.config.cors=e.cors),"fraud"in e&&(0,Y.default)(this.config.fraud,e.fraud),"parent"in e&&(this.config.parent=e.parent),"object"===f(e.fields)&&(0,Y.default)(this.config.fields,e.fields),this.config.required=e.required||this.config.required||[],this.config.parent?this.parent():e.parentVersion&&(this.config.parentVersion=e.parentVersion),this.configured=!0}},{key:"parent",value:function(){var e=this,t=!1;if(this.hostedFields&&this.readyState>1&&!this.hostedFields.integrityCheck(this.config.fields)&&(t=!0),t&&(this.readyState=0,this.hostedFields.reset()),this.readyState>0)return void this.bus.send("hostedFields:configure",{recurly:this.config});this.fraud||(this.fraud=new $.Fraud(this)),this.bus&&this.bus.stop(),this.bus=new V.Bus({api:this.config.api}),this.bus.add(this),this.hostedFields&&!t||(this.hostedFields=new H.HostedFields({recurly:this.config})),0===this.hostedFields.errors.length?(this.bus.add(this.hostedFields),this.once("hostedFields:ready",function(t){e.readyState=2,e.emit("ready")}),this.on("hostedFields:state:change",function(t){return e.emit("change",{fields:t})}),this.on("hostedField:submit",function(){return e.emit("field:submit")}),this.readyState=1):(this.readyState=3,this.emit("ready"))}},{key:"url",value:function(e){return this.config.api+e}},{key:"request",value:function(e,t,n,r){if(te("request",e,t,n),!this.configured)throw(0,C.default)("not-configured");return"function"==typeof n&&(r=n,n={}),this.config.parent?n.version=this.version:n.version=this.config.parentVersion,n.key=this.config.publicKey,this.config.cors?this.xhr(e,t,n,r):this.jsonp(t,n,r)}},{key:"cachedRequest",value:function(e,t,n,r){var i=this._cachedRequests=this._cachedRequests||{},a=[e,t,JSON.stringify(n)].join("-");i[a]?r.apply(void 0,[null].concat(o(i[a]))):this.request(e,t,n,function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o0?e(f.reduce(function(e,t){return e.concat(t)})):n(d[0]))};p.forEach(function(e){return t.request(r,o,e,i)})})}},{key:"xhr",value:function(e,t,n,r){function i(){"post"===e?(a.setRequestHeader&&a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.send(s)):a.send()}te("xhr");var o=function(){var e=window.XMLHttpRequest,t=window.XDomainRequest;return e&&"withCredentials"in new e?e:t||void 0}(),a=new o,u=this.url(t),s=w.default.stringify(n,{encodeValuesOnly:!0});"get"===e&&(u+="?"+s),a.open(e,u),a.timeout=this.config.timeout,a.ontimeout=function(){r((0,C.default)("api-timeout"))},a.onerror=function(){r((0,C.default)("api-error"))},a.onprogress=function(){},a.onload=function(){var e;try{e=JSON.parse(this.responseText)}catch(e){return te(this.responseText,e),r((0,C.default)("api-error",{message:"There was a problem parsing the API response with: "+this.responseText}))}e&&e.error?r((0,C.default)("api-error",e.error)):r(null,e)},setTimeout(i,0)}},{key:"jsonp",value:function(e,t,n){te("jsonp");var r=this.url(e)+"?"+w.default.stringify(t,{encodeValuesOnly:!0});(0,b.default)(r,{timeout:this.config.timeout,prefix:"__rjs"},function(e,t){if(e)return n(e);t.error?n((0,C.default)("api-error",t.error)):n(null,t)})}}]),t}(O.default);re.prototype.Frame=D.factory,re.prototype.coupon=T.default,re.prototype.giftCard=I.default,re.prototype.giftcard=I.default,re.prototype.ApplePay=q.factory,re.prototype.PayPal=B.factory,re.prototype.paypal=U.deprecated,re.prototype.Adyen=z.factory,re.prototype.plan=n(89),re.prototype.tax=R.default,re.prototype.token=L.token,re.prototype.validate=n(90)},function(e,t,n){"use strict";var r=n(42),i=n(43),o=n(21);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,i=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),o=function(e){for(var t;e.length;){var n=e.pop();if(t=n.obj[n.prop],Array.isArray(t)){for(var r=[],i=0;i=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122?n+=t.charAt(r):o<128?n+=i[o]:o<2048?n+=i[192|o>>6]+i[128|63&o]:o<55296||o>=57344?n+=i[224|o>>12]+i[128|o>>6&63]+i[128|63&o]:(r+=1,o=65536+((1023&o)<<10|1023&t.charCodeAt(r)),n+=i[240|o>>18]+i[128|o>>12&63]+i[128|o>>6&63]+i[128|63&o])}return n},t.compact=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;rc){for(var t=0,n=a.length-s;t0)throw this.hostedFields.errors[0];var a=(0,l.default)();this.bus.send("token:init",{id:a,inputs:i}),this.once("token:done:"+a,function(e){return n(e.err,e.token)})}else{var u=o.call(this,i);if(u.length)return t((0,d.default)("validation",{fields:u}));this.request("post","/token",i,n)}}function o(e){var t=[];return this.validate.cardNumber(e.number)||t.push("number"),this.validate.expiry(e.month,e.year)||t.push("month","year"),e.first_name||t.push("first_name"),e.last_name||t.push("last_name"),!~this.config.required.indexOf("cvv")&&!e.cvv||this.validate.cvv(e.cvv)||t.push("cvv"),(0,u.default)(this.config.required,function(n){!e[n]&&~h.indexOf(n)&&t.push(n)}),p("validate errors",t),t}Object.defineProperty(t,"__esModule",{value:!0}),t.FIELDS=void 0,t.token=i;var a=n(4),u=r(a),s=n(15),c=n(5),l=r(c),f=n(1),d=r(f),p=n(0)("recurly:token"),h=t.FIELDS=["first_name","last_name","address1","address2","company","country","city","state","postal_code","phone","vat_number","fraud_session_id","token"]},function(e,t){function n(e){return e.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^\/]+)\//g,"").replace(a,"").match(/[a-zA-Z_]\w*/g)||[]}function r(e,t,n){var r=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^\/]+)\/|[a-zA-Z_]\w*/g;return e.replace(r,function(e){return"("==e[e.length-1]?n(e):~t.indexOf(e)?n(e):e})}function i(e){for(var t=[],n=0;n1?t-1:0),a=1;a1&&void 0!==arguments[1]?arguments[1]:function(e){return e};return e.reduce(function(e,n){var r=t(n);return(e[r]=e[r]||[]).push(n),e},{})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r},function(e,t,n){"use strict";var r=n(18);e.exports=t=new r.Recurly,t.Recurly=r.Recurly},function(e,t){function n(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r-1&&e%1==0&&e-1&&e%1==0&&e<=m}function l(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function f(e){return!!e&&"object"==typeof e}function d(e){return"symbol"==typeof e||f(e)&&F.call(e)==O}function p(e){if(!e)return 0===e?e:0;if((e=y(e))===v||e===-v){return(e<0?-1:1)*b}return e===e?e:0}function h(e){var t=p(e),n=t%1;return t===t?n?t-n:t:0}function y(e){if("number"==typeof e)return e;if(d(e))return g;if(l(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=l(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(j,"");var n=k.test(e);return n||C.test(e)?S(e.slice(2),n?2:8):x.test(e)?g:+e}var v=1/0,m=9007199254740991,b=1.7976931348623157e308,g=NaN,w="[object Function]",_="[object GeneratorFunction]",O="[object Symbol]",j=/^\s+|\s+$/g,x=/^[-+]0x[0-9a-f]+$/i,k=/^0b[01]+$/i,C=/^0o[0-7]+$/i,P=/^(?:0|[1-9]\d*)$/,S=parseInt,E=Object.prototype,F=E.toString,A=Math.ceil,T=Math.max;e.exports=o},function(e,t,n){function r(){}function i(e,t,n){function i(){u.parentNode.removeChild(u),window[h]=r}"function"==typeof t&&(n=t,t={}),t||(t={});var u,s,c=t.prefix||"__jp",l=t.param||"callback",f=null!=t.timeout?t.timeout:6e4,d=encodeURIComponent,p=document.getElementsByTagName("script")[0]||document.head,h=c+a++;f&&(s=setTimeout(function(){i(),n&&n(new Error("Timeout"))},f)),window[h]=function(e){o("jsonp got",e),s&&clearTimeout(s),i(),n&&n(null,e)},e+=(~e.indexOf("?")?"&":"?")+l+"="+d(h),e=e.replace("?&","?"),o('jsonp req "%s"',e),u=document.createElement("script"),u.src=e,p.parentNode.insertBefore(u,p)}var o=n(0)("jsonp");e.exports=i;var a=0},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function o(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function a(){y&&p&&(y=!1,p.length?h=p.concat(h):v=-1,h.length&&u())}function u(){if(!y){var e=i(a);y=!0;for(var t=h.length;t;){for(p=h,h=[];++v1)for(var n=1;n100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function r(e){return e>=c?Math.round(e/c)+"d":e>=s?Math.round(e/s)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return o(e,c,"day")||o(e,s,"hour")||o(e,u,"minute")||o(e,a,"second")||e+" ms"}function o(e,t,n){if(!(e0)return n(e);if("number"===o&&!1===isNaN(e))return t.long?i(e):r(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){"use strict";var r=n(20),i=n(21),o={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},a=Date.prototype.toISOString,u={delimiter:"&",encode:!0,encoder:r.encode,encodeValuesOnly:!1,serializeDate:function(e){return a.call(e)},skipNulls:!1,strictNullHandling:!1},s=function e(t,n,i,o,a,s,c,l,f,d,p,h){var y=t;if("function"==typeof c)y=c(n,y);else if(y instanceof Date)y=d(y);else if(null===y){if(o)return s&&!h?s(n,u.encoder):n;y=""}if("string"==typeof y||"number"==typeof y||"boolean"==typeof y||r.isBuffer(y)){if(s){return[p(h?n:s(n,u.encoder))+"="+p(s(y,u.encoder))]}return[p(n)+"="+p(String(y))]}var v=[];if(void 0===y)return v;var m;if(Array.isArray(c))m=c;else{var b=Object.keys(y);m=l?b.sort(l):b}for(var g=0;g0?P+C:""}},function(e,t,n){"use strict";var r=n(20),i=Object.prototype.hasOwnProperty,o={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:r.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(e,t){for(var n={},r=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,u=r.split(t.delimiter,a),s=0;s=0;--i){var o,a=e[i];if("[]"===a)o=[],o=o.concat(r);else{o=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,s=parseInt(u,10);!isNaN(s)&&a!==u&&String(s)===u&&s>=0&&n.parseArrays&&s<=n.arrayLimit?(o=[],o[s]=r):o[u]=r}r=o}return r},s=function(e,t,n){if(e){var r=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,s=o.exec(r),c=s?r.slice(0,s.index):r,l=[];if(c){if(!n.plainObjects&&i.call(Object.prototype,c)&&!n.allowPrototypes)return;l.push(c)}for(var f=0;null!==(s=a.exec(r))&&f "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+u+";","var res;","switch (argLength) {",n.concat(["extra"]).map(function(e,t){return"case "+t+":res = fn.call("+["self"].concat(n.slice(0,t)).concat("cb").join(",")+");break;"}).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(o,e)}var o=n(7),a=n(49);e.exports=o,o.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?r(e,t):i(e)};var u="function (err, res) {if (err) { rj(err); } else { rs(res); }}";o.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,r=this;try{return e.apply(this,arguments).nodeify(n,r)}catch(e){if(null===n||void 0===n)return new o(function(t,n){n(e)});a(function(){n.call(r,e)})}}},o.prototype.nodeify=function(e,t){if("function"!=typeof e)return this;this.then(function(n){a(function(){e.call(t,null,n)})},function(n){a(function(){e.call(t,n)})})}},function(e,t,n){"use strict";function r(){if(s.length)throw s.shift()}function i(e){var t;t=u.length?u.pop():new o,t.task=e,a(t)}function o(){this.task=null}var a=n(22),u=[],s=[],c=a.makeRequestCallFromTimer(r);e.exports=i,o.prototype.call=function(){try{this.task.call()}catch(e){i.onerror?i.onerror(e):(s.push(e),c())}finally{this.task=null,u[u.length]=this}}},function(e,t,n){"use strict";var r=n(7);e.exports=r,r.enableSynchronous=function(){r.prototype.isPending=function(){return 0==this.getState()},r.prototype.isFulfilled=function(){return 1==this.getState()},r.prototype.isRejected=function(){return 2==this.getState()},r.prototype.getValue=function(){if(3===this._81)return this._65.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._65},r.prototype.getReason=function(){if(3===this._81)return this._65.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._65},r.prototype.getState=function(){return 3===this._81?this._65.getState():-1===this._81||-2===this._81?0:this._81}},r.disableSynchronous=function(){r.prototype.isPending=void 0,r.prototype.isFulfilled=void 0,r.prototype.isRejected=void 0,r.prototype.getValue=void 0,r.prototype.getReason=void 0,r.prototype.getState=void 0}},function(e,t,n){"use strict";e.exports="4.8.5"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){d("token");var n=(0,c.normalize)(p,e),r=n.values,i=a(r);if("function"!=typeof t)throw(0,f.default)("missing-callback");if(i.length)return t((0,f.default)("validation",{fields:i}));this.request("post","/token",r,function(e,r){if(e)return t(e);n.fields.token&&r.id&&(n.fields.token.value=r.id),t(null,r)})}function o(e,t){if(d("bankInfo"),"function"!=typeof t)throw(0,f.default)("missing-callback");var n=e&&e.routingNumber;if(!n||"string"!=typeof n)return t((0,f.default)("validation",{fields:["routingNumber"]}));this.request("get","/bank",{routing_number:n},function(e,n){if(e)return t(e);t(null,n)})}function a(e){var t=[];return(0,s.default)(h,function(n){e[n]&&"string"==typeof e[n]||t.push(n)}),e.account_number!==e.account_number_confirmation&&t.push("account_number_confirmation"),d("validate errors",t),t}var u=n(4),s=r(u),c=n(15),l=n(1),f=r(l),d=n(0)("recurly:bankAccount");e.exports={token:i,bankInfo:o};var p=["account_number","account_number_confirmation","routing_number","name_on_account","account_type","address1","address2","company","country","city","state","postal_code","phone","vat_number","token"],h=["account_number","account_number_confirmation","routing_number","account_type","name_on_account","country"]},function(e,t,n){function r(e){switch({}.toString.call(e)){case"[object Object]":return u(e);case"[object Function]":return e;case"[object String]":return a(e);case"[object RegExp]":return o(e);default:return i(e)}}function i(e){return function(t){return e===t}}function o(e){return function(t){return e.test(t)}}function a(e){return/^ *\W+/.test(e)?new Function("_","return _ "+e):new Function("_","return "+s(e))}function u(e){var t={};for(var n in e)t[n]="string"==typeof e[n]?i(e[n]):r(e[n]);return function(e){if("object"!=typeof e)return!1;for(var n in t){if(!(n in e))return!1;if(!t[n](e[n]))return!1}return!0}}function s(e){var t=l(e);if(!t.length)return"_."+e;var n,r,i;for(r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];a("%j",e);var n=e.coupon,r=e.plans,i=e.plan,u=e.currency;if(!n)throw(0,o.default)("missing-coupon");if("function"!=typeof t)throw(0,o.default)("missing-callback");!r&&i&&(r=[i]),this.pipedRequest({route:"/coupons/"+n,data:{plan_codes:r,currency:u},by:"plan_codes"}).nodeify(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(1),o=function(e){return e&&e.__esModule?e:{default:e}}(i),a=n(0)("recurly:coupon")},function(e,t,n){"use strict";function r(e,t){if(u("%j",e),"function"!=typeof t)throw(0,a.default)("missing-callback");if("object"!==(void 0===e?"undefined":i(e)))throw(0,a.default)("invalid-options");if(!("giftcard"in e))throw(0,a.default)("missing-giftcard");this.request("get","/gift_cards/"+e.giftcard,e,t)}Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=r;var o=n(1),a=function(e){return e&&e.__esModule?e:{default:e}}(o),u=n(0)("recurly:giftcard")},function(e,t,n){"use strict";function r(e,t){if(e=i({},e),"function"!=typeof t)throw new Error("Missing callback");this.cachedRequest("get","/tax",{country:e.country,postal_code:e.postalCode||e.postal_code,tax_code:e.taxCode||e.tax_code,vat_number:e.vatNumber||e.vat_number},t)}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};b("creating request frame"),r.version=this.recurly.version,r.event=this.name,r.key=this.recurly.config.publicKey,this.once(r.event,function(t){n.relay&&e.document.body.removeChild(n.relay),t.error?n.emit("error",t.error):n.emit("done",t)}),this.url=this.recurly.url(t),this.url+=(~this.url.indexOf("?")?"&":"?")+d.default.stringify(r,{encodeValuesOnly:!0})}},{key:"listen",value:function(t){var n=this;if(this.recurly.bus.add(this),"documentMode"in document){b("Creating relay");var r=document.createElement("iframe");r.width=r.height=0,r.src=this.recurly.url("/relay"),r.name="recurly-relay-"+this.recurly.id+"-"+this.id,r.style.display="none",r.onload=function(){return n.create()},e.document.body.appendChild(r),this.relay=r,b("Created relay",r)}else this.create()}},{key:"create",value:function(){b("opening frame window",this.url,this.name,this.attributes),e.open(this.url,this.name,this.attributes)}},{key:"attributes",get:function(){return"\n resizable,scrollbars,\n width="+this.width+",\n height="+this.height+",\n top="+this.top+",\n left="+this.left+"\n "}},{key:"top",get:function(){var t=e.outerHeight||e.document.documentElement.clientHeight,n=null===e.screenY?e.screenTop:e.screenY;return s(t,this.height,n)}},{key:"left",get:function(){var t=e.outerWidth||e.document.documentElement.clientWidth,n=null===e.screenX?e.screenLeft:e.screenX;return s(t,this.width,n)}}]),n}(h.default)}).call(t,n(3))},function(e,t,n){"use strict";(function(e){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){return new j(l({},e,{recurly:this}))}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{label:e,amount:(0,b.default)(t)}}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n0||(this.config.lineItems.push(this.authorizationLineItem),this.config.total=this.authorizationLineItem.amount)}},{key:"onPricingChange",value:function(){var e=this.config.pricing,t=this.config.lineItems=[];if(this.config.total=e.totalNow,e.hasPrice){var n=e.price.now.taxes||e.price.now.tax;t.push(s(this.config.i18n.subtotalLineItemLabel,e.subtotalPreDiscountNow)),+e.price.now.discount&&t.push(s(this.config.i18n.discountLineItemLabel,-e.price.now.discount)),+n&&t.push(s(this.config.i18n.taxLineItemLabel,n)),+e.price.now.giftCard&&t.push(s(this.config.i18n.giftCardLineItemLabel,-e.price.now.giftCard)),this.config.lineItems=t}}},{key:"onValidateMerchant",value:function(e){var t=this;w("Validating Apple Pay merchant session",e);var n=e.validationURL;this.recurly.request("post","/apple_pay/start",{validationURL:n},function(e,n){if(e)return t.error(e);t.session.completeMerchantValidation(n)})}},{key:"onPaymentMethodSelected",value:function(e){w("Payment method selected",e),this.session.completePaymentMethodSelection(this.finalTotalLineItem,this.lineItems)}},{key:"onShippingContactSelected",value:function(e){var t=this.session.STATUS_SUCCESS,n=[];this.session.completeShippingContactSelection(t,n,this.finalTotalLineItem,this.lineItems)}},{key:"onShippingMethodSelected",value:function(e){this.session.completeShippingMethodSelection(this.finalTotalLineItem,this.lineItems)}},{key:"onPaymentAuthorized",value:function(e){var t=this;w("Payment authorization received",e);var n={};this.config.form&&(n=(0,v.normalize)(g.FIELDS,this.config.form,{parseCard:!1}).values),this.mapPaymentData(n,e.payment),this.recurly.request("post","/apple_pay/token",n,function(e,n){if(e)return t.session.completePayment(t.session.STATUS_FAILURE),t.error("apple-pay-payment-failure",e);w("Token received",n),t.session.completePayment(t.session.STATUS_SUCCESS),t.emit("token",n)})}},{key:"onCancel",value:function(e){w("User canceled Apple Pay payment",e),this.emit("cancel",e)}},{key:"error",value:function(){var e=(arguments.length<=0?void 0:arguments[0])instanceof Error?arguments.length<=0?void 0:arguments[0]:h.default.apply(void 0,arguments);return this.emit("error",e),e}},{key:"mapPaymentData",value:function(e,t){e.paymentData=t.token.paymentData,e.paymentMethod=t.token.paymentMethod,t.billingContact&&(g.FIELDS.some(function(t){return e[t]})||g.FIELDS.forEach(function(n){if(_[n]){var r=t.billingContact[_[n]];"address1"===n?r=r[0]:"address2"===n&&(r=r[1]),e[n]=r}}))}},{key:"session",get:function(){if(this._session)return this._session;w("Creating new Apple Pay session"),this.addAuthorizationLineItem();var t=new e.ApplePaySession(2,{countryCode:this.config.country,currencyCode:this.config.currency,supportedNetworks:this.config.supportedNetworks,merchantCapabilities:this.config.merchantCapabilities,requiredBillingContactFields:["postalAddress"],total:this.totalLineItem});return t.onvalidatemerchant=this.onValidateMerchant.bind(this),t.onshippingcontactselected=this.onShippingContactSelected.bind(this),t.onshippingmethodselected=this.onShippingMethodSelected.bind(this),t.onpaymentmethodselected=this.onPaymentMethodSelected.bind(this),t.onpaymentauthorized=this.onPaymentAuthorized.bind(this),t.oncancel=this.onCancel.bind(this),this._session=t}},{key:"lineItems",get:function(){return[].concat(this.config.lineItems)}},{key:"totalLineItem",get:function(){return s(this.config.label,this.config.total)}},{key:"finalTotalLineItem",get:function(){return l({},this.totalLineItem,{type:"final"})}},{key:"authorizationLineItem",get:function(){return s(this.config.i18n.authorizationLineItemLabel,1)}}]),n}(d.default)}).call(t,n(3))},function(e,t,n){var r=n(63);e.exports=function(e){if("string"==typeof e){var t=e.toUpperCase();if(r.hasOwnProperty(t))return r[t]}},e.exports.currencySymbolMap=r},function(e,t){e.exports={AED:"د.إ",AFN:"؋",ALL:"L",AMD:"֏",ANG:"ƒ",AOA:"Kz",ARS:"$",AUD:"$",AWG:"ƒ",AZN:"ман",BAM:"KM",BBD:"$",BDT:"৳",BGN:"лв",BHD:".د.ب",BIF:"FBu",BMD:"$",BND:"$",BOB:"$b",BRL:"R$",BSD:"$",BTC:"฿",BTN:"Nu.",BWP:"P",BYR:"p.",BZD:"BZ$",CAD:"$",CDF:"FC",CHF:"CHF",CLP:"$",CNY:"¥",COP:"$",CRC:"₡",CUC:"$",CUP:"₱",CVE:"$",CZK:"Kč",DJF:"Fdj",DKK:"kr",DOP:"RD$",DZD:"دج",EEK:"kr",EGP:"£",ERN:"Nfk",ETB:"Br",ETH:"Ξ",EUR:"€",FJD:"$",FKP:"£",GBP:"£",GEL:"₾",GGP:"£",GHC:"₵",GHS:"GH₵",GIP:"£",GMD:"D",GNF:"FG",GTQ:"Q",GYD:"$",HKD:"$",HNL:"L",HRK:"kn",HTG:"G",HUF:"Ft",IDR:"Rp",ILS:"₪",IMP:"£",INR:"₹",IQD:"ع.د",IRR:"﷼",ISK:"kr",JEP:"£",JMD:"J$",JOD:"JD",JPY:"¥",KES:"KSh",KGS:"лв",KHR:"៛",KMF:"CF",KPW:"₩",KRW:"₩",KWD:"KD",KYD:"$",KZT:"лв",LAK:"₭",LBP:"£",LKR:"₨",LRD:"$",LSL:"M",LTC:"Ł",LTL:"Lt",LVL:"Ls",LYD:"LD",MAD:"MAD",MDL:"lei",MGA:"Ar",MKD:"ден",MMK:"K",MNT:"₮",MOP:"MOP$",MUR:"₨",MVR:"Rf",MWK:"MK",MXN:"$",MYR:"RM",MZN:"MT",NAD:"$",NGN:"₦",NIO:"C$",NOK:"kr",NPR:"₨",NZD:"$",OMR:"﷼",PAB:"B/.",PEN:"S/.",PGK:"K",PHP:"₱",PKR:"₨",PLN:"zł",PYG:"Gs",QAR:"﷼",RMB:"¥",RON:"lei",RSD:"Дин.",RUB:"₽",RWF:"R₣",SAR:"﷼",SBD:"$",SCR:"₨",SDG:"ج.س.",SEK:"kr",SGD:"$",SHP:"£",SLL:"Le",SOS:"S",SRD:"$",SSP:"£",STD:"Db",SVC:"$",SYP:"£",SZL:"E",THB:"฿",TJS:"SM",TMT:"T",TND:"د.ت",TOP:"T$",TRL:"₤",TRY:"₺",TTD:"TT$",TVD:"$",TWD:"NT$",TZS:"TSh",UAH:"₴",UGX:"USh",USD:"$",UYU:"$U",UZS:"лв",VEF:"Bs",VND:"₫",VUV:"VT",WST:"WS$",XAF:"FCFA",XBT:"Ƀ",XCD:"$",XOF:"CFA",XPF:"₣",YER:"﷼",ZAR:"R",ZWD:"Z$"}},function(e,t,n){function r(e){switch({}.toString.call(e)){case"[object Object]":return u(e);case"[object Function]":return e;case"[object String]":return a(e);case"[object RegExp]":return o(e);default:return i(e)}}function i(e){return function(t){return e===t}}function o(e){return function(t){return e.test(t)}}function a(e){return/^ *\W+/.test(e)?new Function("_","return _ "+e):new Function("_","return "+s(e))}function u(e){var t={};for(var n in e)t[n]="string"==typeof e[n]?i(e[n]):r(e[n]);return function(e){if("object"!=typeof e)return!1;for(var n in t){if(!(n in e))return!1;if(!t[n](e[n]))return!1}return!0}}function s(e){var t=l(e);if(!t.length)return"_."+e;var n,r,i;for(r=0;r0&&n(l)?t>1?o(l,t-1,n,r,a):i(a,l):r||(a[a.length]=l)}return a}function a(e,t){return e=Object(e),u(e,t,function(t,n){return n in e})}function u(e,t,n){for(var r=-1,i=t.length,o={};++r-1&&e%1==0&&e<=g}function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function v(e){return!!e&&"object"==typeof e}function m(e){return"symbol"==typeof e||v(e)&&E.call(e)==j}var b=1/0,g=9007199254740991,w="[object Arguments]",_="[object Function]",O="[object GeneratorFunction]",j="[object Symbol]",x="object"==typeof t&&t&&t.Object===Object&&t,k="object"==typeof self&&self&&self.Object===Object&&self,C=x||k||Function("return this")(),P=Object.prototype,S=P.hasOwnProperty,E=P.toString,F=C.Symbol,A=P.propertyIsEnumerable,T=F?F.isConcatSpreadable:void 0,M=Math.max,I=Array.isArray,N=function(e,t){return t=M(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=M(r.length-t,0),a=Array(o);++i1&&void 0!==arguments[1]?arguments[1]:function(){},r="https://js.braintreegateway.com/web/"+v+"/js/"+t+".min.js";(0,f.default)(r,function(t){t?e.error("paypal-load-error",{cause:t}):n()})},r=function(){e.braintreeClientAvailable("paypal")?t():n("paypal",t),e.braintreeClientAvailable("dataCollector")?t():n("data-collector",t)};this.braintreeClientAvailable()?r():n("client",r)}},{key:"initialize",value:function(){var t=this;y("Initializing Braintree client");var n=this.config.clientAuthorization,r=e.braintree;r.client.create({authorization:n},function(e,n){if(e)return t.fail("paypal-braintree-api-error",{cause:e});y("Braintree client created"),r.dataCollector.create({client:n,paypal:!0},function(e,i){if(e)return t.fail("paypal-braintree-api-error",{cause:e});y("Device data collector created"),t.deviceFingerprint=i.deviceData,r.paypal.create({client:n},function(e,n){if(e)return t.fail("paypal-braintree-api-error",{cause:e});y("PayPal client created"),t.paypal=n,t.emit("ready")})})})}},{key:"start",value:function(){var e=this,t=u({},this.config.display,{flow:"vault"});this.paypal.tokenize(t,function(t,n){if(t)return"PAYPAL_POPUP_CLOSED"===t.code?e.emit("cancel"):e.error("paypal-braintree-tokenize-braintree-error",{cause:t});y("Token payload received",n),e.deviceFingerprint&&(n.deviceFingerprint=e.deviceFingerprint),e.recurly.request("post","/paypal/token",{type:"braintree",payload:n},function(t,n){if(t)return e.error("paypal-braintree-tokenize-recurly-error",{cause:t});e.emit("token",n)})})}},{key:"braintreeClientAvailable",value:function(t){var n=e.braintree;return n&&n.client&&n.client.VERSION===v&&(!t||t in n)}}]),n}(h.PayPalStrategy)}).call(t,n(3))},function(e,t){function n(e,t){for(var n in t)e.setAttribute(n,t[n])}function r(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function i(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}e.exports=function(e,t,o){var a=document.head||document.getElementsByTagName("head")[0],u=document.createElement("script");"function"==typeof t&&(o=t,t={}),t=t||{},o=o||function(){},u.type=t.type||"text/javascript",u.charset=t.charset||"utf8",u.async=!("async"in t)||!!t.async,u.src=e,t.attrs&&n(u,t.attrs),t.text&&(u.text=""+t.text),("onload"in u?r:i)(u,o),u.onload||r(u,o),a.appendChild(u)}},function(e,t,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments[1],n=0;return function(){return n++&&n===e&&t()}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){return new v(l({},e,{recurly:this}))}function s(e){var t=[];return e.skinCode&&8!=e.skinCode.length&&t.push("skinCode should be 8 characters"),e.countryCode&&2!=e.countryCode.length&&t.push("countryCode should be 2 characters"),e.shopperLocale&&5!=e.shopperLocale.length&&t.push("shopperLocale should be 5 characters"),e.invoiceUuid||t.push("invoiceUuid cannot be blank"),y("validate errors",t),t}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n0)return this.error("validation",{fields:r});var i=this.recurly.Frame({height:600,path:"/adyen/start",payload:n});i.once("error",function(e){return t.error("adyen-error",{cause:e})}),i.once("done",function(e){return t.emit("token",e)})}},{key:"error",value:function(){var e=(arguments.length<=0?void 0:arguments[0])instanceof Error?arguments.length<=0?void 0:arguments[0]:h.default.apply(void 0,arguments);return this.emit("error",e),e}}]),t}(d.default)},function(e,t,n){"use strict";(function(e){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(t){var n=e.document.createElement("a");return n.href=t,n.protocol+"//"+n.host}Object.defineProperty(t,"__esModule",{value:!0}),t.Bus=void 0;var s=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.id=(0,p.default)(),r.debug=n(0)("recurly:bus:"+r.id),r.emitters=[],r.recipients=[],r.receive=r.receive.bind(r),r.config={api:e.api},r.connect(),r.send=r.send.bind(r),r}return a(t,e),s(t,[{key:"connect",value:function(){window.addEventListener("message",this.receive,!1),this.debug("listening for postMessage events on",window)}},{key:"receive",value:function(e){if(this.originMatches(e.origin))return"string"==typeof e.data?this.receiveFromRelay(e):void(e.data.event&&(this.debug("message received",e.data),this.send(new f.Message(e),null,{exclude:[e.srcElement]})))}},{key:"receiveFromRelay",value:function(e){var t=void 0;try{t=JSON.parse(e.data)}catch(t){this.debug("failed to parse a string message",t,e)}t&&this.send(new f.Message(t.recurly_event,t.recurly_message))}},{key:"add",value:function(e){~this.recipients.indexOf(e)||(this.recipients.push(e),"function"==typeof e.emit&&e.emit("bus:added",this),this.debug("added recipient",e))}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{exclude:[]},r=new f.Message(e,t);n.exclude;this.debug("sending message to "+this.recipients.length+" recipients",r),this.recipients.forEach(function(e){e.postMessage?"function"==typeof e.postMessage&&e.postMessage(r,"*"):"function"==typeof e.emit&&e.emit(r.event,r.body)})}},{key:"stop",value:function(){this.recipients=[],window.removeEventListener("message",this.receive,!1)}},{key:"originMatches",value:function(e){return u(e)===u(this.config.api)}}]),t}(l.default)}).call(t,n(3))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(r(this,e),t instanceof e)return t;t instanceof window.MessageEvent&&(n=t.data.body,t=t.data.event),this.event=t,this.body=n}return i(e,[{key:"format",value:function(){return{event:this.event,body:this.body}}}]),e}()},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.Fraud=void 0;var u=function(){function e(e,t){for(var n=0;n\n \n \n \n ',this.container=this.target.children[0],this.iframe=this.container.querySelector("iframe"),this.window=this.iframe.contentWindow,u()&&(this.tabbingProxy=y.default.createHiddenInput(),this.tabbingProxy.addEventListener("focus",this.focus),this.container.insertBefore(this.tabbingProxy,this.iframe))}},{key:"bindDeferredFocus",value:function(){var t=this;if(this.container.addEventListener("click",this.focus),this.target.id){var n=e.document.querySelectorAll("label[for="+this.target.id+"]");[].slice.apply(n).forEach(function(e){e.addEventListener("click",t.focus)})}}},{key:"reset",value:function(){this.off(),this.target.innerHTML="",delete this.target,delete this.iframe,delete this.window}},{key:"update",value:function(){this.container.className=this.classList,this.iframe.setAttribute("tabindex",this.tabIndex)}},{key:"onReady",value:function(e){e.type===this.type&&(this.ready=!0,this.off("hostedField:ready",this.onReady),this.update())}},{key:"onStateChange",value:function(e){if(e.type===this.type){var t=s({},e);delete t.type,this.state=t,this.update()}}},{key:"onChange",value:function(e){e.type===this.type&&this.update()}},{key:"onConfigure",value:function(e){e.type===this.type&&(this.configure(e),this.update())}},{key:"focus",value:function(){this.bus&&this.bus.send("hostedField:"+this.type+":focus!")}},{key:"type",get:function(){return this.config.type}},{key:"url",get:function(){var e=encodeURIComponent(JSON.stringify(this.config));return this.config.recurly.api+"/field.html#config="+e}},{key:"classList",get:function(){var e="recurly-hosted-field",t=[e];return this.ready&&(t.push(e+"-"+this.config.type),this.state.focus&&(t.push(e+"-focus"),t.push(e+"-"+this.config.type+"-focus")),this.state.valid?(t.push(e+"-valid"),t.push(e+"-"+this.config.type+"-valid")):this.state.focus||this.state.empty||(t.push(e+"-invalid"),t.push(e+"-"+this.config.type+"-invalid"))),t.join(" ")}},{key:"tabIndex",get:function(){var e=parseInt(this.config.tabIndex,10);return isNaN(e)?0:e}}]),n}(f.default)}).call(t,n(3))},function(e,t,n){/*! * Bowser - a browser detector * https://github.com/ded/bowser * MIT License | (c) Dustin Diaz 2015 */ !function(t,r,i){void 0!==e&&e.exports?e.exports=i():n(78)("bowser",i)}(0,0,function(){function e(e){function t(t){var n=e.match(t);return n&&n.length>1&&n[1]||""}function n(t){var n=e.match(t);return n&&n.length>1&&n[2]||""}var r,i=t(/(ipod|iphone|ipad)/i).toLowerCase(),o=/like android/i.test(e),u=!o&&/android/i.test(e),s=/nexus\s*[0-6]\s*/i.test(e),c=!s&&/nexus\s*[0-9]+/i.test(e),l=/CrOS/.test(e),f=/silk/i.test(e),d=/sailfish/i.test(e),p=/tizen/i.test(e),h=/(web|hpw)os/i.test(e),y=/windows phone/i.test(e),v=(/SamsungBrowser/i.test(e),!y&&/windows/i.test(e)),m=!i&&!f&&/macintosh/i.test(e),b=!u&&!d&&!p&&!h&&/linux/i.test(e),g=n(/edg([ea]|ios)\/(\d+(\.\d+)?)/i),w=t(/version\/(\d+(\.\d+)?)/i),_=/tablet/i.test(e)&&!/tablet pc/i.test(e),O=!_&&/[^-]mobi/i.test(e),j=/xbox/i.test(e);/opera/i.test(e)?r={name:"Opera",opera:a,version:w||t(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(e)?r={name:"Opera",opera:a,version:t(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||w}:/SamsungBrowser/i.test(e)?r={name:"Samsung Internet for Android",samsungBrowser:a,version:w||t(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/coast/i.test(e)?r={name:"Opera Coast",coast:a,version:w||t(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(e)?r={name:"Yandex Browser",yandexbrowser:a,version:w||t(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(e)?r={name:"UC Browser",ucbrowser:a,version:t(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(e)?r={name:"Maxthon",maxthon:a,version:t(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(e)?r={name:"Epiphany",epiphany:a,version:t(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(e)?r={name:"Puffin",puffin:a,version:t(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(e)?r={name:"Sleipnir",sleipnir:a,version:t(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(e)?r={name:"K-Meleon",kMeleon:a,version:t(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:y?(r={name:"Windows Phone",osname:"Windows Phone",windowsphone:a},g?(r.msedge=a,r.version=g):(r.msie=a,r.version=t(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?r={name:"Internet Explorer",msie:a,version:t(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:l?r={name:"Chrome",osname:"Chrome OS",chromeos:a,chromeBook:a,chrome:a,version:t(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/edg([ea]|ios)/i.test(e)?r={name:"Microsoft Edge",msedge:a,version:g}:/vivaldi/i.test(e)?r={name:"Vivaldi",vivaldi:a,version:t(/vivaldi\/(\d+(\.\d+)?)/i)||w}:d?r={name:"Sailfish",osname:"Sailfish OS",sailfish:a,version:t(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?r={name:"SeaMonkey",seamonkey:a,version:t(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(e)?(r={name:"Firefox",firefox:a,version:t(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(r.firefoxos=a,r.osname="Firefox OS")):f?r={name:"Amazon Silk",silk:a,version:t(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(e)?r={name:"PhantomJS",phantom:a,version:t(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(e)?r={name:"SlimerJS",slimer:a,version:t(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?r={name:"BlackBerry",osname:"BlackBerry OS",blackberry:a,version:w||t(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:h?(r={name:"WebOS",osname:"WebOS",webos:a,version:w||t(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(r.touchpad=a)):/bada/i.test(e)?r={name:"Bada",osname:"Bada",bada:a,version:t(/dolfin\/(\d+(\.\d+)?)/i)}:p?r={name:"Tizen",osname:"Tizen",tizen:a,version:t(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||w}:/qupzilla/i.test(e)?r={name:"QupZilla",qupzilla:a,version:t(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||w}:/chromium/i.test(e)?r={name:"Chromium",chromium:a,version:t(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||w}:/chrome|crios|crmo/i.test(e)?r={name:"Chrome",chrome:a,version:t(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:u?r={name:"Android",version:w}:/safari|applewebkit/i.test(e)?(r={name:"Safari",safari:a},w&&(r.version=w)):i?(r={name:"iphone"==i?"iPhone":"ipad"==i?"iPad":"iPod"},w&&(r.version=w)):r=/googlebot/i.test(e)?{name:"Googlebot",googlebot:a,version:t(/googlebot\/(\d+(\.\d+))/i)||w}:{name:t(/^(.*)\/(.*) /),version:n(/^(.*)\/(.*) /)},!r.msedge&&/(apple)?webkit/i.test(e)?(/(apple)?webkit\/537\.36/i.test(e)?(r.name=r.name||"Blink",r.blink=a):(r.name=r.name||"Webkit",r.webkit=a),!r.version&&w&&(r.version=w)):!r.opera&&/gecko\//i.test(e)&&(r.name=r.name||"Gecko",r.gecko=a,r.version=r.version||t(/gecko\/(\d+(\.\d+)?)/i)),r.windowsphone||!u&&!r.silk?!r.windowsphone&&i?(r[i]=a,r.ios=a,r.osname="iOS"):m?(r.mac=a,r.osname="macOS"):j?(r.xbox=a,r.osname="Xbox"):v?(r.windows=a,r.osname="Windows"):b&&(r.linux=a,r.osname="Linux"):(r.android=a,r.osname="Android");var x="";r.windows?x=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}(t(/Windows ((NT|XP)( \d\d?.\d)?)/i)):r.windowsphone?x=t(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):r.mac?(x=t(/Mac OS X (\d+([_\.\s]\d+)*)/i),x=x.replace(/[_\s]/g,".")):i?(x=t(/os (\d+([_\s]\d+)*) like mac os x/i),x=x.replace(/[_\s]/g,".")):u?x=t(/android[ \/-](\d+(\.\d+)*)/i):r.webos?x=t(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):r.blackberry?x=t(/rim\stablet\sos\s(\d+(\.\d+)*)/i):r.bada?x=t(/bada\/(\d+(\.\d+)*)/i):r.tizen&&(x=t(/tizen[\/\s](\d+(\.\d+)*)/i)),x&&(r.osversion=x);var k=!r.windows&&x.split(".")[0];return _||c||"ipad"==i||u&&(3==k||k>=4&&!O)||r.silk?r.tablet=a:(O||"iphone"==i||"ipod"==i||u||s||r.blackberry||r.webos||r.bada)&&(r.mobile=a),r.msedge||r.msie&&r.version>=10||r.yandexbrowser&&r.version>=15||r.vivaldi&&r.version>=1||r.chrome&&r.version>=20||r.samsungBrowser&&r.version>=4||r.firefox&&r.version>=20||r.safari&&r.version>=6||r.opera&&r.version>=10||r.ios&&r.osversion&&r.osversion.split(".")[0]>=6||r.blackberry&&r.version>=10.1||r.chromium&&r.version>=20?r.a=a:r.msie&&r.version<10||r.chrome&&r.version<20||r.firefox&&r.version<20||r.safari&&r.version<6||r.opera&&r.version<10||r.ios&&r.osversion&&r.osversion.split(".")[0]<6||r.chromium&&r.version<20?r.c=a:r.x=a,r}function t(e){return e.split(".").length}function n(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n=0;){if(i[0][r]>i[1][r])return 1;if(i[0][r]!==i[1][r])return-1;if(0===r)return 0}}function i(t,n,i){var o=u;"string"==typeof n&&(i=n,n=void 0),void 0===n&&(n=!1),i&&(o=e(i));var a=""+o.version;for(var s in t)if(t.hasOwnProperty(s)&&o[s]){if("string"!=typeof t[s])throw new Error("Browser version in the minVersion map should be a string: "+s+": "+String(t));return r([a,t[s]])<0}return n}function o(e,t,n){return!i(e,t,n)}var a=!0,u=e("undefined"!=typeof navigator?navigator.userAgent||"":"");return u.test=function(e){for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:{},n=t.commit,r=void 0===n||n,i=void 0;if(i=(0,v.default)(this.validSubscriptions)?e:(0,h.default)(this.subscriptionCurrencies,e),(0,v.default)(i))throw new Error("unresolvable");if(r)return this.currency(i[0])}},{key:"Calculations",get:function(){return N.default}},{key:"PRICING_METHODS",get:function(){return l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"PRICING_METHODS",this).concat(["address","adjustment","coupon","currency","giftCard","shippingAddress","subscription","tax"])}},{key:"validAdjustments",get:function(){var e=this;return this.items.adjustments.filter(function(t){return t.currency===e.items.currency})}},{key:"validSubscriptions",get:function(){return this.items.subscriptions.filter(function(e){return e.isValid})}},{key:"subscriptionCurrencies",get:function(){return(0,h.default)(this.validSubscriptions.map(function(e){return Object.keys(e.items.plan.price)}))}},{key:"subscriptionPlanCodes",get:function(){return(0,O.default)(this.validSubscriptions.map(function(e){return e.items.plan.code}))}}]),t}(P.Pricing);t.default=q},function(e,t){function n(e){var t={},n=e.length-1,r=e[0],i=e[n];for(var o in r)t[r[o]]=0;for(var o=1;o<=n;o++){var a=e[o];for(var u in a){var s=a[u];t[s]===o-1&&(t[s]=o)}}var c=[];for(var o in i){var s=i[o];t[s]===n&&c.push(s)}return c}function r(e,t){if(!t)return n(e);for(var r=[],o=0;o-1&&r.push(e[o]);return r}function i(e,t){for(var n=0;ne?(n=e,r=t-e):n=t,{used:n,remains:r}}if(this.pricing.items.gift_card){var t=this.price.now.total,n=this.price.next.total,r=e(t,this.pricing.items.gift_card.unit_amount),i=e(n,r.remains);this.price.now.gift_card=r.used,this.price.next.gift_card=i.used,this.price.now.total=t-r.used,this.price.next.total=n-i.used}}},{key:"planPrice",value:function(){var e=this.items.plan;if(!e)return{amount:0,setup_fee:0};var t=e.price[this.items.currency];return t.amount=t.unit_amount*(e.quantity||1),t}},{key:"isTrial",value:function(){var e=this.items.coupon;return!(!e||"free_trial"!==e.discount.type)||this.items.plan.trial}}]),e}();t.default=m},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){return function(){return new l.default(function(e,t){return e()},t)}}Object.defineProperty(t,"__esModule",{value:!0}),t.DEFERRED_METHODS=t.DISABLED_METHODS=void 0;var a=function(){function e(e,t){for(var n=0;n1)try{t.checkout.resolveCurrency(Object.keys(o.price),{commit:!1})}catch(r){return n((0,s.default)("invalid-plan-currency",{planCode:o.code,currencies:t.checkout.subscriptionCurrencies}))}o.quantity=i,t.subscription.items.plan=o;var a=function(){t.subscription.emit("set.plan",o),e(o)};if(t.checkout.currencyCode in o.price)a();else try{t.checkout.resolveCurrency(Object.keys(o.price)).then(a)}catch(e){n(r)}})},this.subscription).nodeify(a)}},{key:"id",get:function(){return this.subscription.id}},{key:"isValid",get:function(){return this.subscription.isValid}},{key:"items",get:function(){return this.subscription.items}},{key:"price",get:function(){return this.subscription.price}},{key:"taxCode",get:function(){return this.subscription.taxCode}},{key:"taxExempt",get:function(){return this.subscription.taxExempt}}]),e}();t.default=h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){var n=t.id,r=t.price;return{type:"subscription",id:n,amount:r[e].total,setupFee:r[e].setup_fee,addons:r[e].addons,plan:r[e].plan}}function a(e){if(!e.items.plan.trial)return 0;var t={days:86400,months:2678400}[e.items.plan.trial.interval]||0;return e.items.plan.trial.length*t}function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.setupFees,i=void 0===r||r,o=t.price[e],a=parseFloat(o.subtotal)+parseFloat(o.discount);return i||(a-=parseFloat(o.setup_fee)),a}function s(e,t){return 0===e.length?e:t.applies_to_all_plans?e:e.filter(function(e){return e.couponIsValidForSubscription(t)})}function c(e){return parseFloat((Math.round(100*e)/100).toFixed(6))}Object.defineProperty(t,"__esModule",{value:!0});var l=Object.assign||function(e){for(var t=1;te?(n=e,r=t-e):n=t,{used:n,remains:r}}if(this.price.now.giftCard=0,this.price.next.giftCard=0,this.items.giftCard){var t=this.price.now.subtotal+this.price.now.taxes,n=this.price.next.subtotal+this.price.next.taxes,r=e(t,this.items.giftCard.unit_amount),i=r.used,o=r.remains,a=e(n,o),u=a.used;return this.price.now.giftCard=i,this.price.next.giftCard=u,m.default.resolve()}}},{key:"totals",value:function(){return this.price.now.total=this.price.now.subtotal+this.price.now.taxes-this.price.now.giftCard,this.price.next.total=this.price.next.subtotal+this.price.next.taxes-this.price.next.giftCard,m.default.resolve()}},{key:"itemizedSets",value:function(){return this.price.now.items=this._itemizedSets.now.subscriptions.concat(this._itemizedSets.now.adjustments),this.price.next.items=this._itemizedSets.next.subscriptions,m.default.resolve()}},{key:"applyFreeTrialCoupon",value:function(){var e=this,t=this.items.coupon;return this.hasValidSubscriptions?"subscription"===t.redemption_resource?this.mostValuableSubscriptionForFreeTrial().coupon(t).reprice(null,{internal:!0}).then(function(){return e.subscriptions()}):m.default.all(this.validSubscriptions.map(function(e){return e.coupon(t).reprice(null,{internal:!0})})).then(function(){return e.subscriptions()}):m.default.resolve()}},{key:"discountAmounts",value:function(){var e=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],this.items.coupon),t=0,n=0;if(e)if("free_trial"===e.discount.type);else if(e.discount.rate){var r=this.discountableSubtotals(e,{setupFees:!1}),i=r.discountableNow,o=r.discountableNext;t=c(i*e.discount.rate),n=c(o*e.discount.rate)}else if(e.discount.amount){var a=this.discountableSubtotals(e),u=a.discountableNow,s=a.discountableNext,l=e.discount.amount[this.items.currency]||0;t=Math.min(u,l),n=Math.min(s,l)}return{discountNow:t,discountNext:n}}},{key:"discountableSubtotals",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.setupFees,r=void 0===n||n,i=t.taxExempt,o=void 0===i||i,a=0,c=0;if(e.applies_to_non_plan_charges&&(a+=o?this.price.now.adjustments:this.validAdjustments.reduce(function(e,t){return e+(t.taxExempt?0:t.amount*t.quantity)},0)),e.applies_to_plans&&this.hasValidSubscriptions){var l=void 0;l="subscription"===e.redemption_resource?[this.mostValuableSubscriptionForDiscount()]:this.validSubscriptions,l=s(l,e),l.forEach(function(e){!o&&e.taxExempt||(a+=u("now",e,{setupFees:r}),c+=u("next",e,{setupFees:r}))})}return{discountableNow:a,discountableNext:c}}},{key:"mostValuableSubscriptionForDiscount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.validSubscriptions;return e=s(e,this.items.coupon),e.sort(function(e,t){var n=parseFloat(e.price.now.subtotal),r=parseFloat(t.price.now.subtotal);return n>r?-1:n0}},{key:"taxableAdjustments",get:function(){return this.validAdjustments.filter(function(e){return!e.taxExempt&&e.amount>0})}},{key:"taxableSubscriptions",get:function(){return this.validSubscriptions.filter(function(e){return!e.items.plan.tax_exempt})}},{key:"taxCodes",get:function(){var e=this.taxableAdjustments.concat(this.taxableSubscriptions);return(0,g.default)(e.map(function(e){return e.taxCode}))}}]),e}();t.default=C},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n19)return!1;for(;o--;)n=parseInt(t.charAt(o),10)*i,r+=n-9*(n>9),i^=3;return r%10==0&&r>0}function i(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=(0,c.parseCard)(e),r=n.length,i=(0,s.default)(l,function(e){return e.pattern.test(n)&&(t||~e.lengths.indexOf(r))});return i&&i.type||"unknown"}function o(e,t){if((e=Number(e)-1)<0||e>11)return!1;t=Number(t),t+=t<100?2e3:0;var n=new Date;return n.setYear(t),n.setDate(1),n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setMonth(e+1),new Date=222100&&t<=272099}},lengths:[16]},{type:"american_express",pattern:/^3[47]/,lengths:[15]},{type:"visa",pattern:/^4/,lengths:[13,16]},{type:"jcb",pattern:/^35[2-8]\d/,lengths:[16]},{type:"diners_club",pattern:/^(30[0-5]|309|36|3[89]|54|55|2014|2149)/,lengths:[14]}]}]);