@paydock/client-sdk 1.110.2 → 1.110.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-dompurify")):"function"==typeof define&&define.amd?define(["exports","isomorphic-dompurify"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).paydock={})}(this,(function(e){"use strict";function t(e,t,i){return t=h(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,n()?Reflect.construct(t,i||[],h(e).constructor):t.apply(e,i))}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(n=function(){return!!e})()}function i(){i=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function d(e,t,n,i){var r=t&&t.prototype instanceof y?t:y,s=Object.create(r.prototype),a=new R(i||[]);return o(s,"_invoke",{value:O(e,n,a)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var p="suspendedStart",f="suspendedYield",m="executing",v="completed",g={};function y(){}function b(){}function E(){}var w={};u(w,a,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(x([])));S&&S!==n&&r.call(S,a)&&(w=S);var T=E.prototype=y.prototype=Object.create(w);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,s,a){var c=h(e[i],e,o);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==typeof u&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(u).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function O(t,n,i){var r=p;return function(o,s){if(r===m)throw Error("Generator is already running");if(r===v){if("throw"===o)throw s;return{value:e,done:!0}}for(i.method=o,i.arg=s;;){var a=i.delegate;if(a){var c=N(a,i);if(c){if(c===g)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var l=h(t,n,i);if("normal"===l.type){if(r=i.done?v:f,l.arg===g)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=v,i.method="throw",i.arg=l.arg)}}}function N(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,N(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;var o=h(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=E,o(T,"constructor",{value:E,configurable:!0}),o(E,"constructor",{value:b,configurable:!0}),b.displayName=u(E,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,u(e,l,"GeneratorFunction")),e.prototype=Object.create(T),e},t.awrap=function(e){return{__await:e}},_(C.prototype),u(C.prototype,c,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var s=new C(d(e,n,i,r),o);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(T),u(T,l,"Generator"),u(T,a,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},t.values=x,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(c&&l){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:x(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),g}},t}function r(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function o(e){return o="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},o(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},u.apply(this,arguments)}function d(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},f.apply(this,arguments)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw r}}return a}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function b(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var E=function(){return c((function e(){s(this,e)}),null,[{key:"isFacebook",value:function(){return-1!==navigator.userAgent.indexOf("FBSN/iOS")&&-1!==navigator.userAgent.indexOf("AppleWebKit")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isInstagram",value:function(){return-1!==navigator.userAgent.indexOf("iOS")&&-1!==navigator.userAgent.indexOf("Instagram")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isSupportPopUp",value:function(){return!this.isFacebook()&&!this.isInstagram()}},{key:"getLanguage",value:function(){return window.navigator.language||""}},{key:"getTimezoneOffset",value:function(){return(new Date).getTimezoneOffset()}},{key:"getBrowserName",value:function(){var e=navigator.userAgent;return e.indexOf("Firefox")>-1?"Mozilla Firefox":e.indexOf("Opera")>-1?"Opera":e.indexOf("Trident")>-1?"Microsoft Internet Explorer":e.indexOf("Edge")>-1?"Microsoft Edge":e.indexOf("Chrome")>-1?"Google Chrome or Chromium":e.indexOf("Safari")>-1?"Apple Safari":"unknown"}},{key:"isJavaEnabled",value:function(){return navigator.javaEnabled()}},{key:"getColorDepth",value:function(){return screen.colorDepth}},{key:"getScreenHeight",value:function(){return screen.height}},{key:"getScreenWidth",value:function(){return screen.width}},{key:"getBrowserInfo",value:function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?{name:"IE",version:(e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""}:"Chrome"===n[1]&&null!=(e=t.match(/\bOPR|Edge\/(\d+)/))?{name:"Opera",version:e[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&n.splice(1,1,e[1]),{name:n[0],version:n[1]})}}])}(),w="/v1/charges/3ds",k=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"preAuth",value:function(e,t){return"function"==typeof t?this.api.getClient("POST",w).send(u(u({},e),{_3ds:u(u({},e._3ds),{browser_details:{name:E.getBrowserName(),java_enabled:E.isJavaEnabled().toString(),language:E.getLanguage(),screen_height:E.getScreenHeight().toString(),screen_width:E.getScreenWidth().toString(),time_zone:E.getTimezoneOffset().toString(),color_depth:E.getColorDepth().toString()}})}),(function(e){t(e)})):this.api.getClientPromise("POST",w).send(u(u({},e),{_3ds:u(u({},e._3ds),{browser_details:{name:E.getBrowserName(),java_enabled:E.isJavaEnabled().toString(),language:E.getLanguage(),screen_height:E.getScreenHeight().toString(),screen_width:E.getScreenWidth().toString(),time_zone:E.getTimezoneOffset().toString(),color_depth:E.getColorDepth().toString()}})}))}}])}(),S="sandbox",T="sandbox-kovena",_="sandbox-demo-kovena",C="production",O="staging",N="staging_1",I="staging_2",A="staging_3",R="staging_4",x="staging_5",M="staging_6",P="staging_7",D="staging_8",L="staging_9",F="staging_10",U="staging_11",j="staging_12",B="staging_13",H="staging_14",z="staging_15",V=[{env:S,url:"https://widget-sandbox."},{env:T,url:"https://widget-sandbox."},{env:"sandbox-demo",url:"https://widget-sandbox-demo."},{env:_,url:"https://widget-sandbox-demo."},{env:C,url:"https://widget."},{env:O,url:"https://widsta."},{env:N,url:"https://widsta-1."},{env:I,url:"https://widsta-2."},{env:A,url:"https://widsta-3."},{env:R,url:"https://widsta-4."},{env:x,url:"https://widsta-5."},{env:M,url:"https://widsta-6."},{env:P,url:"https://widsta-7."},{env:D,url:"https://widsta-8."},{env:L,url:"https://widsta-9."},{env:F,url:"https://widsta-10."},{env:U,url:"https://widsta-11."},{env:j,url:"https://widsta-12."},{env:B,url:"https://widsta-13."},{env:H,url:"https://widsta-14."},{env:z,url:"https://widsta-15."}],W=[{env:S,url:"https://api-sandbox."},{env:C,url:"https://api."},{env:O,url:"https://apista."},{env:N,url:"https://apista-1."},{env:I,url:"https://apista-2."},{env:A,url:"https://apista-3."},{env:R,url:"https://apista-4."},{env:x,url:"https://apista-5."},{env:M,url:"https://apista-6."},{env:P,url:"https://apista-7."},{env:D,url:"https://apista-8."},{env:L,url:"https://apista-9."},{env:F,url:"https://apista-10."},{env:U,url:"https://apista-11."},{env:j,url:"https://apista-12."},{env:B,url:"https://apista-13."},{env:H,url:"https://apista-14."},{env:z,url:"https://apista-15."}],q=[T,_],G=S,K="paydock.com",Y="kovena.com",$=function(){return c((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G;s(this,e),this.configs=t,this.setEnv(n)}),[{key:"setEnv",value:function(e,t){if(!this.isValidMode(this.configs,e))throw new Error("unknown env: ".concat(e));if(this.env=e,t&&!t.match("^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-.]*(?!-)\\.(?![-.]))*[a-zA-Z0-9]+)?)$"))throw new Error("invalid: ".concat(t));t?this.alias=t:-1!==q.indexOf(this.env)?this.alias=Y:this.alias=K}},{key:"getEnv",value:function(){return this.env}},{key:"getConf",value:function(){for(var e in this.configs)if(this.configs.hasOwnProperty(e)&&this.configs[e].env===this.getEnv())return{url:-1!==this.configs[e].url.indexOf("localhost")?this.configs[e].url:this.configs[e].url+this.alias,env:this.configs[e].env};throw new Error("invalid env")}},{key:"isValidMode",value:function(e,t){for(var n in e)if(e.hasOwnProperty(n)&&e[n].env===t)return!0;return!1}}])}(),J=function(){function e(){s(this,e)}return c(e,null,[{key:"version",get:function(){return e._version.trim()||null}}])}();J.type="client",J.headerKeys=Object.freeze({version:"x-sdk-version",type:"x-sdk-type"}),J._version="v1.110.2";var X="x-access-token",Z="x-user-public-key",Q=function(){function e(){s(this,e)}return c(e,null,[{key:"validateJWT",value:function(e){if(!e)return null;var t=m(e.split("."),3),n=t[0],i=t[1],r=t[2];if(!n||!i||!r)return null;if(2+n.length+i.length+r.length!==e.length)return null;try{return{head:JSON.parse(atob(n)),body:JSON.parse(atob(i)),signature:r}}catch(e){return null}}},{key:"extractData",value:function(e){try{return JSON.parse(atob(e.meta))}catch(e){return null}}},{key:"extractMeta",value:function(e){try{return JSON.parse(atob(e.meta)).meta}catch(e){return null}}},{key:"getAccessHeaderNameByToken",value:function(t){return e.validateJWT(t)?X:Z}}])}(),ee=function(){function e(t){s(this,e),this.request=t}return c(e,[{key:"inner",value:function(){return this.request}},{key:"setHeader",value:function(e,t){return this.request.setRequestHeader(e,t),this}},{key:"setAccessToken",value:function(e){return this.setHeader("x-access-token",e)}},{key:"setPublicKey",value:function(e){return this.setHeader("x-user-public-key",e)}},{key:"setContentTypeJson",value:function(){return this.setHeader("Content-Type","application/json; charset=UTF-8")}},{key:"setSdkVersion",value:function(){return J.version&&(this.setHeader(J.headerKeys.version,J.version),this.setHeader(J.headerKeys.type,J.type)),this}}],[{key:"create",value:function(t,n){var i=new XMLHttpRequest;return i.open(t,n,!0),new e(i)}}])}();function te(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function ne(){return Math.floor(performance.now())}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-dompurify")):"function"==typeof define&&define.amd?define(["exports","isomorphic-dompurify"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).paydock={})}(this,(function(e){"use strict";function t(e,t,i){return t=h(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,n()?Reflect.construct(t,i||[],h(e).constructor):t.apply(e,i))}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(n=function(){return!!e})()}function i(){i=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function d(e,t,n,i){var r=t&&t.prototype instanceof y?t:y,s=Object.create(r.prototype),a=new R(i||[]);return o(s,"_invoke",{value:O(e,n,a)}),s}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var p="suspendedStart",f="suspendedYield",m="executing",v="completed",g={};function y(){}function b(){}function E(){}var w={};u(w,a,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(x([])));S&&S!==n&&r.call(S,a)&&(w=S);var T=E.prototype=y.prototype=Object.create(w);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,s,a){var c=h(e[i],e,o);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==typeof u&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(u).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function O(t,n,i){var r=p;return function(o,s){if(r===m)throw Error("Generator is already running");if(r===v){if("throw"===o)throw s;return{value:e,done:!0}}for(i.method=o,i.arg=s;;){var a=i.delegate;if(a){var c=N(a,i);if(c){if(c===g)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var l=h(t,n,i);if("normal"===l.type){if(r=i.done?v:f,l.arg===g)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=v,i.method="throw",i.arg=l.arg)}}}function N(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,N(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;var o=h(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=E,o(T,"constructor",{value:E,configurable:!0}),o(E,"constructor",{value:b,configurable:!0}),b.displayName=u(E,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,u(e,l,"GeneratorFunction")),e.prototype=Object.create(T),e},t.awrap=function(e){return{__await:e}},_(C.prototype),u(C.prototype,c,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var s=new C(d(e,n,i,r),o);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},_(T),u(T,l,"Generator"),u(T,a,(function(){return this})),u(T,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},t.values=x,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),l=r.call(s,"finallyLoc");if(c&&l){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:x(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),g}},t}function r(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function o(e){return o="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},o(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},u.apply(this,arguments)}function d(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function f(){return f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},f.apply(this,arguments)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw r}}return a}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function b(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var E=function(){return c((function e(){s(this,e)}),null,[{key:"isFacebook",value:function(){return-1!==navigator.userAgent.indexOf("FBSN/iOS")&&-1!==navigator.userAgent.indexOf("AppleWebKit")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isInstagram",value:function(){return-1!==navigator.userAgent.indexOf("iOS")&&-1!==navigator.userAgent.indexOf("Instagram")&&-1!==navigator.userAgent.indexOf("(KHTML, like Gecko)")}},{key:"isSupportPopUp",value:function(){return!this.isFacebook()&&!this.isInstagram()}},{key:"getLanguage",value:function(){return window.navigator.language||""}},{key:"getTimezoneOffset",value:function(){return(new Date).getTimezoneOffset()}},{key:"getBrowserName",value:function(){var e=navigator.userAgent;return e.indexOf("Firefox")>-1?"Mozilla Firefox":e.indexOf("Opera")>-1?"Opera":e.indexOf("Trident")>-1?"Microsoft Internet Explorer":e.indexOf("Edge")>-1?"Microsoft Edge":e.indexOf("Chrome")>-1?"Google Chrome or Chromium":e.indexOf("Safari")>-1?"Apple Safari":"unknown"}},{key:"isJavaEnabled",value:function(){return navigator.javaEnabled()}},{key:"getColorDepth",value:function(){return screen.colorDepth}},{key:"getScreenHeight",value:function(){return screen.height}},{key:"getScreenWidth",value:function(){return screen.width}},{key:"getBrowserInfo",value:function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?{name:"IE",version:(e=/\brv[ :]+(\d+)/g.exec(t)||[])[1]||""}:"Chrome"===n[1]&&null!=(e=t.match(/\bOPR|Edge\/(\d+)/))?{name:"Opera",version:e[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&n.splice(1,1,e[1]),{name:n[0],version:n[1]})}}])}(),w="/v1/charges/3ds",k=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"preAuth",value:function(e,t){return"function"==typeof t?this.api.getClient("POST",w).send(u(u({},e),{_3ds:u(u({},e._3ds),{browser_details:{name:E.getBrowserName(),java_enabled:E.isJavaEnabled().toString(),language:E.getLanguage(),screen_height:E.getScreenHeight().toString(),screen_width:E.getScreenWidth().toString(),time_zone:E.getTimezoneOffset().toString(),color_depth:E.getColorDepth().toString()}})}),(function(e){t(e)})):this.api.getClientPromise("POST",w).send(u(u({},e),{_3ds:u(u({},e._3ds),{browser_details:{name:E.getBrowserName(),java_enabled:E.isJavaEnabled().toString(),language:E.getLanguage(),screen_height:E.getScreenHeight().toString(),screen_width:E.getScreenWidth().toString(),time_zone:E.getTimezoneOffset().toString(),color_depth:E.getColorDepth().toString()}})}))}}])}(),S="sandbox",T="sandbox-kovena",_="sandbox-demo-kovena",C="production",O="staging",N="staging_1",I="staging_2",A="staging_3",R="staging_4",x="staging_5",M="staging_6",P="staging_7",D="staging_8",L="staging_9",F="staging_10",U="staging_11",j="staging_12",B="staging_13",H="staging_14",z="staging_15",V=[{env:S,url:"https://widget-sandbox."},{env:T,url:"https://widget-sandbox."},{env:"sandbox-demo",url:"https://widget-sandbox-demo."},{env:_,url:"https://widget-sandbox-demo."},{env:C,url:"https://widget."},{env:O,url:"https://widsta."},{env:N,url:"https://widsta-1."},{env:I,url:"https://widsta-2."},{env:A,url:"https://widsta-3."},{env:R,url:"https://widsta-4."},{env:x,url:"https://widsta-5."},{env:M,url:"https://widsta-6."},{env:P,url:"https://widsta-7."},{env:D,url:"https://widsta-8."},{env:L,url:"https://widsta-9."},{env:F,url:"https://widsta-10."},{env:U,url:"https://widsta-11."},{env:j,url:"https://widsta-12."},{env:B,url:"https://widsta-13."},{env:H,url:"https://widsta-14."},{env:z,url:"https://widsta-15."}],W=[{env:S,url:"https://api-sandbox."},{env:C,url:"https://api."},{env:O,url:"https://apista."},{env:N,url:"https://apista-1."},{env:I,url:"https://apista-2."},{env:A,url:"https://apista-3."},{env:R,url:"https://apista-4."},{env:x,url:"https://apista-5."},{env:M,url:"https://apista-6."},{env:P,url:"https://apista-7."},{env:D,url:"https://apista-8."},{env:L,url:"https://apista-9."},{env:F,url:"https://apista-10."},{env:U,url:"https://apista-11."},{env:j,url:"https://apista-12."},{env:B,url:"https://apista-13."},{env:H,url:"https://apista-14."},{env:z,url:"https://apista-15."}],q=[T,_],G=S,K="paydock.com",Y="kovena.com",$=function(){return c((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G;s(this,e),this.configs=t,this.setEnv(n)}),[{key:"setEnv",value:function(e,t){if(!this.isValidMode(this.configs,e))throw new Error("unknown env: ".concat(e));if(this.env=e,t&&!t.match("^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-.]*(?!-)\\.(?![-.]))*[a-zA-Z0-9]+)?)$"))throw new Error("invalid: ".concat(t));t?this.alias=t:-1!==q.indexOf(this.env)?this.alias=Y:this.alias=K}},{key:"getEnv",value:function(){return this.env}},{key:"getConf",value:function(){for(var e in this.configs)if(this.configs.hasOwnProperty(e)&&this.configs[e].env===this.getEnv())return{url:-1!==this.configs[e].url.indexOf("localhost")?this.configs[e].url:this.configs[e].url+this.alias,env:this.configs[e].env};throw new Error("invalid env")}},{key:"isValidMode",value:function(e,t){for(var n in e)if(e.hasOwnProperty(n)&&e[n].env===t)return!0;return!1}}])}(),J=function(){function e(){s(this,e)}return c(e,null,[{key:"version",get:function(){return e._version.trim()||null}}])}();J.type="client",J.headerKeys=Object.freeze({version:"x-sdk-version",type:"x-sdk-type"}),J._version="v1.110.3";var X="x-access-token",Z="x-user-public-key",Q=function(){function e(){s(this,e)}return c(e,null,[{key:"validateJWT",value:function(e){if(!e)return null;var t=m(e.split("."),3),n=t[0],i=t[1],r=t[2];if(!n||!i||!r)return null;if(2+n.length+i.length+r.length!==e.length)return null;try{return{head:JSON.parse(atob(n)),body:JSON.parse(atob(i)),signature:r}}catch(e){return null}}},{key:"extractData",value:function(e){try{return JSON.parse(atob(e.meta))}catch(e){return null}}},{key:"extractMeta",value:function(e){try{return JSON.parse(atob(e.meta)).meta}catch(e){return null}}},{key:"getAccessHeaderNameByToken",value:function(t){return e.validateJWT(t)?X:Z}}])}(),ee=function(){function e(t){s(this,e),this.request=t}return c(e,[{key:"inner",value:function(){return this.request}},{key:"setHeader",value:function(e,t){return this.request.setRequestHeader(e,t),this}},{key:"setAccessToken",value:function(e){return this.setHeader("x-access-token",e)}},{key:"setPublicKey",value:function(e){return this.setHeader("x-user-public-key",e)}},{key:"setContentTypeJson",value:function(){return this.setHeader("Content-Type","application/json; charset=UTF-8")}},{key:"setSdkVersion",value:function(){return J.version&&(this.setHeader(J.headerKeys.version,J.version),this.setHeader(J.headerKeys.type,J.type)),this}}],[{key:"create",value:function(t,n){var i=new XMLHttpRequest;return i.open(t,n,!0),new e(i)}}])}();function te(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function ne(){return Math.floor(performance.now())}
|
|
2
2
|
/**
|
|
3
3
|
* @file Contains constants about the environment the agent is running
|
|
4
4
|
* within. These values are derived at the time the agent is first loaded.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* when loaded.
|
|
11
11
|
* @copyright 2023 New Relic Corporation. All rights reserved.
|
|
12
12
|
* @license Apache-2.0
|
|
13
|
-
*/const rt=nt(),ot="nr@context:".concat(rt),st=function e(t,n){var i={},r={},o={},s=!1;try{s=16===n.length&&Ze(n).isolatedBacklog}catch(e){}var a={on:l,addEventListener:l,removeEventListener:function(e,t){var n=i[e];if(!n)return;for(var r=0;r<n.length;r++)n[r]===t&&n.splice(r,1)},emit:function(e,n,i,o,s){!1!==s&&(s=!0);if(st.aborted&&!o)return;t&&s&&t.emit(e,n,i);for(var l=c(i),d=u(e),p=d.length,f=0;f<p;f++)d[f].apply(l,n);var m=h()[r[e]];m&&m.push([a,e,n,l]);return l},get:d,listeners:u,context:c,buffer:function(e,t){const n=h();if(t=t||"feature",a.aborted)return;Object.entries(e||{}).forEach((e=>{let[i,o]=e;r[o]=t,t in n||(n[t]=[])}))},abort:function(){a._aborted=!0,Object.keys(a.backlog).forEach((e=>{delete a.backlog[e]}))},isBuffering:function(e){return!!h()[r[e]]},debugId:n,backlog:s?{}:t&&"object"==typeof t.backlog?t.backlog:{},isolatedBacklog:s};return Object.defineProperty(a,"aborted",{get:()=>{let e=a._aborted||!1;return e||(t&&(e=t.aborted),e)}}),a;function c(e){return e&&e instanceof et?e:e?Ee(e,ot,(()=>new et(ot))):new et(ot)}function l(e,t){i[e]=u(e).concat(t)}function u(e){return i[e]||[]}function d(t){return o[t]=o[t]||e(a,t)}function h(){return a.backlog}}(void 0,"globalEE"),at=me();at.ee||(at.ee=st);var ct=st.get("handle");function lt(e,t,n,i,r){r?(r.buffer([e],i),r.emit(e,t,n)):(ct.buffer([e],i),ct.emit(e,t,n))}const ut=(e,t)=>Object.entries(e||{}).map((e=>{let[n,i]=e;return t(n,i)}));ht.on=pt;var dt=ht.handlers={};function ht(e,t,n,i){pt(i||ct,dt,e,t,n)}function pt(e,t,n,i,r){r||(r="feature"),e||(e=ct);var o=t[r]=t[r]||{};(o[n]=o[n]||[]).push([e,i])}const ft={ajax:"ajax",jserrors:"jserrors",metrics:"metrics",pageAction:"page_action",pageViewEvent:"page_view_event",pageViewTiming:"page_view_timing",sessionReplay:"session_replay",sessionTrace:"session_trace",softNav:"soft_navigations",spa:"spa"},mt={[ft.pageViewEvent]:1,[ft.pageViewTiming]:2,[ft.metrics]:3,[ft.jserrors]:4,[ft.ajax]:5,[ft.sessionTrace]:6,[ft.pageAction]:7,[ft.spa]:8,[ft.softNav]:9,[ft.sessionReplay]:10},vt={};function gt(e,t){const n={staged:!1,priority:mt[t]||0};bt(e),vt[e].get(t)||vt[e].set(t,n)}function yt(e,t){bt(e),vt[e].get(t)&&vt[e].delete(t),vt[e].size&&wt(e)}function bt(e){if(!e)throw new Error("agentIdentifier required");vt[e]||(vt[e]=new Map)}function Et(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"feature",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(bt(e),!e||!vt[e].get(t)||n)return kt(e,t);vt[e].get(t).staged=!0,wt(e)}function wt(e){const t=Array.from(vt[e]);t.every((e=>{let[t,n]=e;return n.staged}))&&(t.sort(((e,t)=>e[1].priority-t[1].priority)),t.forEach((t=>{let[n]=t;vt[e].delete(n),kt(e,n)})))}function kt(e,t){const n=e?st.get(e):st,i=ht.handlers;if(n.backlog&&i){var r=n.backlog[t],o=i[t];if(o){for(var s=0;r&&s<r.length;++s)St(r[s],o);ut(o,(function(e,t){ut(t,(function(t,n){n[0].on(e,n[1])}))}))}n.isolatedBacklog||delete i[t],n.backlog[t]=null,n.emit("drain-"+t,[])}}function St(e,t){var n=e[1];ut(t[n],(function(t,n){var i=e[0];if(n[0]===i){var r=n[1],o=e[3],s=e[2];r.apply(o,s)}}))}class Tt{constructor(e,t,n){this.agentIdentifier=e,this.aggregator=t,this.ee=st.get(e),this.featureName=n,this.blocked=!1}}let _t=!1,Ct=!1;try{const e={get passive(){return _t=!0,!1},get signal(){return Ct=!0,!1}};oe.addEventListener("test",null,e),oe.removeEventListener("test",null,e)}catch(e){}function Ot(e,t){return _t||Ct?{capture:!!e,passive:_t,signal:t}:!!e}function Nt(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;window.addEventListener(e,t,Ot(n,i))}function It(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;document.addEventListener(e,t,Ot(n,i))}function At(){return"undefined"==typeof document||"complete"===document.readyState}function Rt(e,t){if(At())return e();Nt("load",e,t)}const xt=e=>ie&&!0===Ve(e,"privacy.cookies_enabled");function Mt(e,t){return!!function(e){return!!Ke.MO&&xt(e)&&!0===Ve(e,"session_trace.enabled")}(e)&&(!!t?.isNew||!!t?.state.sessionReplayMode)}function Pt(e,t){const n=t.correctAbsoluteTimestamp(e);return{originalTimestamp:e,correctedTimestamp:n,timestampDiff:e-n,originTime:pe,correctedOriginTime:t.correctedOriginTime,originTimeDiff:Math.floor(pe-t.correctedOriginTime)}}function Dt(e){var t=this;let n=!1;return function(){if(!n){n=!0;for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];e.apply(t,r)}}}class Lt extends Tt{constructor(e,t,n){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];super(e,t,n),this.auto=i,this.abortHandler=void 0,this.featAggregate=void 0,this.onAggregateImported=void 0,!1===Ve(this.agentIdentifier,"".concat(this.featureName,".autoStart"))&&(this.auto=!1),this.auto?gt(e,n):this.ee.on("manual-start-all",Dt((()=>{gt(this.agentIdentifier,this.featureName),this.auto=!0,this.importAggregator()})))}importAggregator(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.featAggregate||!this.auto)return;this.onAggregateImported=new Promise((t=>{e=t}));const n=async()=>{let n;try{if(xt(this.agentIdentifier)){const{setupAgentSession:e}=await Promise.resolve().then((function(){return Jo}));n=e(this.agentIdentifier)}}catch(e){we("A problem occurred when starting up session manager. This page will not start or extend any session.",e),this.featureName===ft.sessionReplay&&this.abortHandler?.()}try{if(!this.#e(this.featureName,n))return Et(this.agentIdentifier,this.featureName),void e(!1);const{lazyFeatureLoader:i}=await Promise.resolve().then((function(){return Xo})),{Aggregate:r}=await i(this.featureName,"aggregate");this.featAggregate=new r(this.agentIdentifier,this.aggregator,t),e(!0)}catch(t){we("Downloading and initializing ".concat(this.featureName," failed..."),t),this.abortHandler?.(),Et(this.agentIdentifier,this.featureName,!0),e(!1),this.ee&&this.ee.abort()}};ie?Rt((()=>n()),!0):n()}#e(e,t){return e!==ft.sessionReplay||Mt(this.agentIdentifier,t)}}const Ft=ft.jserrors,Ut=ft.sessionReplay,jt={RECORD:"recordReplay",PAUSE:"pauseReplay",REPLAY_RUNNING:"replayRunning",ERROR_DURING_REPLAY:"errorDuringReplay"},Bt=2,Ht=4,zt={[Fe.ERROR]:15e3,[Fe.FULL]:3e5,[Fe.OFF]:0},Vt={message:"Session was reset",sm:"Reset"},Wt={message:"Recorder failed to import",sm:"Import"},qt={message:"429: Too Many Requests",sm:"Too-Many"},Gt={message:"Payload was too large",sm:"Too-Big"},Kt={message:"Session Entity was set to OFF on another tab",sm:"Cross-Tab"},Yt={message:"Session Replay is not allowed and will not be started",sm:"Entitlement"},$t="api",Jt=()=>{const e=new WeakSet;return(t,n)=>{if("object"==typeof n&&null!==n){if(e.has(n))return;e.add(n)}return n}};function Xt(e){try{return JSON.stringify(e,Jt())}catch(e){try{st.emit("internal-error",[e])}catch(e){}}}class Zt{constructor(e,t,n,i,r){this.name="UncaughtError",this.message="string"==typeof e?e:Xt(e),this.sourceURL=t,this.line=n,this.column=i,this.__newrelic=r}}function Qt(e){return nn(e)?e:new Zt(void 0!==e?.message?e.message:e,e?.filename||e?.sourceURL,e?.lineno||e?.line,e?.colno||e?.col,e?.__newrelic)}function en(e){let t="Unhandled Promise Rejection";if(nn(e?.reason))try{return e.reason.message=t+": "+e.reason.message,Qt(e.reason)}catch(t){return Qt(e.reason)}if(void 0===e.reason)return Qt(t);const n=Qt(e.reason);return n.message=t+": "+n?.message,n}function tn(e){if(e.error instanceof SyntaxError&&!/:\d+$/.test(e.error.stack?.trim())){const t=new Zt(e.message,e.filename,e.lineno,e.colno,e.error.__newrelic);return t.name=SyntaxError.name,t}return nn(e.error)?e.error:Qt(e)}function nn(e){return e instanceof Error&&!!e.stack}let rn=class extends Lt{static featureName=Ft;#t=!1;constructor(e,t){super(e,t,Ft,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);try{this.removeOnAbort=new AbortController}catch(e){}this.ee.on("internal-error",(e=>{this.abortHandler&<("ierr",[Qt(e),ne(),!0,{},this.#t],void 0,this.featureName,this.ee)})),this.ee.on(jt.REPLAY_RUNNING,(e=>{this.#t=e})),oe.addEventListener("unhandledrejection",(e=>{this.abortHandler&<("err",[en(e),ne(),!1,{unhandledPromiseRejection:1},this.#t],void 0,this.featureName,this.ee)}),Ot(!1,this.removeOnAbort?.signal)),oe.addEventListener("error",(e=>{this.abortHandler&<("err",[tn(e),ne(),!1,{},this.#t],void 0,this.featureName,this.ee)}),Ot(!1,this.removeOnAbort?.signal)),this.abortHandler=this.#n,this.importAggregator()}#n(){this.removeOnAbort?.abort(),this.abortHandler=void 0}};const on=ft.pageViewEvent;let sn=class extends Lt{static featureName=on;constructor(e,t){super(e,t,on,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]),this.importAggregator()}};const an=Object.values(ft);function cn(e){const t={};return an.forEach((n=>{t[n]=function(e,t){return!0===Ve(t,"".concat(e,".enabled"))}(n,e)})),t}const ln=ft.metrics,un="storeSupportabilityMetrics",dn="storeEventMetrics",hn=["setErrorHandler","finished","addToTrace","addRelease","addPageAction","setCurrentRouteName","setPageViewName","setCustomAttribute","interaction","noticeError","setUserId","setApplicationVersion","start",jt.RECORD,jt.PAUSE],pn=["setErrorHandler","finished","addToTrace","addRelease"];function fn(){const e=ye();hn.forEach((t=>{e[t]=function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];let o=[];return Object.values(e.initializedAgents).forEach((e=>{e.exposed&&e.api[t]&&o.push(e.api[t](...i))})),o.length>1?o:o[0]}(t,...i)}}))}const mn={};const vn="newrelic";const gn=new Set,yn={};function bn(e,t){const n=st.get(t);yn[t]??={},e&&"object"==typeof e&&(gn.has(t)||(n.emit("rumresp",[e]),yn[t]=e,gn.add(t),function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{oe.dispatchEvent(new CustomEvent(vn,{detail:e}))}catch(e){}}({loaded:!0})))}let En=!1;function wn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,{init:r,info:o,loader_config:s,runtime:a={loaderType:n},exposed:c=!0}=t;const l=ye();o||(r=l.init,o=l.info,s=l.loader_config),function(e,t){if(!e)throw new Error(He);Be[e]=ke(t,je());const n=ge(e);n&&(n.init=Be[e])}(e.agentIdentifier,r||{}),function(e,t){if(!e)throw new Error("All loader-config objects require an agent identifier!");qe[e]=ke(t,We);const n=ge(e);n&&(n.loader_config=qe[e])}(e.agentIdentifier,s||{}),o.jsAttributes??={},re&&(o.jsAttributes.isWorker=!0),Ce(e.agentIdentifier,o);const u=ze(e.agentIdentifier),d=[o.beacon,o.errorBeacon];var h,p;En||(u.proxy.assets&&(u.proxy.assets,d.push(u.proxy.assets)),u.proxy.beacon&&d.push(u.proxy.beacon),fn(),h="activatedFeatures",p=yn,me()[h]=p,e.runSoftNavOverSpa&&=!0===u.soft_navigations.enabled&&u.feature_flags.includes("soft_nav")),a.denyList=[...u.ajax.deny_list||[],...u.ajax.block_internal?d:[]],a.ptid=e.agentIdentifier,function(e,t){if(!e)throw new Error("All runtime objects require an agent identifier!");Xe[e]={...ke(t,Je),...$e};const n=ge(e);n&&(n.runtime=Xe[e])}(e.agentIdentifier,a),void 0===e.api&&(e.api=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||gt(e,"api");const i={};var r=st.get(e),o=r.get("tracer");mn[e]=Fe.OFF,r.on(jt.REPLAY_RUNNING,(t=>{mn[e]=t}));var s="api-",a=s+"ixn-";function c(t,n,i,r){const o=_e(e);return null===n?delete o.jsAttributes[t]:Ce(e,{...o,jsAttributes:{...o.jsAttributes,[t]:n}}),d(s,i,!0,r||null===n?"session":void 0)(t,n)}function l(){}pn.forEach((e=>{i[e]=d(s,e,!0,"api")})),i.addPageAction=d(s,"addPageAction",!0,ft.pageAction),i.setPageViewName=function(t,n){if("string"==typeof t)return"/"!==t.charAt(0)&&(t="/"+t),Ze(e).customTransaction=(n||"http://custom.transaction")+t,d(s,"setPageViewName",!0)()},i.setCustomAttribute=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof e){if(["string","number","boolean"].includes(typeof t)||null===t)return c(e,t,"setCustomAttribute",n);we("Failed to execute setCustomAttribute.\nNon-null value must be a string, number or boolean type, but a type of <".concat(typeof t,"> was provided."))}else we("Failed to execute setCustomAttribute.\nName must be a string type, but a type of <".concat(typeof e,"> was provided."))},i.setUserId=function(e){if("string"==typeof e||null===e)return c("enduser.id",e,"setUserId",!0);we("Failed to execute setUserId.\nNon-null value must be a string type, but a type of <".concat(typeof e,"> was provided."))},i.setApplicationVersion=function(e){if("string"==typeof e||null===e)return c("application.version",e,"setApplicationVersion",!1);we("Failed to execute setApplicationVersion. Expected <String | null>, but got <".concat(typeof e,">."))},i.start=()=>{try{lt(un,["API/start/called"],void 0,ft.metrics,r),r.emit("manual-start-all")}catch(e){we("An unexpected issue occurred",e)}},i[jt.RECORD]=function(){lt(un,["API/recordReplay/called"],void 0,ft.metrics,r),lt(jt.RECORD,[],void 0,ft.sessionReplay,r)},i[jt.PAUSE]=function(){lt(un,["API/pauseReplay/called"],void 0,ft.metrics,r),lt(jt.PAUSE,[],void 0,ft.sessionReplay,r)},i.interaction=function(e){return(new l).get("object"==typeof e?e:{})};const u=l.prototype={createTracer:function(e,t){var i={},s=this,c="function"==typeof t;return lt(un,["API/createTracer/called"],void 0,ft.metrics,r),n||lt(a+"tracer",[ne(),e,i],s,ft.spa,r),function(){if(o.emit((c?"":"no-")+"fn-start",[ne(),s,c],i),c)try{return t.apply(this,arguments)}catch(e){const t="string"==typeof e?new Error(e):e;throw o.emit("fn-err",[arguments,this,t],i),t}finally{o.emit("fn-end",[ne()],i)}}}};function d(e,t,n,i){return function(){return lt(un,["API/"+t+"/called"],void 0,ft.metrics,r),i&<(e+t,[ne(),...arguments],n?null:this,i,r),n?void 0:this}}function h(){Promise.resolve().then((function(){return Zo})).then((t=>{let{setAPI:n}=t;n(e),Et(e,"api")})).catch((e=>{we("Downloading runtime APIs failed...",e),r.abort()}))}return["actionText","setName","setAttribute","save","ignore","onEnd","getContext","end","get"].forEach((e=>{u[e]=d(a,e,void 0,n?ft.softNav:ft.spa)})),i.setCurrentRouteName=n?d(a,"routeName",void 0,ft.softNav):d(s,"routeName",!0,ft.spa),i.noticeError=function(t,n){"string"==typeof t&&(t=new Error(t)),lt(un,["API/noticeError/called"],void 0,ft.metrics,r),lt("err",[t,ne(),!1,n,!!mn[e]],void 0,ft.jserrors,r)},ie?Rt((()=>h()),!0):h(),i}(e.agentIdentifier,i,e.runSoftNavOverSpa)),void 0===e.exposed&&(e.exposed=c),En=!0}const kn={agentIdentifier:"",ee:void 0};class Sn{constructor(e){try{if("object"!=typeof e)return we("shared context requires an object as input");this.sharedContext={},Object.assign(this.sharedContext,kn),Object.entries(e).forEach((e=>{let[t,n]=e;Object.keys(kn).includes(t)&&(this.sharedContext[t]=n)}))}catch(e){we("An error occurred while setting SharedContext",e)}}}class Tn extends Sn{constructor(e){super(e),this.aggregatedData={}}store(e,t,n,i,r){var o=this.getBucket(e,t,n,r);return o.metrics=function(e,t){t||(t={count:0});return t.count+=1,ut(e,(function(e,n){t[e]=_n(n,t[e])})),t}(i,o.metrics),o}merge(e,t,n,i,r){var o=this.getBucket(e,t,i,r);if(o.metrics){var s=o.metrics;s.count+=n.count,ut(n,(function(e,t){if("count"!==e){var i=s[e],r=n[e];r&&!r.c?s[e]=_n(r.t,i):s[e]=function(e,t){if(!t)return e;t.c||(t=Cn(t.t));return t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max),t.t+=e.t,t.sos+=e.sos,t.c+=e.c,t}(r,s[e])}}))}else o.metrics=n}storeMetric(e,t,n,i){var r=this.getBucket(e,t,n);return r.stats=_n(i,r.stats),r}getBucket(e,t,n,i){this.aggregatedData[e]||(this.aggregatedData[e]={});var r=this.aggregatedData[e][t];return r||(r=this.aggregatedData[e][t]={params:n||{}},i&&(r.custom=i)),r}get(e,t){return t?this.aggregatedData[e]&&this.aggregatedData[e][t]:this.aggregatedData[e]}take(e){for(var t={},n="",i=!1,r=0;r<e.length;r++)t[n=e[r]]=Object.values(this.aggregatedData[n]||{}),t[n].length&&(i=!0),delete this.aggregatedData[n];return i?t:null}}function _n(e,t){return null==e?function(e){e?e.c++:e={c:1};return e}(t):t?(t.c||(t=Cn(t.t)),t.c+=1,t.t+=e,t.sos+=e*e,e>t.max&&(t.max=e),e<t.min&&(t.min=e),t):{t:e}}function Cn(e){return{t:e,min:e,max:e,sos:e*e,c:1}}class On{agentIdentifier;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:it(16);this.agentIdentifier=e,this.ee=st.get(e)}#i(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if("function"==typeof this.api?.[e])return this.api[e](...n);we("Call to agent api ".concat(e," failed. The API is not currently initialized."))}addPageAction(e,t){return this.#i("addPageAction",e,t)}setPageViewName(e,t){return this.#i("setPageViewName",e,t)}setCustomAttribute(e,t,n){return this.#i("setCustomAttribute",e,t,n)}noticeError(e,t){return this.#i("noticeError",e,t)}setUserId(e){return this.#i("setUserId",e)}setApplicationVersion(e){return this.#i("setApplicationVersion",e)}setErrorHandler(e){return this.#i("setErrorHandler",e)}finished(e){return this.#i("finished",e)}addRelease(e,t){return this.#i("addRelease",e,t)}start(e){return this.#i("start",e)}recordReplay(){return this.#i(jt.RECORD)}pauseReplay(){return this.#i(jt.PAUSE)}addToTrace(e){return this.#i("addToTrace",e)}setCurrentRouteName(e){return this.#i("setCurrentRouteName",e)}interaction(){return this.#i("interaction")}}const Nn=[ft.jserrors,ft.pageAction,ft.metrics];class In extends On{constructor(e,t){super(t),this.sharedAggregator=new Tn({agentIdentifier:this.agentIdentifier}),this.features={},function(e,t){let n=me();n.initializedAgents??={},t.initializedAt={ms:ne(),date:new Date},n.initializedAgents[e]=t}(this.agentIdentifier,this),wn(this,{...e,runtime:{isolatedBacklog:!0}},e.loaderType||"micro-agent"),Object.assign(this,this.api),this.start=e=>this.run(e),this.run(Nn.filter((e=>Ve(this.agentIdentifier,"".concat(e,".autoStart")))))}get config(){return{info:_e(this.agentIdentifier),init:ze(this.agentIdentifier),loader_config:Ge(this.agentIdentifier),runtime:Ze(this.agentIdentifier)}}run(e){try{const t=Nn;if(void 0===e)e=t;else{if((e=Array.isArray(e)&&e.length?e:[e]).some((e=>!t.includes(e))))return we("Invalid feature name supplied. Acceptable feature names are: ".concat(t));e.includes(ft.pageViewEvent)||e.push(ft.pageViewEvent)}}catch(e){we("An unexpected issue occurred",e)}try{const t=cn(this.agentIdentifier);try{this.features.page_view_event=new sn(this.agentIdentifier,this.sharedAggregator)}catch(e){we("Something prevented the agent from instrumenting.",e)}return Rt((()=>{Nn.forEach((n=>{t[n]&&e.includes(n)&&Promise.resolve().then((function(){return Xo})).then((e=>{let{lazyFeatureLoader:t}=e;return t(n,"aggregate")})).then((e=>{let{Aggregate:t}=e;this.features[n]=new t(this.agentIdentifier,this.sharedAggregator)})).catch((e=>we("Something prevented the agent from being downloaded.",e)))}))})),!0}catch(e){return we("Failed to initialize instrument classes.",e),!1}}}const An=ft.pageAction;class Rn extends Lt{static featureName=An;constructor(e,t){super(e,t,An,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]),this.importAggregator()}}function xn(){var e,t,n=(e="bam.nr-data.net",t={enabled:"true",accountId:"974691",agentId:"1386157152",applicationId:"1386157152",licenseKey:"4848a32285",trustKey:"974691"},{browserAgent:{available:Object.values(t).every(Boolean),options:{info:{applicationID:t.applicationId,licenseKey:t.licenseKey,beacon:e,errorBeacon:e,sa:1},init:{distributed_tracing:{autoStart:!1,enabled:!1},jserrors:{autoStart:!0,enabled:!0},metrics:{autoStart:!1,enabled:!1},page_action:{autoStart:!0,enabled:!0},page_view_event:{autoStart:!0,enabled:!0},page_view_timing:{autoStart:!1,enabled:!1},session_replay:{autoStart:!1,enabled:!1},session_trace:{autoStart:!1,enabled:!1},spa:{autoStart:!1,enabled:!1},ajax:u(u({},{autoStart:!1,enabled:!1}),{deny_list:[e,"undefined"==typeof window?void 0:window.location.host].filter(Boolean)}),privacy:{cookies_enabled:!1}},loaderConfig:{accountID:t.accountId,agentID:t.agentId,applicationID:t.applicationId,licenseKey:t.licenseKey,trustKey:t.trustKey}}}}).browserAgent;return{available:n.available,options:n.options}}var Mn=function(e){function n(e){var i;return s(this,n),(i=t(this,n,[e])).call=function(e){if(i.isAvailable()){for(var t,r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];(t=n.agent)[e].apply(t,o)}},i}return d(n,e),c(n,[{key:"isAvailable",value:function(){return n.available}}],[{key:"instance",get:function(){if(!n.initialized){var e=xn(),t=e.available,i=e.options;n.available=t,t&&(n.agent=new n(i),n.agent.start([rn.featureName,Rn.featureName,sn.featureName])),n.initialized=!0}return n.agent}}])}(In),Pn=function(){return c((function e(){s(this,e),this.agent=Mn.instance}),[{key:"createAction",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(this,void 0,void 0,i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.agent).addPageAction.apply(n,t);case 1:case"end":return e.stop()}}),e,this)})))}}])}();new Pn;var Dn,Ln=function(){return c((function e(){s(this,e),this.agent=Mn.instance}),[{key:"createError",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(this,void 0,void 0,i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.agent).noticeError.apply(n,t);case 1:case"end":return e.stop()}}),e,this)})))}}])}(),Fn=new Ln,Un=function(){return c((function e(){s(this,e),this.agent=Mn.instance}),[{key:"createEvent",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(this,void 0,void 0,i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.agent).addPageAction.apply(n,t);case 1:case"end":return e.stop()}}),e,this)})))}}])}();new Un,function(e){e[e.PUBLIC_KEY=0]="PUBLIC_KEY",e[e.TOKEN=1]="TOKEN"}(Dn||(Dn={}));var jn,Bn,Hn,zn=function(){function e(t,n){s(this,e),this.reportEvent=function(e,t){e.createEvent(t)},this.reportError=function(e,t,n){e.createError(t,n)},this.auth=t,this.authType=n||this.setAuthType(),this.env=new $(W)}return c(e,[{key:"setEnv",value:function(e,t){return this.env.setEnv(e,t),this}},{key:"setAuthType",value:function(){return this.authType=Q.validateJWT(this.auth)?Dn.TOKEN:Dn.PUBLIC_KEY,this.authType}},{key:"getClient",value:function(e,t){var n=this,i=this.newApiRequest(e,t);return{config:i,send:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};i.onload=function(){return n.parser({text:i.responseText,status:i.status},t,(function(e){n.reportError(Fn,e,u(u({},n.ctx),{classMethod:"getClient",description:"Send unsuccessful."})),r(e)}))},i.send(JSON.stringify(e))}}}},{key:"getClientPromise",value:function(e,t){var n=this,i=this.newApiRequest(e,t);return{config:i,send:function(e){return new Promise((function(t,n){i.onload=function(){return t({text:i.responseText,status:i.status})},i.send(JSON.stringify(e))})).then((function(e){return n.parserPromise(e)})).catch((function(e){throw n.reportError(Fn,e,u(u({},n.ctx),{classMethod:"getClientPromise",description:"Send unsuccessful."})),e}))}}}},{key:"parser",value:function(e,t,n){var i=e.text,r=e.status;try{var o=JSON.parse(i);if(r>=200&&r<300||302===r)return t(o.resource.data);n(o.error||{message:"unknown error"})}catch(e){this.reportError(Fn,e,u(u({},this.ctx),{classMethod:"parser",description:"Unable to parse response body to json."}))}}},{key:"parserPromise",value:function(e){var t=e.text,n=e.status;try{var i=JSON.parse(t);return n>=200&&n<300||302===n?Promise.resolve(i.resource.data):Promise.reject(i.error||{message:"unknown error"})}catch(e){return this.reportError(Fn,e,u(u({},this.ctx),{classMethod:"parserPromise",description:"Unable to parse response body to json."})),Promise.reject(e)}}},{key:"newApiRequest",value:function(e,t){var n=ee.create(e,this.env.getConf().url+t).setContentTypeJson().setSdkVersion();switch(this.authType){case Dn.PUBLIC_KEY:n.setPublicKey(this.auth);break;case Dn.TOKEN:n.setAccessToken(this.auth)}return n.inner()}},{key:"ctx",get:function(){return{sdkVersion:J.version,className:e.name,environment:this.env.getEnv()}}}])}(),Vn=function(e){function n(e){var i;return s(this,n),(i=t(this,n,[e])).publicKey=i.auth,i}return d(n,e),c(n,[{key:"getBrowserDetails",value:function(){return{name:E.getBrowserName(),java_enabled:E.isJavaEnabled().toString(),language:E.getLanguage(),screen_height:E.getScreenHeight().toString(),screen_width:E.getScreenWidth().toString(),time_zone:E.getTimezoneOffset().toString(),color_depth:E.getColorDepth().toString()}}},{key:"charge",value:function(){return new k(this)}}])}(zn),Wn=function(){return c((function e(){s(this,e)}),null,[{key:"extendSearchParams",value:function(e,t,n){return e.replace(new RegExp("([?&]"+t+"(?=[=&#]|$)[^#&]*|(?=#|$))"),"&"+t+"="+encodeURIComponent(n)).replace(/^([^?&]+)&/,"$1?")}},{key:"serialize",value:function(e){return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&")}}])}(),qn=function(){return c((function e(){s(this,e)}),null,[{key:"generate",value:function(){if("undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.getRandomValues){var e=new Uint16Array(8);return window.crypto.getRandomValues(e),this.hash(e[0])+this.hash(e[1])+"-"+this.hash(e[2])+"-"+this.hash(e[3])+"-"+this.hash(e[4])+"-"+this.hash(e[5])+this.hash(e[6])+this.hash(e[7])}return this.random()+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+this.random()+this.random()}},{key:"hash",value:function(e){for(var t=e.toString(16);t.length<4;)t="0"+t;return t}},{key:"random",value:function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}}])}(),Gn="/wallet/flypay",Kn="/images/logo.png",Yn=function(){return c((function e(t){s(this,e),this.params={},this.widgetId=qn.generate(),this.linkResource=t,this.env=new $(V),this.setParams({widget_id:this.widgetId})}),[{key:"getNetUrl",value:function(){return this.env.getConf().url+this.linkResource}},{key:"getUrl",value:function(){var e=this.getNetUrl(),t=this.getParams();for(var n in t)t.hasOwnProperty(n)&&(e=Wn.extendSearchParams(e,n,t[n]));return e}},{key:"setParams",value:function(e){this.params=u({},this.params,e)}},{key:"concatParams",value:function(e){for(var t in e)e.hasOwnProperty(t)&&e[t].length&&("string"!=typeof this.params[t]&&(this.params[t]=""),this.params[t].length?this.params[t]+=","+e[t]:this.params[t]+=e[t])}},{key:"getParams",value:function(){return this.params}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getBaseUrl",value:function(){return this.env.getConf().url}}])}(),$n=function(){return c((function e(){s(this,e)}),null,[{key:"insertToInput",value:function(e,t,n){if(void 0!==n[t]){var i=document.querySelector(e);i&&(i.value=n[t])}}},{key:"subscribe",value:function(e,t,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent("on".concat(e),n)}}])}(),Jn=function(){return c((function e(t){s(this,e),this.selector=t}),[{key:"isExist",value:function(){return!!this.getElement()}},{key:"getStyles",value:function(e){if(this.isExist()){var t=this.getElement().getAttribute("widget-style");if(!t)return{};var n=t.split(";");return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"on",value:function(e,t){this.isExist()&&$n.subscribe(e,this.getElement(),t)}},{key:"getAttr",value:function(e){if(this.isExist()){var t=this.getElement(),n=[];for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].replace(/_/g,"-"),o=t.getAttribute(r);o&&n.push("".concat(e[i],":").concat(o))}return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"getSelector",value:function(){return this.selector}},{key:"convertConfigs",value:function(e,t){var n={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].split(":"),o=r[0].replace(/-/g,"_").trim();-1!==t.indexOf(o)&&(n[o]=r[1].trim())}return n}}])}(),Xn=function(){return c((function e(t){s(this,e),this.container=t}),[{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("src",e),t.title&&(n.title=t.title),this.container.getElement().appendChild(n)}}},{key:"loadFromHtml",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("height","100%"),n.setAttribute("width","100%"),t.title&&(n.title=t.title);this.container.getElement().appendChild(n);var i=this.getElement().contentDocument;i.open(),i.write("<html><head><style>html, body {margin: 0;} iframe {border: 0; width: 100%}</style><title></title></head><body>{{content}}</body></html>".replace("{{content}}",e)),i.close()}}},{key:"remove",value:function(){if(this.container.isExist()&&this.isExist()){var e=this.getElement();this.container.getElement().removeChild(e)}}},{key:"show",value:function(){this.isExist()&&(this.setStyle("visibility","visible"),this.setStyle("display","block"))}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isExist()&&(e?this.setStyle("visibility","hidden"):this.setStyle("display","none"))}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"getElement",value:function(){return this.container.isExist()?this.container.getElement().querySelector("iframe"):null}},{key:"setStyle",value:function(e,t){this.getElement().style[e]=t}}])}(),Zn={AFTER_LOAD:"afterLoad",SUBMIT:"submit",FINISH:"finish",VALIDATION_ERROR:"validationError",SYSTEM_ERROR:"systemError",CHECKOUT_SUCCESS:"checkoutSuccess",CHECKOUT_READY:"checkoutReady",CHECKOUT_ERROR:"checkoutError",CHECKOUT_COMPLETED:"checkoutCompleted",CHECKOUT_POPUP_OPEN:"checkoutPopupOpen",CHECKOUT_POPUP_CLOSE:"checkoutPopupClose",VALIDATION:"validation",SELECT:"select",UNSELECT:"unselect",NEXT:"next",PREV:"prev",META_CHANGE:"metaChange",RESIZE:"resize",CHARGE_AUTH_SUCCESS:"chargeAuthSuccess",CHARGE_AUTH_REJECT:"chargeAuthReject",CHARGE_AUTH_CANCELLED:"chargeAuthCancelled",ADDITIONAL_DATA_SUCCESS:"additionalDataCollectSuccess",ADDITIONAL_DATA_REJECT:"additionalDataCollectReject",CHARGE_AUTH:"chargeAuth",DISPATCH_SUCCESS:"dispatchSuccess",DISPATCH_ERROR:"dispatchError"},Qn=function(){return c((function e(t){var n=this;s(this,e),this.listeners=[],t&&$n.subscribe("message",t,(function(e){var t;try{t=JSON.parse(e.data)}catch(e){}t&&n.emit(t)}))}),[{key:"emit",value:function(e){for(var t in this.listeners)this.listeners[t].event===e.event&&e.widget_id===this.listeners[t].widget_id&&this.listeners[t].listener.apply(this,[e])}},{key:"on",value:function(e,t,n){for(var i in Zn)Zn.hasOwnProperty(i)&&e===Zn[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}},{key:"clear",value:function(){this.listeners=[]}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("message",t):e.attachEvent("onmessage",t)}}])}(),ei={visibility:"hidden",border:"0",width:"0",height:"0"};!function(e){e.SUCCESS="success",e.ERROR="error",e.PENDING="pending"}(jn||(jn={})),function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(Bn||(Bn={})),function(e){e.FINISHED="MethodFinished",e.SKIPPED="MethodSkipped",e.READY="ResultReady",e.TIMEOUT="AuthTimedOut",e.INVALID="invalid_event"}(Hn||(Hn={}));var ti,ni="chargeAuthSuccess",ii="chargeAuthReject",ri="chargeAuthDecoupled",oi="chargeAuthChallenge",si="chargeAuthInfo",ai="error",ci=function(){return c((function e(t,n,i){s(this,e),this.container=t,this.api=n,this.eventEmitter=i,this.resultRead=!1,this.iFrameEvent=new Qn(window)}),[{key:"load",value:function(e,t){var n=e.initialization_url,i=e.secondary_url,r=e.charge_3ds_id;try{this.setupIFrameEvents(r),this.initializeIFrames(n,i,t)}catch(e){this.eventEmitter.emit(ai,this.parseError(e,r))}}},{key:"initializeIFrames",value:function(e,t,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=this.container.getElement();if(r){var o=document.createElement("div");if(o.setAttribute("id","paydock_authorization_iframe"),r.appendChild(o),this.browserAndChallengeContainer=new Jn("#paydock_authorization_iframe"),this.iFrameAuthorization=new Xn(this.browserAndChallengeContainer),this.iFrameAuthorization.load(e,{title:n}),t){var s=document.createElement("div");s.setAttribute("id","paydock_secondary_iframe"),r.appendChild(s),this.monitoringContainer=new Jn("#paydock_secondary_iframe"),this.iFrameSecondaryUrl=new Xn(this.monitoringContainer),this.iFrameSecondaryUrl.load(t,{title:n})}else this.iFrameSecondaryUrl=void 0;this.hideIframes(i)}}},{key:"hideIframes",value:function(){var e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];for(var n in ei)ei.hasOwnProperty(n)&&(t&&this.iFrameAuthorization.setStyle(n,ei[n]),null===(e=this.iFrameSecondaryUrl)||void 0===e||e.setStyle(n,ei[n]))}},{key:"setupIFrameEvents",value:function(e){var t=this;this.iFrameEvent.on(Zn.CHARGE_AUTH,e,(function(e){e.status===Hn.SKIPPED||e.status===Hn.FINISHED?(e.info&&t.eventEmitter.emit(si,{info:e.info}),t.performAuthentication(e)):e.status!==Hn.TIMEOUT&&e.status!==Hn.INVALID||t.eventEmitter.emit(ii,t.parseHandleResponse({status:e.status},e.charge_3ds_id))})),this.iFrameEvent.on(Zn.CHARGE_AUTH_SUCCESS,e,(function(e){t.processResult(e.charge_3ds_id)}))}},{key:"parseResultData",value:function(e,t){return{status:e.status,charge_3ds_id:t}}},{key:"parseHandleResponse",value:function(e,t){var n=e.status,i=e.result;return{status:n,charge_3ds_id:t,result:{description:null==i?void 0:i.description}}}},{key:"parseError",value:function(e,t){return{charge_3ds_id:t,error:e}}},{key:"processResult",value:function(e){var t=this;this.resultRead||(this.resultRead=!0,this.api.charge().standalone3dsHandle().then((function(n){var i;t.iFrameAuthorization.remove(),null===(i=t.iFrameSecondaryUrl)||void 0===i||i.remove(),n.status===jn.SUCCESS?t.eventEmitter.emit(ni,t.parseResultData(n,e)):t.eventEmitter.emit(ii,t.parseResultData(n,e))}),(function(n){t.eventEmitter.emit(ai,t.parseError(n,e))})))}},{key:"externalAPI",value:function(e,t){var n=ee.create(e,t).inner();return new Promise((function(e,t){n.onload=function(){try{var i=JSON.parse(n.responseText);e(i)}catch(e){t(e)}},n.send()}))}},{key:"doPolling",value:function(e,t){var n=this;this.externalAPI("GET",e).then((function(i){if(i.event&&"AuthResultNotReady"!==i.event){if("AuthResultReady"!==i.event)throw new Error("Event not supported");n.processResult(t)}else setTimeout((function(){n.doPolling(e,t)}),2e3)})).catch((function(e){return n.eventEmitter.emit(ai,n.parseError(e,t))}))}},{key:"performAuthentication",value:function(e){var t,n=this,i=e.charge_3ds_id;this.iFrameAuthorization.remove(),null===(t=this.iFrameSecondaryUrl)||void 0===t||t.remove(),this.api.charge().standalone3dsProcess({charge_3ds_id:i}).then((function(e){var t,r;if(e.status===Bn.SUCCESS)n.eventEmitter.emit(ni,n.parseHandleResponse(e,i));else{if(e.status!==Bn.PENDING)return n.eventEmitter.emit(ii,n.parseHandleResponse(e,i));(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.challenge)?(n.eventEmitter.emit(oi,n.parseHandleResponse(e,i)),n.initializeIFrames(e.result.challenge_url,void 0,"Authentication Challenge",!1),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i)):(null===(r=null==e?void 0:e.result)||void 0===r?void 0:r.decoupled_challenge)&&(n.eventEmitter.emit(ri,n.parseHandleResponse(e,i)),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i))}}),(function(e){n.eventEmitter.emit(ai,n.parseError(e,i))}))}}])}(),li=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"walletCapture",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/capture").send(e)}},{key:"walletCallback",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/callback").send(e)}},{key:"standalone3dsProcess",value:function(e){return this.api.getClientPromise("POST","/v1/charges/standalone-3ds/process").send(e)}},{key:"standalone3dsHandle",value:function(){return this.api.getClientPromise("GET","/v1/charges/standalone-3ds/handle").send(void 0)}}])}(),ui=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"getWalletConfig",value:function(e){var t="/v1/gateways/:gateway_id/wallet-config".replace(":gateway_id",e);return this.api.getClientPromise("GET",t).send(void 0)}}])}(),di=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"getConfig",value:function(e){var t="/v1/services/:service_id/config".replace(":service_id",e);return this.api.getClientPromise("GET",t).send(void 0)}}])}();!function(e){e.VISA_SRC="VisaSRC",e.MASTERCARD_SRC="ClickToPay"}(ti||(ti={}));var hi,pi=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"charge",value:function(){return new li(this)}},{key:"service",value:function(){return new di(this)}},{key:"gateway",value:function(){return new ui(this)}}])}(zn),fi="GPayments",mi=function(){return c((function e(t,n){s(this,e),this.env=G,this.container=t,this.eventEmitter=n}),[{key:"load",value:function(e,t){var n=Q.validateJWT(e);if(!n)throw new Error("Invalid charge token");var i=Q.extractData(n.body),r=new pi(e,Dn.TOKEN);if(r.setEnv(this.env,this.alias),i.service_type===fi)new ci(this.container,r,this.eventEmitter).load(i,t.title)}},{key:"setEnv",value:function(e,t){this.env=e,this.alias=t}}])}(),vi=function(){return c((function e(){s(this,e),this.events={}}),[{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e.call(null,t)}))}},{key:"emitWithResult",value:function(e,t){var n=this,r=this.events[e];if(r){var o=r.map((function(e){return te(n,void 0,void 0,i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.call(null,t));case 1:case"end":return n.stop()}}),n)})))}));return Promise.all(o)}return Promise.resolve([])}},{key:"subscribe",value:function(e,t){var n=this;return this.events[e]||(this.events[e]=[]),this.events[e].push(t),function(){n.events[e]=n.events[e].filter((function(e){return t!==e}))}}}])}();!function(e){e.HTML="html",e.URL="url",e.STANDALONE_3DS="standalone_3ds"}(hi||(hi={}));var gi,yi,bi=function(){return c((function e(t,n){s(this,e),this.configs=[],this.link=new Yn("/3ds/webhook"),this.token=e.extractToken(n),this.link.setParams({ref_id:this.token.charge_3ds_id}),this.container=new Jn(t),this.iFrame=new Xn(this.container),this.eventEmitter=new vi,this.standalone3dsService=new mi(this.container,this.eventEmitter),this.event=new Qn(window)}),[{key:"load",value:function(){this.token.format===hi.HTML?this.iFrame.loadFromHtml(this.token.content,{title:"3d secure authentication"}):this.token.format===hi.URL?this.iFrame.load(this.token.content,{title:"3d secure authentication"}):this.token.format===hi.STANDALONE_3DS?this.standalone3dsService.load(this.token.content,{title:"3d secure authentication"}):console.error("Token contain unsupported payload")}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.standalone3dsService.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"on",value:function(e,t){var n=this;return this.token.format===hi.STANDALONE_3DS?"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))})):"function"==typeof t?this.event.on(e,this.link.getParams().ref_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().ref_id,(function(e){return t(e)}))}))}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}}],[{key:"extractToken",value:function(e){return JSON.parse(window.atob(e))}}])}(),Ei={CLICK:"click",POPUP_REDIRECT:"popupRedirect",REDIRECT:"redirect",ERROR:"error",REFERRED:"referred",DECLINED:"declined",CANCELLED:"cancelled",ACCEPTED:"accepted",FINISH:"finish",CLOSE:"close"};!function(e){e.CONTEXTUAL="contextual",e.REDIRECT="redirect"}(gi||(gi={})),function(e){e.ZIPMONEY="Zipmoney",e.PAYPAL="PaypalClassic",e.AFTERPAY="Afterpay"}(yi||(yi={}));var wi,ki,Si="[Paydock:CheckoutButton]",Ti={CARD:"card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},_i={CARD_NAME:"card_name",CARD_NUMBER:"card_number",EXPIRE_MONTH:"expire_month",EXPIRE_YEAR:"expire_year",CARD_CCV:"card_ccv",CARD_PIN:"card_pin",ACCOUNT_NAME:"account_name",ACCOUNT_BSB:"account_bsb",ACCOUNT_NUMBER:"account_number",ACCOUNT_ROUTING:"account_routing",ACCOUNT_HOLDER_TYPE:"account_holder_type",ACCOUNT_BANK_NAME:"account_bank_name",ACCOUNT_TYPE:"account_type",FIRST_NAME:"first_name",LAST_NAME:"last_name",EMAIL:"email",PHONE:"phone",PHONE2:"phone2",ADDRESS_LINE1:"address_line1",ADDRESS_LINE2:"address_line2",ADDRESS_STATE:"address_state",ADDRESS_COUNTRY:"address_country",ADDRESS_CITY:"address_city",ADDRESS_POSTCODE:"address_postcode",ADDRESS_COMPANY:"address_company"},Ci={BACKGROUND_COLOR:"background_color",BACKGROUND_ACTIVE_COLOR:"background_active_color",TEXT_COLOR:"text_color",BORDER_COLOR:"border_color",ICON_SIZE:"icon_size",BUTTON_COLOR:"button_color",ERROR_COLOR:"error_color",SUCCESS_COLOR:"success_color",FONT_SIZE:"font_size",FONT_FAMILY:"font_family"},Oi={TITLE:"title",TITLE_H1:"title_h1",TITLE_H2:"title_h2",TITLE_H3:"title_h3",TITLE_H4:"title_h4",TITLE_H5:"title_h5",TITLE_H6:"title_h6",FINISH:"finish_text",TITLE_DESCRIPTION:"title_description",SUBMIT_BUTTON:"submit_button",SUBMIT_BUTTON_PROCESSING:"submit_button_processing"},Ni={SUBMIT_BUTTON:"submit_button",TABS:"tabs"},Ii={AMEX:"amex",AUSBC:"ausbc",DINERS:"diners",DISCOVER:"discover",JAPCB:"japcb",LASER:"laser",MASTERCARD:"mastercard",SOLO:"solo",VISA:"visa",VISA_WHITE:"visa_white"},Ai=[].concat(["brand_name","cart_border_color","reference","email","hdr_img","logo_img","pay_flow_color","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone","hide_shipping_address"],["first_name","last_name","phone","tokenize","email","gender","date_of_birth","charge","statistics","hide_shipping_address"],["amount","currency","email","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone"],["customer_storage_number","tokenise_algorithm"]);!function(e){e.STRIPE="Stripe",e.FLYPAY="Flypay",e.FLYPAY_V2="FlypayV2",e.PAYPAL="Paypal",e.MASTERCARD="MasterCard",e.AFTERPAY="Afterpay"}(wi||(wi={})),function(e){e.GOOGLE="google",e.APPLE="apple",e.FLYPAY="flypay",e.FLYPAY_V2="flypayV2",e.PAYPAL="paypal",e.AFTERPAY="afterpay"}(ki||(ki={}));var Ri,xi=function(){return c((function e(){s(this,e),this.env=new $(W)}),[{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getUrl",value:function(){return this.env.getConf().url+this.getLink()}},{key:"create",value:function(e,t,n,i){var r=this,o=ee.create("POST",this.getUrl()).setHeader(Q.getAccessHeaderNameByToken(e),e).setContentTypeJson().setSdkVersion().inner();o.onload=function(){r.parser(o.responseText,o.status,n,i)},o.send(JSON.stringify(t))}},{key:"get",value:function(e,t,n){var i=this,r=ee.create("GET",this.getUrl()).setHeader(Q.getAccessHeaderNameByToken(e),e).setContentTypeJson().setSdkVersion().inner();r.onload=function(){i.parser(r.responseText,r.status,t,n)},r.send()}},{key:"parser",value:function(e,t,n,i){var r={};try{r=JSON.parse(e)}catch(e){}return t>=200&&t<300||302===t?n(r.resource.data,t):i(r.error||{message:"unknown error"},t)}}])}(),Mi=function(e){function n(e,i,r){var o;return s(this,n),(o=t(this,n)).body={gateway_id:e,meta:{},success_redirect_url:i,error_redirect_url:r,redirect_url:i},o}return d(n,e),c(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout"}},{key:"setDescriptions",value:function(e){this.body.description=e}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==Ai.indexOf(t)?this.body.meta[t]=e[t]:console.warn("ExternalCheckout::setMeta: unsupported meta key ".concat(t)))}},{key:"getConfigs",value:function(){return this.body}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e,t){};this.create(e,this.getConfigs(),(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error"),"unknown_error"):n(e.message,e.code)}))}}])}(xi),Pi=function(e){function n(e){var i;return s(this,n),(i=t(this,n)).token=e,i}return d(n,e),c(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout/:token".replace(":token",this.token)}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.get(e,(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error")):n(e.message)}))}}])}(xi),Di='\n <div class="cs-loader">\n <div class="cs-loader-inner">\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n </div>\n </div>\n',Li="\n <style> \n .cs-loader {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n }\n \n .cs-loader-inner {\n transform: translateY(-50%);\n top: 50%;\n position: absolute;\n width: calc(100% - 200px);\n color: #8e8d8c;\n padding: 0 100px;\n text-align: center;\n }\n \n \n .cs-loader-inner label {\n font-size: 20px;\n opacity: 0;\n display:inline-block;\n }\n \n @keyframes lol {\n 0% {\n opacity: 0;\n transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n transform: translateX(300px);\n }\n }\n \n @-webkit-keyframes lol {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n -webkit-transform: translateX(300px);\n -moz-transform: translateX(300px);\n }\n }\n \n .cs-loader-inner label:nth-child(6) {\n -webkit-animation: lol 3s infinite ease-in-out;\n -moz-animation: lol 3s infinite ease-in-out;\n animation: lol 3s infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(5) {\n -webkit-animation: lol 3s 100ms infinite ease-in-out;\n -moz-animation: lol 3s 100ms infinite ease-in-out;\n animation: lol 3s 100ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(4) {\n -webkit-animation: lol 3s 200ms infinite ease-in-out;\n -moz-animation: lol 3s 200ms infinite ease-in-out;\n animation: lol 3s 200ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(3) {\n -webkit-animation: lol 3s 300ms infinite ease-in-out;\n -moz-animation: lol 3s 300ms infinite ease-in-out;\n animation: lol 3s 300ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(2) {\n -webkit-animation: lol 3s 400ms infinite ease-in-out;\n -moz-animation: lol 3s 400ms infinite ease-in-out;\n animation: lol 3s 400ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(1) {\n -webkit-animation: lol 3s 500ms infinite ease-in-out;\n -moz-animation: lol 3s 500ms infinite ease-in-out;\n animation: lol 3s 500ms infinite ease-in-out;\n }\n </style>\n",Fi="close",Ui="focus",ji=function(){return c((function e(){s(this,e),this.description="Don't see the secure checkout browser? We'll help you re-launch the window to complete your purchase",this.title="Checkout",this.overlay=null,this.style=null,this.showControl=!0,this.showLoader=!0,this.eventEmitter=new vi}),[{key:"initControl",value:function(){if(!this.isInit()&&this.showControl){if(!E.isSupportPopUp())return this.createLoader();this.createTemplate(),this.createStyles(),this.eventHandler()}}},{key:"initLoader",value:function(){!this.isInit()&&this.showLoader&&(this.createStyles(),this.createLoader())}},{key:"eventHandler",value:function(){var e=this,t=document.querySelector("[data-close]"),n=document.querySelector("[data-continue]");t&&$n.subscribe("click",t,(function(){return e.eventEmitter.emit(Fi,{})})),n&&$n.subscribe("click",n,(function(){return e.eventEmitter.emit(Ui,{})}))}},{key:"clear",value:function(){(this.style||this.overlay)&&(this.style.parentNode.removeChild(this.style),this.overlay.parentNode.removeChild(this.overlay),this.style=null,this.overlay=null)}},{key:"createLoader",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0];this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=Li+Di,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <strong class="checkout-title" data-title>{{title}}</strong>\n <p data-description>{{description}}</p>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');n=(n=n.replace("{{description}}",this.description)).replace("{{title}}",this.title),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .hide-continue-button [data-continue] {\n display: none;\n }\n\n .checkout-overlay .cs-loader-inner {\n color: #ddd;\n }\n\n .checkout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0,0,0, 0.5);\n text-align: center;\n color: #fff;\n opacity: 0;\n }\n .checkout-overlay.display {\n opacity: 1;\n transition: opacity 0.7s ease-out;\n }\n .checkout-overlay a { color: #00f; }\n .checkout-container {\n position: absolute;\n top: 50%;\n left: 0;\n width: 100%;\n margin-top: -{{width}}px;\n }\n .checkout-title {\n font-size: 24px;\n display: block;\n text-transform: uppercase;\n }\n [data-close] {\n position: fixed;\n right: 32px;\n top: 32px;\n width: 32px;\n height: 32px;\n opacity: 0.3;\n overflow: hidden;\n text-indent: -9999px;\n }\n [data-close]:hover { opacity: 1; }\n [data-close]:before, [data-close]:after {\n position: absolute;\n left: 15px;\n content: ' ';\n height: 33px;\n width: 2px;\n background-color: #00f;\n }\n [data-close]:before { transform: rotate(45deg); }\n [data-close]:after { transform: rotate(-45deg); }\n"),n=document.querySelector(".checkout-container");t=t.replace("{{width}}",n?String(n.offsetHeight/2):"0"),this.style=document.createElement("style"),this.style.type="text/css",this.style.appendChild(document.createTextNode(t)),e.appendChild(this.style)}},{key:"setBackdropDescription",value:function(e){this.description=e}},{key:"setBackdropTitle",value:function(e){this.title=e}},{key:"onTrigger",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"isInit",value:function(){return!(!this.overlay||!this.style)}},{key:"hideContinueControl",value:function(){this.isInit()&&this.overlay.classList.add("hide-continue-button")}},{key:"turnOffControl",value:function(){this.showControl=!1}},{key:"turnOffLoader",value:function(){this.showLoader=!1}}])}(),Bi=function(){return c((function e(){s(this,e),this.widgetEnv=new $(V)}),[{key:"error",value:function(e,t,n){n(!0)}},{key:"setEnv",value:function(e,t){this.widgetEnv.setEnv(e,t)}}])}();function Hi(){return function(e){function n(){var e;s(this,n);for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return(e=t(this,n,[].concat(r))).background=new ji,e.background.onTrigger(Ui,(function(){return e.continue()})),e.background.onTrigger(Fi,(function(){return e.stop()})),e}return d(n,e),c(n,[{key:"continue",value:function(){}},{key:"stop",value:function(){}},{key:"error",value:function(e,t,n){n(!0)}},{key:"setSuspendedRedirectUri",value:function(e){this.suspendedRedirectUri=e}},{key:"setBackgroundTitle",value:function(e){this.background.setBackdropTitle(e)}},{key:"setBackgroundDescription",value:function(e){this.background.setBackdropDescription(e)}},{key:"turnOffBackdrop",value:function(){this.background.turnOffControl(),this.background.turnOffLoader()}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Bi)}!function(e){e.SUCCESS="success",e.DECLINED="declined",e.CLOSE="close",e.REFERRED="referred",e.ERROR="error"}(Ri||(Ri={}));var zi="paydock-dispatcher",Vi=function(){return c((function e(t){s(this,e),this.messageSource=t,this.env=new $(V)}),[{key:"restartDispatcher",value:function(){var e=document.getElementById(zi);e&&e.parentNode&&e.parentNode.removeChild(e);var t=document.createElement("iframe");t.setAttribute("src",this.env.getConf().url+"/dispatcher"),t.id=zi,t.style.display="none",document.body.appendChild(t)}},{key:"on",value:function(e,t){var n=this;$n.subscribe("message",window,(function(i){var r=null;try{r=JSON.parse(i.data)}catch(e){}r&&r.message_source===n.messageSource&&r.event===e&&t(r)}))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.restartDispatcher()}}])}(),Wi="close",qi=function(){return c((function e(){s(this,e),this.configs={width:500,height:500,scrollbars:!0,resizable:!0,top:0,left:0},this.eventEmitter=new vi}),[{key:"isExist",value:function(){return!(!this.getElement()||this.getElement().closed)}},{key:"getElement",value:function(){return this.window}},{key:"init",value:function(){var e=this;if(!E.isSupportPopUp())return this.window=window;var t=this.getConfigs();this.window=window.open("about:blank","_blank","noopener=false,width=".concat(t.width,",height=").concat(t.height,",top=").concat(t.top,",left=").concat(t.left,",scrollbars=").concat(t.scrollbars?"yes":"no",",resizable=").concat(t.resizable?"yes":"no")),this.showLoader();var n=setInterval((function(){e.isExist()||(clearInterval(n),e.eventEmitter.emit(Wi,{}))}),200)}},{key:"redirect",value:function(e){this.isExist()&&(this.window.location.href=e)}},{key:"close",value:function(){this.isExist()&&this.getElement().close&&(this.getElement().close(),this.window=null)}},{key:"focus",value:function(){this.isExist()&&this.getElement().focus&&this.getElement().focus()}},{key:"setConfigs",value:function(e){this.configs=u(this.configs,e)}},{key:"getNetConfigs",value:function(){return u({},this.configs)}},{key:"getConfigs",value:function(){var e=this.getNetConfigs();return e.left=window.screenX+(window.screen.width/2-e.width/2),e.top=window.screenY+(window.screen.height/2-e.height/2),e}},{key:"onClose",value:function(e){this.eventEmitter.subscribe(Wi,e)}},{key:"initError",value:function(e){this.getElement().document.write("."),(this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0]).innerHTML="<style>\n .error-wrapper {\n color: #ff0000;\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n }\n </style>"+'<div class="error-wrapper"><div>{{error}}</div></div>'.replace("{{error}}",e)}},{key:"showLoader",value:function(){this.getElement().document.write(".");var e=this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0];if(e.innerHTML=Li+Di,this.env===O&&this.env===N&&this.env===I&&this.env===A&&this.env===R&&this.env===x&&this.env===M&&this.env===P&&this.env===D&&this.env===L&&this.env===F&&this.env===U&&this.env===j&&this.env===B&&this.env===H&&this.env===z){var t=0;$n.subscribe("click",e,(function(){5===++t&&(e.innerHTML='\n <style>\n html{width: 100%;height: 100%;}\n body{margin: 0px;padding: 0px;background-color: #111;}\n \n .eye{\n width: 20px; height: 8px;\n background-color: #eee;\n border-radius:0px 0px 20px 20px;\n position: relative;\n top: 40px;\n left: 10px;\n box-shadow: 40px 0px 0px 0px #eee; \n }\n \n .head{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden; \n position: relative;\n margin: -250px auto;\n width: 80px; height: 80px;\n background-color: #111;\n border-radius:50px;\n box-shadow: inset -4px 2px 0px 0px #eee;\n -webkit-animation:node 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n .body{ \n position: relative;\n margin: 90px auto;\n width: 140px; height: 120px;\n background-color: #111;\n border-radius: 50px/25px ;\n box-shadow: inset -5px 2px 0px 0px #eee;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out; \n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out; \n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out; \n }\n \n @keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-moz-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-moz-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-webkit-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-webkit-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n \n \n .circ{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin: 60px auto;\n width: 180px; height: 180px;\n background-color: #111;\n border-radius: 0px 0px 50px 50px;\n position: relative;\n z-index: -1; \n left: 0%;\n top: 20%;\n overflow: hidden;\n }\n \n .hands{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin-top: 140px;\n width: 120px;height: 120px;\n position: absolute;\n background-color: #111;\n border-radius:20px;\n box-shadow:-1px -4px 0px 0px #eee;\n transform:rotate(45deg);\n -webkit-transform:rotate(45deg);\n -mox-transform:rotate(45deg);\n top:75%;left: 16%;\n z-index: 1;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n \n .load{ position: absolute;\n width: 100px; height: 20px;\n margin: -10px auto;\n -webkit-font-smoothing: antialiased;\n -moz-font-smoothing: antialiased;\n font-smoothing: antialiased;\n font-family: \'Julius Sans One\', sans-serif;\n font-size:30px;\n font-weight:400;\n color:#eee;\n left: 10%;\n top: 5%;\n }\n </style>\n\n <div class="circ">\n <div class="load">A little patience ...</div>\n <div class="hands"></div>\n <div class="body"></div>\n <div class="head">\n <div class="eye"></div>\n </div>\n </div>\n')}))}}},{key:"setEnv",value:function(e){this.env=e}}])}(),Gi=function(e){function n(e){var i;return s(this,n),(i=t(this,n)).publicKey=e,i.checkout=null,i.dispatcher=new Vi("checkout.paydock"),setTimeout((function(){return i.dispatcher.restartDispatcher()}),200),i.popup=new qi,i}return d(n,e),c(n,[{key:"run",value:function(){this.isRunning()||(this.popup.init(),this.background.initControl())}},{key:"isRunning",value:function(){return this.popup.isExist()}},{key:"next",value:function(e){this.checkout=e,E.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.checkout.link)}},{key:"continue",value:function(){this.popup.focus()}},{key:"stop",value:function(){this.popup.close()}},{key:"onStop",value:function(e){var t=this;this.popup.onClose((function(){t.background.clear(),t.checkout=null,e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.dispatcher.on(e,(function(e){if(n.checkout&&n.checkout.reference_id===e.reference_id)n.background.clear(),t(n.checkout,e);else if(!E.isSupportPopUp()){var i=window.localStorage.getItem("paydock_checkout_token");if(!i)return;var r=JSON.parse(i);r&&r.reference_id===e.reference_id&&(window.localStorage.removeItem("paydock_checkout_token"),n.checkout=r,n.background.clear(),t(n.checkout,e))}}))}},{key:"setEnv",value:function(e,t){f(h(n.prototype),"setEnv",this).call(this,e,t),this.dispatcher.setEnv(e,t),this.popup.setEnv(e)}}])}(Hi());function Ki(e){return"run"in e}function Yi(e){return"setRedirectUrl"in e}!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(e,t,n){function i(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function o(e){if(u===setTimeout)return setTimeout(e,0);if((u===i||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function s(){m&&p&&(m=!1,p.length?f=p.concat(f):v=-1,f.length&&a())}function a(){if(!m){var e=o(s);m=!0;for(var t=f.length;t;){for(p=f,f=[];++v<t;)p&&p[v].run();v=-1,t=f.length}p=null,m=!1,function(e){if(d===clearTimeout)return clearTimeout(e);if((d===r||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}(e)}}function c(e,t){this.fun=e,this.array=t}function l(){}var u,d,h=t.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:i}catch(e){u=i}try{d="function"==typeof clearTimeout?clearTimeout:r}catch(e){d=r}}();var p,f=[],m=!1,v=-1;h.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new c(e,t)),1!==f.length||m||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],2:[function(e,t,n){(function(e){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==o(n)&&"object"==o(t))t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else{if("undefined"==typeof window&&"undefined"==typeof self)throw Error("This environment was not anticipated by Q. Please file a bug.");var i="undefined"!=typeof window?window:self,r=i.Q;i.Q=e(),i.Q.noConflict=function(){return i.Q=r,this}}}((function(){function t(e){return function(){return R.apply(e,arguments)}}function n(e,t){if(_&&t.stack&&"object"==o(e)&&null!==e&&e.stack){for(var n=[],r=t;r;r=r.source)r.stack&&(!e.__minimumStackCounter__||e.__minimumStackCounter__>r.stackCounter)&&(F(e,"__minimumStackCounter__",{value:r.stackCounter,configurable:!0}),n.unshift(r.stack));n.unshift(e.stack),F(e,"stack",{value:function(e){for(var t=e.split("\n"),n=[],r=0;r<t.length;++r){var o=t[r];s(o)||i(o)||!o||n.push(o)}return n.join("\n")}(n.join("\n"+H+"\n")),configurable:!0})}}function i(e){return-1!==e.indexOf("(module.js:")||-1!==e.indexOf("(node.js:")}function r(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(n)return[n[1],Number(n[2])];var i=/.*@(.+):(\d+)$/.exec(e);return i?[i[1],Number(i[2])]:void 0}function s(e){var t=r(e);if(!t)return!1;var n=t[0],i=t[1];return n===C&&i>=N&&i<=Y}function a(){if(_)try{throw Error()}catch(n){var e=n.stack.split("\n"),t=r(e[0].indexOf("@")>0?e[1]:e[2]);if(!t)return;return C=t[0],t[1]}}function c(e){var t,n;return e instanceof h?e:v(e)?(t=e,n=l(),c.nextTick((function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}})),n.promise):b(e)}function l(){function e(e){t=e,c.longStackSupport&&_&&(o.source=e),M(n,(function(t,n){c.nextTick((function(){e.promiseDispatch.apply(e,n)}))}),void 0),n=void 0,i=void 0}var t,n=[],i=[],r=L(l.prototype),o=L(h.prototype);if(o.promiseDispatch=function(e,r,o){var s=x(arguments);n?(n.push(s),"when"===r&&o[1]&&i.push(o[1])):c.nextTick((function(){t.promiseDispatch.apply(t,s)}))},o.valueOf=function(){if(n)return o;var e=f(t);return m(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},c.longStackSupport&&_)try{throw Error()}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=z++}return r.promise=o,r.resolve=function(n){t||e(c(n))},r.fulfill=function(n){t||e(b(n))},r.reject=function(n){t||e(y(n))},r.notify=function(e){t||M(i,(function(t,n){c.nextTick((function(){n(e)}))}),void 0)},r}function u(e){if("function"!=typeof e)throw TypeError("resolver must be a function.");var t=l();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function d(e){return u((function(t,n){for(var i=0,r=e.length;i<r;i++)c(e[i]).then(t,n)}))}function h(e,t,n){void 0===t&&(t=function(e){return y(Error("Promise does not support operation: "+e))}),void 0===n&&(n=function(){return{state:"unknown"}});var i=L(h.prototype);if(i.promiseDispatch=function(n,r,o){var s;try{s=e[r]?e[r].apply(i,o):t.call(i,r,o)}catch(e){s=y(e)}n&&n(s)},i.inspect=n,n){var r=n();"rejected"===r.state&&(i.exception=r.reason),i.valueOf=function(){var e=n();return"pending"===e.state||"rejected"===e.state?i:e.value}}return i}function p(e,t,n,i){return c(e).then(t,n,i)}function f(e){if(m(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function m(e){return e instanceof h}function v(e){var t;return(t=e)===Object(t)&&"function"==typeof e.then}function g(){W.length=0,q.length=0,K||(K=!0)}function y(t){var n,i,r=h({when:function(n){return n&&function(t){if(K){var n=P(q,t);-1!==n&&("object"==o(e)&&"function"==typeof e.emit&&c.nextTick.runAfter((function(){var i=P(G,t);-1!==i&&(e.emit("rejectionHandled",W[n],t),G.splice(i,1))})),q.splice(n,1),W.splice(n,1))}}(this),n?n(t):this}},(function(){return this}),(function(){return{state:"rejected",reason:t}}));return n=r,i=t,K&&("object"==o(e)&&"function"==typeof e.emit&&c.nextTick.runAfter((function(){-1!==P(q,n)&&(e.emit("unhandledRejection",i,n),G.push(n))})),q.push(n),i&&void 0!==i.stack?W.push(i.stack):W.push("(no stack) "+i)),r}function b(e){return h({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},delete:function(t){delete e[t]},post:function(t,n){return null==t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return j(e)}},void 0,(function(){return{state:"fulfilled",value:e}}))}function E(e,t,n){return c(e).spread(t,n)}function w(e,t,n){return c(e).dispatch(t,n)}function k(e){return p(e,(function(e){var t=0,n=l();return M(e,(function(i,r,o){var s;m(r)&&"fulfilled"===(s=r.inspect()).state?e[o]=s.value:(++t,p(r,(function(i){e[o]=i,0==--t&&n.resolve(e)}),n.reject,(function(e){n.notify({index:o,value:e})})))}),void 0),0===t&&n.resolve(e),n.promise}))}function S(e){if(0===e.length)return c.resolve();var t=c.defer(),n=0;return M(e,(function(i,r,o){var s=e[o];n++,p(s,(function(e){t.resolve(e)}),(function(e){0==--n&&(e.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+e.message,t.reject(e))}),(function(e){t.notify({index:o,value:e})}))}),void 0),t.promise}function T(e){return p(e,(function(e){return e=D(e,c),p(k(D(e,(function(e){return p(e,I,I)}))),(function(){return e}))}))}var _=!1;try{throw Error()}catch(e){_=!!e.stack}var C,O,N=a(),I=function(){},A=function(){function t(){for(var e,t;i.next;)e=(i=i.next).task,i.task=void 0,(t=i.domain)&&(i.domain=void 0,t.enter()),n(e,t);for(;l.length;)n(e=l.pop());s=!1}function n(e,n){try{e()}catch(e){if(c)throw n&&n.exit(),setTimeout(t,0),n&&n.enter(),e;setTimeout((function(){throw e}),0)}n&&n.exit()}var i={task:void 0,next:null},r=i,s=!1,a=void 0,c=!1,l=[];if(A=function(t){r=r.next={task:t,domain:c&&e.domain,next:null},s||(s=!0,a())},"object"==o(e)&&"[object process]"===e.toString()&&e.nextTick)c=!0,a=function(){e.nextTick(t)};else if("function"==typeof setImmediate)a="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){a=d,u.port1.onmessage=t,t()};var d=function(){u.port2.postMessage(0)};a=function(){setTimeout(t,0),d()}}else a=function(){setTimeout(t,0)};return A.runAfter=function(e){l.push(e),s||(s=!0,a())},A}(),R=Function.call,x=t(Array.prototype.slice),M=t(Array.prototype.reduce||function(e,t){var n=0,i=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=i)throw TypeError()}for(;n<i;n++)n in this&&(t=e(t,this[n],n));return t}),P=t(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),D=t(Array.prototype.map||function(e,t){var n=this,i=[];return M(n,(function(r,o,s){i.push(e.call(t,o,s,n))}),void 0),i}),L=Object.create||function(e){function t(){}return t.prototype=e,new t},F=Object.defineProperty||function(e,t,n){return e[t]=n.value,e},U=t(Object.prototype.hasOwnProperty),j=Object.keys||function(e){var t=[];for(var n in e)U(e,n)&&t.push(n);return t},B=t(Object.prototype.toString);O="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var H="From previous event:";c.resolve=c,c.nextTick=A,c.longStackSupport=!1;var z=1;"object"==o(e)&&e&&e.env&&e.env.Q_DEBUG&&(c.longStackSupport=!0),c.defer=l,l.prototype.makeNodeResolver=function(){var e=this;return function(t,n){t?e.reject(t):arguments.length>2?e.resolve(x(arguments,1)):e.resolve(n)}},c.Promise=u,c.promise=u,u.race=d,u.all=k,u.reject=y,u.resolve=c,c.passByCopy=function(e){return e},h.prototype.passByCopy=function(){return this},c.join=function(e,t){return c(e).join(t)},h.prototype.join=function(e){return c([this,e]).spread((function(e,t){if(e===t)return e;throw Error("Q can't join: not the same: "+e+" "+t)}))},c.race=d,h.prototype.race=function(){return this.then(c.race)},c.makePromise=h,h.prototype.toString=function(){return"[object Promise]"},h.prototype.then=function(e,t,i){var r=this,o=l(),s=!1;return c.nextTick((function(){r.promiseDispatch((function(t){s||(s=!0,o.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return y(e)}}(t)))}),"when",[function(e){s||(s=!0,o.resolve(function(e){if("function"==typeof t){n(e,r);try{return t(e)}catch(e){return y(e)}}return y(e)}(e)))}])})),r.promiseDispatch(void 0,"when",[void 0,function(e){var t,n,r=!1;try{t=e,n="function"==typeof i?i(t):t}catch(e){if(r=!0,!c.onerror)throw e;c.onerror(e)}r||o.notify(n)}]),o.promise},c.tap=function(e,t){return c(e).tap(t)},h.prototype.tap=function(e){return e=c(e),this.then((function(t){return e.fcall(t).thenResolve(t)}))},c.when=p,h.prototype.thenResolve=function(e){return this.then((function(){return e}))},c.thenResolve=function(e,t){return c(e).thenResolve(t)},h.prototype.thenReject=function(e){return this.then((function(){throw e}))},c.thenReject=function(e,t){return c(e).thenReject(t)},c.nearer=f,c.isPromise=m,c.isPromiseAlike=v,c.isPending=function(e){return m(e)&&"pending"===e.inspect().state},h.prototype.isPending=function(){return"pending"===this.inspect().state},c.isFulfilled=function(e){return!m(e)||"fulfilled"===e.inspect().state},h.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},c.isRejected=function(e){return m(e)&&"rejected"===e.inspect().state},h.prototype.isRejected=function(){return"rejected"===this.inspect().state};var V,W=[],q=[],G=[],K=!0;c.resetUnhandledRejections=g,c.getUnhandledReasons=function(){return W.slice()},c.stopUnhandledRejectionTracking=function(){g(),K=!1},g(),c.reject=y,c.fulfill=b,c.master=function(e){return h({isDef:function(){}},(function(t,n){return w(e,t,n)}),(function(){return c(e).inspect()}))},c.spread=E,h.prototype.spread=function(e,t){return this.all().then((function(t){return e.apply(void 0,t)}),t)},c.async=function(e){return function(){function t(e,t){var o,s;if("undefined"==typeof StopIteration){try{o=n[e](t)}catch(e){return y(e)}return o.done?c(o.value):p(o.value,i,r)}try{o=n[e](t)}catch(e){return"[object StopIteration]"===B(s=e)||s instanceof O?c(e.value):y(e)}return p(o,i,r)}var n=e.apply(this,arguments),i=t.bind(t,"next"),r=t.bind(t,"throw");return i()}},c.spawn=function(e){c.done(c.async(e)())},c.return=function(e){throw new O(e)},c.promised=function(e){return function(){return E([this,k(arguments)],(function(t,n){return e.apply(t,n)}))}},c.dispatch=w,h.prototype.dispatch=function(e,t){var n=this,i=l();return c.nextTick((function(){n.promiseDispatch(i.resolve,e,t)})),i.promise},c.get=function(e,t){return c(e).dispatch("get",[t])},h.prototype.get=function(e){return this.dispatch("get",[e])},c.set=function(e,t,n){return c(e).dispatch("set",[t,n])},h.prototype.set=function(e,t){return this.dispatch("set",[e,t])},c.del=c.delete=function(e,t){return c(e).dispatch("delete",[t])},h.prototype.del=h.prototype.delete=function(e){return this.dispatch("delete",[e])},c.mapply=c.post=function(e,t,n){return c(e).dispatch("post",[t,n])},h.prototype.mapply=h.prototype.post=function(e,t){return this.dispatch("post",[e,t])},c.send=c.mcall=c.invoke=function(e,t){return c(e).dispatch("post",[t,x(arguments,2)])},h.prototype.send=h.prototype.mcall=h.prototype.invoke=function(e){return this.dispatch("post",[e,x(arguments,1)])},c.fapply=function(e,t){return c(e).dispatch("apply",[void 0,t])},h.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},c.try=c.fcall=function(e){return c(e).dispatch("apply",[void 0,x(arguments,1)])},h.prototype.fcall=function(){return this.dispatch("apply",[void 0,x(arguments)])},c.fbind=function(e){var t=c(e),n=x(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(x(arguments))])}},h.prototype.fbind=function(){var e=this,t=x(arguments);return function(){return e.dispatch("apply",[this,t.concat(x(arguments))])}},c.keys=function(e){return c(e).dispatch("keys",[])},h.prototype.keys=function(){return this.dispatch("keys",[])},c.all=k,h.prototype.all=function(){return k(this)},c.any=S,h.prototype.any=function(){return S(this)},c.allResolved=(V=T,function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("allResolved is deprecated, use allSettled instead.",Error("").stack),V.apply(V,arguments)}),h.prototype.allResolved=function(){return T(this)},c.allSettled=function(e){return c(e).allSettled()},h.prototype.allSettled=function(){return this.then((function(e){return k(D(e,(function(e){function t(){return e.inspect()}return(e=c(e)).then(t,t)})))}))},c.fail=c.catch=function(e,t){return c(e).then(void 0,t)},h.prototype.fail=h.prototype.catch=function(e){return this.then(void 0,e)},c.progress=function(e,t){return c(e).then(void 0,void 0,t)},h.prototype.progress=function(e){return this.then(void 0,void 0,e)},c.fin=c.finally=function(e,t){return c(e).finally(t)},h.prototype.fin=h.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw Error("Q can't apply finally callback");return e=c(e),this.then((function(t){return e.fcall().then((function(){return t}))}),(function(t){return e.fcall().then((function(){throw t}))}))},c.done=function(e,t,n,i){return c(e).done(t,n,i)},h.prototype.done=function(t,i,r){var s=function(e){c.nextTick((function(){if(n(e,a),!c.onerror)throw e;c.onerror(e)}))},a=t||i||r?this.then(t,i,r):this;"object"==o(e)&&e&&e.domain&&(s=e.domain.bind(s)),a.then(void 0,s)},c.timeout=function(e,t,n){return c(e).timeout(t,n)},h.prototype.timeout=function(e,t){var n=l(),i=setTimeout((function(){t&&"string"!=typeof t||((t=Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),n.reject(t)}),e);return this.then((function(e){clearTimeout(i),n.resolve(e)}),(function(e){clearTimeout(i),n.reject(e)}),n.notify),n.promise},c.delay=function(e,t){return void 0===t&&(t=e,e=void 0),c(e).delay(t)},h.prototype.delay=function(e){return this.then((function(t){var n=l();return setTimeout((function(){n.resolve(t)}),e),n.promise}))},c.nfapply=function(e,t){return c(e).nfapply(t)},h.prototype.nfapply=function(e){var t=l(),n=x(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},c.nfcall=function(e){var t=x(arguments,1);return c(e).nfapply(t)},h.prototype.nfcall=function(){var e=x(arguments),t=l();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},c.nfbind=c.denodeify=function(e){if(void 0===e)throw Error("Q can't wrap an undefined function");var t=x(arguments,1);return function(){var n=t.concat(x(arguments)),i=l();return n.push(i.makeNodeResolver()),c(e).fapply(n).fail(i.reject),i.promise}},h.prototype.nfbind=h.prototype.denodeify=function(){var e=x(arguments);return e.unshift(this),c.denodeify.apply(void 0,e)},c.nbind=function(e,t){var n=x(arguments,2);return function(){var i=n.concat(x(arguments)),r=l();return i.push(r.makeNodeResolver()),c((function(){return e.apply(t,arguments)})).fapply(i).fail(r.reject),r.promise}},h.prototype.nbind=function(){var e=x(arguments,0);return e.unshift(this),c.nbind.apply(void 0,e)},c.nmapply=c.npost=function(e,t,n){return c(e).npost(t,n)},h.prototype.nmapply=h.prototype.npost=function(e,t){var n=x(t||[]),i=l();return n.push(i.makeNodeResolver()),this.dispatch("post",[e,n]).fail(i.reject),i.promise},c.nsend=c.nmcall=c.ninvoke=function(e,t){var n=x(arguments,2),i=l();return n.push(i.makeNodeResolver()),c(e).dispatch("post",[t,n]).fail(i.reject),i.promise},h.prototype.nsend=h.prototype.nmcall=h.prototype.ninvoke=function(e){var t=x(arguments,1),n=l();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},c.nodeify=function(e,t){return c(e).nodeify(t)},h.prototype.nodeify=function(e){if(!e)return this;this.then((function(t){c.nextTick((function(){e(null,t)}))}),(function(t){c.nextTick((function(){e(t)}))}))},c.noConflict=function(){throw Error("Q.noConflict only works when Q is used as a global")};var Y=a();return c}))}).call(this,e("_process"))},{_process:1}],3:[function(e,t,n){var i=function(e){switch(o(e)){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,r){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==o(e)?Object.keys(e).map((function(r){var o=encodeURIComponent(i(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return o+encodeURIComponent(i(e))})).join(t):o+encodeURIComponent(i(e[r]))})).join(t):r?encodeURIComponent(i(r))+n+encodeURIComponent(i(e)):""}},{}],4:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return l.default.information("zip:checkout:init"),d.default.Promise((function(t,n){return e.onCheckout(t,n,{})})).then((function(i){var r=i.redirect_uri||i.redirectUri||i.data&&(i.data.redirect_uri||i.data.redirectUri);if(!r)return l.default.debug("zip:checkout:error","Response does not contain redirectUri property"),n(i),void e.onError({code:"checkout_error",message:"The response does not contain the redirectUri property",detail:i});l.default.debug("zip:checkout:success",i),t({redirectUri:r})})).catch((function(t){l.default.debug("zip:checkout:error",t),n(t),e.onError({code:"checkout_error",message:"Checkout response error",detail:t})}))}Object.defineProperty(n,"__esModule",{value:!0}),n.Checkout=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=i(e("./modal")),a=i(e("./options")),c=i(e("./utility")),l=i(e("./console")),d=i((e("./events"),e("q"))),h=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return o(e,null,[{key:"init",value:function(e){var t,n;if("function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw TypeError("Cannot convert undefined or null to object");e=Object(e);for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}),e=u({},a.default,e),!this._validate(e))return l.default.setLevel(e.logLevel),e.redirect?r(e,(function(t){return e.redirectFn(t.redirectUri)})):(t=e,(n=new s.default).onClose=t.onComplete.bind(t),n.build(),void r(t,(function(e){return n.setUri(e.redirectUri)}),(function(e){return n.close(!1)})))}},{key:"attachButton",value:function(e,t){var n=document.querySelectorAll(e);if(!n.length)return config.onError({code:"attach_error",message:"Cannot find button to attach zipMoney checkout"});for(var i=0;i<n.length;i++)c.default.addEventHandler(n[i],"click",(function(){return Zip.Checkout.init(t)}))}},{key:"_validate",value:function(e){return 0>["error","information","debug"].indexOf(e.logLevel.toLowerCase())&&(e.logLevel="error"),0>["standard","express"].indexOf(e.request.toLowerCase())&&(e.request="standard"),e.onComplete=e.onComplete||function(){},e.onError=e.onError||function(){},e.checkoutUri||e.onCheckout!==a.default.onCheckout?"express"===e.request?e.onError({code:"not_implemented",message:"This feature is not yet implemented"}):e.redirect||e.onComplete!==a.default.onComplete||e.redirectUri?void 0:e.onError({code:"validation",message:"if onComplete function is not specified then redirectUri must be specified"}):e.onError({code:"validation",message:"if onCheckout function is not specified then checkoutUri must be specified"})}}]),e}();n.Checkout=h},{"./console":5,"./events":6,"./modal":8,"./options":9,"./utility":10,q:2}],5:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i="error";n.default={error:function(){var e;(e=window.console).log.apply(e,arguments)},information:function(){var e;"error"!==i&&(e=window.console).log.apply(e,arguments)},debug:function(){var e;"debug"===i&&(e=window.console).log.apply(e,arguments)},setLevel:function(e){i=e}}},{}],6:[function(e,t,n){(function(t){Object.defineProperty(n,"__esModule",{value:!0}),n.EventListener=void 0;var i,r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();if(((i=e("./utility"))&&i.__esModule?i:{default:i}).default.isIe){var o=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n};o.prototype=t.Event.prototype,t.CustomEvent=o}var s={},a=n.EventListener=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"constructor",value:function(){s={}}},{key:"on",value:function(e,t){s[e]=t}},{key:"off",value:function(e){s[e]=null}}]),e}();a.Event=function(e,t){this.eventType=e,this.data=t||{}},a.Event.eventTypes={resize:"resize",transition:"transition",close:"close",complete:"complete",clear:"clear"};var c=window.addEventListener?"addEventListener":"attachEvent",l=window[c];l("attachEvent"==c?"onmessage":"message",(function(e){var n,i;e.data.zipmoney&&(n=e.data.msg,i=new t.CustomEvent("zipmoney",{detail:n}),t.dispatchEvent(i))}),!1),l("zipmoney",(function(e){var t,n=s[e.detail.eventType];n?n(e.detail.data||{}):(t=e,console.log("Unexpected Event",t))}),!1)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utility":10}],7:[function(e,t,n){(function(t){var n=e("./checkout"),i=e("./events");t.Zip=t.Zip||{},t.Zip.Checkout=n.Checkout,t.zipMoneyEvent=i.EventListener.ZipEvent}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./checkout":4,"./events":6}],8:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}function o(){var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}function s(e){for(var t=document.querySelectorAll("html, body"),n=0;n<t.length;n++)t[n].style.overflowY=e}function a(e){var t=document.body.currentStyle||window.getComputedStyle(document.body),n=document.body.offsetHeight+(parseInt(t.marginTop,10)+parseInt(t.marginBottom,10))-parseInt(t.height,10);document.body.style.height=e-n+"px"}Object.defineProperty(n,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=i(e("./utility")),d=e("./events"),h=(i(e("./console")),{iframeWidth:400,iframeMinWidth:320,iframeInitialHeight:704,iframeMinHeight:600,verticalMargin:35}),p=["resize","transition","close","complete","clear"],f="https://d3k1w8lx8mqizo.cloudfront.net/zm/",m=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,e),this._events=[],this._isMobile=l.default.isMobileDevice(),p.forEach((function(e){return d.EventListener.on(d.EventListener.Event.eventTypes[e],t[e].bind(t))}))}return c(e,[{key:"build",value:function(){this._initialHtmlHeight=o(),window.scrollTo(0,0);var e=this._frame=(t=this._frameUri,n=this._isMobile,(i=document.createElement("iframe")).id="zipmoney-iframe",i.frameborder=0,u(i.style,{padding:"0",border:"none",zIndex:"999999",backgroundColor:"#FFF",backgroundImage:"url("+f+"spinner.gif)",backgroundRepeat:"no-repeat",backgroundPosition:"50% 50%"}),u(i.style,n?{overflow:"scroll",width:"100%",height:"100%",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",margin:"0"}:{width:h.iframeWidth+"px",minWidth:h.iframeMinWidth+"px",height:h.iframeInitialHeight+"px",margin:h.verticalMargin+"px auto 0 auto",display:"table-row",backgroundSize:"25%",textAlign:"center",boxShadow:"0px 0px 70px 0px rgb(0, 0, 0)"}),i.src=t||"",i);if(!this._isMobile){var t,n,i,r,c,l=((r=document.createElement("img")).src=f+"icon-close.png",u(r.style,{width:"50px",height:"50px",position:"absolute",top:"20px",right:"20px",cursor:"pointer"}),r);l.onclick=this.close.bind(this),this._overlay=((c=document.createElement("div")).className="zipmoney-overlay",u(c.style,{position:"absolute",left:"0",top:"0",display:"table-cell",textAlign:"center",verticalAlign:"middle",background:"rgba(0, 0, 0, 0.75)",zIndex:"10000",height:"100%",width:"100%"}),c),this._overlay.appendChild(l),this._overlay.appendChild(this._frame),e=this._overlay}document.body.appendChild(e),this._isMobile&&a(this._frame.offsetHeight),s("auto"),this._startMonitoringWindowResize()}},{key:"setUri",value:function(e){this._frameUri=e,this._frame&&(this._frame.src=e)}},{key:"resize",value:function(e){var t=this._isMobile?16:0,n=(e=e>=h.iframeMinHeight?e:h.iframeMinHeight,(e+=t)+2*h.verticalMargin),i=r();this._frame.style.height=e+"px",this._overlay&&(this._overlay.style.height=Math.max(i,this._initialHtmlHeight,n)+"px"),this._isMobile&&a(e)}},{key:"transition",value:function(){window.scroll(0,0)}},{key:"close",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t={state:"cancelled"};this._events.length&&(t=this._events.pop()),this._destroy(),this.onClose&&e&&this.onClose(t)}},{key:"complete",value:function(e){this._events.push(e)}},{key:"clear",value:function(e){this._events=[]}},{key:"_startMonitoringWindowResize",value:function(){var e=this;this._resizeHandler=l.default.debounce((function(){var t,n,i,s;return t=e,n=r(),i=o(),s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t._overlay&&(t._overlay.style.height=Math.max(n,i)+"px"),void(t._isMobile||s<h.iframeWidth?t._frame.style.width="100%":t._frame.style.width=h.iframeWidth+"px")}),250),l.default.addEventHandler(window,"resize",this._resizeHandler)}},{key:"_stopMonitoringWindowResize",value:function(){l.default.removeEventHandler(window,"resize",this._resizeHandler)}},{key:"_destroy",value:function(){this._stopMonitoringWindowResize(),this._overlay?document.body.removeChild(this._overlay):document.body.removeChild(this._frame),this._isMobile&&(document.body.style.height="initial"),s("initial"),this._overlay=this._frame=null,p.forEach((function(e){return d.EventListener.off(d.EventListener.Event.eventTypes[e])}))}}]),e}();n.default=m},{"./console":5,"./events":6,"./utility":10}],9:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var r=i(e("./xr")),o=i(e("./console"));r.default.configure({headers:{"X-Requested-With":"XMLHttpRequest"}}),n.default={request:"standard",redirect:!1,logLevel:"Error",onCheckout:function(e,t,n){r.default.post(this.checkoutUri).then((function(t){return e(t.data)})).catch(t)},onShippingAddressChanged:function(e,t,n){r.default.post(this.shippingUri).then(e).catch(t)},onComplete:function(e){if(o.default.information("zip:completed",e),"cancelled"!==e.state){var t=e.checkoutId?"&checkoutId="+e.checkoutId:"";this.redirectFn(this.redirectUri+"?result="+e.state+t)}},onError:function(e){o.default.error(e)},redirectFn:function(e){window.location.href=e}}},{"./console":5,"./xr":11}],10:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"isIe",value:function(){var e=-1,t=window.navigator.userAgent,n=t.indexOf("MSIE "),i=t.indexOf("Trident/");if(n>0)e=parseInt(t.substring(n+5,t.indexOf(".",n)),10);else if(i>0){var r=t.indexOf("rv:");e=parseInt(t.substring(r+3,t.indexOf(".",r)),10)}return e>-1?e:void 0}},{key:"isMobileDevice",value:function(){var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}},{key:"debounce",value:function(e,t){var n;return function(){var i=this,r=arguments,o=!n;clearTimeout(n),n=setTimeout((function(){n=null,e.apply(i,r)}),t),o&&e.apply(i,r)}}},{key:"addEventHandler",value:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)}},{key:"removeEventHandler",value:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}}]),e}();n.default=r},{}],11:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return{status:e.status,response:e.response,data:t,xhr:e}}function s(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(var r in n)if({}.hasOwnProperty.call(n,r)){var o=n[r];if("object"===(void 0===o?"undefined":c(o)))for(var s in o)({}).hasOwnProperty.call(o,s)&&(e[s]=o[s])}return e}function a(e){var t,n;return n=function(t,n){var i=s({},p,f,e),o=i.xmlHttpRequest();for(var a in i.abort&&e.abort((function(){n(r(o)),o.abort()})),o.open(i.method,i.params?i.url.split("?")[0]+"?"+(0,l.default)(i.params):i.url,!0),o.withCredentials=i.withCredentials,o.addEventListener(h.LOAD,(function(){if(o.status>=200&&o.status<300){var e=null;o.responseText&&(e=!0===i.raw?o.responseText:i.load(o.responseText)),t(r(o,e))}else n(r(o))})),o.addEventListener(h.ABORT,(function(){return n(r(o))})),o.addEventListener(h.ERROR,(function(){return n(r(o))})),o.addEventListener(h.TIMEOUT,(function(){return n(r(o))})),i.headers)({}).hasOwnProperty.call(i.headers,a)&&o.setRequestHeader(a,i.headers[a]);for(var u in i.events)({}).hasOwnProperty.call(i.events,u)&&o.addEventListener(u,i.events[u].bind(null,o),!1);var d="object"!==c(i.data)||i.raw?i.data:i.dump(i.data);void 0!==d?o.send(d):o.send()},((t=e)&&t.promise?t.promise:f.promise||p.promise)(n)}Object.defineProperty(n,"__esModule",{value:!0});var c="function"==typeof Symbol&&"symbol"==o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)},l=i(e("querystring/encode")),u=i(e("q")),d={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE",PATCH:"PATCH",OPTIONS:"OPTIONS"},h={READY_STATE_CHANGE:"readystatechange",LOAD_START:"loadstart",PROGRESS:"progress",ABORT:"abort",ERROR:"error",LOAD:"load",TIMEOUT:"timeout",LOAD_END:"loadend"},p={method:d.GET,data:void 0,headers:{Accept:"application/json","Content-Type":"application/json"},dump:JSON.stringify,load:JSON.parse,xmlHttpRequest:function(){return new XMLHttpRequest},promise:function(e){return u.default.Promise(e)},withCredentials:!1},f={};a.assign=s,a.encode=l.default,a.configure=function(e){f=s({},f,e)},a.Methods=d,a.Events=h,a.defaults=p,a.get=function(e,t,n){return a(s({url:e,method:d.GET,params:t},n))},a.put=function(e,t,n){return a(s({url:e,method:d.PUT,data:t},n))},a.post=function(e,t,n){return a(s({url:e,method:d.POST,data:t},n))},a.patch=function(e,t,n){return a(s({url:e,method:d.PATCH,data:t},n))},a.del=function(e,t){return a(s({url:e,method:d.DELETE},t))},a.options=function(e,t){return a(s({url:e,method:d.OPTIONS},t))},n.default=a},{q:2,"querystring/encode":3}]},{},[7]);var $i,Ji=function(e){function n(){var e;return s(this,n),(e=t(this,n)).apiEnv=new $(W),e}return d(n,e),c(n,[{key:"setEnv",value:function(e,t){f(h(n.prototype),"setEnv",this).call(this,e,t),this.apiEnv.setEnv(e,t)}},{key:"getCheckoutUri",value:function(e){return this.apiEnv.getConf().url+"/v1/echo?"+Wn.serialize({json_body:JSON.stringify({redirect_uri:e})})}}])}(Bi),Xi=function(e){function n(){var e;return s(this,n),(e=t(this,n)).runs=!1,e.eventEmitter=new vi,e}return d(n,e),c(n,[{key:"run",value:function(){this.runs=!0,this.background.initLoader()}},{key:"isRunning",value:function(){return this.runs}},{key:"next",value:function(e){var t=this;this.background.clear(),this.checkout=e;var n=this.getCheckoutUri(this.checkout.link);Zip.Checkout.init({checkoutUri:n,onComplete:function(e){return t.eventHandler(e)},onError:function(e){return t.eventHandler(e)}})}},{key:"getSuccessRedirectUri",value:function(){return this.suspendedRedirectUri?this.suspendedRedirectUri:this.widgetEnv.getConf().url+String("/checkout/zipmoney/suspended")}},{key:"getErrorRedirectUri",value:function(){return this.getSuccessRedirectUri()}},{key:"stop",value:function(){f(h(n.prototype),"stop",this).call(this),this.runs=!1;var e=document.querySelector(".zipmoney-overlay");e&&e.remove(),this.eventEmitter.emit(Ri.CLOSE)}},{key:"onStop",value:function(e){var t=this;this.eventEmitter.subscribe(Ri.CLOSE,(function(){t.background.clear(),e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.eventEmitter.subscribe(e,(function(){t(n.checkout)}))}},{key:"eventHandler",value:function(e){switch(this.runs=!1,e.state){case"approved":this.eventEmitter.emit(Ri.CLOSE),this.eventEmitter.emit(Ri.SUCCESS);break;case"declined":this.eventEmitter.emit(Ri.CLOSE),this.eventEmitter.emit(Ri.DECLINED);break;case"cancelled":this.eventEmitter.emit(Ri.CLOSE);break;case"referred":this.eventEmitter.emit(Ri.CLOSE),this.eventEmitter.emit(Ri.REFERRED);break;default:console.warn("".concat("[CheckoutButton:Zipmoney]"," Unknown gateway status."))}}}])}(Hi(Ji)),Zi="[Paydock:StorageDispatcher]";!function(e){e.WIDGET_SESSION="widget-session"}($i||($i={}));var Qi,er=function(){return c((function e(t){s(this,e),this.messageSource=t,this.defaultPayload={destination:"widget.paydock"},this.env=new $(V),this.defaultPayload.source=t,this.iframeEvent=new Qn(window)}),[{key:"create",value:function(e){this.onLoadCallback=e,this.dispatcherFrame&&this.destroy(),this.widgetId=qn.generate(),this.setupIframeEventListeners();var t=document.createElement("iframe");return t.setAttribute("src",this.env.getConf().url+"/storage-dispatcher"+"?widgetId=".concat(this.widgetId)),t.setAttribute("id","pd-storage-dispatcher"),t.style.display="none",document.body.appendChild(t),this.dispatcherFrame=t,console.info("".concat(Zi," initialized.")),t}},{key:"destroy",value:function(){this.dispatcherFrame&&this.dispatcherFrame.parentNode&&this.dispatcherFrame.parentNode.removeChild(this.dispatcherFrame),this.iframeEvent.clear(),this.widgetId=void 0,this.dispatcherFrame=void 0}},{key:"push",value:function(e,t){var n;if(this.pushCallbacks=t,this.dispatcherFrame){var i=u(u({},this.defaultPayload),e);null===(n=this.dispatcherFrame.contentWindow)||void 0===n||n.postMessage(i,this.env.getConf().url)}else console.error("".concat(Zi," dispatcher is not initialized."))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.create(this.onLoadCallback)}},{key:"setupIframeEventListeners",value:function(){var e=this;this.widgetId&&(this.iframeEvent.on(Zn.AFTER_LOAD,this.widgetId,(function(t){var n;null===(n=e.onLoadCallback)||void 0===n||n.call(e)})),this.iframeEvent.on(Zn.DISPATCH_SUCCESS,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onSuccess)||void 0===i||i.call(n)})),this.iframeEvent.on(Zn.DISPATCH_ERROR,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onError)||void 0===i||i.call(n)})))}}])}(),tr=function(e){function n(){var e;return s(this,n),(e=t(this,n)).storageDispatcher=new er("zipmoney.checkout.paydock"),e}return d(n,e),c(n,[{key:"getProxyRedirectUrl",value:function(){return this.widgetEnv.getConf().url+"/checkout/zipmoney/response"}},{key:"next",value:function(e,t){var n=this;this.storageDispatcher.create((function(){var i={merchant_redirect_url:n.getRedirectUrl(),checkout_token:e.token,public_key:t.public_key,gateway_id:t.gateway_id};n.storageDispatcher.push({intent:$i.WIDGET_SESSION,data:i},{onSuccess:function(){var t=n.getCheckoutUri(e.link);Zip.Checkout.init({checkoutUri:t,redirect:!0})},onError:function(){console.error("Error initializing Zip Checkout")}})}))}},{key:"getSuccessRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"getErrorRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"setEnv",value:function(e,t){f(h(n.prototype),"setEnv",this).call(this,e,t),this.storageDispatcher.setEnv(e,t)}}])}(function(){return function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"setRedirectUrl",value:function(e){this.merchantRedirectUrl=e}},{key:"getRedirectUrl",value:function(){return this.merchantRedirectUrl}},{key:"error",value:function(e,t,n){n(!1)}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Bi)}(Ji)),nr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+Wn.extendSearchParams("/checkout/success","merchant",encodeURIComponent(window.location.href))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+Wn.extendSearchParams("/checkout/error","merchant",encodeURIComponent(window.location.href))}}])}(Gi);!function(e){e.CLOSE="CANCELLED"}(Qi||(Qi={}));var ir,rr,or=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/success".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/error".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"next",value:function(e,t){this.checkout=e,E.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.getRedirectUrl(this.checkout,t))}},{key:"onCheckout",value:function(e,t){f(h(n.prototype),"onCheckout",this).call(this,e,(function(e,n){if(!(null==n?void 0:n.status))return t(e);var i=n.status,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(n,["status"]);i===Qi.CLOSE?t(e,u(u({},r),{isCloseEvent:!0})):t(e,r)}))}},{key:"error",value:function(e,t,n){return!t||t&&"invalid_amount"!==t?n(!0):(this.popup.initError(e),n(!1))}},{key:"run",value:function(){this.isRunning()||(this.popup.setConfigs({width:420,height:715}),this.popup.init(),this.background.initControl())}},{key:"getRedirectUrl",value:function(e,t){return this.widgetEnv.getConf().url+"/checkout/afterpay/init?"+Wn.serialize(u(u({},t),{token:e.reference_id,env:"live"===e.mode?"live":"test"}))}}])}(Gi),sr={EXTERNAL_CHECKOUT_TOKEN:"external_checkout_token",CHECKOUT_TOKEN:"checkout_token",BANK_ACCOUNT:"bank_account",CARD:"card"},ar=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sr.CARD;switch(s(this,n),(r=t(this,n)).body={gateway_id:e,type:o},o){case sr.CARD:case sr.BANK_ACCOUNT:delete i.gateway_id,delete i.type,delete i.checkout_token,r.body=u(r.body,i);break;case sr.CHECKOUT_TOKEN:case sr.EXTERNAL_CHECKOUT_TOKEN:r.body.checkout_token=i;break;default:throw new Error("Unsupported type of PaymentSourceToken")}return r}return d(n,e),c(n,[{key:"getLink",value:function(){return"/v1/payment_sources/tokens"}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.create(e,this.getConfigs(),(function(e,n){return t(e)}),(function(e,t){void 0===e.message?n("unknown error"):n(e.message)}))}},{key:"getConfigs",value:function(){return this.body}}])}(xi),cr=function(){return c((function e(t,n,i,r){var o=this;s(this,e),this.background=t,this.runner=n,this.eventEmitter=i,this.params=r,this.runner.onStop((function(){o.eventEmitter.emit(Ei.CLOSE)}))}),[{key:"init",value:function(e){var t=this;this.setEnv(e),this.runner.onCheckout(Ri.SUCCESS,(function(e){t.eventEmitter.emit(Ei.ACCEPTED,{}),t.background.initLoader(),t.runner.stop(),t.checkToken(e.token,(function(){t.createOneTimeToken(e.token)}))})),this.runner.onCheckout(Ri.ERROR,(function(e,n){(null==n?void 0:n.isCloseEvent)||(t.eventEmitter.emit(Ei.ERROR),console.error("".concat(Si," Error from checkout server."))),t.runner.stop()})),this.runner.onCheckout(Ri.REFERRED,(function(){t.eventEmitter.emit(Ei.REFERRED),t.runner.stop()})),this.runner.onCheckout(Ri.DECLINED,(function(){t.eventEmitter.emit(Ei.DECLINED),t.runner.stop()})),this.eventEmitter.subscribe(Ei.ERROR,(function(){t.runner.stop()})),this.eventEmitter.subscribe(Ei.FINISH,(function(e){t.background.clear()}))}},{key:"setEnv",value:function(e){this.env=e}},{key:"checkToken",value:function(e,t){var n=this,i=new Pi(e);i.setEnv(this.env),i.send(this.params.accessToken,(function(e){n.details=e,t()}),(function(){n.eventEmitter.emit(Ei.ERROR,{}),console.error("".concat(Si," Error during creating payment source token."))}))}},{key:"createOneTimeToken",value:function(e){var t=this,n=new ar(this.params.gatewayId,e,sr.CHECKOUT_TOKEN);n.setEnv(this.env),n.send(this.params.accessToken,(function(e){t.eventEmitter.emit(Ei.FINISH,{payment_source_token:e,checkout_email:t.details.checkout_email,checkout_holder:t.details.checkout_holder,gateway_type:t.details.gateway_type})}),(function(){t.eventEmitter.emit(Ei.ERROR,{}),console.error("".concat(Si," Error during creating payment source token."))}))}}])}(),lr=function(){return c((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yi.PAYPAL,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:gi.CONTEXTUAL;s(this,e),this.accessToken=n,this.gatewayId=i,this.gatewayType=r,this.mode=o,this.window=window,this.meta={},this.env=G,this.eventEmitter=new vi,this.container=new Jn(t),this.initCheckout(this.container),this.chooseRunner(r,o)}),[{key:"chooseRunner",value:function(e,t){var n=this.getRunnerByMode(e,t);this.runner=new n(this.accessToken),Ki(this.runner)?(this.background=new ji,this.checkoutHandler=new cr(this.background,this.runner,this.eventEmitter,{accessToken:this.accessToken,gatewayId:this.gatewayId}),this.checkoutHandler.init(this.env)):(this.background=void 0,this.checkoutHandler=void 0)}},{key:"buildAdditionalParams",value:function(){return{}}},{key:"initCheckout",value:function(e){var t=this;e.on("click",(function(e){if(Ki(t.runner)){if(t.runner.isRunning())return;t.runner.run()}else if(Yi(t.runner)&&!t.runner.getRedirectUrl())throw Error("".concat(Si," The merchant redirect URL should is required in the '").concat(t.mode,"' mode."));t.eventEmitter.emit(Ei.CLICK);var n=new Mi(t.gatewayId,t.runner.getSuccessRedirectUri(),t.runner.getErrorRedirectUri());n.setMeta(t.meta),n.setEnv(t.env),n.send(t.accessToken,(function(e){var n=Ki(t.runner)?Ei.POPUP_REDIRECT:Ei.REDIRECT;t.eventEmitter.emit(n),t.runner.next(e,t.buildAdditionalParams())}),(function(e,n){console.error("".concat(Si," ").concat(e)),t.eventEmitter.emit(Ei.ERROR,{error:e,code:n}),t.runner.error(e,n,(function(e){e&&t.close()}))}))}))}},{key:"on",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"close",value:function(){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.stop()}},{key:"onFinishInsert",value:function(e,t){this.on(Ei.FINISH,(function(n){$n.insertToInput(e,t,n)}))}},{key:"setMeta",value:function(e){this.meta=u(this.meta,e)}},{key:"setBackdropDescription",value:function(e){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.setBackgroundDescription(e)}},{key:"setBackdropTitle",value:function(e){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.setBackgroundTitle(e)}},{key:"setSuspendedRedirectUri",value:function(e){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.setSuspendedRedirectUri(e)}},{key:"setRedirectUrl",value:function(e){this.assertMethodSupport(this.runner,gi.REDIRECT)&&this.runner.setRedirectUrl(e)}},{key:"getSuccessRedirectUri",value:function(){return this.runner.getSuccessRedirectUri()}},{key:"turnOffBackdrop",value:function(){this.turnOffControlBackdrop(),this.turnOffLoaderBackdrop()}},{key:"turnOffControlBackdrop",value:function(){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.turnOffBackdrop()}},{key:"turnOffLoaderBackdrop",value:function(){var e;null===(e=this.background)||void 0===e||e.turnOffLoader()}},{key:"setEnv",value:function(e,t){var n;this.env=e,this.alias=t,null===(n=this.checkoutHandler)||void 0===n||n.setEnv(e),this.runner.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env}},{key:"getRunnerByMode",value:function(e,t){if(e===yi.PAYPAL){if(t===gi.REDIRECT)throw Error("".concat(Si," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return nr}if(e===yi.AFTERPAY){if(t===gi.REDIRECT)throw Error("".concat(Si," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return or}if(e===yi.ZIPMONEY)return t===gi.CONTEXTUAL?Xi:tr;throw Error("".concat(Si," Unsupported gateway."))}},{key:"assertMethodSupport",value:function(e,t){var n="".concat(Si," The method is not supported in the '").concat(t,"' mode.");switch(t){case gi.CONTEXTUAL:if(Ki(e))return!0;console.warn(n);break;case gi.REDIRECT:if(Yi(e))return!0;console.warn(n)}return!1}}])}(),ur=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:gi.CONTEXTUAL;return s(this,n),(r=t(this,n,[e,i,o,yi.ZIPMONEY,a])).publicKey=i,r.gatewayId=o,r.mode=a,r}return d(n,e),c(n,[{key:"setSuspendedRedirectUri",value:function(e){f(h(n.prototype),"setSuspendedRedirectUri",this).call(this,e)}},{key:"setRedirectUrl",value:function(e){Ki(this.runner)&&(f(h(n.prototype),"chooseRunner",this).call(this,yi.ZIPMONEY,gi.REDIRECT),f(h(n.prototype),"setEnv",this).call(this,this.env,this.alias)),f(h(n.prototype),"setRedirectUrl",this).call(this,e)}},{key:"buildAdditionalParams",value:function(){return u(u({},f(h(n.prototype),"buildAdditionalParams",this).call(this)),{public_key:this.publicKey,gateway_id:this.gatewayId})}}])}(lr),dr=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return s(this,n),(r=t(this,n,[e,i,o,yi.AFTERPAY])).accessToken=i,r.gatewayId=o,r.showETP=!1,r}return d(n,e),c(n,[{key:"showEnhancedTrackingProtectionPopup",value:function(e){var t=E.getBrowserInfo(),n=t.name,i=t.version;e&&"Firefox"===n&&+i>=100&&(this.showETP=!0)}},{key:"buildAdditionalParams",value:function(){var e=f(h(n.prototype),"buildAdditionalParams",this).call(this);return this.showETP&&(e.show_etp=!0),e}}])}(lr),hr=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return s(this,n),(r=t(this,n,[e,i,o,yi.PAYPAL])).publicKey=i,r.gatewayId=o,r}return d(n,e),c(n)}(lr),pr=function(){return c((function e(){s(this,e)}),null,[{key:"values",value:function(e){return Object.keys(e).map((function(t){return e[t]}))}}])}(),fr=function(){return c((function e(t,n){s(this,e),this.configs=[],this.configTokens=[],this.link=new Yn("/payment-sources"),this.link.setParams(u({query_token:n},Q.validateJWT(t)?{access_token:t}:{public_key:t})),J.version&&this.link.setParams({sdk_version:J.version,sdk_type:J.type})}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==pr.values(Ci).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"setLimit",value:function(e){this.link.setParams({limit:e})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"getIFrameUrl",value:function(){return this.link.getUrl()}},{key:"filterByGatewayIds",value:function(e){this.link.setParams({gateway_ids:e.join(",")})}},{key:"filterByTypes",value:function(e){var t,n=[],i=b(e);try{for(i.s();!(t=i.n()).done;){var r=t.value;e.hasOwnProperty(r)&&(-1===pr.values(Ti).indexOf(r)?console.warn("PaymentSourceWidget::filterByTypes: unsupported type ".concat(r)):n.push(r))}}catch(e){i.e(e)}finally{i.f()}this.link.setParams({payment_source_types:n.join(",")})}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),mr=function(e){function n(e,i,r){var o;return s(this,n),(o=t(this,n,[i,r])).container=new Jn(e),o.iFrame=new Xn(o.container),o.event=new Qn(window),o}return d(n,e),c(n,[{key:"load",value:function(){this.iFrame.load(this.getIFrameUrl(),{title:"Payment Sources"})}},{key:"on",value:function(e,t){this.event.on(e,this.link.getParams().widget_id,t)}},{key:"hide",value:function(e){console.info("PayDock SDK"),this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"onSelectInsert",value:function(e,t){this.on(Zn.SELECT,(function(n){$n.insertToInput(e,t,n)}))}}])}(fr);!function(e){e.IFRAME_LOADED="iframeLoaded",e.CHECKOUT_READY="checkoutReady",e.CHECKOUT_COMPLETED="checkoutCompleted",e.CHECKOUT_ERROR="checkoutError",e.CHECKOUT_POPUP_OPEN="checkoutPopupOpen",e.CHECKOUT_POPUP_CLOSE="checkoutPopupClose"}(ir||(ir={})),function(e){e.CRITICAL_ERROR="CriticalError",e.USER_ERROR="UserError",e.SUCCESS="Success"}(rr||(rr={}));var vr,gr={PRIMARY_BUTTON_COLOR:"primary_button_color",SECONDARY_BUTTON_COLOR:"secondary_button_color",PRIMARY_BUTTON_TEXT_COLOR:"primary_button_text_color",SECONDARY_BUTTON_TEXT_COLOR:"secondary_button_text_color",FONT_FAMILY:"font_family",ENABLE_SRC_POPUP:"enable_src_popup"},yr=function(){return c((function e(t,n,i,r,o,a,c,l){s(this,e),this.meta=r,this.eventEmitter=o,this.autoResize=a,this.link=new Yn("/secure-remote-commerce/mastercard"),this.link.setParams(u({service_id:n,public_key:i},r&&{meta:JSON.stringify(r)})),J.version&&this.link.setParams({sdk_version:J.version,sdk_type:J.type}),c&&this.link.setEnv(c,l),this.iFrameContainer=new Jn(t),this.iFrame=new Xn(this.iFrameContainer),this.iFrameEvent=new Qn(window),this.setupIFrameEvents()}),[{key:"setupIFrameEvents",value:function(){var e=this,t=this.link.getParams().widget_id;t&&(this.iFrameEvent.on(ir.CHECKOUT_READY,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_READY,n)})),this.iFrameEvent.on(ir.CHECKOUT_COMPLETED,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_COMPLETED,n)})),this.iFrameEvent.on(ir.CHECKOUT_POPUP_OPEN,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_POPUP_OPEN,n)})),this.iFrameEvent.on(ir.CHECKOUT_POPUP_CLOSE,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_POPUP_CLOSE,n)})),this.iFrameEvent.on(ir.CHECKOUT_ERROR,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_ERROR,n)})),this.autoResize&&this.useAutoResize(!0))}},{key:"load",value:function(){var e=this;this.iFrame.load(this.link.getUrl(),{title:"Click To Pay checkout"});var t=this.iFrame.getElement();this.iFrame.setStyle("width","100%"),t&&(t.onload=function(){return e.eventEmitter.emit(ir.IFRAME_LOADED,{})})}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"hideCheckout",value:function(e){this.iFrame&&this.iFrame.hide()}},{key:"showCheckout",value:function(){this.iFrame&&this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"useAutoResize",value:function(e){var t=this;if(!this.autoResize||e){this.autoResize=!0;var n=this.link.getParams();(null==n?void 0:n.widget_id)&&this.iFrameEvent.on("resize",n.widget_id,(function(e){var n,i,r=e.data,o=t.iFrame.getElement();o&&(o.scrolling="no",(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.height)&&t.iFrame.setStyle("height",(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.height)+"px"))}))}}}])}(),br=function(){return c((function e(t,n,i,r){s(this,e),this.iframe_selector=t,this.service_id=n,this.public_key_or_access_token=i,this.meta=r,this.autoResize=!1,this.style={},this.api=new pi(i,Dn.PUBLIC_KEY),this.eventEmitter=new vi}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==pr.values(gr).indexOf(e)?this.style[e]=t:console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){var e=this;this.provider||this.api.service().getConfig(this.service_id).then((function(t){var n=t.type;if(e.meta.customizations=e.style,n===ti.MASTERCARD_SRC)e.provider=new yr(e.iframe_selector,e.service_id,e.public_key_or_access_token,e.meta,e.eventEmitter,e.autoResize,e.env,e.alias);e.provider&&e.provider.load()}))}},{key:"setEnv",value:function(e,t){this.provider||(this.env=e,this.alias=t,this.api.setEnv(e,t))}},{key:"getEnv",value:function(){return this.provider?this.provider.getEnv():this.env}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"hideCheckout",value:function(e){this.provider&&"function"==typeof this.provider.hideCheckout&&this.provider.hideCheckout(e)}},{key:"showCheckout",value:function(){this.provider&&"function"==typeof this.provider.showCheckout&&this.provider.showCheckout()}},{key:"reload",value:function(){this.provider&&this.provider.reload()}},{key:"useAutoResize",value:function(){this.autoResize=!0,this.provider&&"function"==typeof this.provider.useAutoResize&&this.provider.useAutoResize()}}])}(),Er=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i,r,o])).iframe_selector=e,a.service_id=i,a.public_key_or_access_token=r,a.meta=o,a}return d(n,e),c(n,[{key:"load",value:function(){this.provider||(this.meta.customizations=this.style,this.provider=new yr(this.iframe_selector,this.service_id,this.public_key_or_access_token,this.meta,this.eventEmitter,this.autoResize,this.env,this.alias),this.provider.load())}}])}(br),wr={SUBMIT_FORM:"submit_form",CHANGE_TAB:"tab",HIDE_ELEMENTS:"hide_elements",SHOW_ELEMENTS:"show_elements",REFRESH_CHECKOUT:"refresh_checkout",UPDATE_FORM_VALUES:"update_form_values",INIT_CHECKOUT:"init_checkout"},kr=function(){return c((function e(t){s(this,e),this.iFrame=t}),[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===pr.values(wr).indexOf(e)&&console.warn("unsupported trigger type");var n={trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}();!function(e){e.AFTER_LOAD="after_load",e.SYSTEM_ERROR="system_error",e.CVV_SECURE_CODE_REQUESTED="cvv_secure_code_requested",e.CARD_NUMBER_SECURE_CODE_REQUESTED="card_number_secure_code_requested",e.ACCESS_FORBIDDEN="access_forbidden",e.SESSION_EXPIRED="session_expired",e.OPERATION_FORBIDDEN="operation_forbidden"}(vr||(vr={}));var Sr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"on",value:function(e,t,n){for(var i in vr)vr.hasOwnProperty(i)&&e===vr[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(Qn),Tr=function(){return c((function e(t,n){s(this,e),this.validationData={},this.configs=[],this.container=new Jn(t),this.iFrame=new Xn(this.container),this.triggerElement=new kr(this.iFrame),this.event=new Sr(window),this.vaultDisplayToken=n,this.link=new Yn("/vault-display"),this.link.setParams({vault_display_token:n})}),[{key:"setEnv",value:function(e,t){this.link.setEnv(e,t)}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==pr.values(Ci).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){this.iFrame.load(this.link.getUrl(),{title:"Vault Display"})}}])}(),_r={UNAVAILABLE:"unavailable",UPDATE:"update",PAYMENT_METHOD_SELECTED:"payment_method_selected",PAYMENT_SUCCESS:"payment_success",PAYMENT_IN_REVIEW:"payment_in_review",PAYMENT_ERROR:"payment_error",CALLBACK:"callback",AUTH_TOKENS_CHANGED:"auth_tokens_changed",BUTTON_CLICK:"button_click",CHECKOUT_OPEN:"checkout_open",CHECKOUT_CLOSE:"checkout_close"},Cr=function(){return c((function e(t,n){s(this,e),this.publicKey=t,this.meta=n,this.env=G,this.eventEmitter=new vi,this.initializeChildWallets()}),[{key:"initializeChildWallets",value:function(){this.childWallets=[]}},{key:"getGatewayName",value:function(){throw new Error("Method not implemented")}},{key:"setEnv",value:function(e){return this.env=e,this}},{key:"load",value:function(e){this.childWallets.forEach((function(t){return t.load(e)}))}},{key:"update",value:function(e){}},{key:"enable",value:function(){}},{key:"disable",value:function(){}},{key:"on",value:function(e,t){var n=this;if(-1===pr.values(_r).indexOf(e))throw new Error("invalid wallet event");return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}}])}(),Or=function(e){function n(e,i){var r;return s(this,n),(r=t(this,n,[e,i])).token=e,r.storageDispatcher=new er("afterpay.wallet.paydock"),r}return d(n,e),c(n,[{key:"load",value:function(e){var t=this;this.storageDispatcher.create((function(){return t.mount(e)}))}},{key:"setEnv",value:function(e){return f(h(n.prototype),"setEnv",this).call(this,e),this.storageDispatcher.setEnv(e),this}},{key:"mount",value:function(e){var t,n,i,r,s=this,a={};(null===(t=this.meta)||void 0===t?void 0:t.style)&&"object"===o(null===(n=this.meta)||void 0===n?void 0:n.style)&&(a=JSON.parse(JSON.stringify((null===(i=this.meta)||void 0===i?void 0:i.style.afterpay)||(null===(r=this.meta)||void 0===r?void 0:r.style))));var c=this.getButton(a);c.onclick=function(){return s.onAfterPayButtonClicked()};var l=this.getButtonStyle(a);e.getElement().appendChild(c),e.getElement().appendChild(l)}},{key:"onAfterPayButtonClicked",value:function(){var e,t,n=this,i=document.createElement("script"),r=null===(e=this.meta)||void 0===e?void 0:e.country;i.type="text/javascript",i.src="live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"https://portal.afterpay.com/afterpay.js":"https://portal.sandbox.afterpay.com/afterpay.js",i.async=!0,i.defer=!0,i.onload=function(){window.AfterPay.initialize({countryCode:r}),n.storageDispatcher.push({intent:$i.WIDGET_SESSION,data:{token:n.token}},{onSuccess:function(){n.getCheckoutSession().then((function(e){window.AfterPay.redirect({token:e.ref_token})})).catch((function(e){window.AfterPay.close(),n.eventEmitter.emit(_r.UNAVAILABLE,{err:e})}))},onError:function(){console.error("Error initializing Afterpay wallet"),window.AfterPay.close(),n.eventEmitter.emit(_r.UNAVAILABLE,{})}})},document.head.appendChild(i)}},{key:"getCheckoutSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(_r.CALLBACK,{data:{request_type:"CREATE_SESSION",wallet_type:ki.AFTERPAY},onSuccess:function(e){t(e)},onError:function(e){n(e)}})}))}},{key:"getButton",value:function(e){var t=document.createElement("button");return t.classList.add("afterpay-checkout-btn"),t.setAttribute("type","button"),t.innerHTML='\n <div class="afterpay-checkout-btn__wrapper">\n <svg viewBox="0 0 390 94"\n height="'.concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <g fill="currentColor">\n <path\n d="M388.6 21.4l-34.8 71.8h-14.4l13-26.8-20.5-45h14.8l13.2 30.1 14.3-30.1zM41 46.9c0-8.6-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4C11 73.2.4 62 .4 46.9c0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51H41.1zM114.6 61.1c-4.4 0-5.6-1.6-5.6-5.9V32.5h8.1V21.4H109V8.9H96.1v12.4H79.5v-5.1c0-4.3 1.6-5.9 6.1-5.9h2.8V.4h-6.2C71.6.4 66.6 3.9 66.6 14.5v6.8h-7.1v11.1h7.1v39.9h12.9V32.5h16.6v25c0 10.4 4 14.9 14.4 14.9h6.6V61.1h-2.5zM160.7 42.3c-.9-6.6-6.3-10.6-12.6-10.6s-11.5 3.9-12.9 10.6h25.5zm-25.6 7.9c.9 7.5 6.3 11.8 13.2 11.8 5.4 0 9.6-2.6 12-6.6h13.2c-3.1 10.8-12.7 17.7-25.5 17.7-15.4 0-26.2-10.8-26.2-26.2 0-15.4 11.4-26.5 26.5-26.5 15.2 0 26.2 11.2 26.2 26.5 0 1.1-.1 2.2-.3 3.3h-39.1zM256.2 46.9c0-8.3-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.4 13.9-14.6m-40.4 46.3V21.4h12.5V28c3.8-4.7 9.4-7.5 16.1-7.5 13.8 0 24.6 11.3 24.6 26.3s-11 26.4-24.9 26.4c-6.4 0-11.7-2.6-15.4-6.8v26.8h-12.9zM314.2 46.9c0-8.6-6.2-14.6-13.9-14.6-7.6 0-13.9 6.1-13.9 14.6 0 8.4 6.2 14.6 13.9 14.6s13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4-14 0-24.6-11.2-24.6-26.3 0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51h-12.5zM193.2 26.4s3.2-5.9 11-5.9c3.3 0 5.5 1.2 5.5 1.2v13s-4.7-2.9-9.1-2.3c-4.3.6-7.1 4.6-7.1 9.9v30.2h-13v-51H193v4.9h.2z" />\n </g>\n </svg>\n <svg viewBox="0 0 107 96"\n height="').concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <path\n d="M99 19.5L84.2 11l-15-8.6c-10-5.7-22.4 1.5-22.4 13v1.9c0 1.1.6 2 1.5 2.6l7 4c1.9 1.1 4.4-.3 4.4-2.5v-4.6c0-2.3 2.5-3.7 4.4-2.6l13.8 7.9L91.6 30c2 1.1 2 4 0 5.1L77.9 43l-13.8 7.9c-2 1.1-4.4-.3-4.4-2.6V46c0-11.5-12.4-18.7-22.4-13l-15 8.6-14.8 8.5c-10 5.7-10 20.2 0 26l14.8 8.5 15 8.6c10 5.7 22.4-1.5 22.4-13v-1.9c0-1.1-.6-2-1.5-2.6l-7-4c-1.9-1.1-4.4.3-4.4 2.5v4.6c0 2.3-2.5 3.7-4.4 2.6l-13.8-7.9-13.7-7.9c-2-1.1-2-4 0-5.1l13.7-7.9 13.8-7.9c2-1.1 4.4.3 4.4 2.6v2.3c0 11.5 12.4 18.7 22.4 13l15-8.6L99 45.5c10.1-5.8 10.1-20.2 0-26"\n fill="currentColor" />\n </svg>\n </div>\n '),t}},{key:"getButtonStyle",value:function(e){var t=document.createElement("style"),n=this.generateButtonColor(e.button_type);return t.innerText="\n .afterpay-checkout-btn {\n outline: none;\n border: none;\n border-radius: ".concat(this.getHeight(e),";\n padding: 0;\n margin: 0;\n transition: all 300ms;\n cursor: pointer;\n }\n\n .afterpay-checkout-btn:active {\n opacity: 0.7;\n }\n\n .afterpay-checkout-btn__wrapper {\n display: flex;\n align-items: center;\n padding: 10px 20px;\n color: ").concat(n.color,";\n background-color: ").concat(n.background,";\n border-radius: ").concat(this.getHeight(e),";\n }\n "),t}},{key:"generateButtonColor",value:function(e){switch(e){case"black":return{color:"#B2FCE3",background:"#000"};case"mint":return{color:"#000",background:"#B2FCE3"};default:return{color:"#fff",background:"#000"}}}},{key:"getHeight",value:function(e){return e.height?Number.isNaN(Number(e.height))?e.height:"".concat(e.height,"px"):"40px"}}])}(Cr);var Nr=class{DEFAULT_WIDTH=450;DEFAULT_HEIGHT=750;DEFAULT_FEATURES={resizable:"no"};auth;callback;error;frame;isCheckoutOpen;onMessage;url;orderId;accessToken;refreshToken;clientId;onCheckoutClosed;redirectUrl;rootUrl;targetOrigin;title;windowFeatures;windowObserver;constructor({auth:e,url:t,clientId:n,mode:i,orderId:r,onCheckoutClosed:o,onError:s,onTokensChanged:a,onPaymentSuccess:c,onPaymentError:l,redirectUrl:u,title:d,windowFeatures:h}){this.callback={ERROR({error:e,orderId:t}){s?.({error:e,orderId:t})},PAYMENT_ERROR({error:e,orderId:t}){l?.({error:e,orderId:t})},PAYMENT_SUCCESS({orderId:e}){c?.({orderId:e})},TOKENS_CHANGED({accessToken:e,refreshToken:t}){a?.({accessToken:e,refreshToken:t})}},this.auth=e,this.isCheckoutOpen=!1,this.error=void 0,this.frame=void 0,this.onMessage=e=>{const{data:n,origin:i}=e;i===t&&(!0===n?.isDomReady&&this.postMessage(),n?.isPaymentSuccessful&&this.callback.PAYMENT_SUCCESS({orderId:n.orderId}),!n?.isPaymentSuccessful&&n?.error&&this.callback.PAYMENT_ERROR({orderId:n.orderId,error:n.error}),!n?.paymentFlowState&&n?.error&&this.callback.ERROR({orderId:n.orderId,error:n.error}),n?.accessToken&&n?.refreshToken&&this.callback.TOKENS_CHANGED({accessToken:n.accessToken,refreshToken:n.refreshToken}))};const p=i||"default",f=u?`&redirectUrl=${u}`:"",m=n?`&clientId=${n}`:"";this.rootUrl=t.replaceAll(/\/+$/g,""),this.targetOrigin=window.location.href.replace(/\/$/,""),this.url=`${this.rootUrl}?orderId=${r}&merchantUrl=${encodeURIComponent(this.targetOrigin)}&mode=${p}${f}${m}`,this.orderId=r,this.clientId=n,this.onCheckoutClosed=o,this.title=d,this.windowFeatures=h,this.windowObserver=void 0}get isWindowObserverOpen(){return!!this.windowObserver}open=()=>{this.isCheckoutOpen?this.frame?.focus():(this.frame=window.open(this.url,this.title,this.getFeatures()),this.isCheckoutOpen=!0,this.startWindowObserver())};close=()=>{this.frame?.close(),this.frame=void 0,this.isCheckoutOpen=!1,this.stopWindowObserver()};listenMessage=()=>{this.onMessage&&window.addEventListener("message",this.onMessage,!1)};postMessage=()=>{this.frame&&this.rootUrl&&this.frame.postMessage({auth:{...this.auth}},this.rootUrl)};getFeatures(){const e=this.windowFeatures?.width||this.DEFAULT_WIDTH,t=this.windowFeatures?.height||this.DEFAULT_HEIGHT,n={...this.DEFAULT_FEATURES,...this.windowFeatures};return function(e,t="="){return Object.keys(e).length?Object.entries(e).reduce(((e,[n,i])=>[...e,`${n}${t}${i}`]),[]).join(","):""}({...this.getCenteredPosition(e,t),...n,width:e,height:t})}getCenteredPosition(e,t){return{left:screen.width/2-e/2,top:screen.height/2-t/2}}startWindowObserver(){this.isWindowObserverOpen||(this.windowObserver=setInterval((()=>{this.frame?.closed&&(this.close(),this.onCheckoutClosed?.({orderId:this.orderId}),this.onMessage&&window.removeEventListener("message",this.onMessage))}),300))}stopWindowObserver(){clearInterval(this.windowObserver)}},Ir=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return s(this,n),(i=t(this,n)).bgImageUrl=e,i.hideCloseButton=r,i.hideContinueButton=o,i.imageStyle=null,i}return d(n,e),c(n,[{key:"initControl",value:function(){this.imageStyle||this.createImageStyles(),f(h(n.prototype),"initControl",this).call(this)}},{key:"clear",value:function(){this.imageStyle&&this.imageStyle.parentNode.removeChild(this.imageStyle),this.imageStyle=null,f(h(n.prototype),"clear",this).call(this)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <div class="checkout-bg-logo"></div>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');!0===this.hideCloseButton&&(n=n.replace('<a href="#" data-close>Close</a>',"")),!0===this.hideContinueButton&&(n=n.replace('<a href="#" data-continue>Continue</a>',"")),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createImageStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .checkout-bg-logo {\n display: block;\n background: url({{url}}) no-repeat;\n width: 100px;\n height: 50px;\n margin: 0 auto;\n border-radius: 10px;\n background-size: contain;\n }\n [data-continue] {\n margin-top: 24px;\n display: block;\n font-family: Helvetica, sans-serif;\n text-decoration: none;\n color: #fff !important;\n border: 1px solid white;\n width: 100px;\n border-radius: 16px;\n padding: 5px;\n }\n [data-continue]:hover {\n background-color: #f2f2f2;\n border: none;\n color: rgba(0, 0, 0, 0.7) !important;\n }\n .checkout-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .checkout-overlay {\n z-index: 2147483647;\n }\n\n .checkout-container [data-close] {\n opacity: 1;\n }\n .checkout-container [data-close]:before,\n .checkout-container [data-close]:after {\n background-color: #fff;\n }\n");document.querySelector(".checkout-container"),t=t.replace("{{url}}",this.bgImageUrl),this.imageStyle=document.createElement("style"),this.imageStyle.type="text/css",this.imageStyle.appendChild(document.createTextNode(t)),e.appendChild(this.imageStyle)}}])}(ji);function Ar(e){return xr("paydock-flypay-button",e)}function Rr(e){return"flypay-v2-checkout-btn__wrapper__".concat(e)}function xr(e,t){return'\n <div id="'.concat(t,'-loading-overlay"></div>\n <div class="').concat(e,'" tabindex="0">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 125.2 21" data-name="pay-with-flypay"\n style="grid-area: center; width: 100%; height: 100%"\n fill="none"\n >\n <path\n fill="#fff"\n d="M89 .5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM98 22.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM87 3.5a.5.5 0 0 1 .5-.5H121c.758 0 1.42.031 1.974.133.553.102 1.044.284 1.421.618.78.694.849 1.829.598 3.331-.258 1.552-1.025 3.843-1.711 5.715a100.003 100.003 0 0 1-1.211 3.128l-.081.198-.021.051v.001c-.531 1.583-1.345 2.557-2.269 3.126-.92.566-1.898.699-2.7.699H96.5a.5.5 0 1 1 0-1v.5-.5H117c.698 0 1.47-.117 2.175-.55.697-.43 1.382-1.2 1.851-2.608l.005-.017.008-.018.006-.016.021-.05.079-.194a94.823 94.823 0 0 0 1.198-3.094c.689-1.878 1.422-4.087 1.664-5.535.249-1.498.068-2.113-.277-2.42-.186-.165-.476-.296-.938-.381C122.33 4.03 121.742 4 121 4H87.5a.5.5 0 0 1-.5-.5ZM76.512 9.512h3.157V7.34h-3.157v-.01h-.02c.01-1.196.841-2.17 2.52-2.17H81V3h-1.988C75.547 3 74.008 4.936 74 7.326V16h2.512V9.512ZM82 3.55 84.987 3H85v13h-3V3.55Z"\n />\n <path\n fill="#fff"\n d="M91.592 15.365a4.557 4.557 0 0 1-1.595.33c-2.391 0-4-1.68-3.997-4.092V7.546l2.41-.543V11.6c0 1.118.536 1.738 1.59 1.738 1.055 0 1.592-.622 1.592-1.738V7.543L94 7v9.855C94 19.41 92.497 21 90.073 21h-.596v-2.359h.59c.71 0 1.525-.641 1.525-1.786v-1.49Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M2.54 11.6h2.598c1.356 0 2.399-.299 3.129-.896.731-.598 1.096-1.62 1.096-3.063 0-1.323-.365-2.3-1.096-2.93-.73-.631-1.71-.947-2.938-.947H0V16h2.54v-4.4Zm4.291-3.943c0 .637-.166 1.102-.498 1.395-.337.293-.808.44-1.411.44H2.54V5.889h2.382c.603 0 1.071.136 1.403.407.337.271.506.725.506 1.361ZM14.651 6.736c-1.522 0-2.596.398-3.221 1.195-.393.51-.614 1.16-.664 1.95h2.283c.055-.348.166-.624.332-.83.232-.276.628-.414 1.187-.414.498 0 .874.072 1.128.216.261.138.391.392.391.763 0 .305-.169.529-.507.673-.188.083-.501.152-.938.207l-.805.1c-.913.116-1.605.31-2.075.58-.858.499-1.287 1.304-1.287 2.416 0 .858.266 1.522.797 1.993.537.464 1.215.697 2.034.697.642 0 1.217-.147 1.726-.44a4.83 4.83 0 0 0 1.129-.905c.017.205.039.388.067.548.027.16.077.332.149.515h2.573v-.349a.843.843 0 0 1-.348-.274c-.078-.11-.125-.32-.141-.63-.011-.41-.017-.759-.017-1.047V9.55c0-1.09-.385-1.832-1.154-2.225-.769-.393-1.649-.59-2.639-.59Zm-.648 7.828c-.321 0-.592-.092-.813-.274-.227-.177-.341-.468-.341-.872 0-.454.183-.788.548-1.004.216-.128.573-.236 1.071-.324l.531-.1c.266-.05.473-.102.623-.157.155-.061.307-.139.456-.233v.88c-.016.791-.24 1.336-.672 1.635a2.39 2.39 0 0 1-1.403.449Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m26.097 6.952-1.867 6.674-1.976-6.674h-2.631l3.32 9.446c.022.066-.028.25-.149.548-.117.299-.244.495-.382.59-.144.099-.321.162-.531.19a3.752 3.752 0 0 1-.665.025l-.298-.017v1.893c.254.017.445.025.572.025.128.005.296.008.507.008 1.046 0 1.743-.207 2.092-.622.348-.41.821-1.472 1.419-3.188l3.104-8.898h-2.515ZM40.192 9.409l1.419 6.59h2.433l2.623-9.047h-2.466l-1.411 6.516-1.378-6.516h-2.399l-1.303 6.491-1.411-6.491h-2.54L36.299 16h2.457l1.436-6.591ZM50.41 16V6.952h-2.399V16h2.399ZM50.41 5.873V3.689h-2.399v2.184h2.399ZM56.852 16.083v-1.768l-.241.016h-.224c-.482 0-.769-.044-.863-.133-.094-.094-.142-.326-.142-.697V8.72h1.47V7.035h-1.47V4.51h-2.34v2.524H51.78V8.72h1.262v5.57c0 .564.132.982.398 1.253.41.426 1.173.62 2.291.581l1.121-.041ZM66.547 16v-5.313c0-.808-.028-1.389-.083-1.743a2.347 2.347 0 0 0-.457-1.046 2.656 2.656 0 0 0-1.128-.888 3.836 3.836 0 0 0-1.519-.29c-.499 0-.974.104-1.428.315-.448.204-.844.57-1.187 1.095V3.806h-2.358V16h2.358v-4.898c0-.775.16-1.37.481-1.785.327-.42.803-.63 1.428-.63.603 0 1.013.21 1.228.63.167.3.25.692.25 1.18V16h2.415Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M103 16h1.997l1.276-2.003h3.56l.265 2.003H112l-1.337-9h-1.778L103 16Zm6.231-6.674.383 2.954h-2.237l1.854-2.954ZM98.02 16l.754-2.72h1.752a6.36 6.36 0 0 0 1.762-.228c.512-.139.992-.37 1.412-.683.398-.299.721-.677.95-1.107.24-.465.36-.978.349-1.496 0-.772-.239-1.389-.716-1.85a2.871 2.871 0 0 0-1.195-.7A5.816 5.816 0 0 0 101.401 7h-2.926L96 16h2.02Zm3.307-7.205c.257-.007.512.026.757.097.194.06.368.165.51.304.101.098.18.215.232.344a.977.977 0 0 1 .072.402c.012.232-.039.463-.147.671-.108.209-.27.387-.471.519-.413.279-.955.418-1.635.418h-1.38l.751-2.752h1.314l-.003-.003Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m113.439 16 .982-3.548L112.5 7h2.266l1.087 3.73L119.112 7h2.388l-5.078 5.63-.939 3.37h-2.044Z"\n />\n </svg>\n </div>\n ')}var Mr,Pr=function(e){function n(e,i){var r;if(s(this,n),(r=t(this,n,[e,i])).widgetId=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),r.onFlypayV2ButtonClick=function(){var e=function(e){var t,n=document.getElementById((t=r.widgetId,"".concat(t,"-loading-overlay")));n&&(n.style.display=e)};r.disable(),e("flex"),r.handleMerchantOnButtonClickEvent().then((function(){var t=function(t){var n;e("none"),r.background=r.initBackground(),r.orderId?(null===(n=r.background)||void 0===n||n.initControl(),r.flypayV2Checkout(r.orderId)):r.eventEmitter.emit(_r.UNAVAILABLE)};r.orderId?t(r.orderId):r.getOrderId().then((function(e){r.orderId=e,t()})).catch((function(t){!function(t){var n;null===(n=r.background)||void 0===n||n.clear(),e("none"),r.enable(),r.eventEmitter.emit(_r.UNAVAILABLE,{err:t})}(t)}))})).catch((function(t){e("none"),r.enable()}))},r.accessToken=null==i?void 0:i.access_token,r.refreshToken=null==i?void 0:i.refresh_token,!(null==i?void 0:i.client_id))throw new Error("Wallet meta `client_id` is required as part of initialization process.");return r.link=new Yn(""),r}return d(n,e),c(n,[{key:"load",value:function(e){this.mount(e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),f(h(n.prototype),"setEnv",this).call(this,e)}},{key:"enable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!1,this.flypayV2Button.innerHTML=Ar(this.widgetId))}},{key:"disable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!0,this.flypayV2Button.innerHTML=xr("paydock-flypay-button paydock-flypay-button__disabled",this.widgetId))}},{key:"mount",value:function(e){this.flypayV2Button=this.getButton(),this.flypayV2Button.onclick=this.onFlypayV2ButtonClick,e.getElement().appendChild(this.flypayV2Button)}},{key:"getButton",value:function(){var e,t,n=document.createElement("style");return n.innerHTML=(e=this.widgetId,t=Rr(e),"\n .".concat(t," {\n position: relative;\n height: 100%;\n width: 100%;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .").concat(t,' .paydock-flypay-button {\n background-color: #212121;\n border-radius: 9999px;\n width: 100%; /* set hard pixel dimensions here for a button with intrinsic dimensions */\n height: 100%; /* and leave the 100% settings for the Coles use case (enabled by extra param object flag) */\n display: grid;\n grid-template-columns: 20% 1fr 20%;\n grid-template-rows: 20% 1fr 20%;\n grid-template-areas:\n ". . ."\n ". center ."\n ". . .";\n box-sizing: border-box;\n }\n \n .').concat(t," .paydock-flypay-button:hover {\n background-color: #3d3d3d;\n }\n \n .").concat(t," .paydock-flypay-button:focus-visible {\n outline-color: transparent;\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2670ee;\n outline-color: transparent;\n }\n \n .").concat(t," .paydock-flypay-button:active {\n background-color: #6f6f6f;\n }\n \n .").concat(t," .paydock-flypay-button:disabled,\n .").concat(t," .paydock-flypay-button__disabled {\n opacity: 25%;\n cursor: not-allowed;\n }\n \n #").concat(e,"-loading-overlay {\n position: absolute;\n height: 100%;\n width: 100%;\n background: rgba(255, 255, 255, 0.7);\n display: none;\n justify-content: center;\n align-items: center;\n cursor: not-allowed; /* Make it look not clickable */ \n }\n \n #").concat(e,'-loading-overlay::after {\n content: "";\n height: 60%;\n aspect-ratio: 1 / 1;\n display: inline-block;\n border: 4px solid #ccc;\n border-top-color: #333;\n border-radius: 50%;\n /* Vendor prefixes for animation property */\n -webkit-animation: spin 1s infinite linear;\n -moz-animation: spin 1s infinite linear;\n -o-animation: spin 1s infinite linear;\n animation: spin 1s infinite linear;\n }\n \n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); \n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-moz-keyframes spin {\n 0% {\n -moz-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -moz-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-o-keyframes spin {\n 0% {\n -o-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -o-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n } \n ')),document.head.appendChild(n),this.flypayV2Button=document.createElement("button"),this.flypayV2Button.classList.add(Rr(this.widgetId)),this.flypayV2Button.setAttribute("type","button"),this.flypayV2Button.setAttribute("aria-label","Pay with flypay"),this.flypayV2Button.setAttribute("id",this.widgetId),this.flypayV2Button.innerHTML=Ar(this.widgetId),this.flypayV2Button}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"getOrderId",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(_r.CALLBACK,{data:{request_type:"CREATE_SESSION"},onSuccess:function(e){return t(e.id)},onError:function(e){return n(e.error)}})}))}},{key:"flypayV2Checkout",value:function(e){var t,n=this;this.checkout=new Nr(u(u({orderId:e},this.accessToken&&this.refreshToken&&{auth:{access_token:this.accessToken,refresh_token:this.refreshToken},mode:"express"}),{clientId:this.meta.client_id,url:"live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"https://checkout.flypay.com.au":"https://checkout.sandbox.cxbflypay.com.au",onCheckoutClosed:function(){var e;n.eventEmitter.emit(_r.CHECKOUT_CLOSE),null===(e=n.background)||void 0===e||e.clear(),n.enable()},onError:function(e){return n.eventEmitter.emit(_r.PAYMENT_ERROR,{error:e})},onPaymentSuccess:function(e){return n.eventEmitter.emit(_r.PAYMENT_SUCCESS,e)},onPaymentError:function(e){return n.eventEmitter.emit(_r.PAYMENT_ERROR,{error:e})},onTokensChanged:function(e){var t=e.accessToken,i=e.refreshToken;n.accessToken=t,n.refreshToken=i,n.eventEmitter.emit(_r.AUTH_TOKENS_CHANGED,{accessToken:t,refreshToken:i})}})),this.checkout.open(),this.checkout.isCheckoutOpen&&this.eventEmitter.emit(_r.CHECKOUT_OPEN,{}),this.checkout.listenMessage()}},{key:"initBackground",value:function(){var e=this,t=new Ir(this.link.getNetUrl()+Kn,!1,!1);return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Fi,(function(){var t;e.checkout.close(),null===(t=e.background)||void 0===t||t.clear(),e.enable()})),t.onTrigger(Ui,(function(){return e.checkout.open()})),t}}])}(Cr);!function(e){e.AFTER_LOAD="after_load",e.UNAVAILABLE="unavailable",e.START_LOADING="start_loading",e.END_LOADING="end_loading",e.UPDATE="update",e.PAYMENT_SUCCESSFUL="payment_successful",e.PAYMENT_IN_REVIEW="payment_in_review",e.PAYMENT_ERROR="payment_error"}(Mr||(Mr={}));var Dr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"on",value:function(e,t,n){for(var i in Mr)Mr.hasOwnProperty(i)&&e===Mr[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(Qn),Lr={CLOSE:"close",UPDATED:"updated"},Fr=function(e){function n(e,i){var r;return s(this,n),(r=t(this,n,[e])).widgetId=i,r}return d(n,e),c(n,[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===pr.values(Lr).indexOf(e)&&console.warn("unsupported trigger type");var n={message_source:"wallet.paydock",reference_id:this.widgetId,trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}(kr),Ur=function(e){function n(e,i){var r;s(this,n),(r=t(this,n,[e,i])).link=new Yn(Gn);var o=i.amount,a=i.currency,c=i.id,l=i.gateway_mode,d=i.reference,h=i.request_shipping;return r.link.setParams(u({token:e,amount:o,currency:a,gateway_mode:l,credentials:d||c},h?{request_shipping:h}:{})),J.version&&r.link.setParams({sdk_version:J.version,sdk_type:J.type}),r.token=e,r.event=new Dr(window),r}return d(n,e),c(n,[{key:"load",value:function(e){this.container=e,this.iFrame=new Xn(this.container);var t=this.link.getParams().widget_id;this.triggerElement=new Fr(this.iFrame,t),this.setupIFrameEvents(t),this.background=this.initBackground(),this.iFrame.load(this.link.getUrl())}},{key:"close",value:function(){this.triggerElement.push(Lr.CLOSE),this.background.clear()}},{key:"update",value:function(e){this.triggerElement.push(Lr.UPDATED,e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),this}},{key:"initBackground",value:function(){var e=this,t=new Ir(this.link.getNetUrl().replace(Gn,Kn));return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Fi,(function(){return e.triggerElement.push(Lr.CLOSE)})),t}},{key:"setupIFrameEvents",value:function(e){var t=this;this.event.on(Mr.UNAVAILABLE,e,(function(e){return t.eventEmitter.emit(_r.UNAVAILABLE,null)})),this.event.on(Mr.START_LOADING,e,(function(e){return t.background.initControl()})),this.event.on(Mr.END_LOADING,e,(function(e){return t.background.clear()})),this.event.on(Mr.UPDATE,e,(function(e){t.eventEmitter.emit(_r.UPDATE,t.parseUpdateData(e))})),this.event.on(Mr.PAYMENT_SUCCESSFUL,e,(function(e){t.eventEmitter.emit(_r.PAYMENT_SUCCESS,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(Mr.PAYMENT_IN_REVIEW,e,(function(e){t.eventEmitter.emit(_r.PAYMENT_IN_REVIEW,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(Mr.PAYMENT_ERROR,e,(function(e){t.eventEmitter.emit(_r.PAYMENT_ERROR,e),t.iFrame.getElement()||t.background.clear()}))}},{key:"parsePaymentSuccessfulData",value:function(e){var t;return{id:this.meta.id,amount:e.amount,currency:e.currencyCode,status:null===(t=e.charge)||void 0===t?void 0:t.status}}},{key:"parseUpdateData",value:function(e){return u(u(u({wallet_response_code:e.responseCode,wallet_session_id:e.sessionId},e.paymentMethodDetails?{payment_source:{wallet_payment_method_id:e.paymentMethodDetails.paymentMethodId,card_number_last4:e.paymentMethodDetails.lastFourDigitsOfPan,card_scheme:e.paymentMethodDetails.paymentScheme}}:{}),e.loyaltyAccountSummary?{wallet_loyalty_account:{id:e.loyaltyAccountSummary.loyaltyAccountId,barcode:e.loyaltyAccountSummary.loyaltyAccountBarcode}}:{}),e.deliveryAddressDetails?{shipping:{address_line1:e.deliveryAddressDetails.line1,address_line2:e.deliveryAddressDetails.line2,address_postcode:e.deliveryAddressDetails.postalCode,address_city:e.deliveryAddressDetails.city,address_state:e.deliveryAddressDetails.state,address_country:e.deliveryAddressDetails.countryCode,address_company:e.deliveryAddressDetails.companyName,wallet_address_id:e.deliveryAddressDetails.addressId,post_office_box_number:e.deliveryAddressDetails.postOfficeBoxNumber,wallet_address_created_timestamp:e.deliveryAddressDetails.createdTimestamp,wallet_address_updated_timestamp:e.deliveryAddressDetails.updatedTimestamp,wallet_address_name:e.deliveryAddressDetails.name}}:{})}}])}(Cr),jr=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i])).gatewayName=r,a.eventEmitter=o,a.latestShippingData={},a.onCancelPayment=function(e){return a.eventEmitter.emit(_r.CHECKOUT_CLOSE)},a.onValidateMerchant=function(e){a.handleMerchantOnButtonClickEvent().then((function(){a.getMerchantSession().then((function(e){a.paymentSession.completeMerchantValidation(e)})).catch((function(e){console.error("Error fetching merchant session",e),a.paymentSession.abort()}))})).catch((function(e){console.error("Error while processing merchant callback",e),a.paymentSession.abort()}))},a.onPaymentAuthorized=function(e){var t,n=e.payment,i=n.token,r=n.billingContact,o=n.shippingContact;a.latestShippingData.shippingContact=o;var s=null===(t=a.selectedShippingOption)||void 0===t?void 0:t.type,c=[null==o?void 0:o.givenName,null==o?void 0:o.familyName].join(" ").trim();a.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:u({customer:{payment_source:u(u({wallet_type:ki.APPLE},c&&{card_name:c}),{type:i.paymentMethod.type,card_scheme:i.paymentMethod.network,address_line1:null==r?void 0:r.addressLines[0],address_line2:null==r?void 0:r.addressLines[1],address_country:null==r?void 0:r.countryCode,address_city:null==r?void 0:r.locality,address_postcode:null==r?void 0:r.postalCode,address_state:null==r?void 0:r.administrativeArea,ref_token:i.paymentData?JSON.stringify(i.paymentData):""})}},a.meta.request_shipping&&o&&{shipping:u(u(u({},s&&{method:s}),a.hasShippingOptions()&&{options:a.meta.shipping_options}),{address_line1:o.addressLines[0],address_line2:o.addressLines[1],address_country:o.countryCode,address_city:o.locality,address_postcode:o.postalCode,address_state:o.administrativeArea,contact:{first_name:o.givenName,last_name:o.familyName,email:o.emailAddress,phone:o.phoneNumber}})}),onSuccess:function(){return a.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS)},onError:function(){return a.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE)}})},a.onShippingContactSelected=function(e){a.latestShippingData.shippingContact=e.shippingContact;var t=a.parseUpdateData(a.latestShippingData);return a.eventEmitter.emit(_r.UPDATE,t),new Promise((function(e,t){a.latestShippingChangePromiseResolve=e,a.latestShippingChangePromiseReject=t}))},a.onShippingMethodSelected=function(e){var t,n;a.latestShippingData.shippingMethod=e.shippingMethod;var i={newTotal:{label:a.meta.amount_label||(null===(n=null===(t=a.getMetaRawDataInitialization())||void 0===t?void 0:t.total)||void 0===n?void 0:n.label),amount:a.meta.amount.toString(),type:"final"}};a.paymentSession.completeShippingMethodSelection(i)},a.parseUpdateData=function(e){var t,n,i,r,o,s,a,c;return u({shipping:{address_city:null===(t=null==e?void 0:e.shippingContact)||void 0===t?void 0:t.locality,address_state:null===(n=null==e?void 0:e.shippingContact)||void 0===n?void 0:n.administrativeArea,address_postcode:null===(i=null==e?void 0:e.shippingContact)||void 0===i?void 0:i.postalCode,address_country:null===(r=null==e?void 0:e.shippingContact)||void 0===r?void 0:r.countryCode}},(null==e?void 0:e.shippingMethod)&&{selected_shipping_option:{id:null===(o=null==e?void 0:e.shippingMethod)||void 0===o?void 0:o.identifier,label:null===(s=null==e?void 0:e.shippingMethod)||void 0===s?void 0:s.label,detail:null===(a=null==e?void 0:e.shippingMethod)||void 0===a?void 0:a.detail,amount:null===(c=null==e?void 0:e.shippingMethod)||void 0===c?void 0:c.amount}})},a.formatShippingOptions=function(e){return e.map((function(e){return{identifier:e.id,label:e.label,detail:(null==e?void 0:e.detail)||"",amount:e.amount}}))},a.eventEmitter=o,a}return d(n,e),c(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[ki.APPLE])||void 0===n?void 0:n.merchant)||""}},{key:"getMetaStyles",value:function(){var e,t,n;if((null===(e=this.meta)||void 0===e?void 0:e.style)&&"object"===o(null===(t=this.meta)||void 0===t?void 0:t.style)){var i=JSON.parse(JSON.stringify(null===(n=this.meta)||void 0===n?void 0:n.style));return"google"in i&&(null==i||delete i.google),"apple"in i?null==i?void 0:i.apple:i}return null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i;if((null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"object"===o(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)){var r=JSON.parse(JSON.stringify(null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization));return"google"in r&&(null==r||delete r.google),"apple"in r?null==r?void 0:r.apple:r}return null}},{key:"isShippingRequired",value:function(){var e;return null===(e=this.meta)||void 0===e?void 0:e.request_shipping}},{key:"hasShippingOptions",value:function(){var e,t;return(null===(e=this.meta)||void 0===e?void 0:e.request_shipping)&&!!(null===(t=this.meta)||void 0===t?void 0:t.shipping_options)}},{key:"load",value:function(e){var t=this;if(window.Promise)return this.checkAvailability().then((function(n){var i;n?(t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(i=t.meta)||void 0===i?void 0:i.shipping_options[0],t.latestShippingData.shippingMethod=t.formatShippingOptions([t.selectedShippingOption])[0]),t.mount(e)):t.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.APPLE})})).catch((function(e){return console.error("Error checking ApplePay availability",e)}));this.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.APPLE})}},{key:"update",value:function(e){var t,n,i;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success||!e.body)return this.latestShippingChangePromiseReject();var r=null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount,o=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;r&&(this.meta.amount=r),o&&(this.meta.shipping_options=o,this.selectedShippingOption=o?o[0]:void 0);var s=u({newTotal:{label:null===(i=this.meta)||void 0===i?void 0:i.amount_label,amount:this.meta.amount.toString(),type:"final"}},this.isShippingRequired()&&this.hasShippingOptions()&&{newShippingMethods:this.formatShippingOptions(this.meta.shipping_options)});this.paymentSession.completeShippingContactSelection(s),this.latestShippingChangePromiseResolve({})}}},{key:"checkAvailability",value:function(){var e=this;return new Promise((function(t,n){window.ApplePaySession&&ApplePaySession||t(!1),ApplePaySession.canMakePaymentsWithActiveCard(e.getMerchantId()).then((function(e){return t(e)})).catch((function(e){return t(!1)}))}))}},{key:"mount",value:function(e){var t=this,n=document.createElement("style");n.innerHTML=this.createButtonStyle(),document.head.appendChild(n);var i=document.createElement("div");i.onclick=function(){return t.onApplePayButtonClicked()},i.classList.add("paydock-apple-container","apple-pay-button","apple-pay-button-black"),i.setAttribute("tabindex","0"),i.setAttribute("role","button"),e.getElement().appendChild(i)}},{key:"onApplePayButtonClicked",value:function(){this.paymentSession=new ApplePaySession(3,this.createRequest()),this.paymentSession.onvalidatemerchant=this.onValidateMerchant,this.paymentSession.onpaymentauthorized=this.onPaymentAuthorized,this.paymentSession.oncancel=this.onCancelPayment,this.paymentSession.onshippingcontactselected=this.onShippingContactSelected,this.paymentSession.onshippingmethodselected=this.onShippingMethodSelected,this.paymentSession.begin()}},{key:"createRequest",value:function(){var e,t=this.getMetaRawDataInitialization();return t&&"object"===o(t)&&("object"===o(t.total)?t.total.amount=this.meta.amount.toString():t.total={label:(null===(e=this.meta)||void 0===e?void 0:e.amount_label)||"",amount:this.meta.amount.toString()},this.isShippingRequired()&&this.hasShippingOptions()&&(t.shippingMethods=this.formatShippingOptions(this.meta.shipping_options))),t||u(u(u({countryCode:this.meta.country.toUpperCase(),currencyCode:this.meta.currency.toUpperCase(),merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard","amex","discover"]},this.meta.show_billing_address&&{requiredBillingContactFields:["name","postalAddress"]}),this.isShippingRequired()&&u({requiredShippingContactFields:["postalAddress","name","phone","email"]},this.hasShippingOptions()&&{shippingMethods:this.formatShippingOptions(this.meta.shipping_options)})),{total:{label:this.meta.amount_label,amount:this.meta.amount.toString(),type:"final"}})}},{key:"getMerchantSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(_r.CALLBACK,{data:u({request_type:"CREATE_SESSION",wallet_type:ki.APPLE,session_id:window.location.hostname},e.isShippingRequired()&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e)},onError:function(e){return n(e)}})}))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"createButtonStyle",value:function(){var e,t;return"\n .paydock-apple-container {\n width: 100%;\n height: 40px;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: ".concat((null===(e=this.getMetaStyles())||void 0===e?void 0:e.button_type)||"plain","\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: ").concat((null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"plain","\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ")}}])}(Cr),Br=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i])).gatewayName=r,a.eventEmitter=o,a.processingButtonClick=!1,a.parseUpdateData=function(e){var t,n,i,r,o,s,c=null===(n=null===(t=a.meta)||void 0===t?void 0:t.shipping_options)||void 0===n?void 0:n.find((function(t){var n;return t.id===(null===(n=null==e?void 0:e.shippingOptionData)||void 0===n?void 0:n.id)}));return u({shipping:{address_city:null===(i=e.shippingAddress)||void 0===i?void 0:i.locality,address_state:null===(r=e.shippingAddress)||void 0===r?void 0:r.administrativeArea,address_postcode:null===(o=null==e?void 0:e.shippingAddress)||void 0===o?void 0:o.postalCode,address_country:null===(s=null==e?void 0:e.shippingAddress)||void 0===s?void 0:s.countryCode}},c&&{selected_shipping_option:{id:null==c?void 0:c.id,label:null==c?void 0:c.label,detail:null==c?void 0:c.detail,type:null==c?void 0:c.type}})},a.formatShippingOptions=function(e){return e.map((function(e){return{id:e.id,label:e.label,description:(null==e?void 0:e.detail)||""}}))},a.eventEmitter=o,a}return d(n,e),c(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[ki.GOOGLE])||void 0===n?void 0:n.merchant}},{key:"getMetaStyles",value:function(){var e,t,n,i;return"object"===o(null===(e=this.meta)||void 0===e?void 0:e.style)&&"google"in(null===(t=this.meta)||void 0===t?void 0:t.style)?null===(i=null===(n=this.meta)||void 0===n?void 0:n.style)||void 0===i?void 0:i.google:null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i,r;return(null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&"object"===o(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"google"in(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)?null===(r=null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization)||void 0===r?void 0:r.google:null}},{key:"isShippingRequired",value:function(){return!!this.meta.request_shipping}},{key:"hasShippingOptions",value:function(){return this.meta.request_shipping&&!!this.meta.shipping_options}},{key:"load",value:function(e){var t=this;if(window.Promise)return new Promise((function(n,i){var r=document.createElement("script");r.type="text/javascript",r.src="https://pay.google.com/gp/p/js/pay.js",r.async=!0,r.onload=function(){var r,o,s,a;if(!window.google)return t.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.GOOGLE}),void i();t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(r=t.meta)||void 0===r?void 0:r.shipping_options[0]),t.paymentsClient=new google.payments.api.PaymentsClient(u({merchantInfo:u(u({},(null===(o=t.meta)||void 0===o?void 0:o.merchant_name)?{merchantName:null===(s=t.meta)||void 0===s?void 0:s.merchant_name}:{}),{merchantId:t.getMerchantId()}),paymentDataCallbacks:u({onPaymentAuthorized:function(e){return t.onPaymentAuthorized(e)}},t.isShippingRequired()&&{onPaymentDataChanged:function(e){return t.onPaymentDataChanged(e)}})},"live"===(null===(a=t.meta)||void 0===a?void 0:a.gateway_mode)?{environment:"PRODUCTION"}:{environment:"TEST"})),t.checkAvailability().then((function(r){if(!r)return t.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.GOOGLE}),void i();t.mount(e),n()}))},document.head.appendChild(r)}));this.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.GOOGLE})}},{key:"update",value:function(e){var t,n,i,r;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success)return this.latestShippingChangePromiseReject();var o=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount)||this.meta.amount,s=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;o&&(this.meta.amount=o),s&&(this.meta.shipping_options=s,this.selectedShippingOption=s?s[0]:void 0);var a=u({newTransactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:null===(i=this.meta.amount)||void 0===i?void 0:i.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()}},this.isShippingRequired()&&this.hasShippingOptions()&&s&&{newShippingOptionParameters:{defaultSelectedOptionId:null===(r=this.selectedShippingOption)||void 0===r?void 0:r.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}});this.latestShippingChangePromiseResolve(a)}}},{key:"checkAvailability",value:function(){return te(this,void 0,void 0,i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paymentsClient.isReadyToPay(this.createRequest()).then((function(e){return!!e.result})).catch((function(e){return console.error("Error checking GooglePay availability",e),!1})));case 1:case"end":return e.stop()}}),e,this)})))}},{key:"mount",value:function(e){var t,n,i,r=this;e.getElement().appendChild(this.paymentsClient.createButton({onClick:function(){return r.onGooglePayButtonClicked()},buttonType:(null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"pay",buttonSizeMode:(null===(n=this.getMetaStyles())||void 0===n?void 0:n.button_size_mode)||"fill",buttonColor:(null===(i=this.getMetaStyles())||void 0===i?void 0:i.button_color)||"default"}))}},{key:"onGooglePayButtonClicked",value:function(){var e=this;this.processingButtonClick||(this.processingButtonClick=!0,this.handleMerchantOnButtonClickEvent().then((function(){e.loadPaymentData().finally((function(){e.processingButtonClick=!1}))})).catch((function(t){e.processingButtonClick=!1,console.error("Error while processing merchant callback",t)})))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"loadPaymentData",value:function(){return te(this,void 0,void 0,i().mark((function e(){var t=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paymentsClient.loadPaymentData(this.createPaymentDataRequest()).catch((function(e){throw t.eventEmitter.emit(_r.CHECKOUT_CLOSE),console.error("Error while loading payment data",e),e})));case 1:case"end":return e.stop()}}),e,this)})))}},{key:"onPaymentAuthorized",value:function(e){var t,n,i,r,o,s,a,c,l,d,h,p,f,m,v,g=this,y=null===(i=null===(n=null===(t=e.paymentMethodData)||void 0===t?void 0:t.info)||void 0===n?void 0:n.billingAddress)||void 0===i?void 0:i.address1,b=null===(s=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.address2,E=null===(a=null==e?void 0:e.shippingAddress)||void 0===a?void 0:a.address1,w=null===(c=null==e?void 0:e.shippingAddress)||void 0===c?void 0:c.address2,k=null===(l=this.selectedShippingOption)||void 0===l?void 0:l.type,S=null===(d=null==e?void 0:e.shippingAddress)||void 0===d?void 0:d.countryCode,T=null===(h=null==e?void 0:e.shippingAddress)||void 0===h?void 0:h.locality,_=null===(p=null==e?void 0:e.shippingAddress)||void 0===p?void 0:p.postalCode,C=null===(f=null==e?void 0:e.shippingAddress)||void 0===f?void 0:f.administrativeArea,O=null===(m=null==e?void 0:e.shippingAddress)||void 0===m?void 0:m.name,N=null==e?void 0:e.email,I=null===(v=null==e?void 0:e.shippingAddress)||void 0===v?void 0:v.phoneNumber;return new Promise((function(t){var n,i,r,o,s,a,c,l,d,h,p,f,m,v;return g.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:u({customer:{payment_source:u(u(u(u({wallet_type:ki.GOOGLE,type:e.paymentMethodData.type,card_scheme:null===(i=null===(n=e.paymentMethodData)||void 0===n?void 0:n.info)||void 0===i?void 0:i.cardNetwork},y&&{address_line1:y}),b&&{address_line2:b}),b&&{address_line2:b}),{address_country:null===(s=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.countryCode,address_city:null===(l=null===(c=null===(a=e.paymentMethodData)||void 0===a?void 0:a.info)||void 0===c?void 0:c.billingAddress)||void 0===l?void 0:l.locality,address_postcode:null===(p=null===(h=null===(d=e.paymentMethodData)||void 0===d?void 0:d.info)||void 0===h?void 0:h.billingAddress)||void 0===p?void 0:p.postalCode,address_state:null===(v=null===(m=null===(f=e.paymentMethodData)||void 0===f?void 0:f.info)||void 0===m?void 0:m.billingAddress)||void 0===v?void 0:v.administrativeArea,ref_token:e.paymentMethodData.tokenizationData.token})}},g.isShippingRequired()&&{shipping:u(u(u(u(u(u(u(u(u({},k&&{method:k}),g.hasShippingOptions()&&{options:g.meta.shipping_options}),E&&{address_line1:E}),w&&{address_line2:w}),S&&{address_country:S}),T&&{address_city:T}),_&&{address_postcode:_}),C&&{address_state:C}),{contact:u(u(u({},O&&{first_name:O}),N&&{email:N}),I&&{phone:I})})}),onSuccess:function(){return t({transactionState:"SUCCESS"})},onError:function(e){return t({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:(null==e?void 0:e.message)||"Error processing payment",reason:"PAYMENT_DATA_INVALID"}})}})}))}},{key:"onPaymentDataChanged",value:function(e){var t=this;if(this.isShippingRequired()){var n=this.parseUpdateData(e),i=new Promise((function(e,n){t.latestShippingChangePromiseResolve=e,t.latestShippingChangePromiseReject=n}));return this.eventEmitter.emit(_r.UPDATE,n),i}}},{key:"createRequest",value:function(){var e="Apple Safari"===E.getBrowserName();return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[this.createCardData()],existingPaymentMethodRequired:!e}}},{key:"createPaymentDataRequest",value:function(){var e,t,n,i;this.isShippingRequired()&&this.hasShippingOptions()&&(this.selectedShippingOption=null===(e=this.meta)||void 0===e?void 0:e.shipping_options[0]);var r=this.getMerchantId();return u({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[u(u({},this.createCardData()),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"paydock",gatewayMerchantId:r}}})],transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:this.meta.amount.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()},merchantInfo:u(u({},(null===(t=this.meta)||void 0===t?void 0:t.merchant_name)?{merchantName:null===(n=this.meta)||void 0===n?void 0:n.merchant_name}:{}),{merchantId:r}),callbackIntents:["PAYMENT_AUTHORIZATION"].concat(v(this.isShippingRequired()?["SHIPPING_ADDRESS"]:[]),v(this.hasShippingOptions()?["SHIPPING_OPTION"]:[]))},this.isShippingRequired()&&u({shippingAddressRequired:!0},this.hasShippingOptions()&&{shippingOptionRequired:!0,shippingOptionParameters:{defaultSelectedOptionId:null===(i=this.selectedShippingOption)||void 0===i?void 0:i.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}}))}},{key:"createCardData",value:function(){return this.getMetaRawDataInitialization()||{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!!this.meta.show_billing_address}}}}])}(Cr),Hr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"initializeChildWallets",value:function(){var e,t,n,i,r,o;this.childWallets=[];var s=!!(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t.apple)||void 0===n?void 0:n.merchant),a=!!(null===(o=null===(r=null===(i=this.meta)||void 0===i?void 0:i.credentials)||void 0===r?void 0:r.google)||void 0===o?void 0:o.merchant);!s||this.meta.wallets&&!this.meta.wallets.includes(ki.APPLE)||this.childWallets.push(new jr(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter)),!a||this.meta.wallets&&!this.meta.wallets.includes(ki.GOOGLE)||this.childWallets.push(new Br(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter))}},{key:"getGatewayName",value:function(){return wi.MASTERCARD}},{key:"setEnv",value:function(e){return this.childWallets.forEach((function(t){return t.setEnv(e)})),this}},{key:"update",value:function(e){this.childWallets.forEach((function(t){return t.update(e)}))}}])}(Cr),zr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"load",value:function(e){return window.Promise?(!0===this.meta.standalone?this.renderPaypalStandaloneComponent(e):this.renderPaypalCommonComponent(e),Promise.resolve()):(this.eventEmitter.emit(_r.UNAVAILABLE,null),Promise.resolve())}},{key:"update",value:function(e){var t=this;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject)return e.success?void this.eventEmitter.emit(_r.CALLBACK,{data:{request_type:"UPDATE_TRANSACTION",shipping:this.latestShippingData},onSuccess:function(e){return t.latestShippingChangePromiseResolve(!0)},onError:function(){return t.latestShippingChangePromiseReject()}}):this.latestShippingChangePromiseReject()}},{key:"renderPaypalCommonComponent",value:function(e){var t,n=this,i=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",r=document.createElement("script");r.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency).concat(!0===this.meta.pay_later?"&enable-funding=paylater&disable-funding=card":"&disable-funding=credit,card").concat(this.meta.capture?"":"&intent=authorize"),r.async=!0,r.onload=function(){window.paypal?(n.paypal=window.paypal,n.paypal.Buttons(u({},n.paypalSharedProps())).render("#".concat(i))):n.eventEmitter.emit(_r.UNAVAILABLE,null)},document.head.appendChild(r)}},{key:"renderPaypalStandaloneComponent",value:function(e){var t,n,i=this,r=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",o=document.createElement("script");o.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency,"&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(this.meta.capture?"":"&intent=authorize").concat("live"===(null===(n=this.meta)||void 0===n?void 0:n.gateway_mode)?"":"&buyer-country=AU"),o.async=!0,o.onload=function(){if(window.paypal){i.paypal=window.paypal;var e=!!i.meta.pay_later,t=i.paypal.Buttons(u({fundingSource:e?i.paypal.FUNDING.PAYLATER:i.paypal.FUNDING.PAYPAL},i.paypalSharedProps()));if(t.isEligible()){if(t.render("#".concat(r)),e)i.paypal.Messages(u({amount:i.meta.amount,currency:i.meta.currency,placement:"payment"},i.meta.style&&i.meta.style.messages&&{style:i.meta.style.messages})).render("#".concat(r))}else i.eventEmitter.emit(_r.UNAVAILABLE,null)}else i.eventEmitter.emit(_r.UNAVAILABLE,null)},document.head.appendChild(o)}},{key:"paypalSharedProps",value:function(){var e=this;return u(u({},this.meta.style&&{style:this.meta.style}),{onClick:function(t,n){var i;return e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e&&e instanceof Promise?e.then((function(){return n.resolve()})).catch((function(){return n.reject()})):e}}),i},createOrder:function(){return new Promise((function(t,n){e.eventEmitter.emit(_r.CALLBACK,{data:u({request_type:"CREATE_TRANSACTION"},e.meta.request_shipping&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e.id)},onError:function(e){return n(e)}})}))},onShippingChange:function(t,n){return new Promise((function(n,i){var r=e.parseUpdateData(t);e.latestShippingData=r.shipping,e.latestShippingChangePromiseResolve=n,e.latestShippingChangePromiseReject=i,e.eventEmitter.emit(_r.UPDATE,r)}))},onApprove:function(t){return e.pendingApprovalPromise=e.pendingApprovalPromise||new Promise((function(n,i){return e.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:{payment_method_id:t.orderID,customer:{payment_source:{external_payer_id:t.payerID}}},onSuccess:function(){e.pendingApprovalPromise=void 0,n(!0)},onError:function(t){e.pendingApprovalPromise=void 0,i(t)}})})),e.pendingApprovalPromise},onCancel:function(){return e.eventEmitter.emit(_r.CHECKOUT_CLOSE)},onError:function(e){}})}},{key:"parseUpdateData",value:function(e){var t;return u(u({wallet_order_id:e.orderID,wallet_session_id:e.paymentID,payment_source:{wallet_payment_method_id:e.paymentToken}},e.shipping_address&&{shipping:{address_city:e.shipping_address.city,address_state:e.shipping_address.state,address_postcode:e.shipping_address.postal_code,address_country:e.shipping_address.country_code}}),e.selected_shipping_option&&{selected_shipping_option:{id:e.selected_shipping_option.id,label:e.selected_shipping_option.label,amount:e.selected_shipping_option.amount.value,currency:e.selected_shipping_option.amount.currency_code,type:null===(t=e.selected_shipping_option)||void 0===t?void 0:t.type}})}}])}(Cr),Vr={};function Wr(e){return Wr="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},Wr(e)}Object.defineProperty(Vr,"__esModule",{value:!0});var qr,Gr="https://js.stripe.com/v3",Kr=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Yr="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",$r=null,Jr=function(e){return null!==$r||($r=new Promise((function(t,n){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Yr),window.Stripe)t(window.Stripe);else try{var i=function(){for(var e=document.querySelectorAll('script[src^="'.concat(Gr,'"]')),t=0;t<e.length;t++){var n=e[t];if(Kr.test(n.src))return n}return null}();i&&e?console.warn(Yr):i||(i=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(Gr).concat(t);var i=document.head||document.body;if(!i)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return i.appendChild(n),n}(e)),i.addEventListener("load",(function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))})),i.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else t(null)}))),$r},Xr=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==Wr(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},Zr=!1,Qr=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Zr=!0;var i=Date.now();return Jr(qr).then((function(e){return function(e,t,n){if(null===e)return null;var i=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.54.2",startTime:t})}(i,n),i}(e,t,i)}))};Qr.setLoadParameters=function(e){if(Zr&&qr){var t=Xr(e);if(Object.keys(t).reduce((function(t,n){var i;return t&&e[n]===(null===(i=qr)||void 0===i?void 0:i[n])}),!0))return}if(Zr)throw new Error("You cannot change load parameters after calling loadStripe");qr=Xr(e)},Vr.loadStripe=Qr;var eo,to=Vr,no="success",io="fail",ro=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"initPaymentRequest",value:function(){return this.stripe.paymentRequest({country:this.meta.country.toUpperCase(),currency:this.meta.currency.toLowerCase(),total:{label:this.meta.amount_label,amount:Math.floor(100*this.meta.amount)},requestPayerName:!0===this.meta.request_payer_name,requestPayerEmail:!0===this.meta.request_payer_email,requestPayerPhone:!0===this.meta.request_payer_phone})}},{key:"createWalletButton",value:function(){return this.stripe.elements().create("paymentRequestButton",{paymentRequest:this.paymentRequest})}},{key:"load",value:function(e){var t=this;return to.loadStripe(this.publicKey).then((function(e){t.stripe=e,t.paymentRequest=t.initPaymentRequest()})).then((function(){return t.checkAvailability()})).then((function(n){return t.mount(e,n)})).then((function(){return t.setOnPaymentMethodSelected()}))}},{key:"checkAvailability",value:function(){var e=this;return this.paymentRequest.canMakePayment().then((function(t){if(t){var n=!e.meta.wallets||e.meta.wallets.includes(ki.GOOGLE),i=!e.meta.wallets||e.meta.wallets.includes(ki.APPLE);return{google_pay:n&&!t.applePay,apple_pay:i&&t.applePay,flypay:!1}}}))}},{key:"mount",value:function(e,t){if(!t||!t.apple_pay&&!t.google_pay)return this.eventEmitter.emit(_r.UNAVAILABLE,null);this.createWalletButton().mount(e.getElement())}},{key:"setOnPaymentMethodSelected",value:function(){var e=this;this.paymentRequest.on("paymentmethod",(function(t){var n,i,r=t.paymentMethod,o=r.id,s=r.card,a=r.billing_details,c=a.name,l=a.address,u={payment_method_id:o,customer:{payer_name:t.payerName,payer_email:t.payerEmail,payer_phone:t.payerPhone,payment_source:{wallet_type:e.getWalletType(null===(n=null==s?void 0:s.wallet)||void 0===n?void 0:n.type),card_name:c,type:null===(i=null==s?void 0:s.wallet)||void 0===i?void 0:i.type,card_scheme:null==s?void 0:s.brand,card_number_last4:null==s?void 0:s.last4,expire_month:null==s?void 0:s.exp_month,expire_year:null==s?void 0:s.exp_year,address_line1:l.line1,address_line2:l.line2,address_city:l.city,address_postcode:l.postal_code,address_state:l.state,address_country:l.country}}};e.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:u,onSuccess:function(){return t.complete(no)},onError:function(e){return t.complete(io)}})}))}},{key:"getWalletType",value:function(e){return e?"google_pay"===e?ki.GOOGLE:ki.APPLE:null}}])}(Cr),oo="unavailable",so="update",ao="paymentSuccessful",co="paymentError",lo="paymentInReview",uo="authTokensChanged",ho="onClick",po="onCheckoutOpen",fo="onCheckoutClose",mo=function(){return c((function e(t,n,i){s(this,e),this.hasUpdateHandler=!1;var r=Q.validateJWT(n);if(!r)throw new Error("Invalid charge token");this.eventEmitter=new vi,this.container=new Jn(t);var o=Q.extractMeta(r.body);switch(this.api=new pi(n,Dn.TOKEN),o.gateway.type){case wi.STRIPE:this.service=new ro(o.credentials.client_auth,u(u({},i),{amount:o.charge.amount,currency:o.charge.currency}));break;case wi.FLYPAY:this.service=new Ur(n,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,reference:o.charge.reference}));break;case wi.FLYPAY_V2:this.service=new Pr(n,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,reference:o.charge.reference}));break;case wi.PAYPAL:this.service=new zr(o.credentials.client_auth,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,capture:o.charge.capture}));break;case wi.MASTERCARD:this.service=new Hr("",u(u({},i),{credentials:o.gateway.credentials,amount:o.charge.amount,currency:o.charge.currency,gateway_mode:o.gateway.mode}));break;case wi.AFTERPAY:this.service=new Or(n,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,reference:o.charge.reference}))}}),[{key:"load",value:function(){try{this.setupServiceCallbacks(),this.service.load(this.container)}catch(e){throw this.eventEmitter.emit(oo,null),e}}},{key:"update",value:function(e){this.service.update(e)}},{key:"setEnv",value:function(e,t){this.api.setEnv(e,t),this.service.setEnv(e)}},{key:"enable",value:function(){this.service.enable()}},{key:"disable",value:function(){this.service.disable()}},{key:"close",value:function(){"function"==typeof this.service.close&&this.service.close()}},{key:"on",value:function(e,t){var n=this;return e===so&&(this.hasUpdateHandler=!0),"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"onUnavailable",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(oo,e):new Promise((function(e){return t.eventEmitter.subscribe(oo,(function(){return e()}))}))}},{key:"onUpdate",value:function(e){var t=this;return this.hasUpdateHandler=!0,"function"==typeof e?this.eventEmitter.subscribe(so,e):new Promise((function(e){return t.eventEmitter.subscribe(so,(function(t){return e(t)}))}))}},{key:"onPaymentSuccessful",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(ao,e):new Promise((function(e){return t.eventEmitter.subscribe(ao,(function(t){return e(t)}))}))}},{key:"onPaymentInReview",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(lo,e):new Promise((function(e){return t.eventEmitter.subscribe(lo,(function(t){return e(t)}))}))}},{key:"onPaymentError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(co,e):new Promise((function(e){return t.eventEmitter.subscribe(co,(function(t){return e(t)}))}))}},{key:"onAuthTokensChanged",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(uo,e):new Promise((function(e){return t.eventEmitter.subscribe(uo,(function(t){return e(t)}))}))}},{key:"onClick",value:function(e){if("function"==typeof e)return this.eventEmitter.subscribe(ho,e)}},{key:"onCheckoutOpen",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(po,e):new Promise((function(e){return t.eventEmitter.subscribe(po,(function(t){return e(t)}))}))}},{key:"onCheckoutClose",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(fo,e):new Promise((function(e){return t.eventEmitter.subscribe(fo,(function(t){return e(t)}))}))}},{key:"setupServiceCallbacks",value:function(){this.setupUnavailableCallback(),this.setupUpdateCallback(),this.setupWalletCallback(),this.setupPaymentCallback(),this.setupPaymentSuccessCallback(),this.setupPaymentInReviewCallback(),this.setupPaymentErrorCallback(),this.setupAuthTokensChangedCallback(),this.setupOnClickCallback(),this.setupOnCheckoutOpenCallback(),this.setupOnCheckoutCloseCallback()}},{key:"setupUnavailableCallback",value:function(){var e=this;this.service.on(_r.UNAVAILABLE,(function(t){return e.eventEmitter.emit(oo,{event:oo,data:t})}))}},{key:"setupUpdateCallback",value:function(){var e=this;this.service.on(_r.UPDATE,(function(t){return e.hasUpdateHandler?e.eventEmitter.emit(so,{event:so,data:t}):e.update({success:!0})}))}},{key:"setupOnClickCallback",value:function(){var e=this;this.service.on(_r.BUTTON_CLICK,(function(t){return e.eventEmitter.emit(ho,{event:ho,data:t})}))}},{key:"setupOnCheckoutOpenCallback",value:function(){var e=this;this.service.on(_r.CHECKOUT_OPEN,(function(t){return e.eventEmitter.emit(po,{event:po,data:t})}))}},{key:"setupOnCheckoutCloseCallback",value:function(){var e=this;this.service.on(_r.CHECKOUT_CLOSE,(function(t){return e.eventEmitter.emit(fo,{event:fo,data:t})}))}},{key:"setupWalletCallback",value:function(){var e=this;this.service.on(_r.CALLBACK,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCallback(n).then((function(e){return i(e)}),(function(e){return r(e.message)}))}))}},{key:"setupPaymentCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_METHOD_SELECTED,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCapture(n).then((function(t){"function"==typeof i&&i();var r="inreview"===t.status?lo:ao;e.eventEmitter.emit(r,{event:r,data:u(u({},t),n.customer&&{payer_name:n.customer.payer_name,payer_email:n.customer.payer_email,payer_phone:n.customer.payer_phone})})}),(function(t){"function"==typeof r&&r(t),e.eventEmitter.emit(co,{event:co,data:t})}))}))}},{key:"setupPaymentSuccessCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_SUCCESS,(function(t){return e.eventEmitter.emit(ao,{event:ao,data:t})}))}},{key:"setupPaymentInReviewCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_IN_REVIEW,(function(t){return e.eventEmitter.emit(lo,{event:lo,data:t})}))}},{key:"setupPaymentErrorCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_ERROR,(function(t){return e.eventEmitter.emit(co,{event:co,data:t})}))}},{key:"setupAuthTokensChangedCallback",value:function(){var e=this;this.service.on(_r.AUTH_TOKENS_CHANGED,(function(t){return e.eventEmitter.emit(uo,{event:uo,data:t})}))}}])}(),vo={CARD:"card",GIFT_CARD:"gift_card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},go={PAYMENT_SOURCE:"payment_source",CARD_PAYMENT_SOURCE_WITH_CVV:"card_payment_source_with_cvv",CARD_PAYMENT_SOURCE_WITHOUT_CVV:"card_payment_source_without_cvv"},yo=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vo.CARD,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:go.PAYMENT_SOURCE;if(s(this,e),-1===pr.values(vo).indexOf(n))throw new Error("unsupported payment type");if(n===vo.CHECKOUT)throw new Error('Payment type "checkout" is deprecated. Use CheckoutButton for this type of payments https://www.npmjs.com/package/@paydock/client-sdk#checkout-button');if(-1===pr.values(go).indexOf(i))throw new Error("unsupported purpose");this.env=new $(W),this.configs={purpose:i,meta:{},dynamic_fields_position:!0,predefined_fields:{gateway_id:t,type:n,card_scheme:null,card_processing_network:null}}}return c(e,[{key:"setWebHookDestination",value:function(e){this.configs.webhook_destination=e}},{key:"setSuccessRedirectUrl",value:function(e){this.configs.success_redirect_url=e}},{key:"setErrorRedirectUrl",value:function(e){this.configs.error_redirect_url=e}},{key:"setFormFields",value:function(e){for(var t in Array.isArray(this.configs.defined_form_fields)||(this.configs.defined_form_fields=[]),e)e.hasOwnProperty(t)&&(-1!==pr.values(_i).indexOf(e[t].replace("*",""))?this.configs.defined_form_fields.push(e[t]):console.warn("Configuration::setFormFields: unsupported form field ".concat(e[t])))}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==Ai.indexOf(t)?this.configs.meta[t]=e[t]:console.warn("Configuration::setMeta: unsupported meta key ".concat(t)))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"setLabel",value:function(e){this.configs.label=e}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"createToken",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.send(e,(function(e,i){if(i>=200&&i<300)return t(e.resource.data.configuration_token);void 0===e.error||void 0===e.error.message?n("unknown error"):n(e.error.message)}))}},{key:"send",value:function(e,t){var n=ee.create("POST",this.getUrl()).setHeader(Q.getAccessHeaderNameByToken(e),e).setContentTypeJson().setSdkVersion().inner();n.onload=function(){var e={};try{e=JSON.parse(n.responseText)}catch(e){}t(e,n.status)},n.send(JSON.stringify(this.getConfigs()))}},{key:"getConfigs",value:function(){return this.configs}},{key:"getUrl",value:function(){return this.env.getConf().url+"/v1/remote-action/configs"}},{key:"setGiftCardSchemeData",value:function(e,t){if(this.configs.predefined_fields.type!==vo.GIFT_CARD)throw new Error("unsupported payment type");if(!e||!t)throw new Error("");this.configs.predefined_fields.card_scheme=e,this.configs.predefined_fields.card_processing_network=t}}],[{key:"createEachToken",value:function(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){},o=new Array(n.length),s=[],a=0,c=function(c){n.hasOwnProperty(c)&&n[c].createToken(t,(function(t){o[c]=t,a++,n.length===a&&e.finishCreatingEachToken(o,s,i,r)}),(function(t){s.push("gateway: ".concat(n[c].getConfigs().predefined_fields.gateway_id," | ").concat(t)),a++,n.length===a&&e.finishCreatingEachToken(o,s,i,r)}))};for(var l in n)c(l)}},{key:"finishCreatingEachToken",value:function(e,t,n,i){t.length>=1?i(t):n(e)}}])}(),bo={INPUT:"input",SUBMIT_BUTTON:"submit_button",LABEL:"label",TITLE:"title",TITLE_DESCRIPTION:"title_description"},Eo={ERROR:"error",FOCUS:"focus",HOVER:"hover"},wo=[{element:bo.INPUT,states:[Eo.FOCUS,Eo.ERROR],styles:["color","border","border_radius","background_color","height","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition"]},{element:bo.SUBMIT_BUTTON,states:[Eo.HOVER],styles:["color","border","border_radius","background_color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition","opacity"]},{element:bo.LABEL,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin"]},{element:bo.TITLE,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]},{element:bo.TITLE_DESCRIPTION,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]}],ko=function(){return c((function e(){s(this,e)}),null,[{key:"check",value:function(e,t,n,i){for(var r in e)if(e.hasOwnProperty(r)&&e[r].element===t){if(-1===e[r].states.indexOf(n)&&n)return!1;for(var o in i)if(i.hasOwnProperty(o)&&-1===e[r].styles.indexOf(o.replace("-","_")))return!1;return!0}return!1}},{key:"encode",value:function(e,t,n){var i=[];for(var r in n)n.hasOwnProperty(r)&&i.push("".concat(r.replace("_","-"),":").concat(n[r]));var o=i.join(";");return t?"".concat(e,"::").concat(t,"{").concat(o,"}"):"".concat(e,"{").concat(o,"}")}},{key:"decode",value:function(e){var t=(e.match("::(.*){")||["",null])[1],n=null!==t?(e.match("(.*)::")||["",""])[1].trim():(e.match("(.*){")||["",""])[1].trim(),i=(e.match("{(.*)}")||["",""])[1].split(";"),r={};for(var o in i)if(i.hasOwnProperty(o)){var s=i[o].split(":");(s||2===s.length)&&(r[s[0].trim()]=(s[1]||"").trim())}return{element:n,state:t,styles:r}}}])}(),So=function(){return c((function e(t,n){if(s(this,e),this.configs=[],this.configTokens=[],this.link=new Yn("/remote-action"),J.version&&this.link.setParams({sdk_version:J.version,sdk_type:J.type}),Q.validateJWT(t)?this.link.setParams({token:t}):this.link.setParams({public_key:t}),this.accessToken=t,!n||Array.isArray(n)&&!n.length)throw Error("configuration token is required");if("string"==typeof n)this.configTokens.push(n);else if(n instanceof yo)this.configs.push(n);else if(Array.isArray(n)&&"string"==typeof n[0])this.configTokens=n;else{if(!(Array.isArray(n)&&n[0]instanceof yo))throw Error("Unsupported type of configuration token");this.configs=n}}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"usePhoneCountryMask",value:function(e){return e?!e.only_countries||/^[a-z]+$/.test(e.only_countries.join(""))&&2*e.only_countries.length===e.only_countries.join("").length?!e.preferred_countries||/^[a-z]+$/.test(e.preferred_countries.join(""))&&2*e.preferred_countries.length===e.preferred_countries.join("").length?e.default_country&&2!==e.default_country.length?console.warn("Widget::usePhoneCountryMask[s: default_country - incorrect value length"):(this.link.setParams({use_country_phone_mask:!0}),e.only_countries&&this.link.setParams({phone_mask_only_countries:e.only_countries.join(",")}),e.preferred_countries&&this.link.setParams({phone_mask_preferred_countries:e.preferred_countries.join(",")}),void(e.default_country&&this.link.setParams({phone_mask_default_country:e.default_country}))):console.warn("Widget::usePhoneCountryMask[s: preferred_countries - unsupported symbols or incorrect length of value"):console.warn("Widget::usePhoneCountryMask[s: only_countries - unsupported symbols or incorrect length of value"):this.link.setParams({use_country_phone_mask:!0})}},{key:"setStyle",value:function(e,t){-1!==pr.values(Ci).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setTexts",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setText(t,e[t])}},{key:"setText",value:function(e,t){-1!==pr.values(Oi).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setText[s: unsupported text param ".concat(e))}},{key:"setElementStyle",value:function(e,t,n){var i=3===arguments.length?t:null,r=3===arguments.length?n:t;if(!ko.check(wo,e,i,r))return console.warn('Styles for "'.concat(e,'" element with "').concat(i||"default",'" state was ignored because some of the arguments are unacceptable'));this.link.concatParams({element_styles:ko.encode(e,i,r)})}},{key:"setFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormValue(t,e[t])}},{key:"setFormValue",value:function(e,t){return-1===pr.values(_i).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void("string"==typeof this.link.getParams().form_values&&this.link.getParams().form_values.length?this.link.setParams({form_values:"".concat(this.link.getParams().form_values,",").concat(e,":").concat(t)}):this.link.setParams({form_values:"".concat(e,":").concat(t)}))}},{key:"setFormLabels",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormLabel(t,e[t])}},{key:"setFormLabel",value:function(e,t){if(-1===pr.values(_i).indexOf(e))return console.warn("Widget::setFormLabel[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormLabel[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_labels:"".concat(e,":").concat(n)})}},{key:"setFormPlaceholders",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormPlaceholder(t,e[t])}},{key:"setFormPlaceholder",value:function(e,t){if(-1===pr.values(_i).indexOf(e))return console.warn("Widget::setFormPlaceholder[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormPlaceholder[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_placeholders:"".concat(e,":").concat(n)})}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){e.value&&this.setFormValue(e.field,e.value),e.label&&this.setFormLabel(e.field,e.label),e.placeholder&&this.setFormPlaceholder(e.field,e.placeholder)}},{key:"setIcons",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setIcon(t,e[t])}},{key:"setIcon",value:function(e,t){if(/\,/.test(t)||/\:/.test(t))return console.warn("Widget::setIcon[s: ".concat(e," - unsupported symbols (: or ,) in value"));"string"==typeof this.link.getParams().icons&&this.link.getParams().icons.length?this.link.setParams({icons:"".concat(this.link.getParams().icons,",").concat(e,":").concat(t)}):this.link.setParams({icons:"".concat(e,":").concat(t)})}},{key:"setHiddenElements",value:function(e){var t=[],n=pr.values(Ni).concat(pr.values(_i));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::setHiddenElements: unsupported element ".concat(e[i])));t.length&&this.link.concatParams({hidden_elements:t.join(",")})}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"useGatewayFieldValidation",value:function(){this.link.setParams({fields_validation:!0})}},{key:"setSupportedCardIcons",value:function(e,t){var n=[];for(var i in e)e.hasOwnProperty(i)&&(-1!==pr.values(Ii).indexOf(e[i])?n.push(e[i]):console.warn("Widget::cardTypes: unsupported type of cards ".concat(e[i])));n.length&&this.link.concatParams({supported_card_types:n.join(",")}),t&&this.link.setParams({validate_card_types:t})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"loadIFrameUrl",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){};if(this.link.setParams({configuration_tokens:""}),this.configTokens.length)return this.link.setParams({configuration_tokens:this.configTokens.join(",")}),e(this.link.getUrl());yo.createEachToken(this.accessToken,this.configs,(function(n){return t.link.concatParams({configuration_tokens:n.join(",")}),e(t.link.getUrl())}),(function(e){n(e)}))}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),To=function(){return c((function e(t){s(this,e),this.intercepted=!1,this.selector=t}),[{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"beforeSubmit",value:function(e){var t=this;this.isExist()&&this.subscribe(this.getElement(),(function(n){n.preventDefault(),t.intercepted=!0,e.apply(t,[])}))}},{key:"continueSubmit",value:function(){var e=this;this.isExist()&&this.intercepted&&(this.intercepted=!1,setTimeout((function(){e.getElement().submit()}),50))}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("submit",t):e.attachEvent("onsubmit",t)}}])}(),_o=function(e){function n(e,i,r){var o;return s(this,n),(o=t(this,n,[i,r])).validationData={},o.container=new Jn(e),o.iFrame=new Xn(o.container),o.triggerElement=new kr(o.iFrame),o.event=new Qn(window),o}return d(n,e),c(n,[{key:"load",value:function(){var e=this;this.setStyles(this.container.getStyles(pr.values(Ci))),this.setTexts(this.container.getAttr(pr.values(Oi))),this.loadIFrameUrl((function(t){e.iFrame.load(t,{title:"Card details"}),e.afterLoad()}),(function(e){for(var t in console.error("Errors when creating a token[s, widget will not be load:"),e)e.hasOwnProperty(t)&&console.error("--- | ".concat(e[t]))}))}},{key:"afterLoad",value:function(){var e=this;this.on(Zn.VALIDATION,(function(t){e.validationData=t}))}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.triggerElement.push(e,t)}},{key:"getValidationState",value:function(){return this.validationData}},{key:"isValidForm",value:function(){return!!this.validationData.form_valid}},{key:"isInvalidField",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_fields&&-1!==this.validationData.invalid_fields.indexOf(e)}},{key:"isFieldErrorShowed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_showed_fields&&-1!==this.validationData.invalid_showed_fields.indexOf(e)}},{key:"isInvalidFieldByValidator",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=!1;if(!this.validationData.validators)return n;var i=this.validationData.validators[t];return i?-1!==i.indexOf(e):n}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"hideElements",value:function(e){var t=[],n=pr.values(Ni).concat(pr.values(_i));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::hideElements: unsupported element ".concat(e[i])));t.length&&this.trigger(wr.HIDE_ELEMENTS,{elements:t.join(",")})}},{key:"showElements",value:function(e){var t=[],n=pr.values(Ni).concat(pr.values(_i));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::showElements: unsupported element ".concat(e[i])));t.length&&this.trigger(wr.SHOW_ELEMENTS,{elements:t.join(",")})}},{key:"updateFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.updateFormValue(t,e[t])}},{key:"updateFormValue",value:function(e,t){return-1===pr.values(_i).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void this.trigger(wr.UPDATE_FORM_VALUES,{form_values:"".concat(e,":").concat(t)})}},{key:"onFinishInsert",value:function(e,t){this.on(Zn.FINISH,(function(n){$n.insertToInput(e,t,n)}))}},{key:"interceptSubmitForm",value:function(e){var t=this;this.setHiddenElements([Ni.SUBMIT_BUTTON]);var n=new To(e);n.beforeSubmit((function(){t.triggerElement.push(wr.SUBMIT_FORM,{}),t.event.on(Zn.FINISH,t.link.getParams().widget_id,(function(){n.continueSubmit()}))}))}},{key:"useCheckoutAutoSubmit",value:function(){var e=this;this.setHiddenElements([Ni.SUBMIT_BUTTON]),this.on(Zn.CHECKOUT_SUCCESS,(function(t){e.trigger(wr.SUBMIT_FORM)})),this.on(Zn.VALIDATION_ERROR,(function(t){e.trigger(wr.REFRESH_CHECKOUT)})),this.on(Zn.SYSTEM_ERROR,(function(t){e.trigger(wr.REFRESH_CHECKOUT)}))}},{key:"useAutoResize",value:function(){var e=this;this.on(Zn.RESIZE,(function(t){e.iFrame.getElement()&&(e.iFrame.getElement().scrolling="no",t.height&&e.iFrame.setStyle("height",t.height+"px"))}))}}])}(So),Co=function(e){function n(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;return s(this,n),t(this,n,[e,i,new yo(r,o,a)])}return d(n,e),c(n,[{key:"setWebHookDestination",value:function(e){this.configs[0].setWebHookDestination(e)}},{key:"setSuccessRedirectUrl",value:function(e){this.configs[0].setSuccessRedirectUrl(e)}},{key:"setErrorRedirectUrl",value:function(e){this.configs[0].setErrorRedirectUrl(e)}},{key:"setFormFields",value:function(e){this.configs[0].setFormFields(e)}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){this.configs[0].setFormFields([e.field]),f(h(n.prototype),"setFormElement",this).call(this,u(u({},e),{field:e.field.replace("*","")}))}},{key:"setMeta",value:function(e){this.configs[0].setMeta(e)}},{key:"setGiftCardScheme",value:function(e,t){this.configs[0].setGiftCardSchemeData(e,t)}}])}(_o);!function(e){e.UNAVAILABLE="unavailable",e.ERROR="error",e.PAYMENT_SUCCESSFUL="paymentSuccessful",e.PAYMENT_ERROR="paymentError",e.PAYMENT_IN_REVIEW="paymentInReview",e.ON_CLICK="onClick",e.ON_CHECKOUT_CLOSE="onCheckoutClose"}(eo||(eo={}));var Oo=function(){return c((function e(t,n,i,r,o){s(this,e),this.env=G,this.eventEmitter=new vi,this.container=new Jn(t),this.api=new pi(n,this.getApiAuthType(n)),this.gatewayId=i,this.meta=r,this.validateRequiredMetaFields(o)}),[{key:"getApiAuthType",value:function(e){return Q.validateJWT(e)?Dn.TOKEN:Dn.PUBLIC_KEY}},{key:"setEnv",value:function(e,t){this.env=e,this.api.setEnv(e,t)}},{key:"onClick",value:function(e){if("function"==typeof e)return this.eventEmitter.subscribe(eo.ON_CLICK,e);this.handleOnError(new Error("onClick event handler is required to return the wallet token string."))}},{key:"onPaymentSuccessful",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.PAYMENT_SUCCESSFUL,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.PAYMENT_SUCCESSFUL,(function(t){return e(t)}))}))}},{key:"onPaymentInReview",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.PAYMENT_IN_REVIEW,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.PAYMENT_IN_REVIEW,(function(t){return e(t)}))}))}},{key:"onPaymentError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.PAYMENT_ERROR,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.PAYMENT_ERROR,(function(t){return e(t)}))}))}},{key:"onCheckoutClose",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.ON_CHECKOUT_CLOSE,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.ON_CHECKOUT_CLOSE,(function(t){return e(t)}))}))}},{key:"onUnavailable",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.UNAVAILABLE,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.UNAVAILABLE,(function(t){return e(t)}))}))}},{key:"onError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.ERROR,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.ERROR,(function(t){return e(t)}))}))}},{key:"getGatewayWalletConfig",value:function(){var e=this,t="gatewayConfig-".concat(this.gatewayId),n=localStorage.getItem(t);return new Promise((function(i,r){if(n){var o=JSON.parse(atob(n)),s=o.data,a=o.timestamp;if(Date.now()-a<864e5)return i(JSON.parse(s))}e.api.gateway().getWalletConfig(e.gatewayId).then((function(e){var n=btoa(JSON.stringify({data:JSON.stringify(e),timestamp:Date.now()}));return localStorage.setItem(t,n),i(e)})).catch(r)}))}},{key:"executeWalletCallback",value:function(e){var t=this;return this.api.charge().walletCallback(e).catch((function(e){var n;throw t.eventEmitter.emit(eo.PAYMENT_ERROR,{event:eo.PAYMENT_ERROR,chargeId:null===(n=t.chargeWalletTokenMeta)||void 0===n?void 0:n.charge.id,data:t.eventDataFromApiError(e)}),t.handleOnError(e),e}))}},{key:"executeWalletCapture",value:function(e){var t=this;return this.api.charge().walletCapture(e).then((function(e){var n,i="inreview"===e.status?eo.PAYMENT_IN_REVIEW:eo.PAYMENT_SUCCESSFUL;return t.eventEmitter.emit(i,{event:i,chargeId:null===(n=t.chargeWalletTokenMeta)||void 0===n?void 0:n.charge.id,data:e}),e})).catch((function(e){var n;throw t.eventEmitter.emit(eo.PAYMENT_ERROR,{event:eo.PAYMENT_ERROR,chargeId:null===(n=t.chargeWalletTokenMeta)||void 0===n?void 0:n.charge.id,data:t.eventDataFromApiError(e)}),e}))}},{key:"handleMerchantOnExpressButtonClickEvent",value:function(){var e=this;return this.eventEmitter.emitWithResult(eo.ON_CLICK,{event:eo.ON_CLICK}).then((function(t){if(!t||0===t.length){var n=new Error("No result from onClick event");throw e.handleOnError(n),n}var i=t[0];if(e.setWalletToken(i),e.chargeWalletTokenMeta.charge.amount!==e.meta.amount){var r=new Error("Wallet meta amount (".concat(e.chargeWalletTokenMeta.charge.amount,") and charge amount (").concat(e.meta.amount,') do not match. Consider using "setMeta" SDK method to update the amount.'));throw e.handleOnError(r),r}if(e.chargeWalletTokenMeta.charge.currency!==e.meta.currency){var o=new Error("Wallet meta currency (".concat(e.chargeWalletTokenMeta.charge.currency,") and charge currency (").concat(e.meta.currency,') do not match. Consider using "setMeta" SDK method to update the currency.'));throw e.handleOnError(o),o}}))}},{key:"setWalletToken",value:function(e){var t=Q.validateJWT(e);return t?(this.chargeWalletTokenMeta=Q.extractMeta(t.body),this.chargeWalletTokenMeta?(this.api.auth=e,void(this.api.authType=Dn.TOKEN)):this.handleOnError(new Error("Invalid charge token"))):this.handleOnError(new Error("Invalid charge token"))}},{key:"handleCheckoutClose",value:function(){var e,t=null===(e=this.chargeWalletTokenMeta)||void 0===e?void 0:e.charge.id;this.eventEmitter.emit(eo.ON_CHECKOUT_CLOSE,u({event:eo.ON_CHECKOUT_CLOSE},t&&{chargeId:t}))}},{key:"handleOnUnavailable",value:function(){this.eventEmitter.emit(eo.UNAVAILABLE,{event:eo.UNAVAILABLE})}},{key:"handleOnError",value:function(e){var t;e&&console.error(e);var n=null===(t=this.chargeWalletTokenMeta)||void 0===t?void 0:t.charge.id;this.eventEmitter.emit(eo.ERROR,u(u({event:eo.ERROR},n&&{chargeId:n}),{data:e}))}},{key:"eventDataFromApiError",value:function(e){var t,n,i,r;return{message:(null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.message)||(null==e?void 0:e.message)||(null===(n=null==e?void 0:e.error_summary)||void 0===n?void 0:n.message),code:(null===(i=null==e?void 0:e.error)||void 0===i?void 0:i.code)||(null==e?void 0:e.code)||(null===(r=null==e?void 0:e.error_summary)||void 0===r?void 0:r.code)}}},{key:"validateRequiredMetaFields",value:function(e){var t=this;if(!this.meta)throw new Error("Meta is required");if("number"!=typeof this.meta.amount)throw new Error("meta.amount needs to be numeric");if("string"!=typeof this.meta.currency)throw new Error("meta.amount needs to be a string");e.forEach((function(e){var n,i=e.split("."),r=t.meta,o=b(i);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(void 0===r[s]||null===r[s])throw new Error("Meta field ".concat(e," is required"));r=r[s]}}catch(e){o.e(e)}finally{o.f()}}))}}])}(),No=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i,r,o,["amount_label","country"]])).onValidateMerchant=function(e){a.handleMerchantOnExpressButtonClickEvent().then((function(){a.getMerchantSession().then((function(e){a.paymentSession.completeMerchantValidation(e)})).catch((function(){a.paymentSession.abort(),a.handleCheckoutClose()}))})).catch((function(){a.paymentSession.abort(),a.handleCheckoutClose()}))},a.onPaymentAuthorized=function(e){var t=e.payment,n=t.token,i=t.billingContact,r=t.shippingContact;a.executeWalletCapture({customer:{first_name:null==i?void 0:i.givenName,last_name:null==i?void 0:i.familyName,email:(null==i?void 0:i.emailAddress)||(null==r?void 0:r.emailAddress),phone:(null==i?void 0:i.phoneNumber)||(null==r?void 0:r.phoneNumber),payment_source:{wallet_type:ki.APPLE,address_line1:null==i?void 0:i.addressLines[0],address_line2:null==i?void 0:i.addressLines[1],address_country:null==i?void 0:i.countryCode,address_city:null==i?void 0:i.locality,address_postcode:null==i?void 0:i.postalCode,address_state:null==i?void 0:i.administrativeArea,ref_token:n.paymentData?JSON.stringify(n.paymentData):""}}}).then((function(){a.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS)})).catch((function(){a.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE)}))},a.onCancelPayment=function(){return a.handleCheckoutClose()},a}return d(n,e),c(n,[{key:"load",value:function(){var e=this;if(!window.Promise)return this.handleOnUnavailable();this.getGatewayWalletConfig().then((function(t){if(!(t&&"MasterCard"===t.type&&t.credentials&&t.credentials.apple&&t.credentials.apple.merchant))throw new Error("Invalid configuration");return e.checkAvailability(t)})).then((function(t){return t?e.mount():e.handleOnUnavailable()})).catch((function(t){t&&e.handleOnError(t),e.handleOnUnavailable()}))}},{key:"setMeta",value:function(e){this.meta=e}},{key:"checkAvailability",value:function(e){return new Promise((function(t,n){window.ApplePaySession&&ApplePaySession||t(!1),ApplePaySession.canMakePaymentsWithActiveCard(e.credentials[ki.APPLE].merchant).then((function(e){return t(e)})).catch((function(e){return t(!1)}))}))}},{key:"mount",value:function(){var e,t,n=this,i=document.createElement("style");i.innerHTML=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"plain";return"\n .paydock-apple-container {\n display: inline-block;\n width: 100%;\n height: 44px;\n cursor: pointer;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: ".concat(e,";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-outline {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: ").concat(e,";\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-outline {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ")}(null===(e=this.meta.style)||void 0===e?void 0:e.button_type),document.head.appendChild(i);var r=document.createElement("div");r.onclick=function(){return n.onApplePayButtonClicked()},r.classList.add("paydock-apple-container","apple-pay-button","apple-pay-button-".concat((null===(t=this.meta.style)||void 0===t?void 0:t.button_style)||"black")),r.setAttribute("tabindex","0"),r.setAttribute("role","button"),this.container.getElement().appendChild(r)}},{key:"onApplePayButtonClicked",value:function(){this.paymentSession=new ApplePaySession(3,this.createRequest()),this.paymentSession.onvalidatemerchant=this.onValidateMerchant,this.paymentSession.onpaymentauthorized=this.onPaymentAuthorized,this.paymentSession.oncancel=this.onCancelPayment,this.paymentSession.begin()}},{key:"createRequest",value:function(){var e;return{countryCode:this.meta.country,currencyCode:this.meta.currency,merchantCapabilities:this.meta.merchant_capabilities||["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:this.meta.supported_networks||["visa","masterCard","amex","discover"],requiredBillingContactFields:this.meta.required_billing_contact_fields||["email","name","phone","postalAddress"],requiredShippingContactFields:this.meta.required_shipping_contact_fields,supportedCountries:this.meta.supported_countries,total:{label:this.meta.amount_label,amount:null===(e=this.meta.amount)||void 0===e?void 0:e.toFixed(2),type:"final"}}}},{key:"getMerchantSession",value:function(){return this.executeWalletCallback({request_type:"CREATE_SESSION",wallet_type:ki.APPLE,session_id:window.location.hostname})}}])}(Oo),Io=function(e){function n(e,i,r,o){return s(this,n),t(this,n,[e,i,r,o,[]])}return d(n,e),c(n,[{key:"load",value:function(){var e=this;if(!window.Promise)return this.handleOnUnavailable();this.getGatewayWalletConfig().then((function(t){if(!t||"Paypal"!==t.type||!t.credentials||!t.credentials.client_auth)throw new Error("Invalid configuration");e.config=t,e.renderPaypalButton()})).catch((function(t){t&&e.handleOnError(t),e.handleOnUnavailable()}))}},{key:"setMeta",value:function(e){this.meta=e,this.renderPaypalButton()}},{key:"renderPaypalButton",value:function(){!0===this.meta.standalone?this.renderPaypalStandaloneComponent():this.renderPaypalCommonComponent()}},{key:"renderPaypalCommonComponent",value:function(){var e,t,n=this,i=(null===(e=this.container.getElement())||void 0===e?void 0:e.id)||"",r=document.createElement("script");r.src="https://www.paypal.com/sdk/js?client-id=".concat(null===(t=this.config.credentials)||void 0===t?void 0:t.client_auth,"¤cy=").concat(this.meta.currency).concat(!0===this.meta.pay_later?"&enable-funding=paylater&disable-funding=card":"&disable-funding=credit,card").concat(this.meta.capture?"":"&intent=authorize"),r.async=!0,r.onload=function(){window.paypal?(n.paypal=window.paypal,n.paypal.Buttons(u({},n.paypalSharedProps())).render("#".concat(i))):n.handleOnUnavailable()},document.head.appendChild(r)}},{key:"renderPaypalStandaloneComponent",value:function(){var e,t,n,i=this,r=(null===(e=this.container.getElement())||void 0===e?void 0:e.id)||"",o=document.createElement("script");o.src="https://www.paypal.com/sdk/js?client-id=".concat(null===(t=this.config.credentials)||void 0===t?void 0:t.client_auth,"¤cy=").concat(this.meta.currency,"&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(this.meta.capture?"":"&intent=authorize").concat("live"===(null===(n=this.config)||void 0===n?void 0:n.mode)?"":"&buyer-country=AU"),o.async=!0,o.onload=function(){var e;if(window.paypal){i.paypal=window.paypal;var t=!!i.meta.pay_later,n=i.paypal.Buttons(u({fundingSource:t?i.paypal.FUNDING.PAYLATER:i.paypal.FUNDING.PAYPAL},i.paypalSharedProps()));if(n.isEligible()){if(n.render("#".concat(r)),t)i.paypal.Messages(u({amount:i.meta.amount,currency:i.meta.currency,placement:"payment"},(null===(e=i.meta.style)||void 0===e?void 0:e.messages)&&{style:i.meta.style.messages})).render("#".concat(r))}else i.handleOnUnavailable()}else i.handleOnUnavailable()},document.head.appendChild(o)}},{key:"paypalSharedProps",value:function(){var e=this;return u(u({},this.meta.style&&{style:this.meta.style}),{onClick:function(t,n){return e.handleMerchantOnExpressButtonClickEvent().then((function(){return n.resolve()})).catch((function(){return e.handleCheckoutClose(),n.reject()}))},createOrder:function(){return new Promise((function(t,n){return e.api.auth?e.executeWalletCallback({request_type:"CREATE_TRANSACTION"}).then((function(e){t(e.id)})).catch((function(e){n(e)})):n(new Error("Wallet Token not injected. Please handle onClick correctly."))}))},onApprove:function(t){return e.pendingApprovalPromise||(e.pendingApprovalPromise=e.executeWalletCapture({payment_method_id:t.orderID,customer:{payment_source:{external_payer_id:t.payerID}}}).finally((function(){e.pendingApprovalPromise=void 0}))),e.pendingApprovalPromise},onCancel:function(){return e.handleCheckoutClose()},onError:function(){}})}}])}(Oo);class Ao{constructor(e,t){if(!e.onEnd)throw new Error("onEnd handler is required");if(!t)throw new Error("ms duration is required");this.onEnd=e.onEnd,this.initialMs=t,this.startTimestamp=Date.now(),this.timer=this.create(this.onEnd,t)}create(e,t){return this.timer&&this.clear(),setTimeout((()=>e?e():this.onEnd()),t||this.initialMs)}clear(){clearTimeout(this.timer),this.timer=null}end(){this.clear(),this.onEnd()}isValid(){return this.initialMs-(Date.now()-this.startTimestamp)>0}}function Ro(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];It("visibilitychange",(function(){if(t)return void("hidden"===document.visibilityState&&e());e(document.visibilityState)}),arguments.length>2?arguments[2]:void 0,arguments.length>3?arguments[3]:void 0)}class xo extends Ao{constructor(e,t){super(e,t),this.onPause="function"==typeof e.onPause?e.onPause:()=>{},this.onRefresh="function"==typeof e.onRefresh?e.onRefresh:()=>{},this.onResume="function"==typeof e.onResume?e.onResume:()=>{},this.readStorage=e.readStorage,this.remainingMs=void 0,e.refreshEvents||(e.refreshEvents=["click","keydown","scroll"]);try{this.abortController=new AbortController}catch(e){}if(ie&&e.ee){if(e.ee){this.ee=e.ee;const t=function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=i?.leading||!1;let o;return function(){for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];r&&void 0===o&&(e.apply(t,s),o=setTimeout((()=>{o=clearTimeout(o)}),n)),r||(clearTimeout(o),o=setTimeout((()=>{e.apply(t,s)}),n))}}(this.refresh.bind(this),500,{leading:!0});this.refreshHandler=n=>{e.refreshEvents.includes(n?.[0]?.type)&&t()},e.ee.on("fn-end",this.refreshHandler)}Ro((e=>{"hidden"===e?this.pause():this.resume()}),!1,!1,this.abortController?.signal)}}abort(){this.clear(),this.abortController?.abort(),this.refreshHandler&&(this.ee.removeEventListener("fn-end",this.refreshHandler),this.refreshHandler=this.ee=null)}pause(){this.onPause(),clearTimeout(this.timer),this.remainingMs=this.initialMs-(Date.now()-this.startTimestamp)}resume(){try{const t=this.readStorage(),n="string"==typeof t?JSON.parse(t):t;e(n.expiresAt)||e(n.inactiveAt)?this.end():(this.refresh(),this.onResume())}catch(e){this.end()}function e(e){return Date.now()>e}}refresh(e,t){this.clear(),this.timer=this.create(e,t),this.startTimestamp=Date.now(),this.remainingMs=void 0,this.onRefresh()}}const Mo="nr@original:".concat(rt);var Po=Object.prototype.hasOwnProperty,Do=!1;function Lo(e,t){return e||(e=st),n.inPlace=function(e,t,i,r,o){i||(i="");const s="-"===i.charAt(0);for(let a=0;a<t.length;a++){const c=t[a],l=e[c];Uo(l)||(e[c]=n(l,s?c+i:i,r,c,o))}},n.flag=Mo,n;function n(t,n,r,o,s){return Uo(t)?t:(n||(n=""),a[Mo]=t,function(e,t,n){if(Object.defineProperty&&Object.keys)try{return Object.keys(e).forEach((function(n){Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){return e[n]=t,t}})})),t}catch(e){Fo([e],n)}for(var i in e)Po.call(e,i)&&(t[i]=e[i])}(t,a,e),a);function a(){var a,c,l,u;try{c=this,a=[...arguments],l="function"==typeof r?r(a,c):r||{}}catch(t){Fo([t,"",[a,c,o],l],e)}i(n+"start",[a,c,o],l,s);try{return u=t.apply(c,a)}catch(e){throw i(n+"err",[a,c,e],l,s),e}finally{i(n+"end",[a,c,u],l,s)}}}function i(n,i,r,o){if(!Do||t){var s=Do;Do=!0;try{e.emit(n,i,r,t,o)}catch(t){Fo([t,n,i,r],e)}Do=s}}}function Fo(e,t){t||(t=st);try{t.emit("internal-error",e)}catch(e){}}function Uo(e){return!(e&&"function"==typeof e&&e.apply&&!e[Mo])}const jo={},Bo=oe.XMLHttpRequest,Ho="addEventListener",zo="removeEventListener",Vo="nr@wrapped:".concat(ot);function Wo(e){var t=function(e){return(e||st).get("events")}(e);if(jo[t.debugId]++)return t;jo[t.debugId]=1;var n=Lo(t,!0);function i(e){n.inPlace(e,[Ho,zo],"-",r)}function r(e,t){return e[1]}return"getPrototypeOf"in Object&&(ie&&qo(document,i),qo(oe,i),qo(Bo.prototype,i)),t.on(Ho+"-start",(function(e,t){var i=e[1];if(null!==i&&("function"==typeof i||"object"==typeof i)){var r=Ee(i,Vo,(function(){var e={object:function(){if("function"!=typeof i.handleEvent)return;return i.handleEvent.apply(i,arguments)},function:i}[typeof i];return e?n(e,"fn-",null,e.name||"anonymous"):i}));this.wrapped=e[1]=r}})),t.on(zo+"-start",(function(e){e[1]=this.wrapped||e[1]})),t}function qo(e,t){let n=e;for(;"object"==typeof n&&!Object.prototype.hasOwnProperty.call(n,Ho);)n=Object.getPrototypeOf(n);for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];n&&t(n,...r)}const Go={value:"",inactiveAt:0,expiresAt:0,updatedAt:Date.now(),sessionReplayMode:Fe.OFF,sessionReplaySentFirstChunk:!1,sessionTraceMode:Fe.OFF,traceHarvestStarted:!1,serverTimeDiff:null,custom:{}};class Ko{constructor(e){const{agentIdentifier:t,key:n,storage:i}=e;if(!t||!n||!i)throw new Error("Missing required field(s):".concat(t?"":" agentID").concat(n?"":" key").concat(i?"":" storage"));this.agentIdentifier=t,this.storage=i,this.state={},this.key=n,this.ee=st.get(t),Wo(this.ee),this.setup(e),ie&&Nt("storage",(e=>{if(e.key===this.lookupKey){const t="string"==typeof e.newValue?JSON.parse(e.newValue):e.newValue;this.sync(t),this.ee.emit(Pe,[Le,this.state])}}))}setup(e){let{value:t=it(16),expiresMs:n=Ne,inactiveMs:i=Ie}=e;const r={serverTimeDiff:this.state.serverTimeDiff||Go.serverTimeDiff};this.state={},this.sync({...Go,...r}),this.state.value=t,this.expiresMs=n,this.inactiveMs=i;const o=this.read();n?(this.state.expiresAt=o?.expiresAt||this.getFutureTimestamp(n),this.expiresTimer=new Ao({onEnd:()=>{this.collectSM("expired"),this.collectSM("duration"),this.reset()}},this.state.expiresAt-Date.now())):this.state.expiresAt=1/0,i?(this.state.inactiveAt=o?.inactiveAt||this.getFutureTimestamp(i),this.inactiveTimer=new xo({onEnd:()=>{this.collectSM("inactive"),this.collectSM("duration"),this.reset()},onRefresh:this.refresh.bind(this),onResume:()=>{this.ee.emit(Me)},onPause:()=>{this.initialized&&this.ee.emit(Re),this.write(ke(this.state,Go))},ee:this.ee,refreshEvents:["click","keydown","scroll"],readStorage:()=>this.storage.get(this.lookupKey)},this.state.inactiveAt-Date.now())):this.state.inactiveAt=1/0,this.isNew||=!Object.keys(o).length,this.isNew?this.write(ke(this.state,Go),!0):this.sync(o),this.initialized=!0,this.ee.emit(Ae,[this.isNew])}get lookupKey(){return"".concat("NRBA","_").concat(this.key)}sync(e){Object.assign(this.state,e)}read(){try{const e=this.storage.get(this.lookupKey);if(!e)return{};const t="string"==typeof e?JSON.parse(e):e;return this.isInvalid(t)?{}:this.isExpired(t.expiresAt)?(this.collectSM("expired"),this.collectSM("duration",t,!0),this.reset()):this.isExpired(t.inactiveAt)?(this.collectSM("inactive"),this.collectSM("duration",t,!0),this.reset()):t}catch(e){return we("Failed to read from storage API",e),{}}}write(e){try{if(!e||"object"!=typeof e)return;return e.updatedAt=Date.now(),this.sync(e),this.storage.set(this.lookupKey,Xt(this.state)),this.ee.emit(Pe,[De,this.state]),e}catch(e){return we("Failed to write to the storage API",e),null}}reset(){try{return this.initialized&&this.ee.emit(xe),this.storage.remove(this.lookupKey),this.inactiveTimer?.abort?.(),this.expiresTimer?.clear?.(),delete this.isNew,this.setup({agentIdentifier:this.agentIdentifier,key:this.key,storage:this.storage,expiresMs:this.expiresMs,inactiveMs:this.inactiveMs}),this.read()}catch(e){return{}}}refresh(){const e=this.read();this.write({...e,inactiveAt:this.getFutureTimestamp(this.inactiveMs)})}isExpired(e){return Date.now()>e}isInvalid(e){return!Object.keys(Go).every((t=>Object.keys(e).includes(t)))}collectSM(e,t,n){let i,r;"duration"===e&&(i=this.getDuration(t,n),r="Session/Duration/Ms"),"expired"===e&&(r="Session/Expired/Seen"),"inactive"===e&&(r="Session/Inactive/Seen"),r&<(un,[r,i],void 0,ft.metrics,this.ee)}getDuration(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state,t=arguments.length>1?arguments[1]:void 0;const n=e.expiresAt-this.expiresMs;return(t?Date.now():e.updatedAt)-n}getFutureTimestamp(e){return Date.now()+e}syncCustomAttribute(e,t){if(ie)if(null===t){const t=this.read();t.custom&&(delete t.custom[e],this.write({...t}))}else{const n=this.read();this.custom={...n?.custom||{},[e]:t},this.write({...n,custom:this.custom})}}}class Yo{get(e){try{return localStorage.getItem(e)||void 0}catch(e){return""}}set(e,t){try{return null==t?this.remove(e):localStorage.setItem(e,t)}catch(e){}}remove(e){try{localStorage.removeItem(e)}catch(e){}}}let $o=0;var Jo=Object.freeze({__proto__:null,setupAgentSession:function(e){const t=Ze(e);if($o++)return t.session;const n=ze(e).session;t.session=new Ko({agentIdentifier:e,key:"SESSION",storage:new Yo,expiresMs:n?.expiresMs,inactiveMs:n?.inactiveMs});const i=t.session.state.custom,r=_e(e);i&&(r.jsAttributes={...r.jsAttributes,...i});const o=st.get(e);return ht("api-setCustomAttribute",((e,n,i)=>{t.session.syncCustomAttribute(n,i)}),"session",o),ht("api-setUserId",((e,n,i)=>{t.session.syncCustomAttribute(n,i)}),"session",o),Et(e,"session"),t.session}});var Xo=Object.freeze({__proto__:null,lazyFeatureLoader:function(e,t){if("aggregate"===t)switch(e){case ft.ajax:return Promise.resolve().then((function(){return Bs}));case ft.jserrors:return Promise.resolve().then((function(){return ta}));case ft.metrics:return Promise.resolve().then((function(){return ka}));case ft.pageAction:return Promise.resolve().then((function(){return Sa}));case ft.pageViewEvent:return Promise.resolve().then((function(){return Xc}));case ft.pageViewTiming:return Promise.resolve().then((function(){return rl}));case ft.sessionReplay:return Promise.resolve().then((function(){return ll}));case ft.sessionTrace:return Promise.resolve().then((function(){return gl}));case ft.spa:return Promise.resolve().then((function(){return Yl}));case ft.softNav:return Promise.resolve().then((function(){return lu}));default:throw new Error("Attempted to load unsupported agent feature: ".concat(e," ").concat(t))}}});var Zo=Object.freeze({__proto__:null,setAPI:function(e){var t=st.get(e),n={finished:Dt((function(e,n){var r=n?n-pe:e;lt(dn,["finished",{time:r}],void 0,ft.metrics,t),i(e,{name:"finished",start:r+pe,origin:"nr"}),lt("api-addPageAction",[r,"finished"],void 0,ft.pageAction,t)})),setErrorHandler:function(t,n){Ze(e).onerror=n},addToTrace:i,addRelease:function(t,n,i){if(++r>10)return;Ze(e).releaseIds[n.slice(-200)]=(""+i).slice(-200)}};function i(e,n){n&&"object"==typeof n&&n.name&&n.start&<("bstApi",[{n:n.name,s:n.start-pe,e:(n.end||n.start)-pe,o:n.origin||"",t:"api"}],void 0,ft.sessionTrace,t)}Object.entries(n).forEach((e=>{let[n,i]=e;return ht("api-"+n,i,"api",t)}));var r=0}});
|
|
13
|
+
*/const rt=nt(),ot="nr@context:".concat(rt),st=function e(t,n){var i={},r={},o={},s=!1;try{s=16===n.length&&Ze(n).isolatedBacklog}catch(e){}var a={on:l,addEventListener:l,removeEventListener:function(e,t){var n=i[e];if(!n)return;for(var r=0;r<n.length;r++)n[r]===t&&n.splice(r,1)},emit:function(e,n,i,o,s){!1!==s&&(s=!0);if(st.aborted&&!o)return;t&&s&&t.emit(e,n,i);for(var l=c(i),d=u(e),p=d.length,f=0;f<p;f++)d[f].apply(l,n);var m=h()[r[e]];m&&m.push([a,e,n,l]);return l},get:d,listeners:u,context:c,buffer:function(e,t){const n=h();if(t=t||"feature",a.aborted)return;Object.entries(e||{}).forEach((e=>{let[i,o]=e;r[o]=t,t in n||(n[t]=[])}))},abort:function(){a._aborted=!0,Object.keys(a.backlog).forEach((e=>{delete a.backlog[e]}))},isBuffering:function(e){return!!h()[r[e]]},debugId:n,backlog:s?{}:t&&"object"==typeof t.backlog?t.backlog:{},isolatedBacklog:s};return Object.defineProperty(a,"aborted",{get:()=>{let e=a._aborted||!1;return e||(t&&(e=t.aborted),e)}}),a;function c(e){return e&&e instanceof et?e:e?Ee(e,ot,(()=>new et(ot))):new et(ot)}function l(e,t){i[e]=u(e).concat(t)}function u(e){return i[e]||[]}function d(t){return o[t]=o[t]||e(a,t)}function h(){return a.backlog}}(void 0,"globalEE"),at=me();at.ee||(at.ee=st);var ct=st.get("handle");function lt(e,t,n,i,r){r?(r.buffer([e],i),r.emit(e,t,n)):(ct.buffer([e],i),ct.emit(e,t,n))}const ut=(e,t)=>Object.entries(e||{}).map((e=>{let[n,i]=e;return t(n,i)}));ht.on=pt;var dt=ht.handlers={};function ht(e,t,n,i){pt(i||ct,dt,e,t,n)}function pt(e,t,n,i,r){r||(r="feature"),e||(e=ct);var o=t[r]=t[r]||{};(o[n]=o[n]||[]).push([e,i])}const ft={ajax:"ajax",jserrors:"jserrors",metrics:"metrics",pageAction:"page_action",pageViewEvent:"page_view_event",pageViewTiming:"page_view_timing",sessionReplay:"session_replay",sessionTrace:"session_trace",softNav:"soft_navigations",spa:"spa"},mt={[ft.pageViewEvent]:1,[ft.pageViewTiming]:2,[ft.metrics]:3,[ft.jserrors]:4,[ft.ajax]:5,[ft.sessionTrace]:6,[ft.pageAction]:7,[ft.spa]:8,[ft.softNav]:9,[ft.sessionReplay]:10},vt={};function gt(e,t){const n={staged:!1,priority:mt[t]||0};bt(e),vt[e].get(t)||vt[e].set(t,n)}function yt(e,t){bt(e),vt[e].get(t)&&vt[e].delete(t),vt[e].size&&wt(e)}function bt(e){if(!e)throw new Error("agentIdentifier required");vt[e]||(vt[e]=new Map)}function Et(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"feature",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(bt(e),!e||!vt[e].get(t)||n)return kt(e,t);vt[e].get(t).staged=!0,wt(e)}function wt(e){const t=Array.from(vt[e]);t.every((e=>{let[t,n]=e;return n.staged}))&&(t.sort(((e,t)=>e[1].priority-t[1].priority)),t.forEach((t=>{let[n]=t;vt[e].delete(n),kt(e,n)})))}function kt(e,t){const n=e?st.get(e):st,i=ht.handlers;if(n.backlog&&i){var r=n.backlog[t],o=i[t];if(o){for(var s=0;r&&s<r.length;++s)St(r[s],o);ut(o,(function(e,t){ut(t,(function(t,n){n[0].on(e,n[1])}))}))}n.isolatedBacklog||delete i[t],n.backlog[t]=null,n.emit("drain-"+t,[])}}function St(e,t){var n=e[1];ut(t[n],(function(t,n){var i=e[0];if(n[0]===i){var r=n[1],o=e[3],s=e[2];r.apply(o,s)}}))}class Tt{constructor(e,t,n){this.agentIdentifier=e,this.aggregator=t,this.ee=st.get(e),this.featureName=n,this.blocked=!1}}let _t=!1,Ct=!1;try{const e={get passive(){return _t=!0,!1},get signal(){return Ct=!0,!1}};oe.addEventListener("test",null,e),oe.removeEventListener("test",null,e)}catch(e){}function Ot(e,t){return _t||Ct?{capture:!!e,passive:_t,signal:t}:!!e}function Nt(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;window.addEventListener(e,t,Ot(n,i))}function It(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;document.addEventListener(e,t,Ot(n,i))}function At(){return"undefined"==typeof document||"complete"===document.readyState}function Rt(e,t){if(At())return e();Nt("load",e,t)}const xt=e=>ie&&!0===Ve(e,"privacy.cookies_enabled");function Mt(e,t){return!!function(e){return!!Ke.MO&&xt(e)&&!0===Ve(e,"session_trace.enabled")}(e)&&(!!t?.isNew||!!t?.state.sessionReplayMode)}function Pt(e,t){const n=t.correctAbsoluteTimestamp(e);return{originalTimestamp:e,correctedTimestamp:n,timestampDiff:e-n,originTime:pe,correctedOriginTime:t.correctedOriginTime,originTimeDiff:Math.floor(pe-t.correctedOriginTime)}}function Dt(e){var t=this;let n=!1;return function(){if(!n){n=!0;for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];e.apply(t,r)}}}class Lt extends Tt{constructor(e,t,n){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];super(e,t,n),this.auto=i,this.abortHandler=void 0,this.featAggregate=void 0,this.onAggregateImported=void 0,!1===Ve(this.agentIdentifier,"".concat(this.featureName,".autoStart"))&&(this.auto=!1),this.auto?gt(e,n):this.ee.on("manual-start-all",Dt((()=>{gt(this.agentIdentifier,this.featureName),this.auto=!0,this.importAggregator()})))}importAggregator(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.featAggregate||!this.auto)return;this.onAggregateImported=new Promise((t=>{e=t}));const n=async()=>{let n;try{if(xt(this.agentIdentifier)){const{setupAgentSession:e}=await Promise.resolve().then((function(){return Jo}));n=e(this.agentIdentifier)}}catch(e){we("A problem occurred when starting up session manager. This page will not start or extend any session.",e),this.featureName===ft.sessionReplay&&this.abortHandler?.()}try{if(!this.#e(this.featureName,n))return Et(this.agentIdentifier,this.featureName),void e(!1);const{lazyFeatureLoader:i}=await Promise.resolve().then((function(){return Xo})),{Aggregate:r}=await i(this.featureName,"aggregate");this.featAggregate=new r(this.agentIdentifier,this.aggregator,t),e(!0)}catch(t){we("Downloading and initializing ".concat(this.featureName," failed..."),t),this.abortHandler?.(),Et(this.agentIdentifier,this.featureName,!0),e(!1),this.ee&&this.ee.abort()}};ie?Rt((()=>n()),!0):n()}#e(e,t){return e!==ft.sessionReplay||Mt(this.agentIdentifier,t)}}const Ft=ft.jserrors,Ut=ft.sessionReplay,jt={RECORD:"recordReplay",PAUSE:"pauseReplay",REPLAY_RUNNING:"replayRunning",ERROR_DURING_REPLAY:"errorDuringReplay"},Bt=2,Ht=4,zt={[Fe.ERROR]:15e3,[Fe.FULL]:3e5,[Fe.OFF]:0},Vt={message:"Session was reset",sm:"Reset"},Wt={message:"Recorder failed to import",sm:"Import"},qt={message:"429: Too Many Requests",sm:"Too-Many"},Gt={message:"Payload was too large",sm:"Too-Big"},Kt={message:"Session Entity was set to OFF on another tab",sm:"Cross-Tab"},Yt={message:"Session Replay is not allowed and will not be started",sm:"Entitlement"},$t="api",Jt=()=>{const e=new WeakSet;return(t,n)=>{if("object"==typeof n&&null!==n){if(e.has(n))return;e.add(n)}return n}};function Xt(e){try{return JSON.stringify(e,Jt())}catch(e){try{st.emit("internal-error",[e])}catch(e){}}}class Zt{constructor(e,t,n,i,r){this.name="UncaughtError",this.message="string"==typeof e?e:Xt(e),this.sourceURL=t,this.line=n,this.column=i,this.__newrelic=r}}function Qt(e){return nn(e)?e:new Zt(void 0!==e?.message?e.message:e,e?.filename||e?.sourceURL,e?.lineno||e?.line,e?.colno||e?.col,e?.__newrelic)}function en(e){let t="Unhandled Promise Rejection";if(nn(e?.reason))try{return e.reason.message=t+": "+e.reason.message,Qt(e.reason)}catch(t){return Qt(e.reason)}if(void 0===e.reason)return Qt(t);const n=Qt(e.reason);return n.message=t+": "+n?.message,n}function tn(e){if(e.error instanceof SyntaxError&&!/:\d+$/.test(e.error.stack?.trim())){const t=new Zt(e.message,e.filename,e.lineno,e.colno,e.error.__newrelic);return t.name=SyntaxError.name,t}return nn(e.error)?e.error:Qt(e)}function nn(e){return e instanceof Error&&!!e.stack}let rn=class extends Lt{static featureName=Ft;#t=!1;constructor(e,t){super(e,t,Ft,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);try{this.removeOnAbort=new AbortController}catch(e){}this.ee.on("internal-error",(e=>{this.abortHandler&<("ierr",[Qt(e),ne(),!0,{},this.#t],void 0,this.featureName,this.ee)})),this.ee.on(jt.REPLAY_RUNNING,(e=>{this.#t=e})),oe.addEventListener("unhandledrejection",(e=>{this.abortHandler&<("err",[en(e),ne(),!1,{unhandledPromiseRejection:1},this.#t],void 0,this.featureName,this.ee)}),Ot(!1,this.removeOnAbort?.signal)),oe.addEventListener("error",(e=>{this.abortHandler&<("err",[tn(e),ne(),!1,{},this.#t],void 0,this.featureName,this.ee)}),Ot(!1,this.removeOnAbort?.signal)),this.abortHandler=this.#n,this.importAggregator()}#n(){this.removeOnAbort?.abort(),this.abortHandler=void 0}};const on=ft.pageViewEvent;let sn=class extends Lt{static featureName=on;constructor(e,t){super(e,t,on,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]),this.importAggregator()}};const an=Object.values(ft);function cn(e){const t={};return an.forEach((n=>{t[n]=function(e,t){return!0===Ve(t,"".concat(e,".enabled"))}(n,e)})),t}const ln=ft.metrics,un="storeSupportabilityMetrics",dn="storeEventMetrics",hn=["setErrorHandler","finished","addToTrace","addRelease","addPageAction","setCurrentRouteName","setPageViewName","setCustomAttribute","interaction","noticeError","setUserId","setApplicationVersion","start",jt.RECORD,jt.PAUSE],pn=["setErrorHandler","finished","addToTrace","addRelease"];function fn(){const e=ye();hn.forEach((t=>{e[t]=function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];let o=[];return Object.values(e.initializedAgents).forEach((e=>{e.exposed&&e.api[t]&&o.push(e.api[t](...i))})),o.length>1?o:o[0]}(t,...i)}}))}const mn={};const vn="newrelic";const gn=new Set,yn={};function bn(e,t){const n=st.get(t);yn[t]??={},e&&"object"==typeof e&&(gn.has(t)||(n.emit("rumresp",[e]),yn[t]=e,gn.add(t),function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{oe.dispatchEvent(new CustomEvent(vn,{detail:e}))}catch(e){}}({loaded:!0})))}let En=!1;function wn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,{init:r,info:o,loader_config:s,runtime:a={loaderType:n},exposed:c=!0}=t;const l=ye();o||(r=l.init,o=l.info,s=l.loader_config),function(e,t){if(!e)throw new Error(He);Be[e]=ke(t,je());const n=ge(e);n&&(n.init=Be[e])}(e.agentIdentifier,r||{}),function(e,t){if(!e)throw new Error("All loader-config objects require an agent identifier!");qe[e]=ke(t,We);const n=ge(e);n&&(n.loader_config=qe[e])}(e.agentIdentifier,s||{}),o.jsAttributes??={},re&&(o.jsAttributes.isWorker=!0),Ce(e.agentIdentifier,o);const u=ze(e.agentIdentifier),d=[o.beacon,o.errorBeacon];var h,p;En||(u.proxy.assets&&(u.proxy.assets,d.push(u.proxy.assets)),u.proxy.beacon&&d.push(u.proxy.beacon),fn(),h="activatedFeatures",p=yn,me()[h]=p,e.runSoftNavOverSpa&&=!0===u.soft_navigations.enabled&&u.feature_flags.includes("soft_nav")),a.denyList=[...u.ajax.deny_list||[],...u.ajax.block_internal?d:[]],a.ptid=e.agentIdentifier,function(e,t){if(!e)throw new Error("All runtime objects require an agent identifier!");Xe[e]={...ke(t,Je),...$e};const n=ge(e);n&&(n.runtime=Xe[e])}(e.agentIdentifier,a),void 0===e.api&&(e.api=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||gt(e,"api");const i={};var r=st.get(e),o=r.get("tracer");mn[e]=Fe.OFF,r.on(jt.REPLAY_RUNNING,(t=>{mn[e]=t}));var s="api-",a=s+"ixn-";function c(t,n,i,r){const o=_e(e);return null===n?delete o.jsAttributes[t]:Ce(e,{...o,jsAttributes:{...o.jsAttributes,[t]:n}}),d(s,i,!0,r||null===n?"session":void 0)(t,n)}function l(){}pn.forEach((e=>{i[e]=d(s,e,!0,"api")})),i.addPageAction=d(s,"addPageAction",!0,ft.pageAction),i.setPageViewName=function(t,n){if("string"==typeof t)return"/"!==t.charAt(0)&&(t="/"+t),Ze(e).customTransaction=(n||"http://custom.transaction")+t,d(s,"setPageViewName",!0)()},i.setCustomAttribute=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof e){if(["string","number","boolean"].includes(typeof t)||null===t)return c(e,t,"setCustomAttribute",n);we("Failed to execute setCustomAttribute.\nNon-null value must be a string, number or boolean type, but a type of <".concat(typeof t,"> was provided."))}else we("Failed to execute setCustomAttribute.\nName must be a string type, but a type of <".concat(typeof e,"> was provided."))},i.setUserId=function(e){if("string"==typeof e||null===e)return c("enduser.id",e,"setUserId",!0);we("Failed to execute setUserId.\nNon-null value must be a string type, but a type of <".concat(typeof e,"> was provided."))},i.setApplicationVersion=function(e){if("string"==typeof e||null===e)return c("application.version",e,"setApplicationVersion",!1);we("Failed to execute setApplicationVersion. Expected <String | null>, but got <".concat(typeof e,">."))},i.start=()=>{try{lt(un,["API/start/called"],void 0,ft.metrics,r),r.emit("manual-start-all")}catch(e){we("An unexpected issue occurred",e)}},i[jt.RECORD]=function(){lt(un,["API/recordReplay/called"],void 0,ft.metrics,r),lt(jt.RECORD,[],void 0,ft.sessionReplay,r)},i[jt.PAUSE]=function(){lt(un,["API/pauseReplay/called"],void 0,ft.metrics,r),lt(jt.PAUSE,[],void 0,ft.sessionReplay,r)},i.interaction=function(e){return(new l).get("object"==typeof e?e:{})};const u=l.prototype={createTracer:function(e,t){var i={},s=this,c="function"==typeof t;return lt(un,["API/createTracer/called"],void 0,ft.metrics,r),n||lt(a+"tracer",[ne(),e,i],s,ft.spa,r),function(){if(o.emit((c?"":"no-")+"fn-start",[ne(),s,c],i),c)try{return t.apply(this,arguments)}catch(e){const t="string"==typeof e?new Error(e):e;throw o.emit("fn-err",[arguments,this,t],i),t}finally{o.emit("fn-end",[ne()],i)}}}};function d(e,t,n,i){return function(){return lt(un,["API/"+t+"/called"],void 0,ft.metrics,r),i&<(e+t,[ne(),...arguments],n?null:this,i,r),n?void 0:this}}function h(){Promise.resolve().then((function(){return Zo})).then((t=>{let{setAPI:n}=t;n(e),Et(e,"api")})).catch((e=>{we("Downloading runtime APIs failed...",e),r.abort()}))}return["actionText","setName","setAttribute","save","ignore","onEnd","getContext","end","get"].forEach((e=>{u[e]=d(a,e,void 0,n?ft.softNav:ft.spa)})),i.setCurrentRouteName=n?d(a,"routeName",void 0,ft.softNav):d(s,"routeName",!0,ft.spa),i.noticeError=function(t,n){"string"==typeof t&&(t=new Error(t)),lt(un,["API/noticeError/called"],void 0,ft.metrics,r),lt("err",[t,ne(),!1,n,!!mn[e]],void 0,ft.jserrors,r)},ie?Rt((()=>h()),!0):h(),i}(e.agentIdentifier,i,e.runSoftNavOverSpa)),void 0===e.exposed&&(e.exposed=c),En=!0}const kn={agentIdentifier:"",ee:void 0};class Sn{constructor(e){try{if("object"!=typeof e)return we("shared context requires an object as input");this.sharedContext={},Object.assign(this.sharedContext,kn),Object.entries(e).forEach((e=>{let[t,n]=e;Object.keys(kn).includes(t)&&(this.sharedContext[t]=n)}))}catch(e){we("An error occurred while setting SharedContext",e)}}}class Tn extends Sn{constructor(e){super(e),this.aggregatedData={}}store(e,t,n,i,r){var o=this.getBucket(e,t,n,r);return o.metrics=function(e,t){t||(t={count:0});return t.count+=1,ut(e,(function(e,n){t[e]=_n(n,t[e])})),t}(i,o.metrics),o}merge(e,t,n,i,r){var o=this.getBucket(e,t,i,r);if(o.metrics){var s=o.metrics;s.count+=n.count,ut(n,(function(e,t){if("count"!==e){var i=s[e],r=n[e];r&&!r.c?s[e]=_n(r.t,i):s[e]=function(e,t){if(!t)return e;t.c||(t=Cn(t.t));return t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max),t.t+=e.t,t.sos+=e.sos,t.c+=e.c,t}(r,s[e])}}))}else o.metrics=n}storeMetric(e,t,n,i){var r=this.getBucket(e,t,n);return r.stats=_n(i,r.stats),r}getBucket(e,t,n,i){this.aggregatedData[e]||(this.aggregatedData[e]={});var r=this.aggregatedData[e][t];return r||(r=this.aggregatedData[e][t]={params:n||{}},i&&(r.custom=i)),r}get(e,t){return t?this.aggregatedData[e]&&this.aggregatedData[e][t]:this.aggregatedData[e]}take(e){for(var t={},n="",i=!1,r=0;r<e.length;r++)t[n=e[r]]=Object.values(this.aggregatedData[n]||{}),t[n].length&&(i=!0),delete this.aggregatedData[n];return i?t:null}}function _n(e,t){return null==e?function(e){e?e.c++:e={c:1};return e}(t):t?(t.c||(t=Cn(t.t)),t.c+=1,t.t+=e,t.sos+=e*e,e>t.max&&(t.max=e),e<t.min&&(t.min=e),t):{t:e}}function Cn(e){return{t:e,min:e,max:e,sos:e*e,c:1}}class On{agentIdentifier;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:it(16);this.agentIdentifier=e,this.ee=st.get(e)}#i(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if("function"==typeof this.api?.[e])return this.api[e](...n);we("Call to agent api ".concat(e," failed. The API is not currently initialized."))}addPageAction(e,t){return this.#i("addPageAction",e,t)}setPageViewName(e,t){return this.#i("setPageViewName",e,t)}setCustomAttribute(e,t,n){return this.#i("setCustomAttribute",e,t,n)}noticeError(e,t){return this.#i("noticeError",e,t)}setUserId(e){return this.#i("setUserId",e)}setApplicationVersion(e){return this.#i("setApplicationVersion",e)}setErrorHandler(e){return this.#i("setErrorHandler",e)}finished(e){return this.#i("finished",e)}addRelease(e,t){return this.#i("addRelease",e,t)}start(e){return this.#i("start",e)}recordReplay(){return this.#i(jt.RECORD)}pauseReplay(){return this.#i(jt.PAUSE)}addToTrace(e){return this.#i("addToTrace",e)}setCurrentRouteName(e){return this.#i("setCurrentRouteName",e)}interaction(){return this.#i("interaction")}}const Nn=[ft.jserrors,ft.pageAction,ft.metrics];class In extends On{constructor(e,t){super(t),this.sharedAggregator=new Tn({agentIdentifier:this.agentIdentifier}),this.features={},function(e,t){let n=me();n.initializedAgents??={},t.initializedAt={ms:ne(),date:new Date},n.initializedAgents[e]=t}(this.agentIdentifier,this),wn(this,{...e,runtime:{isolatedBacklog:!0}},e.loaderType||"micro-agent"),Object.assign(this,this.api),this.start=e=>this.run(e),this.run(Nn.filter((e=>Ve(this.agentIdentifier,"".concat(e,".autoStart")))))}get config(){return{info:_e(this.agentIdentifier),init:ze(this.agentIdentifier),loader_config:Ge(this.agentIdentifier),runtime:Ze(this.agentIdentifier)}}run(e){try{const t=Nn;if(void 0===e)e=t;else{if((e=Array.isArray(e)&&e.length?e:[e]).some((e=>!t.includes(e))))return we("Invalid feature name supplied. Acceptable feature names are: ".concat(t));e.includes(ft.pageViewEvent)||e.push(ft.pageViewEvent)}}catch(e){we("An unexpected issue occurred",e)}try{const t=cn(this.agentIdentifier);try{this.features.page_view_event=new sn(this.agentIdentifier,this.sharedAggregator)}catch(e){we("Something prevented the agent from instrumenting.",e)}return Rt((()=>{Nn.forEach((n=>{t[n]&&e.includes(n)&&Promise.resolve().then((function(){return Xo})).then((e=>{let{lazyFeatureLoader:t}=e;return t(n,"aggregate")})).then((e=>{let{Aggregate:t}=e;this.features[n]=new t(this.agentIdentifier,this.sharedAggregator)})).catch((e=>we("Something prevented the agent from being downloaded.",e)))}))})),!0}catch(e){return we("Failed to initialize instrument classes.",e),!1}}}const An=ft.pageAction;class Rn extends Lt{static featureName=An;constructor(e,t){super(e,t,An,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]),this.importAggregator()}}function xn(){var e,t,n=(e="bam.nr-data.net",t={enabled:"true",accountId:"974691",agentId:"1386157152",applicationId:"1386157152",licenseKey:"4848a32285",trustKey:"974691"},{browserAgent:{available:Object.values(t).every(Boolean),options:{info:{applicationID:t.applicationId,licenseKey:t.licenseKey,beacon:e,errorBeacon:e,sa:1},init:{distributed_tracing:{autoStart:!1,enabled:!1},jserrors:{autoStart:!0,enabled:!0},metrics:{autoStart:!1,enabled:!1},page_action:{autoStart:!0,enabled:!0},page_view_event:{autoStart:!0,enabled:!0},page_view_timing:{autoStart:!1,enabled:!1},session_replay:{autoStart:!1,enabled:!1},session_trace:{autoStart:!1,enabled:!1},spa:{autoStart:!1,enabled:!1},ajax:u(u({},{autoStart:!1,enabled:!1}),{deny_list:[e,"undefined"==typeof window?void 0:window.location.host].filter(Boolean)}),privacy:{cookies_enabled:!1}},loaderConfig:{accountID:t.accountId,agentID:t.agentId,applicationID:t.applicationId,licenseKey:t.licenseKey,trustKey:t.trustKey}}}}).browserAgent;return{available:n.available,options:n.options}}var Mn=function(e){function n(e){var i;return s(this,n),(i=t(this,n,[e])).call=function(e){if(i.isAvailable()){for(var t,r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];(t=n.agent)[e].apply(t,o)}},i}return d(n,e),c(n,[{key:"isAvailable",value:function(){return n.available}}],[{key:"instance",get:function(){if(!n.initialized){var e=xn(),t=e.available,i=e.options;n.available=t,t&&(n.agent=new n(i),n.agent.start([rn.featureName,Rn.featureName,sn.featureName])),n.initialized=!0}return n.agent}}])}(In),Pn=function(){return c((function e(){s(this,e),this.agent=Mn.instance}),[{key:"createAction",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(this,void 0,void 0,i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.agent).addPageAction.apply(n,t);case 1:case"end":return e.stop()}}),e,this)})))}}])}();new Pn;var Dn,Ln=function(){return c((function e(){s(this,e),this.agent=Mn.instance}),[{key:"createError",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(this,void 0,void 0,i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.agent).noticeError.apply(n,t);case 1:case"end":return e.stop()}}),e,this)})))}}])}(),Fn=new Ln,Un=function(){return c((function e(){s(this,e),this.agent=Mn.instance}),[{key:"createEvent",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return te(this,void 0,void 0,i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.agent).addPageAction.apply(n,t);case 1:case"end":return e.stop()}}),e,this)})))}}])}();new Un,function(e){e[e.PUBLIC_KEY=0]="PUBLIC_KEY",e[e.TOKEN=1]="TOKEN"}(Dn||(Dn={}));var jn,Bn,Hn,zn=function(){function e(t,n){s(this,e),this.reportEvent=function(e,t){e.createEvent(t)},this.reportError=function(e,t,n){e.createError(t,n)},this.auth=t,this.authType=n||this.setAuthType(),this.env=new $(W)}return c(e,[{key:"setEnv",value:function(e,t){return this.env.setEnv(e,t),this}},{key:"setAuthType",value:function(){return this.authType=Q.validateJWT(this.auth)?Dn.TOKEN:Dn.PUBLIC_KEY,this.authType}},{key:"getClient",value:function(e,t){var n=this,i=this.newApiRequest(e,t);return{config:i,send:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};i.onload=function(){return n.parser({text:i.responseText,status:i.status},t,(function(e){n.reportError(Fn,e,u(u({},n.ctx),{classMethod:"getClient",description:"Send unsuccessful."})),r(e)}))},i.send(JSON.stringify(e))}}}},{key:"getClientPromise",value:function(e,t){var n=this,i=this.newApiRequest(e,t);return{config:i,send:function(e){return new Promise((function(t,n){i.onload=function(){return t({text:i.responseText,status:i.status})},i.send(JSON.stringify(e))})).then((function(e){return n.parserPromise(e)})).catch((function(e){throw n.reportError(Fn,e,u(u({},n.ctx),{classMethod:"getClientPromise",description:"Send unsuccessful."})),e}))}}}},{key:"parser",value:function(e,t,n){var i=e.text,r=e.status;try{var o=JSON.parse(i);if(r>=200&&r<300||302===r)return t(o.resource.data);n(o.error||{message:"unknown error"})}catch(e){this.reportError(Fn,e,u(u({},this.ctx),{classMethod:"parser",description:"Unable to parse response body to json."}))}}},{key:"parserPromise",value:function(e){var t=e.text,n=e.status;try{var i=JSON.parse(t);return n>=200&&n<300||302===n?Promise.resolve(i.resource.data):Promise.reject(i.error||{message:"unknown error"})}catch(e){return this.reportError(Fn,e,u(u({},this.ctx),{classMethod:"parserPromise",description:"Unable to parse response body to json."})),Promise.reject(e)}}},{key:"newApiRequest",value:function(e,t){var n=ee.create(e,this.env.getConf().url+t).setContentTypeJson().setSdkVersion();switch(this.authType){case Dn.PUBLIC_KEY:n.setPublicKey(this.auth);break;case Dn.TOKEN:n.setAccessToken(this.auth)}return n.inner()}},{key:"ctx",get:function(){return{sdkVersion:J.version,className:e.name,environment:this.env.getEnv()}}}])}(),Vn=function(e){function n(e){var i;return s(this,n),(i=t(this,n,[e])).publicKey=i.auth,i}return d(n,e),c(n,[{key:"getBrowserDetails",value:function(){return{name:E.getBrowserName(),java_enabled:E.isJavaEnabled().toString(),language:E.getLanguage(),screen_height:E.getScreenHeight().toString(),screen_width:E.getScreenWidth().toString(),time_zone:E.getTimezoneOffset().toString(),color_depth:E.getColorDepth().toString()}}},{key:"charge",value:function(){return new k(this)}}])}(zn),Wn=function(){return c((function e(){s(this,e)}),null,[{key:"extendSearchParams",value:function(e,t,n){return e.replace(new RegExp("([?&]"+t+"(?=[=&#]|$)[^#&]*|(?=#|$))"),"&"+t+"="+encodeURIComponent(n)).replace(/^([^?&]+)&/,"$1?")}},{key:"serialize",value:function(e){return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&")}}])}(),qn=function(){return c((function e(){s(this,e)}),null,[{key:"generate",value:function(){if("undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.getRandomValues){var e=new Uint16Array(8);return window.crypto.getRandomValues(e),this.hash(e[0])+this.hash(e[1])+"-"+this.hash(e[2])+"-"+this.hash(e[3])+"-"+this.hash(e[4])+"-"+this.hash(e[5])+this.hash(e[6])+this.hash(e[7])}return this.random()+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+"-"+this.random()+this.random()+this.random()}},{key:"hash",value:function(e){for(var t=e.toString(16);t.length<4;)t="0"+t;return t}},{key:"random",value:function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}}])}(),Gn="/wallet/flypay",Kn="/images/logo.png",Yn=function(){return c((function e(t){s(this,e),this.params={},this.widgetId=qn.generate(),this.linkResource=t,this.env=new $(V),this.setParams({widget_id:this.widgetId})}),[{key:"getNetUrl",value:function(){return this.env.getConf().url+this.linkResource}},{key:"getUrl",value:function(){var e=this.getNetUrl(),t=this.getParams();for(var n in t)t.hasOwnProperty(n)&&(e=Wn.extendSearchParams(e,n,t[n]));return e}},{key:"setParams",value:function(e){this.params=u({},this.params,e)}},{key:"concatParams",value:function(e){for(var t in e)e.hasOwnProperty(t)&&e[t].length&&("string"!=typeof this.params[t]&&(this.params[t]=""),this.params[t].length?this.params[t]+=","+e[t]:this.params[t]+=e[t])}},{key:"getParams",value:function(){return this.params}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getBaseUrl",value:function(){return this.env.getConf().url}}])}(),$n=function(){return c((function e(){s(this,e)}),null,[{key:"insertToInput",value:function(e,t,n){if(void 0!==n[t]){var i=document.querySelector(e);i&&(i.value=n[t])}}},{key:"subscribe",value:function(e,t,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent("on".concat(e),n)}}])}(),Jn=function(){return c((function e(t){s(this,e),this.selector=t}),[{key:"isExist",value:function(){return!!this.getElement()}},{key:"getStyles",value:function(e){if(this.isExist()){var t=this.getElement().getAttribute("widget-style");if(!t)return{};var n=t.split(";");return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"on",value:function(e,t){this.isExist()&&$n.subscribe(e,this.getElement(),t)}},{key:"getAttr",value:function(e){if(this.isExist()){var t=this.getElement(),n=[];for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].replace(/_/g,"-"),o=t.getAttribute(r);o&&n.push("".concat(e[i],":").concat(o))}return void 0===n||n.length?this.convertConfigs(n,e):{}}}},{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"getSelector",value:function(){return this.selector}},{key:"convertConfigs",value:function(e,t){var n={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i].split(":"),o=r[0].replace(/-/g,"_").trim();-1!==t.indexOf(o)&&(n[o]=r[1].trim())}return n}}])}(),Xn=function(){return c((function e(t){s(this,e),this.container=t}),[{key:"load",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("src",e),t.title&&(n.title=t.title),this.container.getElement().appendChild(n)}}},{key:"loadFromHtml",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.container.isExist()&&!this.isExist()){var n=document.createElement("iframe");n.setAttribute("height","100%"),n.setAttribute("width","100%"),t.title&&(n.title=t.title);this.container.getElement().appendChild(n);var i=this.getElement().contentDocument;i.open(),i.write("<html><head><style>html, body {margin: 0;} iframe {border: 0; width: 100%}</style><title></title></head><body>{{content}}</body></html>".replace("{{content}}",e)),i.close()}}},{key:"remove",value:function(){if(this.container.isExist()&&this.isExist()){var e=this.getElement();this.container.getElement().removeChild(e)}}},{key:"show",value:function(){this.isExist()&&(this.setStyle("visibility","visible"),this.setStyle("display","block"))}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isExist()&&(e?this.setStyle("visibility","hidden"):this.setStyle("display","none"))}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"getElement",value:function(){return this.container.isExist()?this.container.getElement().querySelector("iframe"):null}},{key:"setStyle",value:function(e,t){this.getElement().style[e]=t}}])}(),Zn={AFTER_LOAD:"afterLoad",SUBMIT:"submit",FINISH:"finish",VALIDATION_ERROR:"validationError",SYSTEM_ERROR:"systemError",CHECKOUT_SUCCESS:"checkoutSuccess",CHECKOUT_READY:"checkoutReady",CHECKOUT_ERROR:"checkoutError",CHECKOUT_COMPLETED:"checkoutCompleted",CHECKOUT_POPUP_OPEN:"checkoutPopupOpen",CHECKOUT_POPUP_CLOSE:"checkoutPopupClose",VALIDATION:"validation",SELECT:"select",UNSELECT:"unselect",NEXT:"next",PREV:"prev",META_CHANGE:"metaChange",RESIZE:"resize",CHARGE_AUTH_SUCCESS:"chargeAuthSuccess",CHARGE_AUTH_REJECT:"chargeAuthReject",CHARGE_AUTH_CANCELLED:"chargeAuthCancelled",ADDITIONAL_DATA_SUCCESS:"additionalDataCollectSuccess",ADDITIONAL_DATA_REJECT:"additionalDataCollectReject",CHARGE_AUTH:"chargeAuth",DISPATCH_SUCCESS:"dispatchSuccess",DISPATCH_ERROR:"dispatchError"},Qn=function(){return c((function e(t){var n=this;s(this,e),this.listeners=[],t&&$n.subscribe("message",t,(function(e){var t;try{t=JSON.parse(e.data)}catch(e){}t&&n.emit(t)}))}),[{key:"emit",value:function(e){for(var t in this.listeners)this.listeners[t].event===e.event&&e.widget_id===this.listeners[t].widget_id&&this.listeners[t].listener.apply(this,[e])}},{key:"on",value:function(e,t,n){for(var i in Zn)Zn.hasOwnProperty(i)&&e===Zn[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}},{key:"clear",value:function(){this.listeners=[]}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("message",t):e.attachEvent("onmessage",t)}}])}(),ei={visibility:"hidden",border:"0",width:"0",height:"0"};!function(e){e.SUCCESS="success",e.ERROR="error",e.PENDING="pending"}(jn||(jn={})),function(e){e.SUCCESS="success",e.PENDING="pending",e.ERROR="error"}(Bn||(Bn={})),function(e){e.FINISHED="MethodFinished",e.SKIPPED="MethodSkipped",e.READY="ResultReady",e.TIMEOUT="AuthTimedOut",e.INVALID="invalid_event"}(Hn||(Hn={}));var ti,ni="chargeAuthSuccess",ii="chargeAuthReject",ri="chargeAuthDecoupled",oi="chargeAuthChallenge",si="chargeAuthInfo",ai="error",ci=function(){return c((function e(t,n,i){s(this,e),this.container=t,this.api=n,this.eventEmitter=i,this.resultRead=!1,this.iFrameEvent=new Qn(window)}),[{key:"load",value:function(e,t){var n=e.initialization_url,i=e.secondary_url,r=e.charge_3ds_id;try{this.setupIFrameEvents(r),this.initializeIFrames(n,i,t)}catch(e){this.eventEmitter.emit(ai,this.parseError(e,r))}}},{key:"initializeIFrames",value:function(e,t,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=this.container.getElement();if(r){var o=document.createElement("div");if(o.setAttribute("id","paydock_authorization_iframe"),r.appendChild(o),this.browserAndChallengeContainer=new Jn("#paydock_authorization_iframe"),this.iFrameAuthorization=new Xn(this.browserAndChallengeContainer),this.iFrameAuthorization.load(e,{title:n}),t){var s=document.createElement("div");s.setAttribute("id","paydock_secondary_iframe"),r.appendChild(s),this.monitoringContainer=new Jn("#paydock_secondary_iframe"),this.iFrameSecondaryUrl=new Xn(this.monitoringContainer),this.iFrameSecondaryUrl.load(t,{title:n})}else this.iFrameSecondaryUrl=void 0;this.hideIframes(i)}}},{key:"hideIframes",value:function(){var e,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];for(var n in ei)ei.hasOwnProperty(n)&&(t&&this.iFrameAuthorization.setStyle(n,ei[n]),null===(e=this.iFrameSecondaryUrl)||void 0===e||e.setStyle(n,ei[n]))}},{key:"setupIFrameEvents",value:function(e){var t=this;this.iFrameEvent.on(Zn.CHARGE_AUTH,e,(function(e){e.status===Hn.SKIPPED||e.status===Hn.FINISHED?(e.info&&t.eventEmitter.emit(si,{info:e.info}),t.performAuthentication(e)):e.status!==Hn.TIMEOUT&&e.status!==Hn.INVALID||t.eventEmitter.emit(ii,t.parseHandleResponse({status:e.status},e.charge_3ds_id))})),this.iFrameEvent.on(Zn.CHARGE_AUTH_SUCCESS,e,(function(e){t.processResult(e.charge_3ds_id)}))}},{key:"parseResultData",value:function(e,t){return{status:e.status,charge_3ds_id:t}}},{key:"parseHandleResponse",value:function(e,t){var n=e.status,i=e.result;return{status:n,charge_3ds_id:t,result:{description:null==i?void 0:i.description}}}},{key:"parseError",value:function(e,t){return{charge_3ds_id:t,error:e}}},{key:"processResult",value:function(e){var t=this;this.resultRead||(this.resultRead=!0,this.api.charge().standalone3dsHandle().then((function(n){var i;t.iFrameAuthorization.remove(),null===(i=t.iFrameSecondaryUrl)||void 0===i||i.remove(),n.status===jn.SUCCESS?t.eventEmitter.emit(ni,t.parseResultData(n,e)):t.eventEmitter.emit(ii,t.parseResultData(n,e))}),(function(n){t.eventEmitter.emit(ai,t.parseError(n,e))})))}},{key:"externalAPI",value:function(e,t){var n=ee.create(e,t).inner();return new Promise((function(e,t){n.onload=function(){try{var i=JSON.parse(n.responseText);e(i)}catch(e){t(e)}},n.send()}))}},{key:"doPolling",value:function(e,t){var n=this;this.externalAPI("GET",e).then((function(i){if(i.event&&"AuthResultNotReady"!==i.event){if("AuthResultReady"!==i.event)throw new Error("Event not supported");n.processResult(t)}else setTimeout((function(){n.doPolling(e,t)}),2e3)})).catch((function(e){return n.eventEmitter.emit(ai,n.parseError(e,t))}))}},{key:"performAuthentication",value:function(e){var t,n=this,i=e.charge_3ds_id;this.iFrameAuthorization.remove(),null===(t=this.iFrameSecondaryUrl)||void 0===t||t.remove(),this.api.charge().standalone3dsProcess({charge_3ds_id:i}).then((function(e){var t,r;if(e.status===Bn.SUCCESS)n.eventEmitter.emit(ni,n.parseHandleResponse(e,i));else{if(e.status!==Bn.PENDING)return n.eventEmitter.emit(ii,n.parseHandleResponse(e,i));(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.challenge)?(n.eventEmitter.emit(oi,n.parseHandleResponse(e,i)),n.initializeIFrames(e.result.challenge_url,void 0,"Authentication Challenge",!1),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i)):(null===(r=null==e?void 0:e.result)||void 0===r?void 0:r.decoupled_challenge)&&(n.eventEmitter.emit(ri,n.parseHandleResponse(e,i)),e.result.secondary_url&&n.doPolling(e.result.secondary_url,i))}}),(function(e){n.eventEmitter.emit(ai,n.parseError(e,i))}))}}])}(),li=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"walletCapture",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/capture").send(e)}},{key:"walletCallback",value:function(e){return this.api.getClientPromise("POST","/v1/charges/wallet/callback").send(e)}},{key:"standalone3dsProcess",value:function(e){return this.api.getClientPromise("POST","/v1/charges/standalone-3ds/process").send(e)}},{key:"standalone3dsHandle",value:function(){return this.api.getClientPromise("GET","/v1/charges/standalone-3ds/handle").send(void 0)}}])}(),ui=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"getWalletConfig",value:function(e){var t="/v1/gateways/:gateway_id/wallet-config".replace(":gateway_id",e);return this.api.getClientPromise("GET",t).send(void 0)}}])}(),di=function(){return c((function e(t){s(this,e),this.api=t}),[{key:"getConfig",value:function(e){var t="/v1/services/:service_id/config".replace(":service_id",e);return this.api.getClientPromise("GET",t).send(void 0)}}])}();!function(e){e.VISA_SRC="VisaSRC",e.MASTERCARD_SRC="ClickToPay"}(ti||(ti={}));var hi,pi=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"charge",value:function(){return new li(this)}},{key:"service",value:function(){return new di(this)}},{key:"gateway",value:function(){return new ui(this)}}])}(zn),fi="GPayments",mi=function(){return c((function e(t,n){s(this,e),this.env=G,this.container=t,this.eventEmitter=n}),[{key:"load",value:function(e,t){var n=Q.validateJWT(e);if(!n)throw new Error("Invalid charge token");var i=Q.extractData(n.body),r=new pi(e,Dn.TOKEN);if(r.setEnv(this.env,this.alias),i.service_type===fi)new ci(this.container,r,this.eventEmitter).load(i,t.title)}},{key:"setEnv",value:function(e,t){this.env=e,this.alias=t}}])}(),vi=function(){return c((function e(){s(this,e),this.events={}}),[{key:"emit",value:function(e,t){var n=this.events[e];n&&n.forEach((function(e){e.call(null,t)}))}},{key:"emitWithResult",value:function(e,t){var n=this,r=this.events[e];if(r){var o=r.map((function(e){return te(n,void 0,void 0,i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.call(null,t));case 1:case"end":return n.stop()}}),n)})))}));return Promise.all(o)}return Promise.resolve([])}},{key:"subscribe",value:function(e,t){var n=this;return this.events[e]||(this.events[e]=[]),this.events[e].push(t),function(){n.events[e]=n.events[e].filter((function(e){return t!==e}))}}}])}();!function(e){e.HTML="html",e.URL="url",e.STANDALONE_3DS="standalone_3ds"}(hi||(hi={}));var gi,yi,bi=function(){return c((function e(t,n){s(this,e),this.configs=[],this.link=new Yn("/3ds/webhook"),this.token=e.extractToken(n),this.link.setParams({ref_id:this.token.charge_3ds_id}),this.container=new Jn(t),this.iFrame=new Xn(this.container),this.eventEmitter=new vi,this.standalone3dsService=new mi(this.container,this.eventEmitter),this.event=new Qn(window)}),[{key:"load",value:function(){this.token.format===hi.HTML?this.iFrame.loadFromHtml(this.token.content,{title:"3d secure authentication"}):this.token.format===hi.URL?this.iFrame.load(this.token.content,{title:"3d secure authentication"}):this.token.format===hi.STANDALONE_3DS?this.standalone3dsService.load(this.token.content,{title:"3d secure authentication"}):console.error("Token contain unsupported payload")}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.standalone3dsService.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"on",value:function(e,t){var n=this;return this.token.format===hi.STANDALONE_3DS?"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))})):"function"==typeof t?this.event.on(e,this.link.getParams().ref_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().ref_id,(function(e){return t(e)}))}))}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}}],[{key:"extractToken",value:function(e){return JSON.parse(window.atob(e))}}])}(),Ei={CLICK:"click",POPUP_REDIRECT:"popupRedirect",REDIRECT:"redirect",ERROR:"error",REFERRED:"referred",DECLINED:"declined",CANCELLED:"cancelled",ACCEPTED:"accepted",FINISH:"finish",CLOSE:"close"};!function(e){e.CONTEXTUAL="contextual",e.REDIRECT="redirect"}(gi||(gi={})),function(e){e.ZIPMONEY="Zipmoney",e.PAYPAL="PaypalClassic",e.AFTERPAY="Afterpay"}(yi||(yi={}));var wi,ki,Si="[Paydock:CheckoutButton]",Ti={CARD:"card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},_i={CARD_NAME:"card_name",CARD_NUMBER:"card_number",EXPIRE_MONTH:"expire_month",EXPIRE_YEAR:"expire_year",CARD_CCV:"card_ccv",CARD_PIN:"card_pin",ACCOUNT_NAME:"account_name",ACCOUNT_BSB:"account_bsb",ACCOUNT_NUMBER:"account_number",ACCOUNT_ROUTING:"account_routing",ACCOUNT_HOLDER_TYPE:"account_holder_type",ACCOUNT_BANK_NAME:"account_bank_name",ACCOUNT_TYPE:"account_type",FIRST_NAME:"first_name",LAST_NAME:"last_name",EMAIL:"email",PHONE:"phone",PHONE2:"phone2",ADDRESS_LINE1:"address_line1",ADDRESS_LINE2:"address_line2",ADDRESS_STATE:"address_state",ADDRESS_COUNTRY:"address_country",ADDRESS_CITY:"address_city",ADDRESS_POSTCODE:"address_postcode",ADDRESS_COMPANY:"address_company"},Ci={BACKGROUND_COLOR:"background_color",BACKGROUND_ACTIVE_COLOR:"background_active_color",TEXT_COLOR:"text_color",BORDER_COLOR:"border_color",ICON_SIZE:"icon_size",BUTTON_COLOR:"button_color",ERROR_COLOR:"error_color",SUCCESS_COLOR:"success_color",FONT_SIZE:"font_size",FONT_FAMILY:"font_family"},Oi={TITLE:"title",TITLE_H1:"title_h1",TITLE_H2:"title_h2",TITLE_H3:"title_h3",TITLE_H4:"title_h4",TITLE_H5:"title_h5",TITLE_H6:"title_h6",FINISH:"finish_text",TITLE_DESCRIPTION:"title_description",SUBMIT_BUTTON:"submit_button",SUBMIT_BUTTON_PROCESSING:"submit_button_processing"},Ni={SUBMIT_BUTTON:"submit_button",TABS:"tabs"},Ii={AMEX:"amex",AUSBC:"ausbc",DINERS:"diners",DISCOVER:"discover",JAPCB:"japcb",LASER:"laser",MASTERCARD:"mastercard",SOLO:"solo",VISA:"visa",VISA_WHITE:"visa_white"},Ai=[].concat(["brand_name","cart_border_color","reference","email","hdr_img","logo_img","pay_flow_color","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone","hide_shipping_address"],["first_name","last_name","phone","tokenize","email","gender","date_of_birth","charge","statistics","hide_shipping_address"],["amount","currency","email","first_name","last_name","address_line","address_line2","address_city","address_state","address_postcode","address_country","phone"],["customer_storage_number","tokenise_algorithm"]);!function(e){e.STRIPE="Stripe",e.FLYPAY="Flypay",e.FLYPAY_V2="FlypayV2",e.PAYPAL="Paypal",e.MASTERCARD="MasterCard",e.AFTERPAY="Afterpay"}(wi||(wi={})),function(e){e.GOOGLE="google",e.APPLE="apple",e.FLYPAY="flypay",e.FLYPAY_V2="flypayV2",e.PAYPAL="paypal",e.AFTERPAY="afterpay"}(ki||(ki={}));var Ri,xi=function(){return c((function e(){s(this,e),this.env=new $(W)}),[{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"getUrl",value:function(){return this.env.getConf().url+this.getLink()}},{key:"create",value:function(e,t,n,i){var r=this,o=ee.create("POST",this.getUrl()).setHeader(Q.getAccessHeaderNameByToken(e),e).setContentTypeJson().setSdkVersion().inner();o.onload=function(){r.parser(o.responseText,o.status,n,i)},o.send(JSON.stringify(t))}},{key:"get",value:function(e,t,n){var i=this,r=ee.create("GET",this.getUrl()).setHeader(Q.getAccessHeaderNameByToken(e),e).setContentTypeJson().setSdkVersion().inner();r.onload=function(){i.parser(r.responseText,r.status,t,n)},r.send()}},{key:"parser",value:function(e,t,n,i){var r={};try{r=JSON.parse(e)}catch(e){}return t>=200&&t<300||302===t?n(r.resource.data,t):i(r.error||{message:"unknown error"},t)}}])}(),Mi=function(e){function n(e,i,r){var o;return s(this,n),(o=t(this,n)).body={gateway_id:e,meta:{},success_redirect_url:i,error_redirect_url:r,redirect_url:i},o}return d(n,e),c(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout"}},{key:"setDescriptions",value:function(e){this.body.description=e}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==Ai.indexOf(t)?this.body.meta[t]=e[t]:console.warn("ExternalCheckout::setMeta: unsupported meta key ".concat(t)))}},{key:"getConfigs",value:function(){return this.body}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e,t){};this.create(e,this.getConfigs(),(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error"),"unknown_error"):n(e.message,e.code)}))}}])}(xi),Pi=function(e){function n(e){var i;return s(this,n),(i=t(this,n)).token=e,i}return d(n,e),c(n,[{key:"getLink",value:function(){return"/v1/payment_sources/external_checkout/:token".replace(":token",this.token)}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.get(e,(function(e,n){t(e)}),(function(e,t){void 0===e.message?n("".concat(t,": unknown error")):n(e.message)}))}}])}(xi),Di='\n <div class="cs-loader">\n <div class="cs-loader-inner">\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n <label>\t●</label>\n </div>\n </div>\n',Li="\n <style> \n .cs-loader {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n }\n \n .cs-loader-inner {\n transform: translateY(-50%);\n top: 50%;\n position: absolute;\n width: calc(100% - 200px);\n color: #8e8d8c;\n padding: 0 100px;\n text-align: center;\n }\n \n \n .cs-loader-inner label {\n font-size: 20px;\n opacity: 0;\n display:inline-block;\n }\n \n @keyframes lol {\n 0% {\n opacity: 0;\n transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n transform: translateX(300px);\n }\n }\n \n @-webkit-keyframes lol {\n 0% {\n opacity: 0;\n -webkit-transform: translateX(-300px);\n }\n 33% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 66% {\n opacity: 1;\n -webkit-transform: translateX(0px);\n }\n 100% {\n opacity: 0;\n -webkit-transform: translateX(300px);\n -moz-transform: translateX(300px);\n }\n }\n \n .cs-loader-inner label:nth-child(6) {\n -webkit-animation: lol 3s infinite ease-in-out;\n -moz-animation: lol 3s infinite ease-in-out;\n animation: lol 3s infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(5) {\n -webkit-animation: lol 3s 100ms infinite ease-in-out;\n -moz-animation: lol 3s 100ms infinite ease-in-out;\n animation: lol 3s 100ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(4) {\n -webkit-animation: lol 3s 200ms infinite ease-in-out;\n -moz-animation: lol 3s 200ms infinite ease-in-out;\n animation: lol 3s 200ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(3) {\n -webkit-animation: lol 3s 300ms infinite ease-in-out;\n -moz-animation: lol 3s 300ms infinite ease-in-out;\n animation: lol 3s 300ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(2) {\n -webkit-animation: lol 3s 400ms infinite ease-in-out;\n -moz-animation: lol 3s 400ms infinite ease-in-out;\n animation: lol 3s 400ms infinite ease-in-out;\n }\n \n .cs-loader-inner label:nth-child(1) {\n -webkit-animation: lol 3s 500ms infinite ease-in-out;\n -moz-animation: lol 3s 500ms infinite ease-in-out;\n animation: lol 3s 500ms infinite ease-in-out;\n }\n </style>\n",Fi="close",Ui="focus",ji=function(){return c((function e(){s(this,e),this.description="Don't see the secure checkout browser? We'll help you re-launch the window to complete your purchase",this.title="Checkout",this.overlay=null,this.style=null,this.showControl=!0,this.showLoader=!0,this.eventEmitter=new vi}),[{key:"initControl",value:function(){if(!this.isInit()&&this.showControl){if(!E.isSupportPopUp())return this.createLoader();this.createTemplate(),this.createStyles(),this.eventHandler()}}},{key:"initLoader",value:function(){!this.isInit()&&this.showLoader&&(this.createStyles(),this.createLoader())}},{key:"eventHandler",value:function(){var e=this,t=document.querySelector("[data-close]"),n=document.querySelector("[data-continue]");t&&$n.subscribe("click",t,(function(){return e.eventEmitter.emit(Fi,{})})),n&&$n.subscribe("click",n,(function(){return e.eventEmitter.emit(Ui,{})}))}},{key:"clear",value:function(){(this.style||this.overlay)&&(this.style.parentNode.removeChild(this.style),this.overlay.parentNode.removeChild(this.overlay),this.style=null,this.overlay=null)}},{key:"createLoader",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0];this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=Li+Di,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <strong class="checkout-title" data-title>{{title}}</strong>\n <p data-description>{{description}}</p>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');n=(n=n.replace("{{description}}",this.description)).replace("{{title}}",this.title),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .hide-continue-button [data-continue] {\n display: none;\n }\n\n .checkout-overlay .cs-loader-inner {\n color: #ddd;\n }\n\n .checkout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0,0,0, 0.5);\n text-align: center;\n color: #fff;\n opacity: 0;\n }\n .checkout-overlay.display {\n opacity: 1;\n transition: opacity 0.7s ease-out;\n }\n .checkout-overlay a { color: #00f; }\n .checkout-container {\n position: absolute;\n top: 50%;\n left: 0;\n width: 100%;\n margin-top: -{{width}}px;\n }\n .checkout-title {\n font-size: 24px;\n display: block;\n text-transform: uppercase;\n }\n [data-close] {\n position: fixed;\n right: 32px;\n top: 32px;\n width: 32px;\n height: 32px;\n opacity: 0.3;\n overflow: hidden;\n text-indent: -9999px;\n }\n [data-close]:hover { opacity: 1; }\n [data-close]:before, [data-close]:after {\n position: absolute;\n left: 15px;\n content: ' ';\n height: 33px;\n width: 2px;\n background-color: #00f;\n }\n [data-close]:before { transform: rotate(45deg); }\n [data-close]:after { transform: rotate(-45deg); }\n"),n=document.querySelector(".checkout-container");t=t.replace("{{width}}",n?String(n.offsetHeight/2):"0"),this.style=document.createElement("style"),this.style.type="text/css",this.style.appendChild(document.createTextNode(t)),e.appendChild(this.style)}},{key:"setBackdropDescription",value:function(e){this.description=e}},{key:"setBackdropTitle",value:function(e){this.title=e}},{key:"onTrigger",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"isInit",value:function(){return!(!this.overlay||!this.style)}},{key:"hideContinueControl",value:function(){this.isInit()&&this.overlay.classList.add("hide-continue-button")}},{key:"turnOffControl",value:function(){this.showControl=!1}},{key:"turnOffLoader",value:function(){this.showLoader=!1}}])}(),Bi=function(){return c((function e(){s(this,e),this.widgetEnv=new $(V)}),[{key:"error",value:function(e,t,n){n(!0)}},{key:"setEnv",value:function(e,t){this.widgetEnv.setEnv(e,t)}}])}();function Hi(){return function(e){function n(){var e;s(this,n);for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return(e=t(this,n,[].concat(r))).background=new ji,e.background.onTrigger(Ui,(function(){return e.continue()})),e.background.onTrigger(Fi,(function(){return e.stop()})),e}return d(n,e),c(n,[{key:"continue",value:function(){}},{key:"stop",value:function(){}},{key:"error",value:function(e,t,n){n(!0)}},{key:"setSuspendedRedirectUri",value:function(e){this.suspendedRedirectUri=e}},{key:"setBackgroundTitle",value:function(e){this.background.setBackdropTitle(e)}},{key:"setBackgroundDescription",value:function(e){this.background.setBackdropDescription(e)}},{key:"turnOffBackdrop",value:function(){this.background.turnOffControl(),this.background.turnOffLoader()}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Bi)}!function(e){e.SUCCESS="success",e.DECLINED="declined",e.CLOSE="close",e.REFERRED="referred",e.ERROR="error"}(Ri||(Ri={}));var zi="paydock-dispatcher",Vi=function(){return c((function e(t){s(this,e),this.messageSource=t,this.env=new $(V)}),[{key:"restartDispatcher",value:function(){var e=document.getElementById(zi);e&&e.parentNode&&e.parentNode.removeChild(e);var t=document.createElement("iframe");t.setAttribute("src",this.env.getConf().url+"/dispatcher"),t.id=zi,t.style.display="none",document.body.appendChild(t)}},{key:"on",value:function(e,t){var n=this;$n.subscribe("message",window,(function(i){var r=null;try{r=JSON.parse(i.data)}catch(e){}r&&r.message_source===n.messageSource&&r.event===e&&t(r)}))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.restartDispatcher()}}])}(),Wi="close",qi=function(){return c((function e(){s(this,e),this.configs={width:500,height:500,scrollbars:!0,resizable:!0,top:0,left:0},this.eventEmitter=new vi}),[{key:"isExist",value:function(){return!(!this.getElement()||this.getElement().closed)}},{key:"getElement",value:function(){return this.window}},{key:"init",value:function(){var e=this;if(!E.isSupportPopUp())return this.window=window;var t=this.getConfigs();this.window=window.open("about:blank","_blank","noopener=false,width=".concat(t.width,",height=").concat(t.height,",top=").concat(t.top,",left=").concat(t.left,",scrollbars=").concat(t.scrollbars?"yes":"no",",resizable=").concat(t.resizable?"yes":"no")),this.showLoader();var n=setInterval((function(){e.isExist()||(clearInterval(n),e.eventEmitter.emit(Wi,{}))}),200)}},{key:"redirect",value:function(e){this.isExist()&&(this.window.location.href=e)}},{key:"close",value:function(){this.isExist()&&this.getElement().close&&(this.getElement().close(),this.window=null)}},{key:"focus",value:function(){this.isExist()&&this.getElement().focus&&this.getElement().focus()}},{key:"setConfigs",value:function(e){this.configs=u(this.configs,e)}},{key:"getNetConfigs",value:function(){return u({},this.configs)}},{key:"getConfigs",value:function(){var e=this.getNetConfigs();return e.left=window.screenX+(window.screen.width/2-e.width/2),e.top=window.screenY+(window.screen.height/2-e.height/2),e}},{key:"onClose",value:function(e){this.eventEmitter.subscribe(Wi,e)}},{key:"initError",value:function(e){this.getElement().document.write("."),(this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0]).innerHTML="<style>\n .error-wrapper {\n color: #ff0000;\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n }\n </style>"+'<div class="error-wrapper"><div>{{error}}</div></div>'.replace("{{error}}",e)}},{key:"showLoader",value:function(){this.getElement().document.write(".");var e=this.getElement().document.body||this.getElement().document.getElementsByTagName("body")[0];if(e.innerHTML=Li+Di,this.env===O&&this.env===N&&this.env===I&&this.env===A&&this.env===R&&this.env===x&&this.env===M&&this.env===P&&this.env===D&&this.env===L&&this.env===F&&this.env===U&&this.env===j&&this.env===B&&this.env===H&&this.env===z){var t=0;$n.subscribe("click",e,(function(){5===++t&&(e.innerHTML='\n <style>\n html{width: 100%;height: 100%;}\n body{margin: 0px;padding: 0px;background-color: #111;}\n \n .eye{\n width: 20px; height: 8px;\n background-color: #eee;\n border-radius:0px 0px 20px 20px;\n position: relative;\n top: 40px;\n left: 10px;\n box-shadow: 40px 0px 0px 0px #eee; \n }\n \n .head{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden; \n position: relative;\n margin: -250px auto;\n width: 80px; height: 80px;\n background-color: #111;\n border-radius:50px;\n box-shadow: inset -4px 2px 0px 0px #eee;\n -webkit-animation:node 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n .body{ \n position: relative;\n margin: 90px auto;\n width: 140px; height: 120px;\n background-color: #111;\n border-radius: 50px/25px ;\n box-shadow: inset -5px 2px 0px 0px #eee;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out; \n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out; \n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out; \n }\n \n @keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-moz-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-moz-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n @-webkit-keyframes node {0%{ top:0px; }50%{ top:10px; }100% { top:0px;} }\n @-webkit-keyframes node2 {0%{ top:-5px; }50%{ top:10px; }100% { top:-5px;}}\n \n \n .circ{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin: 60px auto;\n width: 180px; height: 180px;\n background-color: #111;\n border-radius: 0px 0px 50px 50px;\n position: relative;\n z-index: -1; \n left: 0%;\n top: 20%;\n overflow: hidden;\n }\n \n .hands{\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n backface-visibility: hidden;\n margin-top: 140px;\n width: 120px;height: 120px;\n position: absolute;\n background-color: #111;\n border-radius:20px;\n box-shadow:-1px -4px 0px 0px #eee;\n transform:rotate(45deg);\n -webkit-transform:rotate(45deg);\n -mox-transform:rotate(45deg);\n top:75%;left: 16%;\n z-index: 1;\n -webkit-animation:node2 1.5s infinite alternate;\n -webkit-animation-timing-function:ease-out;\n -moz-animation:node2 1.5s infinite alternate;\n -moz-animation-timing-function:ease-out;\n animation:node2 1.5s infinite alternate;\n animation-timing-function:ease-out;\n }\n \n .load{ position: absolute;\n width: 100px; height: 20px;\n margin: -10px auto;\n -webkit-font-smoothing: antialiased;\n -moz-font-smoothing: antialiased;\n font-smoothing: antialiased;\n font-family: \'Julius Sans One\', sans-serif;\n font-size:30px;\n font-weight:400;\n color:#eee;\n left: 10%;\n top: 5%;\n }\n </style>\n\n <div class="circ">\n <div class="load">A little patience ...</div>\n <div class="hands"></div>\n <div class="body"></div>\n <div class="head">\n <div class="eye"></div>\n </div>\n </div>\n')}))}}},{key:"setEnv",value:function(e){this.env=e}}])}(),Gi=function(e){function n(e){var i;return s(this,n),(i=t(this,n)).publicKey=e,i.checkout=null,i.dispatcher=new Vi("checkout.paydock"),setTimeout((function(){return i.dispatcher.restartDispatcher()}),200),i.popup=new qi,i}return d(n,e),c(n,[{key:"run",value:function(){this.isRunning()||(this.popup.init(),this.background.initControl())}},{key:"isRunning",value:function(){return this.popup.isExist()}},{key:"next",value:function(e){this.checkout=e,E.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.checkout.link)}},{key:"continue",value:function(){this.popup.focus()}},{key:"stop",value:function(){this.popup.close()}},{key:"onStop",value:function(e){var t=this;this.popup.onClose((function(){t.background.clear(),t.checkout=null,e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.dispatcher.on(e,(function(e){if(n.checkout&&n.checkout.reference_id===e.reference_id)n.background.clear(),t(n.checkout,e);else if(!E.isSupportPopUp()){var i=window.localStorage.getItem("paydock_checkout_token");if(!i)return;var r=JSON.parse(i);r&&r.reference_id===e.reference_id&&(window.localStorage.removeItem("paydock_checkout_token"),n.checkout=r,n.background.clear(),t(n.checkout,e))}}))}},{key:"setEnv",value:function(e,t){f(h(n.prototype),"setEnv",this).call(this,e,t),this.dispatcher.setEnv(e,t),this.popup.setEnv(e)}}])}(Hi());function Ki(e){return"run"in e}function Yi(e){return"setRedirectUrl"in e}!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return r(t[s][1][e]||e)}),u,u.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(e,t,n){function i(){throw Error("setTimeout has not been defined")}function r(){throw Error("clearTimeout has not been defined")}function o(e){if(u===setTimeout)return setTimeout(e,0);if((u===i||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function s(){m&&p&&(m=!1,p.length?f=p.concat(f):v=-1,f.length&&a())}function a(){if(!m){var e=o(s);m=!0;for(var t=f.length;t;){for(p=f,f=[];++v<t;)p&&p[v].run();v=-1,t=f.length}p=null,m=!1,function(e){if(d===clearTimeout)return clearTimeout(e);if((d===r||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}(e)}}function c(e,t){this.fun=e,this.array=t}function l(){}var u,d,h=t.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:i}catch(e){u=i}try{d="function"==typeof clearTimeout?clearTimeout:r}catch(e){d=r}}();var p,f=[],m=!1,v=-1;h.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new c(e,t)),1!==f.length||m||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],2:[function(e,t,n){(function(e){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==o(n)&&"object"==o(t))t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else{if("undefined"==typeof window&&"undefined"==typeof self)throw Error("This environment was not anticipated by Q. Please file a bug.");var i="undefined"!=typeof window?window:self,r=i.Q;i.Q=e(),i.Q.noConflict=function(){return i.Q=r,this}}}((function(){function t(e){return function(){return R.apply(e,arguments)}}function n(e,t){if(_&&t.stack&&"object"==o(e)&&null!==e&&e.stack){for(var n=[],r=t;r;r=r.source)r.stack&&(!e.__minimumStackCounter__||e.__minimumStackCounter__>r.stackCounter)&&(F(e,"__minimumStackCounter__",{value:r.stackCounter,configurable:!0}),n.unshift(r.stack));n.unshift(e.stack),F(e,"stack",{value:function(e){for(var t=e.split("\n"),n=[],r=0;r<t.length;++r){var o=t[r];s(o)||i(o)||!o||n.push(o)}return n.join("\n")}(n.join("\n"+H+"\n")),configurable:!0})}}function i(e){return-1!==e.indexOf("(module.js:")||-1!==e.indexOf("(node.js:")}function r(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(n)return[n[1],Number(n[2])];var i=/.*@(.+):(\d+)$/.exec(e);return i?[i[1],Number(i[2])]:void 0}function s(e){var t=r(e);if(!t)return!1;var n=t[0],i=t[1];return n===C&&i>=N&&i<=Y}function a(){if(_)try{throw Error()}catch(n){var e=n.stack.split("\n"),t=r(e[0].indexOf("@")>0?e[1]:e[2]);if(!t)return;return C=t[0],t[1]}}function c(e){var t,n;return e instanceof h?e:v(e)?(t=e,n=l(),c.nextTick((function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}})),n.promise):b(e)}function l(){function e(e){t=e,c.longStackSupport&&_&&(o.source=e),M(n,(function(t,n){c.nextTick((function(){e.promiseDispatch.apply(e,n)}))}),void 0),n=void 0,i=void 0}var t,n=[],i=[],r=L(l.prototype),o=L(h.prototype);if(o.promiseDispatch=function(e,r,o){var s=x(arguments);n?(n.push(s),"when"===r&&o[1]&&i.push(o[1])):c.nextTick((function(){t.promiseDispatch.apply(t,s)}))},o.valueOf=function(){if(n)return o;var e=f(t);return m(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},c.longStackSupport&&_)try{throw Error()}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=z++}return r.promise=o,r.resolve=function(n){t||e(c(n))},r.fulfill=function(n){t||e(b(n))},r.reject=function(n){t||e(y(n))},r.notify=function(e){t||M(i,(function(t,n){c.nextTick((function(){n(e)}))}),void 0)},r}function u(e){if("function"!=typeof e)throw TypeError("resolver must be a function.");var t=l();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function d(e){return u((function(t,n){for(var i=0,r=e.length;i<r;i++)c(e[i]).then(t,n)}))}function h(e,t,n){void 0===t&&(t=function(e){return y(Error("Promise does not support operation: "+e))}),void 0===n&&(n=function(){return{state:"unknown"}});var i=L(h.prototype);if(i.promiseDispatch=function(n,r,o){var s;try{s=e[r]?e[r].apply(i,o):t.call(i,r,o)}catch(e){s=y(e)}n&&n(s)},i.inspect=n,n){var r=n();"rejected"===r.state&&(i.exception=r.reason),i.valueOf=function(){var e=n();return"pending"===e.state||"rejected"===e.state?i:e.value}}return i}function p(e,t,n,i){return c(e).then(t,n,i)}function f(e){if(m(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function m(e){return e instanceof h}function v(e){var t;return(t=e)===Object(t)&&"function"==typeof e.then}function g(){W.length=0,q.length=0,K||(K=!0)}function y(t){var n,i,r=h({when:function(n){return n&&function(t){if(K){var n=P(q,t);-1!==n&&("object"==o(e)&&"function"==typeof e.emit&&c.nextTick.runAfter((function(){var i=P(G,t);-1!==i&&(e.emit("rejectionHandled",W[n],t),G.splice(i,1))})),q.splice(n,1),W.splice(n,1))}}(this),n?n(t):this}},(function(){return this}),(function(){return{state:"rejected",reason:t}}));return n=r,i=t,K&&("object"==o(e)&&"function"==typeof e.emit&&c.nextTick.runAfter((function(){-1!==P(q,n)&&(e.emit("unhandledRejection",i,n),G.push(n))})),q.push(n),i&&void 0!==i.stack?W.push(i.stack):W.push("(no stack) "+i)),r}function b(e){return h({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},delete:function(t){delete e[t]},post:function(t,n){return null==t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return j(e)}},void 0,(function(){return{state:"fulfilled",value:e}}))}function E(e,t,n){return c(e).spread(t,n)}function w(e,t,n){return c(e).dispatch(t,n)}function k(e){return p(e,(function(e){var t=0,n=l();return M(e,(function(i,r,o){var s;m(r)&&"fulfilled"===(s=r.inspect()).state?e[o]=s.value:(++t,p(r,(function(i){e[o]=i,0==--t&&n.resolve(e)}),n.reject,(function(e){n.notify({index:o,value:e})})))}),void 0),0===t&&n.resolve(e),n.promise}))}function S(e){if(0===e.length)return c.resolve();var t=c.defer(),n=0;return M(e,(function(i,r,o){var s=e[o];n++,p(s,(function(e){t.resolve(e)}),(function(e){0==--n&&(e.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+e.message,t.reject(e))}),(function(e){t.notify({index:o,value:e})}))}),void 0),t.promise}function T(e){return p(e,(function(e){return e=D(e,c),p(k(D(e,(function(e){return p(e,I,I)}))),(function(){return e}))}))}var _=!1;try{throw Error()}catch(e){_=!!e.stack}var C,O,N=a(),I=function(){},A=function(){function t(){for(var e,t;i.next;)e=(i=i.next).task,i.task=void 0,(t=i.domain)&&(i.domain=void 0,t.enter()),n(e,t);for(;l.length;)n(e=l.pop());s=!1}function n(e,n){try{e()}catch(e){if(c)throw n&&n.exit(),setTimeout(t,0),n&&n.enter(),e;setTimeout((function(){throw e}),0)}n&&n.exit()}var i={task:void 0,next:null},r=i,s=!1,a=void 0,c=!1,l=[];if(A=function(t){r=r.next={task:t,domain:c&&e.domain,next:null},s||(s=!0,a())},"object"==o(e)&&"[object process]"===e.toString()&&e.nextTick)c=!0,a=function(){e.nextTick(t)};else if("function"==typeof setImmediate)a="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){a=d,u.port1.onmessage=t,t()};var d=function(){u.port2.postMessage(0)};a=function(){setTimeout(t,0),d()}}else a=function(){setTimeout(t,0)};return A.runAfter=function(e){l.push(e),s||(s=!0,a())},A}(),R=Function.call,x=t(Array.prototype.slice),M=t(Array.prototype.reduce||function(e,t){var n=0,i=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=i)throw TypeError()}for(;n<i;n++)n in this&&(t=e(t,this[n],n));return t}),P=t(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),D=t(Array.prototype.map||function(e,t){var n=this,i=[];return M(n,(function(r,o,s){i.push(e.call(t,o,s,n))}),void 0),i}),L=Object.create||function(e){function t(){}return t.prototype=e,new t},F=Object.defineProperty||function(e,t,n){return e[t]=n.value,e},U=t(Object.prototype.hasOwnProperty),j=Object.keys||function(e){var t=[];for(var n in e)U(e,n)&&t.push(n);return t},B=t(Object.prototype.toString);O="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var H="From previous event:";c.resolve=c,c.nextTick=A,c.longStackSupport=!1;var z=1;"object"==o(e)&&e&&e.env&&e.env.Q_DEBUG&&(c.longStackSupport=!0),c.defer=l,l.prototype.makeNodeResolver=function(){var e=this;return function(t,n){t?e.reject(t):arguments.length>2?e.resolve(x(arguments,1)):e.resolve(n)}},c.Promise=u,c.promise=u,u.race=d,u.all=k,u.reject=y,u.resolve=c,c.passByCopy=function(e){return e},h.prototype.passByCopy=function(){return this},c.join=function(e,t){return c(e).join(t)},h.prototype.join=function(e){return c([this,e]).spread((function(e,t){if(e===t)return e;throw Error("Q can't join: not the same: "+e+" "+t)}))},c.race=d,h.prototype.race=function(){return this.then(c.race)},c.makePromise=h,h.prototype.toString=function(){return"[object Promise]"},h.prototype.then=function(e,t,i){var r=this,o=l(),s=!1;return c.nextTick((function(){r.promiseDispatch((function(t){s||(s=!0,o.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return y(e)}}(t)))}),"when",[function(e){s||(s=!0,o.resolve(function(e){if("function"==typeof t){n(e,r);try{return t(e)}catch(e){return y(e)}}return y(e)}(e)))}])})),r.promiseDispatch(void 0,"when",[void 0,function(e){var t,n,r=!1;try{t=e,n="function"==typeof i?i(t):t}catch(e){if(r=!0,!c.onerror)throw e;c.onerror(e)}r||o.notify(n)}]),o.promise},c.tap=function(e,t){return c(e).tap(t)},h.prototype.tap=function(e){return e=c(e),this.then((function(t){return e.fcall(t).thenResolve(t)}))},c.when=p,h.prototype.thenResolve=function(e){return this.then((function(){return e}))},c.thenResolve=function(e,t){return c(e).thenResolve(t)},h.prototype.thenReject=function(e){return this.then((function(){throw e}))},c.thenReject=function(e,t){return c(e).thenReject(t)},c.nearer=f,c.isPromise=m,c.isPromiseAlike=v,c.isPending=function(e){return m(e)&&"pending"===e.inspect().state},h.prototype.isPending=function(){return"pending"===this.inspect().state},c.isFulfilled=function(e){return!m(e)||"fulfilled"===e.inspect().state},h.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},c.isRejected=function(e){return m(e)&&"rejected"===e.inspect().state},h.prototype.isRejected=function(){return"rejected"===this.inspect().state};var V,W=[],q=[],G=[],K=!0;c.resetUnhandledRejections=g,c.getUnhandledReasons=function(){return W.slice()},c.stopUnhandledRejectionTracking=function(){g(),K=!1},g(),c.reject=y,c.fulfill=b,c.master=function(e){return h({isDef:function(){}},(function(t,n){return w(e,t,n)}),(function(){return c(e).inspect()}))},c.spread=E,h.prototype.spread=function(e,t){return this.all().then((function(t){return e.apply(void 0,t)}),t)},c.async=function(e){return function(){function t(e,t){var o,s;if("undefined"==typeof StopIteration){try{o=n[e](t)}catch(e){return y(e)}return o.done?c(o.value):p(o.value,i,r)}try{o=n[e](t)}catch(e){return"[object StopIteration]"===B(s=e)||s instanceof O?c(e.value):y(e)}return p(o,i,r)}var n=e.apply(this,arguments),i=t.bind(t,"next"),r=t.bind(t,"throw");return i()}},c.spawn=function(e){c.done(c.async(e)())},c.return=function(e){throw new O(e)},c.promised=function(e){return function(){return E([this,k(arguments)],(function(t,n){return e.apply(t,n)}))}},c.dispatch=w,h.prototype.dispatch=function(e,t){var n=this,i=l();return c.nextTick((function(){n.promiseDispatch(i.resolve,e,t)})),i.promise},c.get=function(e,t){return c(e).dispatch("get",[t])},h.prototype.get=function(e){return this.dispatch("get",[e])},c.set=function(e,t,n){return c(e).dispatch("set",[t,n])},h.prototype.set=function(e,t){return this.dispatch("set",[e,t])},c.del=c.delete=function(e,t){return c(e).dispatch("delete",[t])},h.prototype.del=h.prototype.delete=function(e){return this.dispatch("delete",[e])},c.mapply=c.post=function(e,t,n){return c(e).dispatch("post",[t,n])},h.prototype.mapply=h.prototype.post=function(e,t){return this.dispatch("post",[e,t])},c.send=c.mcall=c.invoke=function(e,t){return c(e).dispatch("post",[t,x(arguments,2)])},h.prototype.send=h.prototype.mcall=h.prototype.invoke=function(e){return this.dispatch("post",[e,x(arguments,1)])},c.fapply=function(e,t){return c(e).dispatch("apply",[void 0,t])},h.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},c.try=c.fcall=function(e){return c(e).dispatch("apply",[void 0,x(arguments,1)])},h.prototype.fcall=function(){return this.dispatch("apply",[void 0,x(arguments)])},c.fbind=function(e){var t=c(e),n=x(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(x(arguments))])}},h.prototype.fbind=function(){var e=this,t=x(arguments);return function(){return e.dispatch("apply",[this,t.concat(x(arguments))])}},c.keys=function(e){return c(e).dispatch("keys",[])},h.prototype.keys=function(){return this.dispatch("keys",[])},c.all=k,h.prototype.all=function(){return k(this)},c.any=S,h.prototype.any=function(){return S(this)},c.allResolved=(V=T,function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("allResolved is deprecated, use allSettled instead.",Error("").stack),V.apply(V,arguments)}),h.prototype.allResolved=function(){return T(this)},c.allSettled=function(e){return c(e).allSettled()},h.prototype.allSettled=function(){return this.then((function(e){return k(D(e,(function(e){function t(){return e.inspect()}return(e=c(e)).then(t,t)})))}))},c.fail=c.catch=function(e,t){return c(e).then(void 0,t)},h.prototype.fail=h.prototype.catch=function(e){return this.then(void 0,e)},c.progress=function(e,t){return c(e).then(void 0,void 0,t)},h.prototype.progress=function(e){return this.then(void 0,void 0,e)},c.fin=c.finally=function(e,t){return c(e).finally(t)},h.prototype.fin=h.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw Error("Q can't apply finally callback");return e=c(e),this.then((function(t){return e.fcall().then((function(){return t}))}),(function(t){return e.fcall().then((function(){throw t}))}))},c.done=function(e,t,n,i){return c(e).done(t,n,i)},h.prototype.done=function(t,i,r){var s=function(e){c.nextTick((function(){if(n(e,a),!c.onerror)throw e;c.onerror(e)}))},a=t||i||r?this.then(t,i,r):this;"object"==o(e)&&e&&e.domain&&(s=e.domain.bind(s)),a.then(void 0,s)},c.timeout=function(e,t,n){return c(e).timeout(t,n)},h.prototype.timeout=function(e,t){var n=l(),i=setTimeout((function(){t&&"string"!=typeof t||((t=Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),n.reject(t)}),e);return this.then((function(e){clearTimeout(i),n.resolve(e)}),(function(e){clearTimeout(i),n.reject(e)}),n.notify),n.promise},c.delay=function(e,t){return void 0===t&&(t=e,e=void 0),c(e).delay(t)},h.prototype.delay=function(e){return this.then((function(t){var n=l();return setTimeout((function(){n.resolve(t)}),e),n.promise}))},c.nfapply=function(e,t){return c(e).nfapply(t)},h.prototype.nfapply=function(e){var t=l(),n=x(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},c.nfcall=function(e){var t=x(arguments,1);return c(e).nfapply(t)},h.prototype.nfcall=function(){var e=x(arguments),t=l();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},c.nfbind=c.denodeify=function(e){if(void 0===e)throw Error("Q can't wrap an undefined function");var t=x(arguments,1);return function(){var n=t.concat(x(arguments)),i=l();return n.push(i.makeNodeResolver()),c(e).fapply(n).fail(i.reject),i.promise}},h.prototype.nfbind=h.prototype.denodeify=function(){var e=x(arguments);return e.unshift(this),c.denodeify.apply(void 0,e)},c.nbind=function(e,t){var n=x(arguments,2);return function(){var i=n.concat(x(arguments)),r=l();return i.push(r.makeNodeResolver()),c((function(){return e.apply(t,arguments)})).fapply(i).fail(r.reject),r.promise}},h.prototype.nbind=function(){var e=x(arguments,0);return e.unshift(this),c.nbind.apply(void 0,e)},c.nmapply=c.npost=function(e,t,n){return c(e).npost(t,n)},h.prototype.nmapply=h.prototype.npost=function(e,t){var n=x(t||[]),i=l();return n.push(i.makeNodeResolver()),this.dispatch("post",[e,n]).fail(i.reject),i.promise},c.nsend=c.nmcall=c.ninvoke=function(e,t){var n=x(arguments,2),i=l();return n.push(i.makeNodeResolver()),c(e).dispatch("post",[t,n]).fail(i.reject),i.promise},h.prototype.nsend=h.prototype.nmcall=h.prototype.ninvoke=function(e){var t=x(arguments,1),n=l();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},c.nodeify=function(e,t){return c(e).nodeify(t)},h.prototype.nodeify=function(e){if(!e)return this;this.then((function(t){c.nextTick((function(){e(null,t)}))}),(function(t){c.nextTick((function(){e(t)}))}))},c.noConflict=function(){throw Error("Q.noConflict only works when Q is used as a global")};var Y=a();return c}))}).call(this,e("_process"))},{_process:1}],3:[function(e,t,n){var i=function(e){switch(o(e)){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,r){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==o(e)?Object.keys(e).map((function(r){var o=encodeURIComponent(i(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return o+encodeURIComponent(i(e))})).join(t):o+encodeURIComponent(i(e[r]))})).join(t):r?encodeURIComponent(i(r))+n+encodeURIComponent(i(e)):""}},{}],4:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return l.default.information("zip:checkout:init"),d.default.Promise((function(t,n){return e.onCheckout(t,n,{})})).then((function(i){var r=i.redirect_uri||i.redirectUri||i.data&&(i.data.redirect_uri||i.data.redirectUri);if(!r)return l.default.debug("zip:checkout:error","Response does not contain redirectUri property"),n(i),void e.onError({code:"checkout_error",message:"The response does not contain the redirectUri property",detail:i});l.default.debug("zip:checkout:success",i),t({redirectUri:r})})).catch((function(t){l.default.debug("zip:checkout:error",t),n(t),e.onError({code:"checkout_error",message:"Checkout response error",detail:t})}))}Object.defineProperty(n,"__esModule",{value:!0}),n.Checkout=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=i(e("./modal")),a=i(e("./options")),c=i(e("./utility")),l=i(e("./console")),d=i((e("./events"),e("q"))),h=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return o(e,null,[{key:"init",value:function(e){var t,n;if("function"!=typeof Object.assign&&(Object.assign=function(e){if(null==e)throw TypeError("Cannot convert undefined or null to object");e=Object(e);for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}),e=u({},a.default,e),!this._validate(e))return l.default.setLevel(e.logLevel),e.redirect?r(e,(function(t){return e.redirectFn(t.redirectUri)})):(t=e,(n=new s.default).onClose=t.onComplete.bind(t),n.build(),void r(t,(function(e){return n.setUri(e.redirectUri)}),(function(e){return n.close(!1)})))}},{key:"attachButton",value:function(e,t){var n=document.querySelectorAll(e);if(!n.length)return config.onError({code:"attach_error",message:"Cannot find button to attach zipMoney checkout"});for(var i=0;i<n.length;i++)c.default.addEventHandler(n[i],"click",(function(){return Zip.Checkout.init(t)}))}},{key:"_validate",value:function(e){return 0>["error","information","debug"].indexOf(e.logLevel.toLowerCase())&&(e.logLevel="error"),0>["standard","express"].indexOf(e.request.toLowerCase())&&(e.request="standard"),e.onComplete=e.onComplete||function(){},e.onError=e.onError||function(){},e.checkoutUri||e.onCheckout!==a.default.onCheckout?"express"===e.request?e.onError({code:"not_implemented",message:"This feature is not yet implemented"}):e.redirect||e.onComplete!==a.default.onComplete||e.redirectUri?void 0:e.onError({code:"validation",message:"if onComplete function is not specified then redirectUri must be specified"}):e.onError({code:"validation",message:"if onCheckout function is not specified then checkoutUri must be specified"})}}]),e}();n.Checkout=h},{"./console":5,"./events":6,"./modal":8,"./options":9,"./utility":10,q:2}],5:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i="error";n.default={error:function(){var e;(e=window.console).log.apply(e,arguments)},information:function(){var e;"error"!==i&&(e=window.console).log.apply(e,arguments)},debug:function(){var e;"debug"===i&&(e=window.console).log.apply(e,arguments)},setLevel:function(e){i=e}}},{}],6:[function(e,t,n){(function(t){Object.defineProperty(n,"__esModule",{value:!0}),n.EventListener=void 0;var i,r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();if(((i=e("./utility"))&&i.__esModule?i:{default:i}).default.isIe){var o=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n};o.prototype=t.Event.prototype,t.CustomEvent=o}var s={},a=n.EventListener=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"constructor",value:function(){s={}}},{key:"on",value:function(e,t){s[e]=t}},{key:"off",value:function(e){s[e]=null}}]),e}();a.Event=function(e,t){this.eventType=e,this.data=t||{}},a.Event.eventTypes={resize:"resize",transition:"transition",close:"close",complete:"complete",clear:"clear"};var c=window.addEventListener?"addEventListener":"attachEvent",l=window[c];l("attachEvent"==c?"onmessage":"message",(function(e){var n,i;e.data.zipmoney&&(n=e.data.msg,i=new t.CustomEvent("zipmoney",{detail:n}),t.dispatchEvent(i))}),!1),l("zipmoney",(function(e){var t,n=s[e.detail.eventType];n?n(e.detail.data||{}):(t=e,console.log("Unexpected Event",t))}),!1)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utility":10}],7:[function(e,t,n){(function(t){var n=e("./checkout"),i=e("./events");t.Zip=t.Zip||{},t.Zip.Checkout=n.Checkout,t.zipMoneyEvent=i.EventListener.ZipEvent}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./checkout":4,"./events":6}],8:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}function o(){var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)}function s(e){for(var t=document.querySelectorAll("html, body"),n=0;n<t.length;n++)t[n].style.overflowY=e}function a(e){var t=document.body.currentStyle||window.getComputedStyle(document.body),n=document.body.offsetHeight+(parseInt(t.marginTop,10)+parseInt(t.marginBottom,10))-parseInt(t.height,10);document.body.style.height=e-n+"px"}Object.defineProperty(n,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=i(e("./utility")),d=e("./events"),h=(i(e("./console")),{iframeWidth:400,iframeMinWidth:320,iframeInitialHeight:704,iframeMinHeight:600,verticalMargin:35}),p=["resize","transition","close","complete","clear"],f="https://d3k1w8lx8mqizo.cloudfront.net/zm/",m=function(){function e(){var t=this;(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,e),this._events=[],this._isMobile=l.default.isMobileDevice(),p.forEach((function(e){return d.EventListener.on(d.EventListener.Event.eventTypes[e],t[e].bind(t))}))}return c(e,[{key:"build",value:function(){this._initialHtmlHeight=o(),window.scrollTo(0,0);var e=this._frame=(t=this._frameUri,n=this._isMobile,(i=document.createElement("iframe")).id="zipmoney-iframe",i.frameborder=0,u(i.style,{padding:"0",border:"none",zIndex:"999999",backgroundColor:"#FFF",backgroundImage:"url("+f+"spinner.gif)",backgroundRepeat:"no-repeat",backgroundPosition:"50% 50%"}),u(i.style,n?{overflow:"scroll",width:"100%",height:"100%",position:"absolute",top:"0",bottom:"0",left:"0",right:"0",margin:"0"}:{width:h.iframeWidth+"px",minWidth:h.iframeMinWidth+"px",height:h.iframeInitialHeight+"px",margin:h.verticalMargin+"px auto 0 auto",display:"table-row",backgroundSize:"25%",textAlign:"center",boxShadow:"0px 0px 70px 0px rgb(0, 0, 0)"}),i.src=t||"",i);if(!this._isMobile){var t,n,i,r,c,l=((r=document.createElement("img")).src=f+"icon-close.png",u(r.style,{width:"50px",height:"50px",position:"absolute",top:"20px",right:"20px",cursor:"pointer"}),r);l.onclick=this.close.bind(this),this._overlay=((c=document.createElement("div")).className="zipmoney-overlay",u(c.style,{position:"absolute",left:"0",top:"0",display:"table-cell",textAlign:"center",verticalAlign:"middle",background:"rgba(0, 0, 0, 0.75)",zIndex:"10000",height:"100%",width:"100%"}),c),this._overlay.appendChild(l),this._overlay.appendChild(this._frame),e=this._overlay}document.body.appendChild(e),this._isMobile&&a(this._frame.offsetHeight),s("auto"),this._startMonitoringWindowResize()}},{key:"setUri",value:function(e){this._frameUri=e,this._frame&&(this._frame.src=e)}},{key:"resize",value:function(e){var t=this._isMobile?16:0,n=(e=e>=h.iframeMinHeight?e:h.iframeMinHeight,(e+=t)+2*h.verticalMargin),i=r();this._frame.style.height=e+"px",this._overlay&&(this._overlay.style.height=Math.max(i,this._initialHtmlHeight,n)+"px"),this._isMobile&&a(e)}},{key:"transition",value:function(){window.scroll(0,0)}},{key:"close",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t={state:"cancelled"};this._events.length&&(t=this._events.pop()),this._destroy(),this.onClose&&e&&this.onClose(t)}},{key:"complete",value:function(e){this._events.push(e)}},{key:"clear",value:function(e){this._events=[]}},{key:"_startMonitoringWindowResize",value:function(){var e=this;this._resizeHandler=l.default.debounce((function(){var t,n,i,s;return t=e,n=r(),i=o(),s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t._overlay&&(t._overlay.style.height=Math.max(n,i)+"px"),void(t._isMobile||s<h.iframeWidth?t._frame.style.width="100%":t._frame.style.width=h.iframeWidth+"px")}),250),l.default.addEventHandler(window,"resize",this._resizeHandler)}},{key:"_stopMonitoringWindowResize",value:function(){l.default.removeEventHandler(window,"resize",this._resizeHandler)}},{key:"_destroy",value:function(){this._stopMonitoringWindowResize(),this._overlay?document.body.removeChild(this._overlay):document.body.removeChild(this._frame),this._isMobile&&(document.body.style.height="initial"),s("initial"),this._overlay=this._frame=null,p.forEach((function(e){return d.EventListener.off(d.EventListener.Event.eventTypes[e])}))}}]),e}();n.default=m},{"./console":5,"./events":6,"./utility":10}],9:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var r=i(e("./xr")),o=i(e("./console"));r.default.configure({headers:{"X-Requested-With":"XMLHttpRequest"}}),n.default={request:"standard",redirect:!1,logLevel:"Error",onCheckout:function(e,t,n){r.default.post(this.checkoutUri).then((function(t){return e(t.data)})).catch(t)},onShippingAddressChanged:function(e,t,n){r.default.post(this.shippingUri).then(e).catch(t)},onComplete:function(e){if(o.default.information("zip:completed",e),"cancelled"!==e.state){var t=e.checkoutId?"&checkoutId="+e.checkoutId:"";this.redirectFn(this.redirectUri+"?result="+e.state+t)}},onError:function(e){o.default.error(e)},redirectFn:function(e){window.location.href=e}}},{"./console":5,"./xr":11}],10:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e)}return i(e,null,[{key:"isIe",value:function(){var e=-1,t=window.navigator.userAgent,n=t.indexOf("MSIE "),i=t.indexOf("Trident/");if(n>0)e=parseInt(t.substring(n+5,t.indexOf(".",n)),10);else if(i>0){var r=t.indexOf("rv:");e=parseInt(t.substring(r+3,t.indexOf(".",r)),10)}return e>-1?e:void 0}},{key:"isMobileDevice",value:function(){var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}},{key:"debounce",value:function(e,t){var n;return function(){var i=this,r=arguments,o=!n;clearTimeout(n),n=setTimeout((function(){n=null,e.apply(i,r)}),t),o&&e.apply(i,r)}}},{key:"addEventHandler",value:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)}},{key:"removeEventHandler",value:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)}}]),e}();n.default=r},{}],11:[function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){return{status:e.status,response:e.response,data:t,xhr:e}}function s(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(var r in n)if({}.hasOwnProperty.call(n,r)){var o=n[r];if("object"===(void 0===o?"undefined":c(o)))for(var s in o)({}).hasOwnProperty.call(o,s)&&(e[s]=o[s])}return e}function a(e){var t,n;return n=function(t,n){var i=s({},p,f,e),o=i.xmlHttpRequest();for(var a in i.abort&&e.abort((function(){n(r(o)),o.abort()})),o.open(i.method,i.params?i.url.split("?")[0]+"?"+(0,l.default)(i.params):i.url,!0),o.withCredentials=i.withCredentials,o.addEventListener(h.LOAD,(function(){if(o.status>=200&&o.status<300){var e=null;o.responseText&&(e=!0===i.raw?o.responseText:i.load(o.responseText)),t(r(o,e))}else n(r(o))})),o.addEventListener(h.ABORT,(function(){return n(r(o))})),o.addEventListener(h.ERROR,(function(){return n(r(o))})),o.addEventListener(h.TIMEOUT,(function(){return n(r(o))})),i.headers)({}).hasOwnProperty.call(i.headers,a)&&o.setRequestHeader(a,i.headers[a]);for(var u in i.events)({}).hasOwnProperty.call(i.events,u)&&o.addEventListener(u,i.events[u].bind(null,o),!1);var d="object"!==c(i.data)||i.raw?i.data:i.dump(i.data);void 0!==d?o.send(d):o.send()},((t=e)&&t.promise?t.promise:f.promise||p.promise)(n)}Object.defineProperty(n,"__esModule",{value:!0});var c="function"==typeof Symbol&&"symbol"==o(Symbol.iterator)?function(e){return o(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":o(e)},l=i(e("querystring/encode")),u=i(e("q")),d={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE",PATCH:"PATCH",OPTIONS:"OPTIONS"},h={READY_STATE_CHANGE:"readystatechange",LOAD_START:"loadstart",PROGRESS:"progress",ABORT:"abort",ERROR:"error",LOAD:"load",TIMEOUT:"timeout",LOAD_END:"loadend"},p={method:d.GET,data:void 0,headers:{Accept:"application/json","Content-Type":"application/json"},dump:JSON.stringify,load:JSON.parse,xmlHttpRequest:function(){return new XMLHttpRequest},promise:function(e){return u.default.Promise(e)},withCredentials:!1},f={};a.assign=s,a.encode=l.default,a.configure=function(e){f=s({},f,e)},a.Methods=d,a.Events=h,a.defaults=p,a.get=function(e,t,n){return a(s({url:e,method:d.GET,params:t},n))},a.put=function(e,t,n){return a(s({url:e,method:d.PUT,data:t},n))},a.post=function(e,t,n){return a(s({url:e,method:d.POST,data:t},n))},a.patch=function(e,t,n){return a(s({url:e,method:d.PATCH,data:t},n))},a.del=function(e,t){return a(s({url:e,method:d.DELETE},t))},a.options=function(e,t){return a(s({url:e,method:d.OPTIONS},t))},n.default=a},{q:2,"querystring/encode":3}]},{},[7]);var $i,Ji=function(e){function n(){var e;return s(this,n),(e=t(this,n)).apiEnv=new $(W),e}return d(n,e),c(n,[{key:"setEnv",value:function(e,t){f(h(n.prototype),"setEnv",this).call(this,e,t),this.apiEnv.setEnv(e,t)}},{key:"getCheckoutUri",value:function(e){return this.apiEnv.getConf().url+"/v1/echo?"+Wn.serialize({json_body:JSON.stringify({redirect_uri:e})})}}])}(Bi),Xi=function(e){function n(){var e;return s(this,n),(e=t(this,n)).runs=!1,e.eventEmitter=new vi,e}return d(n,e),c(n,[{key:"run",value:function(){this.runs=!0,this.background.initLoader()}},{key:"isRunning",value:function(){return this.runs}},{key:"next",value:function(e){var t=this;this.background.clear(),this.checkout=e;var n=this.getCheckoutUri(this.checkout.link);Zip.Checkout.init({checkoutUri:n,onComplete:function(e){return t.eventHandler(e)},onError:function(e){return t.eventHandler(e)}})}},{key:"getSuccessRedirectUri",value:function(){return this.suspendedRedirectUri?this.suspendedRedirectUri:this.widgetEnv.getConf().url+String("/checkout/zipmoney/suspended")}},{key:"getErrorRedirectUri",value:function(){return this.getSuccessRedirectUri()}},{key:"stop",value:function(){f(h(n.prototype),"stop",this).call(this),this.runs=!1;var e=document.querySelector(".zipmoney-overlay");e&&e.remove(),this.eventEmitter.emit(Ri.CLOSE)}},{key:"onStop",value:function(e){var t=this;this.eventEmitter.subscribe(Ri.CLOSE,(function(){t.background.clear(),e()}))}},{key:"onCheckout",value:function(e,t){var n=this;this.eventEmitter.subscribe(e,(function(){t(n.checkout)}))}},{key:"eventHandler",value:function(e){switch(this.runs=!1,e.state){case"approved":this.eventEmitter.emit(Ri.CLOSE),this.eventEmitter.emit(Ri.SUCCESS);break;case"declined":this.eventEmitter.emit(Ri.CLOSE),this.eventEmitter.emit(Ri.DECLINED);break;case"cancelled":this.eventEmitter.emit(Ri.CLOSE);break;case"referred":this.eventEmitter.emit(Ri.CLOSE),this.eventEmitter.emit(Ri.REFERRED);break;default:console.warn("".concat("[CheckoutButton:Zipmoney]"," Unknown gateway status."))}}}])}(Hi(Ji)),Zi="[Paydock:StorageDispatcher]";!function(e){e.WIDGET_SESSION="widget-session"}($i||($i={}));var Qi,er=function(){return c((function e(t){s(this,e),this.messageSource=t,this.defaultPayload={destination:"widget.paydock"},this.env=new $(V),this.defaultPayload.source=t,this.iframeEvent=new Qn(window)}),[{key:"create",value:function(e){this.onLoadCallback=e,this.dispatcherFrame&&this.destroy(),this.widgetId=qn.generate(),this.setupIframeEventListeners();var t=document.createElement("iframe");return t.setAttribute("src",this.env.getConf().url+"/storage-dispatcher"+"?widgetId=".concat(this.widgetId)),t.setAttribute("id","pd-storage-dispatcher"),t.style.display="none",document.body.appendChild(t),this.dispatcherFrame=t,console.info("".concat(Zi," initialized.")),t}},{key:"destroy",value:function(){this.dispatcherFrame&&this.dispatcherFrame.parentNode&&this.dispatcherFrame.parentNode.removeChild(this.dispatcherFrame),this.iframeEvent.clear(),this.widgetId=void 0,this.dispatcherFrame=void 0}},{key:"push",value:function(e,t){var n;if(this.pushCallbacks=t,this.dispatcherFrame){var i=u(u({},this.defaultPayload),e);null===(n=this.dispatcherFrame.contentWindow)||void 0===n||n.postMessage(i,this.env.getConf().url)}else console.error("".concat(Zi," dispatcher is not initialized."))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t),this.create(this.onLoadCallback)}},{key:"setupIframeEventListeners",value:function(){var e=this;this.widgetId&&(this.iframeEvent.on(Zn.AFTER_LOAD,this.widgetId,(function(t){var n;null===(n=e.onLoadCallback)||void 0===n||n.call(e)})),this.iframeEvent.on(Zn.DISPATCH_SUCCESS,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onSuccess)||void 0===i||i.call(n)})),this.iframeEvent.on(Zn.DISPATCH_ERROR,this.widgetId,(function(t){var n,i;null===(i=null===(n=e.pushCallbacks)||void 0===n?void 0:n.onError)||void 0===i||i.call(n)})))}}])}(),tr=function(e){function n(){var e;return s(this,n),(e=t(this,n)).storageDispatcher=new er("zipmoney.checkout.paydock"),e}return d(n,e),c(n,[{key:"getProxyRedirectUrl",value:function(){return this.widgetEnv.getConf().url+"/checkout/zipmoney/response"}},{key:"next",value:function(e,t){var n=this;this.storageDispatcher.create((function(){var i={merchant_redirect_url:n.getRedirectUrl(),checkout_token:e.token,public_key:t.public_key,gateway_id:t.gateway_id};n.storageDispatcher.push({intent:$i.WIDGET_SESSION,data:i},{onSuccess:function(){var t=n.getCheckoutUri(e.link);Zip.Checkout.init({checkoutUri:t,redirect:!0})},onError:function(){console.error("Error initializing Zip Checkout")}})}))}},{key:"getSuccessRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"getErrorRedirectUri",value:function(){return this.getProxyRedirectUrl()}},{key:"setEnv",value:function(e,t){f(h(n.prototype),"setEnv",this).call(this,e,t),this.storageDispatcher.setEnv(e,t)}}])}(function(){return function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"setRedirectUrl",value:function(e){this.merchantRedirectUrl=e}},{key:"getRedirectUrl",value:function(){return this.merchantRedirectUrl}},{key:"error",value:function(e,t,n){n(!1)}}])}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:Bi)}(Ji)),nr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+Wn.extendSearchParams("/checkout/success","merchant",encodeURIComponent(window.location.href))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+Wn.extendSearchParams("/checkout/error","merchant",encodeURIComponent(window.location.href))}}])}(Gi);!function(e){e.CLOSE="CANCELLED"}(Qi||(Qi={}));var ir,rr,or=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"getSuccessRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/success".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"getErrorRedirectUri",value:function(){return this.widgetEnv.getConf().url+"/checkout/afterpay/merchant/{{merchant}}/error".replace("{{merchant}}",encodeURIComponent(window.btoa(window.location.href)))}},{key:"next",value:function(e,t){this.checkout=e,E.isSupportPopUp()||window.localStorage.setItem("paydock_checkout_token",JSON.stringify(this.checkout)),this.popup.redirect(this.getRedirectUrl(this.checkout,t))}},{key:"onCheckout",value:function(e,t){f(h(n.prototype),"onCheckout",this).call(this,e,(function(e,n){if(!(null==n?void 0:n.status))return t(e);var i=n.status,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(n,["status"]);i===Qi.CLOSE?t(e,u(u({},r),{isCloseEvent:!0})):t(e,r)}))}},{key:"error",value:function(e,t,n){return!t||t&&"invalid_amount"!==t?n(!0):(this.popup.initError(e),n(!1))}},{key:"run",value:function(){this.isRunning()||(this.popup.setConfigs({width:420,height:715}),this.popup.init(),this.background.initControl())}},{key:"getRedirectUrl",value:function(e,t){return this.widgetEnv.getConf().url+"/checkout/afterpay/init?"+Wn.serialize(u(u({},t),{token:e.reference_id,env:"live"===e.mode?"live":"test"}))}}])}(Gi),sr={EXTERNAL_CHECKOUT_TOKEN:"external_checkout_token",CHECKOUT_TOKEN:"checkout_token",BANK_ACCOUNT:"bank_account",CARD:"card"},ar=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sr.CARD;switch(s(this,n),(r=t(this,n)).body={gateway_id:e,type:o},o){case sr.CARD:case sr.BANK_ACCOUNT:delete i.gateway_id,delete i.type,delete i.checkout_token,r.body=u(r.body,i);break;case sr.CHECKOUT_TOKEN:case sr.EXTERNAL_CHECKOUT_TOKEN:r.body.checkout_token=i;break;default:throw new Error("Unsupported type of PaymentSourceToken")}return r}return d(n,e),c(n,[{key:"getLink",value:function(){return"/v1/payment_sources/tokens"}},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.create(e,this.getConfigs(),(function(e,n){return t(e)}),(function(e,t){void 0===e.message?n("unknown error"):n(e.message)}))}},{key:"getConfigs",value:function(){return this.body}}])}(xi),cr=function(){return c((function e(t,n,i,r){var o=this;s(this,e),this.background=t,this.runner=n,this.eventEmitter=i,this.params=r,this.runner.onStop((function(){o.eventEmitter.emit(Ei.CLOSE)}))}),[{key:"init",value:function(e){var t=this;this.setEnv(e),this.runner.onCheckout(Ri.SUCCESS,(function(e){t.eventEmitter.emit(Ei.ACCEPTED,{}),t.background.initLoader(),t.runner.stop(),t.checkToken(e.token,(function(){t.createOneTimeToken(e.token)}))})),this.runner.onCheckout(Ri.ERROR,(function(e,n){(null==n?void 0:n.isCloseEvent)||(t.eventEmitter.emit(Ei.ERROR),console.error("".concat(Si," Error from checkout server."))),t.runner.stop()})),this.runner.onCheckout(Ri.REFERRED,(function(){t.eventEmitter.emit(Ei.REFERRED),t.runner.stop()})),this.runner.onCheckout(Ri.DECLINED,(function(){t.eventEmitter.emit(Ei.DECLINED),t.runner.stop()})),this.eventEmitter.subscribe(Ei.ERROR,(function(){t.runner.stop()})),this.eventEmitter.subscribe(Ei.FINISH,(function(e){t.background.clear()}))}},{key:"setEnv",value:function(e){this.env=e}},{key:"checkToken",value:function(e,t){var n=this,i=new Pi(e);i.setEnv(this.env),i.send(this.params.accessToken,(function(e){n.details=e,t()}),(function(){n.eventEmitter.emit(Ei.ERROR,{}),console.error("".concat(Si," Error during creating payment source token."))}))}},{key:"createOneTimeToken",value:function(e){var t=this,n=new ar(this.params.gatewayId,e,sr.CHECKOUT_TOKEN);n.setEnv(this.env),n.send(this.params.accessToken,(function(e){t.eventEmitter.emit(Ei.FINISH,{payment_source_token:e,checkout_email:t.details.checkout_email,checkout_holder:t.details.checkout_holder,gateway_type:t.details.gateway_type})}),(function(){t.eventEmitter.emit(Ei.ERROR,{}),console.error("".concat(Si," Error during creating payment source token."))}))}}])}(),lr=function(){return c((function e(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yi.PAYPAL,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:gi.CONTEXTUAL;s(this,e),this.accessToken=n,this.gatewayId=i,this.gatewayType=r,this.mode=o,this.window=window,this.meta={},this.env=G,this.eventEmitter=new vi,this.container=new Jn(t),this.initCheckout(this.container),this.chooseRunner(r,o)}),[{key:"chooseRunner",value:function(e,t){var n=this.getRunnerByMode(e,t);this.runner=new n(this.accessToken),Ki(this.runner)?(this.background=new ji,this.checkoutHandler=new cr(this.background,this.runner,this.eventEmitter,{accessToken:this.accessToken,gatewayId:this.gatewayId}),this.checkoutHandler.init(this.env)):(this.background=void 0,this.checkoutHandler=void 0)}},{key:"buildAdditionalParams",value:function(){return{}}},{key:"initCheckout",value:function(e){var t=this;e.on("click",(function(e){if(Ki(t.runner)){if(t.runner.isRunning())return;t.runner.run()}else if(Yi(t.runner)&&!t.runner.getRedirectUrl())throw Error("".concat(Si," The merchant redirect URL should is required in the '").concat(t.mode,"' mode."));t.eventEmitter.emit(Ei.CLICK);var n=new Mi(t.gatewayId,t.runner.getSuccessRedirectUri(),t.runner.getErrorRedirectUri());n.setMeta(t.meta),n.setEnv(t.env),n.send(t.accessToken,(function(e){var n=Ki(t.runner)?Ei.POPUP_REDIRECT:Ei.REDIRECT;t.eventEmitter.emit(n),t.runner.next(e,t.buildAdditionalParams())}),(function(e,n){console.error("".concat(Si," ").concat(e)),t.eventEmitter.emit(Ei.ERROR,{error:e,code:n}),t.runner.error(e,n,(function(e){e&&t.close()}))}))}))}},{key:"on",value:function(e,t){this.eventEmitter.subscribe(e,t)}},{key:"close",value:function(){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.stop()}},{key:"onFinishInsert",value:function(e,t){this.on(Ei.FINISH,(function(n){$n.insertToInput(e,t,n)}))}},{key:"setMeta",value:function(e){this.meta=u(this.meta,e)}},{key:"setBackdropDescription",value:function(e){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.setBackgroundDescription(e)}},{key:"setBackdropTitle",value:function(e){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.setBackgroundTitle(e)}},{key:"setSuspendedRedirectUri",value:function(e){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.setSuspendedRedirectUri(e)}},{key:"setRedirectUrl",value:function(e){this.assertMethodSupport(this.runner,gi.REDIRECT)&&this.runner.setRedirectUrl(e)}},{key:"getSuccessRedirectUri",value:function(){return this.runner.getSuccessRedirectUri()}},{key:"turnOffBackdrop",value:function(){this.turnOffControlBackdrop(),this.turnOffLoaderBackdrop()}},{key:"turnOffControlBackdrop",value:function(){this.assertMethodSupport(this.runner,gi.CONTEXTUAL)&&this.runner.turnOffBackdrop()}},{key:"turnOffLoaderBackdrop",value:function(){var e;null===(e=this.background)||void 0===e||e.turnOffLoader()}},{key:"setEnv",value:function(e,t){var n;this.env=e,this.alias=t,null===(n=this.checkoutHandler)||void 0===n||n.setEnv(e),this.runner.setEnv(e,t)}},{key:"getEnv",value:function(){return this.env}},{key:"getRunnerByMode",value:function(e,t){if(e===yi.PAYPAL){if(t===gi.REDIRECT)throw Error("".concat(Si," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return nr}if(e===yi.AFTERPAY){if(t===gi.REDIRECT)throw Error("".concat(Si," Gateway '").concat(e,"' do not support '").concat(t,"' mode"));return or}if(e===yi.ZIPMONEY)return t===gi.CONTEXTUAL?Xi:tr;throw Error("".concat(Si," Unsupported gateway."))}},{key:"assertMethodSupport",value:function(e,t){var n="".concat(Si," The method is not supported in the '").concat(t,"' mode.");switch(t){case gi.CONTEXTUAL:if(Ki(e))return!0;console.warn(n);break;case gi.REDIRECT:if(Yi(e))return!0;console.warn(n)}return!1}}])}(),ur=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:gi.CONTEXTUAL;return s(this,n),(r=t(this,n,[e,i,o,yi.ZIPMONEY,a])).publicKey=i,r.gatewayId=o,r.mode=a,r}return d(n,e),c(n,[{key:"setSuspendedRedirectUri",value:function(e){f(h(n.prototype),"setSuspendedRedirectUri",this).call(this,e)}},{key:"setRedirectUrl",value:function(e){Ki(this.runner)&&(f(h(n.prototype),"chooseRunner",this).call(this,yi.ZIPMONEY,gi.REDIRECT),f(h(n.prototype),"setEnv",this).call(this,this.env,this.alias)),f(h(n.prototype),"setRedirectUrl",this).call(this,e)}},{key:"buildAdditionalParams",value:function(){return u(u({},f(h(n.prototype),"buildAdditionalParams",this).call(this)),{public_key:this.publicKey,gateway_id:this.gatewayId})}}])}(lr),dr=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return s(this,n),(r=t(this,n,[e,i,o,yi.AFTERPAY])).accessToken=i,r.gatewayId=o,r.showETP=!1,r}return d(n,e),c(n,[{key:"showEnhancedTrackingProtectionPopup",value:function(e){var t=E.getBrowserInfo(),n=t.name,i=t.version;e&&"Firefox"===n&&+i>=100&&(this.showETP=!0)}},{key:"buildAdditionalParams",value:function(){var e=f(h(n.prototype),"buildAdditionalParams",this).call(this);return this.showETP&&(e.show_etp=!0),e}}])}(lr),hr=function(e){function n(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default";return s(this,n),(r=t(this,n,[e,i,o,yi.PAYPAL])).publicKey=i,r.gatewayId=o,r}return d(n,e),c(n)}(lr),pr=function(){return c((function e(){s(this,e)}),null,[{key:"values",value:function(e){return Object.keys(e).map((function(t){return e[t]}))}}])}(),fr=function(){return c((function e(t,n){s(this,e),this.configs=[],this.configTokens=[],this.link=new Yn("/payment-sources"),this.link.setParams(u({query_token:n},Q.validateJWT(t)?{access_token:t}:{public_key:t})),J.version&&this.link.setParams({sdk_version:J.version,sdk_type:J.type})}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==pr.values(Ci).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"setLimit",value:function(e){this.link.setParams({limit:e})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"getIFrameUrl",value:function(){return this.link.getUrl()}},{key:"filterByGatewayIds",value:function(e){this.link.setParams({gateway_ids:e.join(",")})}},{key:"filterByTypes",value:function(e){var t,n=[],i=b(e);try{for(i.s();!(t=i.n()).done;){var r=t.value;e.hasOwnProperty(r)&&(-1===pr.values(Ti).indexOf(r)?console.warn("PaymentSourceWidget::filterByTypes: unsupported type ".concat(r)):n.push(r))}}catch(e){i.e(e)}finally{i.f()}this.link.setParams({payment_source_types:n.join(",")})}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),mr=function(e){function n(e,i,r){var o;return s(this,n),(o=t(this,n,[i,r])).container=new Jn(e),o.iFrame=new Xn(o.container),o.event=new Qn(window),o}return d(n,e),c(n,[{key:"load",value:function(){this.iFrame.load(this.getIFrameUrl(),{title:"Payment Sources"})}},{key:"on",value:function(e,t){this.event.on(e,this.link.getParams().widget_id,t)}},{key:"hide",value:function(e){console.info("PayDock SDK"),this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"onSelectInsert",value:function(e,t){this.on(Zn.SELECT,(function(n){$n.insertToInput(e,t,n)}))}}])}(fr);!function(e){e.IFRAME_LOADED="iframeLoaded",e.CHECKOUT_READY="checkoutReady",e.CHECKOUT_COMPLETED="checkoutCompleted",e.CHECKOUT_ERROR="checkoutError",e.CHECKOUT_POPUP_OPEN="checkoutPopupOpen",e.CHECKOUT_POPUP_CLOSE="checkoutPopupClose"}(ir||(ir={})),function(e){e.CRITICAL_ERROR="CriticalError",e.USER_ERROR="UserError",e.SUCCESS="Success"}(rr||(rr={}));var vr,gr={PRIMARY_BUTTON_COLOR:"primary_button_color",SECONDARY_BUTTON_COLOR:"secondary_button_color",PRIMARY_BUTTON_TEXT_COLOR:"primary_button_text_color",SECONDARY_BUTTON_TEXT_COLOR:"secondary_button_text_color",FONT_FAMILY:"font_family",ENABLE_SRC_POPUP:"enable_src_popup"},yr=function(){return c((function e(t,n,i,r,o,a,c,l){s(this,e),this.meta=r,this.eventEmitter=o,this.autoResize=a,this.link=new Yn("/secure-remote-commerce/mastercard"),this.link.setParams(u({service_id:n,public_key:i},r&&{meta:JSON.stringify(r)})),J.version&&this.link.setParams({sdk_version:J.version,sdk_type:J.type}),c&&this.link.setEnv(c,l),this.iFrameContainer=new Jn(t),this.iFrame=new Xn(this.iFrameContainer),this.iFrameEvent=new Qn(window),this.setupIFrameEvents()}),[{key:"setupIFrameEvents",value:function(){var e=this,t=this.link.getParams().widget_id;t&&(this.iFrameEvent.on(ir.CHECKOUT_READY,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_READY,n)})),this.iFrameEvent.on(ir.CHECKOUT_COMPLETED,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_COMPLETED,n)})),this.iFrameEvent.on(ir.CHECKOUT_POPUP_OPEN,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_POPUP_OPEN,n)})),this.iFrameEvent.on(ir.CHECKOUT_POPUP_CLOSE,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_POPUP_CLOSE,n)})),this.iFrameEvent.on(ir.CHECKOUT_ERROR,t,(function(t){var n=t.data;e.eventEmitter.emit(ir.CHECKOUT_ERROR,n)})),this.autoResize&&this.useAutoResize(!0))}},{key:"load",value:function(){var e=this;this.iFrame.load(this.link.getUrl(),{title:"Click To Pay checkout"});var t=this.iFrame.getElement();this.iFrame.setStyle("width","100%"),t&&(t.onload=function(){return e.eventEmitter.emit(ir.IFRAME_LOADED,{})})}},{key:"getEnv",value:function(){return this.link.getEnv()}},{key:"hideCheckout",value:function(e){this.iFrame&&this.iFrame.hide()}},{key:"showCheckout",value:function(){this.iFrame&&this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"useAutoResize",value:function(e){var t=this;if(!this.autoResize||e){this.autoResize=!0;var n=this.link.getParams();(null==n?void 0:n.widget_id)&&this.iFrameEvent.on("resize",n.widget_id,(function(e){var n,i,r=e.data,o=t.iFrame.getElement();o&&(o.scrolling="no",(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.height)&&t.iFrame.setStyle("height",(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.height)+"px"))}))}}}])}(),br=function(){return c((function e(t,n,i,r){s(this,e),this.iframe_selector=t,this.service_id=n,this.public_key_or_access_token=i,this.meta=r,this.autoResize=!1,this.style={},this.api=new pi(i,Dn.PUBLIC_KEY),this.eventEmitter=new vi}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==pr.values(gr).indexOf(e)?this.style[e]=t:console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){var e=this;this.provider||this.api.service().getConfig(this.service_id).then((function(t){var n=t.type;if(e.meta.customizations=e.style,n===ti.MASTERCARD_SRC)e.provider=new yr(e.iframe_selector,e.service_id,e.public_key_or_access_token,e.meta,e.eventEmitter,e.autoResize,e.env,e.alias);e.provider&&e.provider.load()}))}},{key:"setEnv",value:function(e,t){this.provider||(this.env=e,this.alias=t,this.api.setEnv(e,t))}},{key:"getEnv",value:function(){return this.provider?this.provider.getEnv():this.env}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"hideCheckout",value:function(e){this.provider&&"function"==typeof this.provider.hideCheckout&&this.provider.hideCheckout(e)}},{key:"showCheckout",value:function(){this.provider&&"function"==typeof this.provider.showCheckout&&this.provider.showCheckout()}},{key:"reload",value:function(){this.provider&&this.provider.reload()}},{key:"useAutoResize",value:function(){this.autoResize=!0,this.provider&&"function"==typeof this.provider.useAutoResize&&this.provider.useAutoResize()}}])}(),Er=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i,r,o])).iframe_selector=e,a.service_id=i,a.public_key_or_access_token=r,a.meta=o,a}return d(n,e),c(n,[{key:"load",value:function(){this.provider||(this.meta.customizations=this.style,this.provider=new yr(this.iframe_selector,this.service_id,this.public_key_or_access_token,this.meta,this.eventEmitter,this.autoResize,this.env,this.alias),this.provider.load())}}])}(br),wr={SUBMIT_FORM:"submit_form",CHANGE_TAB:"tab",HIDE_ELEMENTS:"hide_elements",SHOW_ELEMENTS:"show_elements",REFRESH_CHECKOUT:"refresh_checkout",UPDATE_FORM_VALUES:"update_form_values",INIT_CHECKOUT:"init_checkout"},kr=function(){return c((function e(t){s(this,e),this.iFrame=t}),[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===pr.values(wr).indexOf(e)&&console.warn("unsupported trigger type");var n={trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}();!function(e){e.AFTER_LOAD="after_load",e.SYSTEM_ERROR="system_error",e.CVV_SECURE_CODE_REQUESTED="cvv_secure_code_requested",e.CARD_NUMBER_SECURE_CODE_REQUESTED="card_number_secure_code_requested",e.ACCESS_FORBIDDEN="access_forbidden",e.SESSION_EXPIRED="session_expired",e.OPERATION_FORBIDDEN="operation_forbidden"}(vr||(vr={}));var Sr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"on",value:function(e,t,n){for(var i in vr)vr.hasOwnProperty(i)&&e===vr[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(Qn),Tr=function(){return c((function e(t,n){s(this,e),this.validationData={},this.configs=[],this.container=new Jn(t),this.iFrame=new Xn(this.container),this.triggerElement=new kr(this.iFrame),this.event=new Sr(window),this.vaultDisplayToken=n,this.link=new Yn("/vault-display"),this.link.setParams({vault_display_token:n})}),[{key:"setEnv",value:function(e,t){this.link.setEnv(e,t)}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"setStyle",value:function(e,t){-1!==pr.values(Ci).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"load",value:function(){this.iFrame.load(this.link.getUrl(),{title:"Vault Display"})}}])}(),_r={UNAVAILABLE:"unavailable",UPDATE:"update",PAYMENT_METHOD_SELECTED:"payment_method_selected",PAYMENT_SUCCESS:"payment_success",PAYMENT_IN_REVIEW:"payment_in_review",PAYMENT_ERROR:"payment_error",CALLBACK:"callback",AUTH_TOKENS_CHANGED:"auth_tokens_changed",BUTTON_CLICK:"button_click",CHECKOUT_OPEN:"checkout_open",CHECKOUT_CLOSE:"checkout_close"},Cr=function(){return c((function e(t,n){s(this,e),this.publicKey=t,this.meta=n,this.env=G,this.eventEmitter=new vi,this.initializeChildWallets()}),[{key:"initializeChildWallets",value:function(){this.childWallets=[]}},{key:"getGatewayName",value:function(){throw new Error("Method not implemented")}},{key:"setEnv",value:function(e){return this.env=e,this}},{key:"load",value:function(e){this.childWallets.forEach((function(t){return t.load(e)}))}},{key:"update",value:function(e){}},{key:"enable",value:function(){}},{key:"disable",value:function(){}},{key:"on",value:function(e,t){var n=this;if(-1===pr.values(_r).indexOf(e))throw new Error("invalid wallet event");return"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}}])}(),Or=function(e){function n(e,i){var r;return s(this,n),(r=t(this,n,[e,i])).token=e,r.storageDispatcher=new er("afterpay.wallet.paydock"),r}return d(n,e),c(n,[{key:"load",value:function(e){var t=this;this.storageDispatcher.create((function(){return t.mount(e)}))}},{key:"setEnv",value:function(e){return f(h(n.prototype),"setEnv",this).call(this,e),this.storageDispatcher.setEnv(e),this}},{key:"mount",value:function(e){var t,n,i,r,s=this,a={};(null===(t=this.meta)||void 0===t?void 0:t.style)&&"object"===o(null===(n=this.meta)||void 0===n?void 0:n.style)&&(a=JSON.parse(JSON.stringify((null===(i=this.meta)||void 0===i?void 0:i.style.afterpay)||(null===(r=this.meta)||void 0===r?void 0:r.style))));var c=this.getButton(a);c.onclick=function(){return s.onAfterPayButtonClicked()};var l=this.getButtonStyle(a);e.getElement().appendChild(c),e.getElement().appendChild(l)}},{key:"onAfterPayButtonClicked",value:function(){var e,t,n=this,i=document.createElement("script"),r=null===(e=this.meta)||void 0===e?void 0:e.country;i.type="text/javascript",i.src="live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"https://portal.afterpay.com/afterpay.js":"https://portal.sandbox.afterpay.com/afterpay.js",i.async=!0,i.defer=!0,i.onload=function(){window.AfterPay.initialize({countryCode:r}),n.storageDispatcher.push({intent:$i.WIDGET_SESSION,data:{token:n.token}},{onSuccess:function(){n.getCheckoutSession().then((function(e){window.AfterPay.redirect({token:e.ref_token})})).catch((function(e){window.AfterPay.close(),n.eventEmitter.emit(_r.UNAVAILABLE,{err:e})}))},onError:function(){console.error("Error initializing Afterpay wallet"),window.AfterPay.close(),n.eventEmitter.emit(_r.UNAVAILABLE,{})}})},document.head.appendChild(i)}},{key:"getCheckoutSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(_r.CALLBACK,{data:{request_type:"CREATE_SESSION",wallet_type:ki.AFTERPAY},onSuccess:function(e){t(e)},onError:function(e){n(e)}})}))}},{key:"getButton",value:function(e){var t=document.createElement("button");return t.classList.add("afterpay-checkout-btn"),t.setAttribute("type","button"),t.innerHTML='\n <div class="afterpay-checkout-btn__wrapper">\n <svg viewBox="0 0 390 94"\n height="'.concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <g fill="currentColor">\n <path\n d="M388.6 21.4l-34.8 71.8h-14.4l13-26.8-20.5-45h14.8l13.2 30.1 14.3-30.1zM41 46.9c0-8.6-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4C11 73.2.4 62 .4 46.9c0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51H41.1zM114.6 61.1c-4.4 0-5.6-1.6-5.6-5.9V32.5h8.1V21.4H109V8.9H96.1v12.4H79.5v-5.1c0-4.3 1.6-5.9 6.1-5.9h2.8V.4h-6.2C71.6.4 66.6 3.9 66.6 14.5v6.8h-7.1v11.1h7.1v39.9h12.9V32.5h16.6v25c0 10.4 4 14.9 14.4 14.9h6.6V61.1h-2.5zM160.7 42.3c-.9-6.6-6.3-10.6-12.6-10.6s-11.5 3.9-12.9 10.6h25.5zm-25.6 7.9c.9 7.5 6.3 11.8 13.2 11.8 5.4 0 9.6-2.6 12-6.6h13.2c-3.1 10.8-12.7 17.7-25.5 17.7-15.4 0-26.2-10.8-26.2-26.2 0-15.4 11.4-26.5 26.5-26.5 15.2 0 26.2 11.2 26.2 26.5 0 1.1-.1 2.2-.3 3.3h-39.1zM256.2 46.9c0-8.3-6.2-14.6-13.9-14.6s-13.9 6.1-13.9 14.6c0 8.4 6.2 14.6 13.9 14.6 7.6 0 13.9-6.4 13.9-14.6m-40.4 46.3V21.4h12.5V28c3.8-4.7 9.4-7.5 16.1-7.5 13.8 0 24.6 11.3 24.6 26.3s-11 26.4-24.9 26.4c-6.4 0-11.7-2.6-15.4-6.8v26.8h-12.9zM314.2 46.9c0-8.6-6.2-14.6-13.9-14.6-7.6 0-13.9 6.1-13.9 14.6 0 8.4 6.2 14.6 13.9 14.6s13.9-6.1 13.9-14.6m.1 25.5v-6.6c-3.8 4.6-9.4 7.4-16.1 7.4-14 0-24.6-11.2-24.6-26.3 0-15 11-26.4 24.9-26.4 6.5 0 12 2.9 15.8 7.3v-6.4h12.5v51h-12.5zM193.2 26.4s3.2-5.9 11-5.9c3.3 0 5.5 1.2 5.5 1.2v13s-4.7-2.9-9.1-2.3c-4.3.6-7.1 4.6-7.1 9.9v30.2h-13v-51H193v4.9h.2z" />\n </g>\n </svg>\n <svg viewBox="0 0 107 96"\n height="').concat(this.getHeight(e),'"\n xmlns="http://www.w3.org/2000/svg">\n <path\n d="M99 19.5L84.2 11l-15-8.6c-10-5.7-22.4 1.5-22.4 13v1.9c0 1.1.6 2 1.5 2.6l7 4c1.9 1.1 4.4-.3 4.4-2.5v-4.6c0-2.3 2.5-3.7 4.4-2.6l13.8 7.9L91.6 30c2 1.1 2 4 0 5.1L77.9 43l-13.8 7.9c-2 1.1-4.4-.3-4.4-2.6V46c0-11.5-12.4-18.7-22.4-13l-15 8.6-14.8 8.5c-10 5.7-10 20.2 0 26l14.8 8.5 15 8.6c10 5.7 22.4-1.5 22.4-13v-1.9c0-1.1-.6-2-1.5-2.6l-7-4c-1.9-1.1-4.4.3-4.4 2.5v4.6c0 2.3-2.5 3.7-4.4 2.6l-13.8-7.9-13.7-7.9c-2-1.1-2-4 0-5.1l13.7-7.9 13.8-7.9c2-1.1 4.4.3 4.4 2.6v2.3c0 11.5 12.4 18.7 22.4 13l15-8.6L99 45.5c10.1-5.8 10.1-20.2 0-26"\n fill="currentColor" />\n </svg>\n </div>\n '),t}},{key:"getButtonStyle",value:function(e){var t=document.createElement("style"),n=this.generateButtonColor(e.button_type);return t.innerText="\n .afterpay-checkout-btn {\n outline: none;\n border: none;\n border-radius: ".concat(this.getHeight(e),";\n padding: 0;\n margin: 0;\n transition: all 300ms;\n cursor: pointer;\n }\n\n .afterpay-checkout-btn:active {\n opacity: 0.7;\n }\n\n .afterpay-checkout-btn__wrapper {\n display: flex;\n align-items: center;\n padding: 10px 20px;\n color: ").concat(n.color,";\n background-color: ").concat(n.background,";\n border-radius: ").concat(this.getHeight(e),";\n }\n "),t}},{key:"generateButtonColor",value:function(e){switch(e){case"black":return{color:"#B2FCE3",background:"#000"};case"mint":return{color:"#000",background:"#B2FCE3"};default:return{color:"#fff",background:"#000"}}}},{key:"getHeight",value:function(e){return e.height?Number.isNaN(Number(e.height))?e.height:"".concat(e.height,"px"):"40px"}}])}(Cr);var Nr=class{DEFAULT_WIDTH=450;DEFAULT_HEIGHT=750;DEFAULT_FEATURES={resizable:"no"};auth;callback;error;frame;isCheckoutOpen;onMessage;url;orderId;accessToken;refreshToken;clientId;onCheckoutClosed;redirectUrl;rootUrl;targetOrigin;title;windowFeatures;windowObserver;constructor({auth:e,url:t,clientId:n,mode:i,orderId:r,onCheckoutClosed:o,onError:s,onTokensChanged:a,onPaymentSuccess:c,onPaymentError:l,redirectUrl:u,title:d,windowFeatures:h}){this.callback={ERROR({error:e,orderId:t}){s?.({error:e,orderId:t})},PAYMENT_ERROR({error:e,orderId:t}){l?.({error:e,orderId:t})},PAYMENT_SUCCESS({orderId:e}){c?.({orderId:e})},TOKENS_CHANGED({accessToken:e,refreshToken:t}){a?.({accessToken:e,refreshToken:t})}},this.auth=e,this.isCheckoutOpen=!1,this.error=void 0,this.frame=void 0,this.onMessage=e=>{const{data:n,origin:i}=e;i===t&&(!0===n?.isDomReady&&this.postMessage(),n?.isPaymentSuccessful&&this.callback.PAYMENT_SUCCESS({orderId:n.orderId}),!n?.isPaymentSuccessful&&n?.error&&this.callback.PAYMENT_ERROR({orderId:n.orderId,error:n.error}),!n?.paymentFlowState&&n?.error&&this.callback.ERROR({orderId:n.orderId,error:n.error}),n?.accessToken&&n?.refreshToken&&this.callback.TOKENS_CHANGED({accessToken:n.accessToken,refreshToken:n.refreshToken}))};const p=i||"default",f=u?`&redirectUrl=${u}`:"",m=n?`&clientId=${n}`:"";this.rootUrl=t.replaceAll(/\/+$/g,""),this.targetOrigin=window.location.href.replace(/\/$/,""),this.url=`${this.rootUrl}?orderId=${r}&merchantUrl=${encodeURIComponent(this.targetOrigin)}&mode=${p}${f}${m}`,this.orderId=r,this.clientId=n,this.onCheckoutClosed=o,this.title=d,this.windowFeatures=h,this.windowObserver=void 0}get isWindowObserverOpen(){return!!this.windowObserver}open=()=>{this.isCheckoutOpen?this.frame?.focus():(this.frame=window.open(this.url,this.title,this.getFeatures()),this.isCheckoutOpen=!0,this.startWindowObserver())};close=()=>{this.frame?.close(),this.frame=void 0,this.isCheckoutOpen=!1,this.stopWindowObserver()};listenMessage=()=>{this.onMessage&&window.addEventListener("message",this.onMessage,!1)};postMessage=()=>{this.frame&&this.rootUrl&&this.frame.postMessage({auth:{...this.auth}},this.rootUrl)};getFeatures(){const e=this.windowFeatures?.width||this.DEFAULT_WIDTH,t=this.windowFeatures?.height||this.DEFAULT_HEIGHT,n={...this.DEFAULT_FEATURES,...this.windowFeatures};return function(e,t="="){return Object.keys(e).length?Object.entries(e).reduce(((e,[n,i])=>[...e,`${n}${t}${i}`]),[]).join(","):""}({...this.getCenteredPosition(e,t),...n,width:e,height:t})}getCenteredPosition(e,t){return{left:screen.width/2-e/2,top:screen.height/2-t/2}}startWindowObserver(){this.isWindowObserverOpen||(this.windowObserver=setInterval((()=>{this.frame?.closed&&(this.close(),this.onCheckoutClosed?.({orderId:this.orderId}),this.onMessage&&window.removeEventListener("message",this.onMessage))}),300))}stopWindowObserver(){clearInterval(this.windowObserver)}},Ir=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return s(this,n),(i=t(this,n)).bgImageUrl=e,i.hideCloseButton=r,i.hideContinueButton=o,i.imageStyle=null,i}return d(n,e),c(n,[{key:"initControl",value:function(){this.imageStyle||this.createImageStyles(),f(h(n.prototype),"initControl",this).call(this)}},{key:"clear",value:function(){this.imageStyle&&this.imageStyle.parentNode.removeChild(this.imageStyle),this.imageStyle=null,f(h(n.prototype),"clear",this).call(this)}},{key:"createTemplate",value:function(){var e=this,t=document.body||document.getElementsByTagName("body")[0],n=String('\n <div class="checkout-container">\n <div class="checkout-bg-logo"></div>\n <a href="#" data-continue>Continue</a>\n <a href="#" data-close>Close</a>\n </div>\n');!0===this.hideCloseButton&&(n=n.replace('<a href="#" data-close>Close</a>',"")),!0===this.hideContinueButton&&(n=n.replace('<a href="#" data-continue>Continue</a>',"")),this.overlay=document.createElement("div"),this.overlay.classList.add("checkout-overlay"),this.overlay.setAttribute("checkout-overlay"," "),this.overlay.innerHTML=n,t.appendChild(this.overlay),setTimeout((function(){e.isInit()&&e.overlay.classList.add("display")}),5)}},{key:"createImageStyles",value:function(){var e=document.head||document.getElementsByTagName("head")[0],t=String("\n .checkout-bg-logo {\n display: block;\n background: url({{url}}) no-repeat;\n width: 100px;\n height: 50px;\n margin: 0 auto;\n border-radius: 10px;\n background-size: contain;\n }\n [data-continue] {\n margin-top: 24px;\n display: block;\n font-family: Helvetica, sans-serif;\n text-decoration: none;\n color: #fff !important;\n border: 1px solid white;\n width: 100px;\n border-radius: 16px;\n padding: 5px;\n }\n [data-continue]:hover {\n background-color: #f2f2f2;\n border: none;\n color: rgba(0, 0, 0, 0.7) !important;\n }\n .checkout-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .checkout-overlay {\n z-index: 2147483647;\n }\n\n .checkout-container [data-close] {\n opacity: 1;\n }\n .checkout-container [data-close]:before,\n .checkout-container [data-close]:after {\n background-color: #fff;\n }\n");document.querySelector(".checkout-container"),t=t.replace("{{url}}",this.bgImageUrl),this.imageStyle=document.createElement("style"),this.imageStyle.type="text/css",this.imageStyle.appendChild(document.createTextNode(t)),e.appendChild(this.imageStyle)}}])}(ji);function Ar(e){return xr("paydock-flypay-button",e)}function Rr(e){return"flypay-v2-checkout-btn__wrapper__".concat(e)}function xr(e,t){return'\n <div id="'.concat(t,'-loading-overlay"></div>\n <div class="').concat(e,'" tabindex="0">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 125.2 21" data-name="pay-with-flypay"\n style="grid-area: center; width: 100%; height: 100%"\n fill="none"\n >\n <path\n fill="#fff"\n d="M89 .5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM98 22.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1h-15a.5.5 0 0 1-.5-.5ZM87 3.5a.5.5 0 0 1 .5-.5H121c.758 0 1.42.031 1.974.133.553.102 1.044.284 1.421.618.78.694.849 1.829.598 3.331-.258 1.552-1.025 3.843-1.711 5.715a100.003 100.003 0 0 1-1.211 3.128l-.081.198-.021.051v.001c-.531 1.583-1.345 2.557-2.269 3.126-.92.566-1.898.699-2.7.699H96.5a.5.5 0 1 1 0-1v.5-.5H117c.698 0 1.47-.117 2.175-.55.697-.43 1.382-1.2 1.851-2.608l.005-.017.008-.018.006-.016.021-.05.079-.194a94.823 94.823 0 0 0 1.198-3.094c.689-1.878 1.422-4.087 1.664-5.535.249-1.498.068-2.113-.277-2.42-.186-.165-.476-.296-.938-.381C122.33 4.03 121.742 4 121 4H87.5a.5.5 0 0 1-.5-.5ZM76.512 9.512h3.157V7.34h-3.157v-.01h-.02c.01-1.196.841-2.17 2.52-2.17H81V3h-1.988C75.547 3 74.008 4.936 74 7.326V16h2.512V9.512ZM82 3.55 84.987 3H85v13h-3V3.55Z"\n />\n <path\n fill="#fff"\n d="M91.592 15.365a4.557 4.557 0 0 1-1.595.33c-2.391 0-4-1.68-3.997-4.092V7.546l2.41-.543V11.6c0 1.118.536 1.738 1.59 1.738 1.055 0 1.592-.622 1.592-1.738V7.543L94 7v9.855C94 19.41 92.497 21 90.073 21h-.596v-2.359h.59c.71 0 1.525-.641 1.525-1.786v-1.49Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M2.54 11.6h2.598c1.356 0 2.399-.299 3.129-.896.731-.598 1.096-1.62 1.096-3.063 0-1.323-.365-2.3-1.096-2.93-.73-.631-1.71-.947-2.938-.947H0V16h2.54v-4.4Zm4.291-3.943c0 .637-.166 1.102-.498 1.395-.337.293-.808.44-1.411.44H2.54V5.889h2.382c.603 0 1.071.136 1.403.407.337.271.506.725.506 1.361ZM14.651 6.736c-1.522 0-2.596.398-3.221 1.195-.393.51-.614 1.16-.664 1.95h2.283c.055-.348.166-.624.332-.83.232-.276.628-.414 1.187-.414.498 0 .874.072 1.128.216.261.138.391.392.391.763 0 .305-.169.529-.507.673-.188.083-.501.152-.938.207l-.805.1c-.913.116-1.605.31-2.075.58-.858.499-1.287 1.304-1.287 2.416 0 .858.266 1.522.797 1.993.537.464 1.215.697 2.034.697.642 0 1.217-.147 1.726-.44a4.83 4.83 0 0 0 1.129-.905c.017.205.039.388.067.548.027.16.077.332.149.515h2.573v-.349a.843.843 0 0 1-.348-.274c-.078-.11-.125-.32-.141-.63-.011-.41-.017-.759-.017-1.047V9.55c0-1.09-.385-1.832-1.154-2.225-.769-.393-1.649-.59-2.639-.59Zm-.648 7.828c-.321 0-.592-.092-.813-.274-.227-.177-.341-.468-.341-.872 0-.454.183-.788.548-1.004.216-.128.573-.236 1.071-.324l.531-.1c.266-.05.473-.102.623-.157.155-.061.307-.139.456-.233v.88c-.016.791-.24 1.336-.672 1.635a2.39 2.39 0 0 1-1.403.449Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m26.097 6.952-1.867 6.674-1.976-6.674h-2.631l3.32 9.446c.022.066-.028.25-.149.548-.117.299-.244.495-.382.59-.144.099-.321.162-.531.19a3.752 3.752 0 0 1-.665.025l-.298-.017v1.893c.254.017.445.025.572.025.128.005.296.008.507.008 1.046 0 1.743-.207 2.092-.622.348-.41.821-1.472 1.419-3.188l3.104-8.898h-2.515ZM40.192 9.409l1.419 6.59h2.433l2.623-9.047h-2.466l-1.411 6.516-1.378-6.516h-2.399l-1.303 6.491-1.411-6.491h-2.54L36.299 16h2.457l1.436-6.591ZM50.41 16V6.952h-2.399V16h2.399ZM50.41 5.873V3.689h-2.399v2.184h2.399ZM56.852 16.083v-1.768l-.241.016h-.224c-.482 0-.769-.044-.863-.133-.094-.094-.142-.326-.142-.697V8.72h1.47V7.035h-1.47V4.51h-2.34v2.524H51.78V8.72h1.262v5.57c0 .564.132.982.398 1.253.41.426 1.173.62 2.291.581l1.121-.041ZM66.547 16v-5.313c0-.808-.028-1.389-.083-1.743a2.347 2.347 0 0 0-.457-1.046 2.656 2.656 0 0 0-1.128-.888 3.836 3.836 0 0 0-1.519-.29c-.499 0-.974.104-1.428.315-.448.204-.844.57-1.187 1.095V3.806h-2.358V16h2.358v-4.898c0-.775.16-1.37.481-1.785.327-.42.803-.63 1.428-.63.603 0 1.013.21 1.228.63.167.3.25.692.25 1.18V16h2.415Z"\n />\n <path\n fill="#fff"\n fill-rule="evenodd"\n d="M103 16h1.997l1.276-2.003h3.56l.265 2.003H112l-1.337-9h-1.778L103 16Zm6.231-6.674.383 2.954h-2.237l1.854-2.954ZM98.02 16l.754-2.72h1.752a6.36 6.36 0 0 0 1.762-.228c.512-.139.992-.37 1.412-.683.398-.299.721-.677.95-1.107.24-.465.36-.978.349-1.496 0-.772-.239-1.389-.716-1.85a2.871 2.871 0 0 0-1.195-.7A5.816 5.816 0 0 0 101.401 7h-2.926L96 16h2.02Zm3.307-7.205c.257-.007.512.026.757.097.194.06.368.165.51.304.101.098.18.215.232.344a.977.977 0 0 1 .072.402c.012.232-.039.463-.147.671-.108.209-.27.387-.471.519-.413.279-.955.418-1.635.418h-1.38l.751-2.752h1.314l-.003-.003Z"\n clip-rule="evenodd"\n />\n <path\n fill="#fff"\n d="m113.439 16 .982-3.548L112.5 7h2.266l1.087 3.73L119.112 7h2.388l-5.078 5.63-.939 3.37h-2.044Z"\n />\n </svg>\n </div>\n ')}var Mr,Pr=function(e){function n(e,i){var r;if(s(this,n),(r=t(this,n,[e,i])).widgetId=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(2,10),r.onFlypayV2ButtonClick=function(){var e=function(e){var t,n=document.getElementById((t=r.widgetId,"".concat(t,"-loading-overlay")));n&&(n.style.display=e)};r.disable(),e("flex"),r.handleMerchantOnButtonClickEvent().then((function(){var t;e("none"),r.background=r.initBackground(),null===(t=r.background)||void 0===t||t.initControl(),r.flypayV2Checkout(r.orderId)})).catch((function(t){e("none"),r.enable()}))},r.accessToken=null==i?void 0:i.access_token,r.refreshToken=null==i?void 0:i.refresh_token,!(null==i?void 0:i.client_id))throw new Error("Wallet meta `client_id` is required as part of initialization process.");return r.link=new Yn(""),r}return d(n,e),c(n,[{key:"load",value:function(e){var t=this;this.orderId?this.mount(e):this.getOrderId().then((function(n){t.orderId=n,t.mount(e)})).catch((function(e){console.error("Error generating order id",e),t.eventEmitter.emit(_r.UNAVAILABLE)}))}},{key:"setEnv",value:function(e){return this.link.setEnv(e),f(h(n.prototype),"setEnv",this).call(this,e)}},{key:"enable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!1,this.flypayV2Button.innerHTML=Ar(this.widgetId))}},{key:"disable",value:function(){var e=document.getElementById(this.widgetId);e&&(e.disabled=!0,this.flypayV2Button.innerHTML=xr("paydock-flypay-button paydock-flypay-button__disabled",this.widgetId))}},{key:"mount",value:function(e){this.flypayV2Button=this.getButton(),this.flypayV2Button.onclick=this.onFlypayV2ButtonClick,e.getElement().appendChild(this.flypayV2Button)}},{key:"getButton",value:function(){var e,t,n=document.createElement("style");return n.innerHTML=(e=this.widgetId,t=Rr(e),"\n .".concat(t," {\n position: relative;\n height: 100%;\n width: 100%;\n border: none; /* Remove borders */\n background: transparent; /* Make the button background transparent */\n cursor: pointer; /* Make it look clickable */\n outline: none; /* Remove focus outline */\n padding: 0; /* Remove any default padding */\n }\n\n .").concat(t,' .paydock-flypay-button {\n background-color: #212121;\n border-radius: 9999px;\n width: 100%; /* set hard pixel dimensions here for a button with intrinsic dimensions */\n height: 100%; /* and leave the 100% settings for the Coles use case (enabled by extra param object flag) */\n display: grid;\n grid-template-columns: 20% 1fr 20%;\n grid-template-rows: 20% 1fr 20%;\n grid-template-areas:\n ". . ."\n ". center ."\n ". . .";\n box-sizing: border-box;\n }\n \n .').concat(t," .paydock-flypay-button:hover {\n background-color: #3d3d3d;\n }\n \n .").concat(t," .paydock-flypay-button:focus-visible {\n outline-color: transparent;\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #2670ee;\n outline-color: transparent;\n }\n \n .").concat(t," .paydock-flypay-button:active {\n background-color: #6f6f6f;\n }\n \n .").concat(t," .paydock-flypay-button:disabled,\n .").concat(t," .paydock-flypay-button__disabled {\n opacity: 25%;\n cursor: not-allowed;\n }\n \n #").concat(e,"-loading-overlay {\n position: absolute;\n height: 100%;\n width: 100%;\n background: rgba(255, 255, 255, 0.7);\n display: none;\n justify-content: center;\n align-items: center;\n cursor: not-allowed; /* Make it look not clickable */ \n }\n \n #").concat(e,'-loading-overlay::after {\n content: "";\n height: 60%;\n aspect-ratio: 1 / 1;\n display: inline-block;\n border: 4px solid #ccc;\n border-top-color: #333;\n border-radius: 50%;\n /* Vendor prefixes for animation property */\n -webkit-animation: spin 1s infinite linear;\n -moz-animation: spin 1s infinite linear;\n -o-animation: spin 1s infinite linear;\n animation: spin 1s infinite linear;\n }\n \n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); \n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-moz-keyframes spin {\n 0% {\n -moz-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -moz-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @-o-keyframes spin {\n 0% {\n -o-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -o-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }\n \n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n } \n ')),document.head.appendChild(n),this.flypayV2Button=document.createElement("button"),this.flypayV2Button.classList.add(Rr(this.widgetId)),this.flypayV2Button.setAttribute("type","button"),this.flypayV2Button.setAttribute("aria-label","Pay with flypay"),this.flypayV2Button.setAttribute("id",this.widgetId),this.flypayV2Button.innerHTML=Ar(this.widgetId),this.flypayV2Button}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"getOrderId",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(_r.CALLBACK,{data:{request_type:"CREATE_SESSION"},onSuccess:function(e){return t(e.id)},onError:function(e){return n(e.error)}})}))}},{key:"flypayV2Checkout",value:function(e){var t,n=this;this.checkout=new Nr(u(u({orderId:e},this.accessToken&&this.refreshToken&&{auth:{access_token:this.accessToken,refresh_token:this.refreshToken},mode:"express"}),{clientId:this.meta.client_id,url:"live"===(null===(t=this.meta)||void 0===t?void 0:t.gateway_mode)?"https://checkout.flypay.com.au":"https://checkout.sandbox.cxbflypay.com.au",onCheckoutClosed:function(){var e;n.eventEmitter.emit(_r.CHECKOUT_CLOSE),null===(e=n.background)||void 0===e||e.clear(),n.enable()},onError:function(e){return n.eventEmitter.emit(_r.PAYMENT_ERROR,{error:e})},onPaymentSuccess:function(e){return n.eventEmitter.emit(_r.PAYMENT_SUCCESS,e)},onPaymentError:function(e){return n.eventEmitter.emit(_r.PAYMENT_ERROR,{error:e})},onTokensChanged:function(e){var t=e.accessToken,i=e.refreshToken;n.accessToken=t,n.refreshToken=i,n.eventEmitter.emit(_r.AUTH_TOKENS_CHANGED,{accessToken:t,refreshToken:i})}})),this.checkout.open(),this.checkout.isCheckoutOpen&&this.eventEmitter.emit(_r.CHECKOUT_OPEN,{}),this.checkout.listenMessage()}},{key:"initBackground",value:function(){var e=this,t=new Ir(this.link.getNetUrl()+Kn,!1,!1);return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Fi,(function(){var t;e.checkout.close(),null===(t=e.background)||void 0===t||t.clear(),e.enable()})),t.onTrigger(Ui,(function(){return e.checkout.open()})),t}}])}(Cr);!function(e){e.AFTER_LOAD="after_load",e.UNAVAILABLE="unavailable",e.START_LOADING="start_loading",e.END_LOADING="end_loading",e.UPDATE="update",e.PAYMENT_SUCCESSFUL="payment_successful",e.PAYMENT_IN_REVIEW="payment_in_review",e.PAYMENT_ERROR="payment_error"}(Mr||(Mr={}));var Dr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"on",value:function(e,t,n){for(var i in Mr)Mr.hasOwnProperty(i)&&e===Mr[i]&&this.listeners.push({event:e,listener:n,widget_id:t})}}])}(Qn),Lr={CLOSE:"close",UPDATED:"updated"},Fr=function(e){function n(e,i){var r;return s(this,n),(r=t(this,n,[e])).widgetId=i,r}return d(n,e),c(n,[{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.iFrame.isExist()){-1===pr.values(Lr).indexOf(e)&&console.warn("unsupported trigger type");var n={message_source:"wallet.paydock",reference_id:this.widgetId,trigger:e,destination:"widget.paydock",data:t};this.iFrame.getElement().contentWindow.postMessage(JSON.stringify(n),"*")}}}])}(kr),Ur=function(e){function n(e,i){var r;s(this,n),(r=t(this,n,[e,i])).link=new Yn(Gn);var o=i.amount,a=i.currency,c=i.id,l=i.gateway_mode,d=i.reference,h=i.request_shipping;return r.link.setParams(u({token:e,amount:o,currency:a,gateway_mode:l,credentials:d||c},h?{request_shipping:h}:{})),J.version&&r.link.setParams({sdk_version:J.version,sdk_type:J.type}),r.token=e,r.event=new Dr(window),r}return d(n,e),c(n,[{key:"load",value:function(e){this.container=e,this.iFrame=new Xn(this.container);var t=this.link.getParams().widget_id;this.triggerElement=new Fr(this.iFrame,t),this.setupIFrameEvents(t),this.background=this.initBackground(),this.iFrame.load(this.link.getUrl())}},{key:"close",value:function(){this.triggerElement.push(Lr.CLOSE),this.background.clear()}},{key:"update",value:function(e){this.triggerElement.push(Lr.UPDATED,e)}},{key:"setEnv",value:function(e){return this.link.setEnv(e),this}},{key:"initBackground",value:function(){var e=this,t=new Ir(this.link.getNetUrl().replace(Gn,Kn));return t.setBackdropTitle(""),t.setBackdropDescription(""),t.onTrigger(Fi,(function(){return e.triggerElement.push(Lr.CLOSE)})),t}},{key:"setupIFrameEvents",value:function(e){var t=this;this.event.on(Mr.UNAVAILABLE,e,(function(e){return t.eventEmitter.emit(_r.UNAVAILABLE,null)})),this.event.on(Mr.START_LOADING,e,(function(e){return t.background.initControl()})),this.event.on(Mr.END_LOADING,e,(function(e){return t.background.clear()})),this.event.on(Mr.UPDATE,e,(function(e){t.eventEmitter.emit(_r.UPDATE,t.parseUpdateData(e))})),this.event.on(Mr.PAYMENT_SUCCESSFUL,e,(function(e){t.eventEmitter.emit(_r.PAYMENT_SUCCESS,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(Mr.PAYMENT_IN_REVIEW,e,(function(e){t.eventEmitter.emit(_r.PAYMENT_IN_REVIEW,t.parsePaymentSuccessfulData(e)),t.iFrame.getElement()||t.background.clear()})),this.event.on(Mr.PAYMENT_ERROR,e,(function(e){t.eventEmitter.emit(_r.PAYMENT_ERROR,e),t.iFrame.getElement()||t.background.clear()}))}},{key:"parsePaymentSuccessfulData",value:function(e){var t;return{id:this.meta.id,amount:e.amount,currency:e.currencyCode,status:null===(t=e.charge)||void 0===t?void 0:t.status}}},{key:"parseUpdateData",value:function(e){return u(u(u({wallet_response_code:e.responseCode,wallet_session_id:e.sessionId},e.paymentMethodDetails?{payment_source:{wallet_payment_method_id:e.paymentMethodDetails.paymentMethodId,card_number_last4:e.paymentMethodDetails.lastFourDigitsOfPan,card_scheme:e.paymentMethodDetails.paymentScheme}}:{}),e.loyaltyAccountSummary?{wallet_loyalty_account:{id:e.loyaltyAccountSummary.loyaltyAccountId,barcode:e.loyaltyAccountSummary.loyaltyAccountBarcode}}:{}),e.deliveryAddressDetails?{shipping:{address_line1:e.deliveryAddressDetails.line1,address_line2:e.deliveryAddressDetails.line2,address_postcode:e.deliveryAddressDetails.postalCode,address_city:e.deliveryAddressDetails.city,address_state:e.deliveryAddressDetails.state,address_country:e.deliveryAddressDetails.countryCode,address_company:e.deliveryAddressDetails.companyName,wallet_address_id:e.deliveryAddressDetails.addressId,post_office_box_number:e.deliveryAddressDetails.postOfficeBoxNumber,wallet_address_created_timestamp:e.deliveryAddressDetails.createdTimestamp,wallet_address_updated_timestamp:e.deliveryAddressDetails.updatedTimestamp,wallet_address_name:e.deliveryAddressDetails.name}}:{})}}])}(Cr),jr=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i])).gatewayName=r,a.eventEmitter=o,a.latestShippingData={},a.onCancelPayment=function(e){return a.eventEmitter.emit(_r.CHECKOUT_CLOSE)},a.onValidateMerchant=function(e){a.handleMerchantOnButtonClickEvent().then((function(){a.getMerchantSession().then((function(e){a.paymentSession.completeMerchantValidation(e)})).catch((function(e){console.error("Error fetching merchant session",e),a.paymentSession.abort()}))})).catch((function(e){console.error("Error while processing merchant callback",e),a.paymentSession.abort()}))},a.onPaymentAuthorized=function(e){var t,n=e.payment,i=n.token,r=n.billingContact,o=n.shippingContact;a.latestShippingData.shippingContact=o;var s=null===(t=a.selectedShippingOption)||void 0===t?void 0:t.type,c=[null==o?void 0:o.givenName,null==o?void 0:o.familyName].join(" ").trim();a.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:u({customer:{payment_source:u(u({wallet_type:ki.APPLE},c&&{card_name:c}),{type:i.paymentMethod.type,card_scheme:i.paymentMethod.network,address_line1:null==r?void 0:r.addressLines[0],address_line2:null==r?void 0:r.addressLines[1],address_country:null==r?void 0:r.countryCode,address_city:null==r?void 0:r.locality,address_postcode:null==r?void 0:r.postalCode,address_state:null==r?void 0:r.administrativeArea,ref_token:i.paymentData?JSON.stringify(i.paymentData):""})}},a.meta.request_shipping&&o&&{shipping:u(u(u({},s&&{method:s}),a.hasShippingOptions()&&{options:a.meta.shipping_options}),{address_line1:o.addressLines[0],address_line2:o.addressLines[1],address_country:o.countryCode,address_city:o.locality,address_postcode:o.postalCode,address_state:o.administrativeArea,contact:{first_name:o.givenName,last_name:o.familyName,email:o.emailAddress,phone:o.phoneNumber}})}),onSuccess:function(){return a.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS)},onError:function(){return a.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE)}})},a.onShippingContactSelected=function(e){a.latestShippingData.shippingContact=e.shippingContact;var t=a.parseUpdateData(a.latestShippingData);return a.eventEmitter.emit(_r.UPDATE,t),new Promise((function(e,t){a.latestShippingChangePromiseResolve=e,a.latestShippingChangePromiseReject=t}))},a.onShippingMethodSelected=function(e){var t,n;a.latestShippingData.shippingMethod=e.shippingMethod;var i={newTotal:{label:a.meta.amount_label||(null===(n=null===(t=a.getMetaRawDataInitialization())||void 0===t?void 0:t.total)||void 0===n?void 0:n.label),amount:a.meta.amount.toString(),type:"final"}};a.paymentSession.completeShippingMethodSelection(i)},a.parseUpdateData=function(e){var t,n,i,r,o,s,a,c;return u({shipping:{address_city:null===(t=null==e?void 0:e.shippingContact)||void 0===t?void 0:t.locality,address_state:null===(n=null==e?void 0:e.shippingContact)||void 0===n?void 0:n.administrativeArea,address_postcode:null===(i=null==e?void 0:e.shippingContact)||void 0===i?void 0:i.postalCode,address_country:null===(r=null==e?void 0:e.shippingContact)||void 0===r?void 0:r.countryCode}},(null==e?void 0:e.shippingMethod)&&{selected_shipping_option:{id:null===(o=null==e?void 0:e.shippingMethod)||void 0===o?void 0:o.identifier,label:null===(s=null==e?void 0:e.shippingMethod)||void 0===s?void 0:s.label,detail:null===(a=null==e?void 0:e.shippingMethod)||void 0===a?void 0:a.detail,amount:null===(c=null==e?void 0:e.shippingMethod)||void 0===c?void 0:c.amount}})},a.formatShippingOptions=function(e){return e.map((function(e){return{identifier:e.id,label:e.label,detail:(null==e?void 0:e.detail)||"",amount:e.amount}}))},a.eventEmitter=o,a}return d(n,e),c(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[ki.APPLE])||void 0===n?void 0:n.merchant)||""}},{key:"getMetaStyles",value:function(){var e,t,n;if((null===(e=this.meta)||void 0===e?void 0:e.style)&&"object"===o(null===(t=this.meta)||void 0===t?void 0:t.style)){var i=JSON.parse(JSON.stringify(null===(n=this.meta)||void 0===n?void 0:n.style));return"google"in i&&(null==i||delete i.google),"apple"in i?null==i?void 0:i.apple:i}return null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i;if((null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"object"===o(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)){var r=JSON.parse(JSON.stringify(null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization));return"google"in r&&(null==r||delete r.google),"apple"in r?null==r?void 0:r.apple:r}return null}},{key:"isShippingRequired",value:function(){var e;return null===(e=this.meta)||void 0===e?void 0:e.request_shipping}},{key:"hasShippingOptions",value:function(){var e,t;return(null===(e=this.meta)||void 0===e?void 0:e.request_shipping)&&!!(null===(t=this.meta)||void 0===t?void 0:t.shipping_options)}},{key:"load",value:function(e){var t=this;if(window.Promise)return this.checkAvailability().then((function(n){var i;n?(t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(i=t.meta)||void 0===i?void 0:i.shipping_options[0],t.latestShippingData.shippingMethod=t.formatShippingOptions([t.selectedShippingOption])[0]),t.mount(e)):t.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.APPLE})})).catch((function(e){return console.error("Error checking ApplePay availability",e)}));this.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.APPLE})}},{key:"update",value:function(e){var t,n,i;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success||!e.body)return this.latestShippingChangePromiseReject();var r=null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount,o=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;r&&(this.meta.amount=r),o&&(this.meta.shipping_options=o,this.selectedShippingOption=o?o[0]:void 0);var s=u({newTotal:{label:null===(i=this.meta)||void 0===i?void 0:i.amount_label,amount:this.meta.amount.toString(),type:"final"}},this.isShippingRequired()&&this.hasShippingOptions()&&{newShippingMethods:this.formatShippingOptions(this.meta.shipping_options)});this.paymentSession.completeShippingContactSelection(s),this.latestShippingChangePromiseResolve({})}}},{key:"checkAvailability",value:function(){var e=this;return new Promise((function(t,n){window.ApplePaySession&&ApplePaySession||t(!1),ApplePaySession.canMakePaymentsWithActiveCard(e.getMerchantId()).then((function(e){return t(e)})).catch((function(e){return t(!1)}))}))}},{key:"mount",value:function(e){var t=this,n=document.createElement("style");n.innerHTML=this.createButtonStyle(),document.head.appendChild(n);var i=document.createElement("div");i.onclick=function(){return t.onApplePayButtonClicked()},i.classList.add("paydock-apple-container","apple-pay-button","apple-pay-button-black"),i.setAttribute("tabindex","0"),i.setAttribute("role","button"),e.getElement().appendChild(i)}},{key:"onApplePayButtonClicked",value:function(){this.paymentSession=new ApplePaySession(3,this.createRequest()),this.paymentSession.onvalidatemerchant=this.onValidateMerchant,this.paymentSession.onpaymentauthorized=this.onPaymentAuthorized,this.paymentSession.oncancel=this.onCancelPayment,this.paymentSession.onshippingcontactselected=this.onShippingContactSelected,this.paymentSession.onshippingmethodselected=this.onShippingMethodSelected,this.paymentSession.begin()}},{key:"createRequest",value:function(){var e,t=this.getMetaRawDataInitialization();return t&&"object"===o(t)&&("object"===o(t.total)?t.total.amount=this.meta.amount.toString():t.total={label:(null===(e=this.meta)||void 0===e?void 0:e.amount_label)||"",amount:this.meta.amount.toString()},this.isShippingRequired()&&this.hasShippingOptions()&&(t.shippingMethods=this.formatShippingOptions(this.meta.shipping_options))),t||u(u(u({countryCode:this.meta.country.toUpperCase(),currencyCode:this.meta.currency.toUpperCase(),merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard","amex","discover"]},this.meta.show_billing_address&&{requiredBillingContactFields:["name","postalAddress"]}),this.isShippingRequired()&&u({requiredShippingContactFields:["postalAddress","name","phone","email"]},this.hasShippingOptions()&&{shippingMethods:this.formatShippingOptions(this.meta.shipping_options)})),{total:{label:this.meta.amount_label,amount:this.meta.amount.toString(),type:"final"}})}},{key:"getMerchantSession",value:function(){var e=this;return new Promise((function(t,n){return e.eventEmitter.emit(_r.CALLBACK,{data:u({request_type:"CREATE_SESSION",wallet_type:ki.APPLE,session_id:window.location.hostname},e.isShippingRequired()&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e)},onError:function(e){return n(e)}})}))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"createButtonStyle",value:function(){var e,t;return"\n .paydock-apple-container {\n width: 100%;\n height: 40px;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: ".concat((null===(e=this.getMetaStyles())||void 0===e?void 0:e.button_type)||"plain","\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: ").concat((null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"plain","\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ")}}])}(Cr),Br=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i])).gatewayName=r,a.eventEmitter=o,a.processingButtonClick=!1,a.parseUpdateData=function(e){var t,n,i,r,o,s,c=null===(n=null===(t=a.meta)||void 0===t?void 0:t.shipping_options)||void 0===n?void 0:n.find((function(t){var n;return t.id===(null===(n=null==e?void 0:e.shippingOptionData)||void 0===n?void 0:n.id)}));return u({shipping:{address_city:null===(i=e.shippingAddress)||void 0===i?void 0:i.locality,address_state:null===(r=e.shippingAddress)||void 0===r?void 0:r.administrativeArea,address_postcode:null===(o=null==e?void 0:e.shippingAddress)||void 0===o?void 0:o.postalCode,address_country:null===(s=null==e?void 0:e.shippingAddress)||void 0===s?void 0:s.countryCode}},c&&{selected_shipping_option:{id:null==c?void 0:c.id,label:null==c?void 0:c.label,detail:null==c?void 0:c.detail,type:null==c?void 0:c.type}})},a.formatShippingOptions=function(e){return e.map((function(e){return{id:e.id,label:e.label,description:(null==e?void 0:e.detail)||""}}))},a.eventEmitter=o,a}return d(n,e),c(n,[{key:"getGatewayName",value:function(){return this.gatewayName}},{key:"getMerchantId",value:function(){var e,t,n;return null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t[ki.GOOGLE])||void 0===n?void 0:n.merchant}},{key:"getMetaStyles",value:function(){var e,t,n,i;return"object"===o(null===(e=this.meta)||void 0===e?void 0:e.style)&&"google"in(null===(t=this.meta)||void 0===t?void 0:t.style)?null===(i=null===(n=this.meta)||void 0===n?void 0:n.style)||void 0===i?void 0:i.google:null}},{key:"getMetaRawDataInitialization",value:function(){var e,t,n,i,r;return(null===(e=this.meta)||void 0===e?void 0:e.raw_data_initialization)&&"object"===o(null===(t=this.meta)||void 0===t?void 0:t.raw_data_initialization)&&"google"in(null===(n=this.meta)||void 0===n?void 0:n.raw_data_initialization)?null===(r=null===(i=this.meta)||void 0===i?void 0:i.raw_data_initialization)||void 0===r?void 0:r.google:null}},{key:"isShippingRequired",value:function(){return!!this.meta.request_shipping}},{key:"hasShippingOptions",value:function(){return this.meta.request_shipping&&!!this.meta.shipping_options}},{key:"load",value:function(e){var t=this;if(window.Promise)return new Promise((function(n,i){var r=document.createElement("script");r.type="text/javascript",r.src="https://pay.google.com/gp/p/js/pay.js",r.async=!0,r.onload=function(){var r,o,s,a;if(!window.google)return t.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.GOOGLE}),void i();t.isShippingRequired()&&t.hasShippingOptions()&&(t.selectedShippingOption=null===(r=t.meta)||void 0===r?void 0:r.shipping_options[0]),t.paymentsClient=new google.payments.api.PaymentsClient(u({merchantInfo:u(u({},(null===(o=t.meta)||void 0===o?void 0:o.merchant_name)?{merchantName:null===(s=t.meta)||void 0===s?void 0:s.merchant_name}:{}),{merchantId:t.getMerchantId()}),paymentDataCallbacks:u({onPaymentAuthorized:function(e){return t.onPaymentAuthorized(e)}},t.isShippingRequired()&&{onPaymentDataChanged:function(e){return t.onPaymentDataChanged(e)}})},"live"===(null===(a=t.meta)||void 0===a?void 0:a.gateway_mode)?{environment:"PRODUCTION"}:{environment:"TEST"})),t.checkAvailability().then((function(r){if(!r)return t.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.GOOGLE}),void i();t.mount(e),n()}))},document.head.appendChild(r)}));this.eventEmitter.emit(_r.UNAVAILABLE,{wallet:ki.GOOGLE})}},{key:"update",value:function(e){var t,n,i,r;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject){if(!e.success)return this.latestShippingChangePromiseReject();var o=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.amount)||this.meta.amount,s=null===(n=null==e?void 0:e.body)||void 0===n?void 0:n.shipping_options;o&&(this.meta.amount=o),s&&(this.meta.shipping_options=s,this.selectedShippingOption=s?s[0]:void 0);var a=u({newTransactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:null===(i=this.meta.amount)||void 0===i?void 0:i.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()}},this.isShippingRequired()&&this.hasShippingOptions()&&s&&{newShippingOptionParameters:{defaultSelectedOptionId:null===(r=this.selectedShippingOption)||void 0===r?void 0:r.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}});this.latestShippingChangePromiseResolve(a)}}},{key:"checkAvailability",value:function(){return te(this,void 0,void 0,i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paymentsClient.isReadyToPay(this.createRequest()).then((function(e){return!!e.result})).catch((function(e){return console.error("Error checking GooglePay availability",e),!1})));case 1:case"end":return e.stop()}}),e,this)})))}},{key:"mount",value:function(e){var t,n,i,r=this;e.getElement().appendChild(this.paymentsClient.createButton({onClick:function(){return r.onGooglePayButtonClicked()},buttonType:(null===(t=this.getMetaStyles())||void 0===t?void 0:t.button_type)||"pay",buttonSizeMode:(null===(n=this.getMetaStyles())||void 0===n?void 0:n.button_size_mode)||"fill",buttonColor:(null===(i=this.getMetaStyles())||void 0===i?void 0:i.button_color)||"default"}))}},{key:"onGooglePayButtonClicked",value:function(){var e=this;this.processingButtonClick||(this.processingButtonClick=!0,this.handleMerchantOnButtonClickEvent().then((function(){e.loadPaymentData().finally((function(){e.processingButtonClick=!1}))})).catch((function(t){e.processingButtonClick=!1,console.error("Error while processing merchant callback",t)})))}},{key:"handleMerchantOnButtonClickEvent",value:function(){var e=this;return new Promise((function(t,n){var i;e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e}}),i instanceof Promise?i.then(t).catch(n):!1===i?n():t()}))}},{key:"loadPaymentData",value:function(){return te(this,void 0,void 0,i().mark((function e(){var t=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.paymentsClient.loadPaymentData(this.createPaymentDataRequest()).catch((function(e){throw t.eventEmitter.emit(_r.CHECKOUT_CLOSE),console.error("Error while loading payment data",e),e})));case 1:case"end":return e.stop()}}),e,this)})))}},{key:"onPaymentAuthorized",value:function(e){var t,n,i,r,o,s,a,c,l,d,h,p,f,m,v,g=this,y=null===(i=null===(n=null===(t=e.paymentMethodData)||void 0===t?void 0:t.info)||void 0===n?void 0:n.billingAddress)||void 0===i?void 0:i.address1,b=null===(s=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.address2,E=null===(a=null==e?void 0:e.shippingAddress)||void 0===a?void 0:a.address1,w=null===(c=null==e?void 0:e.shippingAddress)||void 0===c?void 0:c.address2,k=null===(l=this.selectedShippingOption)||void 0===l?void 0:l.type,S=null===(d=null==e?void 0:e.shippingAddress)||void 0===d?void 0:d.countryCode,T=null===(h=null==e?void 0:e.shippingAddress)||void 0===h?void 0:h.locality,_=null===(p=null==e?void 0:e.shippingAddress)||void 0===p?void 0:p.postalCode,C=null===(f=null==e?void 0:e.shippingAddress)||void 0===f?void 0:f.administrativeArea,O=null===(m=null==e?void 0:e.shippingAddress)||void 0===m?void 0:m.name,N=null==e?void 0:e.email,I=null===(v=null==e?void 0:e.shippingAddress)||void 0===v?void 0:v.phoneNumber;return new Promise((function(t){var n,i,r,o,s,a,c,l,d,h,p,f,m,v;return g.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:u({customer:{payment_source:u(u(u(u({wallet_type:ki.GOOGLE,type:e.paymentMethodData.type,card_scheme:null===(i=null===(n=e.paymentMethodData)||void 0===n?void 0:n.info)||void 0===i?void 0:i.cardNetwork},y&&{address_line1:y}),b&&{address_line2:b}),b&&{address_line2:b}),{address_country:null===(s=null===(o=null===(r=e.paymentMethodData)||void 0===r?void 0:r.info)||void 0===o?void 0:o.billingAddress)||void 0===s?void 0:s.countryCode,address_city:null===(l=null===(c=null===(a=e.paymentMethodData)||void 0===a?void 0:a.info)||void 0===c?void 0:c.billingAddress)||void 0===l?void 0:l.locality,address_postcode:null===(p=null===(h=null===(d=e.paymentMethodData)||void 0===d?void 0:d.info)||void 0===h?void 0:h.billingAddress)||void 0===p?void 0:p.postalCode,address_state:null===(v=null===(m=null===(f=e.paymentMethodData)||void 0===f?void 0:f.info)||void 0===m?void 0:m.billingAddress)||void 0===v?void 0:v.administrativeArea,ref_token:e.paymentMethodData.tokenizationData.token})}},g.isShippingRequired()&&{shipping:u(u(u(u(u(u(u(u(u({},k&&{method:k}),g.hasShippingOptions()&&{options:g.meta.shipping_options}),E&&{address_line1:E}),w&&{address_line2:w}),S&&{address_country:S}),T&&{address_city:T}),_&&{address_postcode:_}),C&&{address_state:C}),{contact:u(u(u({},O&&{first_name:O}),N&&{email:N}),I&&{phone:I})})}),onSuccess:function(){return t({transactionState:"SUCCESS"})},onError:function(e){return t({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:(null==e?void 0:e.message)||"Error processing payment",reason:"PAYMENT_DATA_INVALID"}})}})}))}},{key:"onPaymentDataChanged",value:function(e){var t=this;if(this.isShippingRequired()){var n=this.parseUpdateData(e),i=new Promise((function(e,n){t.latestShippingChangePromiseResolve=e,t.latestShippingChangePromiseReject=n}));return this.eventEmitter.emit(_r.UPDATE,n),i}}},{key:"createRequest",value:function(){var e="Apple Safari"===E.getBrowserName();return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[this.createCardData()],existingPaymentMethodRequired:!e}}},{key:"createPaymentDataRequest",value:function(){var e,t,n,i;this.isShippingRequired()&&this.hasShippingOptions()&&(this.selectedShippingOption=null===(e=this.meta)||void 0===e?void 0:e.shipping_options[0]);var r=this.getMerchantId();return u({apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[u(u({},this.createCardData()),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"paydock",gatewayMerchantId:r}}})],transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:this.meta.amount_label,totalPrice:this.meta.amount.toString(),currencyCode:this.meta.currency.toUpperCase(),countryCode:this.meta.country.toUpperCase()},merchantInfo:u(u({},(null===(t=this.meta)||void 0===t?void 0:t.merchant_name)?{merchantName:null===(n=this.meta)||void 0===n?void 0:n.merchant_name}:{}),{merchantId:r}),callbackIntents:["PAYMENT_AUTHORIZATION"].concat(v(this.isShippingRequired()?["SHIPPING_ADDRESS"]:[]),v(this.hasShippingOptions()?["SHIPPING_OPTION"]:[]))},this.isShippingRequired()&&u({shippingAddressRequired:!0},this.hasShippingOptions()&&{shippingOptionRequired:!0,shippingOptionParameters:{defaultSelectedOptionId:null===(i=this.selectedShippingOption)||void 0===i?void 0:i.id,shippingOptions:this.formatShippingOptions(this.meta.shipping_options)}}))}},{key:"createCardData",value:function(){return this.getMetaRawDataInitialization()||{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!!this.meta.show_billing_address}}}}])}(Cr),Hr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"initializeChildWallets",value:function(){var e,t,n,i,r,o;this.childWallets=[];var s=!!(null===(n=null===(t=null===(e=this.meta)||void 0===e?void 0:e.credentials)||void 0===t?void 0:t.apple)||void 0===n?void 0:n.merchant),a=!!(null===(o=null===(r=null===(i=this.meta)||void 0===i?void 0:i.credentials)||void 0===r?void 0:r.google)||void 0===o?void 0:o.merchant);!s||this.meta.wallets&&!this.meta.wallets.includes(ki.APPLE)||this.childWallets.push(new jr(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter)),!a||this.meta.wallets&&!this.meta.wallets.includes(ki.GOOGLE)||this.childWallets.push(new Br(this.publicKey,this.meta,this.getGatewayName(),this.eventEmitter))}},{key:"getGatewayName",value:function(){return wi.MASTERCARD}},{key:"setEnv",value:function(e){return this.childWallets.forEach((function(t){return t.setEnv(e)})),this}},{key:"update",value:function(e){this.childWallets.forEach((function(t){return t.update(e)}))}}])}(Cr),zr=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"load",value:function(e){return window.Promise?(!0===this.meta.standalone?this.renderPaypalStandaloneComponent(e):this.renderPaypalCommonComponent(e),Promise.resolve()):(this.eventEmitter.emit(_r.UNAVAILABLE,null),Promise.resolve())}},{key:"update",value:function(e){var t=this;if(this.latestShippingChangePromiseResolve&&this.latestShippingChangePromiseReject)return e.success?void this.eventEmitter.emit(_r.CALLBACK,{data:{request_type:"UPDATE_TRANSACTION",shipping:this.latestShippingData},onSuccess:function(e){return t.latestShippingChangePromiseResolve(!0)},onError:function(){return t.latestShippingChangePromiseReject()}}):this.latestShippingChangePromiseReject()}},{key:"renderPaypalCommonComponent",value:function(e){var t,n=this,i=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",r=document.createElement("script");r.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency).concat(!0===this.meta.pay_later?"&enable-funding=paylater&disable-funding=card":"&disable-funding=credit,card").concat(this.meta.capture?"":"&intent=authorize"),r.async=!0,r.onload=function(){window.paypal?(n.paypal=window.paypal,n.paypal.Buttons(u({},n.paypalSharedProps())).render("#".concat(i))):n.eventEmitter.emit(_r.UNAVAILABLE,null)},document.head.appendChild(r)}},{key:"renderPaypalStandaloneComponent",value:function(e){var t,n,i=this,r=(null===(t=e.getElement())||void 0===t?void 0:t.id)||"",o=document.createElement("script");o.src="https://www.paypal.com/sdk/js?client-id=".concat(this.publicKey,"¤cy=").concat(this.meta.currency,"&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(this.meta.capture?"":"&intent=authorize").concat("live"===(null===(n=this.meta)||void 0===n?void 0:n.gateway_mode)?"":"&buyer-country=AU"),o.async=!0,o.onload=function(){if(window.paypal){i.paypal=window.paypal;var e=!!i.meta.pay_later,t=i.paypal.Buttons(u({fundingSource:e?i.paypal.FUNDING.PAYLATER:i.paypal.FUNDING.PAYPAL},i.paypalSharedProps()));if(t.isEligible()){if(t.render("#".concat(r)),e)i.paypal.Messages(u({amount:i.meta.amount,currency:i.meta.currency,placement:"payment"},i.meta.style&&i.meta.style.messages&&{style:i.meta.style.messages})).render("#".concat(r))}else i.eventEmitter.emit(_r.UNAVAILABLE,null)}else i.eventEmitter.emit(_r.UNAVAILABLE,null)},document.head.appendChild(o)}},{key:"paypalSharedProps",value:function(){var e=this;return u(u({},this.meta.style&&{style:this.meta.style}),{onClick:function(t,n){var i;return e.eventEmitter.emit(_r.BUTTON_CLICK,{attachResult:function(e){i=e&&e instanceof Promise?e.then((function(){return n.resolve()})).catch((function(){return n.reject()})):e}}),i},createOrder:function(){return new Promise((function(t,n){e.eventEmitter.emit(_r.CALLBACK,{data:u({request_type:"CREATE_TRANSACTION"},e.meta.request_shipping&&{request_shipping:e.meta.request_shipping}),onSuccess:function(e){return t(e.id)},onError:function(e){return n(e)}})}))},onShippingChange:function(t,n){return new Promise((function(n,i){var r=e.parseUpdateData(t);e.latestShippingData=r.shipping,e.latestShippingChangePromiseResolve=n,e.latestShippingChangePromiseReject=i,e.eventEmitter.emit(_r.UPDATE,r)}))},onApprove:function(t){return e.pendingApprovalPromise=e.pendingApprovalPromise||new Promise((function(n,i){return e.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:{payment_method_id:t.orderID,customer:{payment_source:{external_payer_id:t.payerID}}},onSuccess:function(){e.pendingApprovalPromise=void 0,n(!0)},onError:function(t){e.pendingApprovalPromise=void 0,i(t)}})})),e.pendingApprovalPromise},onCancel:function(){return e.eventEmitter.emit(_r.CHECKOUT_CLOSE)},onError:function(e){}})}},{key:"parseUpdateData",value:function(e){var t;return u(u({wallet_order_id:e.orderID,wallet_session_id:e.paymentID,payment_source:{wallet_payment_method_id:e.paymentToken}},e.shipping_address&&{shipping:{address_city:e.shipping_address.city,address_state:e.shipping_address.state,address_postcode:e.shipping_address.postal_code,address_country:e.shipping_address.country_code}}),e.selected_shipping_option&&{selected_shipping_option:{id:e.selected_shipping_option.id,label:e.selected_shipping_option.label,amount:e.selected_shipping_option.amount.value,currency:e.selected_shipping_option.amount.currency_code,type:null===(t=e.selected_shipping_option)||void 0===t?void 0:t.type}})}}])}(Cr),Vr={};function Wr(e){return Wr="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},Wr(e)}Object.defineProperty(Vr,"__esModule",{value:!0});var qr,Gr="https://js.stripe.com/v3",Kr=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Yr="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",$r=null,Jr=function(e){return null!==$r||($r=new Promise((function(t,n){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Yr),window.Stripe)t(window.Stripe);else try{var i=function(){for(var e=document.querySelectorAll('script[src^="'.concat(Gr,'"]')),t=0;t<e.length;t++){var n=e[t];if(Kr.test(n.src))return n}return null}();i&&e?console.warn(Yr):i||(i=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(Gr).concat(t);var i=document.head||document.body;if(!i)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return i.appendChild(n),n}(e)),i.addEventListener("load",(function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))})),i.addEventListener("error",(function(){n(new Error("Failed to load Stripe.js"))}))}catch(e){return void n(e)}else t(null)}))),$r},Xr=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==Wr(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},Zr=!1,Qr=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Zr=!0;var i=Date.now();return Jr(qr).then((function(e){return function(e,t,n){if(null===e)return null;var i=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.54.2",startTime:t})}(i,n),i}(e,t,i)}))};Qr.setLoadParameters=function(e){if(Zr&&qr){var t=Xr(e);if(Object.keys(t).reduce((function(t,n){var i;return t&&e[n]===(null===(i=qr)||void 0===i?void 0:i[n])}),!0))return}if(Zr)throw new Error("You cannot change load parameters after calling loadStripe");qr=Xr(e)},Vr.loadStripe=Qr;var eo,to=Vr,no="success",io="fail",ro=function(e){function n(){return s(this,n),t(this,n,arguments)}return d(n,e),c(n,[{key:"initPaymentRequest",value:function(){return this.stripe.paymentRequest({country:this.meta.country.toUpperCase(),currency:this.meta.currency.toLowerCase(),total:{label:this.meta.amount_label,amount:Math.floor(100*this.meta.amount)},requestPayerName:!0===this.meta.request_payer_name,requestPayerEmail:!0===this.meta.request_payer_email,requestPayerPhone:!0===this.meta.request_payer_phone})}},{key:"createWalletButton",value:function(){return this.stripe.elements().create("paymentRequestButton",{paymentRequest:this.paymentRequest})}},{key:"load",value:function(e){var t=this;return to.loadStripe(this.publicKey).then((function(e){t.stripe=e,t.paymentRequest=t.initPaymentRequest()})).then((function(){return t.checkAvailability()})).then((function(n){return t.mount(e,n)})).then((function(){return t.setOnPaymentMethodSelected()}))}},{key:"checkAvailability",value:function(){var e=this;return this.paymentRequest.canMakePayment().then((function(t){if(t){var n=!e.meta.wallets||e.meta.wallets.includes(ki.GOOGLE),i=!e.meta.wallets||e.meta.wallets.includes(ki.APPLE);return{google_pay:n&&!t.applePay,apple_pay:i&&t.applePay,flypay:!1}}}))}},{key:"mount",value:function(e,t){if(!t||!t.apple_pay&&!t.google_pay)return this.eventEmitter.emit(_r.UNAVAILABLE,null);this.createWalletButton().mount(e.getElement())}},{key:"setOnPaymentMethodSelected",value:function(){var e=this;this.paymentRequest.on("paymentmethod",(function(t){var n,i,r=t.paymentMethod,o=r.id,s=r.card,a=r.billing_details,c=a.name,l=a.address,u={payment_method_id:o,customer:{payer_name:t.payerName,payer_email:t.payerEmail,payer_phone:t.payerPhone,payment_source:{wallet_type:e.getWalletType(null===(n=null==s?void 0:s.wallet)||void 0===n?void 0:n.type),card_name:c,type:null===(i=null==s?void 0:s.wallet)||void 0===i?void 0:i.type,card_scheme:null==s?void 0:s.brand,card_number_last4:null==s?void 0:s.last4,expire_month:null==s?void 0:s.exp_month,expire_year:null==s?void 0:s.exp_year,address_line1:l.line1,address_line2:l.line2,address_city:l.city,address_postcode:l.postal_code,address_state:l.state,address_country:l.country}}};e.eventEmitter.emit(_r.PAYMENT_METHOD_SELECTED,{data:u,onSuccess:function(){return t.complete(no)},onError:function(e){return t.complete(io)}})}))}},{key:"getWalletType",value:function(e){return e?"google_pay"===e?ki.GOOGLE:ki.APPLE:null}}])}(Cr),oo="unavailable",so="update",ao="paymentSuccessful",co="paymentError",lo="paymentInReview",uo="authTokensChanged",ho="onClick",po="onCheckoutOpen",fo="onCheckoutClose",mo=function(){return c((function e(t,n,i){s(this,e),this.hasUpdateHandler=!1;var r=Q.validateJWT(n);if(!r)throw new Error("Invalid charge token");this.eventEmitter=new vi,this.container=new Jn(t);var o=Q.extractMeta(r.body);switch(this.api=new pi(n,Dn.TOKEN),o.gateway.type){case wi.STRIPE:this.service=new ro(o.credentials.client_auth,u(u({},i),{amount:o.charge.amount,currency:o.charge.currency}));break;case wi.FLYPAY:this.service=new Ur(n,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,reference:o.charge.reference}));break;case wi.FLYPAY_V2:this.service=new Pr(n,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,reference:o.charge.reference}));break;case wi.PAYPAL:this.service=new zr(o.credentials.client_auth,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,capture:o.charge.capture}));break;case wi.MASTERCARD:this.service=new Hr("",u(u({},i),{credentials:o.gateway.credentials,amount:o.charge.amount,currency:o.charge.currency,gateway_mode:o.gateway.mode}));break;case wi.AFTERPAY:this.service=new Or(n,u(u({},i),{id:o.charge.id,gateway_mode:o.gateway.mode,amount:o.charge.amount,currency:o.charge.currency,reference:o.charge.reference}))}}),[{key:"load",value:function(){try{this.setupServiceCallbacks(),this.service.load(this.container)}catch(e){throw this.eventEmitter.emit(oo,null),e}}},{key:"update",value:function(e){this.service.update(e)}},{key:"setEnv",value:function(e,t){this.api.setEnv(e,t),this.service.setEnv(e)}},{key:"enable",value:function(){this.service.enable()}},{key:"disable",value:function(){this.service.disable()}},{key:"close",value:function(){"function"==typeof this.service.close&&this.service.close()}},{key:"on",value:function(e,t){var n=this;return e===so&&(this.hasUpdateHandler=!0),"function"==typeof t?this.eventEmitter.subscribe(e,t):new Promise((function(t){return n.eventEmitter.subscribe(e,(function(e){return t(e)}))}))}},{key:"onUnavailable",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(oo,e):new Promise((function(e){return t.eventEmitter.subscribe(oo,(function(){return e()}))}))}},{key:"onUpdate",value:function(e){var t=this;return this.hasUpdateHandler=!0,"function"==typeof e?this.eventEmitter.subscribe(so,e):new Promise((function(e){return t.eventEmitter.subscribe(so,(function(t){return e(t)}))}))}},{key:"onPaymentSuccessful",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(ao,e):new Promise((function(e){return t.eventEmitter.subscribe(ao,(function(t){return e(t)}))}))}},{key:"onPaymentInReview",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(lo,e):new Promise((function(e){return t.eventEmitter.subscribe(lo,(function(t){return e(t)}))}))}},{key:"onPaymentError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(co,e):new Promise((function(e){return t.eventEmitter.subscribe(co,(function(t){return e(t)}))}))}},{key:"onAuthTokensChanged",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(uo,e):new Promise((function(e){return t.eventEmitter.subscribe(uo,(function(t){return e(t)}))}))}},{key:"onClick",value:function(e){if("function"==typeof e)return this.eventEmitter.subscribe(ho,e)}},{key:"onCheckoutOpen",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(po,e):new Promise((function(e){return t.eventEmitter.subscribe(po,(function(t){return e(t)}))}))}},{key:"onCheckoutClose",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(fo,e):new Promise((function(e){return t.eventEmitter.subscribe(fo,(function(t){return e(t)}))}))}},{key:"setupServiceCallbacks",value:function(){this.setupUnavailableCallback(),this.setupUpdateCallback(),this.setupWalletCallback(),this.setupPaymentCallback(),this.setupPaymentSuccessCallback(),this.setupPaymentInReviewCallback(),this.setupPaymentErrorCallback(),this.setupAuthTokensChangedCallback(),this.setupOnClickCallback(),this.setupOnCheckoutOpenCallback(),this.setupOnCheckoutCloseCallback()}},{key:"setupUnavailableCallback",value:function(){var e=this;this.service.on(_r.UNAVAILABLE,(function(t){return e.eventEmitter.emit(oo,{event:oo,data:t})}))}},{key:"setupUpdateCallback",value:function(){var e=this;this.service.on(_r.UPDATE,(function(t){return e.hasUpdateHandler?e.eventEmitter.emit(so,{event:so,data:t}):e.update({success:!0})}))}},{key:"setupOnClickCallback",value:function(){var e=this;this.service.on(_r.BUTTON_CLICK,(function(t){return e.eventEmitter.emit(ho,{event:ho,data:t})}))}},{key:"setupOnCheckoutOpenCallback",value:function(){var e=this;this.service.on(_r.CHECKOUT_OPEN,(function(t){return e.eventEmitter.emit(po,{event:po,data:t})}))}},{key:"setupOnCheckoutCloseCallback",value:function(){var e=this;this.service.on(_r.CHECKOUT_CLOSE,(function(t){return e.eventEmitter.emit(fo,{event:fo,data:t})}))}},{key:"setupWalletCallback",value:function(){var e=this;this.service.on(_r.CALLBACK,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCallback(n).then((function(e){return i(e)}),(function(e){return r(e.message)}))}))}},{key:"setupPaymentCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_METHOD_SELECTED,(function(t){var n=t.data,i=t.onSuccess,r=t.onError;e.api.charge().walletCapture(n).then((function(t){"function"==typeof i&&i();var r="inreview"===t.status?lo:ao;e.eventEmitter.emit(r,{event:r,data:u(u({},t),n.customer&&{payer_name:n.customer.payer_name,payer_email:n.customer.payer_email,payer_phone:n.customer.payer_phone})})}),(function(t){"function"==typeof r&&r(t),e.eventEmitter.emit(co,{event:co,data:t})}))}))}},{key:"setupPaymentSuccessCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_SUCCESS,(function(t){return e.eventEmitter.emit(ao,{event:ao,data:t})}))}},{key:"setupPaymentInReviewCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_IN_REVIEW,(function(t){return e.eventEmitter.emit(lo,{event:lo,data:t})}))}},{key:"setupPaymentErrorCallback",value:function(){var e=this;this.service.on(_r.PAYMENT_ERROR,(function(t){return e.eventEmitter.emit(co,{event:co,data:t})}))}},{key:"setupAuthTokensChangedCallback",value:function(){var e=this;this.service.on(_r.AUTH_TOKENS_CHANGED,(function(t){return e.eventEmitter.emit(uo,{event:uo,data:t})}))}}])}(),vo={CARD:"card",GIFT_CARD:"gift_card",BANK_ACCOUNT:"bank_account",CHECKOUT:"checkout"},go={PAYMENT_SOURCE:"payment_source",CARD_PAYMENT_SOURCE_WITH_CVV:"card_payment_source_with_cvv",CARD_PAYMENT_SOURCE_WITHOUT_CVV:"card_payment_source_without_cvv"},yo=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vo.CARD,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:go.PAYMENT_SOURCE;if(s(this,e),-1===pr.values(vo).indexOf(n))throw new Error("unsupported payment type");if(n===vo.CHECKOUT)throw new Error('Payment type "checkout" is deprecated. Use CheckoutButton for this type of payments https://www.npmjs.com/package/@paydock/client-sdk#checkout-button');if(-1===pr.values(go).indexOf(i))throw new Error("unsupported purpose");this.env=new $(W),this.configs={purpose:i,meta:{},dynamic_fields_position:!0,predefined_fields:{gateway_id:t,type:n,card_scheme:null,card_processing_network:null}}}return c(e,[{key:"setWebHookDestination",value:function(e){this.configs.webhook_destination=e}},{key:"setSuccessRedirectUrl",value:function(e){this.configs.success_redirect_url=e}},{key:"setErrorRedirectUrl",value:function(e){this.configs.error_redirect_url=e}},{key:"setFormFields",value:function(e){for(var t in Array.isArray(this.configs.defined_form_fields)||(this.configs.defined_form_fields=[]),e)e.hasOwnProperty(t)&&(-1!==pr.values(_i).indexOf(e[t].replace("*",""))?this.configs.defined_form_fields.push(e[t]):console.warn("Configuration::setFormFields: unsupported form field ".concat(e[t])))}},{key:"setMeta",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(-1!==Ai.indexOf(t)?this.configs.meta[t]=e[t]:console.warn("Configuration::setMeta: unsupported meta key ".concat(t)))}},{key:"setEnv",value:function(e,t){this.env.setEnv(e,t)}},{key:"setLabel",value:function(e){this.configs.label=e}},{key:"getEnv",value:function(){return this.env.getEnv()}},{key:"createToken",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};this.send(e,(function(e,i){if(i>=200&&i<300)return t(e.resource.data.configuration_token);void 0===e.error||void 0===e.error.message?n("unknown error"):n(e.error.message)}))}},{key:"send",value:function(e,t){var n=ee.create("POST",this.getUrl()).setHeader(Q.getAccessHeaderNameByToken(e),e).setContentTypeJson().setSdkVersion().inner();n.onload=function(){var e={};try{e=JSON.parse(n.responseText)}catch(e){}t(e,n.status)},n.send(JSON.stringify(this.getConfigs()))}},{key:"getConfigs",value:function(){return this.configs}},{key:"getUrl",value:function(){return this.env.getConf().url+"/v1/remote-action/configs"}},{key:"setGiftCardSchemeData",value:function(e,t){if(this.configs.predefined_fields.type!==vo.GIFT_CARD)throw new Error("unsupported payment type");if(!e||!t)throw new Error("");this.configs.predefined_fields.card_scheme=e,this.configs.predefined_fields.card_processing_network=t}}],[{key:"createEachToken",value:function(t,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){},o=new Array(n.length),s=[],a=0,c=function(c){n.hasOwnProperty(c)&&n[c].createToken(t,(function(t){o[c]=t,a++,n.length===a&&e.finishCreatingEachToken(o,s,i,r)}),(function(t){s.push("gateway: ".concat(n[c].getConfigs().predefined_fields.gateway_id," | ").concat(t)),a++,n.length===a&&e.finishCreatingEachToken(o,s,i,r)}))};for(var l in n)c(l)}},{key:"finishCreatingEachToken",value:function(e,t,n,i){t.length>=1?i(t):n(e)}}])}(),bo={INPUT:"input",SUBMIT_BUTTON:"submit_button",LABEL:"label",TITLE:"title",TITLE_DESCRIPTION:"title_description"},Eo={ERROR:"error",FOCUS:"focus",HOVER:"hover"},wo=[{element:bo.INPUT,states:[Eo.FOCUS,Eo.ERROR],styles:["color","border","border_radius","background_color","height","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition"]},{element:bo.SUBMIT_BUTTON,states:[Eo.HOVER],styles:["color","border","border_radius","background_color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","transition","opacity"]},{element:bo.LABEL,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin"]},{element:bo.TITLE,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]},{element:bo.TITLE_DESCRIPTION,states:[],styles:["color","text_decoration","font_size","font_family","line_height","font_weight","padding","margin","text_align"]}],ko=function(){return c((function e(){s(this,e)}),null,[{key:"check",value:function(e,t,n,i){for(var r in e)if(e.hasOwnProperty(r)&&e[r].element===t){if(-1===e[r].states.indexOf(n)&&n)return!1;for(var o in i)if(i.hasOwnProperty(o)&&-1===e[r].styles.indexOf(o.replace("-","_")))return!1;return!0}return!1}},{key:"encode",value:function(e,t,n){var i=[];for(var r in n)n.hasOwnProperty(r)&&i.push("".concat(r.replace("_","-"),":").concat(n[r]));var o=i.join(";");return t?"".concat(e,"::").concat(t,"{").concat(o,"}"):"".concat(e,"{").concat(o,"}")}},{key:"decode",value:function(e){var t=(e.match("::(.*){")||["",null])[1],n=null!==t?(e.match("(.*)::")||["",""])[1].trim():(e.match("(.*){")||["",""])[1].trim(),i=(e.match("{(.*)}")||["",""])[1].split(";"),r={};for(var o in i)if(i.hasOwnProperty(o)){var s=i[o].split(":");(s||2===s.length)&&(r[s[0].trim()]=(s[1]||"").trim())}return{element:n,state:t,styles:r}}}])}(),So=function(){return c((function e(t,n){if(s(this,e),this.configs=[],this.configTokens=[],this.link=new Yn("/remote-action"),J.version&&this.link.setParams({sdk_version:J.version,sdk_type:J.type}),Q.validateJWT(t)?this.link.setParams({token:t}):this.link.setParams({public_key:t}),this.accessToken=t,!n||Array.isArray(n)&&!n.length)throw Error("configuration token is required");if("string"==typeof n)this.configTokens.push(n);else if(n instanceof yo)this.configs.push(n);else if(Array.isArray(n)&&"string"==typeof n[0])this.configTokens=n;else{if(!(Array.isArray(n)&&n[0]instanceof yo))throw Error("Unsupported type of configuration token");this.configs=n}}),[{key:"setStyles",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setStyle(t,e[t])}},{key:"usePhoneCountryMask",value:function(e){return e?!e.only_countries||/^[a-z]+$/.test(e.only_countries.join(""))&&2*e.only_countries.length===e.only_countries.join("").length?!e.preferred_countries||/^[a-z]+$/.test(e.preferred_countries.join(""))&&2*e.preferred_countries.length===e.preferred_countries.join("").length?e.default_country&&2!==e.default_country.length?console.warn("Widget::usePhoneCountryMask[s: default_country - incorrect value length"):(this.link.setParams({use_country_phone_mask:!0}),e.only_countries&&this.link.setParams({phone_mask_only_countries:e.only_countries.join(",")}),e.preferred_countries&&this.link.setParams({phone_mask_preferred_countries:e.preferred_countries.join(",")}),void(e.default_country&&this.link.setParams({phone_mask_default_country:e.default_country}))):console.warn("Widget::usePhoneCountryMask[s: preferred_countries - unsupported symbols or incorrect length of value"):console.warn("Widget::usePhoneCountryMask[s: only_countries - unsupported symbols or incorrect length of value"):this.link.setParams({use_country_phone_mask:!0})}},{key:"setStyle",value:function(e,t){-1!==pr.values(Ci).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setStyle[s: unsupported style param ".concat(e))}},{key:"setTexts",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setText(t,e[t])}},{key:"setText",value:function(e,t){-1!==pr.values(Oi).indexOf(e)?this.link.setParams(l({},e,t)):console.warn("Widget::setText[s: unsupported text param ".concat(e))}},{key:"setElementStyle",value:function(e,t,n){var i=3===arguments.length?t:null,r=3===arguments.length?n:t;if(!ko.check(wo,e,i,r))return console.warn('Styles for "'.concat(e,'" element with "').concat(i||"default",'" state was ignored because some of the arguments are unacceptable'));this.link.concatParams({element_styles:ko.encode(e,i,r)})}},{key:"setFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormValue(t,e[t])}},{key:"setFormValue",value:function(e,t){return-1===pr.values(_i).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void("string"==typeof this.link.getParams().form_values&&this.link.getParams().form_values.length?this.link.setParams({form_values:"".concat(this.link.getParams().form_values,",").concat(e,":").concat(t)}):this.link.setParams({form_values:"".concat(e,":").concat(t)}))}},{key:"setFormLabels",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormLabel(t,e[t])}},{key:"setFormLabel",value:function(e,t){if(-1===pr.values(_i).indexOf(e))return console.warn("Widget::setFormLabel[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormLabel[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_labels:"".concat(e,":").concat(n)})}},{key:"setFormPlaceholders",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setFormPlaceholder(t,e[t])}},{key:"setFormPlaceholder",value:function(e,t){if(-1===pr.values(_i).indexOf(e))return console.warn("Widget::setFormPlaceholder[s: unsupported field ".concat(e));var n=null===t||""===t?" ":t;if(/\,/.test(n)||/\:/.test(n))return console.warn("Widget::setFormPlaceholder[s: ".concat(e," - unsupported symbols (: or ,) in value"));this.link.concatParams({form_placeholders:"".concat(e,":").concat(n)})}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){e.value&&this.setFormValue(e.field,e.value),e.label&&this.setFormLabel(e.field,e.label),e.placeholder&&this.setFormPlaceholder(e.field,e.placeholder)}},{key:"setIcons",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.setIcon(t,e[t])}},{key:"setIcon",value:function(e,t){if(/\,/.test(t)||/\:/.test(t))return console.warn("Widget::setIcon[s: ".concat(e," - unsupported symbols (: or ,) in value"));"string"==typeof this.link.getParams().icons&&this.link.getParams().icons.length?this.link.setParams({icons:"".concat(this.link.getParams().icons,",").concat(e,":").concat(t)}):this.link.setParams({icons:"".concat(e,":").concat(t)})}},{key:"setHiddenElements",value:function(e){var t=[],n=pr.values(Ni).concat(pr.values(_i));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::setHiddenElements: unsupported element ".concat(e[i])));t.length&&this.link.concatParams({hidden_elements:t.join(",")})}},{key:"setRefId",value:function(e){this.link.setParams({ref_id:e})}},{key:"useGatewayFieldValidation",value:function(){this.link.setParams({fields_validation:!0})}},{key:"setSupportedCardIcons",value:function(e,t){var n=[];for(var i in e)e.hasOwnProperty(i)&&(-1!==pr.values(Ii).indexOf(e[i])?n.push(e[i]):console.warn("Widget::cardTypes: unsupported type of cards ".concat(e[i])));n.length&&this.link.concatParams({supported_card_types:n.join(",")}),t&&this.link.setParams({validate_card_types:t})}},{key:"setEnv",value:function(e,t){for(var n in this.link.setEnv(e,t),this.configs)this.configs.hasOwnProperty(n)&&this.configs[n].setEnv(e,t)}},{key:"getEnv",value:function(){this.link.getEnv()}},{key:"loadIFrameUrl",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){};if(this.link.setParams({configuration_tokens:""}),this.configTokens.length)return this.link.setParams({configuration_tokens:this.configTokens.join(",")}),e(this.link.getUrl());yo.createEachToken(this.accessToken,this.configs,(function(n){return t.link.concatParams({configuration_tokens:n.join(",")}),e(t.link.getUrl())}),(function(e){n(e)}))}},{key:"setLanguage",value:function(e){this.link.setParams({language:e})}}])}(),To=function(){return c((function e(t){s(this,e),this.intercepted=!1,this.selector=t}),[{key:"getElement",value:function(){return document.querySelector(this.selector)}},{key:"isExist",value:function(){return!!this.getElement()}},{key:"beforeSubmit",value:function(e){var t=this;this.isExist()&&this.subscribe(this.getElement(),(function(n){n.preventDefault(),t.intercepted=!0,e.apply(t,[])}))}},{key:"continueSubmit",value:function(){var e=this;this.isExist()&&this.intercepted&&(this.intercepted=!1,setTimeout((function(){e.getElement().submit()}),50))}},{key:"subscribe",value:function(e,t){e.addEventListener?e.addEventListener("submit",t):e.attachEvent("onsubmit",t)}}])}(),_o=function(e){function n(e,i,r){var o;return s(this,n),(o=t(this,n,[i,r])).validationData={},o.container=new Jn(e),o.iFrame=new Xn(o.container),o.triggerElement=new kr(o.iFrame),o.event=new Qn(window),o}return d(n,e),c(n,[{key:"load",value:function(){var e=this;this.setStyles(this.container.getStyles(pr.values(Ci))),this.setTexts(this.container.getAttr(pr.values(Oi))),this.loadIFrameUrl((function(t){e.iFrame.load(t,{title:"Card details"}),e.afterLoad()}),(function(e){for(var t in console.error("Errors when creating a token[s, widget will not be load:"),e)e.hasOwnProperty(t)&&console.error("--- | ".concat(e[t]))}))}},{key:"afterLoad",value:function(){var e=this;this.on(Zn.VALIDATION,(function(t){e.validationData=t}))}},{key:"on",value:function(e,t){var n=this;return"function"==typeof t?this.event.on(e,this.link.getParams().widget_id,t):new Promise((function(t){return n.event.on(e,n.link.getParams().widget_id,(function(e){return t(e)}))}))}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.triggerElement.push(e,t)}},{key:"getValidationState",value:function(){return this.validationData}},{key:"isValidForm",value:function(){return!!this.validationData.form_valid}},{key:"isInvalidField",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_fields&&-1!==this.validationData.invalid_fields.indexOf(e)}},{key:"isFieldErrorShowed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!!this.validationData.invalid_showed_fields&&-1!==this.validationData.invalid_showed_fields.indexOf(e)}},{key:"isInvalidFieldByValidator",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=!1;if(!this.validationData.validators)return n;var i=this.validationData.validators[t];return i?-1!==i.indexOf(e):n}},{key:"hide",value:function(e){this.iFrame.hide(e)}},{key:"show",value:function(){this.iFrame.show()}},{key:"reload",value:function(){this.iFrame.remove(),this.load()}},{key:"hideElements",value:function(e){var t=[],n=pr.values(Ni).concat(pr.values(_i));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::hideElements: unsupported element ".concat(e[i])));t.length&&this.trigger(wr.HIDE_ELEMENTS,{elements:t.join(",")})}},{key:"showElements",value:function(e){var t=[],n=pr.values(Ni).concat(pr.values(_i));for(var i in e)e.hasOwnProperty(i)&&(-1!==n.indexOf(e[i])?t.push(e[i]):console.warn("Widget::showElements: unsupported element ".concat(e[i])));t.length&&this.trigger(wr.SHOW_ELEMENTS,{elements:t.join(",")})}},{key:"updateFormValues",value:function(e){for(var t in e)e.hasOwnProperty(t)&&this.updateFormValue(t,e[t])}},{key:"updateFormValue",value:function(e,t){return-1===pr.values(_i).indexOf(e)?console.warn("Widget::setFormValues[s: unsupported field ".concat(e)):/\,/.test(t)||/\:/.test(t)?console.warn("Widget::setFormValues[s: ".concat(e," - unsupported symbols (: or ,) in value")):void this.trigger(wr.UPDATE_FORM_VALUES,{form_values:"".concat(e,":").concat(t)})}},{key:"onFinishInsert",value:function(e,t){this.on(Zn.FINISH,(function(n){$n.insertToInput(e,t,n)}))}},{key:"interceptSubmitForm",value:function(e){var t=this;this.setHiddenElements([Ni.SUBMIT_BUTTON]);var n=new To(e);n.beforeSubmit((function(){t.triggerElement.push(wr.SUBMIT_FORM,{}),t.event.on(Zn.FINISH,t.link.getParams().widget_id,(function(){n.continueSubmit()}))}))}},{key:"useCheckoutAutoSubmit",value:function(){var e=this;this.setHiddenElements([Ni.SUBMIT_BUTTON]),this.on(Zn.CHECKOUT_SUCCESS,(function(t){e.trigger(wr.SUBMIT_FORM)})),this.on(Zn.VALIDATION_ERROR,(function(t){e.trigger(wr.REFRESH_CHECKOUT)})),this.on(Zn.SYSTEM_ERROR,(function(t){e.trigger(wr.REFRESH_CHECKOUT)}))}},{key:"useAutoResize",value:function(){var e=this;this.on(Zn.RESIZE,(function(t){e.iFrame.getElement()&&(e.iFrame.getElement().scrolling="no",t.height&&e.iFrame.setStyle("height",t.height+"px"))}))}}])}(So),Co=function(e){function n(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"default",o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;return s(this,n),t(this,n,[e,i,new yo(r,o,a)])}return d(n,e),c(n,[{key:"setWebHookDestination",value:function(e){this.configs[0].setWebHookDestination(e)}},{key:"setSuccessRedirectUrl",value:function(e){this.configs[0].setSuccessRedirectUrl(e)}},{key:"setErrorRedirectUrl",value:function(e){this.configs[0].setErrorRedirectUrl(e)}},{key:"setFormFields",value:function(e){this.configs[0].setFormFields(e)}},{key:"setFormElements",value:function(e){var t=this;e.forEach((function(e){return t.setFormElement(e)}))}},{key:"setFormElement",value:function(e){this.configs[0].setFormFields([e.field]),f(h(n.prototype),"setFormElement",this).call(this,u(u({},e),{field:e.field.replace("*","")}))}},{key:"setMeta",value:function(e){this.configs[0].setMeta(e)}},{key:"setGiftCardScheme",value:function(e,t){this.configs[0].setGiftCardSchemeData(e,t)}}])}(_o);!function(e){e.UNAVAILABLE="unavailable",e.ERROR="error",e.PAYMENT_SUCCESSFUL="paymentSuccessful",e.PAYMENT_ERROR="paymentError",e.PAYMENT_IN_REVIEW="paymentInReview",e.ON_CLICK="onClick",e.ON_CHECKOUT_CLOSE="onCheckoutClose"}(eo||(eo={}));var Oo=function(){return c((function e(t,n,i,r,o){s(this,e),this.env=G,this.eventEmitter=new vi,this.container=new Jn(t),this.api=new pi(n,this.getApiAuthType(n)),this.gatewayId=i,this.meta=r,this.validateRequiredMetaFields(o)}),[{key:"getApiAuthType",value:function(e){return Q.validateJWT(e)?Dn.TOKEN:Dn.PUBLIC_KEY}},{key:"setEnv",value:function(e,t){this.env=e,this.api.setEnv(e,t)}},{key:"onClick",value:function(e){if("function"==typeof e)return this.eventEmitter.subscribe(eo.ON_CLICK,e);this.handleOnError(new Error("onClick event handler is required to return the wallet token string."))}},{key:"onPaymentSuccessful",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.PAYMENT_SUCCESSFUL,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.PAYMENT_SUCCESSFUL,(function(t){return e(t)}))}))}},{key:"onPaymentInReview",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.PAYMENT_IN_REVIEW,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.PAYMENT_IN_REVIEW,(function(t){return e(t)}))}))}},{key:"onPaymentError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.PAYMENT_ERROR,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.PAYMENT_ERROR,(function(t){return e(t)}))}))}},{key:"onCheckoutClose",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.ON_CHECKOUT_CLOSE,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.ON_CHECKOUT_CLOSE,(function(t){return e(t)}))}))}},{key:"onUnavailable",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.UNAVAILABLE,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.UNAVAILABLE,(function(t){return e(t)}))}))}},{key:"onError",value:function(e){var t=this;return"function"==typeof e?this.eventEmitter.subscribe(eo.ERROR,e):new Promise((function(e){return t.eventEmitter.subscribe(eo.ERROR,(function(t){return e(t)}))}))}},{key:"getGatewayWalletConfig",value:function(){var e=this,t="gatewayConfig-".concat(this.gatewayId),n=localStorage.getItem(t);return new Promise((function(i,r){if(n){var o=JSON.parse(atob(n)),s=o.data,a=o.timestamp;if(Date.now()-a<864e5)return i(JSON.parse(s))}e.api.gateway().getWalletConfig(e.gatewayId).then((function(e){var n=btoa(JSON.stringify({data:JSON.stringify(e),timestamp:Date.now()}));return localStorage.setItem(t,n),i(e)})).catch(r)}))}},{key:"executeWalletCallback",value:function(e){var t=this;return this.api.charge().walletCallback(e).catch((function(e){var n;throw t.eventEmitter.emit(eo.PAYMENT_ERROR,{event:eo.PAYMENT_ERROR,chargeId:null===(n=t.chargeWalletTokenMeta)||void 0===n?void 0:n.charge.id,data:t.eventDataFromApiError(e)}),t.handleOnError(e),e}))}},{key:"executeWalletCapture",value:function(e){var t=this;return this.api.charge().walletCapture(e).then((function(e){var n,i="inreview"===e.status?eo.PAYMENT_IN_REVIEW:eo.PAYMENT_SUCCESSFUL;return t.eventEmitter.emit(i,{event:i,chargeId:null===(n=t.chargeWalletTokenMeta)||void 0===n?void 0:n.charge.id,data:e}),e})).catch((function(e){var n;throw t.eventEmitter.emit(eo.PAYMENT_ERROR,{event:eo.PAYMENT_ERROR,chargeId:null===(n=t.chargeWalletTokenMeta)||void 0===n?void 0:n.charge.id,data:t.eventDataFromApiError(e)}),e}))}},{key:"handleMerchantOnExpressButtonClickEvent",value:function(){var e=this;return this.eventEmitter.emitWithResult(eo.ON_CLICK,{event:eo.ON_CLICK}).then((function(t){if(!t||0===t.length){var n=new Error("No result from onClick event");throw e.handleOnError(n),n}var i=t[0];if(e.setWalletToken(i),e.chargeWalletTokenMeta.charge.amount!==e.meta.amount){var r=new Error("Wallet meta amount (".concat(e.chargeWalletTokenMeta.charge.amount,") and charge amount (").concat(e.meta.amount,') do not match. Consider using "setMeta" SDK method to update the amount.'));throw e.handleOnError(r),r}if(e.chargeWalletTokenMeta.charge.currency!==e.meta.currency){var o=new Error("Wallet meta currency (".concat(e.chargeWalletTokenMeta.charge.currency,") and charge currency (").concat(e.meta.currency,') do not match. Consider using "setMeta" SDK method to update the currency.'));throw e.handleOnError(o),o}}))}},{key:"setWalletToken",value:function(e){var t=Q.validateJWT(e);return t?(this.chargeWalletTokenMeta=Q.extractMeta(t.body),this.chargeWalletTokenMeta?(this.api.auth=e,void(this.api.authType=Dn.TOKEN)):this.handleOnError(new Error("Invalid charge token"))):this.handleOnError(new Error("Invalid charge token"))}},{key:"handleCheckoutClose",value:function(){var e,t=null===(e=this.chargeWalletTokenMeta)||void 0===e?void 0:e.charge.id;this.eventEmitter.emit(eo.ON_CHECKOUT_CLOSE,u({event:eo.ON_CHECKOUT_CLOSE},t&&{chargeId:t}))}},{key:"handleOnUnavailable",value:function(){this.eventEmitter.emit(eo.UNAVAILABLE,{event:eo.UNAVAILABLE})}},{key:"handleOnError",value:function(e){var t;e&&console.error(e);var n=null===(t=this.chargeWalletTokenMeta)||void 0===t?void 0:t.charge.id;this.eventEmitter.emit(eo.ERROR,u(u({event:eo.ERROR},n&&{chargeId:n}),{data:e}))}},{key:"eventDataFromApiError",value:function(e){var t,n,i,r;return{message:(null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.message)||(null==e?void 0:e.message)||(null===(n=null==e?void 0:e.error_summary)||void 0===n?void 0:n.message),code:(null===(i=null==e?void 0:e.error)||void 0===i?void 0:i.code)||(null==e?void 0:e.code)||(null===(r=null==e?void 0:e.error_summary)||void 0===r?void 0:r.code)}}},{key:"validateRequiredMetaFields",value:function(e){var t=this;if(!this.meta)throw new Error("Meta is required");if("number"!=typeof this.meta.amount)throw new Error("meta.amount needs to be numeric");if("string"!=typeof this.meta.currency)throw new Error("meta.amount needs to be a string");e.forEach((function(e){var n,i=e.split("."),r=t.meta,o=b(i);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(void 0===r[s]||null===r[s])throw new Error("Meta field ".concat(e," is required"));r=r[s]}}catch(e){o.e(e)}finally{o.f()}}))}}])}(),No=function(e){function n(e,i,r,o){var a;return s(this,n),(a=t(this,n,[e,i,r,o,["amount_label","country"]])).onValidateMerchant=function(e){a.handleMerchantOnExpressButtonClickEvent().then((function(){a.getMerchantSession().then((function(e){a.paymentSession.completeMerchantValidation(e)})).catch((function(){a.paymentSession.abort(),a.handleCheckoutClose()}))})).catch((function(){a.paymentSession.abort(),a.handleCheckoutClose()}))},a.onPaymentAuthorized=function(e){var t=e.payment,n=t.token,i=t.billingContact,r=t.shippingContact;a.executeWalletCapture({customer:{first_name:null==i?void 0:i.givenName,last_name:null==i?void 0:i.familyName,email:(null==i?void 0:i.emailAddress)||(null==r?void 0:r.emailAddress),phone:(null==i?void 0:i.phoneNumber)||(null==r?void 0:r.phoneNumber),payment_source:{wallet_type:ki.APPLE,address_line1:null==i?void 0:i.addressLines[0],address_line2:null==i?void 0:i.addressLines[1],address_country:null==i?void 0:i.countryCode,address_city:null==i?void 0:i.locality,address_postcode:null==i?void 0:i.postalCode,address_state:null==i?void 0:i.administrativeArea,ref_token:n.paymentData?JSON.stringify(n.paymentData):""}}}).then((function(){a.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS)})).catch((function(){a.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE)}))},a.onCancelPayment=function(){return a.handleCheckoutClose()},a}return d(n,e),c(n,[{key:"load",value:function(){var e=this;if(!window.Promise)return this.handleOnUnavailable();this.getGatewayWalletConfig().then((function(t){if(!(t&&"MasterCard"===t.type&&t.credentials&&t.credentials.apple&&t.credentials.apple.merchant))throw new Error("Invalid configuration");return e.checkAvailability(t)})).then((function(t){return t?e.mount():e.handleOnUnavailable()})).catch((function(t){t&&e.handleOnError(t),e.handleOnUnavailable()}))}},{key:"setMeta",value:function(e){this.meta=e}},{key:"checkAvailability",value:function(e){return new Promise((function(t,n){window.ApplePaySession&&ApplePaySession||t(!1),ApplePaySession.canMakePaymentsWithActiveCard(e.credentials[ki.APPLE].merchant).then((function(e){return t(e)})).catch((function(e){return t(!1)}))}))}},{key:"mount",value:function(){var e,t,n=this,i=document.createElement("style");i.innerHTML=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"plain";return"\n .paydock-apple-container {\n display: inline-block;\n width: 100%;\n height: 44px;\n cursor: pointer;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: ".concat(e,";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-outline {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: ").concat(e,";\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-outline {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ")}(null===(e=this.meta.style)||void 0===e?void 0:e.button_type),document.head.appendChild(i);var r=document.createElement("div");r.onclick=function(){return n.onApplePayButtonClicked()},r.classList.add("paydock-apple-container","apple-pay-button","apple-pay-button-".concat((null===(t=this.meta.style)||void 0===t?void 0:t.button_style)||"black")),r.setAttribute("tabindex","0"),r.setAttribute("role","button"),this.container.getElement().appendChild(r)}},{key:"onApplePayButtonClicked",value:function(){this.paymentSession=new ApplePaySession(3,this.createRequest()),this.paymentSession.onvalidatemerchant=this.onValidateMerchant,this.paymentSession.onpaymentauthorized=this.onPaymentAuthorized,this.paymentSession.oncancel=this.onCancelPayment,this.paymentSession.begin()}},{key:"createRequest",value:function(){var e;return{countryCode:this.meta.country,currencyCode:this.meta.currency,merchantCapabilities:this.meta.merchant_capabilities||["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:this.meta.supported_networks||["visa","masterCard","amex","discover"],requiredBillingContactFields:this.meta.required_billing_contact_fields||["email","name","phone","postalAddress"],requiredShippingContactFields:this.meta.required_shipping_contact_fields,supportedCountries:this.meta.supported_countries,total:{label:this.meta.amount_label,amount:null===(e=this.meta.amount)||void 0===e?void 0:e.toFixed(2),type:"final"}}}},{key:"getMerchantSession",value:function(){return this.executeWalletCallback({request_type:"CREATE_SESSION",wallet_type:ki.APPLE,session_id:window.location.hostname})}}])}(Oo),Io=function(e){function n(e,i,r,o){return s(this,n),t(this,n,[e,i,r,o,[]])}return d(n,e),c(n,[{key:"load",value:function(){var e=this;if(!window.Promise)return this.handleOnUnavailable();this.getGatewayWalletConfig().then((function(t){if(!t||"Paypal"!==t.type||!t.credentials||!t.credentials.client_auth)throw new Error("Invalid configuration");e.config=t,e.renderPaypalButton()})).catch((function(t){t&&e.handleOnError(t),e.handleOnUnavailable()}))}},{key:"setMeta",value:function(e){this.meta=e,this.renderPaypalButton()}},{key:"renderPaypalButton",value:function(){!0===this.meta.standalone?this.renderPaypalStandaloneComponent():this.renderPaypalCommonComponent()}},{key:"renderPaypalCommonComponent",value:function(){var e,t,n=this,i=(null===(e=this.container.getElement())||void 0===e?void 0:e.id)||"",r=document.createElement("script");r.src="https://www.paypal.com/sdk/js?client-id=".concat(null===(t=this.config.credentials)||void 0===t?void 0:t.client_auth,"¤cy=").concat(this.meta.currency).concat(!0===this.meta.pay_later?"&enable-funding=paylater&disable-funding=card":"&disable-funding=credit,card").concat(this.meta.capture?"":"&intent=authorize"),r.async=!0,r.onload=function(){window.paypal?(n.paypal=window.paypal,n.paypal.Buttons(u({},n.paypalSharedProps())).render("#".concat(i))):n.handleOnUnavailable()},document.head.appendChild(r)}},{key:"renderPaypalStandaloneComponent",value:function(){var e,t,n,i=this,r=(null===(e=this.container.getElement())||void 0===e?void 0:e.id)||"",o=document.createElement("script");o.src="https://www.paypal.com/sdk/js?client-id=".concat(null===(t=this.config.credentials)||void 0===t?void 0:t.client_auth,"¤cy=").concat(this.meta.currency,"&components=buttons,funding-eligibility,messages&enable-funding=paylater").concat(this.meta.capture?"":"&intent=authorize").concat("live"===(null===(n=this.config)||void 0===n?void 0:n.mode)?"":"&buyer-country=AU"),o.async=!0,o.onload=function(){var e;if(window.paypal){i.paypal=window.paypal;var t=!!i.meta.pay_later,n=i.paypal.Buttons(u({fundingSource:t?i.paypal.FUNDING.PAYLATER:i.paypal.FUNDING.PAYPAL},i.paypalSharedProps()));if(n.isEligible()){if(n.render("#".concat(r)),t)i.paypal.Messages(u({amount:i.meta.amount,currency:i.meta.currency,placement:"payment"},(null===(e=i.meta.style)||void 0===e?void 0:e.messages)&&{style:i.meta.style.messages})).render("#".concat(r))}else i.handleOnUnavailable()}else i.handleOnUnavailable()},document.head.appendChild(o)}},{key:"paypalSharedProps",value:function(){var e=this;return u(u({},this.meta.style&&{style:this.meta.style}),{onClick:function(t,n){return e.handleMerchantOnExpressButtonClickEvent().then((function(){return n.resolve()})).catch((function(){return e.handleCheckoutClose(),n.reject()}))},createOrder:function(){return new Promise((function(t,n){return e.api.auth?e.executeWalletCallback({request_type:"CREATE_TRANSACTION"}).then((function(e){t(e.id)})).catch((function(e){n(e)})):n(new Error("Wallet Token not injected. Please handle onClick correctly."))}))},onApprove:function(t){return e.pendingApprovalPromise||(e.pendingApprovalPromise=e.executeWalletCapture({payment_method_id:t.orderID,customer:{payment_source:{external_payer_id:t.payerID}}}).finally((function(){e.pendingApprovalPromise=void 0}))),e.pendingApprovalPromise},onCancel:function(){return e.handleCheckoutClose()},onError:function(){}})}}])}(Oo);class Ao{constructor(e,t){if(!e.onEnd)throw new Error("onEnd handler is required");if(!t)throw new Error("ms duration is required");this.onEnd=e.onEnd,this.initialMs=t,this.startTimestamp=Date.now(),this.timer=this.create(this.onEnd,t)}create(e,t){return this.timer&&this.clear(),setTimeout((()=>e?e():this.onEnd()),t||this.initialMs)}clear(){clearTimeout(this.timer),this.timer=null}end(){this.clear(),this.onEnd()}isValid(){return this.initialMs-(Date.now()-this.startTimestamp)>0}}function Ro(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];It("visibilitychange",(function(){if(t)return void("hidden"===document.visibilityState&&e());e(document.visibilityState)}),arguments.length>2?arguments[2]:void 0,arguments.length>3?arguments[3]:void 0)}class xo extends Ao{constructor(e,t){super(e,t),this.onPause="function"==typeof e.onPause?e.onPause:()=>{},this.onRefresh="function"==typeof e.onRefresh?e.onRefresh:()=>{},this.onResume="function"==typeof e.onResume?e.onResume:()=>{},this.readStorage=e.readStorage,this.remainingMs=void 0,e.refreshEvents||(e.refreshEvents=["click","keydown","scroll"]);try{this.abortController=new AbortController}catch(e){}if(ie&&e.ee){if(e.ee){this.ee=e.ee;const t=function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=i?.leading||!1;let o;return function(){for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];r&&void 0===o&&(e.apply(t,s),o=setTimeout((()=>{o=clearTimeout(o)}),n)),r||(clearTimeout(o),o=setTimeout((()=>{e.apply(t,s)}),n))}}(this.refresh.bind(this),500,{leading:!0});this.refreshHandler=n=>{e.refreshEvents.includes(n?.[0]?.type)&&t()},e.ee.on("fn-end",this.refreshHandler)}Ro((e=>{"hidden"===e?this.pause():this.resume()}),!1,!1,this.abortController?.signal)}}abort(){this.clear(),this.abortController?.abort(),this.refreshHandler&&(this.ee.removeEventListener("fn-end",this.refreshHandler),this.refreshHandler=this.ee=null)}pause(){this.onPause(),clearTimeout(this.timer),this.remainingMs=this.initialMs-(Date.now()-this.startTimestamp)}resume(){try{const t=this.readStorage(),n="string"==typeof t?JSON.parse(t):t;e(n.expiresAt)||e(n.inactiveAt)?this.end():(this.refresh(),this.onResume())}catch(e){this.end()}function e(e){return Date.now()>e}}refresh(e,t){this.clear(),this.timer=this.create(e,t),this.startTimestamp=Date.now(),this.remainingMs=void 0,this.onRefresh()}}const Mo="nr@original:".concat(rt);var Po=Object.prototype.hasOwnProperty,Do=!1;function Lo(e,t){return e||(e=st),n.inPlace=function(e,t,i,r,o){i||(i="");const s="-"===i.charAt(0);for(let a=0;a<t.length;a++){const c=t[a],l=e[c];Uo(l)||(e[c]=n(l,s?c+i:i,r,c,o))}},n.flag=Mo,n;function n(t,n,r,o,s){return Uo(t)?t:(n||(n=""),a[Mo]=t,function(e,t,n){if(Object.defineProperty&&Object.keys)try{return Object.keys(e).forEach((function(n){Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){return e[n]=t,t}})})),t}catch(e){Fo([e],n)}for(var i in e)Po.call(e,i)&&(t[i]=e[i])}(t,a,e),a);function a(){var a,c,l,u;try{c=this,a=[...arguments],l="function"==typeof r?r(a,c):r||{}}catch(t){Fo([t,"",[a,c,o],l],e)}i(n+"start",[a,c,o],l,s);try{return u=t.apply(c,a)}catch(e){throw i(n+"err",[a,c,e],l,s),e}finally{i(n+"end",[a,c,u],l,s)}}}function i(n,i,r,o){if(!Do||t){var s=Do;Do=!0;try{e.emit(n,i,r,t,o)}catch(t){Fo([t,n,i,r],e)}Do=s}}}function Fo(e,t){t||(t=st);try{t.emit("internal-error",e)}catch(e){}}function Uo(e){return!(e&&"function"==typeof e&&e.apply&&!e[Mo])}const jo={},Bo=oe.XMLHttpRequest,Ho="addEventListener",zo="removeEventListener",Vo="nr@wrapped:".concat(ot);function Wo(e){var t=function(e){return(e||st).get("events")}(e);if(jo[t.debugId]++)return t;jo[t.debugId]=1;var n=Lo(t,!0);function i(e){n.inPlace(e,[Ho,zo],"-",r)}function r(e,t){return e[1]}return"getPrototypeOf"in Object&&(ie&&qo(document,i),qo(oe,i),qo(Bo.prototype,i)),t.on(Ho+"-start",(function(e,t){var i=e[1];if(null!==i&&("function"==typeof i||"object"==typeof i)){var r=Ee(i,Vo,(function(){var e={object:function(){if("function"!=typeof i.handleEvent)return;return i.handleEvent.apply(i,arguments)},function:i}[typeof i];return e?n(e,"fn-",null,e.name||"anonymous"):i}));this.wrapped=e[1]=r}})),t.on(zo+"-start",(function(e){e[1]=this.wrapped||e[1]})),t}function qo(e,t){let n=e;for(;"object"==typeof n&&!Object.prototype.hasOwnProperty.call(n,Ho);)n=Object.getPrototypeOf(n);for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];n&&t(n,...r)}const Go={value:"",inactiveAt:0,expiresAt:0,updatedAt:Date.now(),sessionReplayMode:Fe.OFF,sessionReplaySentFirstChunk:!1,sessionTraceMode:Fe.OFF,traceHarvestStarted:!1,serverTimeDiff:null,custom:{}};class Ko{constructor(e){const{agentIdentifier:t,key:n,storage:i}=e;if(!t||!n||!i)throw new Error("Missing required field(s):".concat(t?"":" agentID").concat(n?"":" key").concat(i?"":" storage"));this.agentIdentifier=t,this.storage=i,this.state={},this.key=n,this.ee=st.get(t),Wo(this.ee),this.setup(e),ie&&Nt("storage",(e=>{if(e.key===this.lookupKey){const t="string"==typeof e.newValue?JSON.parse(e.newValue):e.newValue;this.sync(t),this.ee.emit(Pe,[Le,this.state])}}))}setup(e){let{value:t=it(16),expiresMs:n=Ne,inactiveMs:i=Ie}=e;const r={serverTimeDiff:this.state.serverTimeDiff||Go.serverTimeDiff};this.state={},this.sync({...Go,...r}),this.state.value=t,this.expiresMs=n,this.inactiveMs=i;const o=this.read();n?(this.state.expiresAt=o?.expiresAt||this.getFutureTimestamp(n),this.expiresTimer=new Ao({onEnd:()=>{this.collectSM("expired"),this.collectSM("duration"),this.reset()}},this.state.expiresAt-Date.now())):this.state.expiresAt=1/0,i?(this.state.inactiveAt=o?.inactiveAt||this.getFutureTimestamp(i),this.inactiveTimer=new xo({onEnd:()=>{this.collectSM("inactive"),this.collectSM("duration"),this.reset()},onRefresh:this.refresh.bind(this),onResume:()=>{this.ee.emit(Me)},onPause:()=>{this.initialized&&this.ee.emit(Re),this.write(ke(this.state,Go))},ee:this.ee,refreshEvents:["click","keydown","scroll"],readStorage:()=>this.storage.get(this.lookupKey)},this.state.inactiveAt-Date.now())):this.state.inactiveAt=1/0,this.isNew||=!Object.keys(o).length,this.isNew?this.write(ke(this.state,Go),!0):this.sync(o),this.initialized=!0,this.ee.emit(Ae,[this.isNew])}get lookupKey(){return"".concat("NRBA","_").concat(this.key)}sync(e){Object.assign(this.state,e)}read(){try{const e=this.storage.get(this.lookupKey);if(!e)return{};const t="string"==typeof e?JSON.parse(e):e;return this.isInvalid(t)?{}:this.isExpired(t.expiresAt)?(this.collectSM("expired"),this.collectSM("duration",t,!0),this.reset()):this.isExpired(t.inactiveAt)?(this.collectSM("inactive"),this.collectSM("duration",t,!0),this.reset()):t}catch(e){return we("Failed to read from storage API",e),{}}}write(e){try{if(!e||"object"!=typeof e)return;return e.updatedAt=Date.now(),this.sync(e),this.storage.set(this.lookupKey,Xt(this.state)),this.ee.emit(Pe,[De,this.state]),e}catch(e){return we("Failed to write to the storage API",e),null}}reset(){try{return this.initialized&&this.ee.emit(xe),this.storage.remove(this.lookupKey),this.inactiveTimer?.abort?.(),this.expiresTimer?.clear?.(),delete this.isNew,this.setup({agentIdentifier:this.agentIdentifier,key:this.key,storage:this.storage,expiresMs:this.expiresMs,inactiveMs:this.inactiveMs}),this.read()}catch(e){return{}}}refresh(){const e=this.read();this.write({...e,inactiveAt:this.getFutureTimestamp(this.inactiveMs)})}isExpired(e){return Date.now()>e}isInvalid(e){return!Object.keys(Go).every((t=>Object.keys(e).includes(t)))}collectSM(e,t,n){let i,r;"duration"===e&&(i=this.getDuration(t,n),r="Session/Duration/Ms"),"expired"===e&&(r="Session/Expired/Seen"),"inactive"===e&&(r="Session/Inactive/Seen"),r&<(un,[r,i],void 0,ft.metrics,this.ee)}getDuration(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state,t=arguments.length>1?arguments[1]:void 0;const n=e.expiresAt-this.expiresMs;return(t?Date.now():e.updatedAt)-n}getFutureTimestamp(e){return Date.now()+e}syncCustomAttribute(e,t){if(ie)if(null===t){const t=this.read();t.custom&&(delete t.custom[e],this.write({...t}))}else{const n=this.read();this.custom={...n?.custom||{},[e]:t},this.write({...n,custom:this.custom})}}}class Yo{get(e){try{return localStorage.getItem(e)||void 0}catch(e){return""}}set(e,t){try{return null==t?this.remove(e):localStorage.setItem(e,t)}catch(e){}}remove(e){try{localStorage.removeItem(e)}catch(e){}}}let $o=0;var Jo=Object.freeze({__proto__:null,setupAgentSession:function(e){const t=Ze(e);if($o++)return t.session;const n=ze(e).session;t.session=new Ko({agentIdentifier:e,key:"SESSION",storage:new Yo,expiresMs:n?.expiresMs,inactiveMs:n?.inactiveMs});const i=t.session.state.custom,r=_e(e);i&&(r.jsAttributes={...r.jsAttributes,...i});const o=st.get(e);return ht("api-setCustomAttribute",((e,n,i)=>{t.session.syncCustomAttribute(n,i)}),"session",o),ht("api-setUserId",((e,n,i)=>{t.session.syncCustomAttribute(n,i)}),"session",o),Et(e,"session"),t.session}});var Xo=Object.freeze({__proto__:null,lazyFeatureLoader:function(e,t){if("aggregate"===t)switch(e){case ft.ajax:return Promise.resolve().then((function(){return Bs}));case ft.jserrors:return Promise.resolve().then((function(){return ta}));case ft.metrics:return Promise.resolve().then((function(){return ka}));case ft.pageAction:return Promise.resolve().then((function(){return Sa}));case ft.pageViewEvent:return Promise.resolve().then((function(){return Xc}));case ft.pageViewTiming:return Promise.resolve().then((function(){return rl}));case ft.sessionReplay:return Promise.resolve().then((function(){return ll}));case ft.sessionTrace:return Promise.resolve().then((function(){return gl}));case ft.spa:return Promise.resolve().then((function(){return Yl}));case ft.softNav:return Promise.resolve().then((function(){return lu}));default:throw new Error("Attempted to load unsupported agent feature: ".concat(e," ").concat(t))}}});var Zo=Object.freeze({__proto__:null,setAPI:function(e){var t=st.get(e),n={finished:Dt((function(e,n){var r=n?n-pe:e;lt(dn,["finished",{time:r}],void 0,ft.metrics,t),i(e,{name:"finished",start:r+pe,origin:"nr"}),lt("api-addPageAction",[r,"finished"],void 0,ft.pageAction,t)})),setErrorHandler:function(t,n){Ze(e).onerror=n},addToTrace:i,addRelease:function(t,n,i){if(++r>10)return;Ze(e).releaseIds[n.slice(-200)]=(""+i).slice(-200)}};function i(e,n){n&&"object"==typeof n&&n.name&&n.start&<("bstApi",[{n:n.name,s:n.start-pe,e:(n.end||n.start)-pe,o:n.origin||"",t:"api"}],void 0,ft.sessionTrace,t)}Object.entries(n).forEach((e=>{let[n,i]=e;return ht("api-"+n,i,"api",t)}));var r=0}});
|
|
14
14
|
/**
|
|
15
15
|
* @file Contains common methods used to transmit harvested data.
|
|
16
16
|
* @copyright 2023 New Relic Corporation. All rights reserved.
|