!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){var r;r=function(){var e=!0;function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}function r(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}var o,i=n(/(ipod|iphone|ipad)/i).toLowerCase(),s=!/like android/i.test(t)&&/android/i.test(t),p=/nexus\s*[0-6]\s*/i.test(t),l=!p&&/nexus\s*[0-9]+/i.test(t),u=/CrOS/.test(t),c=/silk/i.test(t),d=/sailfish/i.test(t),f=/tizen/i.test(t),y=/(web|hpw)(o|0)s/i.test(t),h=/windows phone/i.test(t),m=(/SamsungBrowser/i.test(t),!h&&/windows/i.test(t)),v=!i&&!c&&/macintosh/i.test(t),g=!s&&!d&&!f&&!y&&/linux/i.test(t),w=r(/edg([ea]|ios)\/(\d+(\.\d+)?)/i),b=n(/version\/(\d+(\.\d+)?)/i),P=/tablet/i.test(t)&&!/tablet pc/i.test(t),_=!P&&/[^-]mobi/i.test(t),k=/xbox/i.test(t);/opera/i.test(t)?o={name:"Opera",opera:e,version:b||n(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(t)?o={name:"Opera",opera:e,version:n(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||b}:/SamsungBrowser/i.test(t)?o={name:"Samsung Internet for Android",samsungBrowser:e,version:b||n(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/Whale/i.test(t)?o={name:"NAVER Whale browser",whale:e,version:n(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)}:/MZBrowser/i.test(t)?o={name:"MZ Browser",mzbrowser:e,version:n(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/coast/i.test(t)?o={name:"Opera Coast",coast:e,version:b||n(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/focus/i.test(t)?o={name:"Focus",focus:e,version:n(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)}:/yabrowser/i.test(t)?o={name:"Yandex Browser",yandexbrowser:e,version:b||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(t)?o={name:"UC Browser",ucbrowser:e,version:n(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(t)?o={name:"Maxthon",maxthon:e,version:n(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(t)?o={name:"Epiphany",epiphany:e,version:n(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(t)?o={name:"Puffin",puffin:e,version:n(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(t)?o={name:"Sleipnir",sleipnir:e,version:n(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(t)?o={name:"K-Meleon",kMeleon:e,version:n(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:h?(o={name:"Windows Phone",osname:"Windows Phone",windowsphone:e},w?(o.msedge=e,o.version=w):(o.msie=e,o.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?o={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:u?o={name:"Chrome",osname:"Chrome OS",chromeos:e,chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/edg([ea]|ios)/i.test(t)?o={name:"Microsoft Edge",msedge:e,version:w}:/vivaldi/i.test(t)?o={name:"Vivaldi",vivaldi:e,version:n(/vivaldi\/(\d+(\.\d+)?)/i)||b}:d?o={name:"Sailfish",osname:"Sailfish OS",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?o={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(t)?(o={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(o.firefoxos=e,o.osname="Firefox OS")):c?o={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(t)?o={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(t)?o={name:"SlimerJS",slimer:e,version:n(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?o={name:"BlackBerry",osname:"BlackBerry OS",blackberry:e,version:b||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:y?(o={name:"WebOS",osname:"WebOS",webos:e,version:b||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(o.touchpad=e)):/bada/i.test(t)?o={name:"Bada",osname:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:f?o={name:"Tizen",osname:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||b}:/qupzilla/i.test(t)?o={name:"QupZilla",qupzilla:e,version:n(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||b}:/chromium/i.test(t)?o={name:"Chromium",chromium:e,version:n(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||b}:/chrome|crios|crmo/i.test(t)?o={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?o={name:"Android",version:b}:/safari|applewebkit/i.test(t)?(o={name:"Safari",safari:e},b&&(o.version=b)):i?(o={name:"iphone"==i?"iPhone":"ipad"==i?"iPad":"iPod"},b&&(o.version=b)):o=/googlebot/i.test(t)?{name:"Googlebot",googlebot:e,version:n(/googlebot\/(\d+(\.\d+))/i)||b}:{name:n(/^(.*)\/(.*) /),version:r(/^(.*)\/(.*) /)},!o.msedge&&/(apple)?webkit/i.test(t)?(/(apple)?webkit\/537\.36/i.test(t)?(o.name=o.name||"Blink",o.blink=e):(o.name=o.name||"Webkit",o.webkit=e),!o.version&&b&&(o.version=b)):!o.opera&&/gecko\//i.test(t)&&(o.name=o.name||"Gecko",o.gecko=e,o.version=o.version||n(/gecko\/(\d+(\.\d+)?)/i)),o.windowsphone||!s&&!o.silk?!o.windowsphone&&i?(o[i]=e,o.ios=e,o.osname="iOS"):v?(o.mac=e,o.osname="macOS"):k?(o.xbox=e,o.osname="Xbox"):m?(o.windows=e,o.osname="Windows"):g&&(o.linux=e,o.osname="Linux"):(o.android=e,o.osname="Android");var T="";o.windows?T=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}}(n(/Windows ((NT|XP)( \d\d?.\d)?)/i)):o.windowsphone?T=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):o.mac?T=(T=n(/Mac OS X (\d+([_\.\s]\d+)*)/i)).replace(/[_\s]/g,"."):i?T=(T=n(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):s?T=n(/android[ \/-](\d+(\.\d+)*)/i):o.webos?T=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):o.blackberry?T=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):o.bada?T=n(/bada\/(\d+(\.\d+)*)/i):o.tizen&&(T=n(/tizen[\/\s](\d+(\.\d+)*)/i)),T&&(o.osversion=T);var A=!o.windows&&T.split(".")[0];return P||l||"ipad"==i||s&&(3==A||A>=4&&!_)||o.silk?o.tablet=e:(_||"iphone"==i||"ipod"==i||s||p||o.blackberry||o.webos||o.bada)&&(o.mobile=e),o.msedge||o.msie&&o.version>=10||o.yandexbrowser&&o.version>=15||o.vivaldi&&o.version>=1||o.chrome&&o.version>=20||o.samsungBrowser&&o.version>=4||o.whale&&1===a([o.version,"1.0"])||o.mzbrowser&&1===a([o.version,"6.0"])||o.focus&&1===a([o.version,"1.0"])||o.firefox&&o.version>=20||o.safari&&o.version>=6||o.opera&&o.version>=10||o.ios&&o.osversion&&o.osversion.split(".")[0]>=6||o.blackberry&&o.version>=10.1||o.chromium&&o.version>=20?o.a=e:o.msie&&o.version<10||o.chrome&&o.version<20||o.firefox&&o.version<20||o.safari&&o.version<6||o.opera&&o.version<10||o.ios&&o.osversion&&o.osversion.split(".")[0]<6||o.chromium&&o.version<20?o.c=e:o.x=e,o}var n=t("undefined"!=typeof navigator&&navigator.userAgent||"");function r(e){return e.split(".").length}function o(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n++)r.push(t(e[n]));return r}function a(e){for(var t=Math.max(r(e[0]),r(e[1])),n=o(e,(function(e){var n=t-r(e);return o((e+=new Array(n+1).join(".0")).split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));--t>=0;){if(n[0][t]>n[1][t])return 1;if(n[0][t]!==n[1][t])return-1;if(0===t)return 0}}function i(e,r,o){var i=n;"string"==typeof r&&(o=r,r=void 0),void 0===r&&(r=!1),o&&(i=t(o));var s=""+i.version;for(var p in e)if(e.hasOwnProperty(p)&&i[p]){if("string"!=typeof e[p])throw new Error("Browser version in the minVersion map should be a string: "+p+": "+String(e));return a([s,e[p]])<0}return r}return n.test=function(e){for(var t=0;t<e.length;++t){var r=e[t];if("string"==typeof r&&r in n)return!0}return!1},n.isUnsupportedBrowser=i,n.compareVersions=a,n.check=function(e,t,n){return!i(e,t,n)},n._detect=t,n.detect=t,n},e.exports?e.exports=r():n(3)("bowser",r)},function(e,t,n){(function(t,n){
/*!
 * @overview es6-promise - a tiny implementation of Promises/A+.
 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
 * @license   Licensed under MIT license
 *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
 * @version   v4.2.8+1e68dce6
 */
var r;r=function(){"use strict";function e(e){return"function"==typeof e}var r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=0,a=void 0,i=void 0,s=function(e,t){y[o]=e,y[o+1]=t,2===(o+=2)&&(i?i(h):b())},p="undefined"!=typeof window?window:void 0,l=p||{},u=l.MutationObserver||l.WebKitMutationObserver,c="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),d="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function f(){var e=setTimeout;return function(){return e(h,1)}}var y=new Array(1e3);function h(){for(var e=0;e<o;e+=2)(0,y[e])(y[e+1]),y[e]=void 0,y[e+1]=void 0;o=0}var m,v,g,w,b=void 0;function P(e,t){var n=this,r=new this.constructor(T);void 0===r[k]&&D(r);var o=n._state;if(o){var a=arguments[o-1];s((function(){return E(o,r,a,n._result)}))}else O(n,r,e,t);return r}function _(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(T);return S(t,e),t}c?b=function(){return t.nextTick(h)}:u?(v=0,g=new u(h),w=document.createTextNode(""),g.observe(w,{characterData:!0}),b=function(){w.data=v=++v%2}):d?((m=new MessageChannel).port1.onmessage=h,b=function(){return m.port2.postMessage(0)}):b=void 0===p?function(){try{var e=Function("return this")().require("vertx");return void 0!==(a=e.runOnLoop||e.runOnContext)?function(){a(h)}:f()}catch(e){return f()}}():f();var k=Math.random().toString(36).substring(2);function T(){}function A(t,n,r){n.constructor===t.constructor&&r===P&&n.constructor.resolve===_?function(e,t){1===t._state?M(e,t._result):2===t._state?R(e,t._result):O(t,void 0,(function(t){return S(e,t)}),(function(t){return R(e,t)}))}(t,n):void 0===r?M(t,n):e(r)?function(e,t,n){s((function(e){var r=!1,o=function(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}(n,t,(function(n){r||(r=!0,t!==n?S(e,n):M(e,n))}),(function(t){r||(r=!0,R(e,t))}),e._label);!r&&o&&(r=!0,R(e,o))}),e)}(t,n,r):M(t,n)}function S(e,t){if(e===t)R(e,new TypeError("You cannot resolve a promise with itself"));else if(o=typeof(r=t),null===r||"object"!==o&&"function"!==o)M(e,t);else{var n=void 0;try{n=t.then}catch(t){return void R(e,t)}A(e,t,n)}var r,o}function C(e){e._onerror&&e._onerror(e._result),q(e)}function M(e,t){void 0===e._state&&(e._result=t,e._state=1,0!==e._subscribers.length&&s(q,e))}function R(e,t){void 0===e._state&&(e._state=2,e._result=t,s(C,e))}function O(e,t,n,r){var o=e._subscribers,a=o.length;e._onerror=null,o[a]=t,o[a+1]=n,o[a+2]=r,0===a&&e._state&&s(q,e)}function q(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r=void 0,o=void 0,a=e._result,i=0;i<t.length;i+=3)r=t[i],o=t[i+n],r?E(n,r,o,a):o(a);e._subscribers.length=0}}function E(t,n,r,o){var a=e(r),i=void 0,s=void 0,p=!0;if(a){try{i=r(o)}catch(e){p=!1,s=e}if(n===i)return void R(n,new TypeError("A promises callback cannot return that same promise."))}else i=o;void 0!==n._state||(a&&p?S(n,i):!1===p?R(n,s):1===t?M(n,i):2===t&&R(n,i))}var x=0;function D(e){e[k]=x++,e._state=void 0,e._result=void 0,e._subscribers=[]}var j=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(T),this.promise[k]||D(this.promise),r(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&M(this.promise,this._result))):R(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;void 0===this._state&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,r=n.resolve;if(r===_){var o=void 0,a=void 0,i=!1;try{o=e.then}catch(e){i=!0,a=e}if(o===P&&void 0!==e._state)this._settledAt(e._state,t,e._result);else if("function"!=typeof o)this._remaining--,this._result[t]=e;else if(n===I){var s=new n(T);i?R(s,a):A(s,e,o),this._willSettleAt(s,t)}else this._willSettleAt(new n((function(t){return t(e)})),t)}else this._willSettleAt(r(e),t)},e.prototype._settledAt=function(e,t,n){var r=this.promise;void 0===r._state&&(this._remaining--,2===e?R(r,n):this._result[t]=n),0===this._remaining&&M(r,this._result)},e.prototype._willSettleAt=function(e,t){var n=this;O(e,void 0,(function(e){return n._settledAt(1,t,e)}),(function(e){return n._settledAt(2,t,e)}))},e}(),I=function(){function t(e){this[k]=x++,this._result=this._state=void 0,this._subscribers=[],T!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(e,t){try{t((function(t){S(e,t)}),(function(t){R(e,t)}))}catch(t){R(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(e){return this.then(null,e)},t.prototype.finally=function(t){var n=this.constructor;return e(t)?this.then((function(e){return n.resolve(t()).then((function(){return e}))}),(function(e){return n.resolve(t()).then((function(){throw e}))})):this.then(t,t)},t}();return I.prototype.then=P,I.all=function(e){return new j(this,e).promise},I.race=function(e){var t=this;return r(e)?new t((function(n,r){for(var o=e.length,a=0;a<o;a++)t.resolve(e[a]).then(n,r)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))},I.resolve=_,I.reject=function(e){var t=new this(T);return R(t,e),t},I._setScheduler=function(e){i=e},I._setAsap=function(e){s=e},I._asap=s,I.polyfill=function(){var e=void 0;if(void 0!==n)e=n;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var r=null;try{r=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===r&&!t.cast)return}e.Promise=I},I.Promise=I,I},e.exports=r()}).call(this,n(4),n(5))},function(e,t,n){(function(e){var n,r,o,a;function i(e){return(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})(e)}a=function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},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="",t(t.s=0)}([function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),window.ApplePaySession&&(t.PaymentRequest=function(){function e(e,t,n){this.paymentRequestID="",this.shippingAddress=null,this.shippingOption="",this.shippingType="shipping",this.paymentResolver=null,this.paymentRejector=null,this.onshippingaddresschange=null,this.onshippingoptionchange=null,this.onpaymentmethodselected=null,this.validationEndpoint="",this.merchantIdentifier="";var r=!1;this.paymentRequest={countryCode:"",currencyCode:"",lineItems:[],merchantCapabilities:["supports3DS"],supportedNetworks:[],total:null,billingContact:null,requiredBillingContactFields:[],requiredShippingContactFields:[],shippingContact:null,shippingMethods:[],shippingType:"shipping"};for(var o,a=0,i=e;a<i.length;a++)if(-1<(o=i[a]).supportedMethods.indexOf("https://apple.com/apple-pay")){this.paymentRequest.supportedNetworks=o.data.supportedNetworks,this.paymentRequest.countryCode=o.data.countryCode,o.data.billingContact?this.paymentRequest.billingContact=o.data.billingContact:delete this.paymentRequest.billingContact,o.data.shippingContact?this.paymentRequest.shippingContact=o.data.shippingContact:delete this.paymentRequest.shippingContact,o.data.merchantCapabilities&&(this.paymentRequest.merchantCapabilities=o.data.merchantCapabilities),this.validationEndpoint=o.data.validationEndpoint,this.merchantIdentifier=o.data.merchantIdentifier,r=!0;break}if(!r)throw"Payment method not specified for Apple Pay.";t&&(n&&!0!==n.requestShipping&&delete t.shippingOptions,this.updatePaymentDetails(t),this.paymentRequest.shippingMethods&&this.paymentRequest.shippingMethods.length&&(this.shippingOption=this.convertShippingMethod(this.paymentRequest.shippingMethods[0]))),n&&(n.requestShipping&&(this.paymentRequest.requiredBillingContactFields.push("postalAddress"),this.paymentRequest.requiredShippingContactFields.push("postalAddress")),n.requestPayerName&&this.paymentRequest.requiredShippingContactFields.push("name"),n.requestPayerEmail&&this.paymentRequest.requiredShippingContactFields.push("email"),n.requestPayerPhone&&this.paymentRequest.requiredShippingContactFields.push("phone"),this.paymentRequest.shippingType="pickup"===n.shippingType?"servicePickup":n.shippingType||"shipping"),this.session=new ApplePaySession(2,this.paymentRequest),this.session.addEventListener("validatemerchant",this.onValidateMerchant.bind(this)),this.session.addEventListener("paymentauthorized",this.onPaymentAuthorized.bind(this)),this.session.addEventListener("paymentmethodselected",this.onPaymentMethodSelected.bind(this)),this.session.addEventListener("shippingcontactselected",this.onShippingAddressChange.bind(this)),this.session.addEventListener("shippingmethodselected",this.onShippingOptionChange.bind(this)),this.session.addEventListener("cancel",this.onPaymentCanceled.bind(this))}return e.prototype.updatePaymentDetails=function(e){if(e.displayItems){this.paymentRequest.lineItems=[];for(var t=0,n=e.displayItems;t<n.length;t++){var r=n[t],o={type:!0===r.isAmountPending?"pending":"final",label:r.label,amount:r.amount.value};this.paymentRequest.lineItems.push(o)}}if(e.shippingOptions){this.paymentRequest.shippingMethods=[];for(var a=0,i=e.shippingOptions;a<i.length;a++){var s=i[a],p={label:s.label,detail:s.detail||"",amount:s.amount.value,identifier:s.id};this.paymentRequest.shippingMethods.push(p)}}if(!e.total)throw"`total` is required parameter for `PaymentDetails`.";this.paymentRequest.currencyCode=e.total.amount.currency,this.paymentRequest.total={type:!0===e.total.isAmountPending?"pending":"final",label:e.total.label,amount:e.total.amount.value}},e.prototype.updatePaymentMethod=function(){},e.prototype.convertPaymentAddress=function(e){return{country:e.countryCode||"",addressLine:e.addressLines||[],region:e.administrativeArea||"",city:e.locality||"",dependentLocality:"",postalCode:e.postalCode||"",sortingCode:e.country||"",languageCode:"",organization:"",recipient:e.givenName+" "+e.familyName,phone:e.phoneNumber||""}},e.prototype.convertShippingMethod=function(e){for(var t,n=0,r=this.paymentRequest.shippingMethods;n<r.length;n++)if(t=r[n],e.identifier===t.identifier)return t.identifier;return""},e.prototype.convertPaymentResponse=function(e){var t=e.shippingContact?this.convertPaymentAddress(e.shippingContact):void 0,n=e.billingContact?this.convertPaymentAddress(e.billingContact):void 0,r=e.shippingContact||{},o=e.billingContact?e.billingContact.givenName+" "+e.billingContact.familyName:void 0;return{details:{billingAddress:n},methodName:"https://apple.com/apple-pay",payerEmail:r.emailAddress,payerName:o,payerPhone:r.phoneNumber,shippingAddress:t,shippingOption:this.shippingOption,applePayRaw:e,complete:this.onPaymentComplete.bind(this)}},e.prototype.show=function(){var e=this;return this.session.begin(),new Promise((function(t,n){e.paymentResolver=function(e){t(e)},e.paymentRejector=function(e){n(e)}}))},e.prototype.abort=function(){this.session.abort()},e.prototype.canMakePayment=function(){if(this.merchantIdentifier)return ApplePaySession.canMakePaymentsWithActiveCard(this.merchantIdentifier);throw"`merchantIdentifier` is not specified."},e.prototype.completeMerchantValidation=function(e){this.session.completeMerchantValidation(e)},e.prototype.completePaymentMethodSelection=function(e,t){this.session.completePaymentMethodSelection(e,t)},e.prototype.addEventListener=function(e,t){if("shippingaddresschange"!==e&&"shippingoptionchange"!==e&&"paymentmethodselected"!==e&&"validatemerchant"!==e)throw'Unknown event type "'+e+'" for `addEventListener`.';this["on"+e]=t},e.prototype.onValidateMerchant=function(e){var t=this;if(e.stopPropagation(),this.onvalidatemerchant)this.onvalidatemerchant(e);else{var n=new Headers({"Content-Type":"application/json"});fetch(this.validationEndpoint,{method:"POST",headers:n,body:JSON.stringify({validationURL:e.validationURL})}).then((function(e){if(200===e.status)return e.json();throw"Merchant validation error."})).then((function(e){t.completeMerchantValidation(e)})).catch((function(e){throw e}))}},e.prototype.onPaymentMethodSelected=function(e){if(e.stopPropagation(),this.onpaymentmethodselected)this.onpaymentmethodselected(e);else{var t=this.paymentRequest.total,n=this.paymentRequest.lineItems;this.session.completePaymentMethodSelection(t,n)}},e.prototype.onShippingAddressChange=function(e){var t=this;if(this.onshippingaddresschange){e.stopPropagation();var n=e.shippingContact;this.shippingAddress=this.convertPaymentAddress(n),this.onshippingaddresschange({updateWith:function(e){Promise.resolve(e).then((function(e){t.updatePaymentDetails(e),t.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,t.paymentRequest.shippingMethods,t.paymentRequest.total,t.paymentRequest.lineItems)}),(function(e){t.updatePaymentDetails(e),t.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE,t.paymentRequest.shippingMethods,t.paymentRequest.total,t.paymentRequest.lineItems)}))}})}},e.prototype.onShippingOptionChange=function(e){var t=this;if(this.onshippingoptionchange){e.stopPropagation();var n=e.shippingMethod;this.shippingOption=this.convertShippingMethod(n),this.onshippingoptionchange({updateWith:function(e){Promise.resolve(e).then((function(e){t.updatePaymentDetails(e),t.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,t.paymentRequest.total,t.paymentRequest.lineItems)}),(function(e){t.updatePaymentDetails(e),t.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE,null,null)}))}})}},e.prototype.onPaymentAuthorized=function(e){if(this.paymentResolver){var t=this.convertPaymentResponse(e.payment);this.paymentResolver(t),this.paymentResolver=null,this.paymentRejector=null}},e.prototype.onPaymentCanceled=function(e){this.paymentRejector&&(this.paymentRejector(e),this.paymentResolver=null,this.paymentRejector=null)},e.prototype.onPaymentComplete=function(e){if("success"!==e&&"fail"!==e&&"unknown"!==e&&""!==e)throw"Unkown status code for complete().";var t="success"===e?ApplePaySession.STATUS_SUCCESS:"fail"===e||"unknown"===e?ApplePaySession.STATUS_FAILURE:ApplePaySession.STATUS_SUCCESS;this.session.completePayment(t)},e}())}])},"object"==i(t)&&"object"==i(e)?e.exports=a():(r=[],void 0===(o="function"==typeof(n=a)?n.apply(t,r):n)||(e.exports=o))}).call(this,n(6)(e))},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t){var n,r,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var p,l=[],u=!1,c=-1;function d(){u&&p&&(u=!1,p.length?l=p.concat(l):c=-1,l.length&&f())}function f(){if(!u){var e=s(d);u=!0;for(var t=l.length;t;){for(p=l,l=[];++c<t;)p&&p[c].run();c=-1,t=l.length}p=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function y(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new y(e,t)),1!==l.length||u||s(f)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";n.r(t);var r,o,a,i=n(0),s=n.n(i),p=n(1);(o=r||(r={})).production="production",o.sandbox="sandboox";var l=function(e){a=e},u=function(e){return a[e]},c="https://js.tappaysdk.com",d={en:"Pay Now",zh:"付款"},f={VISA:1,MASTERCARD:2,JCB:3,UNIONPAY:4,AMEX:5},y={VI:1,MC:2},h={CREDIT:0,DEBIT:1,PREPAID:2},m=0,v=1,g=2,w="card-number",b="expiration-date",P="ccv",_=n(2),k={amex:/^3[47]\d{0,13}/,mastercard:/(^(5[1-5]|2[3-6])\d{0,14})|^(((222[1-9])|(2720))\d{0,12})|^(((22[3-9])|(27[0-1]))\d{0,13})/,jcb:/^(?:2131|1800|35\d{0,2})\d{0,12}/,visa:/^4\d{0,15}/,unionpay:/^(62[0-9]{14,17})$/},T={amex:"AMEX",mastercard:"MASTERCARD",jcb:"JCB",visa:"VISA",unionpay:"UNIONPAY",unknown:"UNKNOWN"},A=function(){return T},S=function(e){return!!T[(e+"").toLowerCase()]},C=function(){return{lower:T.unknown.toLowerCase(),upper:T.unknown}},M=A(),R=function(e){for(var t=[0,2,4,6,8,1,3,5,7,9],n=e.length,r=0,o=0;0<n--;)r+=(o^=1)?e.charCodeAt(n)-48:t[e.charCodeAt(n)-48];return 0==r%10},O=function(e,t){return e=(e+"").replace(/\s+|-/g,""),void 0===t?/^\d{15,19}$/.test(e)&&R(e):t===M.amex?/^\d{15}$/.test(e)&&R(e):/^\d{16,19}$/.test(e)&&R(e)},q=function(e,t){var n,r,o=e;return t+="",!!/^\d+$/.test(o+="")&&!!/^\d+$/.test(t)&&1<=o&&12>=o&&(2===t.length&&(t=70>t?"20"+t:"19"+t),4===t.length&&(r=new Date(t,o),n=new Date,r.setMonth(r.getMonth()-1),r.setMonth(r.getMonth()+1,1),r>n))},E=function(e){for(var t in k)if(!0===k[t].test(e))return M[t];return"Unknown"},x=function(e,t){return void 0===t?/^\d{3,4}$/.test(e):t===M.amex?/^\d{4}$/.test(e):/^\d{3}$/.test(e)};function D(e){return(D="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})(e)}function j(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function I(e,t){return!t||"object"!==D(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function N(e){var t="function"==typeof Map?new Map:void 0;return(N=function(e){function n(){return W(e,arguments,U(this).constructor)}if(null===e||!function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),L(n,e)})(e)}function W(){return(W=F()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&L(o,n.prototype),o}).apply(null,arguments)}function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var z=function(e){function t(e,r){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(o=n.call(this,e)).name=r,o}!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(t,e);var n=function(e){var t=F();return function(){var n,r=U(e);if(t){var o=U(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return I(this,n)}}(t);return function(e,t,n){t&&j(e.prototype,t),n&&j(e,n)}(t,[{key:"toJSON",value:function(){var e={};return Object.getOwnPropertyNames(this).forEach((function(t){e[t]=this[t]}),this),e}}]),t}(N(Error));function B(e){return(B="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})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Y(e);if(t){var o=Y(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return K(this,n)}}function K(e,t){return!t||"object"!==B(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Y(e){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var J=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n.call(this,e,"TapPayNetworkError")}!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&V(e,t)}(t,e);var n=G(t);return t}(z);function H(e){return(H="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})(e)}function X(e,t){return(X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Q(e);if(t){var o=Q(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Z(this,n)}}function Z(e,t){return!t||"object"!==H(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Q(e){return(Q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var ee=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n.call(this,e,"TapPaySDKError")}!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&X(e,t)}(t,e);var n=$(t);return t}(z),te=function(e){if("TapPaySDKError"===e.name){var t=new ee(e.message);return t.stack=e.stack,t}if("TapPayNetworkError"===e.name){var n=new J(e.message);return n.stack=e.stack,n}return e},ne=null,re=null,oe={},ae=function(){return ne},ie=function(e){ne.contentWindow.postMessage(JSON.stringify(e),c)},se=[c,"https://fraud.tappaysdk.com"],pe=new Map;pe.set("send_device_id",[]),pe.set("fraud_id",[]),pe.set("iframe_get_prime_ready",[]),pe.set("setup_payment_request_done",[]),pe.set("payment_request_not_support_in_iframe",[]),pe.set("payment_request_get_prime_done",[]),pe.set("payment_request_apple_pay_get_prime_done",[]),pe.set("apple_pay_get_session_done",[]),pe.set("samsung_pay_iframe_result",[]),pe.set("line_pay_get_prime_done",[]),pe.set("jko_pay_get_prime_done",[]),pe.set("easy_wallet_get_prime_done",[]),pe.set("google_pay_get_prime_done",[]),pe.set("apple_pay_get_prime_done",[]),pe.set("update",[]),pe.set("cardtype-change",[]),pe.set("field-focus-change",[]),pe.set("field-status-change",[]),pe.set("get_prime_for_tappay_fields_done",[]),pe.set("get_prime_for_card_view_done",[]),pe.set("get_prime_for_ccv_prime_done",[]),pe.set("ccv_prime_field_ready",[]),pe.set("ccv_field_ready",[]);var le=function(e,t){if(pe.has(e)){var n=pe.get(e);n.push(t),pe.set(e,n)}},ue=function(e,t){return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},ce=function(e){return"function"!=typeof e},de=function(e){return e instanceof Element},fe=function(e){return!(e instanceof Element)},ye=function(e){return void 0!==e},he=function(e){return void 0===e},me=function(e){return"string"==typeof e},ve=function(e){return"string"!=typeof e},ge=function(e,t){e.classList?e.classList.add(t):!ue(e,t)&&(e.className+=" "+t)},we=function(e,t){if(e.classList)e.classList.remove(t);else if(ue(e,t)){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")}},be=function(e){var t,n=window.location.origin;if(null!==URL&&ye(URL))try{t=new URL(e)}catch(e){return!1}else(t=document.createElement("a")).href=n;return("https://sandbox-redirect.tappaysdk.com"===t.origin||"https://prod-redirect.tappaysdk.com"===t.origin)&&"https:"===t.protocol},Pe=function(e){try{var t=e.token.paymentData;if(!t)return!1;if(!t.data||ve(t.data))return!1;if(!t.version||ve(t.version))return!1;if(!t.signature||ve(t.signature))return!1;if(!t.header)return!1;if(!t.header.publicKeyHash||ve(t.header.publicKeyHash))return!1;if(!t.header.ephemeralPublicKey||ve(t.header.ephemeralPublicKey))return!1;if(!t.header.transactionId||ve(t.header.transactionId))return!1}catch(e){return!1}return!0},_e=function(){return window.ApplePaySession?ApplePaySession.canMakePayments()?!("https:"!==location.protocol&&(console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document."),1)):(console.warn("[TapPay] User Can Not Use Apple Pay"),!1):(console.warn("[TapPay] Your Browser Did Not Support Apple Pay"),!1)},ke=function(){var e;try{e=(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.userLanguage?navigator.userLanguage:navigator.language).split("-")[0].toLowerCase()}catch(e){return d.en}var t=d[e];return t||d.en},Te=function(e){if(!e)return null;var t=e.toUpperCase();return ye(y[t])?y[t]:null},Ae=function(e){var t=e.toUpperCase();return ye(f[t])?f[t]:null},Se=function(e){var t=e.toUpperCase();return ye(h[t])?h[t]:null},Ce=function(e){return new Promise((function(t,n){e((function(e,r){return e?void n(e):void t(r)}))}))};function Me(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Re(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}function Oe(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var qe=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Ee.set(this,{writable:!0,value:void 0}),xe.set(this,{writable:!0,value:void 0}),De.set(this,{writable:!0,value:void 0}),je.set(this,{writable:!0,value:function(){le("apple_pay_get_prime_done",(function(e){Oe(t,De)&&Oe(t,De).call(t,e.err,e.result)})),le("apple_pay_get_session_done",(function(e){Oe(t,xe)&&Oe(t,xe).call(t,e.err,e.result)}))}}),Oe(this,je).call(this)}return function(e,t,n){t&&Me(e.prototype,t),n&&Me(e,n)}(e,[{key:"checkAvailability",value:function(){return _e()}},{key:"canMakePaymentsWithActiveCard",value:function(e,t){return _e()?void ApplePaySession.canMakePaymentsWithActiveCard(e).then((function(e){t({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e,canMakePaymentError:null})})).catch((function(e){t({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:!1,canMakePaymentError:e})})):t({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null})}},{key:"buildSession",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length?arguments[2]:void 0,o=3<arguments.length?arguments[3]:void 0;return"https:"===window.location.protocol?(Re(this,Ee,new ApplePaySession(1,e)),Oe(this,Ee).onvalidatemerchant=function(e){var r={appId:u("appID"),appKey:u("appKey"),appName:window.location.hostname,appleMerchantId:n,merchant_domain:window.location.hostname,validationURL:e.validationURL,tappay_endpoint:u("endPoint")};Re(t,xe,(function(e,n){return e?void o({status:403,msg:"[Apple Pay] Get Session error: ".concat(e.status," ").concat(e.msg)}):void Oe(t,Ee).completeMerchantValidation(n)})),ie({event:"apple_pay_get_session",payload:r})},Oe(this,Ee).onpaymentauthorized=function(e){var a=e.payment;if(!Pe(a))return o({status:402,msg:"Parsing Apple Pay result happen error"}),Oe(t,Ee).completePayment(ApplePaySession.STATUS_FAILURE);var i=function(e){Oe(t,Ee).completePayment(e)};Re(t,De,(function(t,n){return t?o(t):0===n.status?void r(n.prime,e,i):o(n)}));var s={app_id:u("appID"),app_key:u("appKey"),app_name:window.location.hostname,pay_token_data:a.token.paymentData,apple_merchant_id:n,platform_type:"2"};ie({event:"apple_pay_get_prime",parameter:s})},Oe(this,Ee)):console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document.")}}]),e}(),Ee=new WeakMap,xe=new WeakMap,De=new WeakMap,je=new WeakMap;function Ie(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Ne(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}function We(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}var Fe=function(){function e(t){var n=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Le.set(this,{writable:!0,value:void 0}),Ue.set(this,{writable:!0,value:void 0}),ze.set(this,{writable:!0,value:void 0}),Be.set(this,{writable:!0,value:void 0}),Ve.set(this,{writable:!0,value:void 0}),Ge.set(this,{writable:!0,value:void 0}),Ke.set(this,{writable:!0,value:void 0}),Ye.set(this,{writable:!0,value:function(){le("update",(function(e){We(n,Ke,e.result),Ne(n,Ve).call(n,e.result)})),le("cardtype-change",(function(e){if("tappay-field"===e.field_type){Ne(n,Ge).cardType=e.result;var t=n.formatTappayFieldUpdate();Ne(n,Ve).call(n,t)}})),le("field-focus-change",(function(e){if("tappay-field"===e.field_type){var t=e.result,r=Ne(n,Ge)[t.type].el;"focus"===t.state?ge(r,"tappay-field-focus"):we(r,"tappay-field-focus")}})),le("field-status-change",(function(e){if("tappay-field"===e.field_type){var t=e.result,r=Ne(n,Ge).status;t.type===w?r.number=t.status:t.type===b?r.expiry=t.status:t.type===P&&(r.ccv=t.status);var o=n.formatTappayFieldUpdate();Ne(n,Ve).call(n,o)}})),le("get_prime_for_tappay_fields_done",(function(e){Ne(n,ze).call(n,e.result)})),le("get_prime_for_card_view_done",(function(e){Ne(n,Be).call(n,e.result)}))}}),We(this,Le,t),We(this,Ve,(function(e){return e})),Ne(this,Ye).call(this)}return function(e,t,n){t&&Ie(e.prototype,t),n&&Ie(e,n)}(e,[{key:"setup",value:function(e,t,n){if(me(e)&&(e=document.querySelector(e)),!e)return console.error("[TapPay] TPDirect.card.setup(element): Missing element param");if(fe(e)){var r=e;this.setupTappayFields(r)}else{var o={appKey:u("appKey"),appID:u("appID"),serverType:u("type"),hostname:window.location.hostname,origin:window.location.origin,style:t,config:n||{isUsedCcv:!0}};We(this,Ue,document.createElement("iframe")),Ne(this,Ue).setAttribute("frameborder","0"),Ne(this,Ue).setAttribute("allowtransparency","true"),Ne(this,Ue).setAttribute("scrolling","no"),Ne(this,Ue).setAttribute("style","border: none; margin: 0px; padding: 0px; width: 1px; min-width: 100%; overflow: hidden; display: block; height: 24px;"),t&&t.lineHeight&&(Ne(this,Ue).style.height=t.lineHeight),Ne(this,Ue).src="https://js.tappaysdk.com/tpdirect/v5.7.0/card-view/html?"+encodeURIComponent(JSON.stringify(o)),e.appendChild(Ne(this,Ue))}}},{key:"setupTappayFields",value:function(e){var t=this.setupTappayField(e.fields.number.element,{origin:window.location.origin,type:w,placeholder:e.fields.number.placeholder,styles:e.styles,field_type:"tappay-field"}),n=this.setupTappayField(e.fields.expirationDate.element,{origin:window.location.origin,type:b,placeholder:e.fields.expirationDate.placeholder,styles:e.styles,field_type:"tappay-field"}),r=null;void 0!==e.fields.ccv&&(r=this.setupTappayField(e.fields.ccv.element,{origin:window.location.origin,type:P,placeholder:e.fields.ccv.placeholder,styles:e.styles,field_type:"tappay-field"}));var o=!t||!n;return(o=null==r?o:o||!r)?void console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields"):void We(this,Ge,{"card-number":t,"expiration-date":n,ccv:r,cardType:"unknown",status:{number:v,expiry:v,ccv:v}})}},{key:"setupTappayField",value:function(e,t){if(me(e)&&(e=document.querySelector(e)),!fe(e)){var n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowtransparency","true"),n.setAttribute("scrolling","no"),n.setAttribute("style","border: none; width: 100%; height: 100%; float: left;"),n.src="https://js.tappaysdk.com/tpdirect/v5.7.0/tappay-field/html?"+encodeURIComponent(JSON.stringify(t)),e.appendChild(n),{el:e,iframe:n}}console.warn("[TapPay] TPDirect.card.setup(): Cannot find element for "+t.type)}},{key:"onUpdate",value:function(e){return ce(e)?console.error("[TapPay] TPDirect.card.onUpdate(callback): callback in not a function"):void We(this,Ve,e)}},{key:"getPrime",value:function(e){return ce(e)?console.error("[TapPay] TPDirect.card.getPrime(callback): callback is not a function"):Ne(this,Ge)?this.getPrimeForTappayFields(e):Ne(this,Ue)?void this.getPrimeForCardView(e):console.error("[TapPay] You need to call TPDirect.card.setup(element) first")}},{key:"getTappayFieldsStatus",value:function(){return this.formatTappayFieldUpdate()}},{key:"getPrimeForTappayFields",value:function(e){return this.formatTappayFieldUpdate().canGetPrime?(We(this,ze,e),void ie({event:"get_prime_for_tappay_fields"})):e({status:-5,msg:"[Direct Pay - Fields] canGetPrime is false, not ready to get prime, please use TPDirect.card.getTappayFieldsStatus() to retrive canGetPrime parameter, or detect the canGetPrime parameter with TPDirect.card.onUpdate function"})}},{key:"getPrimeForCardView",value:function(e){return Ne(this,Ke)&&Ne(this,Ke).canGetPrime?(We(this,Be,e),void ie({event:"get_prime_for_card_view"})):e({status:-5,msg:"[Direct Pay - Card View] canGetPrime is false, not ready to get prime, please listen to update with TPDirect.card.onUpdate"})}},{key:"validate",value:function(e,t,n,r){var o=E(e);return{cardType:o,isCardNumberValid:O(e,o),isExpiryDateValid:q(t,n),isCCVValid:x(r,o)}}},{key:"formatTappayFieldUpdate",value:function(){var e=Ne(this,Ge).status,t=Ne(this,Ge).cardType,n=null!=Ne(this,Ge).ccv,r=e.number===m&&e.expiry===m,o=e.number===g||e.expiry===g;return n?(r=r&&e.ccv===m,o=o||e.ccv===g):e.ccv=m,{canGetPrime:r,hasError:o,cardType:t,status:e}}}]),e}(),Le=new WeakMap,Ue=new WeakMap,ze=new WeakMap,Be=new WeakMap,Ve=new WeakMap,Ge=new WeakMap,Ke=new WeakMap,Ye=new WeakMap;function Je(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function He(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}function Xe(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var $e=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Ze.set(this,{writable:!0,value:!1}),Qe.set(this,{writable:!0,value:void 0}),et.set(this,{writable:!0,value:function(e){if(ae())He(t,Qe,(function(t,n){return t?void e(t,null):void e(null,n)})),Xe(t,Ze)&&ie({event:"easy_wallet_get_prime"});else{var n=new ee("Doesn't load pfirame yet");e(n,null)}}}),tt.set(this,{writable:!0,value:function(){le("easy_wallet_get_prime_done",(function(e){Xe(t,Qe).call(t,e.err,e.result)})),le("iframe_get_prime_ready",(function(){He(t,Ze,!0),Xe(t,Qe)&&ie({event:"easy_wallet_get_prime"})}))}}),Xe(this,tt).call(this)}return function(e,t,n){t&&Je(e.prototype,t),n&&Je(e,n)}(e,[{key:"getPrime",value:function(e){return ce(e)?Ce(Xe(this,et)):void Xe(this,et).call(this,e)}},{key:"pay",value:function(e){return be(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}(),Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap;function nt(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],!(0<=t.indexOf(n))&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ot(e){for(var t,n=1;n<arguments.length;n++)t=null==arguments[n]?{}:arguments[n],n%2?rt(Object(t),!0).forEach((function(n){at(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):rt(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}));return e}function at(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function it(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function st(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}function pt(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var lt=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),ut.set(this,{writable:!0,value:void 0}),ct.set(this,{writable:!0,value:void 0}),dt.set(this,{writable:!0,value:void 0}),ft.set(this,{writable:!0,value:void 0}),yt.set(this,{writable:!0,value:void 0}),ht.set(this,{writable:!0,value:void 0}),mt.set(this,{writable:!0,value:function(){le("google_pay_get_prime_done",(function(e){pt(t,ht).call(t,e.error,e.result)}))}}),pt(this,mt).call(this)}return function(e,t,n){t&&it(e.prototype,t),n&&it(e,n)}(e,[{key:"setupTransactionPrice",value:function(e){pt(this,ct).transactionInfo={currencyCode:e.currency,totalPrice:e.price,totalPriceStatus:"FINAL"}}},{key:"setupGooglePay",value:function(e){st(this,dt,e)}},{key:"setupGooglePayButton",value:function(e){var t=this,n=pt(this,ft).createButton({buttonColor:e.color,buttonType:e.type,onClick:function(){t.loadPaymentDataAndGetPrime(e.getPrimeCallback)}});document.querySelector(e.el).appendChild(n)}},{key:"setupPaymentRequest",value:function(e,t){var n=this,r="production"===u("type")?"PRODUCTION":"TEST";return google?void(!this.parsePaymentRequestData(e)||(st(this,ft,new google.payments.api.PaymentsClient({environment:r})),pt(this,ft).isReadyToPay(pt(this,yt)).then((function(e){e.result&&st(n,ut,!0),t(null,{canUseGooglePay:pt(n,ut)})})).catch((function(e){t(e,{canUseGooglePay:!1})})))):console.error("[TapPay] Please includ the google pay sdk https://pay.google.com/gp/p/js/pay.js in front of tappay sdk")}},{key:"getPrime",value:function(e){this.loadPaymentDataAndGetPrime((function(t,n){e(t,n)}))}},{key:"validateItemInSupportedArray",value:function(e,t){return!!(e instanceof Array)&&e.map((function(e){return-1!==t.indexOf(e)})).every((function(e){return!0===e}))}},{key:"parsePaymentRequestData",value:function(e){var t=pt(this,dt),n={apiVersion:2,apiVersionMinor:0},r=e.allowedNetworks,o=t.allowedCardAuthMethods;if(!this.validateItemInSupportedArray(r,["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]))return!1;if(!this.validateItemInSupportedArray(o,["PAN_ONLY","CRYPTOGRAM_3DS"]))return!1;var a={type:"CARD",parameters:{allowPrepaidCards:t.allowPrepaidCards,allowedAuthMethods:o,allowedCardNetworks:r,billingAddressParameters:{format:t.billingAddressFormat,phoneNumberRequired:t.phoneNumberRequired},billingAddressRequired:t.billingAddressRequired}},i=ot({},n);i.allowedPaymentMethods=[a];var s=ot(ot({},a),{},{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"tappay",gatewayMerchantId:"tappay"}}}),p=ot({},n);return p.allowedPaymentMethods=[s],p.transactionInfo={totalPriceStatus:"FINAL",totalPrice:e.price,currencyCode:e.currency},p.merchantInfo={merchantName:t.merchantName,merchantId:t.googleMerchantId},p.emailRequired=t.emailRequired,p.shippingAddressRequired=t.shippingAddressRequired,p.shippingAddressParameters={allowedCountryCodes:t.allowedCountryCodes,phoneNumberRequired:t.phoneNumberRequired},st(this,yt,i),st(this,ct,p),!0}},{key:"loadPaymentDataAndGetPrime",value:function(e){var t=this;return pt(this,ut)?void pt(this,ft).loadPaymentData(pt(this,ct)).then((function(n){ie({event:"google_pay_get_prime",payment_data:n}),st(t,ht,(function(t,n){if(t)e(t,null);else if(0===n.status){n.status;var r=n.prime,o=(n.msg,nt(n,["status","prime","msg"]));o.merchant_reference_info||(o.merchant_reference_info={affiliate_codes:[]}),e(null,r,o)}else e(n,null)}))})).catch((function(t){e({status:2200,msg:"[Google Pay] Unexcept Error",originalError:t},null)})):console.error("[TapPay] Your device doesn't support Google Pay")}}]),e}(),ut=new WeakMap,ct=new WeakMap,dt=new WeakMap,ft=new WeakMap,yt=new WeakMap,ht=new WeakMap,mt=new WeakMap;function vt(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function gt(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}function wt(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var bt=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Pt.set(this,{writable:!0,value:!1}),_t.set(this,{writable:!0,value:void 0}),kt.set(this,{writable:!0,value:function(){le("jko_pay_get_prime_done",(function(e){wt(t,_t).call(t,e.err,e.result)})),le("iframe_get_prime_ready",(function(){gt(t,Pt,!0),wt(t,_t)&&ie({event:"jko_pay_get_prime"})}))}}),wt(this,kt).call(this)}return function(e,t,n){t&&vt(e.prototype,t),n&&vt(e,n)}(e,[{key:"getPrime",value:function(e){return ce(e)?console.error("[TapPay] TPDirect.jkoPay.getPrime(callback): callback is not a function"):ae()?(gt(this,_t,(function(t,n){return t?void e(t):void e(n)})),void(wt(this,Pt)&&ie({event:"jko_pay_get_prime"}))):console.error("[TapPay] Doesnt load pfirame yet")}},{key:"pay",value:function(e){return be(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}(),Pt=new WeakMap,_t=new WeakMap,kt=new WeakMap;function Tt(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function At(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}function St(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var Ct=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Mt.set(this,{writable:!0,value:!1}),Rt.set(this,{writable:!0,value:void 0}),Ot.set(this,{writable:!0,value:function(){le("line_pay_get_prime_done",(function(e){St(t,Rt).call(t,e.err,e.result,e.url)})),le("iframe_get_prime_ready",(function(){At(t,Mt,!0),St(t,Rt)&&ie({event:"line_pay_get_prime"})}))}}),St(this,Ot).call(this)}return function(e,t,n){t&&Tt(e.prototype,t),n&&Tt(e,n)}(e,[{key:"getPrime",value:function(e){return ce(e)?console.error("[TapPay] TPDirect.linePay.getPrime(callback): callback is not a function"):ae()?(At(this,Rt,(function(t,n){return t?void e(t):void e(n)})),void(St(this,Mt)&&ie({event:"line_pay_get_prime"}))):console.error("[TapPay] Doesnt load pfirame yet")}},{key:"pay",value:function(e){return be(e)?void(window.location.href=e):console.error("[TapPay] Your payment url is not valid.")}}]),e}(),Mt=new WeakMap,Rt=new WeakMap,Ot=new WeakMap;function qt(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],0<=t.indexOf(n)||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],!(0<=t.indexOf(n))&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Et(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function xt(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}function Dt(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}var jt=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),It.set(this,{writable:!0,value:void 0}),Nt.set(this,{writable:!0,value:void 0}),Wt.set(this,{writable:!0,value:void 0}),Ft.set(this,{writable:!0,value:void 0}),Lt.set(this,{writable:!0,value:void 0}),Ut.set(this,{writable:!0,value:function(){var e={MODE:"",appKey:u("appKey"),appID:u("appID"),serverType:u("type"),hostname:window.location.hostname,origin:window.location.origin,referrer:document.referrer,href:window.location.href,port:window.location.port,protocol:window.location.protocol,sdk_version:u("sdk_version"),payment_request:xt(t,Nt)};Dt(t,Lt,document.createElement("iframe")),xt(t,Lt).setAttribute("frameborder","0"),xt(t,Lt).setAttribute("allowtransparency","true"),xt(t,Lt).setAttribute("style","z-index: 2147483647; display: block; background: rgba(0, 0, 0, 0.004); border: 0px none transparent; overflow-x: hidden; overflow-y: auto; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"),xt(t,Lt).src="https://js.tappaysdk.com/tpdirect/v5.7.0/samsung-pay/html?"+encodeURIComponent(JSON.stringify(e)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?(document.body.appendChild(xt(t,Lt)),xt(t,Vt).call(t)):document.addEventListener("DOMContentLoaded",(function(){document.body.appendChild(xt(this,Lt)),xt(this,Vt).call(this)}))}}),zt.set(this,{writable:!0,value:function(){document.body.removeChild(xt(t,Lt)),xt(t,Gt).call(t)}}),Bt.set(this,{writable:!0,value:function(){!function(e){var t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),t.appendChild(n)}("body.tappay-samsung-pay-shown{ height: auto; overflow-y: hidden; }html.tappay-samsung-pay-shown{ height: auto; overflow-y: hidden; }")}}),Vt.set(this,{writable:!0,value:function(){ge(document.documentElement,"tappay-samsung-pay-shown"),ge(document.body,"tappay-samsung-pay-shown")}}),Gt.set(this,{writable:!0,value:function(){we(document.documentElement,"tappay-samsung-pay-shown"),we(document.body,"tappay-samsung-pay-shown")}}),Kt.set(this,{writable:!0,value:function(e){if(0!==e.status)return e;var t=e.card_last_four,n=e.card_type,r=qt(e,["card_last_four","card_type"]);return r.merchant_reference_info||(r.merchant_reference_info={affiliate_codes:[]}),Object.assign(r,{card:{lastfour:t,type:Te(n)}})}}),Yt.set(this,{writable:!0,value:function(e){if(he(e))return!0;if("[object Array]"!==Object.prototype.toString.call(e))return!1;if(0===e.length)return!1;for(var t=0;t<e.length;t++){var n=e[t];if(!(me(n)||n instanceof String)||""===n)return!1}return!0}}),Jt.set(this,{writable:!0,value:function(){le("samsung_pay_iframe_result",(function(e){xt(t,Ft).call(t,e.result)}))}}),Dt(this,It,!1),Dt(this,Nt,{country_code:"tw"}),Dt(this,Ft,(function(e){xt(t,zt).call(t);var n=xt(t,Kt).call(t,e);xt(t,Wt).call(t,n)})),xt(this,Jt).call(this)}return function(e,t,n){t&&Et(e.prototype,t),n&&Et(e,n)}(e,[{key:"setup",value:function(e){xt(this,Nt).country_code=e.country_code}},{key:"setupPaymentRequest",value:function(e){var t=e.total;return t&&t.label&&t.amount&&t.amount.currency&&parseFloat(t.amount.value)?xt(this,Yt).call(this,e.supportedNetworks)?(!1===xt(this,It)&&xt(this,Bt).call(this),xt(this,Nt).allowed_brands=e.supportedNetworks,xt(this,Nt).merchant_name=t.label,xt(this,Nt).currency=t.amount.currency,xt(this,Nt).amount=parseFloat(t.amount.value),void Dt(this,It,!0)):console.error("[TPDirect.samsungPay.setupPaymentRequest] Please check payment request format (supportedNetworks)"):console.error("[TPDirect.samsungPay.setupPaymentRequest] Please check payment request format")}},{key:"getPrime",value:function(e){return ce(e)?console.error("[TapPay] TPDirect.samsungPay.getPrime(callback): callback is not a function"):xt(this,It)?(Dt(this,Wt,e),void xt(this,Ut).call(this)):e({status:-5,msg:"[TPDirect.samsungPay.getPrime] Setup Samsung Pay with TPDirect.samsungPay.setupPaymentRequest first"})}},{key:"setupSamsungPayButton",value:function(e,t){if(me(e)&&(e=document.querySelector(e)),!de(e))return console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: No element to setup.");var n={color:"black",type:"pay",shape:"rectangular"};t||(t=n),t.color||(t.color=n.color),t.type||(t.type=n.type),t.shape||(t.shape=n.shape),-1===["black","white"].indexOf(t.color)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown color option "+t.color),t.color=n.color),-1===["pay","buy"].indexOf(t.type)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown type option "+t.type),t.type=n.type),-1===["rectangular","pill"].indexOf(t.shape)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown shape option "+t.shape),t.shape=n.shape);var r="https://js.tappaysdk.com/tpdirect/image/samsung-pay/"+t.type+"_"+t.color+"_"+t.shape+".svg",o=document.createElement("div"),a="background-origin: content-box;background-position: center;background-repeat: no-repeat;background-size: contain;border: 0;outline: 0;height: 100%;min-height: 40px;width: 100%;cursor: pointer;";a+="background-image: url("+r+");",o.setAttribute("style",a),e.appendChild(o)}}]),e}(),It=new WeakMap,Nt=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,Lt=new WeakMap,Ut=new WeakMap,zt=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap;function Ht(e,t){for(var n,r=0;r<t.length;r++)(n=t[r]).enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function Xt(e,t,n){var r=t.get(e);if(!r)throw new TypeError("attempted to set private field on non-instance");if(r.set)r.set.call(e,n);else{if(!r.writable)throw new TypeError("attempted to set read only private field");r.value=n}return n}function $t(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var Zt=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),Qt.set(this,{writable:!0,value:void 0}),en.set(this,{writable:!0,value:void 0}),tn.set(this,{writable:!0,value:!1}),nn.set(this,{writable:!0,value:void 0}),rn.set(this,{writable:!0,value:void 0}),on.set(this,{writable:!0,value:function(){}}),an.set(this,{writable:!0,value:function(e,t){if(me(e)&&(e=document.querySelector(e)),!fe(e)){var n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowtransparency","true"),n.setAttribute("scrolling","no"),n.setAttribute("style","border: none; width: 100%; height: 100%; float: left;"),n.src="https://js.tappaysdk.com/tpdirect/v5.7.0/tappay-field/html?"+encodeURIComponent(JSON.stringify(t)),e.appendChild(n),{el:e,iframe:n}}console.warn("[TapPay] TPDirect.card.setup(): Cannot find element for "+t.type)}}),sn.set(this,{writable:!0,value:function(e){Xt(t,Qt,(function(t,n){return t?void e(t,null):void e(null,n)})),$t(t,ln).call(t,{event:"get_prime_for_ccv_prime"})}}),pn.set(this,{writable:!0,value:function(){var e=$t(t,rn);return{canGetPrime:e===m,hasError:e===g,status:{ccv:e}}}}),ln.set(this,{writable:!0,value:function(e){ie(e)}}),un.set(this,{writable:!0,value:function(e){!function(e,t){e.contentWindow.postMessage(JSON.stringify(t),c)}($t(t,en),e)}}),cn.set(this,{writable:!0,value:function(){le("get_prime_for_ccv_prime_done",(function(e){$t(t,Qt).call(t,e.err,e.result)}))}}),dn.set(this,{writable:!0,value:function(){le("ccv_field_ready",(function(e){"ccv-prime"===e.field_type&&($t(t,tn)||(Xt(t,tn,!0),$t(t,nn).call(t,C().lower)))})),le("field-status-change",(function(e){if("ccv-prime"===e.field_type){var n=e.result;Xt(t,rn,n.status);var r=$t(t,pn).call(t);$t(t,on).call(t,r)}}))}}),fn.set(this,{writable:!0,value:function(){$t(t,cn).call(t),$t(t,dn).call(t)}}),$t(this,fn).call(this),Xt(this,nn,(function(e){return S(e)?void $t(t,un).call(t,{event:"cardtype-change",result:e,field_type:"ccv-prime"}):void console.error("[TapPay] TPDirect.ccv.setupCardType(): Invalid card type")}))}return function(e,t,n){t&&Ht(e.prototype,t),n&&Ht(e,n)}(e,[{key:"setup",value:function(e){if($t(this,en))console.error("[TapPay] TPDirect.ccv.setup() has been called once");else{var t=$t(this,an).call(this,e.fields.ccv.element,{origin:window.location.origin,type:P,placeholder:e.fields.ccv.placeholder,styles:e.styles,field_type:"ccv-prime"});Xt(this,en,t.iframe)}}},{key:"setupCardType",value:function(e){$t(this,tn)&&$t(this,nn).call(this,e)}},{key:"getPrime",value:function(e){var t,n=ce(e);return t=$t(this,pn).call(this).canGetPrime?$t(this,sn):function(e){e(new ee("You couldn't get ccv prime because of your ccv is invalid"),null)},n?Ce(t):void t(e)}},{key:"onUpdate",value:function(e){return ce(e)?console.error("[TapPay] TPDirect.ccv.onUpdate(callback): callback in not a function"):void Xt(this,on,e)}}]),e}(),Qt=new WeakMap,en=new WeakMap,tn=new WeakMap,nn=new WeakMap,rn=new WeakMap,on=new WeakMap,an=new WeakMap,sn=new WeakMap,pn=new WeakMap,ln=new WeakMap,un=new WeakMap,cn=new WeakMap,dn=new WeakMap,fn=new WeakMap,yn=A(),hn=Object.create(null);Object.keys(yn).map((function(e){hn[e.toLocaleUpperCase()]=yn[e].toLocaleLowerCase()}));var mn=hn;function vn(e){return(vn="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})(e)}!function(e){window.addEventListener("message",(function(e){if(-1!==se.indexOf(e.origin)){var t=JSON.parse(e.data);if(t.err&&(t.err=te(t.err)),t.error&&(t.error=te(t.error)),pe.has(t.event)){var n=pe.get(t.event);if(0===n.length)return;for(var r=0;r<n.length;r++)n[r](t)}}}),!1),e.location.origin||(e.location.origin=e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:""));var t,n,r,o,a,i,c,d,f,y,h,m,v={},g=!1,w=[];if("https://js.tappaysdk.com",t=document.querySelectorAll('script[src^="https://js.tappaysdk.com"]'),m=0>=t.length?"v5.7.0":"v"+t[0].src.split("/v")[1],"withCredentials"in new XMLHttpRequest)n=!0;else{if(!e.XDomainRequest)return n=!1,console.warn("[TapPay] It looks like browser not support cors.");n=!0}e.TPDirect?(e.TPDirect.isDoubleLoaded=!0,console.warn("[TapPay] It looks like TPDirect.js was loaded more than one time.")):(e.TPDirect=function(t){return r=e.location.hostname,(t={}).isDoubleLoaded=!1,t.setPublishableKey=function(e,t,n){l({appID:e,appKey:t,type:n,endPoint:"production"===n?"https://prod.tappaysdk.com":"https://sandbox.tappaysdk.com"})},t.setupSDK=function(t,n,r){if("object"===vn(t)){var o=t,a=o.rbaAppKey,i=o.rbaAppId;t=o.tappayAppId,n=o.tappayAppKey,r=o.env}i&&a&&function(e){le("send_device_id",(function(e){oe=e.result,ie({event:"main_event_data_register",dataset:{ddcaResult:oe}})})),(re=document.createElement("iframe")).setAttribute("style","display: none;"),re.src="https://fraud.tappaysdk.com/ddca/iframe?"+encodeURIComponent(JSON.stringify(e)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?document.body.appendChild(re):document.addEventListener("DOMContentLoaded",(function(){document.body.appendChild(re)}))}({rbaAppKey:a,rbaAppId:i,serverType:r,origin:e.location.origin,mode:"production"});if(!t||!n||!r)return console.error("[TapPay] TPDirect.setupSDK error, appID = "+t+", appKey = "+n+", serverType = "+r);if(ve(r))return console.error('[TapPay] TPDirect.setupSDK error, serverType is not "sandbox" nor "production", serverType = '+r);if("production"!==(r=r.toLowerCase())&&"sandbox"!==r)return console.error('[TapPay] TPDirect.setupSDK error, serverType is not "sandbox" nor "production", serverType = '+r);if(!ae()){l({appID:t,appKey:n,type:r,endPoint:"production"===r?"https://prod.tappaysdk.com":"https://sandbox.tappaysdk.com",sdk_version:m});var s={appKey:u("appKey"),appID:u("appID"),serverType:u("type"),hostname:e.location.hostname,origin:e.location.origin,referrer:document.referrer,href:e.location.href,port:e.location.port,protocol:e.location.protocol,sdk_version:u("sdk_version")};(h=document.createElement("iframe")).setAttribute("allowpaymentrequest",!0),h.setAttribute("frameborder","0"),h.setAttribute("allowtransparency","true"),h.setAttribute("scrolling","no"),h.setAttribute("style","display: none;"),h.src="https://js.tappaysdk.com/tpdirect/v5.7.0/api/html?"+encodeURIComponent(JSON.stringify(s)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?document.body.appendChild(h):document.addEventListener("DOMContentLoaded",(function(){document.body.appendChild(h)})),function(e){ne=e}(h)}},t.redirect=function(t){return be(t)?void(e.location=t):console.error("[TapPay] Your payment url is not valid.")},v=t,t}(v),e.TPDirect.CardType=mn,e.TPDirect.card=new Fe(v),e.TPDirect.googlePay=new lt,e.TPDirect.linePay=new Ct,e.TPDirect.samsungPay=new jt,e.TPDirect.jkoPay=new bt,e.TPDirect.easyWallet=new $e,e.TPDirect.ccv=new Zt,e.TPDirect.applePay=new qe,e.TPDirect.paymentRequestApi=function(t,n){var l=null;return(n={}).isAmountPending=!1,n.paymentRequest=null,n.pay_with_google_options=null,n.apple_pay_options=null,n.checkAvailability=function(){var t=!1;return e.ApplePaySession?t=_e():e.PaymentRequest&&(t=!0),!1===t?(console.warn("[TapPay] Your Browser Did Not Support Payment Request and Apple Pay"),!1):"https:"!==location.protocol&&"localhost"!==e.location.hostname?(console.warn("[TapPay] Trying to call an PaymentRequest API from an insecure document or http://localhost."),!1):!s.a.msedge||(console.warn("[TapPay] Does not support PaymentRequest on Edge."),!1)},n.availableMethods=function(){return s.a.msedge?[]:_e()?["apple_pay"]:s.a.android&&s.a.check({chrome:"61"})?["card","pay_with_google"]:s.a.android&&ye(e.PaymentRequest)||ye(e.PaymentRequest)?["card"]:[]},n.setupTappayPaymentButton=function(t,r){if(me(t)&&(t=document.querySelector(t)),!de(t))return console.error("[TapPay] TPDirect.paymentRequestApi.setupTappayPaymentButton: Missing element param");if(ce(r))return console.error("[TapPay] TPDirect.paymentRequestApi.setupTappayPaymentButton: Missing callback function");t.style.cursor="pointer";var o,a=!1,i=!1,p=e.TPDirect.paymentRequestApi.paymentRequest.supportedInstruments,l=p.find((function(e){return-1!==e.supportedMethods.indexOf("https://android.com/pay")})),u=p.find((function(e){return-1!==e.supportedMethods.indexOf("https://google.com/pay")}));if(s.a.android&&s.a.check({chrome:"61"})&&u?a=!0:s.a.android&&"undefined"!==e.PaymentRequest&&l&&(i=!0),e.ApplePaySession)(o=document.createElement("div")).style.height="40px",o.style["-webkit-appearance"]="-apple-pay-button",o.style["-apple-pay-button-type"]=y.canMakePaymentWithActiveCard?"buy":"set-up",t.appendChild(o);else if(a){o=document.createElement("div"),ge(o,"googlepay"),o.setAttribute("style","background-color: white;background-image: url('data:image/svg+xml,%3Csvg%20width%3D%22102%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M80.526%202.635v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H95.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%235F6368%22%2F%3E%3Cpath%20d%3D%22M74.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M67.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M64.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M67.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976z%22%20fill%3D%22%233C4043%22%2F%3E%3Cpath%20d%3D%22M61%200h41.285v18H61z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E');background-origin: content-box;background-position: center;background-repeat: no-repeat;background-size: contain;border: 0;border-radius: 4px;box-shadow: 0px 1px 3px 0px #6d6d6d;outline: 0;padding: 10px 8px;height: 40px;min-height: 40px;");var c=document.createElement("style"),d=".googlepay:focus {box-shadow: 0px 1px 3px 0px #6d6d6d, inset 0px 0px 0px 1px #a8abb3;} #pr-button:hover:enabled .googlepay {background-color: #f7f7f7;} .googlepay:active:enabled {background-color: #e7e8e8;} #pr-button:hover .googlepay {background-color: #f7f7f7 !important}";c.styleSheet?c.styleSheet.cssText=d:c.appendChild(document.createTextNode(d)),o.appendChild(c),t.appendChild(o)}else if(i)(o=document.createElement("div")).setAttribute("style","border-radius:5px; box-shadow:0px 1px 3px rgb(116,116,116);height: 100%;background-size:auto calc(60% + 2px);background-repeat:no-repeat;background-position:center;background-color:#fff;background-image:url(https://link-pay.tappaysdk.com/images/android_pay_logo.png)"),t.appendChild(o);else{(o=document.createElement("div")).setAttribute("style","display:flex;justify-content:center;color:rgb(61,64,67);background: #fff;border-radius:5px;box-shadow:0px 1px 3px rgb(116,116,116);height:100%;align-items:center;-webkit-tap-highlight-color: transparent;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;font: 500 16px/21px -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-weight: 500;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;");var f=document.createElement("img");f.setAttribute("src","https://s3-ap-northeast-1.amazonaws.com/tappay-image-resource/favicon-32x32.png"),f.setAttribute("style","width: 20px; height: 20px; margin-right: 5px;");var h=document.createElement("span");h.textContent=ke(),o.appendChild(f),o.appendChild(h),t.appendChild(o)}t.addEventListener("click",(function(){n.getPrime((function(e){r(e)}))}),!1)},n.setupPaymentRequest=function(t,r){ce(r)&&(r=function(e){return e.browserSupportPaymentRequest?void(!e.canMakePaymentWithActiveCard&&console.error("[TapPay] User does not have support payment method.")):void console.error("[TapPay] Browser does not support PaymentRequest or Apple Pay")}),a=function(e){y=e,r(e)};var o=n.checkAvailability();if(!o)return a({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null});var i=s.a.android&&s.a.check({chrome:"61"}),p=-1===t.supportedMethods.indexOf("card")&&-1===t.supportedMethods.indexOf("basic-card"),l=he(e.ApplePaySession);p&&l&&!i&&(o=!1),1===t.supportedMethods.length&&("pay_with_google"===t.supportedMethods[0]||"https://google.com/pay"===t.supportedMethods[0])&&!i&&(o=!1),1===t.supportedMethods.length&&("apple_pay"===t.supportedMethods[0]||"https://apple.com/apple-pay"===t.supportedMethods[0])&&he(e.ApplePaySession)&&(o=!1);var u=-1===t.supportedMethods.indexOf("apple_pay")&&-1===t.supportedMethods.indexOf("https://apple.com/apple-pay");if(e.ApplePaySession&&u&&(o=!1),o)if(n.preparePaymentRequest(t))if(e.ApplePaySession){if(!n.apple_pay_options)return void console.error("[TapPay]: You need to call `TPDirect.paymentRequestApi.setupApplePay` before `TPDirect.paymentRequestApi.setupPaymentRequest`");var c=n.apple_pay_options.merchantIdentifier;v.applePay.canMakePaymentsWithActiveCard(c,a)}else{if(s.a.ios&&s.a.chrome)return n.iosChromeSetupPaymentRequest(),void n.iosChromeCheckCanMakePaymentWithActiveCard();var d=function(){ie({event:"setup_payment_request",paymentRequest:n.paymentRequest,pay_with_google_options:n.pay_with_google_options})};g?d():w.push(d)}else console.error("[TapPay] Please check your paymentRequest");else a({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null})},n.setupApplePay=function(e){e.merchantIdentifier&&!ve(e.merchantIdentifier)||console.error("[TapPay] TPDirect.paymentRequestApi.setupApplePay: merchantIdentifier is required"),e.countryCode&&(ve(e.countryCode)||2!==e.countryCode.length)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupApplePay: countryCode need to be two-letter ISO 3166 country code format."),n.apple_pay_options=e},n.setupPayWithGoogle=function(e){e.allowedPaymentMethods&&e.allowedPaymentMethods.forEach((function(e){-1===["CARD","TOKENIZED_CARD"].indexOf(e)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowedPaymentMethods error: "+e)}));var t=vn(e.allowPrepaidCards);-1===["boolean","undefined"].indexOf(t)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowPrepaidCards type error: "+t);var r=vn(e.billingAddressRequired);if(-1===["boolean","undefined"].indexOf(r)&&console.error("[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: billingAddressRequired type error: "+r),e.billingAddressFormat&&-1===["FULL","MIN"].indexOf(e.billingAddressFormat)){var o="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: billingAddressFormat error: "+e.billingAddressFormat;console.error(o)}if(e.allowedCountryCodes&&"[object Array]"!==Object.prototype.toString.call(e.allowedCountryCodes)){var a="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowedCountryCodes error: "+e.allowedCountryCodes;console.error(a)}n.pay_with_google_options=e},n.preparePaymentItems=function(e){if(!e.hasOwnProperty("total"))return console.error("[TapPay] You need to setup total in the paymentRequest"),!1;var t=!1,r=!1,o=!ye(e.total.isShowTotalAmount)||e.total.isShowTotalAmount,a=!!ye(e.total.isAmountPending)&&e.total.isAmountPending,i={amount:{currency:null,value:"0.00"}},s=function(e,t,n){return{label:e,amount:{currency:t,value:n}}},p=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;return{label:e,amount:{currency:t,value:n},isAmountPending:!0}},l=function(e,t){return parseFloat(e)!==parseFloat(t)},u=0,c=JSON.parse(JSON.stringify(e)),d=!!(c.displayItems&&0<c.displayItems.length);if(d||(c.displayItems=null),d){for(var f,y=[],h=0;h<c.displayItems.length;h++){if(f=c.displayItems[h],i.amount.currency||(i.amount.currency=f.amount.currency),i.amount.currency!==f.amount.currency)return console.error("[TapPay] payment request data have inconsistent currency, please use consistent currency."),!1;if(!f.isAmountPending&&!1===Object.hasOwnProperty.call(f.amount,"value"))return console.error("Your displayItems object should have `amount.value` or `isAmountPending:true`"),!1;if(f.isAmountPending&&Object.hasOwnProperty.call(f.amount,"value"))return console.error("Your displayItems object should only have `amount.value` or `isAmountPending:true`"),!1;f.isAmountPending?(t=!0,y.push(1),Object.assign(f,i)):y.push(-1),u+=parseFloat(f.amount.value)}y.reduce((function(e,t){return e+t}),0)===c.displayItems.length&&(r=!0)}if(i.amount.currency||(i.amount.currency=c.total.amount.currency),i.amount.currency!==c.total.amount.currency)return console.error("[TapPay] payment request data have inconsistent currency, please use consistent currency."),!1;if(!o&&!a)return console.error("[TapPay] `isShowTotalAmount` and `total.isAmountPending` couldn't be false at the same time."),!1;if(d){var m=!(0!==u||!r);if(!(0===u||!t)||null){if(!a)return console.error("[TapPay] `total.isAmountPending` must be true if there is any payment item's amount is `pending`"),!1;if(n.isAmountPending=!0,o){if(l(c.total.amount.value,u))return console.error("[TapPay] Your total amount value is not equal to sum of displayItems value."),!1;c.total=s(c.total.label,i.amount.currency,u)}else c.total=p(c.total.label,i.amount.currency,u)}else if(m){if(!a)return console.error("[TapPay] `total.isAmountPending` must be true if there is any payment item's amount is `pending`"),!1;if(o)return console.error("[TapPay] Total amount couldn’t be displayed if all paymentItems' amount are pending."),!1;n.isAmountPending=!0,c.total=p(c.total.label,i.amount.currency,1)}else if(n.isAmountPending=a,o){var v=c.total.amount.value;if(l(v,u))return console.error("[TapPay] Your total amount value is not equal to sum of displayItems value."),!1;if(0>=parseFloat(v))return console.error("[TapPay] `total.amount.value` must greater than zero when `total.isShowTotalAmount:true`"),!1;c.total=s(c.total.label,i.amount.currency,u)}else c.total=p(c.total.label,i.amount.currency,u)}else if(n.isAmountPending=a,o){if(!1===Object.hasOwnProperty.call(c.total.amount,"value"))return console.error("[TapPay] `total.amount.value` should have value when `total.isShowTotalAmount:true`"),!1;var g=c.total.amount.value;if(0>=parseFloat(g))return console.error("[TapPay] `total.amount.value` must greater than zero when `total.isShowTotalAmount:true`"),!1;c.total=s(c.total.label,i.amount.currency,g)}else c.total=p(c.total.label,i.amount.currency,1);return{displayItems:c.displayItems,total:c.total,shippingOptions:c.shippingOptions||[]}},n.preparePaymentOptions=function(e){var t={};return e.hasOwnProperty("options")&&(t=e.options),t},n.parseSupportMethod=function(e,t){var r=t.supportedNetworks,o=t.options||{},a={};if(-1===["card","pay_with_google","apple_pay","basic-card","https://google.com/pay","https://apple.com/apple-pay"].indexOf(e))return console.error("[TapPay] "+e+" is not supported, supportedMethods: card, pay_with_google, apple_pay");if("card"===e||"basic-card"===e)a={supportedMethods:["basic-card"],data:{supportedNetworks:r.map((function(e){return e.toLowerCase()}))}};else if("pay_with_google"===e||"https://google.com/pay"===e){var i=n.pay_with_google_options||{};a={supportedMethods:["https://google.com/pay"],data:{merchantId:"04234483533225200652",environment:"TEST",apiVersion:1,allowedPaymentMethods:i.allowedPaymentMethods||["CARD","TOKENIZED_CARD"],paymentMethodTokenizationParameters:{tokenizationType:"PAYMENT_GATEWAY",parameters:{gateway:"tappay",gatewayMerchantId:"tappay"}},cardRequirements:{allowedCardNetworks:r,allowPrepaidCards:i.allowPrepaidCards||!0,billingAddressRequired:i.billingAddressRequired||!1,billingAddressFormat:i.billingAddressFormat||"MIN"},phoneNumberRequired:o.requestPayerPhone||!1,emailRequired:o.requestPayerEmail||!1,shippingAddressRequired:o.requestShipping||!1,shippingAddressRequirements:{allowedCountryCodes:i.allowedCountryCodes||void 0}}},"production"===u("type")&&delete a.data.environment}else if("apple_pay"===e||"https://apple.com/apple-pay"===e){var s=n.apple_pay_options||{};a={supportedMethods:["https://apple.com/apple-pay"],data:{supportedNetworks:n.convertToApplePayNetworks(r),countryCode:s.countryCode||"TW",merchantIdentifier:s.merchantIdentifier}}}return a},n.convertToApplePayNetworks=function(e){return e.map((function(e){var t=e.toLowerCase();return"amex"===t?"amex":"jcb"===t?"jcb":"mastercard"===t?"masterCard":"visa"===t?"visa":null})).filter((function(e){return null!==e}))},n.preparePaymentMethods=function(e){return e.hasOwnProperty("supportedMethods")?e.supportedMethods.map((function(t){return n.parseSupportMethod(t,e)})):(console.error('[TapPay] "supportedMthods" is not found in the paymentRequest, you need to setup the right name.'),!1)},n.preparePaymentRequest=function(e){var t=n.preparePaymentMethods(e),r=n.preparePaymentItems(e),o=n.preparePaymentOptions(e);return t&&r&&o?(n.paymentRequest={supportedInstruments:t,details:r,options:o},!0):(n.paymentRequest=null,!1)},n.getPrime=function(t){return ce(t)?console.error("[TapPay] TPDirect.paymentRequestApi.getPrime(callback): callback is not a function"):h?n.paymentRequest?e.ApplePaySession?void n.applePayGetPrime(t):f?void n.iosChromeGetPrime(t):(i=t,void ie({event:"payment_request_get_prime"})):console.error("[TapPay] You need to setup the complete payment request."):console.error("[TapPay] Doesnt load pfirame yet")},n.iosChromeSetupPaymentRequest=function(){var t=n.paymentRequest,r=t.supportedInstruments,o=t.details,i=t.options;"servicePickup"===i.shippingType&&(i.shippingType="pickup");try{f=new e.PaymentRequest(r,o,i)}catch(e){return void a({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1})}f.addEventListener("shippingoptionchange",(function(e){var n=JSON.parse(JSON.stringify(t.details));n.shippingOptions=n.shippingOptions.map((function(e){return f.shippingOption===e.id?(e.selected=!0,n.total.amount.value=(parseFloat(n.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e})),e.updateWith(p.Promise.resolve(o))})),f.addEventListener("shippingaddresschange",(function(e){e.updateWith(p.Promise.resolve(t.details))}))},n.iosChromeCheckCanMakePaymentWithActiveCard=function(){var e=p.Promise.resolve(!0);f.canMakePayment&&(e=f.canMakePayment()),e.then((function(e){a({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e})})).catch((function(e){console.error("[TapPay] PaymentRequest.canMakePayment error (see https://developers.google.com/web/fundamentals/payments/deep-dive-into-payment-request#check_payment_method_availability): ",e),a({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:!0,canMakePaymentError:e})}))},n.iosChromeGetPrime=function(t){f.show().then((function(n){var r,a=e.TPDirect.paymentRequestApi.paymentRequest,i=a.details.shippingOptions,s=a.details.total.amount.value;if(!0===a.options.requestShipping&&i&&i.length){var p=i.find((function(e){return e.id===n.shippingOption})).amount.value;r=(parseFloat(s)+parseFloat(p)).toString()}else r=s;if("basic-card"===n.methodName||"basic_card"===n.methodName){var l=n.details.cardNumber,u=n.details.expiryMonth,c=n.details.expiryYear.slice(2),d=n.details.cardSecurityCode;o=function(e){0===e.status?(e.payer={email:n.payerEmail,name:n.payerName,phone:n.payerPhone},e.billingAddress=n.details.billingAddress,e.shippingAddress=n.shippingAddress,e.shippingOption=n.shippingOption,e.methodName="card",e.requestId=n.requestId,e.prime=e.card.prime,e.total_amount=r,n.complete("success")):n.complete("fail"),t(e)},ie({event:"get_prime",card:{number:l,exp_month:u,exp_year:c,ccv:d}})}})).catch((function(e){var r={status:401,msg:e.message};t(r),n.iosChromeSetupPaymentRequest()}))},n.applePayGetPrime=function(t){i=t;var o=n.paymentRequest;"pickup"===o.options.shippingType&&(o.options.shippingType="storePickup");var a=new _.PaymentRequest(o.supportedInstruments,o.details,o.options);a.onvalidatemerchant=function(e){var t=e.validationURL,o=n.apple_pay_options.merchantIdentifier,i={appId:u("appID"),appKey:u("appKey"),appName:r,appleMerchantId:o,merchant_domain:r,validationURL:t,tappay_endpoint:u("endPoint")};d=function(e,t){if(e)l=new Error("[Apple Pay] Get Session error: ".concat(e.msg));else if(0===t.status)if(0===t.status&&t.statusMessage){var n=t.statusMessage;l=new Error("[Apple Pay] Get Session error: ".concat(n))}else a.completeMerchantValidation(t);else{var r=t.errorMessage||t.msg;l=new Error("[Apple Pay] Get Session error: ".concat(r))}},ie({event:"apple_pay_get_session",payload:i})},a.onshippingoptionchange=function(t){var n=JSON.parse(JSON.stringify(e.TPDirect.paymentRequestApi.paymentRequest)).details;n.shippingOptions=n.shippingOptions.map((function(e){return a.shippingOption===e.id?(e.selected=!0,n.total.amount.value=(parseFloat(n.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e})),t.updateWith(n)},a.onshippingaddresschange=function(e){var t=JSON.parse(JSON.stringify(n.paymentRequest.details));t.shippingOptions&&t.shippingOptions.length&&(t.total.amount.value=(parseFloat(t.total.amount.value)+parseFloat(t.shippingOptions[0].amount.value)).toString()),e.updateWith(t)},a.show().then((function(e){if(!Pe(e.applePayRaw))return t({status:402,msg:"[Apple Pay] Parsing Apple Pay result happen error"}),e.complete("fail");var a={app_id:u("appID"),app_key:u("appKey"),app_name:r,pay_token_data:e.applePayRaw.token.paymentData,apple_merchant_id:n.apple_pay_options.merchantIdentifier,platform_type:"2",is_amount_pending:n.isAmountPending,device_id:oe.deviceId,tappay_sdk_version:u("sdk_version")},i=function(r){var a=r;if(0===a.status){a.merchant_reference_info||(a.merchant_reference_info={affiliate_codes:[]}),a.payer={email:e.payerEmail,name:e.payerName,phone:e.payerPhone},a.billingAddress=e.details.billingAddress,a.shippingAddress=e.shippingAddress,a.shippingOption=e.shippingOption,a.methodName="apple_pay";var i=e.applePayRaw.token.paymentMethod;a.card={lastfour:i.displayName.split(" ")[1],type:Ae(i.network),funding:Se(i.type)};var s=n.paymentRequest,p=o.details.shippingOptions,l=parseFloat(s.details.total.amount.value);if(!0===s.options.requestShipping&&p&&p.length){var u=p.find((function(t){return t.id===e.shippingOption})).amount.value;a.total_amount=(l+parseFloat(u)).toString()}else a.total_amount=l.toString();e.complete("success")}else e.complete("fail");t(a)},s=function(n){t(n),e.complete("fail")};c=function(e,t){return e?void s(e):void i(t)},ie({event:"payment_request_apple_pay_get_prime",parameter:a})})).catch((function(e){var n=null;return l?(n=l.message,t({status:403,msg:n}),void(l=null)):void(e&&t({status:401,msg:"[Apple Pay] Unexcept Error",originalError:e}))}))},n}(0,void 0),e.TPDirect.validate={cardNumber:O,ccv:x,expiry:q,cardType:E,sdkError:function(){return!e.TPDirect.isDoubleLoaded&&n}},le("get_prime_done",(function(e){ye(o)&&o(e.result)})),le("iframe_get_prime_ready",(function(){g=!0,w.forEach((function(e){e()}))})),le("setup_payment_request_done",(function(e){a({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e.result.canMakePaymentWithActiveCard,canMakePaymentError:e.result.error})})),le("payment_request_not_support_in_iframe",(function(){e.TPDirect.paymentRequestApi.iosChromeSetupPaymentRequest(),e.TPDirect.paymentRequestApi.iosChromeCheckCanMakePaymentWithActiveCard()})),le("payment_request_get_prime_done",(function(e){i(e.result)})),le("payment_request_apple_pay_get_prime_done",(function(e){c(e.err,e.result)})),le("apple_pay_get_session_done",(function(e){d&&d(e.err,e.result)})))}(window)}]);