post-robot
Advanced tools
Comparing version 10.0.13 to 10.0.14
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.deleteResponseListener = deleteResponseListener; | ||
exports.cancelResponseListeners = cancelResponseListeners; | ||
exports.markResponseListenerErrored = markResponseListenerErrored; | ||
@@ -46,2 +47,16 @@ exports.isResponseListenerErrored = isResponseListenerErrored; | ||
function cancelResponseListeners() { | ||
const responseListeners = (0, _global.globalStore)('responseListeners'); | ||
for (const hash of responseListeners.keys()) { | ||
const listener = responseListeners.get(hash); | ||
if (listener) { | ||
listener.cancelled = true; | ||
} | ||
responseListeners.del(hash); | ||
} | ||
} | ||
function markResponseListenerErrored(hash) { | ||
@@ -48,0 +63,0 @@ const erroredResponseListeners = (0, _global.globalStore)('erroredResponseListeners'); |
@@ -114,2 +114,6 @@ "use strict"; | ||
if (responseListener.cancelled) { | ||
return promise.reject(new Error(`Response listener was cancelled for ${name}`)); | ||
} | ||
ackTimeout = Math.max(ackTimeout - _conf.RESPONSE_CYCLE_TIME, 0); | ||
@@ -116,0 +120,0 @@ |
@@ -70,4 +70,5 @@ "use strict"; | ||
function destroy() { | ||
(0, _drivers.cancelResponseListeners)(); | ||
(0, _drivers.stopListenForMessages)(); | ||
(0, _global.deleteGlobal)(); | ||
} |
@@ -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 H});var i={u:"mock:",h:"file:",v:"about:"},u="*",f={g:"iframe",_:"popup"},c="Call was rejected by callee.\r\n";function a(n){return void 0===n&&(n=window),n.location.protocol===i.v}function s(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function d(n){if(n&&!s(n))try{return n.opener}catch(n){}}function w(n){try{return!0}catch(n){}return!1}function h(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=s(n);return e&&w()?h(e):i.v+"//"}var o=r.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function v(n){var r=h(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(i.u)?n.mockDomain:r}function m(n){if(!function(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(a(n)&&w())return!0}catch(n){}try{if(h(n)===h(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(a(n)&&w())return!0;if(v(window)===v(n))return!0}catch(n){}return!1}function l(n,r){if(!n||!r)return!1;var t=s(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(s(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(s(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!==c}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===d(r)}function j(n){return d(n=n||window)||s(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=d(t),f=d(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("/"):v()}function A(n){try{if(n===window)return!0}catch(n){if(n&&n.message===c)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===c)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===c)return!0}return!1}function I(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 S,C=[],T=[],B=0;function D(){if(!B&&S){var n=S;S=null,n.resolve()}}function L(){B+=1}function F(){B-=1,D()}var q=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 F(),void this.reject(n)}F(),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(I(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(I(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===C.indexOf(n)){C.push(n),setTimeout(function(){throw n},1);for(var t=0;t<T.length;t++)T[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):I(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,F()}},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:I(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(!I(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 T.push(n),{cancel:function(){T.splice(T.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 F(),n.reject(r)}return F(),n.resolve(o)},n.delay=function(r){return new n(function(n){setTimeout(n,r)})},n.isPromise=function(r){return!!(r&&r instanceof n)||I(r)},n.flush=function(){return r=S=S||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,Z=Date.now()%1e9,H=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,Z+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+Z,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 K(){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(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 H,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var r=J.get(n);return r||(r=typeof n+":"+K(),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}function X(){}function Q(n,r){if(void 0===r&&(r=1),r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,e=n&&n.message;if(t&&e)return-1!==t.indexOf(e)?t:e+"\n"+t;if(t)return t;if(e)return e}return"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+Q(n,r+1)}}function V(n){return"string"==typeof n?n:n&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function $(n){return"[object RegExp]"==={}.toString.call(n)}function nn(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var rn={M:"postrobot_method",O:"postrobot_hello",W:"postrobot_open_tunnel"},tn="__postrobot_bridge__",en="*",on={j:"cross_domain_zalgo_promise",R:"cross_domain_function",N:"cross_domain_window"};function un(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_13__:n.__post_robot_10_0_13__=n.__post_robot_10_0_13__||{}}var fn=function(){return{}};function cn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=fn),nn(un(),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 nn(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var an=function(){};function sn(){var n=un();return n.k=n.k||new an,n.k}function dn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=fn),cn("windowStore").getOrSet(n,function(){var t=new H,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 nn(e(r),n,t)}}})}function wn(){return cn("instance").getOrSet("instanceID",K)}function hn(n){return dn("helloPromises").getOrSet(n,function(){return new q})}function vn(n,r){return(0,r.send)(n,rn.O,{instanceID:wn()},{domain:en,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return hn(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function mn(n,r){var t=r.send;return dn("windowInstanceIDPromises").getOrSet(n,function(){return vn(n,{send:t}).then(function(n){return n.instanceID})})}function ln(n,r,t){void 0===r&&(r=5e3),void 0===t&&(t="Window");var e=hn(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}function pn(n){dn("knownWindows").set(n,!0)}var yn,gn={P:"function",ERROR:"error",A:"promise",I:"regex",S:"date",C:"array",T:"object",B:"string",D:"number",L:"boolean",F:"null",q:"undefined"};function En(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function bn(n){return void 0===n?gn.q:null===n?gn.F:Array.isArray(n)?gn.C:"function"==typeof n?gn.P:"object"==typeof n?n instanceof Error?gn.ERROR:"function"==typeof n.then?gn.A:"[object RegExp]"==={}.toString.call(n)?gn.I:"[object Date]"==={}.toString.call(n)?gn.S:gn.T:"string"==typeof n?gn.B:"number"==typeof n?gn.D:"boolean"==typeof n?gn.L:void 0}function _n(n,r){return{__type__:n,__val__:r}}var xn,Mn=((yn={})[gn.P]=function(){},yn[gn.ERROR]=function(n){return _n(gn.ERROR,{message:n.message,stack:n.stack,code:n.code})},yn[gn.A]=function(){},yn[gn.I]=function(n){return _n(gn.I,n.source)},yn[gn.S]=function(n){return _n(gn.S,n.toJSON())},yn[gn.C]=function(n){return n},yn[gn.T]=function(n){return n},yn[gn.B]=function(n){return n},yn[gn.D]=function(n){return n},yn[gn.L]=function(n){return n},yn[gn.F]=function(n){return n},yn),On={},Wn=((xn={})[gn.P]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},xn[gn.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},xn[gn.A]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},xn[gn.I]=function(n){return new RegExp(n)},xn[gn.S]=function(n){return new Date(n)},xn[gn.C]=function(n){return n},xn[gn.T]=function(n){return n},xn[gn.B]=function(n){return n},xn[gn.D]=function(n){return n},xn[gn.L]=function(n){return n},xn[gn.F]=function(n){return n},xn),jn={};function Rn(){return!!M(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Nn(n){return!N(window,n)}function kn(n,r){if(n){if(v()!==P(n))return!0}else if(r&&!m(r))return!0;return!1}function Pn(n){var r=n.win,t=n.domain;return!(!Rn()||t&&!kn(t,r)||r&&!Nn(r))}function An(n){var r=(n=n||P(n)).replace(/[^a-zA-Z0-9]+/g,"_");return tn+"_"+r}function In(){return Boolean(window.name&&window.name===An(v()))}var Sn=new q(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 Cn(n){dn("remoteWindowPromises").getOrSet(n,function(){return new q})}function Tn(n){var r=dn("remoteWindowPromises").get(n);if(!r)throw new Error("Remote window promise not found");return r}function Bn(n,r,t){Tn(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 Dn(n,r){Tn(n).reject(r).catch(X)}function Ln(n){for(var r=n.win,t=n.name,e=n.domain,o=cn("popupWindowsByName"),i=dn("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,Cn(r)),i.set(r,a),a}function Fn(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?(Ln({win:u,name:t,domain:n?P(n):null}),u):u},function(n){var r=n.on,t=n.send,e=n.receiveMessage,o=cn("popupWindowsByName");r(rn.W,function(n){var i=n.source,u=n.origin,f=n.data,c=cn("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 Bn(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){q.reject(n)}}}}})})}({on:t,send:e,receiveMessage:o}),function(n){var r=n.send;un(window).openTunnelToParent=function(n){var t=n.name,e=n.source,o=n.canary,i=n.sendMessage,u=cn("tunnelWindows"),f=s(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=cn("tunnelWindows"),r=0,t=n.keys();r<t.length;r++){var e=t[r];x(n[e].source)&&n.del(e)}}();var i=K();return cn("tunnelWindows").set(i,{name:r,source:t,canary:e,sendMessage:o}),i}({name:t,source:e,canary:o,sendMessage:i});return r(f,rn.W,{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:en})}}({on:t,send:e}),function(n){var r=n.on,t=n.send,e=n.receiveMessage;q.try(function(){var n,o=d(window);if(o&&Pn({win:o}))return Cn(o),(n=o,dn("remoteBridgeAwaiters").getOrSet(n,function(){return q.try(function(){var r=O(n,An(v()));if(r)return m(r)&&m(r)&&un(r)?r:new q(function(n){var t,e;t=setInterval(function(){if(r&&m(r)&&un(r))return clearInterval(t),clearTimeout(e),n(r)},100),e=setTimeout(function(){return clearInterval(t),n()},2e3)})})})).then(function(n){return n?window.name?un(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){q.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");Bn(r,t,e.sendMessage)}).catch(function(n){throw Dn(o,n),n}):Dn(o,new Error("Can not register with opener: window does not have a name")):Dn(o,new Error("Can not register with opener: no bridge found in opener"))})})}({on:t,send:e,receiveMessage:o})}function qn(){for(var n=cn("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}function zn(n,r,t){var e,o=t.send;return{id:n,type:d(r)?f._:f.g,getInstanceID:Y(function(){return mn(r,{send:o})}),close:function(){return q.try(function(){r.close()})},getName:function(){return q.try(function(){if(!x(r))return e})},focus:function(){return q.try(function(){r.focus()})},isClosed:function(){return q.try(function(){return x(r)})},setLocation:function(n){return q.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 q.try(function(){Ln({win:r,name:n}),(r=function(n){if(!m(n))throw new Error("Expected window to be same domain");return n}(r)).name=n,r.frameElement&&r.frameElement.setAttribute("name",n),e=n})}}}var Un=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.name=void 0,this.serializedWindow=n,this.actualWindowPromise=new q,this.send=e,r&&this.setWindow(r)}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return this.getType()===f._},r.isIframe=function(){return this.getType()===f.g},r.setLocation=function(n){var r=this;return this.serializedWindow.setLocation(n).then(function(){return r})},r.setName=function(n){var r=this;return this.serializedWindow.setName(n).then(function(){return r})},r.close=function(){var n=this;return this.serializedWindow.close().then(function(){return n})},r.focus=function(){var n=this;return q.try(function(){return q.all([n.isPopup()&&n.serializedWindow.getName().then(function(n){n&&window.open("",n)}),n.serializedWindow.focus()])}).then(function(){return n})},r.isClosed=function(){return this.serializedWindow.isClosed()},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.serializedWindow=zn(this.serializedWindow.id,n,{send:this.send}),this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return q.try(function(){return r.actualWindow?n===r.actualWindow:q.all([r.getInstanceID(),mn(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.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 qn(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,o=t.send;return qn(),cn("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;if(qn(),n.isProxyWindow(r))return r;var o=r;return dn("winToProxyWindow").getOrSet(r,function(){var r=K(),t=new n(zn(r,o,{send:e}),o,{send:e});return cn("idToProxyWindow").set(r,t)})},n}();function Jn(n,r,t,e,o){var i=dn("methodStore"),u=cn("proxyWindowMethods");Un.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 Gn(n,r){var t=dn("methodStore"),e=cn("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function Zn(n,r,t,e,o){!function(n){var r=o.on;cn("builtinListeners").getOrSet("functionCalls",function(){return r(rn.M,{domain:en},function(n){var r=n.source,t=n.origin,e=n.data,o=e.id,i=e.name,u=Gn(r,o);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+v(window));var f=u.source,c=u.domain,a=u.val;return q.try(function(){if(!k(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify($(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+v(window));if(Un.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 "+v(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return q.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__||K();n=Un.unwrap(n);var u=t.__name__||t.name||e;return Un.isProxyWindow(n)?(Jn(i,t,u,n,r),n.awaitWindow().then(function(n){Jn(i,t,u,n,r)})):Jn(i,t,u,n,r),_n(on.R,{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=On);var t=JSON.stringify(n,function(n){var t=this[n];if(En(this))return t;var e=bn(t);if(!e)return t;var o=r[e]||Mn[e];return o?o(t,n):t});return void 0===t?gn.q:t}(t,((o={})[gn.A]=function(t,e){return function(n,r,t,e,o){return _n(on.j,{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[gn.P]=function(t,e){return Zn(n,r,t,e,{on:i,send:u})},o[gn.T]=function(n){return A(n)||Un.isProxyWindow(n)?_n(on.N,Un.serialize(n,{send:u})):n},o))}function Kn(n,r,t,e){var o,i=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=jn),n!==gn.q)return JSON.parse(n,function(n,t){if(En(this))return t;var e,o;if(En(t)?(e=t.__type__,o=t.__val__):(e=bn(t),o=t),!e)return o;var i=r[e]||Wn[e];return i?i(o,n):o})}(t,((o={})[on.j]=function(n){return new q(n.then)},o[on.R]=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 Un.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=Gn(n,i);if(c&&c.val!==e)return c.val.apply({source:window,origin:v()},o);var a={domain:r,fireAndForget:t.fireAndForget},s=[].slice.call(o);return f(n,rn.M,{id:i,name:u,args:s},a).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[on.N]=function(n){return Un.deserialize(n,{on:(r={on:i,send:u}).on,send:r.send});var r},o))}var Yn={};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=Hn(n,r,((o={}).__post_robot_10_0_13__=z({id:K(),origin:v(window)},t),o),{on:i,send:u}),c=Object.keys(Yn),a=[],s=0;s<c.length;s++){var d=c[s];try{Yn[d](n,f,r)}catch(n){a.push(n)}}if(a.length===c.length)throw new Error("All post-robot messaging strategies failed:\n\n"+a.map(Q).join("\n\n"))}Yn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[en]).map(function(n){return 0===n.indexOf(i.h)?en:n}).forEach(function(t){n.postMessage(r,t)})},Yn.postrobot_bridge=function(n,r,t){if(Rn()||In()){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");Tn(n).then(function(e){return e(n,r,t)})}(n,t,r)}},Yn.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=un(n);if(!t)throw new Error("Can not find postRobot global on foreign window");t.receiveMessage({source:window,origin:v(),data:r})}};var Qn,Vn="__domain_regex__";function $n(n){return cn("responseListeners").get(n)}function nr(n){cn("responseListeners").del(n)}function rr(n){return cn("erroredResponseListeners").has(n)}function tr(n){var r=n.name,t=n.win,e=n.domain,o=dn("requestListeners");if(t===en&&(t=null),e===en&&(e=null),!r)throw new Error("Name required to get request listener");for(var i=0,u=[t,sn()];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[Vn])for(var s=0,d=a[Vn];s<d.length;s++){var w=d[s],h=w.listener;if(k(w.regex,e))return h}}if(a[en])return a[en]}}}}}var er=((Qn={}).postrobot_message_request=function(n,r,t,e){var o=e.on,i=e.send,u=tr({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 q.all([f("postrobot_message_ack"),q.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("postrobot_message_response","success",{data:n})},function(n){return f("postrobot_message_response","error",{error:n})})]).then(X).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Qn.postrobot_message_ack=function(n,r,t){if(!rr(t.hash)){var e=$n(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}},Qn.postrobot_message_response=function(n,r,t){if(!rr(t.hash)){var e,i=$n(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");nr(t.hash),"error"===t.ack?i.promise.reject(t.error):"success"===t.ack&&i.promise.resolve({source:n,origin:r,data:t.data})}},Qn);function or(n,r){var t=r.on,e=r.send,o=cn("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=Kn(r,t,n,{on:i,send:u})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_13__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&er[o.type])return o}(n.data,u,f,{on:t,send:e});c&&(pn(u),o.has(c.id)||(o.set(c.id,!0),x(u)&&!c.fireAndForget||(0===c.origin.indexOf(i.h)&&(f=i.h+"//"),er[c.type](u,f,c,{on:t,send:e}))))}function ir(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=dn("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=tr({name:e,win:o,domain:i});if(o&&o!==en||(o=sn()),i=i||en,h)throw o&&i?new Error("Request listener already exists for "+e+" on domain "+i.toString()+" for "+(o===sn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+e+" for "+(o===sn()?"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=nn(l,e,function(){return{}}),y=i.toString();return $(i)?(v=nn(p,Vn,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[Vn]),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||en,name:n});return{cancel:function(){i.cancel()}}}function ur(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,o=new q;return r.errorHandler=function(n){e.cancel(),o.reject(n)},e=ir(n,r,function(n){if(e.cancel(),o.resolve(n),t)return t(n)}),o.cancel=e.cancel,o}var fr,cr=function n(r,t,e,o){var i=(o=o||{}).domain||en,u=o.timeout||-1,f=o.timeout||5e3,c=o.fireAndForget||!1;return q.try(function(){return function(n,r,t){if(!n)throw new Error("Expected name");if(t&&"string"!=typeof t&&!Array.isArray(t)&&!$(t))throw new TypeError("Expected domain to be a string, array, or regex");if(x(r))throw new Error("Target window is closed")}(t,r,i),function(n,r,t,e){var o=e.send;return q.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)?ln(n,t):$(r)?vn(n,{send:o}):{domain:r}}).then(function(n){return n.domain})}(r,i,f,{send:n})}).then(function(o){if(!k(i,o))throw new Error("Domain "+V(i)+" does not match "+V(o));i=o;var f,a,s=t===rn.M&&e&&"string"==typeof e.name?e.name+"()":t,d=new q,w=t+"_"+K();if(!c){var h={name:t,win:r,domain:i,promise:d};!function(n,r){cn("responseListeners").set(n,r)}(w,h);var m=dn("requestPromises").getOrSet(r,function(){return[]});m.push(d),d.catch(function(){!function(n){cn("erroredResponseListeners").set(n,!0)}(w),nr(w)});var l=function(n){return dn("knownWindows").get(n,!1)}(r)?1e4:2e3,p=u,y=l,g=p,E=(f=function(){return x(r)?d.reject(new Error("Window closed for "+t+" before "+(h.ack?"response":"ack"))):(y=Math.max(y-500,0),-1!==g&&(g=Math.max(g-500,0)),h.ack||0!==y?0===g?d.reject(new Error("No response for postMessage "+s+" in "+v()+" in "+p+"ms")):void 0:d.reject(new Error("No ack for postMessage "+s+" in "+v()+" in "+l+"ms")))},500,function n(){a=setTimeout(function(){f(),n()},500)}(),{cancel:function(){clearTimeout(a)}});d.finally(function(){E.cancel(),m.splice(m.indexOf(d,1))}).catch(X)}return Xn(r,i,{type:"postrobot_message_request",hash:w,name:t,data:e,fireAndForget:c},{on:ir,send:n}),c?d.resolve():d})};function ar(n,r,t){return Hn(n,r,t,{on:ir,send:cr})}function sr(n,r,t){return Kn(n,r,t,{on:ir,send:cr})}function dr(n){return Un.toProxyWindow(n,{send:cr})}function wr(){var n,r,t,e;un().initialized||(un().initialized=!0,r=(n={on:ir,send:cr}).on,t=n.send,(e=un()).receiveMessage=e.receiveMessage||function(n){return or(n,{on:r,send:t})},function(n){var r=n.on,t=n.send;cn().getOrSet("postMessageListener",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");or({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:ir,send:cr}),Fn({on:ir,send:cr,receiveMessage:or}),function(n){var r=n.on,t=n.send;cn("builtinListeners").getOrSet("helloListener",function(){var n=r(rn.O,{domain:en},function(n){var r=n.source,t=n.origin;return hn(r).resolve({win:r,domain:t}),{instanceID:wn()}}),e=j();return e&&vn(e,{send:t}).catch(X),n})}({on:ir,send:cr}))}function hr(){var n;(n=cn().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_13__}function vr(n){for(var r=0,t=dn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(X)}t.d(r,"bridge",function(){return fr}),t.d(r,"Promise",function(){return q}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return Un}),t.d(r,"setup",function(){return wr}),t.d(r,"destroy",function(){return hr}),t.d(r,"serializeMessage",function(){return ar}),t.d(r,"deserializeMessage",function(){return sr}),t.d(r,"toProxyWindow",function(){return dr}),t.d(r,"on",function(){return ir}),t.d(r,"once",function(){return ur}),t.d(r,"send",function(){return cr}),t.d(r,"markWindowKnown",function(){return pn}),t.d(r,"cleanUpWindow",function(){return vr}),fr={setupBridge:Fn,openBridge:function(n,r){var t=cn("bridges"),e=cn("bridgeFrames");return r=r||P(n),t.getOrSet(r,function(){return q.try(function(){if(v()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var t=An(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),Sn.then(function(r){r.appendChild(o);var t=o.contentWindow;return new q(function(n,r){o.addEventListener("load",n),o.addEventListener("error",r)}).then(function(){return ln(t,5e3,"Bridge "+n)}).then(function(){return t})})})})},linkWindow:Ln,linkUrl:function(n,r){Ln({win:n,domain:P(r)})},isBridge:In,needsBridge:Pn,needsBridgeForBrowser:Rn,hasBridge:function(n,r){return cn("bridges").has(r||P(n))},needsBridgeForWin:Nn,needsBridgeForDomain:kn,destroyBridges:function(){for(var n=cn("bridges"),r=cn("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()}},wr()}])}); | ||
!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 H});var i={u:"mock:",h:"file:",v:"about:"},u="*",f={g:"iframe",_:"popup"},c="Call was rejected by callee.\r\n";function a(n){return void 0===n&&(n=window),n.location.protocol===i.v}function s(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function d(n){if(n&&!s(n))try{return n.opener}catch(n){}}function w(n){try{return!0}catch(n){}return!1}function h(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=s(n);return e&&w()?h(e):i.v+"//"}var o=r.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function v(n){var r=h(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(i.u)?n.mockDomain:r}function l(n){if(!function(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(a(n)&&w())return!0}catch(n){}try{if(h(n)===h(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(a(n)&&w())return!0;if(v(window)===v(n))return!0}catch(n){}return!1}function m(n,r){if(!n||!r)return!1;var t=s(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(s(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=y(n);r<t.length;r++){var e=t[r];try{if(e.top)return e.top}catch(n){}if(s(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!==c}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}(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(l(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===d(r)}function j(n){return d(n=n||window)||s(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=d(t),f=d(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("/"):v()}function A(n){try{if(n===window)return!0}catch(n){if(n&&n.message===c)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===c)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===c)return!0}return!1}function I(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 S,C=[],T=[],B=0;function D(){if(!B&&S){var n=S;S=null,n.resolve()}}function L(){B+=1}function F(){B-=1,D()}var q=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 F(),void this.reject(n)}F(),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(I(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(I(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===C.indexOf(n)){C.push(n),setTimeout(function(){throw n},1);for(var t=0;t<T.length;t++)T[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):I(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,F()}},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:I(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(!I(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 T.push(n),{cancel:function(){T.splice(T.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 F(),n.reject(r)}return F(),n.resolve(o)},n.delay=function(r){return new n(function(n){setTimeout(n,r)})},n.isPromise=function(r){return!!(r&&r instanceof n)||I(r)},n.flush=function(){return r=S=S||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,Z=Date.now()%1e9,H=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,Z+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+Z,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 K(){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(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 H,null==n||"object"!=typeof n&&"function"!=typeof n)throw new Error("Invalid object");var r=J.get(n);return r||(r=typeof n+":"+K(),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}function X(){}function Q(n,r){if(void 0===r&&(r=1),r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,e=n&&n.message;if(t&&e)return-1!==t.indexOf(e)?t:e+"\n"+t;if(t)return t;if(e)return e}return"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+Q(n,r+1)}}function V(n){return"string"==typeof n?n:n&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function $(n){return"[object RegExp]"==={}.toString.call(n)}function nn(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var rn={M:"postrobot_method",O:"postrobot_hello",W:"postrobot_open_tunnel"},tn="__postrobot_bridge__",en="*",on={j:"cross_domain_zalgo_promise",R:"cross_domain_function",N:"cross_domain_window"};function un(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_14__:n.__post_robot_10_0_14__=n.__post_robot_10_0_14__||{}}var fn=function(){return{}};function cn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=fn),nn(un(),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 nn(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var an=function(){};function sn(){var n=un();return n.k=n.k||new an,n.k}function dn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=fn),cn("windowStore").getOrSet(n,function(){var t=new H,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 nn(e(r),n,t)}}})}function wn(){return cn("instance").getOrSet("instanceID",K)}function hn(n){return dn("helloPromises").getOrSet(n,function(){return new q})}function vn(n,r){return(0,r.send)(n,rn.O,{instanceID:wn()},{domain:en,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return hn(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function ln(n,r){var t=r.send;return dn("windowInstanceIDPromises").getOrSet(n,function(){return vn(n,{send:t}).then(function(n){return n.instanceID})})}function mn(n,r,t){void 0===r&&(r=5e3),void 0===t&&(t="Window");var e=hn(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}function pn(n){dn("knownWindows").set(n,!0)}var yn,gn={P:"function",ERROR:"error",A:"promise",I:"regex",S:"date",C:"array",T:"object",B:"string",D:"number",L:"boolean",F:"null",q:"undefined"};function En(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function bn(n){return void 0===n?gn.q:null===n?gn.F:Array.isArray(n)?gn.C:"function"==typeof n?gn.P:"object"==typeof n?n instanceof Error?gn.ERROR:"function"==typeof n.then?gn.A:"[object RegExp]"==={}.toString.call(n)?gn.I:"[object Date]"==={}.toString.call(n)?gn.S:gn.T:"string"==typeof n?gn.B:"number"==typeof n?gn.D:"boolean"==typeof n?gn.L:void 0}function _n(n,r){return{__type__:n,__val__:r}}var xn,Mn=((yn={})[gn.P]=function(){},yn[gn.ERROR]=function(n){return _n(gn.ERROR,{message:n.message,stack:n.stack,code:n.code})},yn[gn.A]=function(){},yn[gn.I]=function(n){return _n(gn.I,n.source)},yn[gn.S]=function(n){return _n(gn.S,n.toJSON())},yn[gn.C]=function(n){return n},yn[gn.T]=function(n){return n},yn[gn.B]=function(n){return n},yn[gn.D]=function(n){return n},yn[gn.L]=function(n){return n},yn[gn.F]=function(n){return n},yn),On={},Wn=((xn={})[gn.P]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},xn[gn.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},xn[gn.A]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},xn[gn.I]=function(n){return new RegExp(n)},xn[gn.S]=function(n){return new Date(n)},xn[gn.C]=function(n){return n},xn[gn.T]=function(n){return n},xn[gn.B]=function(n){return n},xn[gn.D]=function(n){return n},xn[gn.L]=function(n){return n},xn[gn.F]=function(n){return n},xn),jn={};function Rn(){return!!M(window).match(/MSIE|trident|edge\/12|edge\/13/i)}function Nn(n){return!N(window,n)}function kn(n,r){if(n){if(v()!==P(n))return!0}else if(r&&!l(r))return!0;return!1}function Pn(n){var r=n.win,t=n.domain;return!(!Rn()||t&&!kn(t,r)||r&&!Nn(r))}function An(n){var r=(n=n||P(n)).replace(/[^a-zA-Z0-9]+/g,"_");return tn+"_"+r}function In(){return Boolean(window.name&&window.name===An(v()))}var Sn=new q(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 Cn(n){dn("remoteWindowPromises").getOrSet(n,function(){return new q})}function Tn(n){var r=dn("remoteWindowPromises").get(n);if(!r)throw new Error("Remote window promise not found");return r}function Bn(n,r,t){Tn(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 Dn(n,r){Tn(n).reject(r).catch(X)}function Ln(n){for(var r=n.win,t=n.name,e=n.domain,o=cn("popupWindowsByName"),i=dn("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,Cn(r)),i.set(r,a),a}function Fn(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?(Ln({win:u,name:t,domain:n?P(n):null}),u):u},function(n){var r=n.on,t=n.send,e=n.receiveMessage,o=cn("popupWindowsByName");r(rn.W,function(n){var i=n.source,u=n.origin,f=n.data,c=cn("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 Bn(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){q.reject(n)}}}}})})}({on:t,send:e,receiveMessage:o}),function(n){var r=n.send;un(window).openTunnelToParent=function(n){var t=n.name,e=n.source,o=n.canary,i=n.sendMessage,u=cn("tunnelWindows"),f=s(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=cn("tunnelWindows"),r=0,t=n.keys();r<t.length;r++){var e=t[r];x(n[e].source)&&n.del(e)}}();var i=K();return cn("tunnelWindows").set(i,{name:r,source:t,canary:e,sendMessage:o}),i}({name:t,source:e,canary:o,sendMessage:i});return r(f,rn.W,{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:en})}}({on:t,send:e}),function(n){var r=n.on,t=n.send,e=n.receiveMessage;q.try(function(){var n,o=d(window);if(o&&Pn({win:o}))return Cn(o),(n=o,dn("remoteBridgeAwaiters").getOrSet(n,function(){return q.try(function(){var r=O(n,An(v()));if(r)return l(r)&&l(r)&&un(r)?r:new q(function(n){var t,e;t=setInterval(function(){if(r&&l(r)&&un(r))return clearInterval(t),clearTimeout(e),n(r)},100),e=setTimeout(function(){return clearInterval(t),n()},2e3)})})})).then(function(n){return n?window.name?un(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){q.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");Bn(r,t,e.sendMessage)}).catch(function(n){throw Dn(o,n),n}):Dn(o,new Error("Can not register with opener: window does not have a name")):Dn(o,new Error("Can not register with opener: no bridge found in opener"))})})}({on:t,send:e,receiveMessage:o})}function qn(){for(var n=cn("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}function zn(n,r,t){var e,o=t.send;return{id:n,type:d(r)?f._:f.g,getInstanceID:Y(function(){return ln(r,{send:o})}),close:function(){return q.try(function(){r.close()})},getName:function(){return q.try(function(){if(!x(r))return e})},focus:function(){return q.try(function(){r.focus()})},isClosed:function(){return q.try(function(){return x(r)})},setLocation:function(n){return q.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 q.try(function(){Ln({win:r,name:n}),(r=function(n){if(!l(n))throw new Error("Expected window to be same domain");return n}(r)).name=n,r.frameElement&&r.frameElement.setAttribute("name",n),e=n})}}}var Un=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.name=void 0,this.serializedWindow=n,this.actualWindowPromise=new q,this.send=e,r&&this.setWindow(r)}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return this.getType()===f._},r.isIframe=function(){return this.getType()===f.g},r.setLocation=function(n){var r=this;return this.serializedWindow.setLocation(n).then(function(){return r})},r.setName=function(n){var r=this;return this.serializedWindow.setName(n).then(function(){return r})},r.close=function(){var n=this;return this.serializedWindow.close().then(function(){return n})},r.focus=function(){var n=this;return q.try(function(){return q.all([n.isPopup()&&n.serializedWindow.getName().then(function(n){n&&window.open("",n)}),n.serializedWindow.focus()])}).then(function(){return n})},r.isClosed=function(){return this.serializedWindow.isClosed()},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.serializedWindow=zn(this.serializedWindow.id,n,{send:this.send}),this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return q.try(function(){return r.actualWindow?n===r.actualWindow:q.all([r.getInstanceID(),ln(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.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 qn(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,o=t.send;return qn(),cn("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;if(qn(),n.isProxyWindow(r))return r;var o=r;return dn("winToProxyWindow").getOrSet(r,function(){var r=K(),t=new n(zn(r,o,{send:e}),o,{send:e});return cn("idToProxyWindow").set(r,t)})},n}();function Jn(n,r,t,e,o){var i=dn("methodStore"),u=cn("proxyWindowMethods");Un.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 Gn(n,r){var t=dn("methodStore"),e=cn("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function Zn(n,r,t,e,o){!function(n){var r=o.on;cn("builtinListeners").getOrSet("functionCalls",function(){return r(rn.M,{domain:en},function(n){var r=n.source,t=n.origin,e=n.data,o=e.id,i=e.name,u=Gn(r,o);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+v(window));var f=u.source,c=u.domain,a=u.val;return q.try(function(){if(!k(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify($(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+v(window));if(Un.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 "+v(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return q.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__||K();n=Un.unwrap(n);var u=t.__name__||t.name||e;return Un.isProxyWindow(n)?(Jn(i,t,u,n,r),n.awaitWindow().then(function(n){Jn(i,t,u,n,r)})):Jn(i,t,u,n,r),_n(on.R,{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=On);var t=JSON.stringify(n,function(n){var t=this[n];if(En(this))return t;var e=bn(t);if(!e)return t;var o=r[e]||Mn[e];return o?o(t,n):t});return void 0===t?gn.q:t}(t,((o={})[gn.A]=function(t,e){return function(n,r,t,e,o){return _n(on.j,{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[gn.P]=function(t,e){return Zn(n,r,t,e,{on:i,send:u})},o[gn.T]=function(n){return A(n)||Un.isProxyWindow(n)?_n(on.N,Un.serialize(n,{send:u})):n},o))}function Kn(n,r,t,e){var o,i=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=jn),n!==gn.q)return JSON.parse(n,function(n,t){if(En(this))return t;var e,o;if(En(t)?(e=t.__type__,o=t.__val__):(e=bn(t),o=t),!e)return o;var i=r[e]||Wn[e];return i?i(o,n):o})}(t,((o={})[on.j]=function(n){return new q(n.then)},o[on.R]=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 Un.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=Gn(n,i);if(c&&c.val!==e)return c.val.apply({source:window,origin:v()},o);var a={domain:r,fireAndForget:t.fireAndForget},s=[].slice.call(o);return f(n,rn.M,{id:i,name:u,args:s},a).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[on.N]=function(n){return Un.deserialize(n,{on:(r={on:i,send:u}).on,send:r.send});var r},o))}var Yn={};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=Hn(n,r,((o={}).__post_robot_10_0_14__=z({id:K(),origin:v(window)},t),o),{on:i,send:u}),c=Object.keys(Yn),a=[],s=0;s<c.length;s++){var d=c[s];try{Yn[d](n,f,r)}catch(n){a.push(n)}}if(a.length===c.length)throw new Error("All post-robot messaging strategies failed:\n\n"+a.map(Q).join("\n\n"))}Yn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[en]).map(function(n){return 0===n.indexOf(i.h)?en:n}).forEach(function(t){n.postMessage(r,t)})},Yn.postrobot_bridge=function(n,r,t){if(Rn()||In()){if(l(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");Tn(n).then(function(e){return e(n,r,t)})}(n,t,r)}},Yn.postrobot_global=function(n,r){if(M(window).match(/MSIE|rv:11|trident|edge\/12|edge\/13/i)){if(!l(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=un(n);if(!t)throw new Error("Can not find postRobot global on foreign window");t.receiveMessage({source:window,origin:v(),data:r})}};var Qn,Vn="__domain_regex__";function $n(n){return cn("responseListeners").get(n)}function nr(n){cn("responseListeners").del(n)}function rr(n){return cn("erroredResponseListeners").has(n)}function tr(n){var r=n.name,t=n.win,e=n.domain,o=dn("requestListeners");if(t===en&&(t=null),e===en&&(e=null),!r)throw new Error("Name required to get request listener");for(var i=0,u=[t,sn()];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[Vn])for(var s=0,d=a[Vn];s<d.length;s++){var w=d[s],h=w.listener;if(k(w.regex,e))return h}}if(a[en])return a[en]}}}}}var er=((Qn={}).postrobot_message_request=function(n,r,t,e){var o=e.on,i=e.send,u=tr({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 q.all([f("postrobot_message_ack"),q.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("postrobot_message_response","success",{data:n})},function(n){return f("postrobot_message_response","error",{error:n})})]).then(X).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Qn.postrobot_message_ack=function(n,r,t){if(!rr(t.hash)){var e=$n(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}},Qn.postrobot_message_response=function(n,r,t){if(!rr(t.hash)){var e,i=$n(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");nr(t.hash),"error"===t.ack?i.promise.reject(t.error):"success"===t.ack&&i.promise.resolve({source:n,origin:r,data:t.data})}},Qn);function or(n,r){var t=r.on,e=r.send,o=cn("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=Kn(r,t,n,{on:i,send:u})}catch(n){return}if(o&&"object"==typeof o&&null!==o&&(o=o.__post_robot_10_0_14__)&&"object"==typeof o&&null!==o&&o.type&&"string"==typeof o.type&&er[o.type])return o}(n.data,u,f,{on:t,send:e});c&&(pn(u),o.has(c.id)||(o.set(c.id,!0),x(u)&&!c.fireAndForget||(0===c.origin.indexOf(i.h)&&(f=i.h+"//"),er[c.type](u,f,c,{on:t,send:e}))))}function ir(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=dn("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=tr({name:e,win:o,domain:i});if(o&&o!==en||(o=sn()),i=i||en,h)throw o&&i?new Error("Request listener already exists for "+e+" on domain "+i.toString()+" for "+(o===sn()?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+e+" for "+(o===sn()?"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,l,m=u.getOrSet(o,function(){return{}}),p=nn(m,e,function(){return{}}),y=i.toString();return $(i)?(v=nn(p,Vn,function(){return[]})).push(l={regex:i,listener:t}):p[y]=t,{cancel:function(){delete p[y],l&&(v.splice(v.indexOf(l,1)),v.length||delete p[Vn]),Object.keys(p).length||delete m[e],o&&!Object.keys(m).length&&u.del(o)}}}({name:n,win:e,domain:o},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:o||en,name:n});return{cancel:function(){i.cancel()}}}function ur(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,o=new q;return r.errorHandler=function(n){e.cancel(),o.reject(n)},e=ir(n,r,function(n){if(e.cancel(),o.resolve(n),t)return t(n)}),o.cancel=e.cancel,o}var fr,cr=function n(r,t,e,o){var i=(o=o||{}).domain||en,u=o.timeout||-1,f=o.timeout||5e3,c=o.fireAndForget||!1;return q.try(function(){return function(n,r,t){if(!n)throw new Error("Expected name");if(t&&"string"!=typeof t&&!Array.isArray(t)&&!$(t))throw new TypeError("Expected domain to be a string, array, or regex");if(x(r))throw new Error("Target window is closed")}(t,r,i),function(n,r,t,e){var o=e.send;return q.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)?mn(n,t):$(r)?vn(n,{send:o}):{domain:r}}).then(function(n){return n.domain})}(r,i,f,{send:n})}).then(function(o){if(!k(i,o))throw new Error("Domain "+V(i)+" does not match "+V(o));i=o;var f,a,s=t===rn.M&&e&&"string"==typeof e.name?e.name+"()":t,d=new q,w=t+"_"+K();if(!c){var h={name:t,win:r,domain:i,promise:d};!function(n,r){cn("responseListeners").set(n,r)}(w,h);var l=dn("requestPromises").getOrSet(r,function(){return[]});l.push(d),d.catch(function(){!function(n){cn("erroredResponseListeners").set(n,!0)}(w),nr(w)});var m=function(n){return dn("knownWindows").get(n,!1)}(r)?1e4:2e3,p=u,y=m,g=p,E=(f=function(){return x(r)?d.reject(new Error("Window closed for "+t+" before "+(h.ack?"response":"ack"))):h.cancelled?d.reject(new Error("Response listener was cancelled for "+t)):(y=Math.max(y-500,0),-1!==g&&(g=Math.max(g-500,0)),h.ack||0!==y?0===g?d.reject(new Error("No response for postMessage "+s+" in "+v()+" in "+p+"ms")):void 0:d.reject(new Error("No ack for postMessage "+s+" in "+v()+" in "+m+"ms")))},500,function n(){a=setTimeout(function(){f(),n()},500)}(),{cancel:function(){clearTimeout(a)}});d.finally(function(){E.cancel(),l.splice(l.indexOf(d,1))}).catch(X)}return Xn(r,i,{type:"postrobot_message_request",hash:w,name:t,data:e,fireAndForget:c},{on:ir,send:n}),c?d.resolve():d})};function ar(n,r,t){return Hn(n,r,t,{on:ir,send:cr})}function sr(n,r,t){return Kn(n,r,t,{on:ir,send:cr})}function dr(n){return Un.toProxyWindow(n,{send:cr})}function wr(){var n,r,t,e;un().initialized||(un().initialized=!0,r=(n={on:ir,send:cr}).on,t=n.send,(e=un()).receiveMessage=e.receiveMessage||function(n){return or(n,{on:r,send:t})},function(n){var r=n.on,t=n.send;cn().getOrSet("postMessageListener",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");or({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:ir,send:cr}),Fn({on:ir,send:cr,receiveMessage:or}),function(n){var r=n.on,t=n.send;cn("builtinListeners").getOrSet("helloListener",function(){var n=r(rn.O,{domain:en},function(n){var r=n.source,t=n.origin;return hn(r).resolve({win:r,domain:t}),{instanceID:wn()}}),e=j();return e&&vn(e,{send:t}).catch(X),n})}({on:ir,send:cr}))}function hr(){var n;!function(){for(var n=cn("responseListeners"),r=0,t=n.keys();r<t.length;r++){var e=t[r],o=n.get(e);o&&(o.cancelled=!0),n.del(e)}}(),(n=cn().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_14__}function vr(n){for(var r=0,t=dn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(X)}t.d(r,"bridge",function(){return fr}),t.d(r,"Promise",function(){return q}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return Un}),t.d(r,"setup",function(){return wr}),t.d(r,"destroy",function(){return hr}),t.d(r,"serializeMessage",function(){return ar}),t.d(r,"deserializeMessage",function(){return sr}),t.d(r,"toProxyWindow",function(){return dr}),t.d(r,"on",function(){return ir}),t.d(r,"once",function(){return ur}),t.d(r,"send",function(){return cr}),t.d(r,"markWindowKnown",function(){return pn}),t.d(r,"cleanUpWindow",function(){return vr}),fr={setupBridge:Fn,openBridge:function(n,r){var t=cn("bridges"),e=cn("bridgeFrames");return r=r||P(n),t.getOrSet(r,function(){return q.try(function(){if(v()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var t=An(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),Sn.then(function(r){r.appendChild(o);var t=o.contentWindow;return new q(function(n,r){o.addEventListener("load",n),o.addEventListener("error",r)}).then(function(){return mn(t,5e3,"Bridge "+n)}).then(function(){return t})})})})},linkWindow:Ln,linkUrl:function(n,r){Ln({win:n,domain:P(r)})},isBridge:In,needsBridge:Pn,needsBridgeForBrowser:Rn,hasBridge:function(n,r){return cn("bridges").has(r||P(n))},needsBridgeForWin:Nn,needsBridgeForDomain:kn,destroyBridges:function(){for(var n=cn("bridges"),r=cn("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()}},wr()}])}); | ||
//# 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 C});var o={u:"mock:",h:"file:",v:"about:"},u="*",f={g:"iframe",_:"popup"},c="Call was rejected by callee.\r\n";function a(n){return void 0===n&&(n=window),n.location.protocol===o.v}function s(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function d(n){if(n&&!s(n))try{return n.opener}catch(n){}}function w(n){try{return!0}catch(n){}return!1}function h(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=s(n);return e&&w()?h(e):o.v+"//"}var i=r.host;if(!i)throw new Error("Can not read window host");return t+"//"+i}function v(n){var r=h(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(o.u)?n.mockDomain:r}function l(n){if(!function(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(a(n)&&w())return!0}catch(n){}try{if(h(n)===h(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(a(n)&&w())return!0;if(v(window)===v(n))return!0}catch(n){}return!1}function y(n,r){if(!n||!r)return!1;var t=s(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 m(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!==c}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 d(n=n||window)||s(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===c)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===c)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===c)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=[],P=0;function R(){if(!P&&j){var n=j;j=null,n.resolve()}}function A(){P+=1}function W(){P-=1,R()}var k=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 W(),void this.reject(n)}W(),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,W()}},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 W(),n.reject(r)}return W(),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,R(),r;var r},n}();function S(){return(S=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,L=Object.defineProperty,D=Date.now()%1e9,C=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,D+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+D,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:L(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(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 C,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}function B(){}function F(n,r){if(void 0===r&&(r=1),r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,e=n&&n.message;if(t&&e)return-1!==t.indexOf(e)?t:e+"\n"+t;if(t)return t;if(e)return e}return"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+F(n,r+1)}}function U(n){return"string"==typeof n?n:n&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function J(n){return"[object RegExp]"==={}.toString.call(n)}function G(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var H={O:"postrobot_method",j:"postrobot_hello",M:"postrobot_open_tunnel"},K="*",Y={N:"cross_domain_zalgo_promise",P:"cross_domain_function",R:"cross_domain_window"};function Z(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_13__:n.__post_robot_10_0_13__=n.__post_robot_10_0_13__||{}}var X=function(){return{}};function Q(n,r){return void 0===n&&(n="store"),void 0===r&&(r=X),G(Z(),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 G(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var V=function(){};function $(){var n=Z();return n.A=n.A||new V,n.A}function nn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=X),Q("windowStore").getOrSet(n,function(){var t=new C,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 G(e(r),n,t)}}})}function rn(){return Q("instance").getOrSet("instanceID",q)}function tn(n){return nn("helloPromises").getOrSet(n,function(){return new k})}function en(n,r){return(0,r.send)(n,H.j,{instanceID:rn()},{domain:K,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return tn(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function on(n,r){var t=r.send;return nn("windowInstanceIDPromises").getOrSet(n,function(){return en(n,{send:t}).then(function(n){return n.instanceID})})}function un(n){nn("knownWindows").set(n,!0)}var fn,cn={W:"function",ERROR:"error",k:"promise",S:"regex",T:"date",I:"array",L:"object",D:"string",C:"number",q:"boolean",B:"null",F:"undefined"};function an(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function sn(n){return void 0===n?cn.F:null===n?cn.B:Array.isArray(n)?cn.I:"function"==typeof n?cn.W:"object"==typeof n?n instanceof Error?cn.ERROR:"function"==typeof n.then?cn.k:"[object RegExp]"==={}.toString.call(n)?cn.S:"[object Date]"==={}.toString.call(n)?cn.T:cn.L:"string"==typeof n?cn.D:"number"==typeof n?cn.C:"boolean"==typeof n?cn.q:void 0}function dn(n,r){return{__type__:n,__val__:r}}var wn,hn=((fn={})[cn.W]=function(){},fn[cn.ERROR]=function(n){return dn(cn.ERROR,{message:n.message,stack:n.stack,code:n.code})},fn[cn.k]=function(){},fn[cn.S]=function(n){return dn(cn.S,n.source)},fn[cn.T]=function(n){return dn(cn.T,n.toJSON())},fn[cn.I]=function(n){return n},fn[cn.L]=function(n){return n},fn[cn.D]=function(n){return n},fn[cn.C]=function(n){return n},fn[cn.q]=function(n){return n},fn[cn.B]=function(n){return n},fn),vn={},ln=((wn={})[cn.W]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},wn[cn.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},wn[cn.k]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},wn[cn.S]=function(n){return new RegExp(n)},wn[cn.T]=function(n){return new Date(n)},wn[cn.I]=function(n){return n},wn[cn.L]=function(n){return n},wn[cn.D]=function(n){return n},wn[cn.C]=function(n){return n},wn[cn.q]=function(n){return n},wn[cn.B]=function(n){return n},wn),yn={};function mn(){for(var n=Q("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}function pn(n,r,t){var e,i=t.send;return{id:n,type:d(r)?f._:f.g,getInstanceID:z(function(){return on(r,{send:i})}),close:function(){return k.try(function(){r.close()})},getName:function(){return k.try(function(){if(!g(r))return e})},focus:function(){return k.try(function(){r.focus()})},isClosed:function(){return k.try(function(){return g(r)})},setLocation:function(n){return k.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 k.try(function(){(r=function(n){if(!l(n))throw new Error("Expected window to be same domain");return n}(r)).name=n,r.frameElement&&r.frameElement.setAttribute("name",n),e=n})}}}new k(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 En=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.name=void 0,this.serializedWindow=n,this.actualWindowPromise=new k,this.send=e,r&&this.setWindow(r)}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return this.getType()===f._},r.isIframe=function(){return this.getType()===f.g},r.setLocation=function(n){var r=this;return this.serializedWindow.setLocation(n).then(function(){return r})},r.setName=function(n){var r=this;return this.serializedWindow.setName(n).then(function(){return r})},r.close=function(){var n=this;return this.serializedWindow.close().then(function(){return n})},r.focus=function(){var n=this;return k.try(function(){return k.all([n.isPopup()&&n.serializedWindow.getName().then(function(n){n&&window.open("",n)}),n.serializedWindow.focus()])}).then(function(){return n})},r.isClosed=function(){return this.serializedWindow.isClosed()},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.serializedWindow=pn(this.serializedWindow.id,n,{send:this.send}),this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return k.try(function(){return r.actualWindow?n===r.actualWindow:k.all([r.getInstanceID(),on(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.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 mn(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,i=t.send;return mn(),Q("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;if(mn(),n.isProxyWindow(r))return r;var i=r;return nn("winToProxyWindow").getOrSet(r,function(){var r=q(),t=new n(pn(r,i,{send:e}),i,{send:e});return Q("idToProxyWindow").set(r,t)})},n}();function gn(n,r,t,e,i){var o=nn("methodStore"),u=Q("proxyWindowMethods");En.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 bn(n,r){var t=nn("methodStore"),e=Q("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function _n(n,r,t,e,i){!function(n){var r=i.on;Q("builtinListeners").getOrSet("functionCalls",function(){return r(H.O,{domain:K},function(n){var r=n.source,t=n.origin,e=n.data,i=e.id,o=e.name,u=bn(r,i);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+v(window));var f=u.source,c=u.domain,a=u.val;return k.try(function(){if(!_(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify(J(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+v(window));if(En.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 "+v(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return k.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=En.unwrap(n);var u=t.__name__||t.name||e;return En.isProxyWindow(n)?(gn(o,t,u,n,r),n.awaitWindow().then(function(n){gn(o,t,u,n,r)})):gn(o,t,u,n,r),dn(Y.P,{id:o,name:u})}function xn(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){void 0===r&&(r=vn);var t=JSON.stringify(n,function(n){var t=this[n];if(an(this))return t;var e=sn(t);if(!e)return t;var i=r[e]||hn[e];return i?i(t,n):t});return void 0===t?cn.F:t}(t,((i={})[cn.k]=function(t,e){return function(n,r,t,e,i){return dn(Y.N,{then:_n(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[cn.W]=function(t,e){return _n(n,r,t,e,{on:o,send:u})},i[cn.L]=function(n){return x(n)||En.isProxyWindow(n)?dn(Y.R,En.serialize(n,{send:u})):n},i))}function On(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=yn),n!==cn.F)return JSON.parse(n,function(n,t){if(an(this))return t;var e,i;if(an(t)?(e=t.__type__,i=t.__val__):(e=sn(t),i=t),!e)return i;var o=r[e]||ln[e];return o?o(i,n):i})}(t,((i={})[Y.N]=function(n){return new k(n.then)},i[Y.P]=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 En.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=bn(n,o);if(c&&c.val!==e)return c.val.apply({source:window,origin:v()},i);var a={domain:r,fireAndForget:t.fireAndForget},s=[].slice.call(i);return f(n,H.O,{id:o,name:u,args:s},a).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[Y.R]=function(n){return En.deserialize(n,{on:(r={on:o,send:u}).on,send:r.send});var r},i))}var jn={};function Mn(n,r,t,e){var i,o=e.on,u=e.send;if(g(n))throw new Error("Window is closed");for(var f=xn(n,r,((i={}).__post_robot_10_0_13__=S({id:q(),origin:v(window)},t),i),{on:o,send:u}),c=Object.keys(jn),a=[],s=0;s<c.length;s++){var d=c[s];try{jn[d](n,f,r)}catch(n){a.push(n)}}if(a.length===c.length)throw new Error("All post-robot messaging strategies failed:\n\n"+a.map(F).join("\n\n"))}jn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[K]).map(function(n){return 0===n.indexOf(o.h)?K:n}).forEach(function(t){n.postMessage(r,t)})};var Nn,Pn="__domain_regex__";function Rn(n){return Q("responseListeners").get(n)}function An(n){Q("responseListeners").del(n)}function Wn(n){return Q("erroredResponseListeners").has(n)}function kn(n){var r=n.name,t=n.win,e=n.domain,i=nn("requestListeners");if(t===K&&(t=null),e===K&&(e=null),!r)throw new Error("Name required to get request listener");for(var o=0,u=[t,$()];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[Pn])for(var s=0,d=a[Pn];s<d.length;s++){var w=d[s],h=w.listener;if(_(w.regex,e))return h}}if(a[K])return a[K]}}}}}var Sn=((Nn={}).postrobot_message_request=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)||Mn(n,r,S({type:e,ack:u,hash:t.hash,name:t.name},f),{on:i,send:o})}return k.all([f("postrobot_message_ack"),k.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("postrobot_message_response","success",{data:n})},function(n){return f("postrobot_message_response","error",{error:n})})]).then(B).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Nn.postrobot_message_ack=function(n,r,t){if(!Wn(t.hash)){var e=Rn(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}},Nn.postrobot_message_response=function(n,r,t){if(!Wn(t.hash)){var e,o=Rn(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");An(t.hash),"error"===t.ack?o.promise.reject(t.error):"success"===t.ack&&o.promise.resolve({source:n,origin:r,data:t.data})}},Nn);function Tn(n,r){var t=r.on,e=r.send,i=Q("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=On(r,t,n,{on:o,send:u})}catch(n){return}if(i&&"object"==typeof i&&null!==i&&(i=i.__post_robot_10_0_13__)&&"object"==typeof i&&null!==i&&i.type&&"string"==typeof i.type&&Sn[i.type])return i}(n.data,u,f,{on:t,send:e});c&&(un(u),i.has(c.id)||(i.set(c.id,!0),g(u)&&!c.fireAndForget||(0===c.origin.indexOf(o.h)&&(f=o.h+"//"),Sn[c.type](u,f,c,{on:t,send:e}))))}function In(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=nn("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!==K||(i=$()),o=o||K,h)throw i&&o?new Error("Request listener already exists for "+e+" on domain "+o.toString()+" for "+(i===$()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+e+" for "+(i===$()?"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,y=u.getOrSet(i,function(){return{}}),m=G(y,e,function(){return{}}),p=o.toString();return J(o)?(v=G(m,Pn,function(){return[]})).push(l={regex:o,listener:t}):m[p]=t,{cancel:function(){delete m[p],l&&(v.splice(v.indexOf(l,1)),v.length||delete m[Pn]),Object.keys(m).length||delete y[e],i&&!Object.keys(y).length&&u.del(i)}}}({name:n,win:e,domain:i},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:i||K,name:n});return{cancel:function(){o.cancel()}}}function Ln(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,i=new k;return r.errorHandler=function(n){e.cancel(),i.reject(n)},e=In(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.send;return k.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(s(n)===n)return n;try{if(y(window,n)&&window.top)return window.top}catch(n){}try{if(y(n,window)&&window.top)return window.top}catch(n){}for(var r=0,t=function n(r){for(var t=[],e=0,i=m(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(s(e)===e)return e}}}(r)===r)return!1;for(var e=0,i=m(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=tn(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}(n,t):J(r)?en(n,{send:i}):{domain:r}}).then(function(n){return n.domain})}var Cn=function n(r,t,e,i){var o=(i=i||{}).domain||K,u=i.timeout||-1,f=i.timeout||5e3,c=i.fireAndForget||!1;return k.try(function(){return function(n,r,t){if(!n)throw new Error("Expected name");if(t&&"string"!=typeof t&&!Array.isArray(t)&&!J(t))throw new TypeError("Expected domain to be a string, array, or regex");if(g(r))throw new Error("Target window is closed")}(t,r,o),Dn(r,o,f,{send:n})}).then(function(i){if(!_(o,i))throw new Error("Domain "+U(o)+" does not match "+U(i));o=i;var f,a,s=t===H.O&&e&&"string"==typeof e.name?e.name+"()":t,d=new k,w=t+"_"+q();if(!c){var h={name:t,win:r,domain:o,promise:d};!function(n,r){Q("responseListeners").set(n,r)}(w,h);var l=nn("requestPromises").getOrSet(r,function(){return[]});l.push(d),d.catch(function(){!function(n){Q("erroredResponseListeners").set(n,!0)}(w),An(w)});var y=function(n){return nn("knownWindows").get(n,!1)}(r)?1e4:2e3,m=u,p=y,E=m,b=(f=function(){return g(r)?d.reject(new Error("Window closed for "+t+" before "+(h.ack?"response":"ack"))):(p=Math.max(p-500,0),-1!==E&&(E=Math.max(E-500,0)),h.ack||0!==p?0===E?d.reject(new Error("No response for postMessage "+s+" in "+v()+" in "+m+"ms")):void 0:d.reject(new Error("No ack for postMessage "+s+" in "+v()+" in "+y+"ms")))},500,function n(){a=setTimeout(function(){f(),n()},500)}(),{cancel:function(){clearTimeout(a)}});d.finally(function(){b.cancel(),l.splice(l.indexOf(d,1))}).catch(B)}return Mn(r,o,{type:"postrobot_message_request",hash:w,name:t,data:e,fireAndForget:c},{on:In,send:n}),c?d.resolve():d})};function qn(n,r,t){return xn(n,r,t,{on:In,send:Cn})}function zn(n,r,t){return On(n,r,t,{on:In,send:Cn})}function Bn(n){return En.toProxyWindow(n,{send:Cn})}function Fn(){var n,r,t,e;Z().initialized||(Z().initialized=!0,r=(n={on:In,send:Cn}).on,t=n.send,(e=Z()).receiveMessage=e.receiveMessage||function(n){return Tn(n,{on:r,send:t})},function(n){var r=n.on,t=n.send;Q().getOrSet("postMessageListener",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");Tn({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:In,send:Cn}),function(n){var r=n.on,t=n.send;Q("builtinListeners").getOrSet("helloListener",function(){var n=r(H.j,{domain:K},function(n){var r=n.source,t=n.origin;return tn(r).resolve({win:r,domain:t}),{instanceID:rn()}}),e=b();return e&&en(e,{send:t}).catch(B),n})}({on:In,send:Cn}))}function Un(){var n;(n=Q().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_13__}function Jn(n){for(var r=0,t=nn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(B)}t.d(r,"bridge",function(){}),t.d(r,"Promise",function(){return k}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return En}),t.d(r,"setup",function(){return Fn}),t.d(r,"destroy",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 In}),t.d(r,"once",function(){return Ln}),t.d(r,"send",function(){return Cn}),t.d(r,"markWindowKnown",function(){return un}),t.d(r,"cleanUpWindow",function(){return Jn}),Fn()}])}); | ||
!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 C});var o={u:"mock:",h:"file:",v:"about:"},u="*",f={g:"iframe",_:"popup"},c="Call was rejected by callee.\r\n";function a(n){return void 0===n&&(n=window),n.location.protocol===o.v}function s(n){if(n)try{if(n.parent&&n.parent!==n)return n.parent}catch(n){}}function d(n){if(n&&!s(n))try{return n.opener}catch(n){}}function w(n){try{return!0}catch(n){}return!1}function h(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=s(n);return e&&w()?h(e):o.v+"//"}var i=r.host;if(!i)throw new Error("Can not read window host");return t+"//"+i}function v(n){var r=h(n=n||window);return r&&n.mockDomain&&0===n.mockDomain.indexOf(o.u)?n.mockDomain:r}function l(n){if(!function(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(a(n)&&w())return!0}catch(n){}try{if(h(n)===h(window))return!0}catch(n){}return!1}(n))return!1;try{if(n===window)return!0;if(a(n)&&w())return!0;if(v(window)===v(n))return!0}catch(n){}return!1}function y(n,r){if(!n||!r)return!1;var t=s(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 m(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!==c}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 d(n=n||window)||s(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===c)return!0}try{if("[object Window]"==={}.toString.call(n))return!0}catch(n){if(n&&n.message===c)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.self===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.parent===n)return!0}catch(n){if(n&&n.message===c)return!0}try{if(n&&n.top===n)return!0}catch(n){if(n&&n.message===c)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 P(){if(!R&&j){var n=j;j=null,n.resolve()}}function A(){R+=1}function W(){R-=1,P()}var k=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 W(),void this.reject(n)}W(),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,W()}},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 W(),n.reject(r)}return W(),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,P(),r;var r},n}();function S(){return(S=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,L=Object.defineProperty,D=Date.now()%1e9,C=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,D+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+D,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:L(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(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 C,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}function B(){}function F(n,r){if(void 0===r&&(r=1),r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,e=n&&n.message;if(t&&e)return-1!==t.indexOf(e)?t:e+"\n"+t;if(t)return t;if(e)return e}return"function"==typeof n.toString?n.toString():{}.toString.call(n)}catch(n){return"Error while stringifying error: "+F(n,r+1)}}function U(n){return"string"==typeof n?n:n&&"function"==typeof n.toString?n.toString():{}.toString.call(n)}function J(n){return"[object RegExp]"==={}.toString.call(n)}function G(n,r,t){if(n.hasOwnProperty(r))return n[r];var e=t();return n[r]=e,e}Object.create(Error.prototype);var H={O:"postrobot_method",j:"postrobot_hello",M:"postrobot_open_tunnel"},K="*",Y={N:"cross_domain_zalgo_promise",R:"cross_domain_function",P:"cross_domain_window"};function Z(n){return void 0===n&&(n=window),n!==window?n.__post_robot_10_0_14__:n.__post_robot_10_0_14__=n.__post_robot_10_0_14__||{}}var X=function(){return{}};function Q(n,r){return void 0===n&&(n="store"),void 0===r&&(r=X),G(Z(),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 G(n,r,t)},reset:function(){n=r()},keys:function(){return Object.keys(n)}}})}var V=function(){};function $(){var n=Z();return n.A=n.A||new V,n.A}function nn(n,r){return void 0===n&&(n="store"),void 0===r&&(r=X),Q("windowStore").getOrSet(n,function(){var t=new C,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 G(e(r),n,t)}}})}function rn(){return Q("instance").getOrSet("instanceID",q)}function tn(n){return nn("helloPromises").getOrSet(n,function(){return new k})}function en(n,r){return(0,r.send)(n,H.j,{instanceID:rn()},{domain:K,timeout:-1}).then(function(r){var t=r.origin,e=r.data.instanceID;return tn(n).resolve({win:n,domain:t}),{win:n,domain:t,instanceID:e}})}function on(n,r){var t=r.send;return nn("windowInstanceIDPromises").getOrSet(n,function(){return en(n,{send:t}).then(function(n){return n.instanceID})})}function un(n){nn("knownWindows").set(n,!0)}var fn,cn={W:"function",ERROR:"error",k:"promise",S:"regex",T:"date",I:"array",L:"object",D:"string",C:"number",q:"boolean",B:"null",F:"undefined"};function an(n){return"object"==typeof n&&null!==n&&"string"==typeof n.__type__}function sn(n){return void 0===n?cn.F:null===n?cn.B:Array.isArray(n)?cn.I:"function"==typeof n?cn.W:"object"==typeof n?n instanceof Error?cn.ERROR:"function"==typeof n.then?cn.k:"[object RegExp]"==={}.toString.call(n)?cn.S:"[object Date]"==={}.toString.call(n)?cn.T:cn.L:"string"==typeof n?cn.D:"number"==typeof n?cn.C:"boolean"==typeof n?cn.q:void 0}function dn(n,r){return{__type__:n,__val__:r}}var wn,hn=((fn={})[cn.W]=function(){},fn[cn.ERROR]=function(n){return dn(cn.ERROR,{message:n.message,stack:n.stack,code:n.code})},fn[cn.k]=function(){},fn[cn.S]=function(n){return dn(cn.S,n.source)},fn[cn.T]=function(n){return dn(cn.T,n.toJSON())},fn[cn.I]=function(n){return n},fn[cn.L]=function(n){return n},fn[cn.D]=function(n){return n},fn[cn.C]=function(n){return n},fn[cn.q]=function(n){return n},fn[cn.B]=function(n){return n},fn),vn={},ln=((wn={})[cn.W]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},wn[cn.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},wn[cn.k]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},wn[cn.S]=function(n){return new RegExp(n)},wn[cn.T]=function(n){return new Date(n)},wn[cn.I]=function(n){return n},wn[cn.L]=function(n){return n},wn[cn.D]=function(n){return n},wn[cn.C]=function(n){return n},wn[cn.q]=function(n){return n},wn[cn.B]=function(n){return n},wn),yn={};function mn(){for(var n=Q("idToProxyWindow"),r=0,t=n.keys();r<t.length;r++){var e=t[r];n.get(e).shouldClean()&&n.del(e)}}function pn(n,r,t){var e,i=t.send;return{id:n,type:d(r)?f._:f.g,getInstanceID:z(function(){return on(r,{send:i})}),close:function(){return k.try(function(){r.close()})},getName:function(){return k.try(function(){if(!g(r))return e})},focus:function(){return k.try(function(){r.focus()})},isClosed:function(){return k.try(function(){return g(r)})},setLocation:function(n){return k.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 k.try(function(){(r=function(n){if(!l(n))throw new Error("Expected window to be same domain");return n}(r)).name=n,r.frameElement&&r.frameElement.setAttribute("name",n),e=n})}}}new k(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 En=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.name=void 0,this.serializedWindow=n,this.actualWindowPromise=new k,this.send=e,r&&this.setWindow(r)}var r=n.prototype;return r.getType=function(){return this.serializedWindow.type},r.isPopup=function(){return this.getType()===f._},r.isIframe=function(){return this.getType()===f.g},r.setLocation=function(n){var r=this;return this.serializedWindow.setLocation(n).then(function(){return r})},r.setName=function(n){var r=this;return this.serializedWindow.setName(n).then(function(){return r})},r.close=function(){var n=this;return this.serializedWindow.close().then(function(){return n})},r.focus=function(){var n=this;return k.try(function(){return k.all([n.isPopup()&&n.serializedWindow.getName().then(function(n){n&&window.open("",n)}),n.serializedWindow.focus()])}).then(function(){return n})},r.isClosed=function(){return this.serializedWindow.isClosed()},r.getWindow=function(){return this.actualWindow},r.setWindow=function(n){this.actualWindow=n,this.serializedWindow=pn(this.serializedWindow.id,n,{send:this.send}),this.actualWindowPromise.resolve(n)},r.awaitWindow=function(){return this.actualWindowPromise},r.matchWindow=function(n){var r=this;return k.try(function(){return r.actualWindow?n===r.actualWindow:k.all([r.getInstanceID(),on(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.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 mn(),n.toProxyWindow(r,{send:e}).serialize()},n.deserialize=function(r,t){var e=t.on,i=t.send;return mn(),Q("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;if(mn(),n.isProxyWindow(r))return r;var i=r;return nn("winToProxyWindow").getOrSet(r,function(){var r=q(),t=new n(pn(r,i,{send:e}),i,{send:e});return Q("idToProxyWindow").set(r,t)})},n}();function gn(n,r,t,e,i){var o=nn("methodStore"),u=Q("proxyWindowMethods");En.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 bn(n,r){var t=nn("methodStore"),e=Q("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[r]||e.get(r)}function _n(n,r,t,e,i){!function(n){var r=i.on;Q("builtinListeners").getOrSet("functionCalls",function(){return r(H.O,{domain:K},function(n){var r=n.source,t=n.origin,e=n.data,i=e.id,o=e.name,u=bn(r,i);if(!u)throw new Error("Could not find method '"+e.name+"' with id: "+e.id+" in "+v(window));var f=u.source,c=u.domain,a=u.val;return k.try(function(){if(!_(c,t))throw new Error("Method '"+e.name+"' domain "+JSON.stringify(J(u.domain)?u.domain.source:u.domain)+" does not match origin "+t+" in "+v(window));if(En.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 "+v(window))})}).then(function(){return a.apply({source:r,origin:t},e.args)},function(n){return k.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=En.unwrap(n);var u=t.__name__||t.name||e;return En.isProxyWindow(n)?(gn(o,t,u,n,r),n.awaitWindow().then(function(n){gn(o,t,u,n,r)})):gn(o,t,u,n,r),dn(Y.R,{id:o,name:u})}function xn(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){void 0===r&&(r=vn);var t=JSON.stringify(n,function(n){var t=this[n];if(an(this))return t;var e=sn(t);if(!e)return t;var i=r[e]||hn[e];return i?i(t,n):t});return void 0===t?cn.F:t}(t,((i={})[cn.k]=function(t,e){return function(n,r,t,e,i){return dn(Y.N,{then:_n(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[cn.W]=function(t,e){return _n(n,r,t,e,{on:o,send:u})},i[cn.L]=function(n){return x(n)||En.isProxyWindow(n)?dn(Y.P,En.serialize(n,{send:u})):n},i))}function On(n,r,t,e){var i,o=e.on,u=e.send;return function(n,r){if(void 0===r&&(r=yn),n!==cn.F)return JSON.parse(n,function(n,t){if(an(this))return t;var e,i;if(an(t)?(e=t.__type__,i=t.__val__):(e=sn(t),i=t),!e)return i;var o=r[e]||ln[e];return o?o(i,n):i})}(t,((i={})[Y.N]=function(n){return new k(n.then)},i[Y.R]=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 En.toProxyWindow(n,{send:f}).awaitWindow().then(function(n){var c=bn(n,o);if(c&&c.val!==e)return c.val.apply({source:window,origin:v()},i);var a={domain:r,fireAndForget:t.fireAndForget},s=[].slice.call(i);return f(n,H.O,{id:o,name:u,args:s},a).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[Y.P]=function(n){return En.deserialize(n,{on:(r={on:o,send:u}).on,send:r.send});var r},i))}var jn={};function Mn(n,r,t,e){var i,o=e.on,u=e.send;if(g(n))throw new Error("Window is closed");for(var f=xn(n,r,((i={}).__post_robot_10_0_14__=S({id:q(),origin:v(window)},t),i),{on:o,send:u}),c=Object.keys(jn),a=[],s=0;s<c.length;s++){var d=c[s];try{jn[d](n,f,r)}catch(n){a.push(n)}}if(a.length===c.length)throw new Error("All post-robot messaging strategies failed:\n\n"+a.map(F).join("\n\n"))}jn.postrobot_post_message=function(n,r,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[K]).map(function(n){return 0===n.indexOf(o.h)?K:n}).forEach(function(t){n.postMessage(r,t)})};var Nn,Rn="__domain_regex__";function Pn(n){return Q("responseListeners").get(n)}function An(n){Q("responseListeners").del(n)}function Wn(n){return Q("erroredResponseListeners").has(n)}function kn(n){var r=n.name,t=n.win,e=n.domain,i=nn("requestListeners");if(t===K&&(t=null),e===K&&(e=null),!r)throw new Error("Name required to get request listener");for(var o=0,u=[t,$()];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[Rn])for(var s=0,d=a[Rn];s<d.length;s++){var w=d[s],h=w.listener;if(_(w.regex,e))return h}}if(a[K])return a[K]}}}}}var Sn=((Nn={}).postrobot_message_request=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)||Mn(n,r,S({type:e,ack:u,hash:t.hash,name:t.name},f),{on:i,send:o})}return k.all([f("postrobot_message_ack"),k.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("postrobot_message_response","success",{data:n})},function(n){return f("postrobot_message_response","error",{error:n})})]).then(B).catch(function(n){if(u&&u.handleError)return u.handleError(n);throw n})},Nn.postrobot_message_ack=function(n,r,t){if(!Wn(t.hash)){var e=Pn(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}},Nn.postrobot_message_response=function(n,r,t){if(!Wn(t.hash)){var e,o=Pn(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");An(t.hash),"error"===t.ack?o.promise.reject(t.error):"success"===t.ack&&o.promise.resolve({source:n,origin:r,data:t.data})}},Nn);function Tn(n,r){var t=r.on,e=r.send,i=Q("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=On(r,t,n,{on:o,send:u})}catch(n){return}if(i&&"object"==typeof i&&null!==i&&(i=i.__post_robot_10_0_14__)&&"object"==typeof i&&null!==i&&i.type&&"string"==typeof i.type&&Sn[i.type])return i}(n.data,u,f,{on:t,send:e});c&&(un(u),i.has(c.id)||(i.set(c.id,!0),g(u)&&!c.fireAndForget||(0===c.origin.indexOf(o.h)&&(f=o.h+"//"),Sn[c.type](u,f,c,{on:t,send:e}))))}function In(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=nn("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!==K||(i=$()),o=o||K,h)throw i&&o?new Error("Request listener already exists for "+e+" on domain "+o.toString()+" for "+(i===$()?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+e+" for "+(i===$()?"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,y=u.getOrSet(i,function(){return{}}),m=G(y,e,function(){return{}}),p=o.toString();return J(o)?(v=G(m,Rn,function(){return[]})).push(l={regex:o,listener:t}):m[p]=t,{cancel:function(){delete m[p],l&&(v.splice(v.indexOf(l,1)),v.length||delete m[Rn]),Object.keys(m).length||delete y[e],i&&!Object.keys(y).length&&u.del(i)}}}({name:n,win:e,domain:i},{handler:r.handler,handleError:r.errorHandler||function(n){throw n},window:e,domain:i||K,name:n});return{cancel:function(){o.cancel()}}}function Ln(n,r,t){"function"==typeof(r=r||{})&&(t=r,r={});var e,i=new k;return r.errorHandler=function(n){e.cancel(),i.reject(n)},e=In(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.send;return k.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(s(n)===n)return n;try{if(y(window,n)&&window.top)return window.top}catch(n){}try{if(y(n,window)&&window.top)return window.top}catch(n){}for(var r=0,t=function n(r){for(var t=[],e=0,i=m(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(s(e)===e)return e}}}(r)===r)return!1;for(var e=0,i=m(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=tn(n);return-1!==r&&(e=e.timeout(r,new Error(t+" did not load after "+r+"ms"))),e}(n,t):J(r)?en(n,{send:i}):{domain:r}}).then(function(n){return n.domain})}var Cn=function n(r,t,e,i){var o=(i=i||{}).domain||K,u=i.timeout||-1,f=i.timeout||5e3,c=i.fireAndForget||!1;return k.try(function(){return function(n,r,t){if(!n)throw new Error("Expected name");if(t&&"string"!=typeof t&&!Array.isArray(t)&&!J(t))throw new TypeError("Expected domain to be a string, array, or regex");if(g(r))throw new Error("Target window is closed")}(t,r,o),Dn(r,o,f,{send:n})}).then(function(i){if(!_(o,i))throw new Error("Domain "+U(o)+" does not match "+U(i));o=i;var f,a,s=t===H.O&&e&&"string"==typeof e.name?e.name+"()":t,d=new k,w=t+"_"+q();if(!c){var h={name:t,win:r,domain:o,promise:d};!function(n,r){Q("responseListeners").set(n,r)}(w,h);var l=nn("requestPromises").getOrSet(r,function(){return[]});l.push(d),d.catch(function(){!function(n){Q("erroredResponseListeners").set(n,!0)}(w),An(w)});var y=function(n){return nn("knownWindows").get(n,!1)}(r)?1e4:2e3,m=u,p=y,E=m,b=(f=function(){return g(r)?d.reject(new Error("Window closed for "+t+" before "+(h.ack?"response":"ack"))):h.cancelled?d.reject(new Error("Response listener was cancelled for "+t)):(p=Math.max(p-500,0),-1!==E&&(E=Math.max(E-500,0)),h.ack||0!==p?0===E?d.reject(new Error("No response for postMessage "+s+" in "+v()+" in "+m+"ms")):void 0:d.reject(new Error("No ack for postMessage "+s+" in "+v()+" in "+y+"ms")))},500,function n(){a=setTimeout(function(){f(),n()},500)}(),{cancel:function(){clearTimeout(a)}});d.finally(function(){b.cancel(),l.splice(l.indexOf(d,1))}).catch(B)}return Mn(r,o,{type:"postrobot_message_request",hash:w,name:t,data:e,fireAndForget:c},{on:In,send:n}),c?d.resolve():d})};function qn(n,r,t){return xn(n,r,t,{on:In,send:Cn})}function zn(n,r,t){return On(n,r,t,{on:In,send:Cn})}function Bn(n){return En.toProxyWindow(n,{send:Cn})}function Fn(){var n,r,t,e;Z().initialized||(Z().initialized=!0,r=(n={on:In,send:Cn}).on,t=n.send,(e=Z()).receiveMessage=e.receiveMessage||function(n){return Tn(n,{on:r,send:t})},function(n){var r=n.on,t=n.send;Q().getOrSet("postMessageListener",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");Tn({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:In,send:Cn}),function(n){var r=n.on,t=n.send;Q("builtinListeners").getOrSet("helloListener",function(){var n=r(H.j,{domain:K},function(n){var r=n.source,t=n.origin;return tn(r).resolve({win:r,domain:t}),{instanceID:rn()}}),e=b();return e&&en(e,{send:t}).catch(B),n})}({on:In,send:Cn}))}function Un(){var n;!function(){for(var n=Q("responseListeners"),r=0,t=n.keys();r<t.length;r++){var e=t[r],i=n.get(e);i&&(i.cancelled=!0),n.del(e)}}(),(n=Q().get("postMessageListener"))&&n.cancel(),delete window.__post_robot_10_0_14__}function Jn(n){for(var r=0,t=nn("requestPromises").get(n,[]);r<t.length;r++)t[r].reject(new Error("Window cleaned up before response")).catch(B)}t.d(r,"bridge",function(){}),t.d(r,"Promise",function(){return k}),t.d(r,"TYPES",function(){return!0}),t.d(r,"ProxyWindow",function(){return En}),t.d(r,"setup",function(){return Fn}),t.d(r,"destroy",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 In}),t.d(r,"once",function(){return Ln}),t.d(r,"send",function(){return Cn}),t.d(r,"markWindowKnown",function(){return un}),t.d(r,"cleanUpWindow",function(){return Jn}),Fn()}])}); | ||
//# sourceMappingURL=post-robot.min.js.map |
{ | ||
"name": "post-robot", | ||
"version": "10.0.13", | ||
"version": "10.0.14", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,4 @@ /* @flow */ | ||
promise : ZalgoPromise<*>, | ||
ack? : ?boolean | ||
ack? : ?boolean, | ||
cancelled? : ?boolean | ||
|}; | ||
@@ -51,2 +52,13 @@ | ||
export function cancelResponseListeners() { | ||
const responseListeners = globalStore('responseListeners'); | ||
for (const hash of responseListeners.keys()) { | ||
const listener = responseListeners.get(hash); | ||
if (listener) { | ||
listener.cancelled = true; | ||
} | ||
responseListeners.del(hash); | ||
} | ||
} | ||
export function markResponseListenerErrored(hash : string) { | ||
@@ -53,0 +65,0 @@ const erroredResponseListeners = globalStore('erroredResponseListeners'); |
@@ -103,2 +103,6 @@ /* @flow */ | ||
if (responseListener.cancelled) { | ||
return promise.reject(new Error(`Response listener was cancelled for ${ name }`)); | ||
} | ||
ackTimeout = Math.max(ackTimeout - RESPONSE_CYCLE_TIME, 0); | ||
@@ -105,0 +109,0 @@ if (resTimeout !== -1) { |
@@ -6,3 +6,3 @@ /* @flow */ | ||
import { initHello } from './lib'; | ||
import { listenForMessages, stopListenForMessages, receiveMessage, setupGlobalReceiveMessage } from './drivers'; | ||
import { listenForMessages, stopListenForMessages, receiveMessage, setupGlobalReceiveMessage, cancelResponseListeners } from './drivers'; | ||
import { getGlobal, deleteGlobal } from './global'; | ||
@@ -41,4 +41,5 @@ import { on, send } from './public'; | ||
export function destroy() { | ||
cancelResponseListeners(); | ||
stopListenForMessages(); | ||
deleteGlobal(); | ||
} |
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
1440334
8739