New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

post-robot

Package Overview
Dependencies
Maintainers
2
Versions
246
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

post-robot - npm Package Compare versions

Comparing version 9.0.3 to 9.0.4

dist/module/drivers/types.js

6

dist/module/bridge/bridge.js

@@ -5,3 +5,3 @@ import 'zalgo-promise/src';

import { CONSTANTS } from '../conf';
import { MESSAGE_NAME, WILDCARD } from '../conf';
import { global } from '../global';

@@ -89,3 +89,3 @@

return global.send(parentWindow, CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL, {
return global.send(parentWindow, MESSAGE_NAME.OPEN_TUNNEL, {

@@ -118,3 +118,3 @@ name: name,

}
}, { domain: CONSTANTS.WILDCARD });
}, { domain: WILDCARD });
};

@@ -5,3 +5,3 @@ import { ZalgoPromise } from 'zalgo-promise/src';

import { CONSTANTS } from '../conf';
import { WINDOW_PROP } from '../conf';
import { global } from '../global';

@@ -21,3 +21,3 @@

// $FlowFixMe
if (isSameDomain(frame) && frame[CONSTANTS.WINDOW_PROPS.POSTROBOT]) {
if (isSameDomain(frame) && frame[WINDOW_PROP.POSTROBOT]) {
return frame;

@@ -33,3 +33,3 @@ }

// $FlowFixMe
if (frame && isSameDomain(frame) && frame[CONSTANTS.WINDOW_PROPS.POSTROBOT]) {
if (frame && isSameDomain(frame) && frame[WINDOW_PROP.POSTROBOT]) {
clearInterval(interval);

@@ -77,3 +77,3 @@ clearTimeout(timeout);

return bridge[CONSTANTS.WINDOW_PROPS.POSTROBOT].openTunnelToParent({
return bridge[WINDOW_PROP.POSTROBOT].openTunnelToParent({

@@ -80,0 +80,0 @@ name: window.name,

@@ -5,3 +5,3 @@ import { WeakMap } from 'cross-domain-safe-weakmap/src';

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, BRIDGE_NAME_PREFIX } from '../conf';
import { global } from '../global';

@@ -72,3 +72,3 @@

var id = CONSTANTS.BRIDGE_NAME_PREFIX + '_' + sanitizedDomain;
var id = BRIDGE_NAME_PREFIX + '_' + sanitizedDomain;

@@ -114,3 +114,3 @@ return id;

var sendMessageWrapper = function sendMessageWrapper(remoteWin, message, remoteDomain) {
var sendMessageWrapper = function sendMessageWrapper(remoteWin, remoteDomain, message) {

@@ -143,3 +143,3 @@ if (remoteWin !== win) {

export function sendBridgeMessage(win, message, domain) {
export function sendBridgeMessage(win, domain, message) {

@@ -160,4 +160,4 @@ var messagingChild = isOpener(window, win);

return remoteWindow.sendMessagePromise.then(function (sendMessage) {
return sendMessage(win, message, domain);
return sendMessage(win, domain, message);
});
}

@@ -5,3 +5,3 @@ import { WeakMap } from 'cross-domain-safe-weakmap/src';

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, PROTOCOL, MESSAGE_NAME } from '../conf';
import { onChildWindowReady } from '../lib';

@@ -19,3 +19,3 @@ import { global } from '../global';

function listenForRegister(source, domain) {
global.on(CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL, { window: source, domain: domain }, function (_ref) {
global.on(MESSAGE_NAME.OPEN_TUNNEL, { window: source, domain: domain }, function (_ref) {
var origin = _ref.origin,

@@ -161,3 +161,3 @@ data = _ref.data;

if (url && url.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0) {
if (url && url.indexOf(PROTOCOL.MOCK) === 0) {
var _url$split = url.split('|');

@@ -164,0 +164,0 @@

var _ALLOWED_POST_MESSAGE;
import { CONSTANTS } from './constants';
import { SEND_STRATEGY, PROTOCOL } from './constants';

@@ -16,7 +16,7 @@ export var CONFIG = {

ALLOWED_POST_MESSAGE_METHODS: (_ALLOWED_POST_MESSAGE = {}, _ALLOWED_POST_MESSAGE[CONSTANTS.SEND_STRATEGIES.POST_MESSAGE] = true, _ALLOWED_POST_MESSAGE[CONSTANTS.SEND_STRATEGIES.BRIDGE] = true, _ALLOWED_POST_MESSAGE[CONSTANTS.SEND_STRATEGIES.GLOBAL] = true, _ALLOWED_POST_MESSAGE)
ALLOWED_POST_MESSAGE_METHODS: (_ALLOWED_POST_MESSAGE = {}, _ALLOWED_POST_MESSAGE[SEND_STRATEGY.POST_MESSAGE] = true, _ALLOWED_POST_MESSAGE[SEND_STRATEGY.BRIDGE] = true, _ALLOWED_POST_MESSAGE[SEND_STRATEGY.GLOBAL] = true, _ALLOWED_POST_MESSAGE)
};
if (window.location.href.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
if (window.location.href.indexOf(PROTOCOL.FILE) === 0) {
CONFIG.ALLOW_POSTMESSAGE_POPUP = true;
}

@@ -1,61 +0,47 @@

export var CONSTANTS = {
export var MESSAGE_TYPE = {
REQUEST: 'postrobot_message_request',
RESPONSE: 'postrobot_message_response',
ACK: 'postrobot_message_ack'
};
POST_MESSAGE_TYPE: {
REQUEST: 'postrobot_message_request',
RESPONSE: 'postrobot_message_response',
ACK: 'postrobot_message_ack'
},
export var MESSAGE_ACK = {
SUCCESS: 'success',
ERROR: 'error'
};
POST_MESSAGE_ACK: {
SUCCESS: 'success',
ERROR: 'error'
},
export var MESSAGE_NAME = {
METHOD: 'postrobot_method',
HELLO: 'postrobot_ready',
OPEN_TUNNEL: 'postrobot_open_tunnel'
};
POST_MESSAGE_NAMES: {
METHOD: 'postrobot_method',
HELLO: 'postrobot_ready',
OPEN_TUNNEL: 'postrobot_open_tunnel'
},
export var WINDOW_TYPE = {
FULLPAGE: 'fullpage',
POPUP: 'popup',
IFRAME: 'iframe'
};
WINDOW_TYPES: {
FULLPAGE: 'fullpage',
POPUP: 'popup',
IFRAME: 'iframe'
},
export var WINDOW_PROP = {
POSTROBOT: '__postRobot__'
};
WINDOW_PROPS: {
POSTROBOT: '__postRobot__'
},
export var SERIALIZATION_TYPE = {
METHOD: 'postrobot_method',
ZALGO_PROMISE: 'postrobot_zalgo_promise'
};
SERIALIZATION_TYPES: {
METHOD: 'postrobot_method',
ERROR: 'postrobot_error',
PROMISE: 'postrobot_promise',
ZALGO_PROMISE: 'postrobot_zalgo_promise',
REGEX: 'regex'
},
SEND_STRATEGIES: {
POST_MESSAGE: 'postrobot_post_message',
BRIDGE: 'postrobot_bridge',
GLOBAL: 'postrobot_global'
},
MOCK_PROTOCOL: 'mock:',
FILE_PROTOCOL: 'file:',
BRIDGE_NAME_PREFIX: '__postrobot_bridge__',
POSTROBOT_PROXY: '__postrobot_proxy__',
WILDCARD: '*'
export var SEND_STRATEGY = {
POST_MESSAGE: 'postrobot_post_message',
BRIDGE: 'postrobot_bridge',
GLOBAL: 'postrobot_global'
};
export var POST_MESSAGE_NAMES = {
METHOD: 'postrobot_method',
HELLO: 'postrobot_hello',
OPEN_TUNNEL: 'postrobot_open_tunnel'
export var PROTOCOL = {
MOCK: 'mock:',
FILE: 'file:'
};
export var POST_MESSAGE_NAMES_LIST = Object.keys(POST_MESSAGE_NAMES).map(function (key) {
return POST_MESSAGE_NAMES[key];
});
export var BRIDGE_NAME_PREFIX = '__postrobot_bridge__';
export var POSTROBOT_PROXY = '__postrobot_proxy__';
export var WILDCARD = '*';

@@ -7,3 +7,3 @@ import 'zalgo-promise/src';

import { global } from '../global';
import { CONSTANTS } from '../conf';
import { WILDCARD } from '../conf';

@@ -49,7 +49,7 @@ export function resetListeners() {

if (win === CONSTANTS.WILDCARD) {
if (win === WILDCARD) {
win = null;
}
if (domain === CONSTANTS.WILDCARD) {
if (domain === WILDCARD) {
domain = null;

@@ -95,4 +95,4 @@ }

if (winListeners[CONSTANTS.WILDCARD]) {
return winListeners[CONSTANTS.WILDCARD];
if (winListeners[WILDCARD]) {
return winListeners[WILDCARD];
}

@@ -151,7 +151,7 @@ }

if (!win || win === CONSTANTS.WILDCARD) {
if (!win || win === WILDCARD) {
win = global.WINDOW_WILDCARD;
}
domain = domain || CONSTANTS.WILDCARD;
domain = domain || WILDCARD;

@@ -158,0 +158,0 @@ if (existingListener) {

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
import { isWindowClosed } from 'cross-domain-utils/src';
import { isWindowClosed, getDomain } from 'cross-domain-utils/src';
import { addEventListener, noop } from 'belter/src';
import { CONSTANTS, POST_MESSAGE_NAMES_LIST } from '../../conf';
import { deserializeMethods, markWindowKnown } from '../../lib';
import { MESSAGE_NAME, WINDOW_PROP, MESSAGE_TYPE } from '../../conf';
import { deserializeMessage, markWindowKnown } from '../../lib';
import { global } from '../../global';

@@ -14,3 +14,3 @@

function parseMessage(message) {
function parseMessage(message, source, origin) {

@@ -20,3 +20,3 @@ var parsedMessage = void 0;

try {
parsedMessage = JSON.parse(message);
parsedMessage = deserializeMessage(source, origin, message);
} catch (err) {

@@ -34,3 +34,3 @@ return;

parsedMessage = parsedMessage[CONSTANTS.WINDOW_PROPS.POSTROBOT];
parsedMessage = parsedMessage[WINDOW_PROP.POSTROBOT];

@@ -71,4 +71,9 @@ if (!parsedMessage || (typeof parsedMessage === 'undefined' ? 'undefined' : _typeof(parsedMessage)) !== 'object' || parsedMessage === null) {

var message = parseMessage(data);
if (__TEST__) {
// $FlowFixMe
origin = getDomain(source);
}
var message = parseMessage(data, source, origin);
if (!message) {

@@ -80,10 +85,2 @@ return;

if (!message.sourceDomain || typeof message.sourceDomain !== 'string') {
throw new Error('Expected message to have sourceDomain');
}
if (message.sourceDomain.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0 || message.sourceDomain.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
origin = message.sourceDomain;
}
if (global.receivedMessages.indexOf(message.id) === -1) {

@@ -98,3 +95,5 @@ global.receivedMessages.push(message.id);

if (POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 || message.type === CONSTANTS.POST_MESSAGE_TYPE.ACK) {
if (Object.keys(MESSAGE_NAME).map(function (key) {
return MESSAGE_NAME[key];
}).indexOf(message.name) !== -1 || message.type === MESSAGE_TYPE.ACK) {
level = 'debug';

@@ -118,6 +117,2 @@ } else if (message.ack === 'error') {

if (message.data) {
message.data = deserializeMethods(source, origin, message.data);
}
RECEIVE_MESSAGE_TYPES[message.type](source, origin, message);

@@ -124,0 +119,0 @@ }

@@ -7,10 +7,11 @@ var _RECEIVE_MESSAGE_TYPE;

import { isWindowClosed, matchDomain, stringifyDomainPattern } from 'cross-domain-utils/src';
import { stringifyError, noop } from 'belter/src';
import { noop } from 'belter/src';
import { CONSTANTS } from '../../conf';
import { MESSAGE_TYPE, MESSAGE_ACK } from '../../conf';
import { sendMessage } from '../send';
import { getRequestListener, getResponseListener, deleteResponseListener, isResponseListenerErrored } from '../listeners';
export var RECEIVE_MESSAGE_TYPES = (_RECEIVE_MESSAGE_TYPE = {}, _RECEIVE_MESSAGE_TYPE[CONSTANTS.POST_MESSAGE_TYPE.ACK] = function (source, origin, message) {
export var RECEIVE_MESSAGE_TYPES = (_RECEIVE_MESSAGE_TYPE = {}, _RECEIVE_MESSAGE_TYPE[MESSAGE_TYPE.ACK] = function (source, origin, message) {
if (isResponseListenerErrored(message.hash)) {

@@ -31,8 +32,10 @@ return;

options.ack = true;
}, _RECEIVE_MESSAGE_TYPE[CONSTANTS.POST_MESSAGE_TYPE.REQUEST] = function (source, origin, message) {
}, _RECEIVE_MESSAGE_TYPE[MESSAGE_TYPE.REQUEST] = function (source, origin, message) {
var options = getRequestListener({ name: message.name, win: source, domain: origin });
function respond(data) {
function sendResponse(type) {
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (message.fireAndForget || isWindowClosed(source)) {

@@ -42,12 +45,11 @@ return ZalgoPromise.resolve();

return sendMessage(source, _extends({
target: message.originalSource,
// $FlowFixMe
return sendMessage(source, origin, _extends({
type: type,
hash: message.hash,
name: message.name
}, data), origin);
}, data));
}
return ZalgoPromise.all([respond({
type: CONSTANTS.POST_MESSAGE_TYPE.ACK
}), ZalgoPromise['try'](function () {
return ZalgoPromise.all([sendResponse(MESSAGE_TYPE.ACK), ZalgoPromise['try'](function () {

@@ -66,22 +68,12 @@ if (!options) {

}).then(function (data) {
return respond({
type: CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,
ack: CONSTANTS.POST_MESSAGE_ACK.SUCCESS,
return sendResponse(MESSAGE_TYPE.RESPONSE, {
ack: MESSAGE_ACK.SUCCESS,
data: data
});
}, function (err) {
var error = stringifyError(err).replace(/^Error: /, '');
// $FlowFixMe
var code = err.code;
return respond({
type: CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,
ack: CONSTANTS.POST_MESSAGE_ACK.ERROR,
error: error,
code: code
}, function (error) {
return sendResponse(MESSAGE_TYPE.RESPONSE, {
ack: MESSAGE_ACK.ERROR,
error: error
});
})]).then(noop)['catch'](function (err) {
if (options && options.handleError) {

@@ -93,3 +85,3 @@ return options.handleError(err);

});
}, _RECEIVE_MESSAGE_TYPE[CONSTANTS.POST_MESSAGE_TYPE.RESPONSE] = function (source, origin, message) {
}, _RECEIVE_MESSAGE_TYPE[MESSAGE_TYPE.RESPONSE] = function (source, origin, message) {

@@ -112,14 +104,8 @@ if (isResponseListenerErrored(message.hash)) {

if (message.ack === CONSTANTS.POST_MESSAGE_ACK.ERROR) {
var err = new Error(message.error);
if (message.code) {
// $FlowFixMe
err.code = message.code;
}
return options.respond(err, null);
} else if (message.ack === CONSTANTS.POST_MESSAGE_ACK.SUCCESS) {
var data = message.data || message.response;
if (message.ack === MESSAGE_ACK.ERROR) {
return options.respond(message.error, null);
} else if (message.ack === MESSAGE_ACK.SUCCESS) {
var data = message.data;
return options.respond(null, { source: source, origin: origin, data: data });
}
}, _RECEIVE_MESSAGE_TYPE);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import { getDomain, isWindowClosed } from 'cross-domain-utils/src';
import { isWindowClosed } from 'cross-domain-utils/src';
import { ZalgoPromise } from 'zalgo-promise/src';
import { uniqueID, stringifyError } from 'belter/src';
import { CONSTANTS, CONFIG, POST_MESSAGE_NAMES_LIST } from '../../conf';
import { serializeMethods, getWindowType } from '../../lib';
import { MESSAGE_TYPE, CONFIG, MESSAGE_NAME, WILDCARD, WINDOW_PROP } from '../../conf';
import { serializeMessage, getWindowType } from '../../lib';
import { SEND_MESSAGE_STRATEGIES } from './strategies';
function buildMessage(win, message) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
function logMessage(domain, message) {
if (__DEBUG__) {
var level = void 0;
if (Object.keys(MESSAGE_NAME).map(function (key) {
return MESSAGE_NAME[key];
}).indexOf(message.name) !== -1 || message.type === MESSAGE_TYPE.ACK) {
level = 'debug';
} else if (message.ack === 'error') {
level = 'error';
} else {
level = 'info';
}
var id = uniqueID();
var type = getWindowType();
var sourceDomain = getDomain(window);
return _extends({}, message, options, {
sourceDomain: sourceDomain,
id: message.id || id,
windowType: type
});
// eslint-disable-next-line no-console
if (typeof console !== 'undefined' && typeof console[level] === 'function') {
// eslint-disable-next-line no-console
console[level]('postrobot_send', message.type.replace(/^postrobot_message_/, ''), '::', message.name, '::', domain || WILDCARD, '\n\n', message);
}
}
}
export function sendMessage(win, message, domain) {
export function sendMessage(win, domain, message) {
return ZalgoPromise['try'](function () {
var _JSON$stringify;
var _serializeMessage;
message = buildMessage(win, message, {
data: serializeMethods(win, domain, message.data),
domain: domain
});
var level = void 0;
if (__DEBUG__) {
if (POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 || message.type === CONSTANTS.POST_MESSAGE_TYPE.ACK) {
level = 'debug';
} else if (message.ack === 'error') {
level = 'error';
} else {
level = 'info';
}
// eslint-disable-next-line no-console
if (typeof console !== 'undefined' && typeof console[level] === 'function') {
// eslint-disable-next-line no-console
console[level]('postrobot_send', message.type.replace(/^postrobot_message_/, ''), '::', message.name, '::', domain || CONSTANTS.WILDCARD, '\n\n', message);
}
}
if (isWindowClosed(win)) {

@@ -58,6 +43,11 @@ throw new Error('Window is closed');

logMessage(domain, message);
var serializedMessage = serializeMessage(win, domain, (_serializeMessage = {}, _serializeMessage[WINDOW_PROP.POSTROBOT] = _extends({}, message, {
id: uniqueID(),
windowType: getWindowType()
}), _serializeMessage));
var messages = [];
var serializedMessage = JSON.stringify((_JSON$stringify = {}, _JSON$stringify[CONSTANTS.WINDOW_PROPS.POSTROBOT] = message, _JSON$stringify), null, 2);
return ZalgoPromise.map(Object.keys(SEND_MESSAGE_STRATEGIES), function (strategyName) {

@@ -64,0 +54,0 @@

import { isSameDomain, isSameTopWindow, isActuallySameDomain, getActualDomain, getDomain } from 'cross-domain-utils/src';
import { CONSTANTS } from '../../conf';
import { SEND_STRATEGY, PROTOCOL, WILDCARD, WINDOW_PROP } from '../../conf';
import { needsGlobalMessagingForBrowser } from '../../lib';

@@ -8,3 +8,3 @@

SEND_MESSAGE_STRATEGIES[CONSTANTS.SEND_STRATEGIES.POST_MESSAGE] = function (win, serializedMessage, domain) {
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.POST_MESSAGE] = function (win, serializedMessage, domain) {

@@ -26,3 +26,3 @@ if (__POST_ROBOT__.__IE_POPUP_SUPPORT__) {

} else {
domains = [CONSTANTS.WILDCARD];
domains = [WILDCARD];
}

@@ -32,6 +32,6 @@

if (dom.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0) {
if (dom.indexOf(PROTOCOL.MOCK) === 0) {
if (window.location.protocol === CONSTANTS.FILE_PROTOCOL) {
return CONSTANTS.WILDCARD;
if (window.location.protocol === PROTOCOL.FILE) {
return WILDCARD;
}

@@ -47,4 +47,4 @@

if (dom.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
return CONSTANTS.WILDCARD;
if (dom.indexOf(PROTOCOL.FILE) === 0) {
return WILDCARD;
}

@@ -66,3 +66,3 @@

SEND_MESSAGE_STRATEGIES[CONSTANTS.SEND_STRATEGIES.BRIDGE] = function (win, serializedMessage, domain) {
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.BRIDGE] = function (win, serializedMessage, domain) {

@@ -81,3 +81,3 @@ if (!needsBridgeForBrowser() && !isBridge()) {

return sendBridgeMessage(win, serializedMessage, domain);
return sendBridgeMessage(win, domain, serializedMessage);
};

@@ -88,3 +88,3 @@ }

SEND_MESSAGE_STRATEGIES[CONSTANTS.SEND_STRATEGIES.GLOBAL] = function (win, serializedMessage) {
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.GLOBAL] = function (win, serializedMessage) {

@@ -104,3 +104,3 @@ if (!needsGlobalMessagingForBrowser()) {

// $FlowFixMe
var foreignGlobal = win[CONSTANTS.WINDOW_PROPS.POSTROBOT];
var foreignGlobal = win[WINDOW_PROP.POSTROBOT];

@@ -107,0 +107,0 @@ if (!foreignGlobal) {

@@ -1,4 +0,4 @@

import { CONSTANTS } from './conf';
import { WINDOW_PROP } from './conf';
export var global = window[CONSTANTS.WINDOW_PROPS.POSTROBOT] = window[CONSTANTS.WINDOW_PROPS.POSTROBOT] || {};
export var global = window[WINDOW_PROP.POSTROBOT] = window[WINDOW_PROP.POSTROBOT] || {};

@@ -5,0 +5,0 @@ // Backwards compatibility

@@ -1,8 +0,7 @@

import { initOnReady, listenForMethods } from './lib';
import { initOnReady } from './lib';
import { listenForMessages } from './drivers';
import { global } from './global';
import { on, send } from './public';
export * from './public';
export { markWindowKnown } from './lib';
export { markWindowKnown, serializeMessage, deserializeMessage } from './lib';
export { cleanUpWindow } from './clean';

@@ -21,3 +20,2 @@ export { ZalgoPromise as Promise } from 'zalgo-promise/src';

initOnReady();
listenForMethods({ on: on, send: send });
}

@@ -24,0 +22,0 @@

@@ -6,3 +6,3 @@ import { WeakMap } from 'cross-domain-safe-weakmap/src';

import { CONSTANTS } from '../conf';
import { MESSAGE_NAME, WILDCARD } from '../conf';
import { global } from '../global';

@@ -14,3 +14,3 @@

export function onHello(handler) {
global.on(CONSTANTS.POST_MESSAGE_NAMES.HELLO, { domain: CONSTANTS.WILDCARD }, function (_ref) {
global.on(MESSAGE_NAME.HELLO, { domain: WILDCARD }, function (_ref) {
var source = _ref.source,

@@ -24,3 +24,3 @@ origin = _ref.origin;

export function sayHello(win) {
return global.send(win, CONSTANTS.POST_MESSAGE_NAMES.HELLO, {}, { domain: CONSTANTS.WILDCARD, timeout: -1 }).then(function (_ref2) {
return global.send(win, MESSAGE_NAME.HELLO, {}, { domain: WILDCARD, timeout: -1 }).then(function (_ref2) {
var origin = _ref2.origin;

@@ -27,0 +27,0 @@

@@ -1,9 +0,8 @@

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
import { WeakMap } from 'cross-domain-safe-weakmap/src';
import { matchDomain } from 'cross-domain-utils/src';
import { ZalgoPromise } from 'zalgo-promise/src';
import { once, uniqueID, replaceObject, stringifyError, isRegex } from 'belter/src';
import { once, uniqueID } from 'belter/src';
import { TYPE, serialize, serializeType, deserialize } from 'universal-serialize/src';
import { CONSTANTS } from '../conf';
import { MESSAGE_NAME, WILDCARD } from '../conf';
import { global } from '../global';

@@ -13,4 +12,4 @@

export var listenForMethods = once(function () {
global.on(CONSTANTS.POST_MESSAGE_NAMES.METHOD, { origin: CONSTANTS.WILDCARD }, function (_ref) {
var listenForFunctionCalls = once(function () {
global.on(MESSAGE_NAME.METHOD, { origin: WILDCARD }, function (_ref) {
var source = _ref.source,

@@ -20,3 +19,2 @@ origin = _ref.origin,

var methods = global.methods.get(source);

@@ -39,10 +37,8 @@

return ZalgoPromise['try'](function () {
return meth.method.apply({ source: source, origin: origin, data: data }, data.args);
return meth.val.apply({ source: source, origin: origin, data: data }, data.args);
}).then(function (result) {
var id = data.id,
name = data.name;
return {
result: result,
id: data.id,
name: data.name
};
return { result: result, id: id, name: name };
});

@@ -52,8 +48,8 @@ });

function isSerialized(item, type) {
return (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' && item !== null && item.__type__ === type;
}
var CUSTOM_TYPE = {
CROSS_DOMAIN_ZALGO_PROMISE: 'cross_domain_zalgo_promise',
CROSS_DOMAIN_FUNCTION: 'cross_domain_function'
};
export function serializeMethod(destination, domain, method, name) {
function serializeFunction(destination, domain, val, key) {
var id = uniqueID();

@@ -68,160 +64,68 @@

methods[id] = { domain: domain, method: method };
methods[id] = { domain: domain, val: val };
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.METHOD,
__id__: id,
__name__: name
};
}
listenForFunctionCalls();
function serializeError(err) {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.ERROR,
__message__: stringifyError(err),
// $FlowFixMe
__code__: err.code
};
return serializeType(CUSTOM_TYPE.CROSS_DOMAIN_FUNCTION, { id: id, name: val.name || key });
}
function serializePromise(destination, domain, promise, name) {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.PROMISE,
__then__: serializeMethod(destination, domain, function (resolve, reject) {
return promise.then(resolve, reject);
}, name + '.then')
};
}
function deserializeFunction(source, origin, _ref2) {
var id = _ref2.id,
name = _ref2.name;
function serializeZalgoPromise(destination, domain, promise, name) {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.ZALGO_PROMISE,
__then__: serializeMethod(destination, domain, function (resolve, reject) {
return promise.then(resolve, reject);
}, name + '.then')
};
}
function serializeRegex(regex) {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.REGEX,
__source__: regex.source
};
}
export function serializeMethods(destination, domain, obj) {
return replaceObject({ obj: obj }, function (item, key) {
if (typeof item === 'function') {
return serializeMethod(destination, domain, item, key.toString());
}
if (item instanceof Error) {
return serializeError(item);
}
if (window.Promise && item instanceof window.Promise) {
return serializePromise(destination, domain, item, key.toString());
}
if (ZalgoPromise.isPromise(item)) {
// $FlowFixMe
return serializeZalgoPromise(destination, domain, item, key.toString());
}
if (isRegex(item)) {
// $FlowFixMe
return serializeRegex(item);
}
return item;
}).obj;
}
export function deserializeMethod(source, origin, obj) {
function wrapper() {
function crossDomainFunctionWrapper() {
var args = Array.prototype.slice.call(arguments);
return global.send(source, CONSTANTS.POST_MESSAGE_NAMES.METHOD, {
id: obj.__id__,
name: obj.__name__,
args: args
}, { domain: origin, timeout: -1 }).then(function (_ref2) {
var data = _ref2.data;
return global.send(source, MESSAGE_NAME.METHOD, { id: id, name: name, args: args }, { domain: origin }).then(function (_ref3) {
var data = _ref3.data;
return data.result;
}, function (err) {
throw err;
});
}
wrapper.__name__ = obj.__name__;
wrapper.__xdomain__ = true;
crossDomainFunctionWrapper.__name__ = name;
crossDomainFunctionWrapper.__xdomain__ = true;
wrapper.source = source;
wrapper.origin = origin;
crossDomainFunctionWrapper.source = source;
crossDomainFunctionWrapper.origin = origin;
return wrapper;
return crossDomainFunctionWrapper;
}
export function deserializeError(source, origin, obj) {
var err = new Error(obj.__message__);
if (obj.__code__) {
// $FlowFixMe
err.code = obj.__code__;
}
return err;
function serializePromise(destination, domain, val, key) {
return serializeType(CUSTOM_TYPE.CROSS_DOMAIN_ZALGO_PROMISE, {
then: serializeFunction(destination, domain, function (resolve, reject) {
return val.then(resolve, reject);
}, key)
});
}
export function deserializeZalgoPromise(source, origin, prom) {
function deserializePromise(source, origin, _ref4) {
var then = _ref4.then;
return new ZalgoPromise(function (resolve, reject) {
return deserializeMethod(source, origin, prom.__then__)(resolve, reject);
deserializeFunction(source, origin, then)(resolve, reject);
});
}
export function deserializePromise(source, origin, prom) {
if (!window.Promise) {
return deserializeZalgoPromise(source, origin, prom);
}
export function serializeMessage(destination, domain, obj) {
var _serialize;
return new window.Promise(function (resolve, reject) {
return deserializeMethod(source, origin, prom.__then__)(resolve, reject);
});
return serialize(obj, (_serialize = {}, _serialize[TYPE.PROMISE] = function (val, key) {
return serializePromise(destination, domain, val, key);
}, _serialize[TYPE.FUNCTION] = function (val, key) {
return serializeFunction(destination, domain, val, key);
}, _serialize));
}
export function deserializeRegex(source, origin, item) {
// eslint-disable-next-line security/detect-non-literal-regexp
return new RegExp(item.__source__);
}
export function deserializeMessage(source, origin, message) {
var _deserialize;
export function deserializeMethods(source, origin, obj) {
return replaceObject({ obj: obj }, function (item) {
if ((typeof item === 'undefined' ? 'undefined' : _typeof(item)) !== 'object' || item === null) {
return item;
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.METHOD)) {
return deserializeMethod(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.ERROR)) {
return deserializeError(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.PROMISE)) {
return deserializePromise(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.ZALGO_PROMISE)) {
return deserializeZalgoPromise(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.REGEX)) {
return deserializeRegex(source, origin, item);
}
return item;
}).obj;
return deserialize(message, (_deserialize = {}, _deserialize[CUSTOM_TYPE.CROSS_DOMAIN_ZALGO_PROMISE] = function (_ref5) {
var then = _ref5.then;
return deserializePromise(source, origin, { then: then });
}, _deserialize[CUSTOM_TYPE.CROSS_DOMAIN_FUNCTION] = function (_ref6) {
var id = _ref6.id,
name = _ref6.name;
return deserializeFunction(source, origin, { id: id, name: name });
}, _deserialize));
}
import { isPopup, isIframe, getUserAgent } from 'cross-domain-utils/src';
import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, WINDOW_TYPE } from '../conf';
export function getWindowType() {
if (isPopup()) {
return CONSTANTS.WINDOW_TYPES.POPUP;
return WINDOW_TYPE.POPUP;
}
if (isIframe()) {
return CONSTANTS.WINDOW_TYPES.IFRAME;
return WINDOW_TYPE.IFRAME;
}
return CONSTANTS.WINDOW_TYPES.FULLPAGE;
return WINDOW_TYPE.FULLPAGE;
}

@@ -14,0 +14,0 @@

@@ -7,3 +7,3 @@ export { _send as send };

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, MESSAGE_TYPE, WILDCARD } from '../conf';
import { sendMessage, addResponseListener, deleteResponseListener, markResponseListenerErrored } from '../drivers';

@@ -69,3 +69,3 @@ import { onChildWindowReady, sayHello, isWindowKnown } from '../lib';

domain = options.domain || CONSTANTS.WILDCARD;
domain = options.domain || WILDCARD;

@@ -143,9 +143,9 @@ var hash = options.name + '_' + uniqueID();

sendMessage(win, {
type: CONSTANTS.POST_MESSAGE_TYPE.REQUEST,
sendMessage(win, actualDomain, {
type: MESSAGE_TYPE.REQUEST,
hash: hash,
name: name,
data: options.data,
fireAndForget: options.fireAndForget
}, actualDomain)['catch'](reject);
fireAndForget: Boolean(options.fireAndForget)
})['catch'](reject);

@@ -152,0 +152,0 @@ if (options.fireAndForget) {

@@ -1,9 +0,9 @@

import { CONSTANTS } from '../conf';
import { WINDOW_PROP } from '../conf';
import { messageListener } from '../drivers';
export { CONFIG, CONSTANTS } from '../conf';
export { CONFIG } from '../conf';
export function disable() {
delete window[CONSTANTS.WINDOW_PROPS.POSTROBOT];
delete window[WINDOW_PROP.POSTROBOT];
window.removeEventListener('message', messageListener);
}

@@ -10,3 +10,3 @@ export { _on as on };

import { addRequestListener } from '../drivers';
import { CONSTANTS } from '../conf';
import { WILDCARD } from '../conf';
import { global } from '../global';

@@ -34,3 +34,3 @@

window: win,
domain: domain || CONSTANTS.WILDCARD,
domain: domain || WILDCARD,
name: name

@@ -37,0 +37,0 @@ };

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="",r(r.s=13)}([function(e,n,r){"use strict";var t=r(14);r.d(n,"getActualDomain",function(){return t.a}),r.d(n,"getAncestor",function(){return t.b}),r.d(n,"getDomain",function(){return t.c}),r.d(n,"getDomainFromUrl",function(){return t.d}),r.d(n,"getFrameByName",function(){return t.e}),r.d(n,"getOpener",function(){return t.f}),r.d(n,"getParent",function(){return t.g}),r.d(n,"getUserAgent",function(){return t.h}),r.d(n,"isActuallySameDomain",function(){return t.i}),r.d(n,"isAncestor",function(){return t.j}),r.d(n,"isIframe",function(){return t.k}),r.d(n,"isOpener",function(){return t.l}),r.d(n,"isPopup",function(){return t.m}),r.d(n,"isSameDomain",function(){return t.n}),r.d(n,"isSameTopWindow",function(){return t.o}),r.d(n,"isWindow",function(){return t.p}),r.d(n,"isWindowClosed",function(){return t.q}),r.d(n,"linkFrameWindow",function(){return t.r}),r.d(n,"matchDomain",function(){return t.s}),r.d(n,"stringifyDomainPattern",function(){return t.t});var o=r(15);r.n(o)},function(e,n,r){"use strict";var t,o={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",HELLO:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method",ERROR:"postrobot_error",PROMISE:"postrobot_promise",ZALGO_PROMISE:"postrobot_zalgo_promise",REGEX:"regex"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",BRIDGE:"postrobot_bridge",GLOBAL:"postrobot_global"},MOCK_PROTOCOL:"mock:",FILE_PROTOCOL:"file:",BRIDGE_NAME_PREFIX:"__postrobot_bridge__",POSTROBOT_PROXY:"__postrobot_proxy__",WILDCARD:"*"},i={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},a=Object.keys(i).map(function(e){return i[e]}),u={ALLOW_POSTMESSAGE_POPUP:!("__ALLOW_POSTMESSAGE_POPUP__"in window)||window.__ALLOW_POSTMESSAGE_POPUP__,BRIDGE_TIMEOUT:5e3,CHILD_WINDOW_TIMEOUT:5e3,ACK_TIMEOUT:2e3,ACK_TIMEOUT_KNOWN:1e4,RES_TIMEOUT:-1,ALLOWED_POST_MESSAGE_METHODS:(t={},t[o.SEND_STRATEGIES.POST_MESSAGE]=!0,t[o.SEND_STRATEGIES.BRIDGE]=!0,t[o.SEND_STRATEGIES.GLOBAL]=!0,t)};0===window.location.href.indexOf(o.FILE_PROTOCOL)&&(u.ALLOW_POSTMESSAGE_POPUP=!0),r.d(n,"a",function(){return u}),r.d(n,"b",function(){return o}),r.d(n,!1,function(){return i}),r.d(n,!1,function(){return a})},function(e,n,r){"use strict";function t(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&e instanceof window.constructor)return!1;var n={}.toString;if(n){var r=n.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}function o(){var e=void 0;if("undefined"!=typeof window)e=window;else{if("undefined"==typeof window)throw new TypeError("Can not find global");e=window}var n=e.__zalgopromise__=e.__zalgopromise__||{};return n.flushPromises=n.flushPromises||[],n.activeCount=n.activeCount||0,n.possiblyUnhandledPromiseHandlers=n.possiblyUnhandledPromiseHandlers||[],n.dispatchedErrors=n.dispatchedErrors||[],n}var i=function(){function e(n){var r=this;if(function(n,r){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var t=void 0,o=void 0,i=!1,a=!1,u=!1;try{n(function(e){u?r.resolve(e):(i=!0,t=e)},function(e){u?r.reject(e):(a=!0,o=e)})}catch(e){return void this.reject(e)}u=!0,i?this.resolve(t):a&&this.reject(o)}}return e.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(t(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},e.prototype.reject=function(e){var n=this;if(this.resolved||this.rejected)return this;if(t(e))throw new Error("Can not reject promise with another promise");if(!e){var r=e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);e=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){n.errorHandled||function(e,n){if(-1===o().dispatchedErrors.indexOf(e)){o().dispatchedErrors.push(e),setTimeout(function(){throw e},1);for(var r=0;r<o().possiblyUnhandledPromiseHandlers.length;r++)o().possiblyUnhandledPromiseHandlers[r](e,n)}}(e,n)},1),this.dispatch(),this},e.prototype.asyncReject=function(e){this.errorHandled=!0,this.reject(e)},e.prototype.dispatch=function(){var n=this,r=this.dispatching,i=this.resolved,a=this.rejected,u=this.handlers;if(!r&&(i||a)){this.dispatching=!0,o().activeCount+=1;for(var c=function(r){var o=u[r],c=o.onSuccess,s=o.onError,d=o.promise,f=void 0;if(i)try{f=c?c(n.value):n.value}catch(e){return d.reject(e),"continue"}else if(a){if(!s)return d.reject(n.error),"continue";try{f=s(n.error)}catch(e){return d.reject(e),"continue"}}f instanceof e&&(f.resolved||f.rejected)?(f.resolved?d.resolve(f.value):d.reject(f.error),f.errorHandled=!0):t(f)?f instanceof e&&(f.resolved||f.rejected)?f.resolved?d.resolve(f.value):d.reject(f.error):f.then(function(e){d.resolve(e)},function(e){d.reject(e)}):d.resolve(f)},s=0;s<u.length;s++)c(s);u.length=0,this.dispatching=!1,o().activeCount-=1,0===o().activeCount&&e.flushQueue()}},e.prototype.then=function(n,r){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new e;return this.handlers.push({promise:t,onSuccess:n,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.finally=function(n){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return e.try(n).then(function(){return r})},function(r){return e.try(n).then(function(){throw r})})},e.prototype.timeout=function(e,n){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout(function(){r.resolved||r.rejected||r.reject(n||new Error("Promise timed out after "+e+"ms"))},e);return this.then(function(e){return clearTimeout(t),e})},e.prototype.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.resolve=function(n){return n instanceof e?n:t(n)?new e(function(e,r){return n.then(e,r)}):(new e).resolve(n)},e.reject=function(n){return(new e).reject(n)},e.all=function(n){var r=new e,o=n.length,i=[];if(!o)return r.resolve(i),r;for(var a=function(a){var u=n[a];if(u instanceof e){if(u.resolved)return i[a]=u.value,o-=1,"continue"}else if(!t(u))return i[a]=u,o-=1,"continue";e.resolve(u).then(function(e){i[a]=e,0==(o-=1)&&r.resolve(i)},function(e){r.reject(e)})},u=0;u<n.length;u++)a(u);return 0===o&&r.resolve(i),r},e.hash=function(n){var r={};return e.all(Object.keys(n).map(function(t){return e.resolve(n[t]).then(function(e){r[t]=e})})).then(function(){return r})},e.map=function(n,r){return e.all(n.map(r))},e.onPossiblyUnhandledException=function(e){return function(e){return o().possiblyUnhandledPromiseHandlers.push(e),{cancel:function(){o().possiblyUnhandledPromiseHandlers.splice(o().possiblyUnhandledPromiseHandlers.indexOf(e),1)}}}(e)},e.try=function(n,r,t){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.try expected a function");var o=void 0;try{o=n.apply(r,t||[])}catch(n){return e.reject(n)}return e.resolve(o)},e.delay=function(n){return new e(function(e){setTimeout(e,n)})},e.isPromise=function(n){return!!(n&&n instanceof e)||t(n)},e.flush=function(){var n=new e;return o().flushPromises.push(n),0===o().activeCount&&e.flushQueue(),n},e.flushQueue=function(){var e=o().flushPromises;o().flushPromises=[];for(var n=0,r=null==e?0:e.length;n<r;n++)e[n].resolve()},e}();r.d(n,"a",function(){return i})},function(e,n,r){"use strict";r.d(n,"a",function(){return o});var t=r(1),o=window[t.b.WINDOW_PROPS.POSTROBOT]=window[t.b.WINDOW_PROPS.POSTROBOT]||{};o.registerSelf=function(){}},function(e,n,r){"use strict";r(9);var t=r(10);r.d(n,"addEventListener",function(){return t.a}),r(16),r(17),r(11);var o=r(7);r.d(n,"isRegex",function(){return o.f}),r.d(n,"noop",function(){return o.h}),r.d(n,"once",function(){return o.i}),r.d(n,"replaceObject",function(){return o.k}),r.d(n,"safeInterval",function(){return o.l}),r.d(n,"stringifyError",function(){return o.n}),r.d(n,"uniqueID",function(){return o.o}),r.d(n,"weakMapMemoize",function(){return o.p}),r(18);var i=r(19);r.n(i),r(20),r(21)},function(e,n,r){"use strict";r.d({},"WeakMap",function(){return u});var t=r(0);function o(e,n){for(var r=0;r<e.length;r++)try{if(e[r]===n)return r}catch(e){}return-1}var i=Object.defineProperty,a=Date.now()%1e9,u=function(){function e(){if(function(n,r){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),a+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+a,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,n={};return Object.freeze(n),e.set(n,"__testvalue__"),"__testvalue__"===e.get(n)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}return e.prototype._cleanupClosedWindows=function(){for(var e=this.weakmap,n=this.keys,r=0;r<n.length;r++){var o=n[r];if(Object(t.isWindow)(o)&&Object(t.isWindowClosed)(o)){if(e)try{e.delete(o)}catch(e){}n.splice(r,1),this.values.splice(r,1),r-=1}}},e.prototype.isSafeToReadWrite=function(e){if(Object(t.isWindow)(e))return!1;try{e&&e.self,e&&e[this.name]}catch(e){return!1}return!0},e.prototype.set=function(e,n){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(e,n)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var t=this.name,a=e[t];a&&a[0]===e?a[1]=n:i(e,t,{value:[e,n],writable:!0})}else{this._cleanupClosedWindows();var u=this.keys,c=this.values,s=o(u,e);-1===s?(u.push(e),c.push(n)):c[s]=n}},e.prototype.get=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{if(n.has(e))return n.get(e)}catch(e){delete this.weakmap}if(!this.isSafeToReadWrite(e)){this._cleanupClosedWindows();var r=o(this.keys,e);if(-1===r)return;return this.values[r]}var t=e[this.name];if(t&&t[0]===e)return t[1]},e.prototype.delete=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];r&&r[0]===e&&(r[0]=r[1]=void 0)}else{this._cleanupClosedWindows();var t=this.keys,i=o(t,e);-1!==i&&(t.splice(i,1),this.values.splice(i,1))}},e.prototype.has=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{return n.has(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];return!(!r||r[0]!==e)}return this._cleanupClosedWindows(),-1!==o(this.keys,e)},e.prototype.getOrSet=function(e,n){if(this.has(e))return this.get(e);var r=n();return this.set(e,r),r},e}();r.d(n,"a",function(){return u})},function(e,n,r){"use strict";var t=r(0),o=r(1);function i(){return Object(t.isPopup)()?o.b.WINDOW_TYPES.POPUP:Object(t.isIframe)()?o.b.WINDOW_TYPES.IFRAME:o.b.WINDOW_TYPES.FULLPAGE}function a(){return!!Object(t.getUserAgent)(window).match(/MSIE|trident|edge\/12|edge\/13/i)||!o.a.ALLOW_POSTMESSAGE_POPUP}var u=r(5),c=r(2),s=r(4),d=r(3),f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};d.a.methods=d.a.methods||new u.a;var w=Object(s.once)(function(){d.a.on(o.b.POST_MESSAGE_NAMES.METHOD,{origin:o.b.WILDCARD},function(e){var n=e.source,r=e.origin,o=e.data,i=d.a.methods.get(n);if(!i)throw new Error("Could not find any methods this window has privileges to call");var a=i[o.id];if(!a)throw new Error("Could not find method with id: "+o.id);if(!Object(t.matchDomain)(a.domain,r))throw new Error("Method domain "+a.domain+" does not match origin "+r);return c.a.try(function(){return a.method.apply({source:n,origin:r,data:o},o.args)}).then(function(e){return{result:e,id:o.id,name:o.name}})})});function l(e,n){return"object"===(void 0===e?"undefined":f(e))&&null!==e&&e.__type__===n}function p(e,n,r,t){var i=Object(s.uniqueID)(),a=d.a.methods.get(e);return a||(a={},d.a.methods.set(e,a)),a[i]={domain:n,method:r},{__type__:o.b.SERIALIZATION_TYPES.METHOD,__id__:i,__name__:t}}function m(e,n,r){return Object(s.replaceObject)({obj:r},function(r,t){return"function"==typeof r?p(e,n,r,t.toString()):r instanceof Error?(i=r,{__type__:o.b.SERIALIZATION_TYPES.ERROR,__message__:Object(s.stringifyError)(i),__code__:i.code}):window.Promise&&r instanceof window.Promise?function(e,n,r,t){return{__type__:o.b.SERIALIZATION_TYPES.PROMISE,__then__:p(e,n,function(e,n){return r.then(e,n)},t+".then")}}(e,n,r,t.toString()):c.a.isPromise(r)?function(e,n,r,t){return{__type__:o.b.SERIALIZATION_TYPES.ZALGO_PROMISE,__then__:p(e,n,function(e,n){return r.then(e,n)},t+".then")}}(e,n,r,t.toString()):Object(s.isRegex)(r)?(a=r,{__type__:o.b.SERIALIZATION_TYPES.REGEX,__source__:a.source}):r;var i,a}).obj}function h(e,n,r){function t(){var t=Array.prototype.slice.call(arguments);return d.a.send(e,o.b.POST_MESSAGE_NAMES.METHOD,{id:r.__id__,name:r.__name__,args:t},{domain:n,timeout:-1}).then(function(e){return e.data.result},function(e){throw e})}return t.__name__=r.__name__,t.__xdomain__=!0,t.source=e,t.origin=n,t}function O(e,n,r){var t=new Error(r.__message__);return r.__code__&&(t.code=r.__code__),t}function g(e,n,r){return new c.a(function(t,o){return h(e,n,r.__then__)(t,o)})}function v(e,n,r){return window.Promise?new window.Promise(function(t,o){return h(e,n,r.__then__)(t,o)}):g(e,n,r)}function y(e,n,r){return new RegExp(r.__source__)}function b(e,n,r){return Object(s.replaceObject)({obj:r},function(r){return"object"!==(void 0===r?"undefined":f(r))||null===r?r:l(r,o.b.SERIALIZATION_TYPES.METHOD)?h(e,n,r):l(r,o.b.SERIALIZATION_TYPES.ERROR)?O(0,0,r):l(r,o.b.SERIALIZATION_TYPES.PROMISE)?v(e,n,r):l(r,o.b.SERIALIZATION_TYPES.ZALGO_PROMISE)?g(e,n,r):l(r,o.b.SERIALIZATION_TYPES.REGEX)?y(0,0,r):r}).obj}function _(e){d.a.on(o.b.POST_MESSAGE_NAMES.HELLO,{domain:o.b.WILDCARD},function(n){var r=n.source,t=n.origin;return e({source:r,origin:t})})}function E(e){return d.a.send(e,o.b.POST_MESSAGE_NAMES.HELLO,{},{domain:o.b.WILDCARD,timeout:-1}).then(function(e){return{origin:e.origin}})}function S(e){d.a.knownWindows.set(e,!0)}function P(e){return d.a.knownWindows.get(e)}function T(){_(function(e){var n=e.source,r=e.origin,t=d.a.readyPromises.get(n)||new c.a;t.resolve({origin:r}),d.a.readyPromises.set(n,t)});var e=Object(t.getAncestor)();e&&E(e).catch(s.noop)}function j(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Window",t=d.a.readyPromises.get(e);return t||(t=new c.a,d.a.readyPromises.set(e,t),-1!==n&&setTimeout(function(){return t.reject(new Error(r+" did not load after "+n+"ms"))},n),t)}d.a.readyPromises=d.a.readyPromises||new u.a,d.a.knownWindows=d.a.knownWindows||new u.a,r.d(n,"b",function(){return i}),r.d(n,"g",function(){return a}),r.d(n,"e",function(){return w}),r.d(n,!1,function(){return p}),r.d(n,"j",function(){return m}),r.d(n,!1,function(){return h}),r.d(n,!1,function(){return O}),r.d(n,!1,function(){return g}),r.d(n,!1,function(){return v}),r.d(n,!1,function(){return y}),r.d(n,"a",function(){return b}),r.d(n,!1,function(){return _}),r.d(n,"i",function(){return E}),r.d(n,"f",function(){return S}),r.d(n,"d",function(){return P}),r.d(n,"c",function(){return T}),r.d(n,"h",function(){return j})},function(e,n,r){"use strict";n.o=a,n.d=function(){if("undefined"!=typeof window)return window;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("No global found")},n.g=function(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=new o.a;function i(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];var u=t.getOrSet(r.thisNamespace?this:e,function(){return{}}),s=c(o),d=r.time;if(u[s]&&d&&Date.now()-u[s].time<d&&delete u[s],u[s])return u[s].value;i.__calling__=!0;var f=Date.now(),w=e.apply(this,arguments);return i.__calling__=!1,u[s]={time:f,value:w},u[s].value}return i.reset=function(){t.delete(r.thisNamespace?n:e)},r.name&&(i.displayName=r.name+":memoized"),i},n.j=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};function r(){return t.a.try(e,this,arguments)}return n.name&&(r.displayName=n.name+":promisified"),r},n.e=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],t=e.__inline_memoize_cache__=e.__inline_memoize_cache__||{},o=c(r);return t.hasOwnProperty(o)?t[o]:t[o]=n.apply(void 0,r)},n.h=function(){},n.i=function(e){var n=!1;return function(){if(!n)return n=!0,e.apply(this,arguments)}},n.n=function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+Object.prototype.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,o=n&&n.message;if(t&&o)return-1!==t.indexOf(o)?t:o+"\n"+t;if(t)return t;if(o)return o}return"function"==typeof n.toString?n.toString():Object.prototype.toString.call(n)}catch(n){return"Error while stringifying error: "+e(n,r+1)}},n.m=function(e){return"string"==typeof e?e:e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)},n.c=function(e,n){if(!n)return e;if(Object.assign)return Object.assign(e,n);for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r]);return e},n.l=function(e,n){var r=void 0;return function t(){r=setTimeout(function(){e(),t()},n)}(),{cancel:function(){clearTimeout(r)}}},n.a=function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},n.k=function e(n,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(Array.isArray(n)){for(var o=n.length,i=[],a=function(o){s(i,o,function(){var i=t?t+"."+o:""+o,a=n[o],u=r(a,o,i);return(f(u)||Array.isArray(u))&&(u=e(u,r,i)),u})},u=0;u<o;u++)a(u);return i}if(f(n)){var c={},d=function(o){if(!n.hasOwnProperty(o))return"continue";s(c,o,function(){var i=t?t+"."+o:""+o,a=n[o],u=r(a,o,i);return(f(u)||Array.isArray(u))&&(u=e(u,r,i)),u})};for(var w in n)d(w);return c}throw new Error("Pass an object or array")},n.b=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=void 0;return function(){var t=this,o=arguments;clearTimeout(r),r=setTimeout(function(){return e.apply(t,o)},n)}},n.f=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},r.d(n,"p",function(){return w});var t=r(2),o=r(5),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function a(){var e,n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+(e=(new Date).toISOString().slice(11,19).replace("T","."),window.btoa(e)).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var u=void 0;function c(e){try{return JSON.stringify(Array.prototype.slice.call(e),function(e,n){return"function"==typeof n?"memoize["+function(e){if(u=u||new o.a,null===e||void 0===e||"object"!==(void 0===e?"undefined":i(e))&&"function"!=typeof e)throw new Error("Invalid object");var n=u.get(e);return n||(n=(void 0===e?"undefined":i(e))+":"+a(),u.set(e,n)),n}(n)+"]":n})}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function s(e,n,r){if(Array.isArray(e)){if("number"!=typeof n)throw new TypeError("Array key must be number")}else if("object"===(void 0===e?"undefined":i(e))&&null!==e&&"string"!=typeof n)throw new TypeError("Object key must be string");Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get:function(){delete e[n];var t=r();return e[n]=t,t},set:function(r){delete e[n],e[n]=r}})}function d(e){return"object"===(void 0===(n=e)?"undefined":i(n))&&null!==n&&"[object Object]"===Object.prototype.toString.call(e);var n}function f(e){if(!d(e))return!1;var n=e.constructor;if("function"!=typeof n)return!1;var r=n.prototype;return!!d(r)&&!!r.hasOwnProperty("isPrototypeOf")}var w=function(e){var n=new o.a;return function(r){var t=n.get(r);return void 0!==t?t:(void 0!==(t=e.call(this,r))&&n.set(r,t),t)}}},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(2),o=r(0),i=r(4),a=r(1),u=r(3);function c(e){try{u.a.tunnelWindows[e]&&delete u.a.tunnelWindows[e].source}catch(e){}delete u.a.tunnelWindows[e]}u.a.tunnelWindows=u.a.tunnelWindows||{},u.a.tunnelWindowId=0,u.a.openTunnelToParent=function(e){var n=e.name,r=e.source,t=e.canary,s=e.sendMessage,d=Object(o.getParent)(window);if(!d)throw new Error("No parent window found to open tunnel to");var f=function(e){var n=e.name,r=e.source,t=e.canary,a=e.sendMessage;return function(){for(var e=u.a.tunnelWindows,n=0,r=Object.keys(e),t=null==r?0:r.length;n<t;n++){var a=r[n],s=e[a];try{Object(i.noop)(s.source)}catch(e){c(a);continue}Object(o.isWindowClosed)(s.source)&&c(a)}}(),u.a.tunnelWindowId+=1,u.a.tunnelWindows[u.a.tunnelWindowId]={name:n,source:r,canary:t,sendMessage:a},u.a.tunnelWindowId}({name:n,source:r,canary:t,sendMessage:s});return u.a.send(d,a.b.POST_MESSAGE_NAMES.OPEN_TUNNEL,{name:n,sendMessage:function(){var e=function(e){return u.a.tunnelWindows[e]}(f);try{Object(i.noop)(e&&e.source)}catch(e){return void c(f)}if(e&&e.source&&!Object(o.isWindowClosed)(e.source)){try{e.canary()}catch(e){return}e.sendMessage.apply(this,arguments)}}},{domain:a.b.WILDCARD})};var s=r(5);function d(){return!!Object(o.getUserAgent)(window).match(/MSIE|trident|edge\/12|edge\/13/i)||!a.a.ALLOW_POSTMESSAGE_POPUP}function f(e){return!Object(o.isSameTopWindow)(window,e)}function w(e,n){if(e){if(Object(o.getDomain)()!==Object(o.getDomainFromUrl)(e))return!0}else if(n&&!Object(o.isSameDomain)(n))return!0;return!1}function l(e){var n=e.win,r=e.domain;return!(!d()||r&&!w(r,n)||n&&!f(n))}function p(e){var n=(e=e||Object(o.getDomainFromUrl)(e)).replace(/[^a-zA-Z0-9]+/g,"_");return a.b.BRIDGE_NAME_PREFIX+"_"+n}function m(){return Boolean(window.name&&window.name===p(Object(o.getDomain)()))}var h=new t.a(function(e){if(window.document&&window.document.body)return e(window.document.body);var n=setInterval(function(){if(window.document&&window.document.body)return clearInterval(n),e(window.document.body)},10)});function O(e){u.a.remoteWindows.set(e,{sendMessagePromise:new t.a})}function g(e){return u.a.remoteWindows.get(e)}function v(e,n,r){var i=g(e);if(!i)throw new Error("Window not found to register sendMessage to");var a=function(t,i,a){if(t!==e)throw new Error("Remote window does not match window");if(!Object(o.matchDomain)(a,n))throw new Error("Remote domain "+a+" does not match domain "+n);r(i)};i.sendMessagePromise.resolve(a),i.sendMessagePromise=t.a.resolve(a)}function y(e,n){var r=g(e);if(!r)throw new Error("Window not found on which to reject sendMessage");r.sendMessagePromise.asyncReject(n)}function b(e,n,r){var t=Object(o.isOpener)(window,e),i=Object(o.isOpener)(e,window);if(!t&&!i)throw new Error("Can only send messages to and from parent and popup windows");var a=g(e);if(!a)throw new Error("Window not found to send message to");return a.sendMessagePromise.then(function(t){return t(e,n,r)})}u.a.remoteWindows=u.a.remoteWindows||new s.a;var _=Object(i.weakMapMemoize)(function(e){return t.a.try(function(){try{var n=Object(o.getFrameByName)(e,p(Object(o.getDomain)()));if(!n)return;return Object(o.isSameDomain)(n)&&n[a.b.WINDOW_PROPS.POSTROBOT]?n:new t.a(function(e){var r=void 0,t=void 0;r=setInterval(function(){if(n&&Object(o.isSameDomain)(n)&&n[a.b.WINDOW_PROPS.POSTROBOT])return clearInterval(r),clearTimeout(t),e(n)},100),t=setTimeout(function(){return clearInterval(r),e()},2e3)})}catch(e){}})});function E(){return t.a.try(function(){var e=Object(o.getOpener)(window);if(e&&l({win:e}))return O(e),_(e).then(function(n){return n?window.name?n[a.b.WINDOW_PROPS.POSTROBOT].openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(e){try{Object(i.noop)(window)}catch(e){return}if(window&&!window.closed)try{u.a.receiveMessage({data:e,origin:this.origin,source:this.source})}catch(e){t.a.reject(e)}}}).then(function(n){var r=n.source,t=n.origin,o=n.data;if(r!==e)throw new Error("Source does not match opener");v(r,t,o.sendMessage)}).catch(function(n){throw y(e,n),n}):y(e,new Error("Can not register with opener: window does not have a name")):y(e,new Error("Can not register with opener: no bridge found in opener"))})})}var S=r(6);function P(e,n){return n=n||Object(o.getDomainFromUrl)(e),Boolean(u.a.bridges[n])}function T(e,n){return n=n||Object(o.getDomainFromUrl)(e),u.a.bridges[n]?u.a.bridges[n]:(u.a.bridges[n]=t.a.try(function(){if(Object(o.getDomain)()===n)throw new Error("Can not open bridge on the same domain as current domain: "+n);var r=p(n);if(Object(o.getFrameByName)(window,r))throw new Error("Frame with name "+r+" already exists on page");var i=function(e,n){var r=document.createElement("iframe");return r.setAttribute("name",e),r.setAttribute("id",e),r.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=n,r}(r,e);return u.a.bridgeFrames[n]=i,h.then(function(r){r.appendChild(i);var o=i.contentWindow;return function(e,n){u.a.on(a.b.POST_MESSAGE_NAMES.OPEN_TUNNEL,{window:e,domain:n},function(e){var r=e.origin,o=e.data;if(r!==n)throw new Error("Domain "+n+" does not match origin "+r);if(!o.name)throw new Error("Register window expected to be passed window name");if(!o.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!u.a.popupWindowsByName[o.name])throw new Error("Window with name "+o.name+" does not exist, or was not opened by this window");if(!u.a.popupWindowsByName[o.name].domain)throw new Error("We do not have a registered domain for window "+o.name);if(u.a.popupWindowsByName[o.name].domain!==r)throw new Error("Message origin "+r+" does not matched registered window origin "+u.a.popupWindowsByName[o.name].domain);return v(u.a.popupWindowsByName[o.name].win,n,o.sendMessage),{sendMessage:function(e){if(window&&!window.closed){var n=u.a.popupWindowsByName[o.name];if(n)try{u.a.receiveMessage({data:e,origin:n.domain,source:n.win})}catch(e){t.a.reject(e)}}}}})}(o,n),new t.a(function(e,n){i.onload=e,i.onerror=n}).then(function(){return Object(S.h)(o,a.a.BRIDGE_TIMEOUT,"Bridge "+e)}).then(function(){return o})})}),u.a.bridges[n])}u.a.bridges=u.a.bridges||{},u.a.bridgeFrames=u.a.bridgeFrames||{},u.a.popupWindowsByWin=u.a.popupWindowsByWin||new s.a,u.a.popupWindowsByName=u.a.popupWindowsByName||{};var j=window.open;function W(e,n){var r=u.a.popupWindowsByWin.get(e);r&&(r.domain=Object(o.getDomainFromUrl)(n),O(e))}function A(){for(var e=0,n=Object.keys(u.a.bridgeFrames),r=null==n?0:n.length;e<r;e++){var t=n[e],o=u.a.bridgeFrames[t];o.parentNode&&o.parentNode.removeChild(o)}u.a.bridgeFrames={},u.a.bridges={}}window.open=function(e,n,r,t){var i=e;if(e&&0===e.indexOf(a.b.MOCK_PROTOCOL)){var c=e.split("|");i=c[0],e=c[1]}i&&(i=Object(o.getDomainFromUrl)(i));var s=j.call(this,e,n,r,t);if(!s)return s;e&&O(s);for(var d=0,f=Object.keys(u.a.popupWindowsByName),w=null==f?0:f.length;d<w;d++){var l=f[d];Object(o.isWindowClosed)(u.a.popupWindowsByName[l].win)&&delete u.a.popupWindowsByName[l]}if(n&&s){var p=u.a.popupWindowsByWin.get(s)||u.a.popupWindowsByName[n]||{};p.name=p.name||n,p.win=p.win||s,p.domain=p.domain||i,u.a.popupWindowsByWin.set(s,p),u.a.popupWindowsByName[n]=p}return s},r.d(n,"openTunnelToOpener",function(){return E}),r.d(n,"needsBridgeForBrowser",function(){return d}),r.d(n,"needsBridgeForWin",function(){return f}),r.d(n,"needsBridgeForDomain",function(){return w}),r.d(n,"needsBridge",function(){return l}),r.d(n,"getBridgeName",function(){return p}),r.d(n,"isBridge",function(){return m}),r.d(n,"documentBodyReady",function(){return h}),r.d(n,"registerRemoteWindow",function(){return O}),r.d(n,"findRemoteWindow",function(){return g}),r.d(n,"registerRemoteSendMessage",function(){return v}),r.d(n,"rejectRemoteSendMessage",function(){return y}),r.d(n,"sendBridgeMessage",function(){return b}),r.d(n,"hasBridge",function(){return P}),r.d(n,"openBridge",function(){return T}),r.d(n,"linkUrl",function(){return W}),r.d(n,"destroyBridges",function(){return A})},function(e,n,r){"use strict";n.a=function(){return!!(window.navigator.mockUserAgent||window.navigator.userAgent).match(/Android|webOS|iPhone|iPad|iPod|bada|Symbian|Palm|CriOS|BlackBerry|IEMobile|WindowsMobile|Opera Mini/i)}},function(e,n,r){"use strict";r(2),r(0),r(5);var t=r(7);r(9),n.b=function e(){return Object(t.e)(e,function(){try{if("undefined"==typeof window)return!1;if(window.localStorage){var e=Math.random().toString();window.localStorage.setItem("__test__localStorage__",e);var n=window.localStorage.getItem("__test__localStorage__");if(window.localStorage.removeItem("__test__localStorage__"),e===n)return!0}}catch(e){}return!1})},n.a=function(e,n,r){return e.addEventListener(n,r),{cancel:function(){e.removeEventListener(n,r)}}},"function"==typeof Symbol&&Symbol.iterator,Object.assign,Object.create(Error.prototype)},function(e,n,r){"use strict";n.a=function e(n){var r=n.name,i=n.version,a=void 0===i?"latest":i,u=n.lifetime,c=void 0===u?3e5:u;return Object(t.e)(e,function(){var e="__"+r+"_"+a+"_storage__",n=void 0;function i(r){var i=Object(o.b)(),a=void 0;if(n&&(a=n),!a&&i){var u=window.localStorage.getItem(e);u&&(a=JSON.parse(u))}a||(a=Object(t.d)()[e]),a||(a={id:Object(t.o)()}),a.id||(a.id=Object(t.o)()),n=a;var c=r(a);return i?window.localStorage.setItem(e,JSON.stringify(a)):Object(t.d)()[e]=a,n=null,c}function u(e){return i(function(n){var r=n.__session__,o=Date.now();return r&&o-r.created>c&&(r=null),r||(r={guid:Object(t.o)(),created:o}),n.__session__=r,e(r)})}return{getState:i,getID:function(){return i(function(e){return e.id})},getSessionState:function(e){return u(function(n){return n.state=n.state||{},e(n.state)})},getSessionID:function(){return u(function(e){return e.guid})}}},[{name:r,version:a,lifetime:c}])};var t=r(7),o=r(10)},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(0),o=r(1);function i(e,n){if(!o.a.ALLOW_POSTMESSAGE_POPUP&&!1===Object(t.isSameTopWindow)(e,n))throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}r.d(n,"emulateIERestrictions",function(){return i})},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t={};r.d(t,"markWindowKnown",function(){return o.f}),r.d(t,"cleanUpWindow",function(){return U}),r.d(t,"Promise",function(){return s.a}),r.d(t,"bridge",function(){return G}),r.d(t,"init",function(){return F}),r.d(t,"parent",function(){return k}),r.d(t,"send",function(){return R}),r.d(t,"request",function(){return A}),r.d(t,"sendToParent",function(){return D}),r.d(t,"client",function(){return I}),r.d(t,"on",function(){return C}),r.d(t,"listen",function(){return L}),r.d(t,"once",function(){return N}),r.d(t,"listener",function(){return B}),r.d(t,"CONFIG",function(){return u.a}),r.d(t,"CONSTANTS",function(){return u.b}),r.d(t,"disable",function(){return x});var o=r(6),i=r(0),a=r(4),u=r(1),c=r(3),s=r(2),d={};d[u.b.SEND_STRATEGIES.POST_MESSAGE]=function(e,n,t){try{r(12).emulateIERestrictions(window,e)}catch(e){return}(Array.isArray(t)?t:"string"==typeof t?[t]:[u.b.WILDCARD]).map(function(n){if(0===n.indexOf(u.b.MOCK_PROTOCOL)){if(window.location.protocol===u.b.FILE_PROTOCOL)return u.b.WILDCARD;if(!Object(i.isActuallySameDomain)(e))throw new Error("Attempting to send messsage to mock domain "+n+", but window is actually cross-domain");return Object(i.getActualDomain)(e)}return 0===n.indexOf(u.b.FILE_PROTOCOL)?u.b.WILDCARD:n}).forEach(function(r){return e.postMessage(n,r)})};var f=r(8),w=f.sendBridgeMessage,l=f.needsBridgeForBrowser,p=f.isBridge;d[u.b.SEND_STRATEGIES.BRIDGE]=function(e,n,r){if(l()||p()){if(Object(i.isSameDomain)(e))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==Object(i.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");return w(e,n,r)}},d[u.b.SEND_STRATEGIES.GLOBAL]=function(e,n){if(Object(o.g)()){if(!Object(i.isSameDomain)(e))throw new Error("Post message through global disabled between different domain windows");if(!1!==Object(i.isSameTopWindow)(window,e))throw new Error("Can only use global to communicate between two different windows, not between frames");var r=e[u.b.WINDOW_PROPS.POSTROBOT];if(!r)throw new Error("Can not find postRobot global on foreign window");return r.receiveMessage({source:window,origin:Object(i.getDomain)(),data:n})}};var m=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};function h(e,n,r){return s.a.try(function(){var t;if(n=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=Object(a.uniqueID)(),u=Object(o.b)(),c=Object(i.getDomain)(window);return m({},n,r,{sourceDomain:c,id:n.id||t,windowType:u})}(e,n,{data:Object(o.j)(e,r,n.data),domain:r}),Object(i.isWindowClosed)(e))throw new Error("Window is closed");var c=[],f=JSON.stringify(((t={})[u.b.WINDOW_PROPS.POSTROBOT]=n,t),null,2);return s.a.map(Object.keys(d),function(n){return s.a.try(function(){if(!u.a.ALLOWED_POST_MESSAGE_METHODS[n])throw new Error("Strategy disallowed: "+n);return d[n](e,f,r)}).then(function(){return c.push(n+": success"),!0},function(e){return c.push(n+": "+Object(a.stringifyError)(e)+"\n"),!1})}).then(function(e){var r=e.some(Boolean),t=n.type+" "+n.name+" "+(r?"success":"error")+":\n - "+c.join("\n - ")+"\n";if(!r)throw new Error(t)})})}var O=r(5);c.a.responseListeners=c.a.responseListeners||{},c.a.requestListeners=c.a.requestListeners||{},c.a.WINDOW_WILDCARD=c.a.WINDOW_WILDCARD||new function(){},c.a.erroredResponseListeners=c.a.erroredResponseListeners||{};var g,v="__domain_regex__";function y(e){return c.a.responseListeners[e]}function b(e){delete c.a.responseListeners[e]}function _(e){return Boolean(c.a.erroredResponseListeners[e])}function E(e){var n=e.name,r=e.win,t=e.domain;if(r===u.b.WILDCARD&&(r=null),t===u.b.WILDCARD&&(t=null),!n)throw new Error("Name required to get request listener");var o=c.a.requestListeners[n];if(o)for(var a=0,s=[r,c.a.WINDOW_WILDCARD],d=null==s?0:s.length;a<d;a++){var f=s[a],w=f&&o.get(f);if(w){if(t&&"string"==typeof t){if(w[t])return w[t];if(w[v])for(var l=0,p=w[v],m=null==p?0:p.length;l<m;l++){var h=p[l],O=h.regex,g=h.listener;if(Object(i.matchDomain)(O,t))return g}}if(w[u.b.WILDCARD])return w[u.b.WILDCARD]}}}var S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},P=((g={})[u.b.POST_MESSAGE_TYPE.ACK]=function(e,n,r){if(!_(r.hash)){var t=y(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Ack origin "+n+" does not match domain "+t.domain.toString());t.ack=!0}},g[u.b.POST_MESSAGE_TYPE.REQUEST]=function(e,n,r){var t=E({name:r.name,win:e,domain:n});function o(t){return r.fireAndForget||Object(i.isWindowClosed)(e)?s.a.resolve():h(e,S({target:r.originalSource,hash:r.hash,name:r.name},t),n)}return s.a.all([o({type:u.b.POST_MESSAGE_TYPE.ACK}),s.a.try(function(){if(!t)throw new Error("No handler found for post message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Request origin "+n+" does not match domain "+t.domain.toString());var o=r.data;return t.handler({source:e,origin:n,data:o})}).then(function(e){return o({type:u.b.POST_MESSAGE_TYPE.RESPONSE,ack:u.b.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){var n=Object(a.stringifyError)(e).replace(/^Error: /,""),r=e.code;return o({type:u.b.POST_MESSAGE_TYPE.RESPONSE,ack:u.b.POST_MESSAGE_ACK.ERROR,error:n,code:r})})]).then(a.noop).catch(function(e){if(t&&t.handleError)return t.handleError(e);throw e})},g[u.b.POST_MESSAGE_TYPE.RESPONSE]=function(e,n,r){if(!_(r.hash)){var t=y(r.hash);if(!t)throw new Error("No handler found for post message response for message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Response origin "+n+" does not match domain "+Object(i.stringifyDomainPattern)(t.domain));if(b(r.hash),r.ack===u.b.POST_MESSAGE_ACK.ERROR){var o=new Error(r.error);return r.code&&(o.code=r.code),t.respond(o,null)}if(r.ack===u.b.POST_MESSAGE_ACK.SUCCESS){var a=r.data||r.response;return t.respond(null,{source:e,origin:n,data:a})}}},g),T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function j(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(e){return}var n=e.source,r=e.origin,t=function(e){var n=void 0;try{n=JSON.parse(e)}catch(e){return}if(n&&"object"===(void 0===n?"undefined":T(n))&&null!==n&&(n=n[u.b.WINDOW_PROPS.POSTROBOT])&&"object"===(void 0===n?"undefined":T(n))&&null!==n&&n.type&&"string"==typeof n.type&&P[n.type])return n}(e.data);if(t){if(Object(o.f)(n),!t.sourceDomain||"string"!=typeof t.sourceDomain)throw new Error("Expected message to have sourceDomain");0!==t.sourceDomain.indexOf(u.b.MOCK_PROTOCOL)&&0!==t.sourceDomain.indexOf(u.b.FILE_PROTOCOL)||(r=t.sourceDomain),-1===c.a.receivedMessages.indexOf(t.id)&&(c.a.receivedMessages.push(t.id),Object(i.isWindowClosed)(n)&&!t.fireAndForget||(t.data&&(t.data=Object(o.a)(n,r,t.data)),P[t.type](n,r,t)))}}function W(e){try{Object(a.noop)(e.source)}catch(e){return}var n={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent&&e.originalEvent.origin,data:e.data};try{r(12).emulateIERestrictions(n.source,window)}catch(e){return}j(n)}function A(e){return s.a.try(function(){if(!e.name)throw new Error("Expected options.name");var n=e.name,r=void 0,t=void 0;if("string"==typeof e.window){var d=document.getElementById(e.window);if(!d)throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be a valid element id");if("iframe"!==d.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(!d.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");r=d.contentWindow}else if(e.window instanceof HTMLIFrameElement){if("iframe"!==e.window.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(e.window&&!e.window.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");e.window&&e.window.contentWindow&&(r=e.window.contentWindow)}else r=e.window;if(!r)throw new Error("Expected options.window to be a window object, iframe, or iframe element id.");var f=r;t=e.domain||u.b.WILDCARD;var w=e.name+"_"+Object(a.uniqueID)();if(Object(i.isWindowClosed)(f))throw new Error("Target window is closed");var l=!1,p=c.a.requestPromises.get(f);p||(p=[],c.a.requestPromises.set(f,p));var m=s.a.try(function(){if(Object(i.isAncestor)(window,f))return Object(o.h)(f,e.timeout||u.a.CHILD_WINDOW_TIMEOUT)}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(a.isRegex)(t)&&!e)return Object(o.i)(f)}).then(function(){var r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(a.isRegex)(t)){if(!Object(i.matchDomain)(t,r))throw new Error("Remote window domain "+r+" does not match regex: "+t.toString());t=r}if("string"!=typeof t&&!Array.isArray(t))throw new TypeError("Expected domain to be a string or array");var d=t;return new s.a(function(r,t){var a=void 0;if(e.fireAndForget||function(e,n){c.a.responseListeners[e]=n}(w,a={name:n,window:f,domain:d,respond:function(e,n){e||(l=!0,p.splice(p.indexOf(m,1))),e?t(e):r(n)}}),h(f,{type:u.b.POST_MESSAGE_TYPE.REQUEST,hash:w,name:n,data:e.data,fireAndForget:e.fireAndForget},d).catch(t),e.fireAndForget)return r();var s=Object(o.d)(f)?u.a.ACK_TIMEOUT_KNOWN:u.a.ACK_TIMEOUT,O=e.timeout||u.a.RES_TIMEOUT,g=s,v=O,y=100;setTimeout(function e(){if(!l){if(Object(i.isWindowClosed)(f))return a.ack?t(new Error("Window closed for "+n+" before response")):t(new Error("Window closed for "+n+" before ack"));if(g=Math.max(g-y,0),-1!==v&&(v=Math.max(v-y,0)),a.ack){if(-1===v)return;y=Math.min(v,2e3)}else{if(0===g)return t(new Error("No ack for postMessage "+n+" in "+Object(i.getDomain)()+" in "+s+"ms"));if(0===v)return t(new Error("No response for postMessage "+n+" in "+Object(i.getDomain)()+" in "+O+"ms"))}setTimeout(e,y)}},y)})});return m.catch(function(){!function(e){c.a.erroredResponseListeners[e]=!0}(w),b(w)}),p.push(m),m})}function R(e,n,r,t){return(t=t||{}).window=e,t.name=n,t.data=r,A(t)}function D(e,n,r){var t=Object(i.getAncestor)();return t?R(t,e,n,r):new s.a(function(e,n){return n(new Error("Window does not have a parent"))})}function I(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.window)throw new Error("Expected options.window");var n=e.window;return{send:function(r,t){return R(n,r,t,e)}}}c.a.receivedMessages=c.a.receivedMessages||[],c.a.receiveMessage=j,c.a.requestPromises=c.a.requestPromises||new O.a,c.a.send=R;var M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function L(e){if(!e.name)throw new Error("Expected options.name");if(!e.handler)throw new Error("Expected options.handler");var n=e.name,r=e.window,t=e.domain,o={handler:e.handler,handleError:e.errorHandler||function(e){throw e},window:r,domain:t||u.b.WILDCARD,name:n},s=function e(n,r){var t=n.name,o=n.win,i=n.domain;if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var s=[],d=0,f=o,w=null==f?0:f.length;d<w;d++){var l=f[d];s.push(e({name:t,domain:i,win:l},r))}return{cancel:function(){for(var e=0,n=null==s?0:s.length;e<n;e++)s[e].cancel()}}}if(Array.isArray(i)){for(var p=[],m=0,h=i,g=null==h?0:h.length;m<g;m++){var y=h[m];p.push(e({name:t,win:o,domain:y},r))}return{cancel:function(){for(var e=0,n=null==p?0:p.length;e<n;e++)p[e].cancel()}}}var b=E({name:t,win:o,domain:i});if(o&&o!==u.b.WILDCARD||(o=c.a.WINDOW_WILDCARD),i=i||u.b.WILDCARD,b)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===c.a.WINDOW_WILDCARD?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===c.a.WINDOW_WILDCARD?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var _=c.a.requestListeners,S=_[t];S||(S=new O.a,_[t]=S);var P=S.get(o);P||(P={},S.set(o,P));var T=i.toString(),j=P[v],W=void 0;return Object(a.isRegex)(i)?(j||(j=[],P[v]=j),W={regex:i,listener:r},j.push(W)):P[T]=r,{cancel:function(){P&&(delete P[T],o&&0===Object.keys(P).length&&S.delete(o),W&&j.splice(j.indexOf(W,1)))}}}({name:n,win:r,domain:t},o);if(e.once){var d=o.handler;o.handler=Object(a.once)(function(){return s.cancel(),d.apply(this,arguments)})}if(o.window&&e.errorOnClose)var f=Object(a.safeInterval)(function(){r&&"object"===(void 0===r?"undefined":M(r))&&Object(i.isWindowClosed)(r)&&(f.cancel(),o.handleError(new Error("Post message target window is closed")))},50);return{cancel:function(){s.cancel()}}}function C(e,n,r){return"function"==typeof n&&(r=n,n={}),(n=n||{}).name=e,n.handler=r||n.handler,L(n)}function N(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];"function"==typeof n&&(r=n,n={}),n=n||{},r=r||n.handler;var t=n.errorHandler,o=new s.a(function(o,i){(n=n||{}).name=e,n.once=!0,n.handler=function(e){if(o(e),r)return r(e)},n.errorHandler=function(e){if(i(e),t)return t(e)}}),i=L(n);return o.cancel=i.cancel,o}function B(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{on:function(n,r){return C(n,e,r)}}}function x(){delete window[u.b.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",W)}c.a.on=C;var k=Object(i.getAncestor)();function U(e){var n=c.a.requestPromises.get(e);if(n)for(var r=0,t=null==n?0:n.length;r<t;r++)n[r].reject(new Error("No response from window - cleaned up"));c.a.popupWindowsByWin&&c.a.popupWindowsByWin.delete(e),c.a.remoteWindows&&c.a.remoteWindows.delete(e),c.a.requestPromises.delete(e),c.a.methods.delete(e),c.a.readyPromises.delete(e)}var G=r(22);function F(){c.a.initialized||(Object(a.addEventListener)(window,"message",W),r(8).openTunnelToOpener(),Object(o.c)(),Object(o.e)({on:C,send:R})),c.a.initialized=!0}F(),r.d(n,"markWindowKnown",function(){return o.f}),r.d(n,"cleanUpWindow",function(){return U}),r.d(n,"Promise",function(){return s.a}),r.d(n,"bridge",function(){return G}),r.d(n,"init",function(){return F}),r.d(n,"parent",function(){return k}),r.d(n,"send",function(){return R}),r.d(n,"request",function(){return A}),r.d(n,"sendToParent",function(){return D}),r.d(n,"client",function(){return I}),r.d(n,"on",function(){return C}),r.d(n,"listen",function(){return L}),r.d(n,"once",function(){return N}),r.d(n,"listener",function(){return B}),r.d(n,"CONFIG",function(){return u.a}),r.d(n,"CONSTANTS",function(){return u.b}),r.d(n,"disable",function(){return x}),n.default=t},function(e,n,r){"use strict";function t(e){return"[object RegExp]"===Object.prototype.toString.call(e)}n.g=u,n.f=c,n.a=d,n.c=f,n.i=w,n.n=l,n.q=_,n.r=function(e){if(function(){for(var e=0;e<b.length;e++)v(b[e])&&(b.splice(e,1),y.splice(e,1));for(var n=0;n<y.length;n++)_(y[n])&&(b.splice(n,1),y.splice(n,1))}(),e&&e.contentWindow)try{y.push(e.contentWindow),b.push(e)}catch(e){}},n.h=function(e){return(e=e||window).navigator.mockUserAgent||e.navigator.userAgent},n.e=function(e,n){for(var r=m(e),t=0,o=null==r?0:r.length;t<o;t++){var i=r[t];try{if(l(i)&&i.name===n&&-1!==r.indexOf(i))return i}catch(e){}}try{if(-1!==r.indexOf(e.frames[n]))return e.frames[n]}catch(e){}try{if(-1!==r.indexOf(e[n]))return e[n]}catch(e){}},n.l=function(e,n){return e===c(n)},n.b=E,n.j=function(e,n){var r=E(n);if(r)return r===e;if(n===e)return!1;if(O(n)===n)return!1;for(var t=0,o=m(e),i=null==o?0:o.length;t<i;t++)if(o[t]===n)return!0;return!1},n.m=function(){return Boolean(c(window))},n.k=function(){return Boolean(u(window))},n.o=function(e,n){var r=O(e)||e,t=O(n)||n;try{if(r&&t)return r===t}catch(e){}var o=g(e),i=g(n);if(S(o,i))return!0;var a=c(r),u=c(t);return!(a&&S(g(a),i)||(u&&S(g(u),o),1))},n.s=function e(n,r){if("string"==typeof n){if("string"==typeof r)return n===o.WILDCARD||r===n;if(t(r))return!1;if(Array.isArray(r))return!1}return t(n)?t(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!t(r)&&n.some(function(n){return e(n,r)}))},n.t=function(e){return Array.isArray(e)?"("+e.join(" | ")+")":t(e)?"RegExp("+e.toString():e.toString()},n.d=function(e){return e.match(/^(https?|mock|file):\/\//)?e.split("/").slice(0,3).join("/"):f()},n.p=function(e){try{if(e===window)return!0}catch(e){if(e&&e.message===i)return!0}try{if("[object Window]"===Object.prototype.toString.call(e))return!0}catch(e){if(e&&e.message===i)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===i)return!0}try{e&&e.__cross_domain_utils_window_check__}catch(e){return!0}return!1};var o={MOCK_PROTOCOL:"mock:",FILE_PROTOCOL:"file:",ABOUT_PROTOCOL:"about:",WILDCARD:"*"},i="Call was rejected by callee.\r\n";function a(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===o.ABOUT_PROTOCOL}function u(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function c(e){if(e&&!u(e))try{return e.opener}catch(e){}}function s(e){try{return e&&e.location&&e.location.href,!0}catch(e){}return!1}function d(e){var n=(e=e||window).location;if(!n)throw new Error("Can not read window location");var r=n.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE_PROTOCOL)return o.FILE_PROTOCOL+"//";if(r===o.ABOUT_PROTOCOL){var t=u(e);return t&&s(t)?d(t):o.ABOUT_PROTOCOL+"//"}var i=n.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function f(e){var n=d(e=e||window);return n&&e.mockDomain&&0===e.mockDomain.indexOf(o.MOCK_PROTOCOL)?e.mockDomain:n}function w(e){try{if(e===window)return!0}catch(e){}try{var n=Object.getOwnPropertyDescriptor(e,"location");if(n&&!1===n.enumerable)return!1}catch(e){}try{if(a(e)&&s(e))return!0}catch(e){}try{if(d(e)===d(window))return!0}catch(e){}return!1}function l(e){if(!w(e))return!1;try{if(e===window)return!0;if(a(e)&&s(e))return!0;if(f(window)===f(e))return!0}catch(e){}return!1}function p(e,n){if(!e||!n)return!1;var r=u(n);return r?r===e:-1!==function(e){var n=[];try{for(;e.parent!==e;)n.push(e.parent),e=e.parent}catch(e){}return n}(n).indexOf(e)}function m(e){var n=[],r=void 0;try{r=e.frames}catch(n){r=e}var t=void 0;try{t=r.length}catch(e){}if(0===t)return n;if(t){for(var o=0;o<t;o++){var i=void 0;try{i=r[o]}catch(e){continue}n.push(i)}return n}for(var a=0;a<100;a++){var u=void 0;try{u=r[a]}catch(e){return n}if(!u)return n;n.push(u)}return n}function h(e){for(var n=[],r=0,t=m(e),o=null==t?0:t.length;r<o;r++){var i=t[r];n.push(i);for(var a=0,u=h(i),c=null==u?0:u.length;a<c;a++){var s=u[a];n.push(s)}}return n}function O(e){if(e){try{if(e.top)return e.top}catch(e){}if(u(e)===e)return e;try{if(p(window,e)&&window.top)return window.top}catch(e){}try{if(p(e,window)&&window.top)return window.top}catch(e){}for(var n=0,r=h(e),t=null==r?0:r.length;n<t;n++){var o=r[n];try{if(o.top)return o.top}catch(e){}if(u(o)===o)return o}}}function g(e){var n=O(e);if(!n)throw new Error("Can not determine top window");return[].concat(h(n),[n])}function v(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var n=e.ownerDocument;return!(!n||!n.documentElement||n.documentElement.contains(e))}var y=[],b=[];function _(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==i}if(n&&l(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var r=function(e,n){for(var r=0;r<e.length;r++)try{if(e[r]===n)return r}catch(e){}return-1}(y,e);if(-1!==r){var t=b[r];if(t&&v(t))return!0}return!1}function E(e){return c(e=e||window)||u(e)||void 0}function S(e,n){for(var r=0,t=null==e?0:e.length;r<t;r++)for(var o=e[r],i=0,a=null==n?0:n.length;i<a;i++)if(o===n[i])return!0;return!1}},function(e,n){},function(e,n,r){"use strict";r(7),r(11)},function(e,n,r){"use strict";r(7)},function(e,n,r){"use strict";r(2),r(0)},function(e,n){},function(e,n,r){"use strict";r(7)},function(e,n,r){"use strict"},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(8);r.d(n,"openBridge",function(){return t.openBridge}),r.d(n,"linkUrl",function(){return t.linkUrl}),r.d(n,"isBridge",function(){return t.isBridge}),r.d(n,"needsBridge",function(){return t.needsBridge}),r.d(n,"needsBridgeForBrowser",function(){return t.needsBridgeForBrowser}),r.d(n,"hasBridge",function(){return t.hasBridge}),r.d(n,"needsBridgeForWin",function(){return t.needsBridgeForWin}),r.d(n,"needsBridgeForDomain",function(){return t.needsBridgeForDomain}),r.d(n,"openTunnelToOpener",function(){return t.openTunnelToOpener}),r.d(n,"destroyBridges",function(){return t.destroyBridges})}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="",r(r.s=13)}([function(e,n,r){"use strict";var t=r(14);r.d(n,"getActualDomain",function(){return t.a}),r.d(n,"getAncestor",function(){return t.b}),r.d(n,"getDomain",function(){return t.c}),r.d(n,"getDomainFromUrl",function(){return t.d}),r.d(n,"getFrameByName",function(){return t.e}),r.d(n,"getOpener",function(){return t.f}),r.d(n,"getParent",function(){return t.g}),r.d(n,"getUserAgent",function(){return t.h}),r.d(n,"isActuallySameDomain",function(){return t.i}),r.d(n,"isAncestor",function(){return t.j}),r.d(n,"isIframe",function(){return t.k}),r.d(n,"isOpener",function(){return t.l}),r.d(n,"isPopup",function(){return t.m}),r.d(n,"isSameDomain",function(){return t.n}),r.d(n,"isSameTopWindow",function(){return t.o}),r.d(n,"isWindow",function(){return t.p}),r.d(n,"isWindowClosed",function(){return t.q}),r.d(n,"linkFrameWindow",function(){return t.r}),r.d(n,"matchDomain",function(){return t.s}),r.d(n,"stringifyDomainPattern",function(){return t.t});var o=r(15);r.n(o)},function(e,n,r){"use strict";var t,o={REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},i={SUCCESS:"success",ERROR:"error"},a={METHOD:"postrobot_method",HELLO:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},u={FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},c={POSTROBOT:"__postRobot__"},s={METHOD:"postrobot_method",ZALGO_PROMISE:"postrobot_zalgo_promise"},d={POST_MESSAGE:"postrobot_post_message",BRIDGE:"postrobot_bridge",GLOBAL:"postrobot_global"},f={MOCK:"mock:",FILE:"file:"},l={ALLOW_POSTMESSAGE_POPUP:!("__ALLOW_POSTMESSAGE_POPUP__"in window)||window.__ALLOW_POSTMESSAGE_POPUP__,BRIDGE_TIMEOUT:5e3,CHILD_WINDOW_TIMEOUT:5e3,ACK_TIMEOUT:2e3,ACK_TIMEOUT_KNOWN:1e4,RES_TIMEOUT:-1,ALLOWED_POST_MESSAGE_METHODS:(t={},t[d.POST_MESSAGE]=!0,t[d.BRIDGE]=!0,t[d.GLOBAL]=!0,t)};0===window.location.href.indexOf(f.FILE)&&(l.ALLOW_POSTMESSAGE_POPUP=!0),r.d(n,"b",function(){return l}),r.d(n,"e",function(){return o}),r.d(n,"c",function(){return i}),r.d(n,"d",function(){return a}),r.d(n,"j",function(){return u}),r.d(n,"i",function(){return c}),r.d(n,!1,function(){return s}),r.d(n,"g",function(){return d}),r.d(n,"f",function(){return f}),r.d(n,"a",function(){return"__postrobot_bridge__"}),r.d(n,!1,function(){return"__postrobot_proxy__"}),r.d(n,"h",function(){return"*"})},function(e,n,r){"use strict";function t(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&e instanceof window.constructor)return!1;var n={}.toString;if(n){var r=n.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}function o(){var e=void 0;if("undefined"!=typeof window)e=window;else{if("undefined"==typeof window)throw new TypeError("Can not find global");e=window}var n=e.__zalgopromise__=e.__zalgopromise__||{};return n.flushPromises=n.flushPromises||[],n.activeCount=n.activeCount||0,n.possiblyUnhandledPromiseHandlers=n.possiblyUnhandledPromiseHandlers||[],n.dispatchedErrors=n.dispatchedErrors||[],n}var i=function(){function e(n){var r=this;if(function(n,r){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var t=void 0,o=void 0,i=!1,a=!1,u=!1;try{n(function(e){u?r.resolve(e):(i=!0,t=e)},function(e){u?r.reject(e):(a=!0,o=e)})}catch(e){return void this.reject(e)}u=!0,i?this.resolve(t):a&&this.reject(o)}}return e.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(t(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},e.prototype.reject=function(e){var n=this;if(this.resolved||this.rejected)return this;if(t(e))throw new Error("Can not reject promise with another promise");if(!e){var r=e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);e=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){n.errorHandled||function(e,n){if(-1===o().dispatchedErrors.indexOf(e)){o().dispatchedErrors.push(e),setTimeout(function(){throw e},1);for(var r=0;r<o().possiblyUnhandledPromiseHandlers.length;r++)o().possiblyUnhandledPromiseHandlers[r](e,n)}}(e,n)},1),this.dispatch(),this},e.prototype.asyncReject=function(e){this.errorHandled=!0,this.reject(e)},e.prototype.dispatch=function(){var n=this,r=this.dispatching,i=this.resolved,a=this.rejected,u=this.handlers;if(!r&&(i||a)){this.dispatching=!0,o().activeCount+=1;for(var c=function(r){var o=u[r],c=o.onSuccess,s=o.onError,d=o.promise,f=void 0;if(i)try{f=c?c(n.value):n.value}catch(e){return d.reject(e),"continue"}else if(a){if(!s)return d.reject(n.error),"continue";try{f=s(n.error)}catch(e){return d.reject(e),"continue"}}f instanceof e&&(f.resolved||f.rejected)?(f.resolved?d.resolve(f.value):d.reject(f.error),f.errorHandled=!0):t(f)?f instanceof e&&(f.resolved||f.rejected)?f.resolved?d.resolve(f.value):d.reject(f.error):f.then(function(e){d.resolve(e)},function(e){d.reject(e)}):d.resolve(f)},s=0;s<u.length;s++)c(s);u.length=0,this.dispatching=!1,o().activeCount-=1,0===o().activeCount&&e.flushQueue()}},e.prototype.then=function(n,r){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new e;return this.handlers.push({promise:t,onSuccess:n,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.finally=function(n){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return e.try(n).then(function(){return r})},function(r){return e.try(n).then(function(){throw r})})},e.prototype.timeout=function(e,n){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout(function(){r.resolved||r.rejected||r.reject(n||new Error("Promise timed out after "+e+"ms"))},e);return this.then(function(e){return clearTimeout(t),e})},e.prototype.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.resolve=function(n){return n instanceof e?n:t(n)?new e(function(e,r){return n.then(e,r)}):(new e).resolve(n)},e.reject=function(n){return(new e).reject(n)},e.all=function(n){var r=new e,o=n.length,i=[];if(!o)return r.resolve(i),r;for(var a=function(a){var u=n[a];if(u instanceof e){if(u.resolved)return i[a]=u.value,o-=1,"continue"}else if(!t(u))return i[a]=u,o-=1,"continue";e.resolve(u).then(function(e){i[a]=e,0==(o-=1)&&r.resolve(i)},function(e){r.reject(e)})},u=0;u<n.length;u++)a(u);return 0===o&&r.resolve(i),r},e.hash=function(n){var r={};return e.all(Object.keys(n).map(function(t){return e.resolve(n[t]).then(function(e){r[t]=e})})).then(function(){return r})},e.map=function(n,r){return e.all(n.map(r))},e.onPossiblyUnhandledException=function(e){return function(e){return o().possiblyUnhandledPromiseHandlers.push(e),{cancel:function(){o().possiblyUnhandledPromiseHandlers.splice(o().possiblyUnhandledPromiseHandlers.indexOf(e),1)}}}(e)},e.try=function(n,r,t){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.try expected a function");var o=void 0;try{o=n.apply(r,t||[])}catch(n){return e.reject(n)}return e.resolve(o)},e.delay=function(n){return new e(function(e){setTimeout(e,n)})},e.isPromise=function(n){return!!(n&&n instanceof e)||t(n)},e.flush=function(){var n=new e;return o().flushPromises.push(n),0===o().activeCount&&e.flushQueue(),n},e.flushQueue=function(){var e=o().flushPromises;o().flushPromises=[];for(var n=0,r=null==e?0:e.length;n<r;n++)e[n].resolve()},e}();r.d(n,"a",function(){return i})},function(e,n,r){"use strict";r.d(n,"a",function(){return o});var t=r(1),o=window[t.i.POSTROBOT]=window[t.i.POSTROBOT]||{};o.registerSelf=function(){}},function(e,n,r){"use strict";r(9);var t=r(10);r.d(n,"addEventListener",function(){return t.a}),r(16),r(17),r(11);var o=r(7);r.d(n,"isRegex",function(){return o.f}),r.d(n,"noop",function(){return o.h}),r.d(n,"once",function(){return o.i}),r.d(n,"safeInterval",function(){return o.k}),r.d(n,"stringifyError",function(){return o.m}),r.d(n,"uniqueID",function(){return o.n}),r.d(n,"weakMapMemoize",function(){return o.o}),r(18);var i=r(19);r.n(i),r(20),r(21)},function(e,n,r){"use strict";r.d({},"WeakMap",function(){return u});var t=r(0);function o(e,n){for(var r=0;r<e.length;r++)try{if(e[r]===n)return r}catch(e){}return-1}var i=Object.defineProperty,a=Date.now()%1e9,u=function(){function e(){if(function(n,r){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),a+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+a,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,n={};return Object.freeze(n),e.set(n,"__testvalue__"),"__testvalue__"===e.get(n)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}return e.prototype._cleanupClosedWindows=function(){for(var e=this.weakmap,n=this.keys,r=0;r<n.length;r++){var o=n[r];if(Object(t.isWindow)(o)&&Object(t.isWindowClosed)(o)){if(e)try{e.delete(o)}catch(e){}n.splice(r,1),this.values.splice(r,1),r-=1}}},e.prototype.isSafeToReadWrite=function(e){if(Object(t.isWindow)(e))return!1;try{e&&e.self,e&&e[this.name]}catch(e){return!1}return!0},e.prototype.set=function(e,n){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(e,n)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var t=this.name,a=e[t];a&&a[0]===e?a[1]=n:i(e,t,{value:[e,n],writable:!0})}else{this._cleanupClosedWindows();var u=this.keys,c=this.values,s=o(u,e);-1===s?(u.push(e),c.push(n)):c[s]=n}},e.prototype.get=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{if(n.has(e))return n.get(e)}catch(e){delete this.weakmap}if(!this.isSafeToReadWrite(e)){this._cleanupClosedWindows();var r=o(this.keys,e);if(-1===r)return;return this.values[r]}var t=e[this.name];if(t&&t[0]===e)return t[1]},e.prototype.delete=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];r&&r[0]===e&&(r[0]=r[1]=void 0)}else{this._cleanupClosedWindows();var t=this.keys,i=o(t,e);-1!==i&&(t.splice(i,1),this.values.splice(i,1))}},e.prototype.has=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{return n.has(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];return!(!r||r[0]!==e)}return this._cleanupClosedWindows(),-1!==o(this.keys,e)},e.prototype.getOrSet=function(e,n){if(this.has(e))return this.get(e);var r=n();return this.set(e,r),r},e}();r.d(n,"a",function(){return u})},function(e,n,r){"use strict";var t=r(0),o=r(1);function i(){return Object(t.isPopup)()?o.j.POPUP:Object(t.isIframe)()?o.j.IFRAME:o.j.FULLPAGE}function a(){return!!Object(t.getUserAgent)(window).match(/MSIE|trident|edge\/12|edge\/13/i)||!o.b.ALLOW_POSTMESSAGE_POPUP}var u,c=r(5),s=r(2),d=r(4),f={FUNCTION:"function",ERROR:"error",PROMISE:"promise",REGEX:"regex",DATE:"date",ARRAY:"array",OBJECT:"object",STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",UNDEFINED:"undefined"},l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function w(e){return"object"===(void 0===e?"undefined":l(e))&&null!==e&&"string"==typeof e.__type__}function h(e){return void 0===e?f.UNDEFINED:null===e?f.NULL:Array.isArray(e)?f.ARRAY:"function"==typeof e?f.FUNCTION:"object"===(void 0===e?"undefined":l(e))?e instanceof Error?f.ERROR:"function"==typeof e.then?f.PROMISE:"[object RegExp]"===Object.prototype.toString.call(e)?f.REGEX:"[object Date]"===Object.prototype.toString.call(e)?f.DATE:f.OBJECT:"string"==typeof e?f.STRING:"number"==typeof e?f.NUMBER:"boolean"==typeof e?f.BOOLEAN:void 0}function m(e,n){return{__type__:e,__val__:n}}var p,g=((u={})[f.FUNCTION]=function(){},u[f.ERROR]=function(e){var n=e.message,r=e.stack,t=e.code;return m(f.ERROR,{message:n,stack:r,code:t})},u[f.PROMISE]=function(){},u[f.REGEX]=function(e){return m(f.REGEX,e.source)},u[f.DATE]=function(e){return m(f.DATE,e.toJSON())},u[f.ARRAY]=function(e){return e},u[f.OBJECT]=function(e){return e},u[f.STRING]=function(e){return e},u[f.NUMBER]=function(e){return e},u[f.BOOLEAN]=function(e){return e},u[f.NULL]=function(e){return e},u),v={},y=((p={})[f.FUNCTION]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},p[f.ERROR]=function(e){var n=e.message,r=e.stack,t=e.code,o=new Error(n);return o.code=t,o.stack=r+"\n\n"+o.stack,o},p[f.PROMISE]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},p[f.REGEX]=function(e){return new RegExp(e)},p[f.DATE]=function(e){return new Date(e)},p[f.ARRAY]=function(e){return e},p[f.OBJECT]=function(e){return e},p[f.STRING]=function(e){return e},p[f.NUMBER]=function(e){return e},p[f.BOOLEAN]=function(e){return e},p[f.NULL]=function(e){return e},p),O={},b=r(3);b.a.methods=b.a.methods||new c.a;var E=Object(d.once)(function(){b.a.on(o.d.METHOD,{origin:o.h},function(e){var n=e.source,r=e.origin,o=e.data,i=b.a.methods.get(n);if(!i)throw new Error("Could not find any methods this window has privileges to call");var a=i[o.id];if(!a)throw new Error("Could not find method with id: "+o.id);if(!Object(t.matchDomain)(a.domain,r))throw new Error("Method domain "+a.domain+" does not match origin "+r);return s.a.try(function(){return a.val.apply({source:n,origin:r,data:o},o.args)}).then(function(e){return{result:e,id:o.id,name:o.name}})})}),_={CROSS_DOMAIN_ZALGO_PROMISE:"cross_domain_zalgo_promise",CROSS_DOMAIN_FUNCTION:"cross_domain_function"};function S(e,n,r,t){var o=Object(d.uniqueID)(),i=b.a.methods.get(e);return i||(i={},b.a.methods.set(e,i)),i[o]={domain:n,val:r},E(),m(_.CROSS_DOMAIN_FUNCTION,{id:o,name:r.name||t})}function j(e,n,r){var t=r.id,i=r.name;function a(){var r=Array.prototype.slice.call(arguments);return b.a.send(e,o.d.METHOD,{id:t,name:i,args:r},{domain:n}).then(function(e){return e.data.result})}return a.__name__=i,a.__xdomain__=!0,a.source=e,a.origin=n,a}function W(e,n,r){var t;return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v,r=JSON.stringify(e,function(e){var r=this[e];if(w(this))return r;var t=h(r);if(!t)return r;var o=n[t]||g[t];return o?o(r,e):r});return void 0===r?f.UNDEFINED:r}(r,((t={})[f.PROMISE]=function(r,t){return function(e,n,r,t){return m(_.CROSS_DOMAIN_ZALGO_PROMISE,{then:S(e,n,function(e,n){return r.then(e,n)},t)})}(e,n,r,t)},t[f.FUNCTION]=function(r,t){return S(e,n,r,t)},t))}function P(e,n,r){var t;return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;if(e!==f.UNDEFINED)return JSON.parse(e,function(e,r){if(w(this))return r;var t=void 0,o=void 0;if(w(r)?(t=r.__type__,o=r.__val__):(t=h(r),o=r),!t)return o;var i=n[t]||y[t];return i?i(o,e):o})}(r,((t={})[_.CROSS_DOMAIN_ZALGO_PROMISE]=function(r){var t=r.then;return function(e,n,r){var t=r.then;return new s.a(function(r,o){j(e,n,t)(r,o)})}(e,n,{then:t})},t[_.CROSS_DOMAIN_FUNCTION]=function(r){var t=r.id,o=r.name;return j(e,n,{id:t,name:o})},t))}function R(e){b.a.on(o.d.HELLO,{domain:o.h},function(n){var r=n.source,t=n.origin;return e({source:r,origin:t})})}function T(e){return b.a.send(e,o.d.HELLO,{},{domain:o.h,timeout:-1}).then(function(e){return{origin:e.origin}})}function A(e){b.a.knownWindows.set(e,!0)}function M(e){return b.a.knownWindows.get(e)}function D(){R(function(e){var n=e.source,r=e.origin,t=b.a.readyPromises.get(n)||new s.a;t.resolve({origin:r}),b.a.readyPromises.set(n,t)});var e=Object(t.getAncestor)();e&&T(e).catch(d.noop)}function N(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Window",t=b.a.readyPromises.get(e);return t||(t=new s.a,b.a.readyPromises.set(e,t),-1!==n&&setTimeout(function(){return t.reject(new Error(r+" did not load after "+n+"ms"))},n),t)}b.a.readyPromises=b.a.readyPromises||new c.a,b.a.knownWindows=b.a.knownWindows||new c.a,r.d(n,"b",function(){return i}),r.d(n,"f",function(){return a}),r.d(n,"i",function(){return W}),r.d(n,"a",function(){return P}),r.d(n,!1,function(){return R}),r.d(n,"h",function(){return T}),r.d(n,"e",function(){return A}),r.d(n,"d",function(){return M}),r.d(n,"c",function(){return D}),r.d(n,"g",function(){return N})},function(e,n,r){"use strict";n.n=a,n.d=function(){if("undefined"!=typeof window)return window;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("No global found")},n.g=function(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=new o.a;function i(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];var u=t.getOrSet(r.thisNamespace?this:e,function(){return{}}),s=c(o),d=r.time;if(u[s]&&d&&Date.now()-u[s].time<d&&delete u[s],u[s])return u[s].value;i.__calling__=!0;var f=Date.now(),l=e.apply(this,arguments);return i.__calling__=!1,u[s]={time:f,value:l},u[s].value}return i.reset=function(){t.delete(r.thisNamespace?n:e)},r.name&&(i.displayName=r.name+":memoized"),i},n.j=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};function r(){return t.a.try(e,this,arguments)}return n.name&&(r.displayName=n.name+":promisified"),r},n.e=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],t=e.__inline_memoize_cache__=e.__inline_memoize_cache__||{},o=c(r);return t.hasOwnProperty(o)?t[o]:t[o]=n.apply(void 0,r)},n.h=function(){},n.i=function(e){var n=!1;return function(){if(!n)return n=!0,e.apply(this,arguments)}},n.m=function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+Object.prototype.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,o=n&&n.message;if(t&&o)return-1!==t.indexOf(o)?t:o+"\n"+t;if(t)return t;if(o)return o}return"function"==typeof n.toString?n.toString():Object.prototype.toString.call(n)}catch(n){return"Error while stringifying error: "+e(n,r+1)}},n.l=function(e){return"string"==typeof e?e:e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)},n.c=function(e,n){if(!n)return e;if(Object.assign)return Object.assign(e,n);for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r]);return e},n.k=function(e,n){var r=void 0;return function t(){r=setTimeout(function(){e(),t()},n)}(),{cancel:function(){clearTimeout(r)}}},n.a=function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},n.b=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=void 0;return function(){var t=this,o=arguments;clearTimeout(r),r=setTimeout(function(){return e.apply(t,o)},n)}},n.f=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},r.d(n,"o",function(){return s});var t=r(2),o=r(5),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function a(){var e,n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+(e=(new Date).toISOString().slice(11,19).replace("T","."),window.btoa(e)).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var u=void 0;function c(e){try{return JSON.stringify(Array.prototype.slice.call(e),function(e,n){return"function"==typeof n?"memoize["+function(e){if(u=u||new o.a,null===e||void 0===e||"object"!==(void 0===e?"undefined":i(e))&&"function"!=typeof e)throw new Error("Invalid object");var n=u.get(e);return n||(n=(void 0===e?"undefined":i(e))+":"+a(),u.set(e,n)),n}(n)+"]":n})}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}var s=function(e){var n=new o.a;return function(r){var t=n.get(r);return void 0!==t?t:(void 0!==(t=e.call(this,r))&&n.set(r,t),t)}}},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(2),o=r(0),i=r(4),a=r(1),u=r(3);function c(e){try{u.a.tunnelWindows[e]&&delete u.a.tunnelWindows[e].source}catch(e){}delete u.a.tunnelWindows[e]}u.a.tunnelWindows=u.a.tunnelWindows||{},u.a.tunnelWindowId=0,u.a.openTunnelToParent=function(e){var n=e.name,r=e.source,t=e.canary,s=e.sendMessage,d=Object(o.getParent)(window);if(!d)throw new Error("No parent window found to open tunnel to");var f=function(e){var n=e.name,r=e.source,t=e.canary,a=e.sendMessage;return function(){for(var e=u.a.tunnelWindows,n=0,r=Object.keys(e),t=null==r?0:r.length;n<t;n++){var a=r[n],s=e[a];try{Object(i.noop)(s.source)}catch(e){c(a);continue}Object(o.isWindowClosed)(s.source)&&c(a)}}(),u.a.tunnelWindowId+=1,u.a.tunnelWindows[u.a.tunnelWindowId]={name:n,source:r,canary:t,sendMessage:a},u.a.tunnelWindowId}({name:n,source:r,canary:t,sendMessage:s});return u.a.send(d,a.d.OPEN_TUNNEL,{name:n,sendMessage:function(){var e=function(e){return u.a.tunnelWindows[e]}(f);try{Object(i.noop)(e&&e.source)}catch(e){return void c(f)}if(e&&e.source&&!Object(o.isWindowClosed)(e.source)){try{e.canary()}catch(e){return}e.sendMessage.apply(this,arguments)}}},{domain:a.h})};var s=r(5);function d(){return!!Object(o.getUserAgent)(window).match(/MSIE|trident|edge\/12|edge\/13/i)||!a.b.ALLOW_POSTMESSAGE_POPUP}function f(e){return!Object(o.isSameTopWindow)(window,e)}function l(e,n){if(e){if(Object(o.getDomain)()!==Object(o.getDomainFromUrl)(e))return!0}else if(n&&!Object(o.isSameDomain)(n))return!0;return!1}function w(e){var n=e.win,r=e.domain;return!(!d()||r&&!l(r,n)||n&&!f(n))}function h(e){var n=(e=e||Object(o.getDomainFromUrl)(e)).replace(/[^a-zA-Z0-9]+/g,"_");return a.a+"_"+n}function m(){return Boolean(window.name&&window.name===h(Object(o.getDomain)()))}var p=new t.a(function(e){if(window.document&&window.document.body)return e(window.document.body);var n=setInterval(function(){if(window.document&&window.document.body)return clearInterval(n),e(window.document.body)},10)});function g(e){u.a.remoteWindows.set(e,{sendMessagePromise:new t.a})}function v(e){return u.a.remoteWindows.get(e)}function y(e,n,r){var i=v(e);if(!i)throw new Error("Window not found to register sendMessage to");var a=function(t,i,a){if(t!==e)throw new Error("Remote window does not match window");if(!Object(o.matchDomain)(i,n))throw new Error("Remote domain "+i+" does not match domain "+n);r(a)};i.sendMessagePromise.resolve(a),i.sendMessagePromise=t.a.resolve(a)}function O(e,n){var r=v(e);if(!r)throw new Error("Window not found on which to reject sendMessage");r.sendMessagePromise.asyncReject(n)}function b(e,n,r){var t=Object(o.isOpener)(window,e),i=Object(o.isOpener)(e,window);if(!t&&!i)throw new Error("Can only send messages to and from parent and popup windows");var a=v(e);if(!a)throw new Error("Window not found to send message to");return a.sendMessagePromise.then(function(t){return t(e,n,r)})}u.a.remoteWindows=u.a.remoteWindows||new s.a;var E=Object(i.weakMapMemoize)(function(e){return t.a.try(function(){try{var n=Object(o.getFrameByName)(e,h(Object(o.getDomain)()));if(!n)return;return Object(o.isSameDomain)(n)&&n[a.i.POSTROBOT]?n:new t.a(function(e){var r=void 0,t=void 0;r=setInterval(function(){if(n&&Object(o.isSameDomain)(n)&&n[a.i.POSTROBOT])return clearInterval(r),clearTimeout(t),e(n)},100),t=setTimeout(function(){return clearInterval(r),e()},2e3)})}catch(e){}})});function _(){return t.a.try(function(){var e=Object(o.getOpener)(window);if(e&&w({win:e}))return g(e),E(e).then(function(n){return n?window.name?n[a.i.POSTROBOT].openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(e){try{Object(i.noop)(window)}catch(e){return}if(window&&!window.closed)try{u.a.receiveMessage({data:e,origin:this.origin,source:this.source})}catch(e){t.a.reject(e)}}}).then(function(n){var r=n.source,t=n.origin,o=n.data;if(r!==e)throw new Error("Source does not match opener");y(r,t,o.sendMessage)}).catch(function(n){throw O(e,n),n}):O(e,new Error("Can not register with opener: window does not have a name")):O(e,new Error("Can not register with opener: no bridge found in opener"))})})}var S=r(6);function j(e,n){return n=n||Object(o.getDomainFromUrl)(e),Boolean(u.a.bridges[n])}function W(e,n){return n=n||Object(o.getDomainFromUrl)(e),u.a.bridges[n]?u.a.bridges[n]:(u.a.bridges[n]=t.a.try(function(){if(Object(o.getDomain)()===n)throw new Error("Can not open bridge on the same domain as current domain: "+n);var r=h(n);if(Object(o.getFrameByName)(window,r))throw new Error("Frame with name "+r+" already exists on page");var i=function(e,n){var r=document.createElement("iframe");return r.setAttribute("name",e),r.setAttribute("id",e),r.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=n,r}(r,e);return u.a.bridgeFrames[n]=i,p.then(function(r){r.appendChild(i);var o=i.contentWindow;return function(e,n){u.a.on(a.d.OPEN_TUNNEL,{window:e,domain:n},function(e){var r=e.origin,o=e.data;if(r!==n)throw new Error("Domain "+n+" does not match origin "+r);if(!o.name)throw new Error("Register window expected to be passed window name");if(!o.sendMessage)throw new Error("Register window expected to be passed sendMessage method");if(!u.a.popupWindowsByName[o.name])throw new Error("Window with name "+o.name+" does not exist, or was not opened by this window");if(!u.a.popupWindowsByName[o.name].domain)throw new Error("We do not have a registered domain for window "+o.name);if(u.a.popupWindowsByName[o.name].domain!==r)throw new Error("Message origin "+r+" does not matched registered window origin "+u.a.popupWindowsByName[o.name].domain);return y(u.a.popupWindowsByName[o.name].win,n,o.sendMessage),{sendMessage:function(e){if(window&&!window.closed){var n=u.a.popupWindowsByName[o.name];if(n)try{u.a.receiveMessage({data:e,origin:n.domain,source:n.win})}catch(e){t.a.reject(e)}}}}})}(o,n),new t.a(function(e,n){i.onload=e,i.onerror=n}).then(function(){return Object(S.g)(o,a.b.BRIDGE_TIMEOUT,"Bridge "+e)}).then(function(){return o})})}),u.a.bridges[n])}u.a.bridges=u.a.bridges||{},u.a.bridgeFrames=u.a.bridgeFrames||{},u.a.popupWindowsByWin=u.a.popupWindowsByWin||new s.a,u.a.popupWindowsByName=u.a.popupWindowsByName||{};var P=window.open;function R(e,n){var r=u.a.popupWindowsByWin.get(e);r&&(r.domain=Object(o.getDomainFromUrl)(n),g(e))}function T(){for(var e=0,n=Object.keys(u.a.bridgeFrames),r=null==n?0:n.length;e<r;e++){var t=n[e],o=u.a.bridgeFrames[t];o.parentNode&&o.parentNode.removeChild(o)}u.a.bridgeFrames={},u.a.bridges={}}window.open=function(e,n,r,t){var i=e;if(e&&0===e.indexOf(a.f.MOCK)){var c=e.split("|");i=c[0],e=c[1]}i&&(i=Object(o.getDomainFromUrl)(i));var s=P.call(this,e,n,r,t);if(!s)return s;e&&g(s);for(var d=0,f=Object.keys(u.a.popupWindowsByName),l=null==f?0:f.length;d<l;d++){var w=f[d];Object(o.isWindowClosed)(u.a.popupWindowsByName[w].win)&&delete u.a.popupWindowsByName[w]}if(n&&s){var h=u.a.popupWindowsByWin.get(s)||u.a.popupWindowsByName[n]||{};h.name=h.name||n,h.win=h.win||s,h.domain=h.domain||i,u.a.popupWindowsByWin.set(s,h),u.a.popupWindowsByName[n]=h}return s},r.d(n,"openTunnelToOpener",function(){return _}),r.d(n,"needsBridgeForBrowser",function(){return d}),r.d(n,"needsBridgeForWin",function(){return f}),r.d(n,"needsBridgeForDomain",function(){return l}),r.d(n,"needsBridge",function(){return w}),r.d(n,"getBridgeName",function(){return h}),r.d(n,"isBridge",function(){return m}),r.d(n,"documentBodyReady",function(){return p}),r.d(n,"registerRemoteWindow",function(){return g}),r.d(n,"findRemoteWindow",function(){return v}),r.d(n,"registerRemoteSendMessage",function(){return y}),r.d(n,"rejectRemoteSendMessage",function(){return O}),r.d(n,"sendBridgeMessage",function(){return b}),r.d(n,"hasBridge",function(){return j}),r.d(n,"openBridge",function(){return W}),r.d(n,"linkUrl",function(){return R}),r.d(n,"destroyBridges",function(){return T})},function(e,n,r){"use strict";n.a=function(){return!!(window.navigator.mockUserAgent||window.navigator.userAgent).match(/Android|webOS|iPhone|iPad|iPod|bada|Symbian|Palm|CriOS|BlackBerry|IEMobile|WindowsMobile|Opera Mini/i)}},function(e,n,r){"use strict";r(2),r(0),r(5);var t=r(7);r(9),n.b=function e(){return Object(t.e)(e,function(){try{if("undefined"==typeof window)return!1;if(window.localStorage){var e=Math.random().toString();window.localStorage.setItem("__test__localStorage__",e);var n=window.localStorage.getItem("__test__localStorage__");if(window.localStorage.removeItem("__test__localStorage__"),e===n)return!0}}catch(e){}return!1})},n.a=function(e,n,r){return e.addEventListener(n,r),{cancel:function(){e.removeEventListener(n,r)}}},"function"==typeof Symbol&&Symbol.iterator,Object.assign,Object.create(Error.prototype)},function(e,n,r){"use strict";n.a=function e(n){var r=n.name,i=n.version,a=void 0===i?"latest":i,u=n.lifetime,c=void 0===u?3e5:u;return Object(t.e)(e,function(){var e="__"+r+"_"+a+"_storage__",n=void 0;function i(r){var i=Object(o.b)(),a=void 0;if(n&&(a=n),!a&&i){var u=window.localStorage.getItem(e);u&&(a=JSON.parse(u))}a||(a=Object(t.d)()[e]),a||(a={id:Object(t.n)()}),a.id||(a.id=Object(t.n)()),n=a;var c=r(a);return i?window.localStorage.setItem(e,JSON.stringify(a)):Object(t.d)()[e]=a,n=null,c}function u(e){return i(function(n){var r=n.__session__,o=Date.now();return r&&o-r.created>c&&(r=null),r||(r={guid:Object(t.n)(),created:o}),n.__session__=r,e(r)})}return{getState:i,getID:function(){return i(function(e){return e.id})},getSessionState:function(e){return u(function(n){return n.state=n.state||{},e(n.state)})},getSessionID:function(){return u(function(e){return e.guid})}}},[{name:r,version:a,lifetime:c}])};var t=r(7),o=r(10)},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(0),o=r(1);function i(e,n){if(!o.b.ALLOW_POSTMESSAGE_POPUP&&!1===Object(t.isSameTopWindow)(e,n))throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}r.d(n,"emulateIERestrictions",function(){return i})},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t={};r.d(t,"markWindowKnown",function(){return o.e}),r.d(t,"serializeMessage",function(){return o.i}),r.d(t,"deserializeMessage",function(){return o.a}),r.d(t,"cleanUpWindow",function(){return U}),r.d(t,"Promise",function(){return s.a}),r.d(t,"bridge",function(){return F}),r.d(t,"init",function(){return G}),r.d(t,"parent",function(){return x}),r.d(t,"send",function(){return A}),r.d(t,"request",function(){return T}),r.d(t,"sendToParent",function(){return M}),r.d(t,"client",function(){return D}),r.d(t,"on",function(){return C}),r.d(t,"listen",function(){return I}),r.d(t,"once",function(){return B}),r.d(t,"listener",function(){return L}),r.d(t,"CONFIG",function(){return u.b}),r.d(t,"disable",function(){return k});var o=r(6),i=r(0),a=r(4),u=r(1),c=r(3),s=r(2),d={};d[u.g.POST_MESSAGE]=function(e,n,t){try{r(12).emulateIERestrictions(window,e)}catch(e){return}(Array.isArray(t)?t:"string"==typeof t?[t]:[u.h]).map(function(n){if(0===n.indexOf(u.f.MOCK)){if(window.location.protocol===u.f.FILE)return u.h;if(!Object(i.isActuallySameDomain)(e))throw new Error("Attempting to send messsage to mock domain "+n+", but window is actually cross-domain");return Object(i.getActualDomain)(e)}return 0===n.indexOf(u.f.FILE)?u.h:n}).forEach(function(r){return e.postMessage(n,r)})};var f=r(8),l=f.sendBridgeMessage,w=f.needsBridgeForBrowser,h=f.isBridge;d[u.g.BRIDGE]=function(e,n,r){if(w()||h()){if(Object(i.isSameDomain)(e))throw new Error("Post message through bridge disabled between same domain windows");if(!1!==Object(i.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");return l(e,r,n)}},d[u.g.GLOBAL]=function(e,n){if(Object(o.f)()){if(!Object(i.isSameDomain)(e))throw new Error("Post message through global disabled between different domain windows");if(!1!==Object(i.isSameTopWindow)(window,e))throw new Error("Can only use global to communicate between two different windows, not between frames");var r=e[u.i.POSTROBOT];if(!r)throw new Error("Can not find postRobot global on foreign window");return r.receiveMessage({source:window,origin:Object(i.getDomain)(),data:n})}};var m=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};function p(e,n,r){return s.a.try(function(){var t;if(Object(i.isWindowClosed)(e))throw new Error("Window is closed");var c=Object(o.i)(e,n,((t={})[u.i.POSTROBOT]=m({},r,{id:Object(a.uniqueID)(),windowType:Object(o.b)()}),t)),f=[];return s.a.map(Object.keys(d),function(r){return s.a.try(function(){if(!u.b.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return d[r](e,c,n)}).then(function(){return f.push(r+": success"),!0},function(e){return f.push(r+": "+Object(a.stringifyError)(e)+"\n"),!1})}).then(function(e){var n=e.some(Boolean),t=r.type+" "+r.name+" "+(n?"success":"error")+":\n - "+f.join("\n - ")+"\n";if(!n)throw new Error(t)})})}var g=r(5);c.a.responseListeners=c.a.responseListeners||{},c.a.requestListeners=c.a.requestListeners||{},c.a.WINDOW_WILDCARD=c.a.WINDOW_WILDCARD||new function(){},c.a.erroredResponseListeners=c.a.erroredResponseListeners||{};var v,y="__domain_regex__";function O(e){return c.a.responseListeners[e]}function b(e){delete c.a.responseListeners[e]}function E(e){return Boolean(c.a.erroredResponseListeners[e])}function _(e){var n=e.name,r=e.win,t=e.domain;if(r===u.h&&(r=null),t===u.h&&(t=null),!n)throw new Error("Name required to get request listener");var o=c.a.requestListeners[n];if(o)for(var a=0,s=[r,c.a.WINDOW_WILDCARD],d=null==s?0:s.length;a<d;a++){var f=s[a],l=f&&o.get(f);if(l){if(t&&"string"==typeof t){if(l[t])return l[t];if(l[y])for(var w=0,h=l[y],m=null==h?0:h.length;w<m;w++){var p=h[w],g=p.regex,v=p.listener;if(Object(i.matchDomain)(g,t))return v}}if(l[u.h])return l[u.h]}}}var S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},j=((v={})[u.e.ACK]=function(e,n,r){if(!E(r.hash)){var t=O(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Ack origin "+n+" does not match domain "+t.domain.toString());t.ack=!0}},v[u.e.REQUEST]=function(e,n,r){var t=_({name:r.name,win:e,domain:n});function o(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r.fireAndForget||Object(i.isWindowClosed)(e)?s.a.resolve():p(e,n,S({type:t,hash:r.hash,name:r.name},o))}return s.a.all([o(u.e.ACK),s.a.try(function(){if(!t)throw new Error("No handler found for post message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Request origin "+n+" does not match domain "+t.domain.toString());var o=r.data;return t.handler({source:e,origin:n,data:o})}).then(function(e){return o(u.e.RESPONSE,{ack:u.c.SUCCESS,data:e})},function(e){return o(u.e.RESPONSE,{ack:u.c.ERROR,error:e})})]).then(a.noop).catch(function(e){if(t&&t.handleError)return t.handleError(e);throw e})},v[u.e.RESPONSE]=function(e,n,r){if(!E(r.hash)){var t=O(r.hash);if(!t)throw new Error("No handler found for post message response for message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Response origin "+n+" does not match domain "+Object(i.stringifyDomainPattern)(t.domain));if(b(r.hash),r.ack===u.c.ERROR)return t.respond(r.error,null);if(r.ack===u.c.SUCCESS){var o=r.data;return t.respond(null,{source:e,origin:n,data:o})}}},v),W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function P(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(e){return}var n=e.source,r=e.origin,t=function(e,n,r){var t=void 0;try{t=Object(o.a)(n,r,e)}catch(e){return}if(t&&"object"===(void 0===t?"undefined":W(t))&&null!==t&&(t=t[u.i.POSTROBOT])&&"object"===(void 0===t?"undefined":W(t))&&null!==t&&t.type&&"string"==typeof t.type&&j[t.type])return t}(e.data,n,r);t&&(Object(o.e)(n),-1===c.a.receivedMessages.indexOf(t.id)&&(c.a.receivedMessages.push(t.id),Object(i.isWindowClosed)(n)&&!t.fireAndForget||j[t.type](n,r,t)))}function R(e){try{Object(a.noop)(e.source)}catch(e){return}var n={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent&&e.originalEvent.origin,data:e.data};try{r(12).emulateIERestrictions(n.source,window)}catch(e){return}P(n)}function T(e){return s.a.try(function(){if(!e.name)throw new Error("Expected options.name");var n=e.name,r=void 0,t=void 0;if("string"==typeof e.window){var d=document.getElementById(e.window);if(!d)throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be a valid element id");if("iframe"!==d.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(!d.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");r=d.contentWindow}else if(e.window instanceof HTMLIFrameElement){if("iframe"!==e.window.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(e.window&&!e.window.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");e.window&&e.window.contentWindow&&(r=e.window.contentWindow)}else r=e.window;if(!r)throw new Error("Expected options.window to be a window object, iframe, or iframe element id.");var f=r;t=e.domain||u.h;var l=e.name+"_"+Object(a.uniqueID)();if(Object(i.isWindowClosed)(f))throw new Error("Target window is closed");var w=!1,h=c.a.requestPromises.get(f);h||(h=[],c.a.requestPromises.set(f,h));var m=s.a.try(function(){if(Object(i.isAncestor)(window,f))return Object(o.g)(f,e.timeout||u.b.CHILD_WINDOW_TIMEOUT)}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(a.isRegex)(t)&&!e)return Object(o.h)(f)}).then(function(){var r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(a.isRegex)(t)){if(!Object(i.matchDomain)(t,r))throw new Error("Remote window domain "+r+" does not match regex: "+t.toString());t=r}if("string"!=typeof t&&!Array.isArray(t))throw new TypeError("Expected domain to be a string or array");var d=t;return new s.a(function(r,t){var a=void 0;if(e.fireAndForget||function(e,n){c.a.responseListeners[e]=n}(l,a={name:n,window:f,domain:d,respond:function(e,n){e||(w=!0,h.splice(h.indexOf(m,1))),e?t(e):r(n)}}),p(f,d,{type:u.e.REQUEST,hash:l,name:n,data:e.data,fireAndForget:Boolean(e.fireAndForget)}).catch(t),e.fireAndForget)return r();var s=Object(o.d)(f)?u.b.ACK_TIMEOUT_KNOWN:u.b.ACK_TIMEOUT,g=e.timeout||u.b.RES_TIMEOUT,v=s,y=g,O=100;setTimeout(function e(){if(!w){if(Object(i.isWindowClosed)(f))return a.ack?t(new Error("Window closed for "+n+" before response")):t(new Error("Window closed for "+n+" before ack"));if(v=Math.max(v-O,0),-1!==y&&(y=Math.max(y-O,0)),a.ack){if(-1===y)return;O=Math.min(y,2e3)}else{if(0===v)return t(new Error("No ack for postMessage "+n+" in "+Object(i.getDomain)()+" in "+s+"ms"));if(0===y)return t(new Error("No response for postMessage "+n+" in "+Object(i.getDomain)()+" in "+g+"ms"))}setTimeout(e,O)}},O)})});return m.catch(function(){!function(e){c.a.erroredResponseListeners[e]=!0}(l),b(l)}),h.push(m),m})}function A(e,n,r,t){return(t=t||{}).window=e,t.name=n,t.data=r,T(t)}function M(e,n,r){var t=Object(i.getAncestor)();return t?A(t,e,n,r):new s.a(function(e,n){return n(new Error("Window does not have a parent"))})}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.window)throw new Error("Expected options.window");var n=e.window;return{send:function(r,t){return A(n,r,t,e)}}}c.a.receivedMessages=c.a.receivedMessages||[],c.a.receiveMessage=P,c.a.requestPromises=c.a.requestPromises||new g.a,c.a.send=A;var N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function I(e){if(!e.name)throw new Error("Expected options.name");if(!e.handler)throw new Error("Expected options.handler");var n=e.name,r=e.window,t=e.domain,o={handler:e.handler,handleError:e.errorHandler||function(e){throw e},window:r,domain:t||u.h,name:n},s=function e(n,r){var t=n.name,o=n.win,i=n.domain;if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var s=[],d=0,f=o,l=null==f?0:f.length;d<l;d++){var w=f[d];s.push(e({name:t,domain:i,win:w},r))}return{cancel:function(){for(var e=0,n=null==s?0:s.length;e<n;e++)s[e].cancel()}}}if(Array.isArray(i)){for(var h=[],m=0,p=i,v=null==p?0:p.length;m<v;m++){var O=p[m];h.push(e({name:t,win:o,domain:O},r))}return{cancel:function(){for(var e=0,n=null==h?0:h.length;e<n;e++)h[e].cancel()}}}var b=_({name:t,win:o,domain:i});if(o&&o!==u.h||(o=c.a.WINDOW_WILDCARD),i=i||u.h,b)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===c.a.WINDOW_WILDCARD?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===c.a.WINDOW_WILDCARD?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var E=c.a.requestListeners,S=E[t];S||(S=new g.a,E[t]=S);var j=S.get(o);j||(j={},S.set(o,j));var W=i.toString(),P=j[y],R=void 0;return Object(a.isRegex)(i)?(P||(P=[],j[y]=P),R={regex:i,listener:r},P.push(R)):j[W]=r,{cancel:function(){j&&(delete j[W],o&&0===Object.keys(j).length&&S.delete(o),R&&P.splice(P.indexOf(R,1)))}}}({name:n,win:r,domain:t},o);if(e.once){var d=o.handler;o.handler=Object(a.once)(function(){return s.cancel(),d.apply(this,arguments)})}if(o.window&&e.errorOnClose)var f=Object(a.safeInterval)(function(){r&&"object"===(void 0===r?"undefined":N(r))&&Object(i.isWindowClosed)(r)&&(f.cancel(),o.handleError(new Error("Post message target window is closed")))},50);return{cancel:function(){s.cancel()}}}function C(e,n,r){return"function"==typeof n&&(r=n,n={}),(n=n||{}).name=e,n.handler=r||n.handler,I(n)}function B(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];"function"==typeof n&&(r=n,n={}),n=n||{},r=r||n.handler;var t=n.errorHandler,o=new s.a(function(o,i){(n=n||{}).name=e,n.once=!0,n.handler=function(e){if(o(e),r)return r(e)},n.errorHandler=function(e){if(i(e),t)return t(e)}}),i=I(n);return o.cancel=i.cancel,o}function L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{on:function(n,r){return C(n,e,r)}}}function k(){delete window[u.i.POSTROBOT],window.removeEventListener("message",R)}c.a.on=C;var x=Object(i.getAncestor)();function U(e){var n=c.a.requestPromises.get(e);if(n)for(var r=0,t=null==n?0:n.length;r<t;r++)n[r].reject(new Error("No response from window - cleaned up"));c.a.popupWindowsByWin&&c.a.popupWindowsByWin.delete(e),c.a.remoteWindows&&c.a.remoteWindows.delete(e),c.a.requestPromises.delete(e),c.a.methods.delete(e),c.a.readyPromises.delete(e)}var F=r(22);function G(){c.a.initialized||(Object(a.addEventListener)(window,"message",R),r(8).openTunnelToOpener(),Object(o.c)()),c.a.initialized=!0}G(),r.d(n,"markWindowKnown",function(){return o.e}),r.d(n,"serializeMessage",function(){return o.i}),r.d(n,"deserializeMessage",function(){return o.a}),r.d(n,"cleanUpWindow",function(){return U}),r.d(n,"Promise",function(){return s.a}),r.d(n,"bridge",function(){return F}),r.d(n,"init",function(){return G}),r.d(n,"parent",function(){return x}),r.d(n,"send",function(){return A}),r.d(n,"request",function(){return T}),r.d(n,"sendToParent",function(){return M}),r.d(n,"client",function(){return D}),r.d(n,"on",function(){return C}),r.d(n,"listen",function(){return I}),r.d(n,"once",function(){return B}),r.d(n,"listener",function(){return L}),r.d(n,"CONFIG",function(){return u.b}),r.d(n,"disable",function(){return k}),n.default=t},function(e,n,r){"use strict";function t(e){return"[object RegExp]"===Object.prototype.toString.call(e)}n.g=u,n.f=c,n.a=d,n.c=f,n.i=l,n.n=w,n.q=E,n.r=function(e){if(function(){for(var e=0;e<b.length;e++)y(b[e])&&(b.splice(e,1),O.splice(e,1));for(var n=0;n<O.length;n++)E(O[n])&&(b.splice(n,1),O.splice(n,1))}(),e&&e.contentWindow)try{O.push(e.contentWindow),b.push(e)}catch(e){}},n.h=function(e){return(e=e||window).navigator.mockUserAgent||e.navigator.userAgent},n.e=function(e,n){for(var r=m(e),t=0,o=null==r?0:r.length;t<o;t++){var i=r[t];try{if(w(i)&&i.name===n&&-1!==r.indexOf(i))return i}catch(e){}}try{if(-1!==r.indexOf(e.frames[n]))return e.frames[n]}catch(e){}try{if(-1!==r.indexOf(e[n]))return e[n]}catch(e){}},n.l=function(e,n){return e===c(n)},n.b=_,n.j=function(e,n){var r=_(n);if(r)return r===e;if(n===e)return!1;if(g(n)===n)return!1;for(var t=0,o=m(e),i=null==o?0:o.length;t<i;t++)if(o[t]===n)return!0;return!1},n.m=function(){return Boolean(c(window))},n.k=function(){return Boolean(u(window))},n.o=function(e,n){var r=g(e)||e,t=g(n)||n;try{if(r&&t)return r===t}catch(e){}var o=v(e),i=v(n);if(S(o,i))return!0;var a=c(r),u=c(t);return!(a&&S(v(a),i)||(u&&S(v(u),o),1))},n.s=function e(n,r){if("string"==typeof n){if("string"==typeof r)return n===o.WILDCARD||r===n;if(t(r))return!1;if(Array.isArray(r))return!1}return t(n)?t(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!t(r)&&n.some(function(n){return e(n,r)}))},n.t=function(e){return Array.isArray(e)?"("+e.join(" | ")+")":t(e)?"RegExp("+e.toString():e.toString()},n.d=function(e){return e.match(/^(https?|mock|file):\/\//)?e.split("/").slice(0,3).join("/"):f()},n.p=function(e){try{if(e===window)return!0}catch(e){if(e&&e.message===i)return!0}try{if("[object Window]"===Object.prototype.toString.call(e))return!0}catch(e){if(e&&e.message===i)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===i)return!0}try{e&&e.__cross_domain_utils_window_check__}catch(e){return!0}return!1};var o={MOCK_PROTOCOL:"mock:",FILE_PROTOCOL:"file:",ABOUT_PROTOCOL:"about:",WILDCARD:"*"},i="Call was rejected by callee.\r\n";function a(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===o.ABOUT_PROTOCOL}function u(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function c(e){if(e&&!u(e))try{return e.opener}catch(e){}}function s(e){try{return e&&e.location&&e.location.href,!0}catch(e){}return!1}function d(e){var n=(e=e||window).location;if(!n)throw new Error("Can not read window location");var r=n.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE_PROTOCOL)return o.FILE_PROTOCOL+"//";if(r===o.ABOUT_PROTOCOL){var t=u(e);return t&&s(t)?d(t):o.ABOUT_PROTOCOL+"//"}var i=n.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function f(e){var n=d(e=e||window);return n&&e.mockDomain&&0===e.mockDomain.indexOf(o.MOCK_PROTOCOL)?e.mockDomain:n}function l(e){try{if(e===window)return!0}catch(e){}try{var n=Object.getOwnPropertyDescriptor(e,"location");if(n&&!1===n.enumerable)return!1}catch(e){}try{if(a(e)&&s(e))return!0}catch(e){}try{if(d(e)===d(window))return!0}catch(e){}return!1}function w(e){if(!l(e))return!1;try{if(e===window)return!0;if(a(e)&&s(e))return!0;if(f(window)===f(e))return!0}catch(e){}return!1}function h(e,n){if(!e||!n)return!1;var r=u(n);return r?r===e:-1!==function(e){var n=[];try{for(;e.parent!==e;)n.push(e.parent),e=e.parent}catch(e){}return n}(n).indexOf(e)}function m(e){var n=[],r=void 0;try{r=e.frames}catch(n){r=e}var t=void 0;try{t=r.length}catch(e){}if(0===t)return n;if(t){for(var o=0;o<t;o++){var i=void 0;try{i=r[o]}catch(e){continue}n.push(i)}return n}for(var a=0;a<100;a++){var u=void 0;try{u=r[a]}catch(e){return n}if(!u)return n;n.push(u)}return n}function p(e){for(var n=[],r=0,t=m(e),o=null==t?0:t.length;r<o;r++){var i=t[r];n.push(i);for(var a=0,u=p(i),c=null==u?0:u.length;a<c;a++){var s=u[a];n.push(s)}}return n}function g(e){if(e){try{if(e.top)return e.top}catch(e){}if(u(e)===e)return e;try{if(h(window,e)&&window.top)return window.top}catch(e){}try{if(h(e,window)&&window.top)return window.top}catch(e){}for(var n=0,r=p(e),t=null==r?0:r.length;n<t;n++){var o=r[n];try{if(o.top)return o.top}catch(e){}if(u(o)===o)return o}}}function v(e){var n=g(e);if(!n)throw new Error("Can not determine top window");return[].concat(p(n),[n])}function y(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var n=e.ownerDocument;return!(!n||!n.documentElement||n.documentElement.contains(e))}var O=[],b=[];function E(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==i}if(n&&w(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var r=function(e,n){for(var r=0;r<e.length;r++)try{if(e[r]===n)return r}catch(e){}return-1}(O,e);if(-1!==r){var t=b[r];if(t&&y(t))return!0}return!1}function _(e){return c(e=e||window)||u(e)||void 0}function S(e,n){for(var r=0,t=null==e?0:e.length;r<t;r++)for(var o=e[r],i=0,a=null==n?0:n.length;i<a;i++)if(o===n[i])return!0;return!1}},function(e,n){},function(e,n,r){"use strict";r(7),r(11)},function(e,n,r){"use strict";r(7)},function(e,n,r){"use strict";r(2),r(0)},function(e,n){},function(e,n,r){"use strict";r(7)},function(e,n,r){"use strict"},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(8);r.d(n,"openBridge",function(){return t.openBridge}),r.d(n,"linkUrl",function(){return t.linkUrl}),r.d(n,"isBridge",function(){return t.isBridge}),r.d(n,"needsBridge",function(){return t.needsBridge}),r.d(n,"needsBridgeForBrowser",function(){return t.needsBridgeForBrowser}),r.d(n,"hasBridge",function(){return t.hasBridge}),r.d(n,"needsBridgeForWin",function(){return t.needsBridgeForWin}),r.d(n,"needsBridgeForDomain",function(){return t.needsBridgeForDomain}),r.d(n,"openTunnelToOpener",function(){return t.openTunnelToOpener}),r.d(n,"destroyBridges",function(){return t.destroyBridges})}])});
//# sourceMappingURL=post-robot.ie.min.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="",r(r.s=8)}([function(e,n,r){"use strict";var t=r(9);r.d(n,"getActualDomain",function(){return t.a}),r.d(n,"getAncestor",function(){return t.b}),r.d(n,"getDomain",function(){return t.c}),r.d(n,"getUserAgent",function(){return t.d}),r.d(n,"isActuallySameDomain",function(){return t.e}),r.d(n,"isAncestor",function(){return t.f}),r.d(n,"isIframe",function(){return t.g}),r.d(n,"isPopup",function(){return t.h}),r.d(n,"isWindow",function(){return t.i}),r.d(n,"isWindowClosed",function(){return t.j}),r.d(n,"linkFrameWindow",function(){return t.k}),r.d(n,"matchDomain",function(){return t.l}),r.d(n,"stringifyDomainPattern",function(){return t.m});var o=r(10);r.n(o)},function(e,n,r){"use strict";function t(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&e instanceof window.constructor)return!1;var n={}.toString;if(n){var r=n.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}function o(){var e=void 0;if("undefined"!=typeof window)e=window;else{if("undefined"==typeof window)throw new TypeError("Can not find global");e=window}var n=e.__zalgopromise__=e.__zalgopromise__||{};return n.flushPromises=n.flushPromises||[],n.activeCount=n.activeCount||0,n.possiblyUnhandledPromiseHandlers=n.possiblyUnhandledPromiseHandlers||[],n.dispatchedErrors=n.dispatchedErrors||[],n}var i=function(){function e(n){var r=this;if(function(n,r){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var t=void 0,o=void 0,i=!1,a=!1,u=!1;try{n(function(e){u?r.resolve(e):(i=!0,t=e)},function(e){u?r.reject(e):(a=!0,o=e)})}catch(e){return void this.reject(e)}u=!0,i?this.resolve(t):a&&this.reject(o)}}return e.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(t(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},e.prototype.reject=function(e){var n=this;if(this.resolved||this.rejected)return this;if(t(e))throw new Error("Can not reject promise with another promise");if(!e){var r=e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);e=new Error("Expected reject to be called with Error, got "+r)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){n.errorHandled||function(e,n){if(-1===o().dispatchedErrors.indexOf(e)){o().dispatchedErrors.push(e),setTimeout(function(){throw e},1);for(var r=0;r<o().possiblyUnhandledPromiseHandlers.length;r++)o().possiblyUnhandledPromiseHandlers[r](e,n)}}(e,n)},1),this.dispatch(),this},e.prototype.asyncReject=function(e){this.errorHandled=!0,this.reject(e)},e.prototype.dispatch=function(){var n=this,r=this.dispatching,i=this.resolved,a=this.rejected,u=this.handlers;if(!r&&(i||a)){this.dispatching=!0,o().activeCount+=1;for(var c=function(r){var o=u[r],c=o.onSuccess,s=o.onError,f=o.promise,d=void 0;if(i)try{d=c?c(n.value):n.value}catch(e){return f.reject(e),"continue"}else if(a){if(!s)return f.reject(n.error),"continue";try{d=s(n.error)}catch(e){return f.reject(e),"continue"}}d instanceof e&&(d.resolved||d.rejected)?(d.resolved?f.resolve(d.value):f.reject(d.error),d.errorHandled=!0):t(d)?d instanceof e&&(d.resolved||d.rejected)?d.resolved?f.resolve(d.value):f.reject(d.error):d.then(function(e){f.resolve(e)},function(e){f.reject(e)}):f.resolve(d)},s=0;s<u.length;s++)c(s);u.length=0,this.dispatching=!1,o().activeCount-=1,0===o().activeCount&&e.flushQueue()}},e.prototype.then=function(n,r){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for success handler");if(r&&"function"!=typeof r&&!r.call)throw new Error("Promise.then expected a function for error handler");var t=new e;return this.handlers.push({promise:t,onSuccess:n,onError:r}),this.errorHandled=!0,this.dispatch(),t},e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.finally=function(n){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return e.try(n).then(function(){return r})},function(r){return e.try(n).then(function(){throw r})})},e.prototype.timeout=function(e,n){var r=this;if(this.resolved||this.rejected)return this;var t=setTimeout(function(){r.resolved||r.rejected||r.reject(n||new Error("Promise timed out after "+e+"ms"))},e);return this.then(function(e){return clearTimeout(t),e})},e.prototype.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.resolve=function(n){return n instanceof e?n:t(n)?new e(function(e,r){return n.then(e,r)}):(new e).resolve(n)},e.reject=function(n){return(new e).reject(n)},e.all=function(n){var r=new e,o=n.length,i=[];if(!o)return r.resolve(i),r;for(var a=function(a){var u=n[a];if(u instanceof e){if(u.resolved)return i[a]=u.value,o-=1,"continue"}else if(!t(u))return i[a]=u,o-=1,"continue";e.resolve(u).then(function(e){i[a]=e,0==(o-=1)&&r.resolve(i)},function(e){r.reject(e)})},u=0;u<n.length;u++)a(u);return 0===o&&r.resolve(i),r},e.hash=function(n){var r={};return e.all(Object.keys(n).map(function(t){return e.resolve(n[t]).then(function(e){r[t]=e})})).then(function(){return r})},e.map=function(n,r){return e.all(n.map(r))},e.onPossiblyUnhandledException=function(e){return function(e){return o().possiblyUnhandledPromiseHandlers.push(e),{cancel:function(){o().possiblyUnhandledPromiseHandlers.splice(o().possiblyUnhandledPromiseHandlers.indexOf(e),1)}}}(e)},e.try=function(n,r,t){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.try expected a function");var o=void 0;try{o=n.apply(r,t||[])}catch(n){return e.reject(n)}return e.resolve(o)},e.delay=function(n){return new e(function(e){setTimeout(e,n)})},e.isPromise=function(n){return!!(n&&n instanceof e)||t(n)},e.flush=function(){var n=new e;return o().flushPromises.push(n),0===o().activeCount&&e.flushQueue(),n},e.flushQueue=function(){var e=o().flushPromises;o().flushPromises=[];for(var n=0,r=null==e?0:e.length;n<r;n++)e[n].resolve()},e}();r.d(n,"a",function(){return i})},function(e,n,r){"use strict";r(5);var t=r(6);r.d(n,"addEventListener",function(){return t.a}),r(11),r(12),r(7);var o=r(4);r.d(n,"isRegex",function(){return o.f}),r.d(n,"noop",function(){return o.h}),r.d(n,"once",function(){return o.i}),r.d(n,"replaceObject",function(){return o.k}),r.d(n,"safeInterval",function(){return o.l}),r.d(n,"stringifyError",function(){return o.n}),r.d(n,"uniqueID",function(){return o.o}),r(13);var i=r(14);r.n(i),r(15),r(16)},function(e,n,r){"use strict";r.d({},"WeakMap",function(){return u});var t=r(0);function o(e,n){for(var r=0;r<e.length;r++)try{if(e[r]===n)return r}catch(e){}return-1}var i=Object.defineProperty,a=Date.now()%1e9,u=function(){function e(){if(function(n,r){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),a+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+a,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,n={};return Object.freeze(n),e.set(n,"__testvalue__"),"__testvalue__"===e.get(n)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}return e.prototype._cleanupClosedWindows=function(){for(var e=this.weakmap,n=this.keys,r=0;r<n.length;r++){var o=n[r];if(Object(t.isWindow)(o)&&Object(t.isWindowClosed)(o)){if(e)try{e.delete(o)}catch(e){}n.splice(r,1),this.values.splice(r,1),r-=1}}},e.prototype.isSafeToReadWrite=function(e){if(Object(t.isWindow)(e))return!1;try{e&&e.self,e&&e[this.name]}catch(e){return!1}return!0},e.prototype.set=function(e,n){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(e,n)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var t=this.name,a=e[t];a&&a[0]===e?a[1]=n:i(e,t,{value:[e,n],writable:!0})}else{this._cleanupClosedWindows();var u=this.keys,c=this.values,s=o(u,e);-1===s?(u.push(e),c.push(n)):c[s]=n}},e.prototype.get=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{if(n.has(e))return n.get(e)}catch(e){delete this.weakmap}if(!this.isSafeToReadWrite(e)){this._cleanupClosedWindows();var r=o(this.keys,e);if(-1===r)return;return this.values[r]}var t=e[this.name];if(t&&t[0]===e)return t[1]},e.prototype.delete=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];r&&r[0]===e&&(r[0]=r[1]=void 0)}else{this._cleanupClosedWindows();var t=this.keys,i=o(t,e);-1!==i&&(t.splice(i,1),this.values.splice(i,1))}},e.prototype.has=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{return n.has(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];return!(!r||r[0]!==e)}return this._cleanupClosedWindows(),-1!==o(this.keys,e)},e.prototype.getOrSet=function(e,n){if(this.has(e))return this.get(e);var r=n();return this.set(e,r),r},e}();r.d(n,"a",function(){return u})},function(e,n,r){"use strict";n.o=a,n.d=function(){if("undefined"!=typeof window)return window;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("No global found")},n.g=function(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=new o.a;function i(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];var u=t.getOrSet(r.thisNamespace?this:e,function(){return{}}),s=c(o),f=r.time;if(u[s]&&f&&Date.now()-u[s].time<f&&delete u[s],u[s])return u[s].value;i.__calling__=!0;var d=Date.now(),l=e.apply(this,arguments);return i.__calling__=!1,u[s]={time:d,value:l},u[s].value}return i.reset=function(){t.delete(r.thisNamespace?n:e)},r.name&&(i.displayName=r.name+":memoized"),i},n.j=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};function r(){return t.a.try(e,this,arguments)}return n.name&&(r.displayName=n.name+":promisified"),r},n.e=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],t=e.__inline_memoize_cache__=e.__inline_memoize_cache__||{},o=c(r);return t.hasOwnProperty(o)?t[o]:t[o]=n.apply(void 0,r)},n.h=function(){},n.i=function(e){var n=!1;return function(){if(!n)return n=!0,e.apply(this,arguments)}},n.n=function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+Object.prototype.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var t=n&&n.stack,o=n&&n.message;if(t&&o)return-1!==t.indexOf(o)?t:o+"\n"+t;if(t)return t;if(o)return o}return"function"==typeof n.toString?n.toString():Object.prototype.toString.call(n)}catch(n){return"Error while stringifying error: "+e(n,r+1)}},n.m=function(e){return"string"==typeof e?e:e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)},n.c=function(e,n){if(!n)return e;if(Object.assign)return Object.assign(e,n);for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r]);return e},n.l=function(e,n){var r=void 0;return function t(){r=setTimeout(function(){e(),t()},n)}(),{cancel:function(){clearTimeout(r)}}},n.a=function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},n.k=function e(n,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(Array.isArray(n)){for(var o=n.length,i=[],a=function(o){s(i,o,function(){var i=t?t+"."+o:""+o,a=n[o],u=r(a,o,i);return(d(u)||Array.isArray(u))&&(u=e(u,r,i)),u})},u=0;u<o;u++)a(u);return i}if(d(n)){var c={},f=function(o){if(!n.hasOwnProperty(o))return"continue";s(c,o,function(){var i=t?t+"."+o:""+o,a=n[o],u=r(a,o,i);return(d(u)||Array.isArray(u))&&(u=e(u,r,i)),u})};for(var l in n)f(l);return c}throw new Error("Pass an object or array")},n.b=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=void 0;return function(){var t=this,o=arguments;clearTimeout(r),r=setTimeout(function(){return e.apply(t,o)},n)}},n.f=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)};var t=r(1),o=r(3),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function a(){var e,n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+(e=(new Date).toISOString().slice(11,19).replace("T","."),window.btoa(e)).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var u=void 0;function c(e){try{return JSON.stringify(Array.prototype.slice.call(e),function(e,n){return"function"==typeof n?"memoize["+function(e){if(u=u||new o.a,null===e||void 0===e||"object"!==(void 0===e?"undefined":i(e))&&"function"!=typeof e)throw new Error("Invalid object");var n=u.get(e);return n||(n=(void 0===e?"undefined":i(e))+":"+a(),u.set(e,n)),n}(n)+"]":n})}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}function s(e,n,r){if(Array.isArray(e)){if("number"!=typeof n)throw new TypeError("Array key must be number")}else if("object"===(void 0===e?"undefined":i(e))&&null!==e&&"string"!=typeof n)throw new TypeError("Object key must be string");Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get:function(){delete e[n];var t=r();return e[n]=t,t},set:function(r){delete e[n],e[n]=r}})}function f(e){return"object"===(void 0===(n=e)?"undefined":i(n))&&null!==n&&"[object Object]"===Object.prototype.toString.call(e);var n}function d(e){if(!f(e))return!1;var n=e.constructor;if("function"!=typeof n)return!1;var r=n.prototype;return!!f(r)&&!!r.hasOwnProperty("isPrototypeOf")}},function(e,n,r){"use strict";n.a=function(){return!!(window.navigator.mockUserAgent||window.navigator.userAgent).match(/Android|webOS|iPhone|iPad|iPod|bada|Symbian|Palm|CriOS|BlackBerry|IEMobile|WindowsMobile|Opera Mini/i)}},function(e,n,r){"use strict";r(1),r(0),r(3);var t=r(4);r(5),n.b=function e(){return Object(t.e)(e,function(){try{if("undefined"==typeof window)return!1;if(window.localStorage){var e=Math.random().toString();window.localStorage.setItem("__test__localStorage__",e);var n=window.localStorage.getItem("__test__localStorage__");if(window.localStorage.removeItem("__test__localStorage__"),e===n)return!0}}catch(e){}return!1})},n.a=function(e,n,r){return e.addEventListener(n,r),{cancel:function(){e.removeEventListener(n,r)}}},"function"==typeof Symbol&&Symbol.iterator,Object.assign,Object.create(Error.prototype)},function(e,n,r){"use strict";n.a=function e(n){var r=n.name,i=n.version,a=void 0===i?"latest":i,u=n.lifetime,c=void 0===u?3e5:u;return Object(t.e)(e,function(){var e="__"+r+"_"+a+"_storage__",n=void 0;function i(r){var i=Object(o.b)(),a=void 0;if(n&&(a=n),!a&&i){var u=window.localStorage.getItem(e);u&&(a=JSON.parse(u))}a||(a=Object(t.d)()[e]),a||(a={id:Object(t.o)()}),a.id||(a.id=Object(t.o)()),n=a;var c=r(a);return i?window.localStorage.setItem(e,JSON.stringify(a)):Object(t.d)()[e]=a,n=null,c}function u(e){return i(function(n){var r=n.__session__,o=Date.now();return r&&o-r.created>c&&(r=null),r||(r={guid:Object(t.o)(),created:o}),n.__session__=r,e(r)})}return{getState:i,getID:function(){return i(function(e){return e.id})},getSessionState:function(e){return u(function(n){return n.state=n.state||{},e(n.state)})},getSessionID:function(){return u(function(e){return e.guid})}}},[{name:r,version:a,lifetime:c}])};var t=r(4),o=r(6)},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t={};r.d(t,"markWindowKnown",function(){return O}),r.d(t,"cleanUpWindow",function(){return K}),r.d(t,"Promise",function(){return f.a}),r.d(t,"bridge",function(){return Z}),r.d(t,"init",function(){return z}),r.d(t,"parent",function(){return F}),r.d(t,"send",function(){return N}),r.d(t,"request",function(){return M}),r.d(t,"sendToParent",function(){return k}),r.d(t,"client",function(){return x}),r.d(t,"on",function(){return H}),r.d(t,"listen",function(){return U}),r.d(t,"once",function(){return B}),r.d(t,"listener",function(){return q}),r.d(t,"CONFIG",function(){return c}),r.d(t,"CONSTANTS",function(){return a}),r.d(t,"disable",function(){return Y});var o,i=r(0),a={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",HELLO:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method",ERROR:"postrobot_error",PROMISE:"postrobot_promise",ZALGO_PROMISE:"postrobot_zalgo_promise",REGEX:"regex"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",BRIDGE:"postrobot_bridge",GLOBAL:"postrobot_global"},MOCK_PROTOCOL:"mock:",FILE_PROTOCOL:"file:",BRIDGE_NAME_PREFIX:"__postrobot_bridge__",POSTROBOT_PROXY:"__postrobot_proxy__",WILDCARD:"*"},u={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},c=(Object.keys(u).map(function(e){return u[e]}),{ALLOW_POSTMESSAGE_POPUP:!("__ALLOW_POSTMESSAGE_POPUP__"in window)||window.__ALLOW_POSTMESSAGE_POPUP__,BRIDGE_TIMEOUT:5e3,CHILD_WINDOW_TIMEOUT:5e3,ACK_TIMEOUT:2e3,ACK_TIMEOUT_KNOWN:1e4,RES_TIMEOUT:-1,ALLOWED_POST_MESSAGE_METHODS:(o={},o[a.SEND_STRATEGIES.POST_MESSAGE]=!0,o[a.SEND_STRATEGIES.BRIDGE]=!0,o[a.SEND_STRATEGIES.GLOBAL]=!0,o)});0===window.location.href.indexOf(a.FILE_PROTOCOL)&&(c.ALLOW_POSTMESSAGE_POPUP=!0);var s=r(3),f=r(1),d=r(2),l=window[a.WINDOW_PROPS.POSTROBOT]=window[a.WINDOW_PROPS.POSTROBOT]||{};l.registerSelf=function(){};var w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};l.methods=l.methods||new s.a;var h=Object(d.once)(function(){l.on(a.POST_MESSAGE_NAMES.METHOD,{origin:a.WILDCARD},function(e){var n=e.source,r=e.origin,t=e.data,o=l.methods.get(n);if(!o)throw new Error("Could not find any methods this window has privileges to call");var a=o[t.id];if(!a)throw new Error("Could not find method with id: "+t.id);if(!Object(i.matchDomain)(a.domain,r))throw new Error("Method domain "+a.domain+" does not match origin "+r);return f.a.try(function(){return a.method.apply({source:n,origin:r,data:t},t.args)}).then(function(e){return{result:e,id:t.id,name:t.name}})})});function p(e,n){return"object"===(void 0===e?"undefined":w(e))&&null!==e&&e.__type__===n}function m(e,n,r,t){var o=Object(d.uniqueID)(),i=l.methods.get(e);return i||(i={},l.methods.set(e,i)),i[o]={domain:n,method:r},{__type__:a.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:t}}function _(e,n,r){function t(){var t=Array.prototype.slice.call(arguments);return l.send(e,a.POST_MESSAGE_NAMES.METHOD,{id:r.__id__,name:r.__name__,args:t},{domain:n,timeout:-1}).then(function(e){return e.data.result},function(e){throw e})}return t.__name__=r.__name__,t.__xdomain__=!0,t.source=e,t.origin=n,t}function v(e,n,r){return new f.a(function(t,o){return _(e,n,r.__then__)(t,o)})}function y(e){return l.send(e,a.POST_MESSAGE_NAMES.HELLO,{},{domain:a.WILDCARD,timeout:-1}).then(function(e){return{origin:e.origin}})}function O(e){l.knownWindows.set(e,!0)}l.readyPromises=l.readyPromises||new s.a,l.knownWindows=l.knownWindows||new s.a;var E={};E[a.SEND_STRATEGIES.POST_MESSAGE]=function(e,n,r){(Array.isArray(r)?r:"string"==typeof r?[r]:[a.WILDCARD]).map(function(n){if(0===n.indexOf(a.MOCK_PROTOCOL)){if(window.location.protocol===a.FILE_PROTOCOL)return a.WILDCARD;if(!Object(i.isActuallySameDomain)(e))throw new Error("Attempting to send messsage to mock domain "+n+", but window is actually cross-domain");return Object(i.getActualDomain)(e)}return 0===n.indexOf(a.FILE_PROTOCOL)?a.WILDCARD:n}).forEach(function(r){return e.postMessage(n,r)})};var g=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};function S(e,n,r){return f.a.try(function(){var t;if(n=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=Object(d.uniqueID)(),o=Object(i.isPopup)()?a.WINDOW_TYPES.POPUP:Object(i.isIframe)()?a.WINDOW_TYPES.IFRAME:a.WINDOW_TYPES.FULLPAGE,u=Object(i.getDomain)(window);return g({},n,r,{sourceDomain:u,id:n.id||t,windowType:o})}(e,n,{data:function(e,n,r){return Object(d.replaceObject)({obj:r},function(r,t){return"function"==typeof r?m(e,n,r,t.toString()):r instanceof Error?(o=r,{__type__:a.SERIALIZATION_TYPES.ERROR,__message__:Object(d.stringifyError)(o),__code__:o.code}):window.Promise&&r instanceof window.Promise?function(e,n,r,t){return{__type__:a.SERIALIZATION_TYPES.PROMISE,__then__:m(e,n,function(e,n){return r.then(e,n)},t+".then")}}(e,n,r,t.toString()):f.a.isPromise(r)?function(e,n,r,t){return{__type__:a.SERIALIZATION_TYPES.ZALGO_PROMISE,__then__:m(e,n,function(e,n){return r.then(e,n)},t+".then")}}(e,n,r,t.toString()):Object(d.isRegex)(r)?(i=r,{__type__:a.SERIALIZATION_TYPES.REGEX,__source__:i.source}):r;var o,i}).obj}(e,r,n.data),domain:r}),Object(i.isWindowClosed)(e))throw new Error("Window is closed");var o=[],u=JSON.stringify(((t={})[a.WINDOW_PROPS.POSTROBOT]=n,t),null,2);return f.a.map(Object.keys(E),function(n){return f.a.try(function(){if(!c.ALLOWED_POST_MESSAGE_METHODS[n])throw new Error("Strategy disallowed: "+n);return E[n](e,u,r)}).then(function(){return o.push(n+": success"),!0},function(e){return o.push(n+": "+Object(d.stringifyError)(e)+"\n"),!1})}).then(function(e){var r=e.some(Boolean),t=n.type+" "+n.name+" "+(r?"success":"error")+":\n - "+o.join("\n - ")+"\n";if(!r)throw new Error(t)})})}l.responseListeners=l.responseListeners||{},l.requestListeners=l.requestListeners||{},l.WINDOW_WILDCARD=l.WINDOW_WILDCARD||new function(){},l.erroredResponseListeners=l.erroredResponseListeners||{};var b,P="__domain_regex__";function A(e){return l.responseListeners[e]}function T(e){delete l.responseListeners[e]}function j(e){return Boolean(l.erroredResponseListeners[e])}function R(e){var n=e.name,r=e.win,t=e.domain;if(r===a.WILDCARD&&(r=null),t===a.WILDCARD&&(t=null),!n)throw new Error("Name required to get request listener");var o=l.requestListeners[n];if(o)for(var u=0,c=[r,l.WINDOW_WILDCARD],s=null==c?0:c.length;u<s;u++){var f=c[u],d=f&&o.get(f);if(d){if(t&&"string"==typeof t){if(d[t])return d[t];if(d[P])for(var w=0,h=d[P],p=null==h?0:h.length;w<p;w++){var m=h[w],_=m.regex,v=m.listener;if(Object(i.matchDomain)(_,t))return v}}if(d[a.WILDCARD])return d[a.WILDCARD]}}}var I=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},W=((b={})[a.POST_MESSAGE_TYPE.ACK]=function(e,n,r){if(!j(r.hash)){var t=A(r.hash);if(!t)throw new Error("No handler found for post message ack for message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Ack origin "+n+" does not match domain "+t.domain.toString());t.ack=!0}},b[a.POST_MESSAGE_TYPE.REQUEST]=function(e,n,r){var t=R({name:r.name,win:e,domain:n});function o(t){return r.fireAndForget||Object(i.isWindowClosed)(e)?f.a.resolve():S(e,I({target:r.originalSource,hash:r.hash,name:r.name},t),n)}return f.a.all([o({type:a.POST_MESSAGE_TYPE.ACK}),f.a.try(function(){if(!t)throw new Error("No handler found for post message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Request origin "+n+" does not match domain "+t.domain.toString());var o=r.data;return t.handler({source:e,origin:n,data:o})}).then(function(e){return o({type:a.POST_MESSAGE_TYPE.RESPONSE,ack:a.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){var n=Object(d.stringifyError)(e).replace(/^Error: /,""),r=e.code;return o({type:a.POST_MESSAGE_TYPE.RESPONSE,ack:a.POST_MESSAGE_ACK.ERROR,error:n,code:r})})]).then(d.noop).catch(function(e){if(t&&t.handleError)return t.handleError(e);throw e})},b[a.POST_MESSAGE_TYPE.RESPONSE]=function(e,n,r){if(!j(r.hash)){var t=A(r.hash);if(!t)throw new Error("No handler found for post message response for message: "+r.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(t.domain,n))throw new Error("Response origin "+n+" does not match domain "+Object(i.stringifyDomainPattern)(t.domain));if(T(r.hash),r.ack===a.POST_MESSAGE_ACK.ERROR){var o=new Error(r.error);return r.code&&(o.code=r.code),t.respond(o,null)}if(r.ack===a.POST_MESSAGE_ACK.SUCCESS){var u=r.data||r.response;return t.respond(null,{source:e,origin:n,data:u})}}},b),D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function L(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(e){return}var n=e.source,r=e.origin,t=function(e){var n=void 0;try{n=JSON.parse(e)}catch(e){return}if(n&&"object"===(void 0===n?"undefined":D(n))&&null!==n&&(n=n[a.WINDOW_PROPS.POSTROBOT])&&"object"===(void 0===n?"undefined":D(n))&&null!==n&&n.type&&"string"==typeof n.type&&W[n.type])return n}(e.data);if(t){if(O(n),!t.sourceDomain||"string"!=typeof t.sourceDomain)throw new Error("Expected message to have sourceDomain");0!==t.sourceDomain.indexOf(a.MOCK_PROTOCOL)&&0!==t.sourceDomain.indexOf(a.FILE_PROTOCOL)||(r=t.sourceDomain),-1===l.receivedMessages.indexOf(t.id)&&(l.receivedMessages.push(t.id),Object(i.isWindowClosed)(n)&&!t.fireAndForget||(t.data&&(t.data=function(e,n,r){return Object(d.replaceObject)({obj:r},function(r){return"object"!==(void 0===r?"undefined":w(r))||null===r?r:p(r,a.SERIALIZATION_TYPES.METHOD)?_(e,n,r):p(r,a.SERIALIZATION_TYPES.ERROR)?(t=r,o=new Error(t.__message__),t.__code__&&(o.code=t.__code__),o):p(r,a.SERIALIZATION_TYPES.PROMISE)?function(e,n,r){return window.Promise?new window.Promise(function(t,o){return _(e,n,r.__then__)(t,o)}):v(e,n,r)}(e,n,r):p(r,a.SERIALIZATION_TYPES.ZALGO_PROMISE)?v(e,n,r):p(r,a.SERIALIZATION_TYPES.REGEX)?function(e,n,r){return new RegExp(r.__source__)}(0,0,r):r;var t,o}).obj}(n,r,t.data)),W[t.type](n,r,t)))}}function C(e){try{Object(d.noop)(e.source)}catch(e){return}L({source:e.source||e.sourceElement,origin:e.origin||e.originalEvent&&e.originalEvent.origin,data:e.data})}function M(e){return f.a.try(function(){if(!e.name)throw new Error("Expected options.name");var n=e.name,r=void 0,t=void 0;if("string"==typeof e.window){var o=document.getElementById(e.window);if(!o)throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be a valid element id");if("iframe"!==o.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(!o.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");r=o.contentWindow}else if(e.window instanceof HTMLIFrameElement){if("iframe"!==e.window.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(e.window&&!e.window.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");e.window&&e.window.contentWindow&&(r=e.window.contentWindow)}else r=e.window;if(!r)throw new Error("Expected options.window to be a window object, iframe, or iframe element id.");var u=r;t=e.domain||a.WILDCARD;var s=e.name+"_"+Object(d.uniqueID)();if(Object(i.isWindowClosed)(u))throw new Error("Target window is closed");var w=!1,h=l.requestPromises.get(u);h||(h=[],l.requestPromises.set(u,h));var p=f.a.try(function(){if(Object(i.isAncestor)(window,u))return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Window",t=l.readyPromises.get(e);return t||(t=new f.a,l.readyPromises.set(e,t),-1!==n&&setTimeout(function(){return t.reject(new Error(r+" did not load after "+n+"ms"))},n),t)}(u,e.timeout||c.CHILD_WINDOW_TIMEOUT)}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(d.isRegex)(t)&&!e)return y(u)}).then(function(){var r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(d.isRegex)(t)){if(!Object(i.matchDomain)(t,r))throw new Error("Remote window domain "+r+" does not match regex: "+t.toString());t=r}if("string"!=typeof t&&!Array.isArray(t))throw new TypeError("Expected domain to be a string or array");var o=t;return new f.a(function(r,t){var f=void 0;if(e.fireAndForget||function(e,n){l.responseListeners[e]=n}(s,f={name:n,window:u,domain:o,respond:function(e,n){e||(w=!0,h.splice(h.indexOf(p,1))),e?t(e):r(n)}}),S(u,{type:a.POST_MESSAGE_TYPE.REQUEST,hash:s,name:n,data:e.data,fireAndForget:e.fireAndForget},o).catch(t),e.fireAndForget)return r();var d=function(e){return l.knownWindows.get(e)}(u)?c.ACK_TIMEOUT_KNOWN:c.ACK_TIMEOUT,m=e.timeout||c.RES_TIMEOUT,_=d,v=m,y=100;setTimeout(function e(){if(!w){if(Object(i.isWindowClosed)(u))return f.ack?t(new Error("Window closed for "+n+" before response")):t(new Error("Window closed for "+n+" before ack"));if(_=Math.max(_-y,0),-1!==v&&(v=Math.max(v-y,0)),f.ack){if(-1===v)return;y=Math.min(v,2e3)}else{if(0===_)return t(new Error("No ack for postMessage "+n+" in "+Object(i.getDomain)()+" in "+d+"ms"));if(0===v)return t(new Error("No response for postMessage "+n+" in "+Object(i.getDomain)()+" in "+m+"ms"))}setTimeout(e,y)}},y)})});return p.catch(function(){!function(e){l.erroredResponseListeners[e]=!0}(s),T(s)}),h.push(p),p})}function N(e,n,r,t){return(t=t||{}).window=e,t.name=n,t.data=r,M(t)}function k(e,n,r){var t=Object(i.getAncestor)();return t?N(t,e,n,r):new f.a(function(e,n){return n(new Error("Window does not have a parent"))})}function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.window)throw new Error("Expected options.window");var n=e.window;return{send:function(r,t){return N(n,r,t,e)}}}l.receivedMessages=l.receivedMessages||[],l.receiveMessage=L,l.requestPromises=l.requestPromises||new s.a,l.send=N;var G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function U(e){if(!e.name)throw new Error("Expected options.name");if(!e.handler)throw new Error("Expected options.handler");var n=e.name,r=e.window,t=e.domain,o={handler:e.handler,handleError:e.errorHandler||function(e){throw e},window:r,domain:t||a.WILDCARD,name:n},u=function e(n,r){var t=n.name,o=n.win,i=n.domain;if(!t||"string"!=typeof t)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var u=[],c=0,f=o,w=null==f?0:f.length;c<w;c++){var h=f[c];u.push(e({name:t,domain:i,win:h},r))}return{cancel:function(){for(var e=0,n=null==u?0:u.length;e<n;e++)u[e].cancel()}}}if(Array.isArray(i)){for(var p=[],m=0,_=i,v=null==_?0:_.length;m<v;m++){var y=_[m];p.push(e({name:t,win:o,domain:y},r))}return{cancel:function(){for(var e=0,n=null==p?0:p.length;e<n;e++)p[e].cancel()}}}var O=R({name:t,win:o,domain:i});if(o&&o!==a.WILDCARD||(o=l.WINDOW_WILDCARD),i=i||a.WILDCARD,O)throw o&&i?new Error("Request listener already exists for "+t+" on domain "+i.toString()+" for "+(o===l.WINDOW_WILDCARD?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+t+" for "+(o===l.WINDOW_WILDCARD?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+t+" on domain "+i.toString()):new Error("Request listener already exists for "+t);var E=l.requestListeners,g=E[t];g||(g=new s.a,E[t]=g);var S=g.get(o);S||(S={},g.set(o,S));var b=i.toString(),A=S[P],T=void 0;return Object(d.isRegex)(i)?(A||(A=[],S[P]=A),T={regex:i,listener:r},A.push(T)):S[b]=r,{cancel:function(){S&&(delete S[b],o&&0===Object.keys(S).length&&g.delete(o),T&&A.splice(A.indexOf(T,1)))}}}({name:n,win:r,domain:t},o);if(e.once){var c=o.handler;o.handler=Object(d.once)(function(){return u.cancel(),c.apply(this,arguments)})}if(o.window&&e.errorOnClose)var f=Object(d.safeInterval)(function(){r&&"object"===(void 0===r?"undefined":G(r))&&Object(i.isWindowClosed)(r)&&(f.cancel(),o.handleError(new Error("Post message target window is closed")))},50);return{cancel:function(){u.cancel()}}}function H(e,n,r){return"function"==typeof n&&(r=n,n={}),(n=n||{}).name=e,n.handler=r||n.handler,U(n)}function B(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];"function"==typeof n&&(r=n,n={}),n=n||{},r=r||n.handler;var t=n.errorHandler,o=new f.a(function(o,i){(n=n||{}).name=e,n.once=!0,n.handler=function(e){if(o(e),r)return r(e)},n.errorHandler=function(e){if(i(e),t)return t(e)}}),i=U(n);return o.cancel=i.cancel,o}function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{on:function(n,r){return H(n,e,r)}}}function Y(){delete window[a.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",C)}l.on=H;var F=Object(i.getAncestor)();function K(e){var n=l.requestPromises.get(e);if(n)for(var r=0,t=null==n?0:n.length;r<t;r++)n[r].reject(new Error("No response from window - cleaned up"));l.popupWindowsByWin&&l.popupWindowsByWin.delete(e),l.remoteWindows&&l.remoteWindows.delete(e),l.requestPromises.delete(e),l.methods.delete(e),l.readyPromises.delete(e)}var Z=null;function z(){l.initialized||(Object(d.addEventListener)(window,"message",C),function(){var e;e=function(e){var n=e.source,r=e.origin,t=l.readyPromises.get(n)||new f.a;t.resolve({origin:r}),l.readyPromises.set(n,t)},l.on(a.POST_MESSAGE_NAMES.HELLO,{domain:a.WILDCARD},function(n){var r=n.source,t=n.origin;return e({source:r,origin:t})});var n=Object(i.getAncestor)();n&&y(n).catch(d.noop)}(),h({on:H,send:N})),l.initialized=!0}z(),r.d(n,"markWindowKnown",function(){return O}),r.d(n,"cleanUpWindow",function(){return K}),r.d(n,"Promise",function(){return f.a}),r.d(n,"bridge",function(){return Z}),r.d(n,"init",function(){return z}),r.d(n,"parent",function(){return F}),r.d(n,"send",function(){return N}),r.d(n,"request",function(){return M}),r.d(n,"sendToParent",function(){return k}),r.d(n,"client",function(){return x}),r.d(n,"on",function(){return H}),r.d(n,"listen",function(){return U}),r.d(n,"once",function(){return B}),r.d(n,"listener",function(){return q}),r.d(n,"CONFIG",function(){return c}),r.d(n,"CONSTANTS",function(){return a}),r.d(n,"disable",function(){return Y}),n.default=t},function(e,n,r){"use strict";function t(e){return"[object RegExp]"===Object.prototype.toString.call(e)}n.a=f,n.c=d,n.e=l,n.j=v,n.k=function(e){if(function(){for(var e=0;e<_.length;e++)p(_[e])&&(_.splice(e,1),m.splice(e,1));for(var n=0;n<m.length;n++)v(m[n])&&(_.splice(n,1),m.splice(n,1))}(),e&&e.contentWindow)try{m.push(e.contentWindow),_.push(e)}catch(e){}},n.d=function(e){return(e=e||window).navigator.mockUserAgent||e.navigator.userAgent},n.b=y,n.f=function(e,n){var r=y(n);if(r)return r===e;if(n===e)return!1;if(function(e){if(e){try{if(e.top)return e.top}catch(e){}if(u(e)===e)return e;try{if(w(window,e)&&window.top)return window.top}catch(e){}try{if(w(e,window)&&window.top)return window.top}catch(e){}for(var n=0,r=function e(n){for(var r=[],t=0,o=h(n),i=null==o?0:o.length;t<i;t++){var a=o[t];r.push(a);for(var u=0,c=e(a),s=null==c?0:c.length;u<s;u++){var f=c[u];r.push(f)}}return r}(e),t=null==r?0:r.length;n<t;n++){var o=r[n];try{if(o.top)return o.top}catch(e){}if(u(o)===o)return o}}}(n)===n)return!1;for(var t=0,o=h(e),i=null==o?0:o.length;t<i;t++)if(o[t]===n)return!0;return!1},n.h=function(){return Boolean(c(window))},n.g=function(){return Boolean(u(window))},n.l=function e(n,r){if("string"==typeof n){if("string"==typeof r)return n===o.WILDCARD||r===n;if(t(r))return!1;if(Array.isArray(r))return!1}return t(n)?t(r)?n.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(n)):!!Array.isArray(n)&&(Array.isArray(r)?JSON.stringify(n)===JSON.stringify(r):!t(r)&&n.some(function(n){return e(n,r)}))},n.m=function(e){return Array.isArray(e)?"("+e.join(" | ")+")":t(e)?"RegExp("+e.toString():e.toString()},n.i=function(e){try{if(e===window)return!0}catch(e){if(e&&e.message===i)return!0}try{if("[object Window]"===Object.prototype.toString.call(e))return!0}catch(e){if(e&&e.message===i)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===i)return!0}try{e&&e.__cross_domain_utils_window_check__}catch(e){return!0}return!1};var o={MOCK_PROTOCOL:"mock:",FILE_PROTOCOL:"file:",ABOUT_PROTOCOL:"about:",WILDCARD:"*"},i="Call was rejected by callee.\r\n";function a(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===o.ABOUT_PROTOCOL}function u(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function c(e){if(e&&!u(e))try{return e.opener}catch(e){}}function s(e){try{return e&&e.location&&e.location.href,!0}catch(e){}return!1}function f(e){var n=(e=e||window).location;if(!n)throw new Error("Can not read window location");var r=n.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.FILE_PROTOCOL)return o.FILE_PROTOCOL+"//";if(r===o.ABOUT_PROTOCOL){var t=u(e);return t&&s(t)?f(t):o.ABOUT_PROTOCOL+"//"}var i=n.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function d(e){var n=f(e=e||window);return n&&e.mockDomain&&0===e.mockDomain.indexOf(o.MOCK_PROTOCOL)?e.mockDomain:n}function l(e){try{if(e===window)return!0}catch(e){}try{var n=Object.getOwnPropertyDescriptor(e,"location");if(n&&!1===n.enumerable)return!1}catch(e){}try{if(a(e)&&s(e))return!0}catch(e){}try{if(f(e)===f(window))return!0}catch(e){}return!1}function w(e,n){if(!e||!n)return!1;var r=u(n);return r?r===e:-1!==function(e){var n=[];try{for(;e.parent!==e;)n.push(e.parent),e=e.parent}catch(e){}return n}(n).indexOf(e)}function h(e){var n=[],r=void 0;try{r=e.frames}catch(n){r=e}var t=void 0;try{t=r.length}catch(e){}if(0===t)return n;if(t){for(var o=0;o<t;o++){var i=void 0;try{i=r[o]}catch(e){continue}n.push(i)}return n}for(var a=0;a<100;a++){var u=void 0;try{u=r[a]}catch(e){return n}if(!u)return n;n.push(u)}return n}function p(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var n=e.ownerDocument;return!(!n||!n.documentElement||n.documentElement.contains(e))}var m=[],_=[];function v(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==i}if(n&&function(e){if(!l(e))return!1;try{if(e===window)return!0;if(a(e)&&s(e))return!0;if(d(window)===d(e))return!0}catch(e){}return!1}(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var r=function(e,n){for(var r=0;r<e.length;r++)try{if(e[r]===n)return r}catch(e){}return-1}(m,e);if(-1!==r){var t=_[r];if(t&&p(t))return!0}return!1}function y(e){return c(e=e||window)||u(e)||void 0}},function(e,n){},function(e,n,r){"use strict";r(4),r(7)},function(e,n,r){"use strict";r(4)},function(e,n,r){"use strict";r(1),r(0)},function(e,n){},function(e,n,r){"use strict";r(4)},function(e,n,r){"use strict"}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=8)}([function(e,n,t){"use strict";var r=t(9);t.d(n,"getActualDomain",function(){return r.a}),t.d(n,"getAncestor",function(){return r.b}),t.d(n,"getDomain",function(){return r.c}),t.d(n,"getUserAgent",function(){return r.d}),t.d(n,"isActuallySameDomain",function(){return r.e}),t.d(n,"isAncestor",function(){return r.f}),t.d(n,"isIframe",function(){return r.g}),t.d(n,"isPopup",function(){return r.h}),t.d(n,"isWindow",function(){return r.i}),t.d(n,"isWindowClosed",function(){return r.j}),t.d(n,"linkFrameWindow",function(){return r.k}),t.d(n,"matchDomain",function(){return r.l}),t.d(n,"stringifyDomainPattern",function(){return r.m});var o=t(10);t.n(o)},function(e,n,t){"use strict";function r(e){try{if(!e)return!1;if("undefined"!=typeof Promise&&e instanceof Promise)return!0;if("undefined"!=typeof window&&window.Window&&e instanceof window.Window)return!1;if("undefined"!=typeof window&&window.constructor&&e instanceof window.constructor)return!1;var n={}.toString;if(n){var t=n.call(e);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}function o(){var e=void 0;if("undefined"!=typeof window)e=window;else{if("undefined"==typeof window)throw new TypeError("Can not find global");e=window}var n=e.__zalgopromise__=e.__zalgopromise__||{};return n.flushPromises=n.flushPromises||[],n.activeCount=n.activeCount||0,n.possiblyUnhandledPromiseHandlers=n.possiblyUnhandledPromiseHandlers||[],n.dispatchedErrors=n.dispatchedErrors||[],n}var i=function(){function e(n){var t=this;if(function(n,t){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var r=void 0,o=void 0,i=!1,a=!1,u=!1;try{n(function(e){u?t.resolve(e):(i=!0,r=e)},function(e){u?t.reject(e):(a=!0,o=e)})}catch(e){return void this.reject(e)}u=!0,i?this.resolve(r):a&&this.reject(o)}}return e.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(r(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},e.prototype.reject=function(e){var n=this;if(this.resolved||this.rejected)return this;if(r(e))throw new Error("Can not reject promise with another promise");if(!e){var t=e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);e=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){n.errorHandled||function(e,n){if(-1===o().dispatchedErrors.indexOf(e)){o().dispatchedErrors.push(e),setTimeout(function(){throw e},1);for(var t=0;t<o().possiblyUnhandledPromiseHandlers.length;t++)o().possiblyUnhandledPromiseHandlers[t](e,n)}}(e,n)},1),this.dispatch(),this},e.prototype.asyncReject=function(e){this.errorHandled=!0,this.reject(e)},e.prototype.dispatch=function(){var n=this,t=this.dispatching,i=this.resolved,a=this.rejected,u=this.handlers;if(!t&&(i||a)){this.dispatching=!0,o().activeCount+=1;for(var c=function(t){var o=u[t],c=o.onSuccess,s=o.onError,f=o.promise,d=void 0;if(i)try{d=c?c(n.value):n.value}catch(e){return f.reject(e),"continue"}else if(a){if(!s)return f.reject(n.error),"continue";try{d=s(n.error)}catch(e){return f.reject(e),"continue"}}d instanceof e&&(d.resolved||d.rejected)?(d.resolved?f.resolve(d.value):f.reject(d.error),d.errorHandled=!0):r(d)?d instanceof e&&(d.resolved||d.rejected)?d.resolved?f.resolve(d.value):f.reject(d.error):d.then(function(e){f.resolve(e)},function(e){f.reject(e)}):f.resolve(d)},s=0;s<u.length;s++)c(s);u.length=0,this.dispatching=!1,o().activeCount-=1,0===o().activeCount&&e.flushQueue()}},e.prototype.then=function(n,t){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for success handler");if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.then expected a function for error handler");var r=new e;return this.handlers.push({promise:r,onSuccess:n,onError:t}),this.errorHandled=!0,this.dispatch(),r},e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.finally=function(n){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.finally expected a function");return this.then(function(t){return e.try(n).then(function(){return t})},function(t){return e.try(n).then(function(){throw t})})},e.prototype.timeout=function(e,n){var t=this;if(this.resolved||this.rejected)return this;var r=setTimeout(function(){t.resolved||t.rejected||t.reject(n||new Error("Promise timed out after "+e+"ms"))},e);return this.then(function(e){return clearTimeout(r),e})},e.prototype.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.resolve=function(n){return n instanceof e?n:r(n)?new e(function(e,t){return n.then(e,t)}):(new e).resolve(n)},e.reject=function(n){return(new e).reject(n)},e.all=function(n){var t=new e,o=n.length,i=[];if(!o)return t.resolve(i),t;for(var a=function(a){var u=n[a];if(u instanceof e){if(u.resolved)return i[a]=u.value,o-=1,"continue"}else if(!r(u))return i[a]=u,o-=1,"continue";e.resolve(u).then(function(e){i[a]=e,0==(o-=1)&&t.resolve(i)},function(e){t.reject(e)})},u=0;u<n.length;u++)a(u);return 0===o&&t.resolve(i),t},e.hash=function(n){var t={};return e.all(Object.keys(n).map(function(r){return e.resolve(n[r]).then(function(e){t[r]=e})})).then(function(){return t})},e.map=function(n,t){return e.all(n.map(t))},e.onPossiblyUnhandledException=function(e){return function(e){return o().possiblyUnhandledPromiseHandlers.push(e),{cancel:function(){o().possiblyUnhandledPromiseHandlers.splice(o().possiblyUnhandledPromiseHandlers.indexOf(e),1)}}}(e)},e.try=function(n,t,r){if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.try expected a function");var o=void 0;try{o=n.apply(t,r||[])}catch(n){return e.reject(n)}return e.resolve(o)},e.delay=function(n){return new e(function(e){setTimeout(e,n)})},e.isPromise=function(n){return!!(n&&n instanceof e)||r(n)},e.flush=function(){var n=new e;return o().flushPromises.push(n),0===o().activeCount&&e.flushQueue(),n},e.flushQueue=function(){var e=o().flushPromises;o().flushPromises=[];for(var n=0,t=null==e?0:e.length;n<t;n++)e[n].resolve()},e}();t.d(n,"a",function(){return i})},function(e,n,t){"use strict";t(5);var r=t(6);t.d(n,"addEventListener",function(){return r.a}),t(11),t(12),t(7);var o=t(4);t.d(n,"isRegex",function(){return o.f}),t.d(n,"noop",function(){return o.h}),t.d(n,"once",function(){return o.i}),t.d(n,"safeInterval",function(){return o.k}),t.d(n,"stringifyError",function(){return o.m}),t.d(n,"uniqueID",function(){return o.n}),t(13);var i=t(14);t.n(i),t(15),t(16)},function(e,n,t){"use strict";t.d({},"WeakMap",function(){return u});var r=t(0);function o(e,n){for(var t=0;t<e.length;t++)try{if(e[t]===n)return t}catch(e){}return-1}var i=Object.defineProperty,a=Date.now()%1e9,u=function(){function e(){if(function(n,t){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this),a+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+a,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,n={};return Object.freeze(n),e.set(n,"__testvalue__"),"__testvalue__"===e.get(n)}catch(e){return!1}}())try{this.weakmap=new WeakMap}catch(e){}this.keys=[],this.values=[]}return e.prototype._cleanupClosedWindows=function(){for(var e=this.weakmap,n=this.keys,t=0;t<n.length;t++){var o=n[t];if(Object(r.isWindow)(o)&&Object(r.isWindowClosed)(o)){if(e)try{e.delete(o)}catch(e){}n.splice(t,1),this.values.splice(t,1),t-=1}}},e.prototype.isSafeToReadWrite=function(e){if(Object(r.isWindow)(e))return!1;try{e&&e.self,e&&e[this.name]}catch(e){return!1}return!0},e.prototype.set=function(e,n){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.set(e,n)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=this.name,a=e[r];a&&a[0]===e?a[1]=n:i(e,r,{value:[e,n],writable:!0})}else{this._cleanupClosedWindows();var u=this.keys,c=this.values,s=o(u,e);-1===s?(u.push(e),c.push(n)):c[s]=n}},e.prototype.get=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{if(n.has(e))return n.get(e)}catch(e){delete this.weakmap}if(!this.isSafeToReadWrite(e)){this._cleanupClosedWindows();var t=o(this.keys,e);if(-1===t)return;return this.values[t]}var r=e[this.name];if(r&&r[0]===e)return r[1]},e.prototype.delete=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{n.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var t=e[this.name];t&&t[0]===e&&(t[0]=t[1]=void 0)}else{this._cleanupClosedWindows();var r=this.keys,i=o(r,e);-1!==i&&(r.splice(i,1),this.values.splice(i,1))}},e.prototype.has=function(e){if(!e)throw new Error("WeakMap expected key");var n=this.weakmap;if(n)try{return n.has(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var t=e[this.name];return!(!t||t[0]!==e)}return this._cleanupClosedWindows(),-1!==o(this.keys,e)},e.prototype.getOrSet=function(e,n){if(this.has(e))return this.get(e);var t=n();return this.set(e,t),t},e}();t.d(n,"a",function(){return u})},function(e,n,t){"use strict";n.n=a,n.d=function(){if("undefined"!=typeof window)return window;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("No global found")},n.g=function(e){var n=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new o.a;function i(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];var u=r.getOrSet(t.thisNamespace?this:e,function(){return{}}),s=c(o),f=t.time;if(u[s]&&f&&Date.now()-u[s].time<f&&delete u[s],u[s])return u[s].value;i.__calling__=!0;var d=Date.now(),l=e.apply(this,arguments);return i.__calling__=!1,u[s]={time:d,value:l},u[s].value}return i.reset=function(){r.delete(t.thisNamespace?n:e)},t.name&&(i.displayName=t.name+":memoized"),i},n.j=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};function t(){return r.a.try(e,this,arguments)}return n.name&&(t.displayName=n.name+":promisified"),t},n.e=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=e.__inline_memoize_cache__=e.__inline_memoize_cache__||{},o=c(t);return r.hasOwnProperty(o)?r[o]:r[o]=n.apply(void 0,t)},n.h=function(){},n.i=function(e){var n=!1;return function(){if(!n)return n=!0,e.apply(this,arguments)}},n.m=function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(t>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+Object.prototype.toString.call(n)+">";if("string"==typeof n)return n;if(n instanceof Error){var r=n&&n.stack,o=n&&n.message;if(r&&o)return-1!==r.indexOf(o)?r:o+"\n"+r;if(r)return r;if(o)return o}return"function"==typeof n.toString?n.toString():Object.prototype.toString.call(n)}catch(n){return"Error while stringifying error: "+e(n,t+1)}},n.l=function(e){return"string"==typeof e?e:e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)},n.c=function(e,n){if(!n)return e;if(Object.assign)return Object.assign(e,n);for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e},n.k=function(e,n){var t=void 0;return function r(){t=setTimeout(function(){e(),r()},n)}(),{cancel:function(){clearTimeout(t)}}},n.a=function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()},n.b=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,t=void 0;return function(){var r=this,o=arguments;clearTimeout(t),t=setTimeout(function(){return e.apply(r,o)},n)}},n.f=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)};var r=t(1),o=t(3),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function a(){var e,n="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+(e=(new Date).toISOString().slice(11,19).replace("T","."),window.btoa(e)).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var u=void 0;function c(e){try{return JSON.stringify(Array.prototype.slice.call(e),function(e,n){return"function"==typeof n?"memoize["+function(e){if(u=u||new o.a,null===e||void 0===e||"object"!==(void 0===e?"undefined":i(e))&&"function"!=typeof e)throw new Error("Invalid object");var n=u.get(e);return n||(n=(void 0===e?"undefined":i(e))+":"+a(),u.set(e,n)),n}(n)+"]":n})}catch(e){throw new Error("Arguments not serializable -- can not be used to memoize")}}},function(e,n,t){"use strict";n.a=function(){return!!(window.navigator.mockUserAgent||window.navigator.userAgent).match(/Android|webOS|iPhone|iPad|iPod|bada|Symbian|Palm|CriOS|BlackBerry|IEMobile|WindowsMobile|Opera Mini/i)}},function(e,n,t){"use strict";t(1),t(0),t(3);var r=t(4);t(5),n.b=function e(){return Object(r.e)(e,function(){try{if("undefined"==typeof window)return!1;if(window.localStorage){var e=Math.random().toString();window.localStorage.setItem("__test__localStorage__",e);var n=window.localStorage.getItem("__test__localStorage__");if(window.localStorage.removeItem("__test__localStorage__"),e===n)return!0}}catch(e){}return!1})},n.a=function(e,n,t){return e.addEventListener(n,t),{cancel:function(){e.removeEventListener(n,t)}}},"function"==typeof Symbol&&Symbol.iterator,Object.assign,Object.create(Error.prototype)},function(e,n,t){"use strict";n.a=function e(n){var t=n.name,i=n.version,a=void 0===i?"latest":i,u=n.lifetime,c=void 0===u?3e5:u;return Object(r.e)(e,function(){var e="__"+t+"_"+a+"_storage__",n=void 0;function i(t){var i=Object(o.b)(),a=void 0;if(n&&(a=n),!a&&i){var u=window.localStorage.getItem(e);u&&(a=JSON.parse(u))}a||(a=Object(r.d)()[e]),a||(a={id:Object(r.n)()}),a.id||(a.id=Object(r.n)()),n=a;var c=t(a);return i?window.localStorage.setItem(e,JSON.stringify(a)):Object(r.d)()[e]=a,n=null,c}function u(e){return i(function(n){var t=n.__session__,o=Date.now();return t&&o-t.created>c&&(t=null),t||(t={guid:Object(r.n)(),created:o}),n.__session__=t,e(t)})}return{getState:i,getID:function(){return i(function(e){return e.id})},getSessionState:function(e){return u(function(n){return n.state=n.state||{},e(n.state)})},getSessionID:function(){return u(function(e){return e.guid})}}},[{name:t,version:a,lifetime:c}])};var r=t(4),o=t(6)},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={};t.d(r,"markWindowKnown",function(){return C}),t.d(r,"serializeMessage",function(){return N}),t.d(r,"deserializeMessage",function(){return D}),t.d(r,"cleanUpWindow",function(){return ae}),t.d(r,"Promise",function(){return h.a}),t.d(r,"bridge",function(){return ue}),t.d(r,"init",function(){return ce}),t.d(r,"parent",function(){return ie}),t.d(r,"send",function(){return Y}),t.d(r,"request",function(){return X}),t.d(r,"sendToParent",function(){return Z}),t.d(r,"client",function(){return V}),t.d(r,"on",function(){return ne}),t.d(r,"listen",function(){return ee}),t.d(r,"once",function(){return te}),t.d(r,"listener",function(){return re}),t.d(r,"CONFIG",function(){return d}),t.d(r,"disable",function(){return oe});var o,i=t(0),a={REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},u={METHOD:"postrobot_method",HELLO:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},c={FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},s={POSTROBOT:"__postRobot__"},f="*",d={ALLOW_POSTMESSAGE_POPUP:!("__ALLOW_POSTMESSAGE_POPUP__"in window)||window.__ALLOW_POSTMESSAGE_POPUP__,BRIDGE_TIMEOUT:5e3,CHILD_WINDOW_TIMEOUT:5e3,ACK_TIMEOUT:2e3,ACK_TIMEOUT_KNOWN:1e4,RES_TIMEOUT:-1,ALLOWED_POST_MESSAGE_METHODS:(o={},o.postrobot_post_message=!0,o.postrobot_bridge=!0,o.postrobot_global=!0,o)};0===window.location.href.indexOf("file:")&&(d.ALLOW_POSTMESSAGE_POPUP=!0);var l,w=t(3),h=t(1),p=t(2),m={FUNCTION:"function",ERROR:"error",PROMISE:"promise",REGEX:"regex",DATE:"date",ARRAY:"array",OBJECT:"object",STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",UNDEFINED:"undefined"},v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function y(e){return"object"===(void 0===e?"undefined":v(e))&&null!==e&&"string"==typeof e.__type__}function g(e){return void 0===e?m.UNDEFINED:null===e?m.NULL:Array.isArray(e)?m.ARRAY:"function"==typeof e?m.FUNCTION:"object"===(void 0===e?"undefined":v(e))?e instanceof Error?m.ERROR:"function"==typeof e.then?m.PROMISE:"[object RegExp]"===Object.prototype.toString.call(e)?m.REGEX:"[object Date]"===Object.prototype.toString.call(e)?m.DATE:m.OBJECT:"string"==typeof e?m.STRING:"number"==typeof e?m.NUMBER:"boolean"==typeof e?m.BOOLEAN:void 0}function O(e,n){return{__type__:e,__val__:n}}var E,_=((l={})[m.FUNCTION]=function(){},l[m.ERROR]=function(e){var n=e.message,t=e.stack,r=e.code;return O(m.ERROR,{message:n,stack:t,code:r})},l[m.PROMISE]=function(){},l[m.REGEX]=function(e){return O(m.REGEX,e.source)},l[m.DATE]=function(e){return O(m.DATE,e.toJSON())},l[m.ARRAY]=function(e){return e},l[m.OBJECT]=function(e){return e},l[m.STRING]=function(e){return e},l[m.NUMBER]=function(e){return e},l[m.BOOLEAN]=function(e){return e},l[m.NULL]=function(e){return e},l),b={},S=((E={})[m.FUNCTION]=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},E[m.ERROR]=function(e){var n=e.message,t=e.stack,r=e.code,o=new Error(n);return o.code=r,o.stack=t+"\n\n"+o.stack,o},E[m.PROMISE]=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},E[m.REGEX]=function(e){return new RegExp(e)},E[m.DATE]=function(e){return new Date(e)},E[m.ARRAY]=function(e){return e},E[m.OBJECT]=function(e){return e},E[m.STRING]=function(e){return e},E[m.NUMBER]=function(e){return e},E[m.BOOLEAN]=function(e){return e},E[m.NULL]=function(e){return e},E),j={},P=window[s.POSTROBOT]=window[s.POSTROBOT]||{};P.registerSelf=function(){},P.methods=P.methods||new w.a;var R=Object(p.once)(function(){P.on(u.METHOD,{origin:f},function(e){var n=e.source,t=e.origin,r=e.data,o=P.methods.get(n);if(!o)throw new Error("Could not find any methods this window has privileges to call");var a=o[r.id];if(!a)throw new Error("Could not find method with id: "+r.id);if(!Object(i.matchDomain)(a.domain,t))throw new Error("Method domain "+a.domain+" does not match origin "+t);return h.a.try(function(){return a.val.apply({source:n,origin:t,data:r},r.args)}).then(function(e){return{result:e,id:r.id,name:r.name}})})}),A={CROSS_DOMAIN_ZALGO_PROMISE:"cross_domain_zalgo_promise",CROSS_DOMAIN_FUNCTION:"cross_domain_function"};function T(e,n,t,r){var o=Object(p.uniqueID)(),i=P.methods.get(e);return i||(i={},P.methods.set(e,i)),i[o]={domain:n,val:t},R(),O(A.CROSS_DOMAIN_FUNCTION,{id:o,name:t.name||r})}function W(e,n,t){var r=t.id,o=t.name;function i(){var t=Array.prototype.slice.call(arguments);return P.send(e,u.METHOD,{id:r,name:o,args:t},{domain:n}).then(function(e){return e.data.result})}return i.__name__=o,i.__xdomain__=!0,i.source=e,i.origin=n,i}function N(e,n,t){var r;return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b,t=JSON.stringify(e,function(e){var t=this[e];if(y(this))return t;var r=g(t);if(!r)return t;var o=n[r]||_[r];return o?o(t,e):t});return void 0===t?m.UNDEFINED:t}(t,((r={})[m.PROMISE]=function(t,r){return function(e,n,t,r){return O(A.CROSS_DOMAIN_ZALGO_PROMISE,{then:T(e,n,function(e,n){return t.then(e,n)},r)})}(e,n,t,r)},r[m.FUNCTION]=function(t,r){return T(e,n,t,r)},r))}function D(e,n,t){var r;return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:j;if(e!==m.UNDEFINED)return JSON.parse(e,function(e,t){if(y(this))return t;var r=void 0,o=void 0;if(y(t)?(r=t.__type__,o=t.__val__):(r=g(t),o=t),!r)return o;var i=n[r]||S[r];return i?i(o,e):o})}(t,((r={})[A.CROSS_DOMAIN_ZALGO_PROMISE]=function(t){var r=t.then;return function(e,n,t){var r=t.then;return new h.a(function(t,o){W(e,n,r)(t,o)})}(e,n,{then:r})},r[A.CROSS_DOMAIN_FUNCTION]=function(t){var r=t.id,o=t.name;return W(e,n,{id:r,name:o})},r))}function I(e){return P.send(e,u.HELLO,{},{domain:f,timeout:-1}).then(function(e){return{origin:e.origin}})}function C(e){P.knownWindows.set(e,!0)}P.readyPromises=P.readyPromises||new w.a,P.knownWindows=P.knownWindows||new w.a;var L={postrobot_post_message:function(e,n,t){(Array.isArray(t)?t:"string"==typeof t?[t]:[f]).map(function(n){if(0===n.indexOf("mock:")){if("file:"===window.location.protocol)return f;if(!Object(i.isActuallySameDomain)(e))throw new Error("Attempting to send messsage to mock domain "+n+", but window is actually cross-domain");return Object(i.getActualDomain)(e)}return 0===n.indexOf("file:")?f:n}).forEach(function(t){return e.postMessage(n,t)})}},M=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};function k(e,n,t){return h.a.try(function(){var r;if(Object(i.isWindowClosed)(e))throw new Error("Window is closed");var o=N(e,n,((r={})[s.POSTROBOT]=M({},t,{id:Object(p.uniqueID)(),windowType:Object(i.isPopup)()?c.POPUP:Object(i.isIframe)()?c.IFRAME:c.FULLPAGE}),r)),a=[];return h.a.map(Object.keys(L),function(t){return h.a.try(function(){if(!d.ALLOWED_POST_MESSAGE_METHODS[t])throw new Error("Strategy disallowed: "+t);return L[t](e,o,n)}).then(function(){return a.push(t+": success"),!0},function(e){return a.push(t+": "+Object(p.stringifyError)(e)+"\n"),!1})}).then(function(e){var n=e.some(Boolean),r=t.type+" "+t.name+" "+(n?"success":"error")+":\n - "+a.join("\n - ")+"\n";if(!n)throw new Error(r)})})}P.responseListeners=P.responseListeners||{},P.requestListeners=P.requestListeners||{},P.WINDOW_WILDCARD=P.WINDOW_WILDCARD||new function(){},P.erroredResponseListeners=P.erroredResponseListeners||{};var x,U="__domain_regex__";function B(e){return P.responseListeners[e]}function F(e){delete P.responseListeners[e]}function H(e){return Boolean(P.erroredResponseListeners[e])}function q(e){var n=e.name,t=e.win,r=e.domain;if(t===f&&(t=null),r===f&&(r=null),!n)throw new Error("Name required to get request listener");var o=P.requestListeners[n];if(o)for(var a=0,u=[t,P.WINDOW_WILDCARD],c=null==u?0:u.length;a<c;a++){var s=u[a],d=s&&o.get(s);if(d){if(r&&"string"==typeof r){if(d[r])return d[r];if(d[U])for(var l=0,w=d[U],h=null==w?0:w.length;l<h;l++){var p=w[l],m=p.regex,v=p.listener;if(Object(i.matchDomain)(m,r))return v}}if(d[f])return d[f]}}}var G=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},z=((x={})[a.ACK]=function(e,n,t){if(!H(t.hash)){var r=B(t.hash);if(!r)throw new Error("No handler found for post message ack for message: "+t.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(r.domain,n))throw new Error("Ack origin "+n+" does not match domain "+r.domain.toString());r.ack=!0}},x[a.REQUEST]=function(e,n,t){var r=q({name:t.name,win:e,domain:n});function o(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.fireAndForget||Object(i.isWindowClosed)(e)?h.a.resolve():k(e,n,G({type:r,hash:t.hash,name:t.name},o))}return h.a.all([o(a.ACK),h.a.try(function(){if(!r)throw new Error("No handler found for post message: "+t.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(r.domain,n))throw new Error("Request origin "+n+" does not match domain "+r.domain.toString());var o=t.data;return r.handler({source:e,origin:n,data:o})}).then(function(e){return o(a.RESPONSE,{ack:"success",data:e})},function(e){return o(a.RESPONSE,{ack:"error",error:e})})]).then(p.noop).catch(function(e){if(r&&r.handleError)return r.handleError(e);throw e})},x[a.RESPONSE]=function(e,n,t){if(!H(t.hash)){var r=B(t.hash);if(!r)throw new Error("No handler found for post message response for message: "+t.name+" from "+n+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(i.matchDomain)(r.domain,n))throw new Error("Response origin "+n+" does not match domain "+Object(i.stringifyDomainPattern)(r.domain));if(F(t.hash),"error"===t.ack)return r.respond(t.error,null);if("success"===t.ack){var o=t.data;return r.respond(null,{source:e,origin:n,data:o})}}},x),K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function J(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(e){return}var n=e.source,t=e.origin,r=function(e,n,t){var r=void 0;try{r=D(n,t,e)}catch(e){return}if(r&&"object"===(void 0===r?"undefined":K(r))&&null!==r&&(r=r[s.POSTROBOT])&&"object"===(void 0===r?"undefined":K(r))&&null!==r&&r.type&&"string"==typeof r.type&&z[r.type])return r}(e.data,n,t);r&&(C(n),-1===P.receivedMessages.indexOf(r.id)&&(P.receivedMessages.push(r.id),Object(i.isWindowClosed)(n)&&!r.fireAndForget||z[r.type](n,t,r)))}function Q(e){try{Object(p.noop)(e.source)}catch(e){return}J({source:e.source||e.sourceElement,origin:e.origin||e.originalEvent&&e.originalEvent.origin,data:e.data})}function X(e){return h.a.try(function(){if(!e.name)throw new Error("Expected options.name");var n=e.name,t=void 0,r=void 0;if("string"==typeof e.window){var o=document.getElementById(e.window);if(!o)throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be a valid element id");if("iframe"!==o.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(!o.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");t=o.contentWindow}else if(e.window instanceof HTMLIFrameElement){if("iframe"!==e.window.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(e.window&&!e.window.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");e.window&&e.window.contentWindow&&(t=e.window.contentWindow)}else t=e.window;if(!t)throw new Error("Expected options.window to be a window object, iframe, or iframe element id.");var u=t;r=e.domain||f;var c=e.name+"_"+Object(p.uniqueID)();if(Object(i.isWindowClosed)(u))throw new Error("Target window is closed");var s=!1,l=P.requestPromises.get(u);l||(l=[],P.requestPromises.set(u,l));var w=h.a.try(function(){if(Object(i.isAncestor)(window,u))return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Window",r=P.readyPromises.get(e);return r||(r=new h.a,P.readyPromises.set(e,r),-1!==n&&setTimeout(function(){return r.reject(new Error(t+" did not load after "+n+"ms"))},n),r)}(u,e.timeout||d.CHILD_WINDOW_TIMEOUT)}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(p.isRegex)(r)&&!e)return I(u)}).then(function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(Object(p.isRegex)(r)){if(!Object(i.matchDomain)(r,t))throw new Error("Remote window domain "+t+" does not match regex: "+r.toString());r=t}if("string"!=typeof r&&!Array.isArray(r))throw new TypeError("Expected domain to be a string or array");var o=r;return new h.a(function(t,r){var f=void 0;if(e.fireAndForget||function(e,n){P.responseListeners[e]=n}(c,f={name:n,window:u,domain:o,respond:function(e,n){e||(s=!0,l.splice(l.indexOf(w,1))),e?r(e):t(n)}}),k(u,o,{type:a.REQUEST,hash:c,name:n,data:e.data,fireAndForget:Boolean(e.fireAndForget)}).catch(r),e.fireAndForget)return t();var h=function(e){return P.knownWindows.get(e)}(u)?d.ACK_TIMEOUT_KNOWN:d.ACK_TIMEOUT,p=e.timeout||d.RES_TIMEOUT,m=h,v=p,y=100;setTimeout(function e(){if(!s){if(Object(i.isWindowClosed)(u))return f.ack?r(new Error("Window closed for "+n+" before response")):r(new Error("Window closed for "+n+" before ack"));if(m=Math.max(m-y,0),-1!==v&&(v=Math.max(v-y,0)),f.ack){if(-1===v)return;y=Math.min(v,2e3)}else{if(0===m)return r(new Error("No ack for postMessage "+n+" in "+Object(i.getDomain)()+" in "+h+"ms"));if(0===v)return r(new Error("No response for postMessage "+n+" in "+Object(i.getDomain)()+" in "+p+"ms"))}setTimeout(e,y)}},y)})});return w.catch(function(){!function(e){P.erroredResponseListeners[e]=!0}(c),F(c)}),l.push(w),w})}function Y(e,n,t,r){return(r=r||{}).window=e,r.name=n,r.data=t,X(r)}function Z(e,n,t){var r=Object(i.getAncestor)();return r?Y(r,e,n,t):new h.a(function(e,n){return n(new Error("Window does not have a parent"))})}function V(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.window)throw new Error("Expected options.window");var n=e.window;return{send:function(t,r){return Y(n,t,r,e)}}}P.receivedMessages=P.receivedMessages||[],P.receiveMessage=J,P.requestPromises=P.requestPromises||new w.a,P.send=Y;var $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function ee(e){if(!e.name)throw new Error("Expected options.name");if(!e.handler)throw new Error("Expected options.handler");var n=e.name,t=e.window,r=e.domain,o={handler:e.handler,handleError:e.errorHandler||function(e){throw e},window:t,domain:r||f,name:n},a=function e(n,t){var r=n.name,o=n.win,i=n.domain;if(!r||"string"!=typeof r)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var a=[],u=0,c=o,s=null==c?0:c.length;u<s;u++){var d=c[u];a.push(e({name:r,domain:i,win:d},t))}return{cancel:function(){for(var e=0,n=null==a?0:a.length;e<n;e++)a[e].cancel()}}}if(Array.isArray(i)){for(var l=[],h=0,m=i,v=null==m?0:m.length;h<v;h++){var y=m[h];l.push(e({name:r,win:o,domain:y},t))}return{cancel:function(){for(var e=0,n=null==l?0:l.length;e<n;e++)l[e].cancel()}}}var g=q({name:r,win:o,domain:i});if(o&&o!==f||(o=P.WINDOW_WILDCARD),i=i||f,g)throw o&&i?new Error("Request listener already exists for "+r+" on domain "+i.toString()+" for "+(o===P.WINDOW_WILDCARD?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+r+" for "+(o===P.WINDOW_WILDCARD?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+r+" on domain "+i.toString()):new Error("Request listener already exists for "+r);var O=P.requestListeners,E=O[r];E||(E=new w.a,O[r]=E);var _=E.get(o);_||(_={},E.set(o,_));var b=i.toString(),S=_[U],j=void 0;return Object(p.isRegex)(i)?(S||(S=[],_[U]=S),j={regex:i,listener:t},S.push(j)):_[b]=t,{cancel:function(){_&&(delete _[b],o&&0===Object.keys(_).length&&E.delete(o),j&&S.splice(S.indexOf(j,1)))}}}({name:n,win:t,domain:r},o);if(e.once){var u=o.handler;o.handler=Object(p.once)(function(){return a.cancel(),u.apply(this,arguments)})}if(o.window&&e.errorOnClose)var c=Object(p.safeInterval)(function(){t&&"object"===(void 0===t?"undefined":$(t))&&Object(i.isWindowClosed)(t)&&(c.cancel(),o.handleError(new Error("Post message target window is closed")))},50);return{cancel:function(){a.cancel()}}}function ne(e,n,t){return"function"==typeof n&&(t=n,n={}),(n=n||{}).name=e,n.handler=t||n.handler,ee(n)}function te(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments[2];"function"==typeof n&&(t=n,n={}),n=n||{},t=t||n.handler;var r=n.errorHandler,o=new h.a(function(o,i){(n=n||{}).name=e,n.once=!0,n.handler=function(e){if(o(e),t)return t(e)},n.errorHandler=function(e){if(i(e),r)return r(e)}}),i=ee(n);return o.cancel=i.cancel,o}function re(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{on:function(n,t){return ne(n,e,t)}}}function oe(){delete window[s.POSTROBOT],window.removeEventListener("message",Q)}P.on=ne;var ie=Object(i.getAncestor)();function ae(e){var n=P.requestPromises.get(e);if(n)for(var t=0,r=null==n?0:n.length;t<r;t++)n[t].reject(new Error("No response from window - cleaned up"));P.popupWindowsByWin&&P.popupWindowsByWin.delete(e),P.remoteWindows&&P.remoteWindows.delete(e),P.requestPromises.delete(e),P.methods.delete(e),P.readyPromises.delete(e)}var ue=null;function ce(){P.initialized||(Object(p.addEventListener)(window,"message",Q),function(){var e;e=function(e){var n=e.source,t=e.origin,r=P.readyPromises.get(n)||new h.a;r.resolve({origin:t}),P.readyPromises.set(n,r)},P.on(u.HELLO,{domain:f},function(n){var t=n.source,r=n.origin;return e({source:t,origin:r})});var n=Object(i.getAncestor)();n&&I(n).catch(p.noop)}()),P.initialized=!0}ce(),t.d(n,"markWindowKnown",function(){return C}),t.d(n,"serializeMessage",function(){return N}),t.d(n,"deserializeMessage",function(){return D}),t.d(n,"cleanUpWindow",function(){return ae}),t.d(n,"Promise",function(){return h.a}),t.d(n,"bridge",function(){return ue}),t.d(n,"init",function(){return ce}),t.d(n,"parent",function(){return ie}),t.d(n,"send",function(){return Y}),t.d(n,"request",function(){return X}),t.d(n,"sendToParent",function(){return Z}),t.d(n,"client",function(){return V}),t.d(n,"on",function(){return ne}),t.d(n,"listen",function(){return ee}),t.d(n,"once",function(){return te}),t.d(n,"listener",function(){return re}),t.d(n,"CONFIG",function(){return d}),t.d(n,"disable",function(){return oe}),n.default=r},function(e,n,t){"use strict";function r(e){return"[object RegExp]"===Object.prototype.toString.call(e)}n.a=f,n.c=d,n.e=l,n.j=y,n.k=function(e){if(function(){for(var e=0;e<v.length;e++)p(v[e])&&(v.splice(e,1),m.splice(e,1));for(var n=0;n<m.length;n++)y(m[n])&&(v.splice(n,1),m.splice(n,1))}(),e&&e.contentWindow)try{m.push(e.contentWindow),v.push(e)}catch(e){}},n.d=function(e){return(e=e||window).navigator.mockUserAgent||e.navigator.userAgent},n.b=g,n.f=function(e,n){var t=g(n);if(t)return t===e;if(n===e)return!1;if(function(e){if(e){try{if(e.top)return e.top}catch(e){}if(u(e)===e)return e;try{if(w(window,e)&&window.top)return window.top}catch(e){}try{if(w(e,window)&&window.top)return window.top}catch(e){}for(var n=0,t=function e(n){for(var t=[],r=0,o=h(n),i=null==o?0:o.length;r<i;r++){var a=o[r];t.push(a);for(var u=0,c=e(a),s=null==c?0:c.length;u<s;u++){var f=c[u];t.push(f)}}return t}(e),r=null==t?0:t.length;n<r;n++){var o=t[n];try{if(o.top)return o.top}catch(e){}if(u(o)===o)return o}}}(n)===n)return!1;for(var r=0,o=h(e),i=null==o?0:o.length;r<i;r++)if(o[r]===n)return!0;return!1},n.h=function(){return Boolean(c(window))},n.g=function(){return Boolean(u(window))},n.l=function e(n,t){if("string"==typeof n){if("string"==typeof t)return n===o.WILDCARD||t===n;if(r(t))return!1;if(Array.isArray(t))return!1}return r(n)?r(t)?n.toString()===t.toString():!Array.isArray(t)&&Boolean(t.match(n)):!!Array.isArray(n)&&(Array.isArray(t)?JSON.stringify(n)===JSON.stringify(t):!r(t)&&n.some(function(n){return e(n,t)}))},n.m=function(e){return Array.isArray(e)?"("+e.join(" | ")+")":r(e)?"RegExp("+e.toString():e.toString()},n.i=function(e){try{if(e===window)return!0}catch(e){if(e&&e.message===i)return!0}try{if("[object Window]"===Object.prototype.toString.call(e))return!0}catch(e){if(e&&e.message===i)return!0}try{if(window.Window&&e instanceof window.Window)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.self===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.parent===e)return!0}catch(e){if(e&&e.message===i)return!0}try{if(e&&e.top===e)return!0}catch(e){if(e&&e.message===i)return!0}try{e&&e.__cross_domain_utils_window_check__}catch(e){return!0}return!1};var o={MOCK_PROTOCOL:"mock:",FILE_PROTOCOL:"file:",ABOUT_PROTOCOL:"about:",WILDCARD:"*"},i="Call was rejected by callee.\r\n";function a(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===o.ABOUT_PROTOCOL}function u(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function c(e){if(e&&!u(e))try{return e.opener}catch(e){}}function s(e){try{return e&&e.location&&e.location.href,!0}catch(e){}return!1}function f(e){var n=(e=e||window).location;if(!n)throw new Error("Can not read window location");var t=n.protocol;if(!t)throw new Error("Can not read window protocol");if(t===o.FILE_PROTOCOL)return o.FILE_PROTOCOL+"//";if(t===o.ABOUT_PROTOCOL){var r=u(e);return r&&s(r)?f(r):o.ABOUT_PROTOCOL+"//"}var i=n.host;if(!i)throw new Error("Can not read window host");return t+"//"+i}function d(e){var n=f(e=e||window);return n&&e.mockDomain&&0===e.mockDomain.indexOf(o.MOCK_PROTOCOL)?e.mockDomain:n}function l(e){try{if(e===window)return!0}catch(e){}try{var n=Object.getOwnPropertyDescriptor(e,"location");if(n&&!1===n.enumerable)return!1}catch(e){}try{if(a(e)&&s(e))return!0}catch(e){}try{if(f(e)===f(window))return!0}catch(e){}return!1}function w(e,n){if(!e||!n)return!1;var t=u(n);return t?t===e:-1!==function(e){var n=[];try{for(;e.parent!==e;)n.push(e.parent),e=e.parent}catch(e){}return n}(n).indexOf(e)}function h(e){var n=[],t=void 0;try{t=e.frames}catch(n){t=e}var r=void 0;try{r=t.length}catch(e){}if(0===r)return n;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=t[o]}catch(e){continue}n.push(i)}return n}for(var a=0;a<100;a++){var u=void 0;try{u=t[a]}catch(e){return n}if(!u)return n;n.push(u)}return n}function p(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var n=e.ownerDocument;return!(!n||!n.documentElement||n.documentElement.contains(e))}var m=[],v=[];function y(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{if(e===window)return!1}catch(e){return!0}try{if(!e)return!0}catch(e){return!0}try{if(e.closed)return!0}catch(e){return!e||e.message!==i}if(n&&function(e){if(!l(e))return!1;try{if(e===window)return!0;if(a(e)&&s(e))return!0;if(d(window)===d(e))return!0}catch(e){}return!1}(e))try{if(e.mockclosed)return!0}catch(e){}try{if(!e.parent||!e.top)return!0}catch(e){}var t=function(e,n){for(var t=0;t<e.length;t++)try{if(e[t]===n)return t}catch(e){}return-1}(m,e);if(-1!==t){var r=v[t];if(r&&p(r))return!0}return!1}function g(e){return c(e=e||window)||u(e)||void 0}},function(e,n){},function(e,n,t){"use strict";t(4),t(7)},function(e,n,t){"use strict";t(4)},function(e,n,t){"use strict";t(1),t(0)},function(e,n){},function(e,n,t){"use strict";t(4)},function(e,n,t){"use strict"}])});
//# sourceMappingURL=post-robot.min.js.map
{
"name": "post-robot",
"version": "9.0.3",
"version": "9.0.4",
"description": "Simple postMessage based server.",

@@ -59,4 +59,5 @@ "main": "index.js",

"cross-domain-utils": "^2.0.0",
"universal-serialize": "^1.0.4",
"zalgo-promise": "^1.0.3"
}
}

@@ -7,3 +7,3 @@ /* @flow */

import { CONSTANTS } from '../conf';
import { MESSAGE_NAME, WILDCARD } from '../conf';
import { global } from '../global';

@@ -87,3 +87,3 @@

return global.send(parentWindow, CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL, {
return global.send(parentWindow, MESSAGE_NAME.OPEN_TUNNEL, {

@@ -117,3 +117,3 @@ name,

}, { domain: CONSTANTS.WILDCARD });
}, { domain: WILDCARD });
};

@@ -7,3 +7,3 @@ /* @flow */

import { CONSTANTS } from '../conf';
import { WINDOW_PROP } from '../conf';
import { global } from '../global';

@@ -23,3 +23,3 @@

// $FlowFixMe
if (isSameDomain(frame) && frame[CONSTANTS.WINDOW_PROPS.POSTROBOT]) {
if (isSameDomain(frame) && frame[WINDOW_PROP.POSTROBOT]) {
return frame;

@@ -35,3 +35,3 @@ }

// $FlowFixMe
if (frame && isSameDomain(frame) && frame[CONSTANTS.WINDOW_PROPS.POSTROBOT]) {
if (frame && isSameDomain(frame) && frame[WINDOW_PROP.POSTROBOT]) {
clearInterval(interval);

@@ -80,3 +80,3 @@ clearTimeout(timeout);

return bridge[CONSTANTS.WINDOW_PROPS.POSTROBOT].openTunnelToParent({
return bridge[WINDOW_PROP.POSTROBOT].openTunnelToParent({

@@ -83,0 +83,0 @@ name: window.name,

@@ -7,3 +7,3 @@ /* @flow */

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, BRIDGE_NAME_PREFIX } from '../conf';
import { global } from '../global';

@@ -71,3 +71,3 @@

let id = `${ CONSTANTS.BRIDGE_NAME_PREFIX }_${ sanitizedDomain }`;
let id = `${ BRIDGE_NAME_PREFIX }_${ sanitizedDomain }`;

@@ -113,3 +113,3 @@ return id;

let sendMessageWrapper = (remoteWin : CrossDomainWindowType, message : string, remoteDomain : string) => {
let sendMessageWrapper = (remoteWin : CrossDomainWindowType, remoteDomain : string, message : string) => {

@@ -142,3 +142,3 @@ if (remoteWin !== win) {

export function sendBridgeMessage(win : CrossDomainWindowType, message : string, domain : string) : ZalgoPromise<void> {
export function sendBridgeMessage(win : CrossDomainWindowType, domain : string, message : string) : ZalgoPromise<void> {

@@ -159,4 +159,4 @@ let messagingChild = isOpener(window, win);

return remoteWindow.sendMessagePromise.then(sendMessage => {
return sendMessage(win, message, domain);
return sendMessage(win, domain, message);
});
}

@@ -7,3 +7,3 @@ /* @flow */

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, PROTOCOL, MESSAGE_NAME } from '../conf';
import { onChildWindowReady } from '../lib';

@@ -21,3 +21,3 @@ import { global } from '../global';

function listenForRegister(source, domain) {
global.on(CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL, { window: source, domain }, ({ origin, data }) => {
global.on(MESSAGE_NAME.OPEN_TUNNEL, { window: source, domain }, ({ origin, data }) => {

@@ -162,3 +162,3 @@ if (origin !== domain) {

if (url && url.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0) {
if (url && url.indexOf(PROTOCOL.MOCK) === 0) {
[ domain, url ] = url.split('|');

@@ -165,0 +165,0 @@ }

/* @flow */
import { CONSTANTS } from './constants';
import { SEND_STRATEGY, PROTOCOL } from './constants';

@@ -19,10 +19,10 @@ export let CONFIG : Object = {

ALLOWED_POST_MESSAGE_METHODS: {
[ CONSTANTS.SEND_STRATEGIES.POST_MESSAGE ]: true,
[ CONSTANTS.SEND_STRATEGIES.BRIDGE ]: true,
[ CONSTANTS.SEND_STRATEGIES.GLOBAL ]: true
[ SEND_STRATEGY.POST_MESSAGE ]: true,
[ SEND_STRATEGY.BRIDGE ]: true,
[ SEND_STRATEGY.GLOBAL ]: true
}
};
if (window.location.href.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
if (window.location.href.indexOf(PROTOCOL.FILE) === 0) {
CONFIG.ALLOW_POSTMESSAGE_POPUP = true;
}
/* @flow */
export let CONSTANTS = {
export const MESSAGE_TYPE = {
REQUEST: ('postrobot_message_request' : 'postrobot_message_request'),
RESPONSE: ('postrobot_message_response' : 'postrobot_message_response'),
ACK: ('postrobot_message_ack' : 'postrobot_message_ack')
};
POST_MESSAGE_TYPE: {
REQUEST: 'postrobot_message_request',
RESPONSE: 'postrobot_message_response',
ACK: 'postrobot_message_ack'
},
export const MESSAGE_ACK = {
SUCCESS: ('success' : 'success'),
ERROR: ('error' : 'error')
};
POST_MESSAGE_ACK: {
SUCCESS: 'success',
ERROR: 'error'
},
export const MESSAGE_NAME = {
METHOD: ('postrobot_method' : 'postrobot_method'),
HELLO: ('postrobot_ready' : 'postrobot_ready'),
OPEN_TUNNEL: ('postrobot_open_tunnel' : 'postrobot_open_tunnel')
};
POST_MESSAGE_NAMES: {
METHOD: 'postrobot_method',
HELLO: 'postrobot_ready',
OPEN_TUNNEL: 'postrobot_open_tunnel'
},
export const WINDOW_TYPE = {
FULLPAGE: ('fullpage' : 'fullpage'),
POPUP: ('popup' : 'popup'),
IFRAME: ('iframe' : 'iframe')
};
WINDOW_TYPES: {
FULLPAGE: 'fullpage',
POPUP: 'popup',
IFRAME: 'iframe'
},
export const WINDOW_PROP = {
POSTROBOT: ('__postRobot__' : '__postRobot__')
};
WINDOW_PROPS: {
POSTROBOT: '__postRobot__'
},
export const SERIALIZATION_TYPE = {
METHOD: ('postrobot_method' : 'postrobot_method'),
ZALGO_PROMISE: ('postrobot_zalgo_promise' : 'postrobot_zalgo_promise')
};
SERIALIZATION_TYPES: {
METHOD: 'postrobot_method',
ERROR: 'postrobot_error',
PROMISE: 'postrobot_promise',
ZALGO_PROMISE: 'postrobot_zalgo_promise',
REGEX: 'regex'
},
SEND_STRATEGIES: {
POST_MESSAGE: 'postrobot_post_message',
BRIDGE: 'postrobot_bridge',
GLOBAL: 'postrobot_global'
},
MOCK_PROTOCOL: 'mock:',
FILE_PROTOCOL: 'file:',
BRIDGE_NAME_PREFIX: '__postrobot_bridge__',
POSTROBOT_PROXY: '__postrobot_proxy__',
WILDCARD: '*'
export const SEND_STRATEGY = {
POST_MESSAGE: ('postrobot_post_message' : 'postrobot_post_message'),
BRIDGE: ('postrobot_bridge' : 'postrobot_bridge'),
GLOBAL: ('postrobot_global' : 'postrobot_global')
};
export const POST_MESSAGE_NAMES = {
METHOD: 'postrobot_method',
HELLO: 'postrobot_hello',
OPEN_TUNNEL: 'postrobot_open_tunnel'
export const PROTOCOL = {
MOCK: ('mock:' : 'mock:'),
FILE: ('file:' : 'file:')
};
export let POST_MESSAGE_NAMES_LIST : Array<string> = Object.keys(POST_MESSAGE_NAMES)
.map(key => POST_MESSAGE_NAMES[key]);
export const BRIDGE_NAME_PREFIX = '__postrobot_bridge__';
export const POSTROBOT_PROXY = '__postrobot_proxy__';
export const WILDCARD = '*';

@@ -9,3 +9,3 @@ /* @flow */

import { global } from '../global';
import { CONSTANTS } from '../conf';
import { WILDCARD } from '../conf';

@@ -26,3 +26,3 @@ export function resetListeners() {

export type RequestListenerType = {
handler : ({ source : CrossDomainWindowType, origin : string, data : Object }) => (mixed | ZalgoPromise<mixed>),
handler : ({ source : CrossDomainWindowType, origin : string, data : mixed }) => (mixed | ZalgoPromise<mixed>),
handleError : (err : mixed) => void,

@@ -38,3 +38,3 @@ window : ?CrossDomainWindowType,

domain : (string | Array<string> | RegExp),
respond : (err : ?mixed, result : ?Object) => void,
respond : (err : ?mixed, result : ?mixed) => void,
ack? : ?boolean

@@ -65,7 +65,7 @@ };

if (win === CONSTANTS.WILDCARD) {
if (win === WILDCARD) {
win = null;
}
if (domain === CONSTANTS.WILDCARD) {
if (domain === WILDCARD) {
domain = null;

@@ -106,4 +106,4 @@ }

if (winListeners[CONSTANTS.WILDCARD]) {
return winListeners[CONSTANTS.WILDCARD];
if (winListeners[WILDCARD]) {
return winListeners[WILDCARD];
}

@@ -154,7 +154,7 @@ }

if (!win || win === CONSTANTS.WILDCARD) {
if (!win || win === WILDCARD) {
win = global.WINDOW_WILDCARD;
}
domain = domain || CONSTANTS.WILDCARD;
domain = domain || WILDCARD;

@@ -161,0 +161,0 @@ if (existingListener) {

/* @flow */
import { isWindowClosed, type CrossDomainWindowType } from 'cross-domain-utils/src';
import { isWindowClosed, type CrossDomainWindowType, getDomain } from 'cross-domain-utils/src';
import { addEventListener, noop } from 'belter/src';
import { CONSTANTS, POST_MESSAGE_NAMES_LIST } from '../../conf';
import { deserializeMethods, markWindowKnown } from '../../lib';
import { MESSAGE_NAME, WINDOW_PROP, MESSAGE_TYPE } from '../../conf';
import { deserializeMessage, markWindowKnown } from '../../lib';
import { global } from '../../global';

@@ -20,3 +20,3 @@

function parseMessage(message : string) : ?Object {
function parseMessage(message : string, source : CrossDomainWindowType, origin : string) : ?Object {

@@ -26,3 +26,3 @@ let parsedMessage;

try {
parsedMessage = JSON.parse(message);
parsedMessage = deserializeMessage(source, origin, message);
} catch (err) {

@@ -40,3 +40,3 @@ return;

parsedMessage = parsedMessage[CONSTANTS.WINDOW_PROPS.POSTROBOT];
parsedMessage = parsedMessage[WINDOW_PROP.POSTROBOT];

@@ -75,4 +75,9 @@ if (!parsedMessage || typeof parsedMessage !== 'object' || parsedMessage === null) {

let message = parseMessage(data);
if (__TEST__) {
// $FlowFixMe
origin = getDomain(source);
}
let message = parseMessage(data, source, origin);
if (!message) {

@@ -83,11 +88,3 @@ return;

markWindowKnown(source);
if (!message.sourceDomain || typeof message.sourceDomain !== 'string') {
throw new Error(`Expected message to have sourceDomain`);
}
if (message.sourceDomain.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0 || message.sourceDomain.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
origin = message.sourceDomain;
}
if (global.receivedMessages.indexOf(message.id) === -1) {

@@ -102,3 +99,3 @@ global.receivedMessages.push(message.id);

if (POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 || message.type === CONSTANTS.POST_MESSAGE_TYPE.ACK) {
if (Object.keys(MESSAGE_NAME).map(key => MESSAGE_NAME[key]).indexOf(message.name) !== -1 || message.type === MESSAGE_TYPE.ACK) {
level = 'debug';

@@ -122,6 +119,2 @@ } else if (message.ack === 'error') {

if (message.data) {
message.data = deserializeMethods(source, origin, message.data);
}
RECEIVE_MESSAGE_TYPES[message.type](source, origin, message);

@@ -128,0 +121,0 @@ }

@@ -5,11 +5,12 @@ /* @flow */

import { isWindowClosed, matchDomain, stringifyDomainPattern, type CrossDomainWindowType } from 'cross-domain-utils/src';
import { stringifyError, noop } from 'belter/src';
import { noop } from 'belter/src';
import { CONSTANTS } from '../../conf';
import { MESSAGE_TYPE, MESSAGE_ACK } from '../../conf';
import { sendMessage } from '../send';
import { getRequestListener, getResponseListener, deleteResponseListener, isResponseListenerErrored } from '../listeners';
import type { RequestMessage, AckResponseMessage, SuccessResponseMessage, ErrorResponseMessage } from '../types';
export let RECEIVE_MESSAGE_TYPES = {
[ CONSTANTS.POST_MESSAGE_TYPE.ACK ](source : CrossDomainWindowType, origin : string, message : Object) {
[ MESSAGE_TYPE.ACK ](source : CrossDomainWindowType, origin : string, message : AckResponseMessage) {

@@ -33,7 +34,7 @@ if (isResponseListenerErrored(message.hash)) {

[ CONSTANTS.POST_MESSAGE_TYPE.REQUEST ](source : CrossDomainWindowType, origin : string, message : Object) : ZalgoPromise<void> {
[ MESSAGE_TYPE.REQUEST ](source : CrossDomainWindowType, origin : string, message : RequestMessage) : ZalgoPromise<void> {
let options = getRequestListener({ name: message.name, win: source, domain: origin });
function respond(data) : ZalgoPromise<void> {
function sendResponse(type : $Values<typeof MESSAGE_TYPE>, data = {}) : ZalgoPromise<void> {

@@ -44,8 +45,9 @@ if (message.fireAndForget || isWindowClosed(source)) {

return sendMessage(source, {
target: message.originalSource,
// $FlowFixMe
return sendMessage(source, origin, {
type,
hash: message.hash,
name: message.name,
...data
}, origin);
});
}

@@ -55,5 +57,3 @@

respond({
type: CONSTANTS.POST_MESSAGE_TYPE.ACK
}),
sendResponse(MESSAGE_TYPE.ACK),

@@ -75,20 +75,11 @@ ZalgoPromise.try(() => {

}).then(data => {
return respond({
type: CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,
ack: CONSTANTS.POST_MESSAGE_ACK.SUCCESS,
return sendResponse(MESSAGE_TYPE.RESPONSE, {
ack: MESSAGE_ACK.SUCCESS,
data
});
}, err => {
let error = stringifyError(err).replace(/^Error: /, '');
// $FlowFixMe
let code = err.code;
return respond({
type: CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,
ack: CONSTANTS.POST_MESSAGE_ACK.ERROR,
error,
code
}, error => {
return sendResponse(MESSAGE_TYPE.RESPONSE, {
ack: MESSAGE_ACK.ERROR,
error
});

@@ -98,3 +89,2 @@ })

]).then(noop).catch(err => {
if (options && options.handleError) {

@@ -108,3 +98,3 @@ return options.handleError(err);

[ CONSTANTS.POST_MESSAGE_TYPE.RESPONSE ](source : CrossDomainWindowType, origin : string, message : Object) : void | ZalgoPromise<void> {
[ MESSAGE_TYPE.RESPONSE ](source : CrossDomainWindowType, origin : string, message : SuccessResponseMessage | ErrorResponseMessage) : void | ZalgoPromise<void> {

@@ -127,12 +117,6 @@ if (isResponseListenerErrored(message.hash)) {

if (message.ack === CONSTANTS.POST_MESSAGE_ACK.ERROR) {
let err = new Error(message.error);
if (message.code) {
// $FlowFixMe
err.code = message.code;
}
return options.respond(err, null);
} else if (message.ack === CONSTANTS.POST_MESSAGE_ACK.SUCCESS) {
let data = message.data || message.response;
if (message.ack === MESSAGE_ACK.ERROR) {
return options.respond(message.error, null);
} else if (message.ack === MESSAGE_ACK.SUCCESS) {
let data = message.data;
return options.respond(null, { source, origin, data });

@@ -139,0 +123,0 @@ }

/* @flow */
import { getDomain, isWindowClosed, type CrossDomainWindowType } from 'cross-domain-utils/src';
import { isWindowClosed, type CrossDomainWindowType } from 'cross-domain-utils/src';
import { ZalgoPromise } from 'zalgo-promise/src';
import { uniqueID, stringifyError } from 'belter/src';
import { CONSTANTS, CONFIG, POST_MESSAGE_NAMES_LIST } from '../../conf';
import { serializeMethods, getWindowType } from '../../lib';
import { MESSAGE_TYPE, CONFIG, MESSAGE_NAME, WILDCARD, WINDOW_PROP } from '../../conf';
import { serializeMessage, getWindowType } from '../../lib';
import type { Message } from '../types';
import { SEND_MESSAGE_STRATEGIES } from './strategies';
function logMessage(domain : string | Array<string>, message : Message) {
if (__DEBUG__) {
let level;
function buildMessage(win : CrossDomainWindowType, message : Object, options = {}) : Object {
if (Object.keys(MESSAGE_NAME).map(key => MESSAGE_NAME[key]).indexOf(message.name) !== -1 || message.type === MESSAGE_TYPE.ACK) {
level = 'debug';
} else if (message.ack === 'error') {
level = 'error';
} else {
level = 'info';
}
let id = uniqueID();
let type = getWindowType();
let sourceDomain = getDomain(window);
return {
...message,
...options,
sourceDomain,
id: message.id || id,
windowType: type
};
// eslint-disable-next-line no-console
if (typeof console !== 'undefined' && typeof console[level] === 'function') {
// eslint-disable-next-line no-console
console[level]('postrobot_send', message.type.replace(/^postrobot_message_/, ''), '::', message.name, '::', domain || WILDCARD, '\n\n', message);
}
}
}
export function sendMessage(win : CrossDomainWindowType, message : Object, domain : string | Array<string>) : ZalgoPromise<void> {
export function sendMessage(win : CrossDomainWindowType, domain : string | Array<string>, message : Message) : ZalgoPromise<void> {
return ZalgoPromise.try(() => {
if (isWindowClosed(win)) {
throw new Error('Window is closed');
}
message = buildMessage(win, message, {
data: serializeMethods(win, domain, message.data),
domain
});
logMessage(domain, message);
let level;
if (__DEBUG__) {
if (POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 || message.type === CONSTANTS.POST_MESSAGE_TYPE.ACK) {
level = 'debug';
} else if (message.ack === 'error') {
level = 'error';
} else {
level = 'info';
const serializedMessage = serializeMessage(win, domain, {
[ WINDOW_PROP.POSTROBOT ]: {
...message,
id: uniqueID(),
windowType: getWindowType()
}
});
// eslint-disable-next-line no-console
if (typeof console !== 'undefined' && typeof console[level] === 'function') {
// eslint-disable-next-line no-console
console[level]('postrobot_send', message.type.replace(/^postrobot_message_/, ''), '::', message.name, '::', domain || CONSTANTS.WILDCARD, '\n\n', message);
}
}
if (isWindowClosed(win)) {
throw new Error('Window is closed');
}
let messages = [];
let serializedMessage = JSON.stringify({
[ CONSTANTS.WINDOW_PROPS.POSTROBOT ]: message
}, null, 2);
return ZalgoPromise.map(Object.keys(SEND_MESSAGE_STRATEGIES), strategyName => {

@@ -66,0 +53,0 @@

@@ -5,3 +5,3 @@ /* @flow */

import { CONSTANTS } from '../../conf';
import { SEND_STRATEGY, PROTOCOL, WILDCARD, WINDOW_PROP } from '../../conf';
import { needsGlobalMessagingForBrowser } from '../../lib';

@@ -12,3 +12,3 @@

SEND_MESSAGE_STRATEGIES[CONSTANTS.SEND_STRATEGIES.POST_MESSAGE] = (win : CrossDomainWindowType, serializedMessage : string, domain : (string | Array<string>)) => {
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.POST_MESSAGE] = (win : CrossDomainWindowType, serializedMessage : string, domain : (string | Array<string>)) => {

@@ -30,3 +30,3 @@ if (__POST_ROBOT__.__IE_POPUP_SUPPORT__) {

} else {
domains = [ CONSTANTS.WILDCARD ];
domains = [ WILDCARD ];
}

@@ -36,6 +36,6 @@

if (dom.indexOf(CONSTANTS.MOCK_PROTOCOL) === 0) {
if (dom.indexOf(PROTOCOL.MOCK) === 0) {
if (window.location.protocol === CONSTANTS.FILE_PROTOCOL) {
return CONSTANTS.WILDCARD;
if (window.location.protocol === PROTOCOL.FILE) {
return WILDCARD;
}

@@ -51,4 +51,4 @@

if (dom.indexOf(CONSTANTS.FILE_PROTOCOL) === 0) {
return CONSTANTS.WILDCARD;
if (dom.indexOf(PROTOCOL.FILE) === 0) {
return WILDCARD;
}

@@ -68,3 +68,3 @@

SEND_MESSAGE_STRATEGIES[CONSTANTS.SEND_STRATEGIES.BRIDGE] = (win : CrossDomainWindowType, serializedMessage : string, domain : string) => {
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.BRIDGE] = (win : CrossDomainWindowType, serializedMessage : string, domain : string) => {

@@ -83,3 +83,3 @@ if (!needsBridgeForBrowser() && !isBridge()) {

return sendBridgeMessage(win, serializedMessage, domain);
return sendBridgeMessage(win, domain, serializedMessage);
};

@@ -90,3 +90,3 @@ }

SEND_MESSAGE_STRATEGIES[CONSTANTS.SEND_STRATEGIES.GLOBAL] = (win : CrossDomainWindowType, serializedMessage : string) => {
SEND_MESSAGE_STRATEGIES[SEND_STRATEGY.GLOBAL] = (win : CrossDomainWindowType, serializedMessage : string) => {

@@ -106,3 +106,3 @@ if (!needsGlobalMessagingForBrowser()) {

// $FlowFixMe
let foreignGlobal = win[CONSTANTS.WINDOW_PROPS.POSTROBOT];
let foreignGlobal = win[WINDOW_PROP.POSTROBOT];

@@ -109,0 +109,0 @@ if (!foreignGlobal) {

/* @flow */
import { CONSTANTS } from './conf';
import { WINDOW_PROP } from './conf';
export let global : Object = window[CONSTANTS.WINDOW_PROPS.POSTROBOT] = window[CONSTANTS.WINDOW_PROPS.POSTROBOT] || {};
export let global : Object = window[WINDOW_PROP.POSTROBOT] = window[WINDOW_PROP.POSTROBOT] || {};

@@ -7,0 +7,0 @@ // Backwards compatibility

/* @flow */
import { initOnReady, listenForMethods } from './lib';
import { initOnReady } from './lib';
import { listenForMessages } from './drivers';
import { global } from './global';
import { on, send } from './public';
export * from './public';
export { markWindowKnown } from './lib';
export { markWindowKnown, serializeMessage, deserializeMessage } from './lib';
export { cleanUpWindow } from './clean';

@@ -23,3 +22,2 @@ export { ZalgoPromise as Promise } from 'zalgo-promise/src';

initOnReady();
listenForMethods({ on, send });
}

@@ -26,0 +24,0 @@

@@ -8,3 +8,3 @@ /* @flow */

import { CONSTANTS } from '../conf';
import { MESSAGE_NAME, WILDCARD } from '../conf';
import { global } from '../global';

@@ -17,3 +17,3 @@

export function onHello(handler : ({ source? : CrossDomainWindowType, origin? : string }) => void) {
global.on(CONSTANTS.POST_MESSAGE_NAMES.HELLO, { domain: CONSTANTS.WILDCARD }, ({ source, origin }) => {
global.on(MESSAGE_NAME.HELLO, { domain: WILDCARD }, ({ source, origin }) => {
return handler({ source, origin });

@@ -24,3 +24,3 @@ });

export function sayHello(win : CrossDomainWindowType) : ZalgoPromise<{ origin : string }> {
return global.send(win, CONSTANTS.POST_MESSAGE_NAMES.HELLO, {}, { domain: CONSTANTS.WILDCARD, timeout: -1 })
return global.send(win, MESSAGE_NAME.HELLO, {}, { domain: WILDCARD, timeout: -1 })
.then(({ origin }) => {

@@ -27,0 +27,0 @@ return { origin };

@@ -6,13 +6,12 @@ /* @flow */

import { ZalgoPromise } from 'zalgo-promise/src';
import { once, uniqueID, replaceObject, stringifyError, isRegex } from 'belter/src';
import { once, uniqueID } from 'belter/src';
import { TYPE, serialize, serializeType, deserialize, type CustomSerializedType, type Thenable } from 'universal-serialize/src';
import { CONSTANTS } from '../conf';
import { MESSAGE_NAME, WILDCARD } from '../conf';
import { global } from '../global';
global.methods = global.methods || new WeakMap();
export let listenForMethods = once(() => {
global.on(CONSTANTS.POST_MESSAGE_NAMES.METHOD, { origin: CONSTANTS.WILDCARD }, ({ source, origin, data } : { source : CrossDomainWindowType, origin : string, data : Object }) => {
const listenForFunctionCalls = once(() => {
global.on(MESSAGE_NAME.METHOD, { origin: WILDCARD }, ({ source, origin, data } : { source : CrossDomainWindowType, origin : string, data : Object }) => {
let methods = global.methods.get(source);

@@ -33,13 +32,8 @@

}
return ZalgoPromise.try(() => {
return meth.method.apply({ source, origin, data }, data.args);
return meth.val.apply({ source, origin, data }, data.args);
}).then(result => {
return {
result,
id: data.id,
name: data.name
};
const { id, name } = data;
return { result, id, name };
});

@@ -49,14 +43,13 @@ });

function isSerialized(item : mixed, type : string) : boolean {
return typeof item === 'object' && item !== null && item.__type__ === type;
}
type SerializedMethod = {
__type__ : string,
__id__ : string,
__name__ : string
const CUSTOM_TYPE = {
CROSS_DOMAIN_ZALGO_PROMISE: ('cross_domain_zalgo_promise' : 'cross_domain_zalgo_promise'),
CROSS_DOMAIN_FUNCTION: ('cross_domain_function' : 'cross_domain_function')
};
export function serializeMethod(destination : CrossDomainWindowType, domain : string | Array<string>, method : Function, name : string) : SerializedMethod {
type SerializedFunction = CustomSerializedType<typeof CUSTOM_TYPE.CROSS_DOMAIN_FUNCTION, {
id : string,
name : string
}>;
function serializeFunction<T>(destination : CrossDomainWindowType, domain : string | Array<string>, val : () => ZalgoPromise<T> | T, key : string) : SerializedFunction {
let id = uniqueID();

@@ -71,165 +64,54 @@

methods[id] = { domain, method };
methods[id] = { domain, val };
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.METHOD,
__id__: id,
__name__: name
};
}
listenForFunctionCalls();
type SerializedError = {
__type__ : string,
__message__ : string
};
function serializeError(err : mixed) : SerializedError {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.ERROR,
__message__: stringifyError(err),
// $FlowFixMe
__code__: err.code
};
return serializeType(CUSTOM_TYPE.CROSS_DOMAIN_FUNCTION, { id, name: val.name || key });
}
type SerializePromise = {
__type__ : string,
__then__ : SerializedMethod
};
function deserializeFunction<T>(source, origin, { id, name }) : (...args : $ReadOnlyArray<mixed>) => ZalgoPromise<T> {
function serializePromise(destination : CrossDomainWindowType, domain : string | Array<string>, promise : ZalgoPromise<mixed>, name : string) : SerializePromise {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.PROMISE,
__then__: serializeMethod(destination, domain, (resolve, reject) => promise.then(resolve, reject), `${ name }.then`)
};
}
function serializeZalgoPromise(destination : CrossDomainWindowType, domain : string | Array<string>, promise : ZalgoPromise<mixed>, name : string) : SerializePromise {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.ZALGO_PROMISE,
__then__: serializeMethod(destination, domain, (resolve, reject) => promise.then(resolve, reject), `${ name }.then`)
};
}
type SerializedRegex = {
__type__ : string,
__source__ : string
};
function serializeRegex(regex : RegExp) : SerializedRegex {
return {
__type__: CONSTANTS.SERIALIZATION_TYPES.REGEX,
__source__: regex.source
};
}
export function serializeMethods(destination : CrossDomainWindowType, domain : string | Array<string>, obj : Object) : Object {
return replaceObject({ obj }, (item, key) => {
if (typeof item === 'function') {
return serializeMethod(destination, domain, item, key.toString());
}
if (item instanceof Error) {
return serializeError(item);
}
if (window.Promise && item instanceof window.Promise) {
return serializePromise(destination, domain, item, key.toString());
}
if (ZalgoPromise.isPromise(item)) {
// $FlowFixMe
return serializeZalgoPromise(destination, domain, item, key.toString());
}
if (isRegex(item)) {
// $FlowFixMe
return serializeRegex(item);
}
return item;
}).obj;
}
export function deserializeMethod(source : CrossDomainWindowType, origin : string, obj : Object) : Function {
function wrapper() : ZalgoPromise<mixed> {
function crossDomainFunctionWrapper<X : mixed>() : ZalgoPromise<X> {
let args = Array.prototype.slice.call(arguments);
return global.send(source, CONSTANTS.POST_MESSAGE_NAMES.METHOD, {
id: obj.__id__,
name: obj.__name__,
args
}, { domain: origin, timeout: -1 }).then(({ data }) => {
return data.result;
}, err => {
throw err;
});
return global.send(source, MESSAGE_NAME.METHOD, { id, name, args }, { domain: origin })
.then(({ data }) => data.result);
}
wrapper.__name__ = obj.__name__;
wrapper.__xdomain__ = true;
crossDomainFunctionWrapper.__name__ = name;
crossDomainFunctionWrapper.__xdomain__ = true;
wrapper.source = source;
wrapper.origin = origin;
crossDomainFunctionWrapper.source = source;
crossDomainFunctionWrapper.origin = origin;
return wrapper;
return crossDomainFunctionWrapper;
}
export function deserializeError(source : CrossDomainWindowType, origin : string, obj : Object) : Error {
let err = new Error(obj.__message__);
if (obj.__code__) {
// $FlowFixMe
err.code = obj.__code__;
}
return err;
}
type SerializedPromise = CustomSerializedType<typeof CUSTOM_TYPE.CROSS_DOMAIN_ZALGO_PROMISE, {
then : SerializedFunction
}>;
export function deserializeZalgoPromise(source : CrossDomainWindowType, origin : string, prom : Object) : ZalgoPromise<mixed> {
return new ZalgoPromise((resolve, reject) => deserializeMethod(source, origin, prom.__then__)(resolve, reject));
function serializePromise(destination : CrossDomainWindowType, domain : string | Array<string>, val : Thenable, key : string) : SerializedPromise {
return serializeType(CUSTOM_TYPE.CROSS_DOMAIN_ZALGO_PROMISE, {
then: serializeFunction(destination, domain, (resolve, reject) => val.then(resolve, reject), key)
});
}
export function deserializePromise(source : CrossDomainWindowType, origin : string, prom : Object) : ZalgoPromise<mixed> {
if (!window.Promise) {
return deserializeZalgoPromise(source, origin, prom);
}
return new window.Promise((resolve, reject) => deserializeMethod(source, origin, prom.__then__)(resolve, reject));
function deserializePromise<T>(source : CrossDomainWindowType, origin : string, { then } : { then : Function }) : ZalgoPromise<T> {
return new ZalgoPromise((resolve, reject) => {
deserializeFunction(source, origin, then)(resolve, reject);
});
}
export function deserializeRegex(source : CrossDomainWindowType, origin : string, item : Object) : RegExp {
// eslint-disable-next-line security/detect-non-literal-regexp
return new RegExp(item.__source__);
export function serializeMessage<T : mixed>(destination : CrossDomainWindowType, domain : string | Array<string>, obj : T) : string {
return serialize(obj, {
[ TYPE.PROMISE ]: (val : Thenable, key : string) : SerializedPromise => serializePromise(destination, domain, val, key),
[ TYPE.FUNCTION ]: (val : Function, key : string) : SerializedFunction => serializeFunction(destination, domain, val, key)
});
}
export function deserializeMethods(source : CrossDomainWindowType, origin : string, obj : Object) : Object {
return replaceObject({ obj }, (item) => {
if (typeof item !== 'object' || item === null) {
return item;
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.METHOD)) {
return deserializeMethod(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.ERROR)) {
return deserializeError(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.PROMISE)) {
return deserializePromise(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.ZALGO_PROMISE)) {
return deserializeZalgoPromise(source, origin, item);
}
if (isSerialized(item, CONSTANTS.SERIALIZATION_TYPES.REGEX)) {
return deserializeRegex(source, origin, item);
}
return item;
}).obj;
export function deserializeMessage<T : mixed>(source : CrossDomainWindowType, origin : string, message : string) : T {
return deserialize(message, {
[ CUSTOM_TYPE.CROSS_DOMAIN_ZALGO_PROMISE ]: ({ then }) => deserializePromise(source, origin, { then }),
[ CUSTOM_TYPE.CROSS_DOMAIN_FUNCTION ]: ({ id, name }) => deserializeFunction(source, origin, { id, name })
});
}

@@ -5,3 +5,3 @@ /* @flow */

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, WINDOW_TYPE } from '../conf';

@@ -11,8 +11,8 @@

if (isPopup()) {
return CONSTANTS.WINDOW_TYPES.POPUP;
return WINDOW_TYPE.POPUP;
}
if (isIframe()) {
return CONSTANTS.WINDOW_TYPES.IFRAME;
return WINDOW_TYPE.IFRAME;
}
return CONSTANTS.WINDOW_TYPES.FULLPAGE;
return WINDOW_TYPE.FULLPAGE;
}

@@ -19,0 +19,0 @@

@@ -9,3 +9,3 @@ /* @flow */

import { CONFIG, CONSTANTS } from '../conf';
import { CONFIG, MESSAGE_TYPE, WILDCARD } from '../conf';
import { sendMessage, addResponseListener, deleteResponseListener, markResponseListenerErrored, type ResponseListenerType } from '../drivers';

@@ -89,3 +89,3 @@ import { onChildWindowReady, sayHello, isWindowKnown } from '../lib';

domain = options.domain || CONSTANTS.WILDCARD;
domain = options.domain || WILDCARD;

@@ -161,9 +161,9 @@ let hash = `${ options.name }_${ uniqueID() }`;

sendMessage(win, {
type: CONSTANTS.POST_MESSAGE_TYPE.REQUEST,
sendMessage(win, actualDomain, {
type: MESSAGE_TYPE.REQUEST,
hash,
name,
data: options.data,
fireAndForget: options.fireAndForget
}, actualDomain).catch(reject);
fireAndForget: Boolean(options.fireAndForget)
}).catch(reject);

@@ -170,0 +170,0 @@ if (options.fireAndForget) {

/* @flow */
import { CONSTANTS } from '../conf';
import { WINDOW_PROP } from '../conf';
import { messageListener } from '../drivers';
export { CONFIG, CONSTANTS } from '../conf';
export { CONFIG } from '../conf';
export function disable() {
delete window[CONSTANTS.WINDOW_PROPS.POSTROBOT];
delete window[WINDOW_PROP.POSTROBOT];
window.removeEventListener('message', messageListener);
}

@@ -8,7 +8,7 @@ /* @flow */

import { addRequestListener, type RequestListenerType } from '../drivers';
import { CONSTANTS } from '../conf';
import { WILDCARD } from '../conf';
import { global } from '../global';
type ErrorHandlerType = (err : mixed) => void;
type HandlerType = ({ source : CrossDomainWindowType, origin : string, data : Object }) => (void | mixed | ZalgoPromise<mixed>);
type HandlerType = ({ source : CrossDomainWindowType, origin : string, data : mixed }) => (void | mixed | ZalgoPromise<mixed>);

@@ -45,3 +45,3 @@ type ServerOptionsType = {

window: win,
domain: domain || CONSTANTS.WILDCARD,
domain: domain || WILDCARD,
name

@@ -48,0 +48,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc