post-robot
Advanced tools
Comparing version 10.0.3 to 10.0.4
@@ -141,5 +141,5 @@ "use strict"; | ||
} else if (ackTimeout === 0) { | ||
return promise.reject(new Error(`No ack for postMessage ${name} in ${(0, _src2.getDomain)()} in ${totalAckTimeout}ms`)); | ||
return promise.reject(new Error(`No ack for postMessage ${logName} in ${(0, _src2.getDomain)()} in ${totalAckTimeout}ms`)); | ||
} else if (resTimeout === 0) { | ||
return promise.reject(new Error(`No response for postMessage ${name} in ${(0, _src2.getDomain)()} in ${totalResTimeout}ms`)); | ||
return promise.reject(new Error(`No response for postMessage ${logName} in ${(0, _src2.getDomain)()} in ${totalResTimeout}ms`)); | ||
} | ||
@@ -146,0 +146,0 @@ |
@@ -103,2 +103,8 @@ "use strict"; | ||
}).then(() => { | ||
// $FlowFixMe | ||
if (err.stack) { | ||
// $FlowFixMe | ||
err.stack = `Remote call to ${name}()\n\n${err.stack}`; | ||
} | ||
throw err; | ||
@@ -105,0 +111,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!function(n,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():n.postRobot=r()}("undefined"!=typeof self?self:this,function(){return function(n){var r={};function t(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=n,t.c=r,t.d=function(n,r,e){t.o(n,r)||Object.defineProperty(n,r,{enumerable:!0,get:e})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,r){if(1&r&&(n=t(n)),8&r)return n;if(4&r&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&r&&"string"!=typeof n)for(var o in n)t.d(e,o,function(r){return n[r]}.bind(null,o));return e},t.n=function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(r,"a",r),r},t.o=function(n,r){return{}.hasOwnProperty.call(n,r)},t.p="",t(t.s=0)}([function(n,r,t){"use strict";t.r(r);var e={};function o(n){return"[object RegExp]"==={}.toString.call(n)}t.r(e),t.d(e,"WeakMap",function(){return Z});var i={u:"mock:",h:"file:",v:"about:"},u="*",f="Call was rejected by callee.\r\n";function c(n){return void 0===n&&(n=window),n.location.protocol===i.v}function a(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function s(n){if(n&&!a(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function w(n){var r=(n=n||window).location;if(!r)throw new Error("Can not read window location");var t=r.protocol;if(!t)throw new Error("Can not read window protocol");if(t===i.h)return i.h+"//";if(t===i.v){var e=a(n);return e&&d()?w(e):i.v+"//"}var o=r.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function h(n){var r=w(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(i.u)?n.mockDomain:r}function v(n){try{if(n===window)return!0}catch(n){}try{var r=Object.getOwnPropertyDescriptor(n,"location");if(r&&!1===r.enumerable)return!1}catch(n){}try{if(c(n)&&d())return!0}catch(n){}try{if(w(n)===w(window))return!0}catch(n){}return!1}function m(n){if(!v(n))return!1;try{if(n===window)return!0;if(c(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function l(n,r){if(!n||!r)return!1;var t=a(r);return t?t===n:-1!==function(n){var r=[];try{for(;n.parent!==n;)r.push(n.parent),n=n.parent}catch(n){}return r}(r).indexOf(n)}function p(n){var r,t,e=[];try{r=n.frames}catch(t){r=n}try{t=r.length}catch(n){}if(0===t)return e;if(t){for(var o=0;o<t;o++){var i=void 0;try{i=r[o]}catch(n){continue}e.push(i)}return e}for(var u=0;u<100;u++){var f=void 0;try{f=r[u]}catch(n){return e}if(!f)return e;e.push(f)}return e}function y(n){for(var r=[],t=0,e=p(n);t<e.length;t++){var o=e[t];r.push(o);for(var i=0,u=y(o);i<u.length;i++)r.push(u[i])}return r}function g(n){if(n){try{if(n.top)return n.top}catch(n){}if(a(n)===n)return n;try{if(l(window,n)&&window.top)return window.top}catch(n){}try{if(l(n,window)&&window.top)return window.top}catch(n){}for(var r=0,t=y(n);r<t.length;r++){var e=t[r];try{if(e.top)return e.top}catch(n){}if(a(e)===e)return e}}}function E(n){var r=g(n);if(!r)throw new Error("Can not determine top window");return[].concat(y(r),[r])}var b=[],_=[];function x(n,r){void 0===r&&(r=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==f}if(r&&m(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var t=function(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}(b,n);if(-1!==t){var e=_[t];if(e&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var r=n.ownerDocument;return!(!r||!r.documentElement||r.documentElement.contains(n))}(e))return!0}return!1}function M(n){return(n=n||window).navigator.mockUserAgent||n.navigator.userAgent}function O(n,r){for(var t=p(n),e=0;e<t.length;e++){var o=t[e];try{if(m(o)&&o.name===r&&-1!==t.indexOf(o))return o}catch(n){}}try{if(-1!==t.indexOf(n.frames[r]))return n.frames[r]}catch(n){}try{if(-1!==t.indexOf(n[r]))return n[r]}catch(n){}}function W(n,r){return n===s(r)}function j(n){return s(n=n||window)||a(n)||void 0}function R(n,r){for(var t=0;t<n.length;t++)for(var e=n[t],o=0;o<r.length;o++)if(e===r[o])return!0;return!1}function N(n,r){var t=g(n)||n,e=g(r)||r;try{if(t&&e)return t===e}catch(n){}var o=E(n),i=E(r);if(R(o,i))return!0;var u=s(t),f=s(e);return!(u&&R(E(u),i)||(f&&R(E(f),o),1))}function k(n,r){if("string"==typeof n){if("string"==typeof r)return n===u||r===n;if(o(r))return!1;if(Array.isArray(r))return!1}return o(n)?o(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!o(r)&&n.some(function(n){return k(n,r)}))}function P(n){return n.match(/^(https?|mock|file):\/\//)?n.split("/").slice(0,3).join("/"):h()}function A(n){try{if(n===window)return!0}catch(n){if(n&&n.message===f)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===f)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===f)return!0}return!1}function S(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&n instanceof window.constructor)return!1;var r={}.toString;if(r){var t=r.call(n);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var C,T=[],B=[],I=0;function D(){if(!I&&C){var n=C;C=null,n.resolve()}}function L(){I+=1}function q(){I-=1,D()}var F=function(){function n(n){var r=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=[],n){var t,e,o=!1,i=!1,u=!1;L();try{n(function(n){u?r.resolve(n):(o=!0,t=n)},function(n){u?r.reject(n):(i=!0,e=n)})}catch(n){return q(),void this.reject(n)}q(),u=!0,o?this.resolve(t):i&&this.reject(e)}}var r=n.prototype;return r.resolve=function(n){if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},r.reject=function(n){var r=this;if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not reject promise with another promise");if(!n){var t=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout(function(){r.errorHandled||function(n,r){if(-1===T.indexOf(n)){T.push(n),setTimeout(function(){throw n},1);for(var t=0;t<B.length;t++)B[t](n,r)}}(n,r)},1),this.dispatch(),this},r.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},r.dispatch=function(){var r=this,t=this.resolved,e=this.rejected,o=this.handlers;if(!this.dispatching&&(t||e)){this.dispatching=!0,L();for(var i=function(i){var u=o[i],f=u.onSuccess,c=u.onError,a=u.promise,s=void 0;if(t)try{s=f?f(r.value):r.value}catch(n){return a.reject(n),"continue"}else if(e){if(!c)return a.reject(r.error),"continue";try{s=c(r.error)}catch(n){return a.reject(n),"continue"}}s instanceof n&&(s.resolved||s.rejected)?(s.resolved?a.resolve(s.value):a.reject(s.error),s.errorHandled=!0):S(s)?s instanceof n&&(s.resolved||s.rejected)?s.resolved?a.resolve(s.value):a.reject(s.error):s.then(function(n){a.resolve(n)},function(n){a.reject(n)}):a.resolve(s)},u=0;u<o.length;u++)i(u);o.length=0,this.dispatching=!1,q()}},r.then=function(r,t){if(r&&"function"!=typeof r&&!r.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 e=new n;return this.handlers.push({promise:e,onSuccess:r,onError:t}),this.errorHandled=!0,this.dispatch(),e},r.catch=function(n){return this.then(void 0,n)},r.finally=function(r){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.finally expected a function");return this.then(function(t){return n.try(r).then(function(){return t})},function(t){return n.try(r).then(function(){throw t})})},r.timeout=function(n,r){var t=this;if(this.resolved||this.rejected)return this;var e=setTimeout(function(){t.resolved||t.rejected||t.reject(r||new Error("Promise timed out after "+n+"ms"))},n);return this.then(function(n){return clearTimeout(e),n})},r.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(r){return r instanceof n?r:S(r)?new n(function(n,t){return r.then(n,t)}):(new n).resolve(r)},n.reject=function(r){return(new n).reject(r)},n.asyncReject=function(r){return(new n).asyncReject(r)},n.all=function(r){var t=new n,e=r.length,o=[];if(!e)return t.resolve(o),t;for(var i=function(i){var u=r[i];if(u instanceof n){if(u.resolved)return o[i]=u.value,e-=1,"continue"}else if(!S(u))return o[i]=u,e-=1,"continue";n.resolve(u).then(function(n){o[i]=n,0==(e-=1)&&t.resolve(o)},function(n){t.reject(n)})},u=0;u<r.length;u++)i(u);return 0===e&&t.resolve(o),t},n.hash=function(r){var t={};return n.all(Object.keys(r).map(function(e){return n.resolve(r[e]).then(function(n){t[e]=n})})).then(function(){return t})},n.map=function(r,t){return n.all(r.map(t))},n.onPossiblyUnhandledException=function(n){return function(n){return B.push(n),{cancel:function(){B.splice(B.indexOf(n),1)}}}(n)},n.try=function(r,t,e){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.try expected a function");var o;L();try{o=r.apply(t,e||[])}catch(r){return q(),n.reject(r)}return q(),n.resolve(o)},n.delay=function(r){return new n(function(n){setTimeout(n,r)})},n.isPromise=function(r){return!!(r&&r instanceof n)||S(r)},n.flush=function(){return r=C=C||new n,D(),r;var r},n}();function z(){return(z=Object.assign||function(n){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var e in t)({}).hasOwnProperty.call(t,e)&&(n[e]=t[e])}return n}).apply(this,arguments)}function U(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}var J,G=Object.defineProperty,K=Date.now()%1e9,Z=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,K+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+K,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,r={};return Object.freeze(r),n.set(r,"__testvalue__"),"__testvalue__"===n.get(r)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var r=n.prototype;return r._cleanupClosedWindows=function(){for(var n=this.weakmap,r=this.keys,t=0;t<r.length;t++){var e=r[t];if(A(e)&&x(e)){if(n)try{n.delete(e)}catch(n){}r.splice(t,1),this.values.splice(t,1),t-=1}}},r.isSafeToReadWrite=function(n){return!A(n)},r.set=function(n,r){if(!n)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.set(n,r)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var e=this.name,o=n[e];o&&o[0]===n?o[1]=r:G(n,e,{value:[n,r],writable:!0})}else{this._cleanupClosedWindows();var i=this.keys,u=this.values,f=U(i,n);-1===f?(i.push(n),u.push(r)):u[f]=r}},r.get=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return r.get(n)}catch(n){delete this.weakmap}if(!this.isSafeToReadWrite(n)){this._cleanupClosedWindows();var t=U(this.keys,n);if(-1===t)return;return this.values[t]}var e=n[this.name];if(e&&e[0]===n)return e[1]},r.delete=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];t&&t[0]===n&&(t[0]=t[1]=void 0)}else{this._cleanupClosedWindows();var e=this.keys,o=U(e,n);-1!==o&&(e.splice(o,1),this.values.splice(o,1))}},r.has=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];return!(!t||t[0]!==n)}return this._cleanupClosedWindows(),-1!==U(this.keys,n)},r.getOrSet=function(n,r){if(this.has(n))return this.get(n);var t=r();return this.set(n,t),t},n}();function H(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(n){if("function"==typeof btoa)return btoa(n);if("undefined"!=typeof Buffer)return Buffer.from(n,"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 Y(){}function Q(n){return"[object RegExp]"==={}.toString.call(n)}function X(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var V=5e3,$=2e3,nn=1e4,rn=-1,tn={g:"postrobot_message_request",_:"postrobot_message_response",M:"postrobot_message_ack"},en={O:"postrobot_method",W:"postrobot_hello",j:"postrobot_open_tunnel"},on="__postrobot_bridge__",un="*",fn={R:"cross_domain_zalgo_promise",N:"cross_domain_function",k:"cross_domain_window"};function cn(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_3__:n.__post_robot_10_0_3__=n.__post_robot_10_0_3__||{}}var an=function(){return{}};function sn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=an),X(cn(),n,function(){var n=r();return{has:function(r){return n.hasOwnProperty(r)},get:function(r,t){return n.hasOwnProperty(r)?n[r]:t},set:function(r,t){return n[r]=t,t},del:function(r){delete n[r]},getOrSet:function(r,t){return X(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var dn=function(){};function wn(){var n=cn();return n.P=n.P||new dn,n.P}function hn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=an),sn("windowStore").getOrSet(n,function(){var t=new Z,e=function(n){return t.getOrSet(n,r)};return{has:function(r){return e(r).hasOwnProperty(n)},get:function(r,t){var o=e(r);return o.hasOwnProperty(n)?o[n]:t},set:function(r,t){return e(r)[n]=t,t},del:function(r){delete e(r)[n]},getOrSet:function(r,t){return X(e(r),n,t)}}})}function vn(){return sn("instance").getOrSet("instanceID",H)}function mn(n){return hn("helloPromises").getOrSet(n,function(){return new F})}function ln(n,r){return(0,r.send)(n,en.W,{instanceID:vn()},{domain:un,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return mn(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function pn(n,r){var t=r.send;return hn("windowInstanceIDPromises").getOrSet(n,function(){return ln(n,{send:t}).then(function(n){return n.instanceID})})}function yn(n,r,t){void 0===r&&(r=5e3),void 0===t&&(t="Window");var e=mn(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}function gn(n){hn("knownWindows").set(n,!0)}var En,bn={A:"function",ERROR:"error",S:"promise",C:"regex",T:"date",B:"array",I:"object",D:"string",L:"number",q:"boolean",F:"null",U:"undefined"};function _n(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function xn(n){return void 0===n?bn.U:null===n?bn.F:Array.isArray(n)?bn.B:"function"==typeof n?bn.A:"object"==typeof n?n instanceof Error?bn.ERROR:"function"==typeof n.then?bn.S:"[object RegExp]"==={}.toString.call(n)?bn.C:"[object Date]"==={}.toString.call(n)?bn.T:bn.I:"string"==typeof n?bn.D:"number"==typeof n?bn.L:"boolean"==typeof n?bn.q:void 0}function Mn(n,r){return{__type__:n,__val__:r}}var On,Wn=((En={})[bn.A]=function(){},En[bn.ERROR]=function(n){return Mn(bn.ERROR,{message:n.message,stack:n.stack,code:n.code})},En[bn.S]=function(){},En[bn.C]=function(n){return Mn(bn.C,n.source)},En[bn.T]=function(n){return Mn(bn.T,n.toJSON())},En[bn.B]=function(n){return n},En[bn.I]=function(n){return n},En[bn.D]=function(n){return n},En[bn.L]=function(n){return n},En[bn.q]=function(n){return n},En[bn.F]=function(n){return n},En),jn={},Rn=((On={})[bn.A]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},On[bn.ERROR]=function(n){var r=n.stack,t=n.code,e=new Error(n.message);return e.code=t,e.stack=r+"\n\n"+e.stack,e},On[bn.S]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},On[bn.C]=function(n){return new RegExp(n)},On[bn.T]=function(n){return new Date(n)},On[bn.B]=function(n){return n},On[bn.I]=function(n){return n},On[bn.D]=function(n){return n},On[bn.L]=function(n){return n},On[bn.q]=function(n){return n},On[bn.F]=function(n){return n},On),Nn={};function kn(){return!!M(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Pn(n){return!N(window,n)}function An(n,r){if(n){if(h()!==P(n))return!0}else if(r&&!m(r))return!0;return!1}function Sn(n){var r=n.win,t=n.domain;return!(!kn()||t&&!An(t,r)||r&&!Pn(r))}function Cn(n){var r=(n=n||P(n)).replace(/[^a-zA-Z0-9]+/g,"_");return on+"_"+r}function Tn(){return Boolean(window.name&&window.name===Cn(h()))}var Bn=new F(function(n){if(window.document&&window.document.body)return n(window.document.body);var r=setInterval(function(){if(window.document&&window.document.body)return clearInterval(r),n(window.document.body)},10)});function In(n){hn("remoteWindowPromises").getOrSet(n,function(){return new F})}function Dn(n){var r=hn("remoteWindowPromises").get(n);if(!r)throw new Error("Remote window promise not found");return r}function Ln(n,r,t){Dn(n).resolve(function(e,o,i){if(e!==n)throw new Error("Remote window does not match window");if(!k(o,r))throw new Error("Remote domain "+o+" does not match domain "+r);t.fireAndForget(i)})}function qn(n,r){Dn(n).reject(r).catch(Y)}function Fn(n){for(var r=n.win,t=n.name,e=n.domain,o=sn("popupWindowsByName"),i=hn("popupWindowsByWin"),u=0,f=o.keys();u<f.length;u++){var c=f[u];x(o.get(c).win)&&o.del(c)}var a=i.getOrSet(r,function(){return t?o.getOrSet(t,function(){return{win:r,name:t}}):{win:r}});if(a.win&&a.win!==r)throw new Error("Different window already linked for window: "+(t||"undefined"));if(t){if(a.name&&a.name!==t)throw new Error("Different window already linked for name "+t+": "+a.name);a.name=t,o.set(t,a)}return e&&(a.domain=e,In(r)),i.set(r,a),a}function zn(n){var r,t=n.on,e=n.send,o=n.receiveMessage;r=window.open,window.open=function(n,t,e,o){var u=r.call(this,function(n){if(0!==P(n).indexOf(i.u))return n;throw new Error("Mock urls not supported out of test mode")}(n),t,e,o);return u?(Fn({win:u,name:t,domain:n?P(n):null}),u):u},function(n){var r=n.on,t=n.send,e=n.receiveMessage,o=sn("popupWindowsByName");r(en.j,function(n){var i=n.source,u=n.origin,f=n.data,c=sn("bridges").get(u);if(!c)throw new Error("Can not find bridge promise for domain "+u);return c.then(function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+u);if(!f.name)throw new Error("Register window expected to be passed window name");if(!f.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(f.name))throw new Error("Window with name "+f.name+" does not exist, or was not opened by this window");if(!o.get(f.name).domain)throw new Error("We do not have a registered domain for window "+f.name);if(o.get(f.name).domain!==u)throw new Error("Message origin "+u+" does not matched registered window origin "+o.get(f.name).domain);return Ln(o.get(f.name).win,u,f.sendMessage),{sendMessage:function(n){if(window&&!window.closed){var i=o.get(f.name);if(i)try{e({data:n,origin:i.domain,source:i.win},{on:r,send:t})}catch(n){F.reject(n)}}}}})})}({on:t,send:e,receiveMessage:o}),function(n){var r=n.send;cn(window).openTunnelToParent=function(n){var t=n.name,e=n.source,o=n.canary,i=n.sendMessage,u=sn("tunnelWindows"),f=a(window);if(!f)throw new Error("No parent window found to open tunnel to");var c=function(n){var r=n.name,t=n.source,e=n.canary,o=n.sendMessage;!function(){for(var n=sn("tunnelWindows"),r=0,t=n.keys();r<t.length;r++){var e=t[r];x(n[e].source)&&n.del(e)}}();var i=H();return sn("tunnelWindows").set(i,{name:r,source:t,canary:e,sendMessage:o}),i}({name:t,source:e,canary:o,sendMessage:i});return r(f,en.j,{name:t,sendMessage:function(){var n=u.get(c);if(n&&n.source&&!x(n.source)){try{n.canary()}catch(n){return}n.sendMessage.apply(this,arguments)}}},{domain:un})}}({on:t,send:e}),function(n){var r=n.on,t=n.send,e=n.receiveMessage;F.try(function(){var n,o=s(window);if(o&&Sn({win:o}))return In(o),(n=o,hn("remoteBridgeAwaiters").getOrSet(n,function(){return F.try(function(){var r=O(n,Cn(h()));if(!r)throw new Error("Bridge not found for domain: "+h());return m(r)&&cn(r)?r:new F(function(n,t){var e,o;e=setInterval(function(){if(r&&m(r)&&cn(r))return clearInterval(e),clearTimeout(o),n(r)},100),o=setTimeout(function(){return clearInterval(e),t(new Error("Bridge not found for domain: "+h()))},2e3)})})})).then(function(n){return window.name?cn(n).openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(n){if(window&&!window.closed)try{e({data:n,origin:this.origin,source:this.source},{on:r,send:t})}catch(n){F.reject(n)}}}).then(function(n){var r=n.source,t=n.origin,e=n.data;if(r!==o)throw new Error("Source does not match opener");Ln(r,t,e.sendMessage)}).catch(function(n){throw qn(o,n),n}):qn(o,new Error("Can not register with opener: window does not have a name"))})})}({on:t,send:e,receiveMessage:o})}function Un(){for(var n=sn("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}var Jn=function(){function n(n,r,t){var e=t.send;this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.serializedWindow=n,this.actualWindowPromise=new F,r&&this.setWindow(r),this.serializedWindow.getInstanceID=function(n){var r={};function t(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];var i=function(n){try{return JSON.stringify([].slice.call(n),function(n,r){return"function"==typeof r?"memoize["+function(n){if(J=J||new Z,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var r=J.get(n);return r||(r=typeof n+":"+H(),J.set(n,r)),r}(r)+"]":r})}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(e);return r.hasOwnProperty(i)?r[i]:(r[i]=n.apply(this,arguments).finally(function(){delete r[i]}),r[i])}return t.reset=function(){r={}},t}(this.serializedWindow.getInstanceID),this.send=e}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return"popup"===this.getType()},r.isIframe=function(){return"iframe"===this.getType()},r.setLocation=function(n){var r=this;return F.try(function(){if(!r.actualWindow)return r.serializedWindow.setLocation(n);r.actualWindow.location=n}).then(function(){return r})},r.setName=function(n){var r=this;return F.try(function(){if(!r.actualWindow)return r.serializedWindow.setName(n);if(!m(r.actualWindow))throw new Error("Can not set name for window on different domain");r.actualWindow.name=n,r.actualWindow.frameElement&&r.actualWindow.frameElement.setAttribute("name",n),Fn({win:r.actualWindow,name:n})}).then(function(){return r})},r.close=function(){var n=this;return F.try(function(){if(!n.actualWindow)return n.serializedWindow.close();n.actualWindow.close()}).then(function(){return n})},r.focus=function(){var n=this;return F.try(function(){return n.actualWindow&&n.actualWindow.focus(),n.serializedWindow.focus()}).then(function(){return n})},r.isClosed=function(){var n=this;return F.try(function(){return n.actualWindow?x(n.actualWindow):n.serializedWindow.isClosed()})},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return F.try(function(){return r.actualWindow?n===r.actualWindow:F.all([r.getInstanceID(),pn(n,{send:r.send})]).then(function(t){var e=t[0]===t[1];return e&&r.setWindow(n),e})})},r.unwrap=function(){return this.actualWindow||this},r.getInstanceID=function(){return this.actualWindow?pn(this.actualWindow,{send:this.send}):this.serializedWindow.getInstanceID()},r.serialize=function(){return this.serializedWindow},r.shouldClean=function(){return this.actualWindow&&x(this.actualWindow)},n.unwrap=function(r){return n.isProxyWindow(r)?r.unwrap():r},n.serialize=function(r,t){var e=t.send;return Un(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,o=t.send;return Un(),sn("idToProxyWindow").getOrSet(r.id,function(){return new n(r,null,{on:e,send:o})})},n.isProxyWindow=function(n){return Boolean(n&&!A(n)&&n.isProxyWindow)},n.toProxyWindow=function(r,t){var e=t.send;return Un(),n.isProxyWindow(r)?r:hn("winToProxyWindow").getOrSet(r,function(){var t=H();return sn("idToProxyWindow").set(t,new n({id:t,type:s(r)?"popup":"iframe",getInstanceID:function(){return pn(r,{send:e})},close:function(){return F.try(function(){r.close()})},focus:function(){return F.try(function(){r.focus()})},isClosed:function(){return F.try(function(){return x(r)})},setLocation:function(n){return F.try(function(){if(m(r))try{if(r.location&&"function"==typeof r.location.replace)return void r.location.replace(n)}catch(n){}r.location=n})},setName:function(n){return F.try(function(){Fn({win:r,name:n}),r.name=n})}},r,{send:e}))})},n}();function Gn(n,r,t,e,o){var i=hn("methodStore"),u=sn("proxyWindowMethods");Jn.isProxyWindow(e)?u.set(n,{val:r,name:t,domain:o,source:e}):(u.del(n),i.getOrSet(e,function(){return{}})[n]={domain:o,name:t,val:r,source:e})}function Kn(n,r){var t=hn("methodStore"),e=sn("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function Zn(n,r,t,e,o){!function(n){var r=o.on;sn("builtinListeners").getOrSet("functionCalls",function(){return r(en.O,{domain:un},function(n){var r=n.source,t=n.origin,e=n.data,o=e.id,i=e.name,u=Kn(r,o);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+h(window));var f=u.source,c=u.domain,a=u.val;return F.try(function(){if(!k(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify(Q(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(Jn.isProxyWindow(f))return f.matchWindow(r).then(function(n){if(!n)throw new Error("Method call '"+e.name+"' failed - proxy window does not match source in "+h(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return F.try(function(){if(a.onError)return a.onError(n)}).then(function(){throw n})}).then(function(n){return{result:n,id:o,name:i}})})})}();var i=t.__id__||H();n=Jn.unwrap(n);var u=t.__name__||t.name||e;return Jn.isProxyWindow(n)?(Gn(i,t,u,n,r),n.awaitWindow().then(function(n){Gn(i,t,u,n,r)})):Gn(i,t,u,n,r),Mn(fn.N,{id:i,name:u})}function Hn(n,r,t,e){var o,i=e.on,u=e.send;return function(n,r){void 0===r&&(r=jn);var t=JSON.stringify(n,function(n){var t=this[n];if(_n(this))return t;var e=xn(t);if(!e)return t;var o=r[e]||Wn[e];return o?o(t,n):t});return void 0===t?bn.U:t}(t,((o={})[bn.S]=function(t,e){return function(n,r,t,e,o){return Mn(fn.R,{then:Zn(n,r,function(n,r){return t.then(n,r)},e,{on:o.on,send:o.send})})}(n,r,t,e,{on:i,send:u})},o[bn.A]=function(t,e){return Zn(n,r,t,e,{on:i,send:u})},o[bn.I]=function(n){return A(n)||Jn.isProxyWindow(n)?Mn(fn.k,Jn.serialize(n,{send:u})):n},o))}function Yn(n,r,t,e){var o,i=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=Nn),n!==bn.U)return JSON.parse(n,function(n,t){if(_n(this))return t;var e,o;if(_n(t)?(e=t.__type__,o=t.__val__):(e=xn(t),o=t),!e)return o;var i=r[e]||Rn[e];return i?i(o,n):o})}(t,((o={})[fn.R]=function(n){return new F(n.then)},o[fn.N]=function(t){return function(n,r,e,o){var i=t.id,u=t.name,f=o.send,c=function(t){function e(){var o=arguments;return Jn.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=Kn(n,i);return c&&c.val!==e?c.val.apply({source:window,origin:h()},o):f(n,en.O,{id:i,name:u,args:[].slice.call(o)},{domain:r,fireAndForget:t.fireAndForget}).then(function(n){if(!t.fireAndForget)return n.data.result})}).catch(function(n){throw n})}return void 0===t&&(t={}),e.__name__=u,e.__origin__=r,e.__source__=n,e.__id__=i,e.origin=r,e},a=c();return a.fireAndForget=c({fireAndForget:!0}),a}(n,r,0,{on:i,send:u})},o[fn.k]=function(n){return Jn.deserialize(n,{on:(r={on:i,send:u}).on,send:r.send});var r},o))}var Qn={};function Xn(n,r,t,e){var o,i=e.on,u=e.send;if(x(n))throw new Error("Window is closed");for(var f,c=Hn(n,r,((o={}).__post_robot_10_0_3__=z({id:H(),origin:h(window)},t),o),{on:i,send:u}),a=!1,s=0,d=Object.keys(Qn);s<d.length;s++){var w=d[s];try{Qn[w](n,c,r),a=!0}catch(n){f=f||n}}if(!a)throw f}Qn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[un]).map(function(r){if(0===r.indexOf(i.u)){if(window.location.protocol===i.h)return un;if(!v(n))throw new Error("Attempting to send messsage to mock domain "+r+", but window is actually cross-domain");return w(n)}return 0===r.indexOf(i.h)?un:r}).forEach(function(t){n.postMessage(r,t)})},Qn.postrobot_bridge=function(n,r,t){if(kn()||Tn()){if(m(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==N(window,n))throw new Error("Can only use bridge to communicate between two different windows, not between frames");!function(n,r,t){var e=W(window,n),o=W(n,window);if(!e&&!o)throw new Error("Can only send messages to and from parent and popup windows");Dn(n).then(function(e){return e(n,r,t)})}(n,t,r)}},Qn.postrobot_global=function(n,r){if(M(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i)){if(!m(n))throw new Error("Post message through global disabled between different domain windows");if(!1!==N(window,n))throw new Error("Can only use global to communicate between two different windows, not between frames");var t=cn(n);if(!t)throw new Error("Can not find postRobot global on foreign window");t.receiveMessage({source:window,origin:h(),data:r})}};var Vn,$n="__domain_regex__";function nr(n){return sn("responseListeners").get(n)}function rr(n){sn("responseListeners").del(n)}function tr(n){return sn("erroredResponseListeners").has(n)}function er(n){var r=n.name,t=n.win,e=n.domain,o=hn("requestListeners");if(t===un&&(t=null),e===un&&(e=null),!r)throw new Error("Name required to get request listener");for(var i=0,u=[t,wn()];i<u.length;i++){var f=u[i];if(f){var c=o.get(f);if(c){var a=c[r];if(a){if(e&&"string"==typeof e){if(a[e])return a[e];if(a[$n])for(var s=0,d=a[$n];s<d.length;s++){var w=d[s],h=w.listener;if(k(w.regex,e))return h}}if(a[un])return a[un]}}}}}var or,ir=((Vn={})[tn.g]=function(n,r,t,e){var o=e.on,i=e.send,u=er({name:t.name,win:n,domain:r});function f(e,u,f){void 0===f&&(f={}),t.fireAndForget||x(n)||Xn(n,r,z({type:e,ack:u,hash:t.hash,name:t.name},f),{on:o,send:i})}return F.all([f(tn.M),F.try(function(){if(!u)throw new Error("No handler found for post message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!k(u.domain,r))throw new Error("Request origin "+r+" does not match domain "+u.domain.toString());return u.handler({source:n,origin:r,data:t.data})}).then(function(n){return f(tn._,"success",{data:n})},function(n){return f(tn._,"error",{error:n})})]).then(Y).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Vn[tn.M]=function(n,r,t){if(!tr(t.hash)){var e=nr(t.hash);if(!e)throw new Error("No handler found for post message ack for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!k(e.domain,r))throw new Error("Ack origin "+r+" does not match domain "+e.domain.toString());if(n!==e.win)throw new Error("Ack source does not match registered window");e.ack=!0}},Vn[tn._]=function(n,r,t){if(!tr(t.hash)){var e,i=nr(t.hash);if(!i)throw new Error("No handler found for post message response for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!k(i.domain,r))throw new Error("Response origin "+r+" does not match domain "+(e=i.domain,Array.isArray(e)?"("+e.join(" | ")+")":o(e)?"RegExp("+e.toString():e.toString()));if(n!==i.win)throw new Error("Response source does not match registered window");rr(t.hash),"error"===t.ack?i.promise.reject(t.error):"success"===t.ack&&i.promise.resolve({source:n,origin:r,data:t.data})}},Vn);function ur(n,r){var t=r.on,e=r.send,o=sn("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var u=n.source,f=n.origin,c=function(n,r,t,e){var o,i=e.on,u=e.send;try{o=Yn(r,t,n,{on:i,send:u})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_3__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&ir[o.type])return o}(n.data,u,f,{on:t,send:e});c&&(gn(u),o.has(c.id)||(o.set(c.id,!0),x(u)&&!c.fireAndForget||(0===c.origin.indexOf(i.h)&&(f=c.origin),ir[c.type](u,f,c,{on:t,send:e}))))}function fr(n,r,t){if(!n)throw new Error("Expected name");if("function"==typeof r&&(t=r,r={}),!t)throw new Error("Expected handler");(r=r||{}).name=n,r.handler=t||r.handler;var e=r.window,o=r.domain,i=function n(r,t){var e=r.name,o=r.win,i=r.domain,u=hn("requestListeners");if(!e||"string"!=typeof e)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var f=[],c=0,a=o;c<a.length;c++)f.push(n({name:e,domain:i,win:a[c]},t));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}if(Array.isArray(i)){for(var s=[],d=0,w=i;d<w.length;d++)s.push(n({name:e,win:o,domain:w[d]},t));return{cancel:function(){for(var n=0;n<s.length;n++)s[n].cancel()}}}var h=er({name:e,win:o,domain:i});if(o&&o!==un||(o=wn()),i=i||un,h)throw o&&i?new Error("Request listener already exists for "+e+" on domain "+i.toString()+" for "+(o===wn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+e+" for "+(o===wn()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+e+" on domain "+i.toString()):new Error("Request listener already exists for "+e);var v,m,l=u.getOrSet(o,function(){return{}}),p=X(l,e,function(){return{}}),y=i.toString();return Q(i)?(v=X(p,$n,function(){return[]})).push(m={regex:i,listener:t}):p[y]=t,{cancel:function(){delete p[y],m&&(v.splice(v.indexOf(m,1)),v.length||delete p[$n]),Object.keys(p).length||delete l[e],o&&!Object.keys(l).length&&u.del(o)}}}({name:n,win:e,domain:o},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:o||un,name:n});return{cancel:function(){i.cancel()}}}function cr(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,o=new F;return r.errorHandler=function(n){e.cancel(),o.reject(n)},e=fr(n,r,function(n){if(e.cancel(),o.resolve(n),t)return t(n)}),o.cancel=e.cancel,o}function ar(n,r,t,e){var o=(e=e||{}).domain||un,i=e.timeout||rn,u=e.timeout||V,f=e.fireAndForget||!1;return F.try(function(){if(!r)throw new Error("Expected name");if(o&&"string"!=typeof o&&!Array.isArray(o)&&!Q(o))throw new TypeError("Expected domain to be a string, array, or regex");if(x(n))throw new Error("Target window is closed");var e=hn("requestPromises").getOrSet(n,function(){return[]}),c=F.try(function(){return function(n,r){var t=j(r);if(t)return t===n;if(r===n)return!1;if(g(r)===r)return!1;for(var e=0,o=p(n);e<o.length;e++)if(o[e]===r)return!0;return!1}(window,n)?yn(n,u):Q(o)?ln(n,{send:ar}):void 0}).then(function(u){var a=(void 0===u?{}:u).domain;if(Q(o)){if(!k(o,a))throw new Error("Remote window domain "+a+" does not match regex: "+o.source);o=a}var s=!1,d=new F;d.finally(function(){s=!0,e.splice(e.indexOf(c,1))}).catch(Y);var w=r+"_"+H();if(Xn(n,o,{type:tn.g,hash:w,name:r,data:t,fireAndForget:f},{on:fr,send:ar}),f)return d.resolve();d.catch(function(){!function(n){sn("erroredResponseListeners").set(n,!0)}(w),rr(w)});var v={name:r,win:n,domain:o,promise:d};!function(n,r){sn("responseListeners").set(n,r)}(w,v);var m=function(n){return hn("knownWindows").get(n,!1)}(n)?nn:$,l=i,p=m,y=l,g=100;return setTimeout(function t(){if(!s){if(x(n))return d.reject(v.ack?new Error("Window closed for "+r+" before response"):new Error("Window closed for "+r+" before ack"));if(p=Math.max(p-g,0),-1!==y&&(y=Math.max(y-g,0)),v.ack){if(-1===y)return;g=Math.min(y,2e3)}else{if(0===p)return d.reject(new Error("No ack for postMessage "+r+" in "+h()+" in "+m+"ms"));if(0===y)return d.reject(new Error("No response for postMessage "+r+" in "+h()+" in "+l+"ms"))}setTimeout(t,g)}},g),d});return e.push(c),c})}function sr(n,r,t){return Hn(n,r,t,{on:fr,send:ar})}function dr(n,r,t){return Yn(n,r,t,{on:fr,send:ar})}function wr(n){return Jn.toProxyWindow(n,{send:ar})}function hr(){var n,r,t,e;cn().initialized||(cn().initialized=!0,function(n){var r=n.on,t=n.send;sn().getOrSet("postMessageListeners",function(){return(n=window).addEventListener("message",e=function(n){!function(n,r){var t=r.on,e=r.send,o=n.source||n.sourceElement,u=n.origin||n.originalEvent&&n.originalEvent.origin,f=n.data;if("null"===u&&(u=i.h+"//"),o){if(!u)throw new Error("Post message did not have origin domain");ur({source:o,origin:u,data:f},{on:t,send:e})}}(n,{on:r,send:t})}),{cancel:function(){n.removeEventListener("message",e)}};var n,e})}({on:fr,send:ar}),zn({on:fr,send:ar,receiveMessage:ur}),function(n){var r=n.on,t=n.send;sn("builtinListeners").getOrSet("helloListener",function(){var n=r(en.W,{domain:un},function(n){var r=n.source,t=n.origin;return mn(r).resolve({win:r,domain:t}),{instanceID:vn()}}),e=j();return e&&ln(e,{send:t}).catch(Y),n})}({on:fr,send:ar}),r=(n={on:fr,send:ar}).on,t=n.send,(e=cn()).receiveMessage=e.receiveMessage||function(n){return ur(n,{on:r,send:t})})}function vr(n){for(var r=0,t=hn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(Y)}t.d(r,"bridge",function(){return or}),t.d(r,"Promise",function(){return F}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return Jn}),t.d(r,"setup",function(){return hr}),t.d(r,"serializeMessage",function(){return sr}),t.d(r,"deserializeMessage",function(){return dr}),t.d(r,"toProxyWindow",function(){return wr}),t.d(r,"on",function(){return fr}),t.d(r,"once",function(){return cr}),t.d(r,"send",function(){return ar}),t.d(r,"markWindowKnown",function(){return gn}),t.d(r,"cleanUpWindow",function(){return vr}),or={setupBridge:zn,openBridge:function(n,r){var t=sn("bridges"),e=sn("bridgeFrames");return r=r||P(n),t.getOrSet(r,function(){return F.try(function(){if(h()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var t=Cn(r);if(O(window,t))throw new Error("Frame with name "+t+" already exists on page");var o=function(n,r){var t=document.createElement("iframe");return t.setAttribute("name",n),t.setAttribute("id",n),t.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),t.setAttribute("frameborder","0"),t.setAttribute("border","0"),t.setAttribute("scrolling","no"),t.setAttribute("allowTransparency","true"),t.setAttribute("tabindex","-1"),t.setAttribute("hidden","true"),t.setAttribute("title",""),t.setAttribute("role","presentation"),t.src=r,t}(t,n);return e.set(r,o),Bn.then(function(r){r.appendChild(o);var t=o.contentWindow;return new F(function(n,r){o.addEventListener("load",n),o.addEventListener("error",r)}).then(function(){return yn(t,5e3,"Bridge "+n)}).then(function(){return t})})})})},linkWindow:Fn,linkUrl:function(n,r){Fn({win:n,domain:P(r)})},isBridge:Tn,needsBridge:Sn,needsBridgeForBrowser:kn,hasBridge:function(n,r){return sn("bridges").has(r||P(n))},needsBridgeForWin:Pn,needsBridgeForDomain:An,destroyBridges:function(){for(var n=sn("bridges"),r=sn("bridgeFrames"),t=0,e=r.keys();t<e.length;t++){var o=r.get(e[t]);o&&o.parentNode&&o.parentNode.removeChild(o)}r.reset(),n.reset()}},hr()}])}); | ||
!function(n,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():n.postRobot=r()}("undefined"!=typeof self?self:this,function(){return function(n){var r={};function t(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=n,t.c=r,t.d=function(n,r,e){t.o(n,r)||Object.defineProperty(n,r,{enumerable:!0,get:e})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,r){if(1&r&&(n=t(n)),8&r)return n;if(4&r&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&r&&"string"!=typeof n)for(var o in n)t.d(e,o,function(r){return n[r]}.bind(null,o));return e},t.n=function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(r,"a",r),r},t.o=function(n,r){return{}.hasOwnProperty.call(n,r)},t.p="",t(t.s=0)}([function(n,r,t){"use strict";t.r(r);var e={};function o(n){return"[object RegExp]"==={}.toString.call(n)}t.r(e),t.d(e,"WeakMap",function(){return Z});var i={u:"mock:",h:"file:",v:"about:"},u="*",f="Call was rejected by callee.\r\n";function c(n){return void 0===n&&(n=window),n.location.protocol===i.v}function a(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function s(n){if(n&&!a(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function w(n){var r=(n=n||window).location;if(!r)throw new Error("Can not read window location");var t=r.protocol;if(!t)throw new Error("Can not read window protocol");if(t===i.h)return i.h+"//";if(t===i.v){var e=a(n);return e&&d()?w(e):i.v+"//"}var o=r.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function h(n){var r=w(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(i.u)?n.mockDomain:r}function v(n){try{if(n===window)return!0}catch(n){}try{var r=Object.getOwnPropertyDescriptor(n,"location");if(r&&!1===r.enumerable)return!1}catch(n){}try{if(c(n)&&d())return!0}catch(n){}try{if(w(n)===w(window))return!0}catch(n){}return!1}function m(n){if(!v(n))return!1;try{if(n===window)return!0;if(c(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function l(n,r){if(!n||!r)return!1;var t=a(r);return t?t===n:-1!==function(n){var r=[];try{for(;n.parent!==n;)r.push(n.parent),n=n.parent}catch(n){}return r}(r).indexOf(n)}function p(n){var r,t,e=[];try{r=n.frames}catch(t){r=n}try{t=r.length}catch(n){}if(0===t)return e;if(t){for(var o=0;o<t;o++){var i=void 0;try{i=r[o]}catch(n){continue}e.push(i)}return e}for(var u=0;u<100;u++){var f=void 0;try{f=r[u]}catch(n){return e}if(!f)return e;e.push(f)}return e}function y(n){for(var r=[],t=0,e=p(n);t<e.length;t++){var o=e[t];r.push(o);for(var i=0,u=y(o);i<u.length;i++)r.push(u[i])}return r}function g(n){if(n){try{if(n.top)return n.top}catch(n){}if(a(n)===n)return n;try{if(l(window,n)&&window.top)return window.top}catch(n){}try{if(l(n,window)&&window.top)return window.top}catch(n){}for(var r=0,t=y(n);r<t.length;r++){var e=t[r];try{if(e.top)return e.top}catch(n){}if(a(e)===e)return e}}}function E(n){var r=g(n);if(!r)throw new Error("Can not determine top window");return[].concat(y(r),[r])}var b=[],_=[];function x(n,r){void 0===r&&(r=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==f}if(r&&m(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var t=function(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}(b,n);if(-1!==t){var e=_[t];if(e&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var r=n.ownerDocument;return!(!r||!r.documentElement||r.documentElement.contains(n))}(e))return!0}return!1}function M(n){return(n=n||window).navigator.mockUserAgent||n.navigator.userAgent}function O(n,r){for(var t=p(n),e=0;e<t.length;e++){var o=t[e];try{if(m(o)&&o.name===r&&-1!==t.indexOf(o))return o}catch(n){}}try{if(-1!==t.indexOf(n.frames[r]))return n.frames[r]}catch(n){}try{if(-1!==t.indexOf(n[r]))return n[r]}catch(n){}}function W(n,r){return n===s(r)}function j(n){return s(n=n||window)||a(n)||void 0}function R(n,r){for(var t=0;t<n.length;t++)for(var e=n[t],o=0;o<r.length;o++)if(e===r[o])return!0;return!1}function N(n,r){var t=g(n)||n,e=g(r)||r;try{if(t&&e)return t===e}catch(n){}var o=E(n),i=E(r);if(R(o,i))return!0;var u=s(t),f=s(e);return!(u&&R(E(u),i)||(f&&R(E(f),o),1))}function k(n,r){if("string"==typeof n){if("string"==typeof r)return n===u||r===n;if(o(r))return!1;if(Array.isArray(r))return!1}return o(n)?o(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!o(r)&&n.some(function(n){return k(n,r)}))}function P(n){return n.match(/^(https?|mock|file):\/\//)?n.split("/").slice(0,3).join("/"):h()}function A(n){try{if(n===window)return!0}catch(n){if(n&&n.message===f)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===f)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===f)return!0}return!1}function S(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&n instanceof window.constructor)return!1;var r={}.toString;if(r){var t=r.call(n);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var C,T=[],B=[],I=0;function D(){if(!I&&C){var n=C;C=null,n.resolve()}}function L(){I+=1}function q(){I-=1,D()}var F=function(){function n(n){var r=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=[],n){var t,e,o=!1,i=!1,u=!1;L();try{n(function(n){u?r.resolve(n):(o=!0,t=n)},function(n){u?r.reject(n):(i=!0,e=n)})}catch(n){return q(),void this.reject(n)}q(),u=!0,o?this.resolve(t):i&&this.reject(e)}}var r=n.prototype;return r.resolve=function(n){if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},r.reject=function(n){var r=this;if(this.resolved||this.rejected)return this;if(S(n))throw new Error("Can not reject promise with another promise");if(!n){var t=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout(function(){r.errorHandled||function(n,r){if(-1===T.indexOf(n)){T.push(n),setTimeout(function(){throw n},1);for(var t=0;t<B.length;t++)B[t](n,r)}}(n,r)},1),this.dispatch(),this},r.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},r.dispatch=function(){var r=this,t=this.resolved,e=this.rejected,o=this.handlers;if(!this.dispatching&&(t||e)){this.dispatching=!0,L();for(var i=function(i){var u=o[i],f=u.onSuccess,c=u.onError,a=u.promise,s=void 0;if(t)try{s=f?f(r.value):r.value}catch(n){return a.reject(n),"continue"}else if(e){if(!c)return a.reject(r.error),"continue";try{s=c(r.error)}catch(n){return a.reject(n),"continue"}}s instanceof n&&(s.resolved||s.rejected)?(s.resolved?a.resolve(s.value):a.reject(s.error),s.errorHandled=!0):S(s)?s instanceof n&&(s.resolved||s.rejected)?s.resolved?a.resolve(s.value):a.reject(s.error):s.then(function(n){a.resolve(n)},function(n){a.reject(n)}):a.resolve(s)},u=0;u<o.length;u++)i(u);o.length=0,this.dispatching=!1,q()}},r.then=function(r,t){if(r&&"function"!=typeof r&&!r.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 e=new n;return this.handlers.push({promise:e,onSuccess:r,onError:t}),this.errorHandled=!0,this.dispatch(),e},r.catch=function(n){return this.then(void 0,n)},r.finally=function(r){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.finally expected a function");return this.then(function(t){return n.try(r).then(function(){return t})},function(t){return n.try(r).then(function(){throw t})})},r.timeout=function(n,r){var t=this;if(this.resolved||this.rejected)return this;var e=setTimeout(function(){t.resolved||t.rejected||t.reject(r||new Error("Promise timed out after "+n+"ms"))},n);return this.then(function(n){return clearTimeout(e),n})},r.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(r){return r instanceof n?r:S(r)?new n(function(n,t){return r.then(n,t)}):(new n).resolve(r)},n.reject=function(r){return(new n).reject(r)},n.asyncReject=function(r){return(new n).asyncReject(r)},n.all=function(r){var t=new n,e=r.length,o=[];if(!e)return t.resolve(o),t;for(var i=function(i){var u=r[i];if(u instanceof n){if(u.resolved)return o[i]=u.value,e-=1,"continue"}else if(!S(u))return o[i]=u,e-=1,"continue";n.resolve(u).then(function(n){o[i]=n,0==(e-=1)&&t.resolve(o)},function(n){t.reject(n)})},u=0;u<r.length;u++)i(u);return 0===e&&t.resolve(o),t},n.hash=function(r){var t={};return n.all(Object.keys(r).map(function(e){return n.resolve(r[e]).then(function(n){t[e]=n})})).then(function(){return t})},n.map=function(r,t){return n.all(r.map(t))},n.onPossiblyUnhandledException=function(n){return function(n){return B.push(n),{cancel:function(){B.splice(B.indexOf(n),1)}}}(n)},n.try=function(r,t,e){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.try expected a function");var o;L();try{o=r.apply(t,e||[])}catch(r){return q(),n.reject(r)}return q(),n.resolve(o)},n.delay=function(r){return new n(function(n){setTimeout(n,r)})},n.isPromise=function(r){return!!(r&&r instanceof n)||S(r)},n.flush=function(){return r=C=C||new n,D(),r;var r},n}();function z(){return(z=Object.assign||function(n){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var e in t)({}).hasOwnProperty.call(t,e)&&(n[e]=t[e])}return n}).apply(this,arguments)}function U(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}var J,G=Object.defineProperty,K=Date.now()%1e9,Z=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,K+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+K,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,r={};return Object.freeze(r),n.set(r,"__testvalue__"),"__testvalue__"===n.get(r)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var r=n.prototype;return r._cleanupClosedWindows=function(){for(var n=this.weakmap,r=this.keys,t=0;t<r.length;t++){var e=r[t];if(A(e)&&x(e)){if(n)try{n.delete(e)}catch(n){}r.splice(t,1),this.values.splice(t,1),t-=1}}},r.isSafeToReadWrite=function(n){return!A(n)},r.set=function(n,r){if(!n)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.set(n,r)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var e=this.name,o=n[e];o&&o[0]===n?o[1]=r:G(n,e,{value:[n,r],writable:!0})}else{this._cleanupClosedWindows();var i=this.keys,u=this.values,f=U(i,n);-1===f?(i.push(n),u.push(r)):u[f]=r}},r.get=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return r.get(n)}catch(n){delete this.weakmap}if(!this.isSafeToReadWrite(n)){this._cleanupClosedWindows();var t=U(this.keys,n);if(-1===t)return;return this.values[t]}var e=n[this.name];if(e&&e[0]===n)return e[1]},r.delete=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];t&&t[0]===n&&(t[0]=t[1]=void 0)}else{this._cleanupClosedWindows();var e=this.keys,o=U(e,n);-1!==o&&(e.splice(o,1),this.values.splice(o,1))}},r.has=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];return!(!t||t[0]!==n)}return this._cleanupClosedWindows(),-1!==U(this.keys,n)},r.getOrSet=function(n,r){if(this.has(n))return this.get(n);var t=r();return this.set(n,t),t},n}();function H(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(n){if("function"==typeof btoa)return btoa(n);if("undefined"!=typeof Buffer)return Buffer.from(n,"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 Y(){}function Q(n){return"[object RegExp]"==={}.toString.call(n)}function X(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var V=5e3,$=2e3,nn=1e4,rn=-1,tn={g:"postrobot_message_request",_:"postrobot_message_response",M:"postrobot_message_ack"},en={O:"postrobot_method",W:"postrobot_hello",j:"postrobot_open_tunnel"},on="__postrobot_bridge__",un="*",fn={R:"cross_domain_zalgo_promise",N:"cross_domain_function",k:"cross_domain_window"};function cn(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_4__:n.__post_robot_10_0_4__=n.__post_robot_10_0_4__||{}}var an=function(){return{}};function sn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=an),X(cn(),n,function(){var n=r();return{has:function(r){return n.hasOwnProperty(r)},get:function(r,t){return n.hasOwnProperty(r)?n[r]:t},set:function(r,t){return n[r]=t,t},del:function(r){delete n[r]},getOrSet:function(r,t){return X(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var dn=function(){};function wn(){var n=cn();return n.P=n.P||new dn,n.P}function hn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=an),sn("windowStore").getOrSet(n,function(){var t=new Z,e=function(n){return t.getOrSet(n,r)};return{has:function(r){return e(r).hasOwnProperty(n)},get:function(r,t){var o=e(r);return o.hasOwnProperty(n)?o[n]:t},set:function(r,t){return e(r)[n]=t,t},del:function(r){delete e(r)[n]},getOrSet:function(r,t){return X(e(r),n,t)}}})}function vn(){return sn("instance").getOrSet("instanceID",H)}function mn(n){return hn("helloPromises").getOrSet(n,function(){return new F})}function ln(n,r){return(0,r.send)(n,en.W,{instanceID:vn()},{domain:un,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return mn(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function pn(n,r){var t=r.send;return hn("windowInstanceIDPromises").getOrSet(n,function(){return ln(n,{send:t}).then(function(n){return n.instanceID})})}function yn(n,r,t){void 0===r&&(r=5e3),void 0===t&&(t="Window");var e=mn(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}function gn(n){hn("knownWindows").set(n,!0)}var En,bn={A:"function",ERROR:"error",S:"promise",C:"regex",T:"date",B:"array",I:"object",D:"string",L:"number",q:"boolean",F:"null",U:"undefined"};function _n(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function xn(n){return void 0===n?bn.U:null===n?bn.F:Array.isArray(n)?bn.B:"function"==typeof n?bn.A:"object"==typeof n?n instanceof Error?bn.ERROR:"function"==typeof n.then?bn.S:"[object RegExp]"==={}.toString.call(n)?bn.C:"[object Date]"==={}.toString.call(n)?bn.T:bn.I:"string"==typeof n?bn.D:"number"==typeof n?bn.L:"boolean"==typeof n?bn.q:void 0}function Mn(n,r){return{__type__:n,__val__:r}}var On,Wn=((En={})[bn.A]=function(){},En[bn.ERROR]=function(n){return Mn(bn.ERROR,{message:n.message,stack:n.stack,code:n.code})},En[bn.S]=function(){},En[bn.C]=function(n){return Mn(bn.C,n.source)},En[bn.T]=function(n){return Mn(bn.T,n.toJSON())},En[bn.B]=function(n){return n},En[bn.I]=function(n){return n},En[bn.D]=function(n){return n},En[bn.L]=function(n){return n},En[bn.q]=function(n){return n},En[bn.F]=function(n){return n},En),jn={},Rn=((On={})[bn.A]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},On[bn.ERROR]=function(n){var r=n.stack,t=n.code,e=new Error(n.message);return e.code=t,e.stack=r+"\n\n"+e.stack,e},On[bn.S]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},On[bn.C]=function(n){return new RegExp(n)},On[bn.T]=function(n){return new Date(n)},On[bn.B]=function(n){return n},On[bn.I]=function(n){return n},On[bn.D]=function(n){return n},On[bn.L]=function(n){return n},On[bn.q]=function(n){return n},On[bn.F]=function(n){return n},On),Nn={};function kn(){return!!M(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Pn(n){return!N(window,n)}function An(n,r){if(n){if(h()!==P(n))return!0}else if(r&&!m(r))return!0;return!1}function Sn(n){var r=n.win,t=n.domain;return!(!kn()||t&&!An(t,r)||r&&!Pn(r))}function Cn(n){var r=(n=n||P(n)).replace(/[^a-zA-Z0-9]+/g,"_");return on+"_"+r}function Tn(){return Boolean(window.name&&window.name===Cn(h()))}var Bn=new F(function(n){if(window.document&&window.document.body)return n(window.document.body);var r=setInterval(function(){if(window.document&&window.document.body)return clearInterval(r),n(window.document.body)},10)});function In(n){hn("remoteWindowPromises").getOrSet(n,function(){return new F})}function Dn(n){var r=hn("remoteWindowPromises").get(n);if(!r)throw new Error("Remote window promise not found");return r}function Ln(n,r,t){Dn(n).resolve(function(e,o,i){if(e!==n)throw new Error("Remote window does not match window");if(!k(o,r))throw new Error("Remote domain "+o+" does not match domain "+r);t.fireAndForget(i)})}function qn(n,r){Dn(n).reject(r).catch(Y)}function Fn(n){for(var r=n.win,t=n.name,e=n.domain,o=sn("popupWindowsByName"),i=hn("popupWindowsByWin"),u=0,f=o.keys();u<f.length;u++){var c=f[u];x(o.get(c).win)&&o.del(c)}var a=i.getOrSet(r,function(){return t?o.getOrSet(t,function(){return{win:r,name:t}}):{win:r}});if(a.win&&a.win!==r)throw new Error("Different window already linked for window: "+(t||"undefined"));if(t){if(a.name&&a.name!==t)throw new Error("Different window already linked for name "+t+": "+a.name);a.name=t,o.set(t,a)}return e&&(a.domain=e,In(r)),i.set(r,a),a}function zn(n){var r,t=n.on,e=n.send,o=n.receiveMessage;r=window.open,window.open=function(n,t,e,o){var u=r.call(this,function(n){if(0!==P(n).indexOf(i.u))return n;throw new Error("Mock urls not supported out of test mode")}(n),t,e,o);return u?(Fn({win:u,name:t,domain:n?P(n):null}),u):u},function(n){var r=n.on,t=n.send,e=n.receiveMessage,o=sn("popupWindowsByName");r(en.j,function(n){var i=n.source,u=n.origin,f=n.data,c=sn("bridges").get(u);if(!c)throw new Error("Can not find bridge promise for domain "+u);return c.then(function(n){if(i!==n)throw new Error("Message source does not matched registered bridge for domain "+u);if(!f.name)throw new Error("Register window expected to be passed window name");if(!f.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!o.has(f.name))throw new Error("Window with name "+f.name+" does not exist, or was not opened by this window");if(!o.get(f.name).domain)throw new Error("We do not have a registered domain for window "+f.name);if(o.get(f.name).domain!==u)throw new Error("Message origin "+u+" does not matched registered window origin "+o.get(f.name).domain);return Ln(o.get(f.name).win,u,f.sendMessage),{sendMessage:function(n){if(window&&!window.closed){var i=o.get(f.name);if(i)try{e({data:n,origin:i.domain,source:i.win},{on:r,send:t})}catch(n){F.reject(n)}}}}})})}({on:t,send:e,receiveMessage:o}),function(n){var r=n.send;cn(window).openTunnelToParent=function(n){var t=n.name,e=n.source,o=n.canary,i=n.sendMessage,u=sn("tunnelWindows"),f=a(window);if(!f)throw new Error("No parent window found to open tunnel to");var c=function(n){var r=n.name,t=n.source,e=n.canary,o=n.sendMessage;!function(){for(var n=sn("tunnelWindows"),r=0,t=n.keys();r<t.length;r++){var e=t[r];x(n[e].source)&&n.del(e)}}();var i=H();return sn("tunnelWindows").set(i,{name:r,source:t,canary:e,sendMessage:o}),i}({name:t,source:e,canary:o,sendMessage:i});return r(f,en.j,{name:t,sendMessage:function(){var n=u.get(c);if(n&&n.source&&!x(n.source)){try{n.canary()}catch(n){return}n.sendMessage.apply(this,arguments)}}},{domain:un})}}({on:t,send:e}),function(n){var r=n.on,t=n.send,e=n.receiveMessage;F.try(function(){var n,o=s(window);if(o&&Sn({win:o}))return In(o),(n=o,hn("remoteBridgeAwaiters").getOrSet(n,function(){return F.try(function(){var r=O(n,Cn(h()));if(!r)throw new Error("Bridge not found for domain: "+h());return m(r)&&cn(r)?r:new F(function(n,t){var e,o;e=setInterval(function(){if(r&&m(r)&&cn(r))return clearInterval(e),clearTimeout(o),n(r)},100),o=setTimeout(function(){return clearInterval(e),t(new Error("Bridge not found for domain: "+h()))},2e3)})})})).then(function(n){return window.name?cn(n).openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(n){if(window&&!window.closed)try{e({data:n,origin:this.origin,source:this.source},{on:r,send:t})}catch(n){F.reject(n)}}}).then(function(n){var r=n.source,t=n.origin,e=n.data;if(r!==o)throw new Error("Source does not match opener");Ln(r,t,e.sendMessage)}).catch(function(n){throw qn(o,n),n}):qn(o,new Error("Can not register with opener: window does not have a name"))})})}({on:t,send:e,receiveMessage:o})}function Un(){for(var n=sn("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}var Jn=function(){function n(n,r,t){var e=t.send;this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.serializedWindow=n,this.actualWindowPromise=new F,r&&this.setWindow(r),this.serializedWindow.getInstanceID=function(n){var r={};function t(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];var i=function(n){try{return JSON.stringify([].slice.call(n),function(n,r){return"function"==typeof r?"memoize["+function(n){if(J=J||new Z,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var r=J.get(n);return r||(r=typeof n+":"+H(),J.set(n,r)),r}(r)+"]":r})}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(e);return r.hasOwnProperty(i)?r[i]:(r[i]=n.apply(this,arguments).finally(function(){delete r[i]}),r[i])}return t.reset=function(){r={}},t}(this.serializedWindow.getInstanceID),this.send=e}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return"popup"===this.getType()},r.isIframe=function(){return"iframe"===this.getType()},r.setLocation=function(n){var r=this;return F.try(function(){if(!r.actualWindow)return r.serializedWindow.setLocation(n);r.actualWindow.location=n}).then(function(){return r})},r.setName=function(n){var r=this;return F.try(function(){if(!r.actualWindow)return r.serializedWindow.setName(n);if(!m(r.actualWindow))throw new Error("Can not set name for window on different domain");r.actualWindow.name=n,r.actualWindow.frameElement&&r.actualWindow.frameElement.setAttribute("name",n),Fn({win:r.actualWindow,name:n})}).then(function(){return r})},r.close=function(){var n=this;return F.try(function(){if(!n.actualWindow)return n.serializedWindow.close();n.actualWindow.close()}).then(function(){return n})},r.focus=function(){var n=this;return F.try(function(){return n.actualWindow&&n.actualWindow.focus(),n.serializedWindow.focus()}).then(function(){return n})},r.isClosed=function(){var n=this;return F.try(function(){return n.actualWindow?x(n.actualWindow):n.serializedWindow.isClosed()})},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return F.try(function(){return r.actualWindow?n===r.actualWindow:F.all([r.getInstanceID(),pn(n,{send:r.send})]).then(function(t){var e=t[0]===t[1];return e&&r.setWindow(n),e})})},r.unwrap=function(){return this.actualWindow||this},r.getInstanceID=function(){return this.actualWindow?pn(this.actualWindow,{send:this.send}):this.serializedWindow.getInstanceID()},r.serialize=function(){return this.serializedWindow},r.shouldClean=function(){return this.actualWindow&&x(this.actualWindow)},n.unwrap=function(r){return n.isProxyWindow(r)?r.unwrap():r},n.serialize=function(r,t){var e=t.send;return Un(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,o=t.send;return Un(),sn("idToProxyWindow").getOrSet(r.id,function(){return new n(r,null,{on:e,send:o})})},n.isProxyWindow=function(n){return Boolean(n&&!A(n)&&n.isProxyWindow)},n.toProxyWindow=function(r,t){var e=t.send;return Un(),n.isProxyWindow(r)?r:hn("winToProxyWindow").getOrSet(r,function(){var t=H();return sn("idToProxyWindow").set(t,new n({id:t,type:s(r)?"popup":"iframe",getInstanceID:function(){return pn(r,{send:e})},close:function(){return F.try(function(){r.close()})},focus:function(){return F.try(function(){r.focus()})},isClosed:function(){return F.try(function(){return x(r)})},setLocation:function(n){return F.try(function(){if(m(r))try{if(r.location&&"function"==typeof r.location.replace)return void r.location.replace(n)}catch(n){}r.location=n})},setName:function(n){return F.try(function(){Fn({win:r,name:n}),r.name=n})}},r,{send:e}))})},n}();function Gn(n,r,t,e,o){var i=hn("methodStore"),u=sn("proxyWindowMethods");Jn.isProxyWindow(e)?u.set(n,{val:r,name:t,domain:o,source:e}):(u.del(n),i.getOrSet(e,function(){return{}})[n]={domain:o,name:t,val:r,source:e})}function Kn(n,r){var t=hn("methodStore"),e=sn("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function Zn(n,r,t,e,o){!function(n){var r=o.on;sn("builtinListeners").getOrSet("functionCalls",function(){return r(en.O,{domain:un},function(n){var r=n.source,t=n.origin,e=n.data,o=e.id,i=e.name,u=Kn(r,o);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+h(window));var f=u.source,c=u.domain,a=u.val;return F.try(function(){if(!k(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify(Q(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(Jn.isProxyWindow(f))return f.matchWindow(r).then(function(n){if(!n)throw new Error("Method call '"+e.name+"' failed - proxy window does not match source in "+h(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return F.try(function(){if(a.onError)return a.onError(n)}).then(function(){throw n.stack&&(n.stack="Remote call to "+i+"()\n\n"+n.stack),n})}).then(function(n){return{result:n,id:o,name:i}})})})}();var i=t.__id__||H();n=Jn.unwrap(n);var u=t.__name__||t.name||e;return Jn.isProxyWindow(n)?(Gn(i,t,u,n,r),n.awaitWindow().then(function(n){Gn(i,t,u,n,r)})):Gn(i,t,u,n,r),Mn(fn.N,{id:i,name:u})}function Hn(n,r,t,e){var o,i=e.on,u=e.send;return function(n,r){void 0===r&&(r=jn);var t=JSON.stringify(n,function(n){var t=this[n];if(_n(this))return t;var e=xn(t);if(!e)return t;var o=r[e]||Wn[e];return o?o(t,n):t});return void 0===t?bn.U:t}(t,((o={})[bn.S]=function(t,e){return function(n,r,t,e,o){return Mn(fn.R,{then:Zn(n,r,function(n,r){return t.then(n,r)},e,{on:o.on,send:o.send})})}(n,r,t,e,{on:i,send:u})},o[bn.A]=function(t,e){return Zn(n,r,t,e,{on:i,send:u})},o[bn.I]=function(n){return A(n)||Jn.isProxyWindow(n)?Mn(fn.k,Jn.serialize(n,{send:u})):n},o))}function Yn(n,r,t,e){var o,i=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=Nn),n!==bn.U)return JSON.parse(n,function(n,t){if(_n(this))return t;var e,o;if(_n(t)?(e=t.__type__,o=t.__val__):(e=xn(t),o=t),!e)return o;var i=r[e]||Rn[e];return i?i(o,n):o})}(t,((o={})[fn.R]=function(n){return new F(n.then)},o[fn.N]=function(t){return function(n,r,e,o){var i=t.id,u=t.name,f=o.send,c=function(t){function e(){var o=arguments;return Jn.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=Kn(n,i);return c&&c.val!==e?c.val.apply({source:window,origin:h()},o):f(n,en.O,{id:i,name:u,args:[].slice.call(o)},{domain:r,fireAndForget:t.fireAndForget}).then(function(n){if(!t.fireAndForget)return n.data.result})}).catch(function(n){throw n})}return void 0===t&&(t={}),e.__name__=u,e.__origin__=r,e.__source__=n,e.__id__=i,e.origin=r,e},a=c();return a.fireAndForget=c({fireAndForget:!0}),a}(n,r,0,{on:i,send:u})},o[fn.k]=function(n){return Jn.deserialize(n,{on:(r={on:i,send:u}).on,send:r.send});var r},o))}var Qn={};function Xn(n,r,t,e){var o,i=e.on,u=e.send;if(x(n))throw new Error("Window is closed");for(var f,c=Hn(n,r,((o={}).__post_robot_10_0_4__=z({id:H(),origin:h(window)},t),o),{on:i,send:u}),a=!1,s=0,d=Object.keys(Qn);s<d.length;s++){var w=d[s];try{Qn[w](n,c,r),a=!0}catch(n){f=f||n}}if(!a)throw f}Qn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[un]).map(function(r){if(0===r.indexOf(i.u)){if(window.location.protocol===i.h)return un;if(!v(n))throw new Error("Attempting to send messsage to mock domain "+r+", but window is actually cross-domain");return w(n)}return 0===r.indexOf(i.h)?un:r}).forEach(function(t){n.postMessage(r,t)})},Qn.postrobot_bridge=function(n,r,t){if(kn()||Tn()){if(m(n))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==N(window,n))throw new Error("Can only use bridge to communicate between two different windows, not between frames");!function(n,r,t){var e=W(window,n),o=W(n,window);if(!e&&!o)throw new Error("Can only send messages to and from parent and popup windows");Dn(n).then(function(e){return e(n,r,t)})}(n,t,r)}},Qn.postrobot_global=function(n,r){if(M(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i)){if(!m(n))throw new Error("Post message through global disabled between different domain windows");if(!1!==N(window,n))throw new Error("Can only use global to communicate between two different windows, not between frames");var t=cn(n);if(!t)throw new Error("Can not find postRobot global on foreign window");t.receiveMessage({source:window,origin:h(),data:r})}};var Vn,$n="__domain_regex__";function nr(n){return sn("responseListeners").get(n)}function rr(n){sn("responseListeners").del(n)}function tr(n){return sn("erroredResponseListeners").has(n)}function er(n){var r=n.name,t=n.win,e=n.domain,o=hn("requestListeners");if(t===un&&(t=null),e===un&&(e=null),!r)throw new Error("Name required to get request listener");for(var i=0,u=[t,wn()];i<u.length;i++){var f=u[i];if(f){var c=o.get(f);if(c){var a=c[r];if(a){if(e&&"string"==typeof e){if(a[e])return a[e];if(a[$n])for(var s=0,d=a[$n];s<d.length;s++){var w=d[s],h=w.listener;if(k(w.regex,e))return h}}if(a[un])return a[un]}}}}}var or,ir=((Vn={})[tn.g]=function(n,r,t,e){var o=e.on,i=e.send,u=er({name:t.name,win:n,domain:r});function f(e,u,f){void 0===f&&(f={}),t.fireAndForget||x(n)||Xn(n,r,z({type:e,ack:u,hash:t.hash,name:t.name},f),{on:o,send:i})}return F.all([f(tn.M),F.try(function(){if(!u)throw new Error("No handler found for post message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!k(u.domain,r))throw new Error("Request origin "+r+" does not match domain "+u.domain.toString());return u.handler({source:n,origin:r,data:t.data})}).then(function(n){return f(tn._,"success",{data:n})},function(n){return f(tn._,"error",{error:n})})]).then(Y).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Vn[tn.M]=function(n,r,t){if(!tr(t.hash)){var e=nr(t.hash);if(!e)throw new Error("No handler found for post message ack for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!k(e.domain,r))throw new Error("Ack origin "+r+" does not match domain "+e.domain.toString());if(n!==e.win)throw new Error("Ack source does not match registered window");e.ack=!0}},Vn[tn._]=function(n,r,t){if(!tr(t.hash)){var e,i=nr(t.hash);if(!i)throw new Error("No handler found for post message response for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!k(i.domain,r))throw new Error("Response origin "+r+" does not match domain "+(e=i.domain,Array.isArray(e)?"("+e.join(" | ")+")":o(e)?"RegExp("+e.toString():e.toString()));if(n!==i.win)throw new Error("Response source does not match registered window");rr(t.hash),"error"===t.ack?i.promise.reject(t.error):"success"===t.ack&&i.promise.resolve({source:n,origin:r,data:t.data})}},Vn);function ur(n,r){var t=r.on,e=r.send,o=sn("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var u=n.source,f=n.origin,c=function(n,r,t,e){var o,i=e.on,u=e.send;try{o=Yn(r,t,n,{on:i,send:u})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_4__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&ir[o.type])return o}(n.data,u,f,{on:t,send:e});c&&(gn(u),o.has(c.id)||(o.set(c.id,!0),x(u)&&!c.fireAndForget||(0===c.origin.indexOf(i.h)&&(f=c.origin),ir[c.type](u,f,c,{on:t,send:e}))))}function fr(n,r,t){if(!n)throw new Error("Expected name");if("function"==typeof r&&(t=r,r={}),!t)throw new Error("Expected handler");(r=r||{}).name=n,r.handler=t||r.handler;var e=r.window,o=r.domain,i=function n(r,t){var e=r.name,o=r.win,i=r.domain,u=hn("requestListeners");if(!e||"string"!=typeof e)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var f=[],c=0,a=o;c<a.length;c++)f.push(n({name:e,domain:i,win:a[c]},t));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}if(Array.isArray(i)){for(var s=[],d=0,w=i;d<w.length;d++)s.push(n({name:e,win:o,domain:w[d]},t));return{cancel:function(){for(var n=0;n<s.length;n++)s[n].cancel()}}}var h=er({name:e,win:o,domain:i});if(o&&o!==un||(o=wn()),i=i||un,h)throw o&&i?new Error("Request listener already exists for "+e+" on domain "+i.toString()+" for "+(o===wn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+e+" for "+(o===wn()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+e+" on domain "+i.toString()):new Error("Request listener already exists for "+e);var v,m,l=u.getOrSet(o,function(){return{}}),p=X(l,e,function(){return{}}),y=i.toString();return Q(i)?(v=X(p,$n,function(){return[]})).push(m={regex:i,listener:t}):p[y]=t,{cancel:function(){delete p[y],m&&(v.splice(v.indexOf(m,1)),v.length||delete p[$n]),Object.keys(p).length||delete l[e],o&&!Object.keys(l).length&&u.del(o)}}}({name:n,win:e,domain:o},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:o||un,name:n});return{cancel:function(){i.cancel()}}}function cr(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,o=new F;return r.errorHandler=function(n){e.cancel(),o.reject(n)},e=fr(n,r,function(n){if(e.cancel(),o.resolve(n),t)return t(n)}),o.cancel=e.cancel,o}function ar(n,r,t,e){var o=(e=e||{}).domain||un,i=e.timeout||rn,u=e.timeout||V,f=e.fireAndForget||!1;return F.try(function(){if(!r)throw new Error("Expected name");if(o&&"string"!=typeof o&&!Array.isArray(o)&&!Q(o))throw new TypeError("Expected domain to be a string, array, or regex");if(x(n))throw new Error("Target window is closed");var e=hn("requestPromises").getOrSet(n,function(){return[]}),c=F.try(function(){return function(n,r){var t=j(r);if(t)return t===n;if(r===n)return!1;if(g(r)===r)return!1;for(var e=0,o=p(n);e<o.length;e++)if(o[e]===r)return!0;return!1}(window,n)?yn(n,u):Q(o)?ln(n,{send:ar}):void 0}).then(function(u){var a=(void 0===u?{}:u).domain;if(Q(o)){if(!k(o,a))throw new Error("Remote window domain "+a+" does not match regex: "+o.source);o=a}var s=r===en.O&&t&&"string"==typeof t.name?t.name+"()":r,d=!1,w=new F;w.finally(function(){d=!0,e.splice(e.indexOf(c,1))}).catch(Y);var v=r+"_"+H();if(Xn(n,o,{type:tn.g,hash:v,name:r,data:t,fireAndForget:f},{on:fr,send:ar}),f)return w.resolve();w.catch(function(){!function(n){sn("erroredResponseListeners").set(n,!0)}(v),rr(v)});var m={name:r,win:n,domain:o,promise:w};!function(n,r){sn("responseListeners").set(n,r)}(v,m);var l=function(n){return hn("knownWindows").get(n,!1)}(n)?nn:$,p=i,y=l,g=p,E=100;return setTimeout(function t(){if(!d){if(x(n))return w.reject(m.ack?new Error("Window closed for "+r+" before response"):new Error("Window closed for "+r+" before ack"));if(y=Math.max(y-E,0),-1!==g&&(g=Math.max(g-E,0)),m.ack){if(-1===g)return;E=Math.min(g,2e3)}else{if(0===y)return w.reject(new Error("No ack for postMessage "+s+" in "+h()+" in "+l+"ms"));if(0===g)return w.reject(new Error("No response for postMessage "+s+" in "+h()+" in "+p+"ms"))}setTimeout(t,E)}},E),w});return e.push(c),c})}function sr(n,r,t){return Hn(n,r,t,{on:fr,send:ar})}function dr(n,r,t){return Yn(n,r,t,{on:fr,send:ar})}function wr(n){return Jn.toProxyWindow(n,{send:ar})}function hr(){var n,r,t,e;cn().initialized||(cn().initialized=!0,function(n){var r=n.on,t=n.send;sn().getOrSet("postMessageListeners",function(){return(n=window).addEventListener("message",e=function(n){!function(n,r){var t=r.on,e=r.send,o=n.source||n.sourceElement,u=n.origin||n.originalEvent&&n.originalEvent.origin,f=n.data;if("null"===u&&(u=i.h+"//"),o){if(!u)throw new Error("Post message did not have origin domain");ur({source:o,origin:u,data:f},{on:t,send:e})}}(n,{on:r,send:t})}),{cancel:function(){n.removeEventListener("message",e)}};var n,e})}({on:fr,send:ar}),zn({on:fr,send:ar,receiveMessage:ur}),function(n){var r=n.on,t=n.send;sn("builtinListeners").getOrSet("helloListener",function(){var n=r(en.W,{domain:un},function(n){var r=n.source,t=n.origin;return mn(r).resolve({win:r,domain:t}),{instanceID:vn()}}),e=j();return e&&ln(e,{send:t}).catch(Y),n})}({on:fr,send:ar}),r=(n={on:fr,send:ar}).on,t=n.send,(e=cn()).receiveMessage=e.receiveMessage||function(n){return ur(n,{on:r,send:t})})}function vr(n){for(var r=0,t=hn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(Y)}t.d(r,"bridge",function(){return or}),t.d(r,"Promise",function(){return F}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return Jn}),t.d(r,"setup",function(){return hr}),t.d(r,"serializeMessage",function(){return sr}),t.d(r,"deserializeMessage",function(){return dr}),t.d(r,"toProxyWindow",function(){return wr}),t.d(r,"on",function(){return fr}),t.d(r,"once",function(){return cr}),t.d(r,"send",function(){return ar}),t.d(r,"markWindowKnown",function(){return gn}),t.d(r,"cleanUpWindow",function(){return vr}),or={setupBridge:zn,openBridge:function(n,r){var t=sn("bridges"),e=sn("bridgeFrames");return r=r||P(n),t.getOrSet(r,function(){return F.try(function(){if(h()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var t=Cn(r);if(O(window,t))throw new Error("Frame with name "+t+" already exists on page");var o=function(n,r){var t=document.createElement("iframe");return t.setAttribute("name",n),t.setAttribute("id",n),t.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),t.setAttribute("frameborder","0"),t.setAttribute("border","0"),t.setAttribute("scrolling","no"),t.setAttribute("allowTransparency","true"),t.setAttribute("tabindex","-1"),t.setAttribute("hidden","true"),t.setAttribute("title",""),t.setAttribute("role","presentation"),t.src=r,t}(t,n);return e.set(r,o),Bn.then(function(r){r.appendChild(o);var t=o.contentWindow;return new F(function(n,r){o.addEventListener("load",n),o.addEventListener("error",r)}).then(function(){return yn(t,5e3,"Bridge "+n)}).then(function(){return t})})})})},linkWindow:Fn,linkUrl:function(n,r){Fn({win:n,domain:P(r)})},isBridge:Tn,needsBridge:Sn,needsBridgeForBrowser:kn,hasBridge:function(n,r){return sn("bridges").has(r||P(n))},needsBridgeForWin:Pn,needsBridgeForDomain:An,destroyBridges:function(){for(var n=sn("bridges"),r=sn("bridgeFrames"),t=0,e=r.keys();t<e.length;t++){var o=r.get(e[t]);o&&o.parentNode&&o.parentNode.removeChild(o)}r.reset(),n.reset()}},hr()}])}); | ||
//# sourceMappingURL=post-robot.ie.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():n.postRobot=r()}("undefined"!=typeof self?self:this,function(){return function(n){var r={};function t(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return n[e].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=n,t.c=r,t.d=function(n,r,e){t.o(n,r)||Object.defineProperty(n,r,{enumerable:!0,get:e})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,r){if(1&r&&(n=t(n)),8&r)return n;if(4&r&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&r&&"string"!=typeof n)for(var i in n)t.d(e,i,function(r){return n[r]}.bind(null,i));return e},t.n=function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(r,"a",r),r},t.o=function(n,r){return{}.hasOwnProperty.call(n,r)},t.p="",t(t.s=0)}([function(n,r,t){"use strict";t.r(r);var e={};function i(n){return"[object RegExp]"==={}.toString.call(n)}t.r(e),t.d(e,"WeakMap",function(){return D});var o={u:"mock:",h:"file:",v:"about:"},u="*",f="Call was rejected by callee.\r\n";function c(n){return void 0===n&&(n=window),n.location.protocol===o.v}function a(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function s(n){if(n&&!a(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function w(n){var r=(n=n||window).location;if(!r)throw new Error("Can not read window location");var t=r.protocol;if(!t)throw new Error("Can not read window protocol");if(t===o.h)return o.h+"//";if(t===o.v){var e=a(n);return e&&d()?w(e):o.v+"//"}var i=r.host;if(!i)throw new Error("Can not read window host");return t+"//"+i}function h(n){var r=w(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(o.u)?n.mockDomain:r}function v(n){try{if(n===window)return!0}catch(n){}try{var r=Object.getOwnPropertyDescriptor(n,"location");if(r&&!1===r.enumerable)return!1}catch(n){}try{if(c(n)&&d())return!0}catch(n){}try{if(w(n)===w(window))return!0}catch(n){}return!1}function l(n){if(!v(n))return!1;try{if(n===window)return!0;if(c(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function m(n,r){if(!n||!r)return!1;var t=a(r);return t?t===n:-1!==function(n){var r=[];try{for(;n.parent!==n;)r.push(n.parent),n=n.parent}catch(n){}return r}(r).indexOf(n)}function y(n){var r,t,e=[];try{r=n.frames}catch(t){r=n}try{t=r.length}catch(n){}if(0===t)return e;if(t){for(var i=0;i<t;i++){var o=void 0;try{o=r[i]}catch(n){continue}e.push(o)}return e}for(var u=0;u<100;u++){var f=void 0;try{f=r[u]}catch(n){return e}if(!f)return e;e.push(f)}return e}var p=[],E=[];function g(n,r){void 0===r&&(r=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==f}if(r&&l(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var t=function(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}(p,n);if(-1!==t){var e=E[t];if(e&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var r=n.ownerDocument;return!(!r||!r.documentElement||r.documentElement.contains(n))}(e))return!0}return!1}function b(n){return s(n=n||window)||a(n)||void 0}function _(n,r){if("string"==typeof n){if("string"==typeof r)return n===u||r===n;if(i(r))return!1;if(Array.isArray(r))return!1}return i(n)?i(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!i(r)&&n.some(function(n){return _(n,r)}))}function x(n){try{if(n===window)return!0}catch(n){if(n&&n.message===f)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===f)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===f)return!0}return!1}function O(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&n instanceof window.constructor)return!1;var r={}.toString;if(r){var t=r.call(n);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var j,M=[],N=[],R=0;function W(){if(!R&&j){var n=j;j=null,n.resolve()}}function A(){R+=1}function P(){R-=1,W()}var S=function(){function n(n){var r=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=[],n){var t,e,i=!1,o=!1,u=!1;A();try{n(function(n){u?r.resolve(n):(i=!0,t=n)},function(n){u?r.reject(n):(o=!0,e=n)})}catch(n){return P(),void this.reject(n)}P(),u=!0,i?this.resolve(t):o&&this.reject(e)}}var r=n.prototype;return r.resolve=function(n){if(this.resolved||this.rejected)return this;if(O(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},r.reject=function(n){var r=this;if(this.resolved||this.rejected)return this;if(O(n))throw new Error("Can not reject promise with another promise");if(!n){var t=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout(function(){r.errorHandled||function(n,r){if(-1===M.indexOf(n)){M.push(n),setTimeout(function(){throw n},1);for(var t=0;t<N.length;t++)N[t](n,r)}}(n,r)},1),this.dispatch(),this},r.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},r.dispatch=function(){var r=this,t=this.resolved,e=this.rejected,i=this.handlers;if(!this.dispatching&&(t||e)){this.dispatching=!0,A();for(var o=function(o){var u=i[o],f=u.onSuccess,c=u.onError,a=u.promise,s=void 0;if(t)try{s=f?f(r.value):r.value}catch(n){return a.reject(n),"continue"}else if(e){if(!c)return a.reject(r.error),"continue";try{s=c(r.error)}catch(n){return a.reject(n),"continue"}}s instanceof n&&(s.resolved||s.rejected)?(s.resolved?a.resolve(s.value):a.reject(s.error),s.errorHandled=!0):O(s)?s instanceof n&&(s.resolved||s.rejected)?s.resolved?a.resolve(s.value):a.reject(s.error):s.then(function(n){a.resolve(n)},function(n){a.reject(n)}):a.resolve(s)},u=0;u<i.length;u++)o(u);i.length=0,this.dispatching=!1,P()}},r.then=function(r,t){if(r&&"function"!=typeof r&&!r.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 e=new n;return this.handlers.push({promise:e,onSuccess:r,onError:t}),this.errorHandled=!0,this.dispatch(),e},r.catch=function(n){return this.then(void 0,n)},r.finally=function(r){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.finally expected a function");return this.then(function(t){return n.try(r).then(function(){return t})},function(t){return n.try(r).then(function(){throw t})})},r.timeout=function(n,r){var t=this;if(this.resolved||this.rejected)return this;var e=setTimeout(function(){t.resolved||t.rejected||t.reject(r||new Error("Promise timed out after "+n+"ms"))},n);return this.then(function(n){return clearTimeout(e),n})},r.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(r){return r instanceof n?r:O(r)?new n(function(n,t){return r.then(n,t)}):(new n).resolve(r)},n.reject=function(r){return(new n).reject(r)},n.asyncReject=function(r){return(new n).asyncReject(r)},n.all=function(r){var t=new n,e=r.length,i=[];if(!e)return t.resolve(i),t;for(var o=function(o){var u=r[o];if(u instanceof n){if(u.resolved)return i[o]=u.value,e-=1,"continue"}else if(!O(u))return i[o]=u,e-=1,"continue";n.resolve(u).then(function(n){i[o]=n,0==(e-=1)&&t.resolve(i)},function(n){t.reject(n)})},u=0;u<r.length;u++)o(u);return 0===e&&t.resolve(i),t},n.hash=function(r){var t={};return n.all(Object.keys(r).map(function(e){return n.resolve(r[e]).then(function(n){t[e]=n})})).then(function(){return t})},n.map=function(r,t){return n.all(r.map(t))},n.onPossiblyUnhandledException=function(n){return function(n){return N.push(n),{cancel:function(){N.splice(N.indexOf(n),1)}}}(n)},n.try=function(r,t,e){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.try expected a function");var i;A();try{i=r.apply(t,e||[])}catch(r){return P(),n.reject(r)}return P(),n.resolve(i)},n.delay=function(r){return new n(function(n){setTimeout(n,r)})},n.isPromise=function(r){return!!(r&&r instanceof n)||O(r)},n.flush=function(){return r=j=j||new n,W(),r;var r},n}();function k(){return(k=Object.assign||function(n){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var e in t)({}).hasOwnProperty.call(t,e)&&(n[e]=t[e])}return n}).apply(this,arguments)}function T(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}var I,C=Object.defineProperty,L=Date.now()%1e9,D=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,L+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+L,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,r={};return Object.freeze(r),n.set(r,"__testvalue__"),"__testvalue__"===n.get(r)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var r=n.prototype;return r._cleanupClosedWindows=function(){for(var n=this.weakmap,r=this.keys,t=0;t<r.length;t++){var e=r[t];if(x(e)&&g(e)){if(n)try{n.delete(e)}catch(n){}r.splice(t,1),this.values.splice(t,1),t-=1}}},r.isSafeToReadWrite=function(n){return!x(n)},r.set=function(n,r){if(!n)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.set(n,r)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var e=this.name,i=n[e];i&&i[0]===n?i[1]=r:C(n,e,{value:[n,r],writable:!0})}else{this._cleanupClosedWindows();var o=this.keys,u=this.values,f=T(o,n);-1===f?(o.push(n),u.push(r)):u[f]=r}},r.get=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return r.get(n)}catch(n){delete this.weakmap}if(!this.isSafeToReadWrite(n)){this._cleanupClosedWindows();var t=T(this.keys,n);if(-1===t)return;return this.values[t]}var e=n[this.name];if(e&&e[0]===n)return e[1]},r.delete=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];t&&t[0]===n&&(t[0]=t[1]=void 0)}else{this._cleanupClosedWindows();var e=this.keys,i=T(e,n);-1!==i&&(e.splice(i,1),this.values.splice(i,1))}},r.has=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];return!(!t||t[0]!==n)}return this._cleanupClosedWindows(),-1!==T(this.keys,n)},r.getOrSet=function(n,r){if(this.has(n))return this.get(n);var t=r();return this.set(n,t),t},n}();function q(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(n){if("function"==typeof btoa)return btoa(n);if("undefined"!=typeof Buffer)return Buffer.from(n,"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 z(){}function B(n){return"[object RegExp]"==={}.toString.call(n)}function U(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var F=5e3,J=2e3,G=1e4,K=-1,H={g:"postrobot_message_request",_:"postrobot_message_response",O:"postrobot_message_ack"},Y={j:"postrobot_method",M:"postrobot_hello",N:"postrobot_open_tunnel"},Z="*",Q={R:"cross_domain_zalgo_promise",W:"cross_domain_function",A:"cross_domain_window"};function X(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_3__:n.__post_robot_10_0_3__=n.__post_robot_10_0_3__||{}}var V=function(){return{}};function $(n,r){return void 0===n&&(n="store"),void 0===r&&(r=V),U(X(),n,function(){var n=r();return{has:function(r){return n.hasOwnProperty(r)},get:function(r,t){return n.hasOwnProperty(r)?n[r]:t},set:function(r,t){return n[r]=t,t},del:function(r){delete n[r]},getOrSet:function(r,t){return U(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var nn=function(){};function rn(){var n=X();return n.P=n.P||new nn,n.P}function tn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=V),$("windowStore").getOrSet(n,function(){var t=new D,e=function(n){return t.getOrSet(n,r)};return{has:function(r){return e(r).hasOwnProperty(n)},get:function(r,t){var i=e(r);return i.hasOwnProperty(n)?i[n]:t},set:function(r,t){return e(r)[n]=t,t},del:function(r){delete e(r)[n]},getOrSet:function(r,t){return U(e(r),n,t)}}})}function en(){return $("instance").getOrSet("instanceID",q)}function on(n){return tn("helloPromises").getOrSet(n,function(){return new S})}function un(n,r){return(0,r.send)(n,Y.M,{instanceID:en()},{domain:Z,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return on(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function fn(n,r){var t=r.send;return tn("windowInstanceIDPromises").getOrSet(n,function(){return un(n,{send:t}).then(function(n){return n.instanceID})})}function cn(n){tn("knownWindows").set(n,!0)}var an,sn={S:"function",ERROR:"error",k:"promise",T:"regex",I:"date",C:"array",L:"object",D:"string",q:"number",B:"boolean",U:"null",F:"undefined"};function dn(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function wn(n){return void 0===n?sn.F:null===n?sn.U:Array.isArray(n)?sn.C:"function"==typeof n?sn.S:"object"==typeof n?n instanceof Error?sn.ERROR:"function"==typeof n.then?sn.k:"[object RegExp]"==={}.toString.call(n)?sn.T:"[object Date]"==={}.toString.call(n)?sn.I:sn.L:"string"==typeof n?sn.D:"number"==typeof n?sn.q:"boolean"==typeof n?sn.B:void 0}function hn(n,r){return{__type__:n,__val__:r}}var vn,ln=((an={})[sn.S]=function(){},an[sn.ERROR]=function(n){return hn(sn.ERROR,{message:n.message,stack:n.stack,code:n.code})},an[sn.k]=function(){},an[sn.T]=function(n){return hn(sn.T,n.source)},an[sn.I]=function(n){return hn(sn.I,n.toJSON())},an[sn.C]=function(n){return n},an[sn.L]=function(n){return n},an[sn.D]=function(n){return n},an[sn.q]=function(n){return n},an[sn.B]=function(n){return n},an[sn.U]=function(n){return n},an),mn={},yn=((vn={})[sn.S]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},vn[sn.ERROR]=function(n){var r=n.stack,t=n.code,e=new Error(n.message);return e.code=t,e.stack=r+"\n\n"+e.stack,e},vn[sn.k]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},vn[sn.T]=function(n){return new RegExp(n)},vn[sn.I]=function(n){return new Date(n)},vn[sn.C]=function(n){return n},vn[sn.L]=function(n){return n},vn[sn.D]=function(n){return n},vn[sn.q]=function(n){return n},vn[sn.B]=function(n){return n},vn[sn.U]=function(n){return n},vn),pn={};function En(){for(var n=$("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}new S(function(n){if(window.document&&window.document.body)return n(window.document.body);var r=setInterval(function(){if(window.document&&window.document.body)return clearInterval(r),n(window.document.body)},10)});var gn=function(){function n(n,r,t){var e=t.send;this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.serializedWindow=n,this.actualWindowPromise=new S,r&&this.setWindow(r),this.serializedWindow.getInstanceID=function(n){var r={};function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var o=function(n){try{return JSON.stringify([].slice.call(n),function(n,r){return"function"==typeof r?"memoize["+function(n){if(I=I||new D,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var r=I.get(n);return r||(r=typeof n+":"+q(),I.set(n,r)),r}(r)+"]":r})}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(e);return r.hasOwnProperty(o)?r[o]:(r[o]=n.apply(this,arguments).finally(function(){delete r[o]}),r[o])}return t.reset=function(){r={}},t}(this.serializedWindow.getInstanceID),this.send=e}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return"popup"===this.getType()},r.isIframe=function(){return"iframe"===this.getType()},r.setLocation=function(n){var r=this;return S.try(function(){if(!r.actualWindow)return r.serializedWindow.setLocation(n);r.actualWindow.location=n}).then(function(){return r})},r.setName=function(n){var r=this;return S.try(function(){if(!r.actualWindow)return r.serializedWindow.setName(n);if(!l(r.actualWindow))throw new Error("Can not set name for window on different domain");r.actualWindow.name=n,r.actualWindow.frameElement&&r.actualWindow.frameElement.setAttribute("name",n)}).then(function(){return r})},r.close=function(){var n=this;return S.try(function(){if(!n.actualWindow)return n.serializedWindow.close();n.actualWindow.close()}).then(function(){return n})},r.focus=function(){var n=this;return S.try(function(){return n.actualWindow&&n.actualWindow.focus(),n.serializedWindow.focus()}).then(function(){return n})},r.isClosed=function(){var n=this;return S.try(function(){return n.actualWindow?g(n.actualWindow):n.serializedWindow.isClosed()})},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return S.try(function(){return r.actualWindow?n===r.actualWindow:S.all([r.getInstanceID(),fn(n,{send:r.send})]).then(function(t){var e=t[0]===t[1];return e&&r.setWindow(n),e})})},r.unwrap=function(){return this.actualWindow||this},r.getInstanceID=function(){return this.actualWindow?fn(this.actualWindow,{send:this.send}):this.serializedWindow.getInstanceID()},r.serialize=function(){return this.serializedWindow},r.shouldClean=function(){return this.actualWindow&&g(this.actualWindow)},n.unwrap=function(r){return n.isProxyWindow(r)?r.unwrap():r},n.serialize=function(r,t){var e=t.send;return En(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,i=t.send;return En(),$("idToProxyWindow").getOrSet(r.id,function(){return new n(r,null,{on:e,send:i})})},n.isProxyWindow=function(n){return Boolean(n&&!x(n)&&n.isProxyWindow)},n.toProxyWindow=function(r,t){var e=t.send;return En(),n.isProxyWindow(r)?r:tn("winToProxyWindow").getOrSet(r,function(){var t=q();return $("idToProxyWindow").set(t,new n({id:t,type:s(r)?"popup":"iframe",getInstanceID:function(){return fn(r,{send:e})},close:function(){return S.try(function(){r.close()})},focus:function(){return S.try(function(){r.focus()})},isClosed:function(){return S.try(function(){return g(r)})},setLocation:function(n){return S.try(function(){if(l(r))try{if(r.location&&"function"==typeof r.location.replace)return void r.location.replace(n)}catch(n){}r.location=n})},setName:function(n){return S.try(function(){r.name=n})}},r,{send:e}))})},n}();function bn(n,r,t,e,i){var o=tn("methodStore"),u=$("proxyWindowMethods");gn.isProxyWindow(e)?u.set(n,{val:r,name:t,domain:i,source:e}):(u.del(n),o.getOrSet(e,function(){return{}})[n]={domain:i,name:t,val:r,source:e})}function _n(n,r){var t=tn("methodStore"),e=$("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function xn(n,r,t,e,i){!function(n){var r=i.on;$("builtinListeners").getOrSet("functionCalls",function(){return r(Y.j,{domain:Z},function(n){var r=n.source,t=n.origin,e=n.data,i=e.id,o=e.name,u=_n(r,i);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+h(window));var f=u.source,c=u.domain,a=u.val;return S.try(function(){if(!_(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify(B(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(gn.isProxyWindow(f))return f.matchWindow(r).then(function(n){if(!n)throw new Error("Method call '"+e.name+"' failed - proxy window does not match source in "+h(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return S.try(function(){if(a.onError)return a.onError(n)}).then(function(){throw n})}).then(function(n){return{result:n,id:i,name:o}})})})}();var o=t.__id__||q();n=gn.unwrap(n);var u=t.__name__||t.name||e;return gn.isProxyWindow(n)?(bn(o,t,u,n,r),n.awaitWindow().then(function(n){bn(o,t,u,n,r)})):bn(o,t,u,n,r),hn(Q.W,{id:o,name:u})}function On(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){void 0===r&&(r=mn);var t=JSON.stringify(n,function(n){var t=this[n];if(dn(this))return t;var e=wn(t);if(!e)return t;var i=r[e]||ln[e];return i?i(t,n):t});return void 0===t?sn.F:t}(t,((i={})[sn.k]=function(t,e){return function(n,r,t,e,i){return hn(Q.R,{then:xn(n,r,function(n,r){return t.then(n,r)},e,{on:i.on,send:i.send})})}(n,r,t,e,{on:o,send:u})},i[sn.S]=function(t,e){return xn(n,r,t,e,{on:o,send:u})},i[sn.L]=function(n){return x(n)||gn.isProxyWindow(n)?hn(Q.A,gn.serialize(n,{send:u})):n},i))}function jn(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=pn),n!==sn.F)return JSON.parse(n,function(n,t){if(dn(this))return t;var e,i;if(dn(t)?(e=t.__type__,i=t.__val__):(e=wn(t),i=t),!e)return i;var o=r[e]||yn[e];return o?o(i,n):i})}(t,((i={})[Q.R]=function(n){return new S(n.then)},i[Q.W]=function(t){return function(n,r,e,i){var o=t.id,u=t.name,f=i.send,c=function(t){function e(){var i=arguments;return gn.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=_n(n,o);return c&&c.val!==e?c.val.apply({source:window,origin:h()},i):f(n,Y.j,{id:o,name:u,args:[].slice.call(i)},{domain:r,fireAndForget:t.fireAndForget}).then(function(n){if(!t.fireAndForget)return n.data.result})}).catch(function(n){throw n})}return void 0===t&&(t={}),e.__name__=u,e.__origin__=r,e.__source__=n,e.__id__=o,e.origin=r,e},a=c();return a.fireAndForget=c({fireAndForget:!0}),a}(n,r,0,{on:o,send:u})},i[Q.A]=function(n){return gn.deserialize(n,{on:(r={on:o,send:u}).on,send:r.send});var r},i))}var Mn={};function Nn(n,r,t,e){var i,o=e.on,u=e.send;if(g(n))throw new Error("Window is closed");for(var f,c=On(n,r,((i={}).__post_robot_10_0_3__=k({id:q(),origin:h(window)},t),i),{on:o,send:u}),a=!1,s=0,d=Object.keys(Mn);s<d.length;s++){var w=d[s];try{Mn[w](n,c,r),a=!0}catch(n){f=f||n}}if(!a)throw f}Mn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[Z]).map(function(r){if(0===r.indexOf(o.u)){if(window.location.protocol===o.h)return Z;if(!v(n))throw new Error("Attempting to send messsage to mock domain "+r+", but window is actually cross-domain");return w(n)}return 0===r.indexOf(o.h)?Z:r}).forEach(function(t){n.postMessage(r,t)})};var Rn,Wn="__domain_regex__";function An(n){return $("responseListeners").get(n)}function Pn(n){$("responseListeners").del(n)}function Sn(n){return $("erroredResponseListeners").has(n)}function kn(n){var r=n.name,t=n.win,e=n.domain,i=tn("requestListeners");if(t===Z&&(t=null),e===Z&&(e=null),!r)throw new Error("Name required to get request listener");for(var o=0,u=[t,rn()];o<u.length;o++){var f=u[o];if(f){var c=i.get(f);if(c){var a=c[r];if(a){if(e&&"string"==typeof e){if(a[e])return a[e];if(a[Wn])for(var s=0,d=a[Wn];s<d.length;s++){var w=d[s],h=w.listener;if(_(w.regex,e))return h}}if(a[Z])return a[Z]}}}}}var Tn=((Rn={})[H.g]=function(n,r,t,e){var i=e.on,o=e.send,u=kn({name:t.name,win:n,domain:r});function f(e,u,f){void 0===f&&(f={}),t.fireAndForget||g(n)||Nn(n,r,k({type:e,ack:u,hash:t.hash,name:t.name},f),{on:i,send:o})}return S.all([f(H.O),S.try(function(){if(!u)throw new Error("No handler found for post message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(u.domain,r))throw new Error("Request origin "+r+" does not match domain "+u.domain.toString());return u.handler({source:n,origin:r,data:t.data})}).then(function(n){return f(H._,"success",{data:n})},function(n){return f(H._,"error",{error:n})})]).then(z).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Rn[H.O]=function(n,r,t){if(!Sn(t.hash)){var e=An(t.hash);if(!e)throw new Error("No handler found for post message ack for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(e.domain,r))throw new Error("Ack origin "+r+" does not match domain "+e.domain.toString());if(n!==e.win)throw new Error("Ack source does not match registered window");e.ack=!0}},Rn[H._]=function(n,r,t){if(!Sn(t.hash)){var e,o=An(t.hash);if(!o)throw new Error("No handler found for post message response for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(o.domain,r))throw new Error("Response origin "+r+" does not match domain "+(e=o.domain,Array.isArray(e)?"("+e.join(" | ")+")":i(e)?"RegExp("+e.toString():e.toString()));if(n!==o.win)throw new Error("Response source does not match registered window");Pn(t.hash),"error"===t.ack?o.promise.reject(t.error):"success"===t.ack&&o.promise.resolve({source:n,origin:r,data:t.data})}},Rn);function In(n,r){var t=r.on,e=r.send,i=$("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var u=n.source,f=n.origin,c=function(n,r,t,e){var i,o=e.on,u=e.send;try{i=jn(r,t,n,{on:o,send:u})}catch(n){return}if(i&&"object"==typeof i&&null!==i&&(i=i.__post_robot_10_0_3__)&&"object"==typeof i&&null!==i&&i.type&&"string"==typeof i.type&&Tn[i.type])return i}(n.data,u,f,{on:t,send:e});c&&(cn(u),i.has(c.id)||(i.set(c.id,!0),g(u)&&!c.fireAndForget||(0===c.origin.indexOf(o.h)&&(f=c.origin),Tn[c.type](u,f,c,{on:t,send:e}))))}function Cn(n,r,t){if(!n)throw new Error("Expected name");if("function"==typeof r&&(t=r,r={}),!t)throw new Error("Expected handler");(r=r||{}).name=n,r.handler=t||r.handler;var e=r.window,i=r.domain,o=function n(r,t){var e=r.name,i=r.win,o=r.domain,u=tn("requestListeners");if(!e||"string"!=typeof e)throw new Error("Name required to add request listener");if(Array.isArray(i)){for(var f=[],c=0,a=i;c<a.length;c++)f.push(n({name:e,domain:o,win:a[c]},t));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}if(Array.isArray(o)){for(var s=[],d=0,w=o;d<w.length;d++)s.push(n({name:e,win:i,domain:w[d]},t));return{cancel:function(){for(var n=0;n<s.length;n++)s[n].cancel()}}}var h=kn({name:e,win:i,domain:o});if(i&&i!==Z||(i=rn()),o=o||Z,h)throw i&&o?new Error("Request listener already exists for "+e+" on domain "+o.toString()+" for "+(i===rn()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+e+" for "+(i===rn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+e+" on domain "+o.toString()):new Error("Request listener already exists for "+e);var v,l,m=u.getOrSet(i,function(){return{}}),y=U(m,e,function(){return{}}),p=o.toString();return B(o)?(v=U(y,Wn,function(){return[]})).push(l={regex:o,listener:t}):y[p]=t,{cancel:function(){delete y[p],l&&(v.splice(v.indexOf(l,1)),v.length||delete y[Wn]),Object.keys(y).length||delete m[e],i&&!Object.keys(m).length&&u.del(i)}}}({name:n,win:e,domain:i},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:i||Z,name:n});return{cancel:function(){o.cancel()}}}function Ln(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,i=new S;return r.errorHandler=function(n){e.cancel(),i.reject(n)},e=Cn(n,r,function(n){if(e.cancel(),i.resolve(n),t)return t(n)}),i.cancel=e.cancel,i}function Dn(n,r,t,e){var i=(e=e||{}).domain||Z,o=e.timeout||K,u=e.timeout||F,f=e.fireAndForget||!1;return S.try(function(){if(!r)throw new Error("Expected name");if(i&&"string"!=typeof i&&!Array.isArray(i)&&!B(i))throw new TypeError("Expected domain to be a string, array, or regex");if(g(n))throw new Error("Target window is closed");var e=tn("requestPromises").getOrSet(n,function(){return[]}),c=S.try(function(){return function(n,r){var t=b(r);if(t)return t===n;if(r===n)return!1;if(function(n){if(n){try{if(n.top)return n.top}catch(n){}if(a(n)===n)return n;try{if(m(window,n)&&window.top)return window.top}catch(n){}try{if(m(n,window)&&window.top)return window.top}catch(n){}for(var r=0,t=function n(r){for(var t=[],e=0,i=y(r);e<i.length;e++){var o=i[e];t.push(o);for(var u=0,f=n(o);u<f.length;u++)t.push(f[u])}return t}(n);r<t.length;r++){var e=t[r];try{if(e.top)return e.top}catch(n){}if(a(e)===e)return e}}}(r)===r)return!1;for(var e=0,i=y(n);e<i.length;e++)if(i[e]===r)return!0;return!1}(window,n)?function(n,r,t){void 0===r&&(r=5e3),void 0===t&&(t="Window");var e=on(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}(n,u):B(i)?un(n,{send:Dn}):void 0}).then(function(u){var a=(void 0===u?{}:u).domain;if(B(i)){if(!_(i,a))throw new Error("Remote window domain "+a+" does not match regex: "+i.source);i=a}var s=!1,d=new S;d.finally(function(){s=!0,e.splice(e.indexOf(c,1))}).catch(z);var w=r+"_"+q();if(Nn(n,i,{type:H.g,hash:w,name:r,data:t,fireAndForget:f},{on:Cn,send:Dn}),f)return d.resolve();d.catch(function(){!function(n){$("erroredResponseListeners").set(n,!0)}(w),Pn(w)});var v={name:r,win:n,domain:i,promise:d};!function(n,r){$("responseListeners").set(n,r)}(w,v);var l=function(n){return tn("knownWindows").get(n,!1)}(n)?G:J,m=o,y=l,p=m,E=100;return setTimeout(function t(){if(!s){if(g(n))return d.reject(v.ack?new Error("Window closed for "+r+" before response"):new Error("Window closed for "+r+" before ack"));if(y=Math.max(y-E,0),-1!==p&&(p=Math.max(p-E,0)),v.ack){if(-1===p)return;E=Math.min(p,2e3)}else{if(0===y)return d.reject(new Error("No ack for postMessage "+r+" in "+h()+" in "+l+"ms"));if(0===p)return d.reject(new Error("No response for postMessage "+r+" in "+h()+" in "+m+"ms"))}setTimeout(t,E)}},E),d});return e.push(c),c})}function qn(n,r,t){return On(n,r,t,{on:Cn,send:Dn})}function zn(n,r,t){return jn(n,r,t,{on:Cn,send:Dn})}function Bn(n){return gn.toProxyWindow(n,{send:Dn})}function Un(){var n,r,t,e;X().initialized||(X().initialized=!0,function(n){var r=n.on,t=n.send;$().getOrSet("postMessageListeners",function(){return(n=window).addEventListener("message",e=function(n){!function(n,r){var t=r.on,e=r.send,i=n.source||n.sourceElement,u=n.origin||n.originalEvent&&n.originalEvent.origin,f=n.data;if("null"===u&&(u=o.h+"//"),i){if(!u)throw new Error("Post message did not have origin domain");In({source:i,origin:u,data:f},{on:t,send:e})}}(n,{on:r,send:t})}),{cancel:function(){n.removeEventListener("message",e)}};var n,e})}({on:Cn,send:Dn}),function(n){var r=n.on,t=n.send;$("builtinListeners").getOrSet("helloListener",function(){var n=r(Y.M,{domain:Z},function(n){var r=n.source,t=n.origin;return on(r).resolve({win:r,domain:t}),{instanceID:en()}}),e=b();return e&&un(e,{send:t}).catch(z),n})}({on:Cn,send:Dn}),r=(n={on:Cn,send:Dn}).on,t=n.send,(e=X()).receiveMessage=e.receiveMessage||function(n){return In(n,{on:r,send:t})})}function Fn(n){for(var r=0,t=tn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(z)}t.d(r,"bridge",function(){}),t.d(r,"Promise",function(){return S}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return gn}),t.d(r,"setup",function(){return Un}),t.d(r,"serializeMessage",function(){return qn}),t.d(r,"deserializeMessage",function(){return zn}),t.d(r,"toProxyWindow",function(){return Bn}),t.d(r,"on",function(){return Cn}),t.d(r,"once",function(){return Ln}),t.d(r,"send",function(){return Dn}),t.d(r,"markWindowKnown",function(){return cn}),t.d(r,"cleanUpWindow",function(){return Fn}),Un()}])}); | ||
!function(n,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():n.postRobot=r()}("undefined"!=typeof self?self:this,function(){return function(n){var r={};function t(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return n[e].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=n,t.c=r,t.d=function(n,r,e){t.o(n,r)||Object.defineProperty(n,r,{enumerable:!0,get:e})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,r){if(1&r&&(n=t(n)),8&r)return n;if(4&r&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&r&&"string"!=typeof n)for(var i in n)t.d(e,i,function(r){return n[r]}.bind(null,i));return e},t.n=function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(r,"a",r),r},t.o=function(n,r){return{}.hasOwnProperty.call(n,r)},t.p="",t(t.s=0)}([function(n,r,t){"use strict";t.r(r);var e={};function i(n){return"[object RegExp]"==={}.toString.call(n)}t.r(e),t.d(e,"WeakMap",function(){return D});var o={u:"mock:",h:"file:",v:"about:"},u="*",f="Call was rejected by callee.\r\n";function c(n){return void 0===n&&(n=window),n.location.protocol===o.v}function a(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function s(n){if(n&&!a(n))try{return n.opener}catch(n){}}function d(n){try{return!0}catch(n){}return!1}function w(n){var r=(n=n||window).location;if(!r)throw new Error("Can not read window location");var t=r.protocol;if(!t)throw new Error("Can not read window protocol");if(t===o.h)return o.h+"//";if(t===o.v){var e=a(n);return e&&d()?w(e):o.v+"//"}var i=r.host;if(!i)throw new Error("Can not read window host");return t+"//"+i}function h(n){var r=w(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(o.u)?n.mockDomain:r}function v(n){try{if(n===window)return!0}catch(n){}try{var r=Object.getOwnPropertyDescriptor(n,"location");if(r&&!1===r.enumerable)return!1}catch(n){}try{if(c(n)&&d())return!0}catch(n){}try{if(w(n)===w(window))return!0}catch(n){}return!1}function l(n){if(!v(n))return!1;try{if(n===window)return!0;if(c(n)&&d())return!0;if(h(window)===h(n))return!0}catch(n){}return!1}function m(n,r){if(!n||!r)return!1;var t=a(r);return t?t===n:-1!==function(n){var r=[];try{for(;n.parent!==n;)r.push(n.parent),n=n.parent}catch(n){}return r}(r).indexOf(n)}function y(n){var r,t,e=[];try{r=n.frames}catch(t){r=n}try{t=r.length}catch(n){}if(0===t)return e;if(t){for(var i=0;i<t;i++){var o=void 0;try{o=r[i]}catch(n){continue}e.push(o)}return e}for(var u=0;u<100;u++){var f=void 0;try{f=r[u]}catch(n){return e}if(!f)return e;e.push(f)}return e}var p=[],E=[];function g(n,r){void 0===r&&(r=!0);try{if(n===window)return!1}catch(n){return!0}try{if(!n)return!0}catch(n){return!0}try{if(n.closed)return!0}catch(n){return!n||n.message!==f}if(r&&l(n))try{if(n.mockclosed)return!0}catch(n){}try{if(!n.parent||!n.top)return!0}catch(n){}var t=function(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}(p,n);if(-1!==t){var e=E[t];if(e&&function(n){if(!n.contentWindow)return!0;if(!n.parentNode)return!0;var r=n.ownerDocument;return!(!r||!r.documentElement||r.documentElement.contains(n))}(e))return!0}return!1}function b(n){return s(n=n||window)||a(n)||void 0}function _(n,r){if("string"==typeof n){if("string"==typeof r)return n===u||r===n;if(i(r))return!1;if(Array.isArray(r))return!1}return i(n)?i(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!i(r)&&n.some(function(n){return _(n,r)}))}function x(n){try{if(n===window)return!0}catch(n){if(n&&n.message===f)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===f)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===f)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===f)return!0}return!1}function O(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&n instanceof window.constructor)return!1;var r={}.toString;if(r){var t=r.call(n);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var j,M=[],N=[],R=0;function W(){if(!R&&j){var n=j;j=null,n.resolve()}}function A(){R+=1}function P(){R-=1,W()}var S=function(){function n(n){var r=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=[],n){var t,e,i=!1,o=!1,u=!1;A();try{n(function(n){u?r.resolve(n):(i=!0,t=n)},function(n){u?r.reject(n):(o=!0,e=n)})}catch(n){return P(),void this.reject(n)}P(),u=!0,i?this.resolve(t):o&&this.reject(e)}}var r=n.prototype;return r.resolve=function(n){if(this.resolved||this.rejected)return this;if(O(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},r.reject=function(n){var r=this;if(this.resolved||this.rejected)return this;if(O(n))throw new Error("Can not reject promise with another promise");if(!n){var t=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout(function(){r.errorHandled||function(n,r){if(-1===M.indexOf(n)){M.push(n),setTimeout(function(){throw n},1);for(var t=0;t<N.length;t++)N[t](n,r)}}(n,r)},1),this.dispatch(),this},r.asyncReject=function(n){return this.errorHandled=!0,this.reject(n),this},r.dispatch=function(){var r=this,t=this.resolved,e=this.rejected,i=this.handlers;if(!this.dispatching&&(t||e)){this.dispatching=!0,A();for(var o=function(o){var u=i[o],f=u.onSuccess,c=u.onError,a=u.promise,s=void 0;if(t)try{s=f?f(r.value):r.value}catch(n){return a.reject(n),"continue"}else if(e){if(!c)return a.reject(r.error),"continue";try{s=c(r.error)}catch(n){return a.reject(n),"continue"}}s instanceof n&&(s.resolved||s.rejected)?(s.resolved?a.resolve(s.value):a.reject(s.error),s.errorHandled=!0):O(s)?s instanceof n&&(s.resolved||s.rejected)?s.resolved?a.resolve(s.value):a.reject(s.error):s.then(function(n){a.resolve(n)},function(n){a.reject(n)}):a.resolve(s)},u=0;u<i.length;u++)o(u);i.length=0,this.dispatching=!1,P()}},r.then=function(r,t){if(r&&"function"!=typeof r&&!r.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 e=new n;return this.handlers.push({promise:e,onSuccess:r,onError:t}),this.errorHandled=!0,this.dispatch(),e},r.catch=function(n){return this.then(void 0,n)},r.finally=function(r){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.finally expected a function");return this.then(function(t){return n.try(r).then(function(){return t})},function(t){return n.try(r).then(function(){throw t})})},r.timeout=function(n,r){var t=this;if(this.resolved||this.rejected)return this;var e=setTimeout(function(){t.resolved||t.rejected||t.reject(r||new Error("Promise timed out after "+n+"ms"))},n);return this.then(function(n){return clearTimeout(e),n})},r.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},n.resolve=function(r){return r instanceof n?r:O(r)?new n(function(n,t){return r.then(n,t)}):(new n).resolve(r)},n.reject=function(r){return(new n).reject(r)},n.asyncReject=function(r){return(new n).asyncReject(r)},n.all=function(r){var t=new n,e=r.length,i=[];if(!e)return t.resolve(i),t;for(var o=function(o){var u=r[o];if(u instanceof n){if(u.resolved)return i[o]=u.value,e-=1,"continue"}else if(!O(u))return i[o]=u,e-=1,"continue";n.resolve(u).then(function(n){i[o]=n,0==(e-=1)&&t.resolve(i)},function(n){t.reject(n)})},u=0;u<r.length;u++)o(u);return 0===e&&t.resolve(i),t},n.hash=function(r){var t={};return n.all(Object.keys(r).map(function(e){return n.resolve(r[e]).then(function(n){t[e]=n})})).then(function(){return t})},n.map=function(r,t){return n.all(r.map(t))},n.onPossiblyUnhandledException=function(n){return function(n){return N.push(n),{cancel:function(){N.splice(N.indexOf(n),1)}}}(n)},n.try=function(r,t,e){if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.try expected a function");var i;A();try{i=r.apply(t,e||[])}catch(r){return P(),n.reject(r)}return P(),n.resolve(i)},n.delay=function(r){return new n(function(n){setTimeout(n,r)})},n.isPromise=function(r){return!!(r&&r instanceof n)||O(r)},n.flush=function(){return r=j=j||new n,W(),r;var r},n}();function k(){return(k=Object.assign||function(n){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var e in t)({}).hasOwnProperty.call(t,e)&&(n[e]=t[e])}return n}).apply(this,arguments)}function T(n,r){for(var t=0;t<n.length;t++)try{if(n[t]===r)return t}catch(n){}return-1}var I,C=Object.defineProperty,L=Date.now()%1e9,D=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,L+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+L,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,r={};return Object.freeze(r),n.set(r,"__testvalue__"),"__testvalue__"===n.get(r)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var r=n.prototype;return r._cleanupClosedWindows=function(){for(var n=this.weakmap,r=this.keys,t=0;t<r.length;t++){var e=r[t];if(x(e)&&g(e)){if(n)try{n.delete(e)}catch(n){}r.splice(t,1),this.values.splice(t,1),t-=1}}},r.isSafeToReadWrite=function(n){return!x(n)},r.set=function(n,r){if(!n)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.set(n,r)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var e=this.name,i=n[e];i&&i[0]===n?i[1]=r:C(n,e,{value:[n,r],writable:!0})}else{this._cleanupClosedWindows();var o=this.keys,u=this.values,f=T(o,n);-1===f?(o.push(n),u.push(r)):u[f]=r}},r.get=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return r.get(n)}catch(n){delete this.weakmap}if(!this.isSafeToReadWrite(n)){this._cleanupClosedWindows();var t=T(this.keys,n);if(-1===t)return;return this.values[t]}var e=n[this.name];if(e&&e[0]===n)return e[1]},r.delete=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(n)}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];t&&t[0]===n&&(t[0]=t[1]=void 0)}else{this._cleanupClosedWindows();var e=this.keys,i=T(e,n);-1!==i&&(e.splice(i,1),this.values.splice(i,1))}},r.has=function(n){if(!n)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(n))return!0}catch(n){delete this.weakmap}if(this.isSafeToReadWrite(n)){var t=n[this.name];return!(!t||t[0]!==n)}return this._cleanupClosedWindows(),-1!==T(this.keys,n)},r.getOrSet=function(n,r){if(this.has(n))return this.get(n);var t=r();return this.set(n,t),t},n}();function q(){var n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(n){if("function"==typeof btoa)return btoa(n);if("undefined"!=typeof Buffer)return Buffer.from(n,"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 z(){}function B(n){return"[object RegExp]"==={}.toString.call(n)}function U(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var F=5e3,J=2e3,G=1e4,K=-1,H={g:"postrobot_message_request",_:"postrobot_message_response",O:"postrobot_message_ack"},Y={j:"postrobot_method",M:"postrobot_hello",N:"postrobot_open_tunnel"},Z="*",Q={R:"cross_domain_zalgo_promise",W:"cross_domain_function",A:"cross_domain_window"};function X(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_4__:n.__post_robot_10_0_4__=n.__post_robot_10_0_4__||{}}var V=function(){return{}};function $(n,r){return void 0===n&&(n="store"),void 0===r&&(r=V),U(X(),n,function(){var n=r();return{has:function(r){return n.hasOwnProperty(r)},get:function(r,t){return n.hasOwnProperty(r)?n[r]:t},set:function(r,t){return n[r]=t,t},del:function(r){delete n[r]},getOrSet:function(r,t){return U(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var nn=function(){};function rn(){var n=X();return n.P=n.P||new nn,n.P}function tn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=V),$("windowStore").getOrSet(n,function(){var t=new D,e=function(n){return t.getOrSet(n,r)};return{has:function(r){return e(r).hasOwnProperty(n)},get:function(r,t){var i=e(r);return i.hasOwnProperty(n)?i[n]:t},set:function(r,t){return e(r)[n]=t,t},del:function(r){delete e(r)[n]},getOrSet:function(r,t){return U(e(r),n,t)}}})}function en(){return $("instance").getOrSet("instanceID",q)}function on(n){return tn("helloPromises").getOrSet(n,function(){return new S})}function un(n,r){return(0,r.send)(n,Y.M,{instanceID:en()},{domain:Z,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return on(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function fn(n,r){var t=r.send;return tn("windowInstanceIDPromises").getOrSet(n,function(){return un(n,{send:t}).then(function(n){return n.instanceID})})}function cn(n){tn("knownWindows").set(n,!0)}var an,sn={S:"function",ERROR:"error",k:"promise",T:"regex",I:"date",C:"array",L:"object",D:"string",q:"number",B:"boolean",U:"null",F:"undefined"};function dn(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function wn(n){return void 0===n?sn.F:null===n?sn.U:Array.isArray(n)?sn.C:"function"==typeof n?sn.S:"object"==typeof n?n instanceof Error?sn.ERROR:"function"==typeof n.then?sn.k:"[object RegExp]"==={}.toString.call(n)?sn.T:"[object Date]"==={}.toString.call(n)?sn.I:sn.L:"string"==typeof n?sn.D:"number"==typeof n?sn.q:"boolean"==typeof n?sn.B:void 0}function hn(n,r){return{__type__:n,__val__:r}}var vn,ln=((an={})[sn.S]=function(){},an[sn.ERROR]=function(n){return hn(sn.ERROR,{message:n.message,stack:n.stack,code:n.code})},an[sn.k]=function(){},an[sn.T]=function(n){return hn(sn.T,n.source)},an[sn.I]=function(n){return hn(sn.I,n.toJSON())},an[sn.C]=function(n){return n},an[sn.L]=function(n){return n},an[sn.D]=function(n){return n},an[sn.q]=function(n){return n},an[sn.B]=function(n){return n},an[sn.U]=function(n){return n},an),mn={},yn=((vn={})[sn.S]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},vn[sn.ERROR]=function(n){var r=n.stack,t=n.code,e=new Error(n.message);return e.code=t,e.stack=r+"\n\n"+e.stack,e},vn[sn.k]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},vn[sn.T]=function(n){return new RegExp(n)},vn[sn.I]=function(n){return new Date(n)},vn[sn.C]=function(n){return n},vn[sn.L]=function(n){return n},vn[sn.D]=function(n){return n},vn[sn.q]=function(n){return n},vn[sn.B]=function(n){return n},vn[sn.U]=function(n){return n},vn),pn={};function En(){for(var n=$("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}new S(function(n){if(window.document&&window.document.body)return n(window.document.body);var r=setInterval(function(){if(window.document&&window.document.body)return clearInterval(r),n(window.document.body)},10)});var gn=function(){function n(n,r,t){var e=t.send;this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.serializedWindow=n,this.actualWindowPromise=new S,r&&this.setWindow(r),this.serializedWindow.getInstanceID=function(n){var r={};function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var o=function(n){try{return JSON.stringify([].slice.call(n),function(n,r){return"function"==typeof r?"memoize["+function(n){if(I=I||new D,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var r=I.get(n);return r||(r=typeof n+":"+q(),I.set(n,r)),r}(r)+"]":r})}catch(n){throw new Error("Arguments not serializable -- can not be used to memoize")}}(e);return r.hasOwnProperty(o)?r[o]:(r[o]=n.apply(this,arguments).finally(function(){delete r[o]}),r[o])}return t.reset=function(){r={}},t}(this.serializedWindow.getInstanceID),this.send=e}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return"popup"===this.getType()},r.isIframe=function(){return"iframe"===this.getType()},r.setLocation=function(n){var r=this;return S.try(function(){if(!r.actualWindow)return r.serializedWindow.setLocation(n);r.actualWindow.location=n}).then(function(){return r})},r.setName=function(n){var r=this;return S.try(function(){if(!r.actualWindow)return r.serializedWindow.setName(n);if(!l(r.actualWindow))throw new Error("Can not set name for window on different domain");r.actualWindow.name=n,r.actualWindow.frameElement&&r.actualWindow.frameElement.setAttribute("name",n)}).then(function(){return r})},r.close=function(){var n=this;return S.try(function(){if(!n.actualWindow)return n.serializedWindow.close();n.actualWindow.close()}).then(function(){return n})},r.focus=function(){var n=this;return S.try(function(){return n.actualWindow&&n.actualWindow.focus(),n.serializedWindow.focus()}).then(function(){return n})},r.isClosed=function(){var n=this;return S.try(function(){return n.actualWindow?g(n.actualWindow):n.serializedWindow.isClosed()})},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return S.try(function(){return r.actualWindow?n===r.actualWindow:S.all([r.getInstanceID(),fn(n,{send:r.send})]).then(function(t){var e=t[0]===t[1];return e&&r.setWindow(n),e})})},r.unwrap=function(){return this.actualWindow||this},r.getInstanceID=function(){return this.actualWindow?fn(this.actualWindow,{send:this.send}):this.serializedWindow.getInstanceID()},r.serialize=function(){return this.serializedWindow},r.shouldClean=function(){return this.actualWindow&&g(this.actualWindow)},n.unwrap=function(r){return n.isProxyWindow(r)?r.unwrap():r},n.serialize=function(r,t){var e=t.send;return En(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,i=t.send;return En(),$("idToProxyWindow").getOrSet(r.id,function(){return new n(r,null,{on:e,send:i})})},n.isProxyWindow=function(n){return Boolean(n&&!x(n)&&n.isProxyWindow)},n.toProxyWindow=function(r,t){var e=t.send;return En(),n.isProxyWindow(r)?r:tn("winToProxyWindow").getOrSet(r,function(){var t=q();return $("idToProxyWindow").set(t,new n({id:t,type:s(r)?"popup":"iframe",getInstanceID:function(){return fn(r,{send:e})},close:function(){return S.try(function(){r.close()})},focus:function(){return S.try(function(){r.focus()})},isClosed:function(){return S.try(function(){return g(r)})},setLocation:function(n){return S.try(function(){if(l(r))try{if(r.location&&"function"==typeof r.location.replace)return void r.location.replace(n)}catch(n){}r.location=n})},setName:function(n){return S.try(function(){r.name=n})}},r,{send:e}))})},n}();function bn(n,r,t,e,i){var o=tn("methodStore"),u=$("proxyWindowMethods");gn.isProxyWindow(e)?u.set(n,{val:r,name:t,domain:i,source:e}):(u.del(n),o.getOrSet(e,function(){return{}})[n]={domain:i,name:t,val:r,source:e})}function _n(n,r){var t=tn("methodStore"),e=$("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function xn(n,r,t,e,i){!function(n){var r=i.on;$("builtinListeners").getOrSet("functionCalls",function(){return r(Y.j,{domain:Z},function(n){var r=n.source,t=n.origin,e=n.data,i=e.id,o=e.name,u=_n(r,i);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+h(window));var f=u.source,c=u.domain,a=u.val;return S.try(function(){if(!_(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify(B(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+h(window));if(gn.isProxyWindow(f))return f.matchWindow(r).then(function(n){if(!n)throw new Error("Method call '"+e.name+"' failed - proxy window does not match source in "+h(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return S.try(function(){if(a.onError)return a.onError(n)}).then(function(){throw n.stack&&(n.stack="Remote call to "+o+"()\n\n"+n.stack),n})}).then(function(n){return{result:n,id:i,name:o}})})})}();var o=t.__id__||q();n=gn.unwrap(n);var u=t.__name__||t.name||e;return gn.isProxyWindow(n)?(bn(o,t,u,n,r),n.awaitWindow().then(function(n){bn(o,t,u,n,r)})):bn(o,t,u,n,r),hn(Q.W,{id:o,name:u})}function On(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){void 0===r&&(r=mn);var t=JSON.stringify(n,function(n){var t=this[n];if(dn(this))return t;var e=wn(t);if(!e)return t;var i=r[e]||ln[e];return i?i(t,n):t});return void 0===t?sn.F:t}(t,((i={})[sn.k]=function(t,e){return function(n,r,t,e,i){return hn(Q.R,{then:xn(n,r,function(n,r){return t.then(n,r)},e,{on:i.on,send:i.send})})}(n,r,t,e,{on:o,send:u})},i[sn.S]=function(t,e){return xn(n,r,t,e,{on:o,send:u})},i[sn.L]=function(n){return x(n)||gn.isProxyWindow(n)?hn(Q.A,gn.serialize(n,{send:u})):n},i))}function jn(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=pn),n!==sn.F)return JSON.parse(n,function(n,t){if(dn(this))return t;var e,i;if(dn(t)?(e=t.__type__,i=t.__val__):(e=wn(t),i=t),!e)return i;var o=r[e]||yn[e];return o?o(i,n):i})}(t,((i={})[Q.R]=function(n){return new S(n.then)},i[Q.W]=function(t){return function(n,r,e,i){var o=t.id,u=t.name,f=i.send,c=function(t){function e(){var i=arguments;return gn.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=_n(n,o);return c&&c.val!==e?c.val.apply({source:window,origin:h()},i):f(n,Y.j,{id:o,name:u,args:[].slice.call(i)},{domain:r,fireAndForget:t.fireAndForget}).then(function(n){if(!t.fireAndForget)return n.data.result})}).catch(function(n){throw n})}return void 0===t&&(t={}),e.__name__=u,e.__origin__=r,e.__source__=n,e.__id__=o,e.origin=r,e},a=c();return a.fireAndForget=c({fireAndForget:!0}),a}(n,r,0,{on:o,send:u})},i[Q.A]=function(n){return gn.deserialize(n,{on:(r={on:o,send:u}).on,send:r.send});var r},i))}var Mn={};function Nn(n,r,t,e){var i,o=e.on,u=e.send;if(g(n))throw new Error("Window is closed");for(var f,c=On(n,r,((i={}).__post_robot_10_0_4__=k({id:q(),origin:h(window)},t),i),{on:o,send:u}),a=!1,s=0,d=Object.keys(Mn);s<d.length;s++){var w=d[s];try{Mn[w](n,c,r),a=!0}catch(n){f=f||n}}if(!a)throw f}Mn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[Z]).map(function(r){if(0===r.indexOf(o.u)){if(window.location.protocol===o.h)return Z;if(!v(n))throw new Error("Attempting to send messsage to mock domain "+r+", but window is actually cross-domain");return w(n)}return 0===r.indexOf(o.h)?Z:r}).forEach(function(t){n.postMessage(r,t)})};var Rn,Wn="__domain_regex__";function An(n){return $("responseListeners").get(n)}function Pn(n){$("responseListeners").del(n)}function Sn(n){return $("erroredResponseListeners").has(n)}function kn(n){var r=n.name,t=n.win,e=n.domain,i=tn("requestListeners");if(t===Z&&(t=null),e===Z&&(e=null),!r)throw new Error("Name required to get request listener");for(var o=0,u=[t,rn()];o<u.length;o++){var f=u[o];if(f){var c=i.get(f);if(c){var a=c[r];if(a){if(e&&"string"==typeof e){if(a[e])return a[e];if(a[Wn])for(var s=0,d=a[Wn];s<d.length;s++){var w=d[s],h=w.listener;if(_(w.regex,e))return h}}if(a[Z])return a[Z]}}}}}var Tn=((Rn={})[H.g]=function(n,r,t,e){var i=e.on,o=e.send,u=kn({name:t.name,win:n,domain:r});function f(e,u,f){void 0===f&&(f={}),t.fireAndForget||g(n)||Nn(n,r,k({type:e,ack:u,hash:t.hash,name:t.name},f),{on:i,send:o})}return S.all([f(H.O),S.try(function(){if(!u)throw new Error("No handler found for post message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(u.domain,r))throw new Error("Request origin "+r+" does not match domain "+u.domain.toString());return u.handler({source:n,origin:r,data:t.data})}).then(function(n){return f(H._,"success",{data:n})},function(n){return f(H._,"error",{error:n})})]).then(z).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Rn[H.O]=function(n,r,t){if(!Sn(t.hash)){var e=An(t.hash);if(!e)throw new Error("No handler found for post message ack for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(e.domain,r))throw new Error("Ack origin "+r+" does not match domain "+e.domain.toString());if(n!==e.win)throw new Error("Ack source does not match registered window");e.ack=!0}},Rn[H._]=function(n,r,t){if(!Sn(t.hash)){var e,o=An(t.hash);if(!o)throw new Error("No handler found for post message response for message: "+t.name+" from "+r+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!_(o.domain,r))throw new Error("Response origin "+r+" does not match domain "+(e=o.domain,Array.isArray(e)?"("+e.join(" | ")+")":i(e)?"RegExp("+e.toString():e.toString()));if(n!==o.win)throw new Error("Response source does not match registered window");Pn(t.hash),"error"===t.ack?o.promise.reject(t.error):"success"===t.ack&&o.promise.resolve({source:n,origin:r,data:t.data})}},Rn);function In(n,r){var t=r.on,e=r.send,i=$("receivedMessages");if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!n.source)return}catch(n){return}var u=n.source,f=n.origin,c=function(n,r,t,e){var i,o=e.on,u=e.send;try{i=jn(r,t,n,{on:o,send:u})}catch(n){return}if(i&&"object"==typeof i&&null!==i&&(i=i.__post_robot_10_0_4__)&&"object"==typeof i&&null!==i&&i.type&&"string"==typeof i.type&&Tn[i.type])return i}(n.data,u,f,{on:t,send:e});c&&(cn(u),i.has(c.id)||(i.set(c.id,!0),g(u)&&!c.fireAndForget||(0===c.origin.indexOf(o.h)&&(f=c.origin),Tn[c.type](u,f,c,{on:t,send:e}))))}function Cn(n,r,t){if(!n)throw new Error("Expected name");if("function"==typeof r&&(t=r,r={}),!t)throw new Error("Expected handler");(r=r||{}).name=n,r.handler=t||r.handler;var e=r.window,i=r.domain,o=function n(r,t){var e=r.name,i=r.win,o=r.domain,u=tn("requestListeners");if(!e||"string"!=typeof e)throw new Error("Name required to add request listener");if(Array.isArray(i)){for(var f=[],c=0,a=i;c<a.length;c++)f.push(n({name:e,domain:o,win:a[c]},t));return{cancel:function(){for(var n=0;n<f.length;n++)f[n].cancel()}}}if(Array.isArray(o)){for(var s=[],d=0,w=o;d<w.length;d++)s.push(n({name:e,win:i,domain:w[d]},t));return{cancel:function(){for(var n=0;n<s.length;n++)s[n].cancel()}}}var h=kn({name:e,win:i,domain:o});if(i&&i!==Z||(i=rn()),o=o||Z,h)throw i&&o?new Error("Request listener already exists for "+e+" on domain "+o.toString()+" for "+(i===rn()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+e+" for "+(i===rn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+e+" on domain "+o.toString()):new Error("Request listener already exists for "+e);var v,l,m=u.getOrSet(i,function(){return{}}),y=U(m,e,function(){return{}}),p=o.toString();return B(o)?(v=U(y,Wn,function(){return[]})).push(l={regex:o,listener:t}):y[p]=t,{cancel:function(){delete y[p],l&&(v.splice(v.indexOf(l,1)),v.length||delete y[Wn]),Object.keys(y).length||delete m[e],i&&!Object.keys(m).length&&u.del(i)}}}({name:n,win:e,domain:i},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:i||Z,name:n});return{cancel:function(){o.cancel()}}}function Ln(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,i=new S;return r.errorHandler=function(n){e.cancel(),i.reject(n)},e=Cn(n,r,function(n){if(e.cancel(),i.resolve(n),t)return t(n)}),i.cancel=e.cancel,i}function Dn(n,r,t,e){var i=(e=e||{}).domain||Z,o=e.timeout||K,u=e.timeout||F,f=e.fireAndForget||!1;return S.try(function(){if(!r)throw new Error("Expected name");if(i&&"string"!=typeof i&&!Array.isArray(i)&&!B(i))throw new TypeError("Expected domain to be a string, array, or regex");if(g(n))throw new Error("Target window is closed");var e=tn("requestPromises").getOrSet(n,function(){return[]}),c=S.try(function(){return function(n,r){var t=b(r);if(t)return t===n;if(r===n)return!1;if(function(n){if(n){try{if(n.top)return n.top}catch(n){}if(a(n)===n)return n;try{if(m(window,n)&&window.top)return window.top}catch(n){}try{if(m(n,window)&&window.top)return window.top}catch(n){}for(var r=0,t=function n(r){for(var t=[],e=0,i=y(r);e<i.length;e++){var o=i[e];t.push(o);for(var u=0,f=n(o);u<f.length;u++)t.push(f[u])}return t}(n);r<t.length;r++){var e=t[r];try{if(e.top)return e.top}catch(n){}if(a(e)===e)return e}}}(r)===r)return!1;for(var e=0,i=y(n);e<i.length;e++)if(i[e]===r)return!0;return!1}(window,n)?function(n,r,t){void 0===r&&(r=5e3),void 0===t&&(t="Window");var e=on(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}(n,u):B(i)?un(n,{send:Dn}):void 0}).then(function(u){var a=(void 0===u?{}:u).domain;if(B(i)){if(!_(i,a))throw new Error("Remote window domain "+a+" does not match regex: "+i.source);i=a}var s=r===Y.j&&t&&"string"==typeof t.name?t.name+"()":r,d=!1,w=new S;w.finally(function(){d=!0,e.splice(e.indexOf(c,1))}).catch(z);var v=r+"_"+q();if(Nn(n,i,{type:H.g,hash:v,name:r,data:t,fireAndForget:f},{on:Cn,send:Dn}),f)return w.resolve();w.catch(function(){!function(n){$("erroredResponseListeners").set(n,!0)}(v),Pn(v)});var l={name:r,win:n,domain:i,promise:w};!function(n,r){$("responseListeners").set(n,r)}(v,l);var m=function(n){return tn("knownWindows").get(n,!1)}(n)?G:J,y=o,p=m,E=y,b=100;return setTimeout(function t(){if(!d){if(g(n))return w.reject(l.ack?new Error("Window closed for "+r+" before response"):new Error("Window closed for "+r+" before ack"));if(p=Math.max(p-b,0),-1!==E&&(E=Math.max(E-b,0)),l.ack){if(-1===E)return;b=Math.min(E,2e3)}else{if(0===p)return w.reject(new Error("No ack for postMessage "+s+" in "+h()+" in "+m+"ms"));if(0===E)return w.reject(new Error("No response for postMessage "+s+" in "+h()+" in "+y+"ms"))}setTimeout(t,b)}},b),w});return e.push(c),c})}function qn(n,r,t){return On(n,r,t,{on:Cn,send:Dn})}function zn(n,r,t){return jn(n,r,t,{on:Cn,send:Dn})}function Bn(n){return gn.toProxyWindow(n,{send:Dn})}function Un(){var n,r,t,e;X().initialized||(X().initialized=!0,function(n){var r=n.on,t=n.send;$().getOrSet("postMessageListeners",function(){return(n=window).addEventListener("message",e=function(n){!function(n,r){var t=r.on,e=r.send,i=n.source||n.sourceElement,u=n.origin||n.originalEvent&&n.originalEvent.origin,f=n.data;if("null"===u&&(u=o.h+"//"),i){if(!u)throw new Error("Post message did not have origin domain");In({source:i,origin:u,data:f},{on:t,send:e})}}(n,{on:r,send:t})}),{cancel:function(){n.removeEventListener("message",e)}};var n,e})}({on:Cn,send:Dn}),function(n){var r=n.on,t=n.send;$("builtinListeners").getOrSet("helloListener",function(){var n=r(Y.M,{domain:Z},function(n){var r=n.source,t=n.origin;return on(r).resolve({win:r,domain:t}),{instanceID:en()}}),e=b();return e&&un(e,{send:t}).catch(z),n})}({on:Cn,send:Dn}),r=(n={on:Cn,send:Dn}).on,t=n.send,(e=X()).receiveMessage=e.receiveMessage||function(n){return In(n,{on:r,send:t})})}function Fn(n){for(var r=0,t=tn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(z)}t.d(r,"bridge",function(){}),t.d(r,"Promise",function(){return S}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return gn}),t.d(r,"setup",function(){return Un}),t.d(r,"serializeMessage",function(){return qn}),t.d(r,"deserializeMessage",function(){return zn}),t.d(r,"toProxyWindow",function(){return Bn}),t.d(r,"on",function(){return Cn}),t.d(r,"once",function(){return Ln}),t.d(r,"send",function(){return Dn}),t.d(r,"markWindowKnown",function(){return cn}),t.d(r,"cleanUpWindow",function(){return Fn}),Un()}])}); | ||
//# sourceMappingURL=post-robot.min.js.map |
{ | ||
"name": "post-robot", | ||
"version": "10.0.3", | ||
"version": "10.0.4", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -140,6 +140,6 @@ /* @flow */ | ||
} else if (ackTimeout === 0) { | ||
return promise.reject(new Error(`No ack for postMessage ${ name } in ${ getDomain() } in ${ totalAckTimeout }ms`)); | ||
return promise.reject(new Error(`No ack for postMessage ${ logName } in ${ getDomain() } in ${ totalAckTimeout }ms`)); | ||
} else if (resTimeout === 0) { | ||
return promise.reject(new Error(`No response for postMessage ${ name } in ${ getDomain() } in ${ totalResTimeout }ms`)); | ||
return promise.reject(new Error(`No response for postMessage ${ logName } in ${ getDomain() } in ${ totalResTimeout }ms`)); | ||
} | ||
@@ -146,0 +146,0 @@ |
@@ -77,2 +77,8 @@ /* @flow */ | ||
}).then(() => { | ||
// $FlowFixMe | ||
if (err.stack) { | ||
// $FlowFixMe | ||
err.stack = `Remote call to ${ name }()\n\n${ err.stack }`; | ||
} | ||
throw err; | ||
@@ -79,0 +85,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1431721
8639