UNPKG

@monei-js/components

Version:

MONEI UI Components enable you to collect sensitive payment information using customizable UI components.

1 lines 235 kB
"use strict";function e(e,n,t,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void t(e)}u.done?n(c):Promise.resolve(c).then(r,o)}function n(n){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=n.apply(t,r);function u(n){e(a,o,i,u,c,"next",n)}function c(n){e(a,o,i,u,c,"throw",n)}u(void 0)}))}}function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function r(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}Object.defineProperty(exports,"__esModule",{value:!0});var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e,n){return e(n={exports:{}},n.exports),n.exports}function u(e){return e&&e.default||e}var c,s=a((function(e){var n=function(e){var n=Object.prototype,t=n.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(e,n,t){return Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[n]}try{u({},"")}catch(e){u=function(e,n,t){return e[n]=t}}function c(e,n,t,r){var o=Object.create((n&&n.prototype instanceof f?n:f).prototype),i=new _(r||[]);return o._invoke=function(e,n,t){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(t.method=o,t.arg=i;;){var a=t.delegate;if(a){var u=E(a,t);if(u){if(u===d)continue;return u}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===r)throw r="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);r="executing";var c=s(e,n,t);if("normal"===c.type){if(r=t.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:t.done}}"throw"===c.type&&(r="completed",t.method="throw",t.arg=c.arg)}}}(e,t,i),o}function s(e,n,t){try{return{type:"normal",arg:e.call(n,t)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d={};function f(){}function l(){}function p(){}var h={};h[o]=function(){return this};var w=Object.getPrototypeOf,v=w&&w(w(O([])));v&&v!==n&&t.call(v,o)&&(h=v);var m=p.prototype=f.prototype=Object.create(h);function y(e){["next","throw","return"].forEach((function(n){u(e,n,(function(e){return this._invoke(n,e)}))}))}function g(e,n){var r;this._invoke=function(o,i){function a(){return new n((function(r,a){!function r(o,i,a,u){var c=s(e[o],e,i);if("throw"!==c.type){var d=c.arg,f=d.value;return f&&"object"==typeof f&&t.call(f,"__await")?n.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):n.resolve(f).then((function(e){d.value=e,a(d)}),(function(e){return r("throw",e,a,u)}))}u(c.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}}function E(e,n){var t=e.iterator[n.method];if(void 0===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=void 0,E(e,n),"throw"===n.method))return d;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var r=s(t,e.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,d;var o=r.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,d):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,d)}function P(e){var n={tryLoc:e[0]};1 in e&&(n.catchLoc=e[1]),2 in e&&(n.finallyLoc=e[2],n.afterLoc=e[3]),this.tryEntries.push(n)}function b(e){var n=e.completion||{};n.type="normal",delete n.arg,e.completion=n}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function O(e){if(e){var n=e[o];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function n(){for(;++r<e.length;)if(t.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=void 0,n.done=!0,n};return i.next=i}}return{next:T}}function T(){return{value:void 0,done:!0}}return l.prototype=m.constructor=p,p.constructor=l,l.displayName=u(p,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var n="function"==typeof e&&e.constructor;return!!n&&(n===l||"GeneratorFunction"===(n.displayName||n.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,u(e,a,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},y(g.prototype),g.prototype[i]=function(){return this},e.AsyncIterator=g,e.async=function(n,t,r,o,i){void 0===i&&(i=Promise);var a=new g(c(n,t,r,o),i);return e.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(m),u(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},e.keys=function(e){var n=[];for(var t in e)n.push(t);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var n in this)"t"===n.charAt(0)&&t.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(t,r){return a.type="throw",a.arg=e,n.next=t,r&&(n.method="next",n.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=t.call(i,"catchLoc"),c=t.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,n){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&t.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(e,n){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&&n&&(this.next=n),d},finish:function(e){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),b(t),d}},catch:function(e){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc===e){var r=t.completion;if("throw"===r.type){var o=r.arg;b(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,t){return this.delegate={iterator:O(e),resultName:n,nextLoc:t},"next"===this.method&&(this.arg=void 0),d}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}})),d=function(e){return Object.keys(e).reduce((function(n,t){return n[t]="string"==typeof e[t]?e[t]:e[t]+"px",n}),{})},f=function(e,n,t,r){return new Promise((function(o,i){var a=Array.from(document.scripts).find((function(n){return n.src===e}));if(a){if(!r)return void o(a);a.remove()}var u=document.createElement("script");u.src=e,u.onload=function(){return o(u)},u.onerror=function(e){return i(e)},n&&u.setAttribute("nonce",n),t&&Object.keys(t).forEach((function(e){t[e]&&(u.dataset[e]=t[e])})),document.head.appendChild(u)}))},l=function(e){return Object.keys(e).reduce((function(n,t){return void 0!==e[t]&&n.push(t+"="+e[t]),n}),[]).join("&")},p=function(){var e,n;try{e=window.localStorage}catch(r){var t=(n=new Map,{getItem:function(e){return n.get(e)},setItem:function(e,t){n.set(e,t)},clear:function(){n=new Map},removeItem:function(e){n.delete(e)}});Object.defineProperty(window,"localStorage",{value:t}),e=t}return e},h=function(){var e,n=p();try{e=n.getItem("i18nextLng")}catch(e){}return e?e.split("-")[0]:""},w=function(){var e=[window.screen.colorDepth,window.screen.height,window.screen.width,(new Date).getTimezoneOffset(),h()].join("|");return window.btoa(e)},v=function(){var e=n(s.mark((function e(n){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.t0=void 0,e.next=4,n;case 4:return e.t1=e.sent,e.abrupt("return",[e.t0,e.t1]);case 8:return e.prev=8,e.t2=e.catch(0),e.abrupt("return",[e.t2,void 0]);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(n){return e.apply(this,arguments)}}(),m=function(e){if(!(e.paymentId||e.accountId&&e.amount&&e.currency))throw new Error("You need to provide paymentId or accountId amount and currency")},y={__proto__:null,transformStyle:d,loadScript:f,stringify:l,fixLocalstorage:p,getClientEnv:w,withError:v,isMethodSupported:function(e,n){return e.paymentMethods&&e.paymentMethods.includes(n)},validateComponentProps:m},g="https://js.monei.com",E=t({},{domain:g,version:"v2",stage:"prod",isProduction:!0,paymentPageUrl:g+"/v2/payment-page/",posPaymentPageUrl:g+"/v2/pos-payment-page/",cardInputUrl:g+"/v2/inner-card-input/",paymentModalUrl:g+"/v2/inner-payment-modal/",paypalUrl:g+"/v2/inner-paypal/",bizumUrl:g+"/v2/inner-bizum/",bizumButtonUrl:g+"/v2/inner-bizum-button/",cofidisUrl:g+"/v2/inner-cofidis/",cofidisButtonUrl:g+"/v2/inner-cofidis-button/",cofidisWidgetUrl:g+"/v2/inner-cofidis-widget/",cofidisLoanUrl:g+"/v2/inner-cofidis-loan/",cofidisLoanButtonUrl:g+"/v2/inner-cofidis-loan-button/",cofidisLoanWidgetUrl:g+"/v2/inner-cofidis-loan-widget/",googlePayUrl:g+"/v2/inner-google-pay/",paymentRequestUrl:g+"/v2/inner-payment-request/",click2PayUrl:g+"/v2/inner-click2pay/",click2PayButtonUrl:g+"/v2/inner-click2pay-button/"},{apiUrl:"https://api.monei.com/v1",secureDomain:"https://secure.monei.com",rootDomain:"monei.com"}),P=function(){var e=n(s.mark((function e(n,r){var o,i,a,u,c,d,f;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=(o=void 0===r?{}:r).headers,c=o.body,"POST"===(a=void 0===(i=o.method)?"GET":i)&&(u=t({"Content-Type":"application/json"},u)),e.next=4,fetch(""+E.apiUrl+n,{method:a,headers:u,body:c?JSON.stringify(c):void 0});case 4:return d=e.sent,e.next=7,v(d.json());case 7:if(f=e.sent[1],d.ok){e.next=11;break}throw f||new Error(d.statusText);case 11:return e.abrupt("return",f);case 12:case"end":return e.stop()}}),e)})));return function(n,t){return e.apply(this,arguments)}}(),b={},_=function(){var e=n(s.mark((function e(n){var t,r,o,i,a;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.accountId,!(r=n.paymentId)){e.next=5;break}o={paymentId:r},e.next=10;break;case 5:if(!t){e.next=9;break}o={accountId:t},e.next=10;break;case 9:throw new Error("You need to provide paymentId or accountId");case 10:if(i=l(o),!b[i]){e.next=13;break}return e.abrupt("return",b[i]);case 13:return a=P("/payment-methods?"+i),b[i]=a,e.abrupt("return",a);case 16:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),O=function(){var e=n(s.mark((function e(n){var t,r,o,i,a,u,c;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.paymentMethod,o=n.sessionId,i=n.amount,a=n.currency,u=n.accountId,!(r=n.paymentId)){e.next=5;break}c={paymentId:r,paymentMethod:t},e.next=10;break;case 5:if(!u){e.next=9;break}c={accountId:u,paymentMethod:t,sessionId:o,amount:i,currency:a},e.next=10;break;case 9:throw new Error("You need to provide paymentId or accountId");case 10:return e.abrupt("return",P("/tokens",{method:"POST",headers:{"Client-Env":w()},body:c}));case 11:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),T=function(){var e=n(s.mark((function e(n){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P("/payments/"+n+"/client-get"));case 1:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),S=function(){var e=n(s.mark((function e(n){var t,o;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.paymentId,o=r(n,["paymentId"]),e.abrupt("return",P("/payments/"+t+"/client-confirm",{method:"POST",headers:{"Client-Env":w()},body:o}));case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),x=function(){var e=n(s.mark((function e(n){var t,o;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.signature,o=r(n,["signature"]),e.abrupt("return",P("/client-payments",{method:"POST",headers:{"Client-Env":w(),"Client-Signature":t},body:o}));case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),I=function(){var e=n(s.mark((function e(n){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P("/payments/"+n.paymentId+"/client-receipt",{method:"POST",body:{customerEmail:n.customerEmail,signature:n.signature,language:n.language}}));case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),N=function(){var e=n(s.mark((function e(n){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P("/apple-pay/sessions",{method:"POST",body:n}));case 1:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),R={__proto__:null,getPaymentMethods:_,createToken:O,getPayment:T,confirmPayment:S,createPayment:x,sendPaymentReceipt:I,createApplePaySession:N,calculateFinancing:function(){var e=n(s.mark((function e(n){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P("/cofidis/calculate-financing",{method:"POST",body:n}));case 1:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),validateBizumPhone:function(){var e=n(s.mark((function e(n){return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P("/bizum/validate-phone",{method:"POST",body:n}));case 1:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()},C=a((function(e,n){var t;"undefined"!=typeof self&&self,t=function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return{}.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){function r(e){return"[object RegExp]"==={}.toString.call(e)}t.r(n),t.d(n,"Promise",(function(){return R})),t.d(n,"TYPES",(function(){return Ge})),t.d(n,"ProxyWindow",(function(){return Pe})),t.d(n,"setup",(function(){return Ye})),t.d(n,"destroy",(function(){return He})),t.d(n,"serializeMessage",(function(){return Fe})),t.d(n,"deserializeMessage",(function(){return ze})),t.d(n,"createProxyWindow",(function(){return Be})),t.d(n,"toProxyWindow",(function(){return Ue})),t.d(n,"on",(function(){return De})),t.d(n,"once",(function(){return Me})),t.d(n,"send",(function(){return qe})),t.d(n,"markWindowKnown",(function(){return de})),t.d(n,"cleanUpWindow",(function(){return Ve})),t.d(n,"bridge",(function(){}));var o="Call was rejected by callee.\r\n";function i(e){return void 0===e&&(e=window),"about:"===e.location.protocol}function a(e){if(void 0===e&&(e=window),e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function u(e){if(void 0===e&&(e=window),e&&!a(e))try{return e.opener}catch(e){}}function c(e){try{return!0}catch(e){}return!1}function s(e){void 0===e&&(e=window);var n=e.location;if(!n)throw new Error("Can not read window location");var t=n.protocol;if(!t)throw new Error("Can not read window protocol");if("file:"===t)return"file://";if("about:"===t){var r=a(e);return r&&c()?s(r):"about://"}var o=n.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function d(e){void 0===e&&(e=window);var n=s(e);return n&&e.mockDomain&&0===e.mockDomain.indexOf("mock:")?e.mockDomain:n}function f(e){if(!function(e){try{if(e===window)return!0}catch(e){}try{var n=Object.getOwnPropertyDescriptor(e,"location");if(n&&!1===n.enumerable)return!1}catch(e){}try{if(i(e)&&c())return!0}catch(e){}try{if(s(e)===s(window))return!0}catch(e){}return!1}(e))return!1;try{if(e===window)return!0;if(i(e)&&c())return!0;if(d(window)===d(e))return!0}catch(e){}return!1}function l(e){if(!f(e))throw new Error("Expected window to be same domain");return e}function p(e,n){if(!e||!n)return!1;var t=a(n);return t?t===e:-1!==function(e){var n=[];try{for(;e.parent!==e;)n.push(e.parent),e=e.parent}catch(e){}return n}(n).indexOf(e)}function h(e){var n,t,r=[];try{n=e.frames}catch(t){n=e}try{t=n.length}catch(e){}if(0===t)return r;if(t){for(var o=0;o<t;o++){var i=void 0;try{i=n[o]}catch(e){continue}r.push(i)}return r}for(var a=0;a<100;a++){var u=void 0;try{u=n[a]}catch(e){return r}if(!u)return r;r.push(u)}return r}var w=[],v=[];function m(e,n){void 0===n&&(n=!0);try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==o}if(n&&f(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var t=function(e,n){for(var t=0;t<e.length;t++)try{if(e[t]===n)return t}catch(e){}return-1}(w,e);if(-1!==t){var r=v[t];if(r&&function(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var n=e.ownerDocument;if(n&&n.documentElement&&!n.documentElement.contains(e)){for(var t=e;t.parentNode&&t.parentNode!==t;)t=t.parentNode;if(!t.host||!n.documentElement.contains(t.host))return!0}return!1}(r))return!0}return!1}function y(e){return void 0===e&&(e=window),u(e=e||window)||a(e)||void 0}function g(e,n){if("string"==typeof e){if("string"==typeof n)return"*"===e||n===e;if(r(n))return!1;if(Array.isArray(n))return!1}return r(e)?r(n)?e.toString()===n.toString():!Array.isArray(n)&&Boolean(n.match(e)):!!Array.isArray(e)&&(Array.isArray(n)?JSON.stringify(e)===JSON.stringify(n):!r(n)&&e.some((function(e){return g(e,n)})))}function E(e){try{if(e===window)return!0}catch(e){if(e&&e.message===o)return!0}try{if("[object Window]"==={}.toString.call(e))return!0}catch(e){if(e&&e.message===o)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===o)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===o)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===o)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===o)return!0}try{if(e&&"__unlikely_value__"===e.__cross_domain_utils_window_check__)return!1}catch(e){return!0}try{if("postMessage"in e&&"self"in e&&"location"in e)return!0}catch(e){}return!1}function P(e){try{e.close()}catch(e){}}function b(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&e instanceof window.constructor)return!1;var n={}.toString;if(n){var t=n.call(e);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}var _,O=[],T=[],S=0;function x(){if(!S&&_){var e=_;_=null,e.resolve()}}function I(){S+=1}function N(){S-=1,x()}var R=function(){function e(e){var n=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],e){var t,r,o=!1,i=!1,a=!1;I();try{e((function(e){a?n.resolve(e):(o=!0,t=e)}),(function(e){a?n.reject(e):(i=!0,r=e)}))}catch(e){return N(),void this.reject(e)}N(),a=!0,o?this.resolve(t):i&&this.reject(r)}}var n=e.prototype;return n.resolve=function(e){if(this.resolved||this.rejected)return this;if(b(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},n.reject=function(e){var n=this;if(this.resolved||this.rejected)return this;if(b(e))throw new Error("Can not reject promise with another promise");if(!e){var t=e&&"function"==typeof e.toString?e.toString():{}.toString.call(e);e=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout((function(){n.errorHandled||function(e,n){if(-1===O.indexOf(e)){O.push(e),setTimeout((function(){throw e}),1);for(var t=0;t<T.length;t++)T[t](e,n)}}(e,n)}),1),this.dispatch(),this},n.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},n.dispatch=function(){var n=this.resolved,t=this.rejected,r=this.handlers;if(!this.dispatching&&(n||t)){this.dispatching=!0,I();for(var o=function(e,n){return e.then((function(e){n.resolve(e)}),(function(e){n.reject(e)}))},i=0;i<r.length;i++){var a=r[i],u=a.onSuccess,c=a.onError,s=a.promise,d=void 0;if(n)try{d=u?u(this.value):this.value}catch(e){s.reject(e);continue}else if(t){if(!c){s.reject(this.error);continue}try{d=c(this.error)}catch(e){s.reject(e);continue}}d instanceof e&&(d.resolved||d.rejected)?(d.resolved?s.resolve(d.value):s.reject(d.error),d.errorHandled=!0):b(d)?d instanceof e&&(d.resolved||d.rejected)?d.resolved?s.resolve(d.value):s.reject(d.error):o(d,s):s.resolve(d)}r.length=0,this.dispatching=!1,N()}},n.then=function(n,t){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for success handler");if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.then expected a function for error handler");var r=new e;return this.handlers.push({promise:r,onSuccess:n,onError:t}),this.errorHandled=!0,this.dispatch(),r},n.catch=function(e){return this.then(void 0,e)},n.finally=function(n){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.finally expected a function");return this.then((function(t){return e.try(n).then((function(){return t}))}),(function(t){return e.try(n).then((function(){throw t}))}))},n.timeout=function(e,n){var t=this;if(this.resolved||this.rejected)return this;var r=setTimeout((function(){t.resolved||t.rejected||t.reject(n||new Error("Promise timed out after "+e+"ms"))}),e);return this.then((function(e){return clearTimeout(r),e}))},n.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.resolve=function(n){return n instanceof e?n:b(n)?new e((function(e,t){return n.then(e,t)})):(new e).resolve(n)},e.reject=function(n){return(new e).reject(n)},e.asyncReject=function(n){return(new e).asyncReject(n)},e.all=function(n){var t=new e,r=n.length,o=[];if(!r)return t.resolve(o),t;for(var i=function(e,n,i){return n.then((function(n){o[e]=n,0==(r-=1)&&t.resolve(o)}),(function(e){i.reject(e)}))},a=0;a<n.length;a++){var u=n[a];if(u instanceof e){if(u.resolved){o[a]=u.value,r-=1;continue}}else if(!b(u)){o[a]=u,r-=1;continue}i(a,e.resolve(u),t)}return 0===r&&t.resolve(o),t},e.hash=function(n){var t={},r=[],o=function(e){if(n.hasOwnProperty(e)){var o=n[e];b(o)?r.push(o.then((function(n){t[e]=n}))):t[e]=o}};for(var i in n)o(i);return e.all(r).then((function(){return t}))},e.map=function(n,t){return e.all(n.map(t))},e.onPossiblyUnhandledException=function(e){return function(e){return T.push(e),{cancel:function(){T.splice(T.indexOf(e),1)}}}(e)},e.try=function(n,t,r){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.try expected a function");var o;I();try{o=n.apply(t,r||[])}catch(n){return N(),e.reject(n)}return N(),e.resolve(o)},e.delay=function(n){return new e((function(e){setTimeout(e,n)}))},e.isPromise=function(n){return!!(n&&n instanceof e)||b(n)},e.flush=function(){return n=_=_||new e,x(),n;var n},e}();function C(e,n){for(var t=0;t<e.length;t++)try{if(e[t]===n)return t}catch(e){}return-1}var k,j=function(){function e(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,n={};return Object.freeze(n),e.set(n,"__testvalue__"),"__testvalue__"===e.get(n)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}var n=e.prototype;return n._cleanupClosedWindows=function(){for(var e=this.weakmap,n=this.keys,t=0;t<n.length;t++){var r=n[t];if(E(r)&&m(r)){if(e)try{e.delete(r)}catch(e){}n.splice(t,1),this.values.splice(t,1),t-=1}}},n.isSafeToReadWrite=function(e){return!E(e)},n.set=function(e,n){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.set(e,n)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var r=this.name,o=e[r];return void(o&&o[0]===e?o[1]=n:Object.defineProperty(e,r,{value:[e,n],writable:!0}))}catch(e){}this._cleanupClosedWindows();var i=this.keys,a=this.values,u=C(i,e);-1===u?(i.push(e),a.push(n)):a[u]=n},n.get=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{if(n.has(e))return n.get(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var t=e[this.name];return t&&t[0]===e?t[1]:void 0}catch(e){}this._cleanupClosedWindows();var r=C(this.keys,e);if(-1!==r)return this.values[r]},n.delete=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var t=e[this.name];t&&t[0]===e&&(t[0]=t[1]=void 0)}catch(e){}this._cleanupClosedWindows();var r=this.keys,o=C(r,e);-1!==o&&(r.splice(o,1),this.values.splice(o,1))},n.has=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{if(n.has(e))return!0}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e))try{var t=e[this.name];return!(!t||t[0]!==e)}catch(e){}return this._cleanupClosedWindows(),-1!==C(this.keys,e)},n.getOrSet=function(e,n){if(this.has(e))return this.get(e);var t=n();return this.set(e,t),t},e}();function W(e){return e.name||e.__name__||e.displayName||"anonymous"}function A(e,n){try{delete e.name,e.name=n}catch(e){}return e.__name__=e.displayName=n,e}function L(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,(function(){return e.charAt(Math.floor(Math.random()*e.length))}))+"_"+function(e){if("function"==typeof btoa)return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,n){return String.fromCharCode(parseInt(n,16))})));if("undefined"!=typeof Buffer)return Buffer.from(e,"utf8").toString("base64");throw new Error("Can not find window.btoa or Buffer")}((new Date).toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function D(e){try{return JSON.stringify([].slice.call(e),(function(e,n){return"function"==typeof n?"memoize["+function(e){if(k=k||new j,null==e||"object"!=typeof e&&"function"!=typeof e)throw new Error("Invalid object");var n=k.get(e);return n||(n=typeof e+":"+L(),k.set(e,n)),n}(n)+"]":n}))}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function M(){return{}}var q=0,F=0;function z(e,n){void 0===n&&(n={});var t,r,o=n.thisNamespace,i=void 0!==o&&o,a=n.time,u=q;q+=1;var c=function(){for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];var s;u<F&&(t=null,r=null,u=q,q+=1),s=i?(r=r||new j).getOrSet(this,M):t=t||{};var d=D(o),f=s[d];if(f&&a&&Date.now()-f.time<a&&(delete s[d],f=null),f)return f.value;var l=Date.now(),p=e.apply(this,arguments);return s[d]={time:l,value:p},p};return c.reset=function(){t=null,r=null},A(c,(n.name||W(e))+"::memoized")}function B(e){var n={};function t(){for(var t=arguments,r=this,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var u=D(i);return n.hasOwnProperty(u)||(n[u]=R.try((function(){return e.apply(r,t)})).finally((function(){delete n[u]}))),n[u]}return t.reset=function(){n={}},A(t,W(e)+"::promiseMemoized")}function U(){}function Y(e,n){if(void 0===n&&(n=1),n>=3)return"stringifyError stack overflow";try{if(!e)return"<unknown error: "+{}.toString.call(e)+">";if("string"==typeof e)return e;if(e instanceof Error){var t=e&&e.stack,r=e&&e.message;if(t&&r)return-1!==t.indexOf(r)?t:r+"\n"+t;if(t)return t;if(r)return r}return e&&e.toString&&"function"==typeof e.toString?e.toString():{}.toString.call(e)}catch(e){return"Error while stringifying error: "+Y(e,n+1)}}function H(e){return"string"==typeof e?e:e&&e.toString&&"function"==typeof e.toString?e.toString():{}.toString.call(e)}function G(e){return"[object RegExp]"==={}.toString.call(e)}function V(e,n,t){if(e.hasOwnProperty(n))return e[n];var r=t();return e[n]=r,r}function J(){return Boolean(document.body)&&"complete"===document.readyState}function $(){return Boolean(document.body)&&"interactive"===document.readyState}z.clear=function(){F=q},z((function(e){if(Object.values)return Object.values(e);var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(e[t]);return n})),z((function(){return new R((function(e){if(J()||$())return e();var n=setInterval((function(){if(J()||$())return clearInterval(n),e()}),10)}))}));var Z="undefined"!=typeof document?document.currentScript:null,X=z((function(){if(Z)return Z;if(Z=function(){try{var e=function(){try{throw new Error("_")}catch(e){return e.stack||""}}(),n=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(e),t=n&&n[1];if(!t)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===t)return i}}catch(e){}}())return Z;throw new Error("Can not determine current script")})),K=L();function Q(e){void 0===e&&(e=window);var n="__post_robot_10_0_42__";return e!==window?e[n]:e[n]=e[n]||{}}z((function(){var e;try{e=X()}catch(e){return K}var n=e.getAttribute("data-uid");return n&&"string"==typeof n||(n=e.getAttribute("data-uid-auto"))&&"string"==typeof n||(n=L(),e.setAttribute("data-uid-auto",n)),n}));var ee=function(){return{}};function ne(e,n){return void 0===e&&(e="store"),void 0===n&&(n=ee),V(Q(),e,(function(){var e=n();return{has:function(n){return e.hasOwnProperty(n)},get:function(n,t){return e.hasOwnProperty(n)?e[n]:t},set:function(n,t){return e[n]=t,t},del:function(n){delete e[n]},getOrSet:function(n,t){return V(e,n,t)},reset:function(){e=n()},keys:function(){return Object.keys(e)}}}))}var te,re=function(){};function oe(){var e=Q();return e.WINDOW_WILDCARD=e.WINDOW_WILDCARD||new re,e.WINDOW_WILDCARD}function ie(e,n){return void 0===e&&(e="store"),void 0===n&&(n=ee),ne("windowStore").getOrSet(e,(function(){var t=new j,r=function(e){return t.getOrSet(e,n)};return{has:function(n){return r(n).hasOwnProperty(e)},get:function(n,t){var o=r(n);return o.hasOwnProperty(e)?o[e]:t},set:function(n,t){return r(n)[e]=t,t},del:function(n){delete r(n)[e]},getOrSet:function(n,t){return V(r(n),e,t)}}}))}function ae(){return ne("instance").getOrSet("instanceID",L)}function ue(e,n){var t=n.domain,r=ie("helloPromises"),o=r.get(e);o&&o.resolve({domain:t});var i=R.resolve({domain:t});return r.set(e,i),i}function ce(e,n){return(0,n.send)(e,"postrobot_hello",{instanceID:ae()},{domain:"*",timeout:-1}).then((function(n){var t=n.origin,r=n.data.instanceID;return ue(e,{domain:t}),{win:e,domain:t,instanceID:r}}))}function se(e,n){var t=n.send;return ie("windowInstanceIDPromises").getOrSet(e,(function(){return ce(e,{send:t}).then((function(e){return e.instanceID}))}))}function de(e){ie("knownWindows").set(e,!0)}function fe(e){return"object"==typeof e&&null!==e&&"string"==typeof e.__type__}function le(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"array":"function"==typeof e?"function":"object"==typeof e?e instanceof Error?"error":"function"==typeof e.then?"promise":"[object RegExp]"==={}.toString.call(e)?"regex":"[object Date]"==={}.toString.call(e)?"date":"object":"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":void 0}function pe(e,n){return{__type__:e,__val__:n}}var he,we=((te={}).function=function(){},te.error=function(e){return pe("error",{message:e.message,stack:e.stack,code:e.code,data:e.data})},te.promise=function(){},te.regex=function(e){return pe("regex",e.source)},te.date=function(e){return pe("date",e.toJSON())},te.array=function(e){return e},te.object=function(e){return e},te.string=function(e){return e},te.number=function(e){return e},te.boolean=function(e){return e},te.null=function(e){return e},te),ve={},me=((he={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},he.error=function(e){var n=e.stack,t=e.code,r=e.data,o=new Error(e.message);return o.code=t,r&&(o.data=r),o.stack=n+"\n\n"+o.stack,o},he.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},he.regex=function(e){return new RegExp(e)},he.date=function(e){return new Date(e)},he.array=function(e){return e},he.object=function(e){return e},he.string=function(e){return e},he.number=function(e){return e},he.boolean=function(e){return e},he.null=function(e){return e},he),ye={};function ge(){for(var e=ne("idToProxyWindow"),n=0,t=e.keys();n<t.length;n++){var r=t[n];e.get(r).shouldClean()&&e.del(r)}}function Ee(e,n){var t=n.send,r=n.id,o=void 0===r?L():r,i=e.then((function(e){if(f(e))return l(e).name})),a=e.then((function(e){if(m(e))throw new Error("Window is closed, can not determine type");return u(e)?"popup":"iframe"}));return i.catch(U),a.catch(U),{id:o,getType:function(){return a},getInstanceID:B((function(){return e.then((function(e){return se(e,{send:t})}))})),close:function(){return e.then(P)},getName:function(){return e.then((function(e){if(!m(e))return f(e)?l(e).name:i}))},focus:function(){return e.then((function(e){e.focus()}))},isClosed:function(){return e.then((function(e){return m(e)}))},setLocation:function(n){return e.then((function(e){var t=window.location.protocol+"//"+window.location.host;if(0===n.indexOf("/"))n=""+t+n;else if(!n.match(/^https?:\/\//)&&0!==n.indexOf(t))throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(n));if(f(e))try{if(e.location&&"function"==typeof e.location.replace)return void e.location.replace(n)}catch(e){}e.location=n}))},setName:function(n){return e.then((function(e){var t=f(e),r=function(e){if(f(e))return l(e).frameElement;for(var n=0,t=document.querySelectorAll("iframe");n<t.length;n++){var r=t[n];if(r&&r.contentWindow&&r.contentWindow===e)return r}}(e);if(!t)throw new Error("Can not set name for cross-domain window: "+n);l(e).name=n,r&&r.setAttribute("name",n),i=R.resolve(n)}))}}}new R((function(e){if(window.document&&window.document.body)return e(window.document.body);var n=setInterval((function(){if(window.document&&window.document.body)return clearInterval(n),e(window.document.body)}),10)}));var Pe=function(){function e(e){var n=e.send,t=e.win,r=e.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new R,this.serializedWindow=r||Ee(this.actualWindowPromise,{send:n}),ne("idToProxyWindow").set(this.getID(),this),t&&this.setWindow(t,{send:n})}var n=e.prototype;return n.getID=function(){return this.serializedWindow.id},n.getType=function(){return this.serializedWindow.getType()},n.isPopup=function(){return this.getType().then((function(e){return"popup"===e}))},n.setLocation=function(e){var n=this;return this.serializedWindow.setLocation(e).then((function(){return n}))},n.getName=function(){return this.serializedWindow.getName()},n.setName=function(e){var n=this;return this.serializedWindow.setName(e).then((function(){return n}))},n.close=function(){var e=this;return this.serializedWindow.close().then((function(){return e}))},n.focus=function(){var e=this,n=this.isPopup(),t=this.getName(),r=R.hash({isPopup:n,name:t}).then((function(e){var n=e.name;e.isPopup&&n&&window.open("",n)})),o=this.serializedWindow.focus();return R.all([r,o]).then((function(){return e}))},n.isClosed=function(){return this.serializedWindow.isClosed()},n.getWindow=function(){return this.actualWindow},n.setWindow=function(e,n){var t=n.send;this.actualWindow=e,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=Ee(this.actualWindowPromise,{send:t,id:this.getID()}),ie("winToProxyWindow").set(e,this)},n.awaitWindow=function(){return this.actualWindowPromise},n.matchWindow=function(e,n){var t=this,r=n.send;return R.try((function(){return t.actualWindow?e===t.actualWindow:R.hash({proxyInstanceID:t.getInstanceID(),knownWindowInstanceID:se(e,{send:r})}).then((function(n){var o=n.proxyInstanceID===n.knownWindowInstanceID;return o&&t.setWindow(e,{send:r}),o}))}))},n.unwrap=function(){return this.actualWindow||this},n.getInstanceID=function(){return this.serializedWindow.getInstanceID()},n.shouldClean=function(){return Boolean(this.actualWindow&&m(this.actualWindow))},n.serialize=function(){return this.serializedWindow},e.unwrap=function(n){return e.isProxyWindow(n)?n.unwrap():n},e.serialize=function(n,t){var r=t.send;return ge(),e.toProxyWindow(n,{send:r}).serialize()},e.deserialize=function(n,t){var r=t.send;return ge(),ne("idToProxyWindow").get(n.id)||new e({serializedWindow:n,send:r})},e.isProxyWindow=function(e){return Boolean(e&&!E(e)&&e.isProxyWindow)},e.toProxyWindow=function(n,t){var r=t.send;if(ge(),e.isProxyWindow(n))return n;var o=n;return ie("winToProxyWindow").get(o)||new e({win:o,send:r})},e}();function be(e,n,t,r,o){var i=ie("methodStore"),a=ne("proxyWindowMethods");Pe.isProxyWindow(r)?a.set(e,{val:n,name:t,domain:o,source:r}):(a.del(e),i.getOrSet(r,(function(){return{}}))[e]={domain:o,name:t,val:n,source:r})}function _e(e,n){var t=ie("methodStore"),r=ne("proxyWindowMethods");return t.getOrSet(e,(function(){return{}}))[n]||r.get(n)}function Oe(e,n,t,r,o){var i,a,u;a=(i={on:o.on,send:o.send}).on,u=i.send,ne("builtinListeners").getOrSet("functionCalls",(function(){return a("postrobot_method",{domain:"*"},(function(e){var n=e.source,t=e.origin,r=e.data,o=r.id,i=r.name,a=_e(n,o);if(!a)throw new Error("Could not find method '"+i+"' with id: "+r.id+" in "+d(window));var c=a.source,s=a.domain,f=a.val;return R.try((function(){if(!g(s,t))throw new Error("Method '"+r.name+"' domain "+JSON.stringify(G(a.domain)?a.domain.source:a.domain)+" does not match origin "+t+" in "+d(window));if(Pe.isProxyWindow(c))return c.matchWindow(n,{send:u}).then((function(e){if(!e)throw new Error("Method call '"+r.name+"' failed - proxy window does not match source in "+d(window))}))})).then((function(){return f.apply({source:n,origin:t},r.args)}),(function(e){return R.try((function(){if(f.onError)return f.onError(e)})).then((function(){var n,t;throw e.stack&&(e.stack="Remote call to "+i+"("+(void 0===(n=r.args)&&(n=[]),(t=n,[].slice.call(t)).map((function(e){return"string"==typeof e?"'"+e+"'":void 0===e?"undefined":null===e?"null":"boolean"==typeof e?e.toString():Array.isArray(e)?"[ ... ]":"object"==typeof e?"{ ... }":"function"==typeof e?"() => { ... }":"<"+typeof e+">"})).join(", ")+") failed\n\n")+e.stack),e}))})).then((function(e){return{result:e,id:o,name:i}}))}))}));var c=t.__id__||L();e=Pe.unwrap(e);var s=t.__name__||t.name||r;return"string"==typeof s&&"function"==typeof s.indexOf&&0===s.indexOf("anonymous::")&&(s=s.replace("anonymous::",r+"::")),Pe.isProxyWindow(e)?(be(c,t,s,e,n),e.awaitWindow().then((function(e){be(c,t,s,e,n)}))):be(c,t,s,e,n),pe("cross_domain_function",{id:c,name:s})}function Te(e,n,t,r){var o,i=r.on,a=r.send;return function(e,n){void 0===n&&(n=ve);var t=JSON.stringify(e,(function(e){var t=this[e];if(fe(this))return t;var r=le(t);if(!r)return t;var o=n[r]||we[r];return o?o(t,e):t}));return void 0===t?"undefined":t}(t,((o={}).promise=function(t,r){return function(e,n,t,r,o){return pe("cross_domain_zalgo_promise",{then:Oe(e,n,(function(e,n){return t.then(e,n)}),r,{on:o.on,send:o.send})})}(e,n,t,r,{on:i,send:a})},o.function=function(t,r){return Oe(e,n,t,r,{on:i,send:a})},o.object=function(e){return E(e)||Pe.isProxyWindow(e)?pe("cross_domain_window",Pe.serialize(e,{send:a})):e},o))}function Se(e,n,t,r){var o,i=r.send;return function(e,n){if(void 0===n&&(n=ye),"undefined"!==e)return JSON.parse(e,(function(e,t){if(fe(this))return t;var r,o;if(fe(t)?(r=t.__type__,o=t.__val__):(r=le(t),o=t),!r)return o;var i=n[r]||me[r];return i?i(o,e):o}))}(t,((o={}).cross_domain_zalgo_promise=function(e){return function(e,n,t){return new R(t.then)}(0,0,e)},o.cross_domain_function=function(t){return function(e,n,t,r){var o=t.id,i=t.name,a=r.send,u=function(t){function r(){var u=arguments;return Pe.toProxyWindow(e,{send:a}).awaitWindow().then((function(e){var c=_e(e,o);if(c&&c.val!==r)return c.val.apply({source:window,origin:d()},u);var s=[].slice.call(u);return t.fireAndForget?a(e,"postrobot_method",{id:o,name:i,args:s},{domain:n,fireAndForget:!0}):a(e,"postrobot_method",{id:o,name:i,args:s},{domain:n,fireAndForget:!1}).then((function(e){return e.data.result}))})).catch((function(e){throw e}))}return void 0===t&&(t={}),r.__name__=i,r.__origin__=n,r.__source__=e,r.__id__=o,r.origin=n,r},c=u();return c.fireAndForget=u({fireAndForget:!0}),c}(e,n,t,{send:i})},o.cross_domain_window=function(e){return Pe.deserialize(e,{send:i})},o))}var xe={};function Ie(e,n,t,r){var o=r.on,i=r.send;return R.try((function(){var r=ie().getOrSet(e,(function(){return{}}));return r.buffer=r.buffer||[],r.buffer.push(t),r.flush=r.flush||R.flush().then((function(){if(m(e))throw new Error("Window is closed");var t,a=Te(e,n,((t={}).__post_robot_10_0_42__=r.buffer||[],t),{on:o,send:i});delete r.buffer;for(var u=Object.keys(xe),c=[],s=0;s<u.length;s++){var d=u[s];try{xe[d](e,a,n)}catch(e){c.push(e)}}if(c.length===u.length)throw new Error("All post-robot messaging strategies failed:\n\n"+c.map((function(e,n){return n+". "+Y(e)})).join("\n\n"))})),r.flush.then((function(){delete r.flush}))})).then(U)}function Ne(e){return ne("responseListeners").get(e)}function Re(e){ne("responseListeners").del(e)}function Ce(e){return ne("erroredResponseListeners").has(e)}function ke(e){var n=e.name,t=e.win,r=e.domain,o=ie("requestListeners");if("*"===t&&(t=null),"*"===r&&(r=null),!n)throw new Error("Name required to get request listener");for(var i=0,a=[t,oe()];i<a.length;i++){var u=a[i];if(u){var c=o.get(u);if(c){var s=c[n];if(s){if(r&&"string"==typeof r){if(s[r])return s[r];if(s.__domain_regex__)for(var d=0,f=s.__domain_regex__;d<f.length;d++){var l=f[d],p=l.listener;if(g(l.regex,r))return p}}if(s["*"])return s["*"]}}}}}function je(e,n,t,r){var o=r.on,i=r.send,a=ke({name:t.name,win:e,domain:n}),u="postrobot_method"===t.name&&t.data&&"string"==typeof t.data.name?t.data.name+"()":t.name;function c(r,a,c){return R.flush().then((function(){if(!t.fireAndForget&&!m(e))try{return Ie(e,n,{id:L(),origin:d(window),type:"postrobot_message_response",hash:t.hash,name:t.name,ack:r,data:a,error:c},{on:o,send:i})}catch(e){throw new Error("Send response message failed for "+u+" in "+d()+"\n\n"+Y(e))}}))}return R.all([R.flush().then((function(){if(!t.fireAndForget&&!m(e))try{return Ie(e,n,{id:L(),origin:d(window),type:"postrobot_message_ack",hash:t.hash,name:t.name},{on:o,send:i})}catch(e){throw new Error("Send ack message failed for "+u+" in "+d()+"\n\n"+Y(e))}})),R.try((function(){if(!a)throw new Error("No handler found for post message: "+t.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!g(a.domain,n))throw new Error("Request origin "+n+" does not match domain "+a.domain.toString());return a.handler({source:e,origin:n,data:t.data})})).then((function(e){return c("success",e)}),(function(e){return c("error",null,e)}))]).then(U).catch((function(e){if(a&&a.handleError)return a.handleError(e);throw e}))}function We(e,n,t){if(!Ce(t.hash)){var r=Ne(t.hash);if(!r)throw new Error("No handler found for post message ack for message: "+t.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!g(r.domain,n))throw new Error("Ack origin "+n+" does not match domain "+r.domain.toString());if(e!==r.win)throw new Error("Ack source does not match registered window")}catch(e){r.promise.reject(e)}r.ack=!0}}function Ae(e,n,t){if(!Ce(t.hash)){var o,i=Ne(t.hash);if(!i)throw new Error("No handler found for post message response for message: "+t.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!g(i.domain,n))throw new Error("Response origin "+n+" does not match domain "+(o=i.domain,Array.isArray(o)?"("+o.join(" | ")+")":r(o)?"RegExp("+o.toString():o.toString()));if(e!==i.win)throw new Error("Response source does not match registered window");Re(t.hash),"error"===t.ack?i.promise.reject(t.error):"success"===t.ack&&i.promise.resolve({source:e,origin:n,data:t.data})}}function Le(e,n){var t=n.on,r=n.send,o=ne("receivedMessages");try{if(!window||window.closed||!e.source)return}catch(e){return}var i=e.source,a=e.origin,u=function(e,n,t,r){var o,i=r.on,a=r.send;try{o=Se(n,t,e,{on:i,send:a})}catch(e){return}if(o&&"object"==typeof o&&null!==o){var u=o.__post_robot_10_0_42__;if(Array.isArray(u))return u}}(e.data,i,a,{on:t,send:r});if(u){de(i);for(var c=0;c<u.length;c++){var s=u[c];if(o.has(s.id))return;if(o.set(s.id,!0),m(i)&&!s.fireAndForget)return;0===s.origin.indexOf("file:")&&(a="file://");try{"postrobot_message_request"===s.type?je(i,a,s,{on:t,send:r}):"postrobot_message_response"===s.type?Ae(i,a,s):"postrobot_message_ack"===s.type&&We(i,a,s)}catch(e){setTimeout((function(){throw e}),0)}}}}function De(e,n,t){if(!e)throw new Error("Expected name");if("function"==typeof(n=n||{})&&(t=n,n={}),!t)throw new Error("Expected handler");(n=n||{}).name=e,n.handler=t||n.handler;var r=n.window,o=n.domain,i=function e(n,t){var r=n.name,o=n.win,i=n.domain,a=ie("requestListeners");if(!r||"string"!=typeof r)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var u=[],c=0,s=o;c<s.length;c++)u.push(e({name:r,domain:i,win:s[c]},t));return{cancel:function(){for(var e=0;e<u.length;e++)u[e].cancel()}}}if(Array.isArray(i)){for(var d=[],f=0,l=i;f<l.length;f++)d.push(e({name:r,win:o,domain:l[f]},t));return{cancel:function(){for(var e=0;e<d.length;e++)d[e].cancel()}}}var p=ke({name:r,win:o,domain:i});if(o&&"*"!==o||(o=oe()),i=i||"*",p)throw o&&i?new Error("Request listener already exists for "+r+" on domain "+i.toString()+" for "+(o===oe()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+r+" for "+(o===oe()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+r+" on domain "+i.toString()):new Error("Request listener already exists for "+r);var h,w,v=a.getOrSet(o,(function(){return{}})),m=V(v,r,(function(){return{}})),y=i.toString();return G(i)?(h=V(m,"__domain_regex__",(function(){return[]}))).push(w={regex:i,listener:t}):m[y]=t,{cancel:function(){delete m[y],w&&(h.splice(h.indexOf(w,1)),h.length||delete m.__domain_regex__),Object.keys(m).length||delete v[r],o&&!Object.keys(v).length&&a.del(o)}}}({name:e,win:r,domain:o},{handler:n.handler,handleError:n.errorHandler||function(e){throw e},window:r,domain:o||"*",name:e});return{cancel:function(){i.cancel()}}}function Me(e,n,t){"function"==typeof(n=n||{})&&(t=n,n={});var r,o=new R;return n.errorHandler=function(e){r.cancel(),o.reject(e)},r=De(e,n,(function(e){if(r.cancel(),o.resolve(e),t)return t(e)})),o.cancel=r.cancel,o}xe.postrobot_post_message=function(e,n,t){0===t.indexOf("file:")&&(t="*"),e.postMessage(n,t)};var qe=function e(n,t,r,o){var i=(o=o||{}).domain||"*",u=o.timeout||-1,c=o.timeout||5e3,s=o.fireAndForget||!1;return R.try((function(){if(function(e,n,t){if(!e)throw new Error("Expected name");if(t&&"string"!=typeof t&&!Array.isArray(t)&&!G(t))throw new TypeError("Can not send "+e+". Expected domain "+JSON.stringify(t)+" to be a string, array, or regex");if(m(n))throw new Error("Can not send "+e+". Target window is closed")}(t,n,i),function(e,n){var t=y(n);if(t)return t===e;if(n===e)return!1;if(function(e){void 0===e&&(e=window);try{if(e.top)return e.top}catch(e){}if(a(e)===e)return e;try{if(p(window,e)&&window.top)return window.top}catch(e){}try{if(p(e,window)&&window.top)return window.top}catch(e){}for(var n=0,t=function e(n){for(var t=[],r=0,o=h(n);r<o.length;r++){var i=o[r];t.push(i);for(var a=0,u=e(i);a<u.length;a++)t.push(u[a])}return t}(e);n<t.length;n++){var r=t[n];try{if(r.top)return r.top}catch(e){}if(a(r)===r)return r}}(n)===n)return!1;for(var r=0,o=h(e);r<o.length;r++)if(o[r]===n)return!0;return!1}(window,n))return function(e,n,t){void 0===n&&(n=5e3),void 0===t&&(t="Window");var r=function(e){return ie("helloPromises").getOrSet(e,(function(){return new R}))}(e);return-1!==n&&(r=r.timeout(n,new Error(t+" did not load after "+n+"ms"))),r}(n,c)})).then((function(t){return function(e,n,t,r){var o=r.send;return R.try((function(){return"string"==typeof n?n:R.