UNPKG

71.3 kBJavaScriptView Raw
1"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var EventSubscription=function(){function e(t){_classCallCheck(this,e),this.subscriber=t}return e.prototype.remove=function(){this.subscriber&&(this.subscriber.removeSubscription(this),this.subscriber=null)},e}(),EventSubscription_1=EventSubscription;function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var EmitterSubscription=function(e){function t(r,n,o){_classCallCheck$1(this,t),e.call(this,r),this.listener=n,this.context=o}return _inherits(t,e),t}(EventSubscription_1),EmitterSubscription_1=EmitterSubscription,validateFormat=function(e){};function invariant(e,t,r,n,o,i,s,a){if(validateFormat(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,o,i,s,a],l=0;(c=new Error(t.replace(/%s/g,function(){return u[l++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}"production"!==process.env.NODE_ENV&&(validateFormat=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")});var invariant_1=invariant;function _classCallCheck$2(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var EventSubscriptionVendor=function(){function e(){_classCallCheck$2(this,e),this._subscriptionsForType={},this._currentSubscription=null}return e.prototype.addSubscription=function(e,t){t.subscriber!==this&&("production"!==process.env.NODE_ENV?invariant_1(!1,"The subscriber of the subscription is incorrectly set."):invariant_1(!1)),this._subscriptionsForType[e]||(this._subscriptionsForType[e]=[]);var r=this._subscriptionsForType[e].length;return this._subscriptionsForType[e].push(t),t.eventType=e,t.key=r,t},e.prototype.removeAllSubscriptions=function(e){void 0===e?this._subscriptionsForType={}:delete this._subscriptionsForType[e]},e.prototype.removeSubscription=function(e){var t=e.eventType,r=e.key,n=this._subscriptionsForType[t];n&&delete n[r]},e.prototype.getSubscriptionsForType=function(e){return this._subscriptionsForType[e]},e}(),EventSubscriptionVendor_1=EventSubscriptionVendor;function makeEmptyFunction(e){return function(){return e}}var emptyFunction=function(){};emptyFunction.thatReturns=makeEmptyFunction,emptyFunction.thatReturnsFalse=makeEmptyFunction(!1),emptyFunction.thatReturnsTrue=makeEmptyFunction(!0),emptyFunction.thatReturnsNull=makeEmptyFunction(null),emptyFunction.thatReturnsThis=function(){return this},emptyFunction.thatReturnsArgument=function(e){return e};var emptyFunction_1=emptyFunction;function _classCallCheck$3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var BaseEventEmitter=function(){function e(){_classCallCheck$3(this,e),this._subscriber=new EventSubscriptionVendor_1,this._currentSubscription=null}return e.prototype.addListener=function(e,t,r){return this._subscriber.addSubscription(e,new EmitterSubscription_1(this._subscriber,t,r))},e.prototype.once=function(e,t,r){var n=this;return this.addListener(e,function(){n.removeCurrentListener(),t.apply(r,arguments)})},e.prototype.removeAllListeners=function(e){this._subscriber.removeAllSubscriptions(e)},e.prototype.removeCurrentListener=function(){this._currentSubscription||("production"!==process.env.NODE_ENV?invariant_1(!1,"Not in an emitting cycle; there is no current subscription"):invariant_1(!1)),this._subscriber.removeSubscription(this._currentSubscription)},e.prototype.listeners=function(e){var t=this._subscriber.getSubscriptionsForType(e);return t?t.filter(emptyFunction_1.thatReturnsTrue).map(function(e){return e.listener}):[]},e.prototype.emit=function(e){var t=this._subscriber.getSubscriptionsForType(e);if(t){for(var r=Object.keys(t),n=0;n<r.length;n++){var o=t[r[n]];o&&(this._currentSubscription=o,this.__emitToSubscription.apply(this,[o].concat(Array.prototype.slice.call(arguments))))}this._currentSubscription=null}},e.prototype.__emitToSubscription=function(e,t){var r=Array.prototype.slice.call(arguments,2);e.listener.apply(e.context,r)},e}(),BaseEventEmitter_1=BaseEventEmitter,fbemitter={EventEmitter:BaseEventEmitter_1,EmitterSubscription:EmitterSubscription_1},fbemitter_1=fbemitter,fbemitter_2=fbemitter_1.EventEmitter,commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var postRobot=createCommonjsModule(function(e,t){"undefined"!=typeof self&&self,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./src/index.js")}({"./node_modules/cross-domain-utils/src/constants.js":function(e,t,r){r.d(t,"a",function(){return n}),r.d(t,"b",function(){return o});var n={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},o="*"},"./node_modules/cross-domain-utils/src/index.js":function(e,t,r){var n=r("./node_modules/cross-domain-utils/src/utils.js");r.d(t,"getActualDomain",function(){return n.a}),r.d(t,"getAncestor",function(){return n.b}),r.d(t,"getDomain",function(){return n.c}),r.d(t,"getUserAgent",function(){return n.d}),r.d(t,"isActuallySameDomain",function(){return n.e}),r.d(t,"isAncestor",function(){return n.f}),r.d(t,"isIframe",function(){return n.g}),r.d(t,"isPopup",function(){return n.h}),r.d(t,"isWindow",function(){return n.i}),r.d(t,"isWindowClosed",function(){return n.j}),r.d(t,"matchDomain",function(){return n.k}),r.d(t,"stringifyDomainPattern",function(){return n.l});var o=r("./node_modules/cross-domain-utils/src/types.js");r.n(o),r("./node_modules/cross-domain-utils/src/constants.js")},"./node_modules/cross-domain-utils/src/types.js":function(e,t){},"./node_modules/cross-domain-utils/src/utils.js":function(e,t,r){function n(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var o=r("./node_modules/cross-domain-utils/src/constants.js");t.a=l,t.c=f,t.e=d,t.j=function(e){var t=!(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(t&&function(e){if(!d(e))return!1;try{if(e===window)return!0;if(s(e)&&u(e))return!0;if(f(window)===f(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,t){for(var r=0;r<e.length;r++)try{if(e[r]===t)return r}catch(e){}return-1}(m,e);if(-1!==r){var n=y[r];if(n&&function(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var t=e.ownerDocument;return!(!t||!t.documentElement||t.documentElement.contains(e))}(n))return!0}return!1},t.d=function(e){return(e=e||window).navigator.mockUserAgent||e.navigator.userAgent},t.b=g,t.f=function(e,t){var r=g(t);if(r)return r===e;if(t===e)return!1;if(function(e){if(e){try{if(e.top)return e.top}catch(e){}if(a(e)===e)return e;try{if(p(window,e)&&window.top)return window.top}catch(e){}try{if(p(e,window)&&window.top)return window.top}catch(e){}for(var t=0,r=function e(t){for(var r=[],n=0,o=h(t),i=null==o?0:o.length;n<i;n++){var s=o[n];r.push(s);for(var a=0,c=e(s),u=null==c?0:c.length;a<u;a++){var l=c[a];r.push(l)}}return r}(e),n=null==r?0:r.length;t<n;t++){var o=r[t];try{if(o.top)return o.top}catch(e){}if(a(o)===o)return o}}}(t)===t)return!1;for(var n=0,o=h(e),i=null==o?0:o.length;n<i;n++)if(o[n]===t)return!0;return!1},t.h=function(){return Boolean(c(window))},t.g=function(){return Boolean(a(window))},t.k=function e(t,r){if("string"==typeof t){if("string"==typeof r)return t===o.b||r===t;if(n(r))return!1;if(Array.isArray(r))return!1}return n(t)?n(r)?t.toString()===r.toString():!Array.isArray(r)&&Boolean(r.match(t)):!!Array.isArray(t)&&(Array.isArray(r)?JSON.stringify(t)===JSON.stringify(r):!n(r)&&t.some(function(t){return e(t,r)}))},t.l=function(e){return Array.isArray(e)?"("+e.join(" | ")+")":n(e)?"RegExp("+e.toString():e.toString()},t.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 i="Call was rejected by callee.\r\n";function s(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).location.protocol===o.a.ABOUT}function a(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function c(e){if(e&&!a(e))try{return e.opener}catch(e){}}function u(e){try{return e&&e.location&&e.location.href,!0}catch(e){}return!1}function l(e){var t=(e=e||window).location;if(!t)throw new Error("Can not read window location");var r=t.protocol;if(!r)throw new Error("Can not read window protocol");if(r===o.a.FILE)return o.a.FILE+"//";if(r===o.a.ABOUT){var n=a(e);return n&&u(n)?l(n):o.a.ABOUT+"//"}var i=t.host;if(!i)throw new Error("Can not read window host");return r+"//"+i}function f(e){var t=l(e=e||window);return t&&e.mockDomain&&0===e.mockDomain.indexOf(o.a.MOCK)?e.mockDomain:t}function d(e){try{if(e===window)return!0}catch(e){}try{var t=Object.getOwnPropertyDescriptor(e,"location");if(t&&!1===t.enumerable)return!1}catch(e){}try{if(s(e)&&u(e))return!0}catch(e){}try{if(l(e)===l(window))return!0}catch(e){}return!1}function p(e,t){if(!e||!t)return!1;var r=a(t);return r?r===e:-1!==function(e){var t=[];try{for(;e.parent!==e;)t.push(e.parent),e=e.parent}catch(e){}return t}(t).indexOf(e)}function h(e){var t=[],r=void 0;try{r=e.frames}catch(t){r=e}var n=void 0;try{n=r.length}catch(e){}if(0===n)return t;if(n){for(var o=0;o<n;o++){var i=void 0;try{i=r[o]}catch(e){continue}t.push(i)}return t}for(var s=0;s<100;s++){var a=void 0;try{a=r[s]}catch(e){return t}if(!a)return t;t.push(a)}return t}var m=[],y=[];function g(e){return c(e=e||window)||a(e)||void 0}},"./src/index.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),r.d({},"WeakMap",function(){return u});var n={};r.d(n,"cleanUpWindow",function(){return re}),r.d(n,"Promise",function(){return _}),r.d(n,"bridge",function(){return ne}),r.d(n,"init",function(){return oe}),r.d(n,"parent",function(){return te}),r.d(n,"send",function(){return K}),r.d(n,"request",function(){return z}),r.d(n,"sendToParent",function(){return Y}),r.d(n,"client",function(){return q}),r.d(n,"on",function(){return J}),r.d(n,"listen",function(){return V}),r.d(n,"once",function(){return Q}),r.d(n,"listener",function(){return X}),r.d(n,"CONFIG",function(){return d}),r.d(n,"CONSTANTS",function(){return l}),r.d(n,"disable",function(){return ee});var o=r("./node_modules/cross-domain-utils/src/index.js");function i(e,t){for(var r=0;r<e.length;r++)try{if(e[r]===t)return r}catch(e){}return-1}var s,a=Object.defineProperty,c=Date.now()%1e9,u=function(){function e(){if(function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),c+=1,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__"+c,function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var e=new WeakMap,t={};return Object.freeze(t),e.set(t,"__testvalue__"),"__testvalue__"===e.get(t)}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,t=this.keys,r=0;r<t.length;r++){var n=t[r];if(Object(o.isWindow)(n)&&Object(o.isWindowClosed)(n)){if(e)try{e.delete(n)}catch(e){}t.splice(r,1),this.values.splice(r,1),r-=1}}},e.prototype.isSafeToReadWrite=function(e){if(Object(o.isWindow)(e))return!1;try{e&&e.self,e&&e[this.name]}catch(e){return!1}return!0},e.prototype.set=function(e,t){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.set(e,t)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var n=this.name,o=e[n];o&&o[0]===e?o[1]=t:a(e,n,{value:[e,t],writable:!0})}else{this._cleanupClosedWindows();var s=this.keys,c=this.values,u=i(s,e);-1===u?(s.push(e),c.push(t)):c[u]=t}},e.prototype.get=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{if(t.has(e))return t.get(e)}catch(e){delete this.weakmap}if(!this.isSafeToReadWrite(e)){this._cleanupClosedWindows();var r=i(this.keys,e);if(-1===r)return;return this.values[r]}var n=e[this.name];if(n&&n[0]===e)return n[1]},e.prototype.delete=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{t.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 n=this.keys,o=i(n,e);-1!==o&&(n.splice(o,1),this.values.splice(o,1))}},e.prototype.has=function(e){if(!e)throw new Error("WeakMap expected key");var t=this.weakmap;if(t)try{if(t.has(e))return!0}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=e[this.name];return!(!r||r[0]!==e)}return this._cleanupClosedWindows(),-1!==i(this.keys,e)},e.prototype.getOrSet=function(e,t){if(this.has(e))return this.get(e);var r=t();return this.set(e,r),r},e}(),l={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:"*"},f={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},d=(Object.keys(f).map(function(e){return f[e]}),{ALLOW_POSTMESSAGE_POPUP:!("__ALLOW_POSTMESSAGE_POPUP__"in window)||window.__ALLOW_POSTMESSAGE_POPUP__,BRIDGE_TIMEOUT:5e3,CHILD_WINDOW_TIMEOUT:5e3,ACK_TIMEOUT:-1!==window.navigator.userAgent.match(/MSIE/i)?1e4:2e3,RES_TIMEOUT:-1,ALLOWED_POST_MESSAGE_METHODS:(s={},s[l.SEND_STRATEGIES.POST_MESSAGE]=!0,s[l.SEND_STRATEGIES.BRIDGE]=!0,s[l.SEND_STRATEGIES.GLOBAL]=!0,s),ALLOW_SAME_ORIGIN:!1});0===window.location.href.indexOf(l.FILE_PROTOCOL)&&(d.ALLOW_POSTMESSAGE_POPUP=!0);var p="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 h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(t>=3)return"stringifyError stack overflow";try{if(!e)return"<unknown error: "+Object.prototype.toString.call(e)+">";if("string"==typeof e)return e;if(e instanceof Error){var r=e&&e.stack,n=e&&e.message;if(r&&n)return-1!==r.indexOf(n)?r:n+"\n"+r;if(r)return r;if(n)return n}return"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)}catch(e){return"Error while stringifying error: "+h(e,t+1)}}var m=function(e){if(!e)return e;var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}};function y(){}function g(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})}function E(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(r>=100)throw new Error("Self-referential object passed, or object contained too many layers");var n=void 0;if("object"!==(void 0===e?"undefined":p(e))||null===e||Array.isArray(e)){if(!Array.isArray(e))throw new TypeError("Invalid type: "+(void 0===e?"undefined":p(e)));n=[]}else n={};return function(e,t){Array.isArray(e)?function(e,t){for(var r=0;r<e.length;r++)t(e[r],r)}(e,t):"object"===(void 0===e?"undefined":p(e))&&null!==e&&function(e,t){for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)}(e,t)}(e,function(e,o){var i=t(e,o);void 0!==i?n[o]=i:"object"===(void 0===e?"undefined":p(e))&&null!==e?n[o]=E(e,t,r+1):n[o]=e}),n}function w(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function v(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 t={}.toString;if(t){var r=t.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 b(){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 t=e.__zalgopromise__=e.__zalgopromise__||{};return t.flushPromises=t.flushPromises||[],t.activeCount=t.activeCount||0,t.possiblyUnhandledPromiseHandlers=t.possiblyUnhandledPromiseHandlers||[],t.dispatchedErrors=t.dispatchedErrors||[],t}var _=function(){function e(t){var r=this;if(function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],t){var n=void 0,o=void 0,i=!1,s=!1,a=!1;try{t(function(e){a?r.resolve(e):(i=!0,n=e)},function(e){a?r.reject(e):(s=!0,o=e)})}catch(e){return void this.reject(e)}a=!0,i?this.resolve(n):s&&this.reject(o)}}return e.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(v(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 t=this;if(this.resolved||this.rejected)return this;if(v(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(){t.errorHandled||function(e,t){if(-1===b().dispatchedErrors.indexOf(e)){b().dispatchedErrors.push(e),setTimeout(function(){throw e},1);for(var r=0;r<b().possiblyUnhandledPromiseHandlers.length;r++)b().possiblyUnhandledPromiseHandlers[r](e,t)}}(e,t)},1),this.dispatch(),this},e.prototype.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},e.prototype.dispatch=function(){var t=this,r=this.dispatching,n=this.resolved,o=this.rejected,i=this.handlers;if(!r&&(n||o)){this.dispatching=!0,b().activeCount+=1;for(var s=function(r){var s=i[r],a=s.onSuccess,c=s.onError,u=s.promise,l=void 0;if(n)try{l=a?a(t.value):t.value}catch(e){return u.reject(e),"continue"}else if(o){if(!c)return u.reject(t.error),"continue";try{l=c(t.error)}catch(e){return u.reject(e),"continue"}}l instanceof e&&(l.resolved||l.rejected)?(l.resolved?u.resolve(l.value):u.reject(l.error),l.errorHandled=!0):v(l)?l instanceof e&&(l.resolved||l.rejected)?l.resolved?u.resolve(l.value):u.reject(l.error):l.then(function(e){u.resolve(e)},function(e){u.reject(e)}):u.resolve(l)},a=0;a<i.length;a++)s(a);i.length=0,this.dispatching=!1,b().activeCount-=1,0===b().activeCount&&e.flushQueue()}},e.prototype.then=function(t,r){if(t&&"function"!=typeof t&&!t.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 n=new e;return this.handlers.push({promise:n,onSuccess:t,onError:r}),this.errorHandled=!0,this.dispatch(),n},e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.finally=function(t){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return e.try(t).then(function(){return r})},function(r){return e.try(t).then(function(){throw r})})},e.prototype.timeout=function(e,t){var r=this;if(this.resolved||this.rejected)return this;var n=setTimeout(function(){r.resolved||r.rejected||r.reject(t||new Error("Promise timed out after "+e+"ms"))},e);return this.then(function(e){return clearTimeout(n),e})},e.prototype.toPromise=function(){if("undefined"==typeof Promise)throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.resolve=function(t){return t instanceof e?t:v(t)?new e(function(e,r){return t.then(e,r)}):(new e).resolve(t)},e.reject=function(t){return(new e).reject(t)},e.asyncReject=function(t){return(new e).asyncReject(t)},e.all=function(t){var r=new e,n=t.length,o=[];if(!n)return r.resolve(o),r;for(var i=function(i){var s=t[i];if(s instanceof e){if(s.resolved)return o[i]=s.value,n-=1,"continue"}else if(!v(s))return o[i]=s,n-=1,"continue";e.resolve(s).then(function(e){o[i]=e,0==(n-=1)&&r.resolve(o)},function(e){r.reject(e)})},s=0;s<t.length;s++)i(s);return 0===n&&r.resolve(o),r},e.hash=function(t){var r={};return e.all(Object.keys(t).map(function(n){return e.resolve(t[n]).then(function(e){r[n]=e})})).then(function(){return r})},e.map=function(t,r){return e.all(t.map(r))},e.onPossiblyUnhandledException=function(e){return function(e){return b().possiblyUnhandledPromiseHandlers.push(e),{cancel:function(){b().possiblyUnhandledPromiseHandlers.splice(b().possiblyUnhandledPromiseHandlers.indexOf(e),1)}}}(e)},e.try=function(t,r,n){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.try expected a function");var o=void 0;try{o=t.apply(r,n||[])}catch(t){return e.reject(t)}return e.resolve(o)},e.delay=function(t){return new e(function(e){setTimeout(e,t)})},e.isPromise=function(t){return!!(t&&t instanceof e)||v(t)},e.flush=function(){var t=new e;return b().flushPromises.push(t),0===b().activeCount&&e.flushQueue(),t},e.flushQueue=function(){var e=b().flushPromises;b().flushPromises=[];for(var t=0,r=null==e?0:e.length;t<r;t++)e[t].resolve()},e}(),O=window[l.WINDOW_PROPS.POSTROBOT]=window[l.WINDOW_PROPS.POSTROBOT]||{};O.registerSelf=function(){};var S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};O.methods=O.methods||new u;var C=m(function(){O.on(l.POST_MESSAGE_NAMES.METHOD,{origin:l.WILDCARD},function(e){var t=e.source,r=e.origin,n=e.data,i=O.methods.get(t);if(!i)throw new Error("Could not find any methods this window has privileges to call");var s=i[n.id];if(!s)throw new Error("Could not find method with id: "+n.id);if(!Object(o.matchDomain)(s.domain,r))throw new Error("Method domain "+s.domain+" does not match origin "+r);return _.try(function(){return s.method.apply({source:t,origin:r,data:n},n.args)}).then(function(e){return{result:e,id:n.id,name:n.name}})})});function A(e,t){return"object"===(void 0===e?"undefined":S(e))&&null!==e&&e.__type__===t}function I(e,t,r,n){var o=g(),i=O.methods.get(e);return i||(i={},O.methods.set(e,i)),i[o]={domain:t,method:r},{__type__:l.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:n}}function R(e,t,r){function n(){var n=Array.prototype.slice.call(arguments);return O.send(e,l.POST_MESSAGE_NAMES.METHOD,{id:r.__id__,name:r.__name__,args:n},{domain:t,timeout:-1}).then(function(e){return e.data.result},function(e){throw e})}return n.__name__=r.__name__,n.__xdomain__=!0,n.source=e,n.origin=t,n}function T(e,t,r){return new _(function(n,o){return R(e,t,r.__then__)(n,o)})}function j(e){return O.send(e,l.POST_MESSAGE_NAMES.HELLO,{},{domain:l.WILDCARD,timeout:-1}).then(function(e){return{origin:e.origin}})}O.readyPromises=O.readyPromises||new u;var P={};P[l.SEND_STRATEGIES.POST_MESSAGE]=function(e,t,r){(Array.isArray(r)?r:"string"==typeof r?[r]:[l.WILDCARD]).map(function(t){if(0===t.indexOf(l.MOCK_PROTOCOL)){if(window.location.protocol===l.FILE_PROTOCOL)return l.WILDCARD;if(!Object(o.isActuallySameDomain)(e))throw new Error("Attempting to send messsage to mock domain "+t+", but window is actually cross-domain");return Object(o.getActualDomain)(e)}return 0===t.indexOf(l.FILE_PROTOCOL)?l.WILDCARD:t}).forEach(function(r){return e.postMessage(t,r)})};var N=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};function D(e,t,r){return _.try(function(){var n;if(t=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=g(),i=Object(o.isPopup)()?l.WINDOW_TYPES.POPUP:Object(o.isIframe)()?l.WINDOW_TYPES.IFRAME:l.WINDOW_TYPES.FULLPAGE,s=Object(o.getDomain)(window);return N({},t,r,{sourceDomain:s,id:t.id||n,windowType:i})}(e,t,{data:function(e,r,n){return E({obj:t.data},function(t,n){return"function"==typeof t?I(e,r,t,n.toString()):t instanceof Error?(o=t,{__type__:l.SERIALIZATION_TYPES.ERROR,__message__:h(o),__code__:o.code}):window.Promise&&t instanceof window.Promise?function(e,t,r,n){return{__type__:l.SERIALIZATION_TYPES.PROMISE,__then__:I(e,t,function(e,t){return r.then(e,t)},n+".then")}}(e,r,t,n.toString()):_.isPromise(t)?function(e,t,r,n){return{__type__:l.SERIALIZATION_TYPES.ZALGO_PROMISE,__then__:I(e,t,function(e,t){return r.then(e,t)},n+".then")}}(e,r,t,n.toString()):w(t)?(i=t,{__type__:l.SERIALIZATION_TYPES.REGEX,__source__:i.source}):void 0;var o,i}).obj}(e,r),domain:r}),e===window&&!d.ALLOW_SAME_ORIGIN)throw new Error("Attemping to send message to self");if(Object(o.isWindowClosed)(e))throw new Error("Window is closed");var i=[],s=function(e,t,r){var n=void 0,o=void 0;try{if("{}"!==JSON.stringify({})&&(n=Object.prototype.toJSON,delete Object.prototype.toJSON),"{}"!==JSON.stringify({}))throw new Error("Can not correctly serialize JSON objects");if("[]"!==JSON.stringify([])&&(o=Array.prototype.toJSON,delete Array.prototype.toJSON),"[]"!==JSON.stringify([]))throw new Error("Can not correctly serialize JSON objects")}catch(e){throw new Error("Can not repair JSON.stringify: "+e.message)}var i=JSON.stringify.call(this,e,null,2);try{n&&(Object.prototype.toJSON=n),o&&(Array.prototype.toJSON=o)}catch(e){throw new Error("Can not repair JSON.stringify: "+e.message)}return i}(((n={})[l.WINDOW_PROPS.POSTROBOT]=t,n));return _.map(Object.keys(P),function(t){return _.try(function(){if(!d.ALLOWED_POST_MESSAGE_METHODS[t])throw new Error("Strategy disallowed: "+t);return P[t](e,s,r)}).then(function(){return i.push(t+": success"),!0},function(e){return i.push(t+": "+h(e)+"\n"),!1})}).then(function(e){var r=e.some(Boolean),n=t.type+" "+t.name+" "+(r?"success":"error")+":\n - "+i.join("\n - ")+"\n";if(!r)throw new Error(n)})})}O.responseListeners=O.responseListeners||{},O.requestListeners=O.requestListeners||{},O.WINDOW_WILDCARD=O.WINDOW_WILDCARD||new function(){},O.erroredResponseListeners=O.erroredResponseListeners||{};var F,L="__domain_regex__";function x(e){return O.responseListeners[e]}function M(e){delete O.responseListeners[e]}function W(e){return Boolean(O.erroredResponseListeners[e])}function k(e){var t=e.name,r=e.win,n=e.domain;if(r===l.WILDCARD&&(r=null),n===l.WILDCARD&&(n=null),!t)throw new Error("Name required to get request listener");var i=O.requestListeners[t];if(i)for(var s=0,a=[r,O.WINDOW_WILDCARD],c=null==a?0:a.length;s<c;s++){var u=a[s],f=u&&i.get(u);if(f){if(n&&"string"==typeof n){if(f[n])return f[n];if(f[L])for(var d=0,p=f[L],h=null==p?0:p.length;d<h;d++){var m=p[d],y=m.regex,g=m.listener;if(Object(o.matchDomain)(y,n))return g}}if(f[l.WILDCARD])return f[l.WILDCARD]}}}var B=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$=((F={})[l.POST_MESSAGE_TYPE.ACK]=function(e,t,r){if(!W(r.hash)){var n=x(r.hash);if(!n)throw new Error("No handler found for post message ack for message: "+r.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(o.matchDomain)(n.domain,t))throw new Error("Ack origin "+t+" does not match domain "+n.domain.toString());n.ack=!0}},F[l.POST_MESSAGE_TYPE.REQUEST]=function(e,t,r){var n=k({name:r.name,win:e,domain:t});function i(n){return r.fireAndForget||Object(o.isWindowClosed)(e)?_.resolve():D(e,B({target:r.originalSource,hash:r.hash,name:r.name},n),t)}return _.all([i({type:l.POST_MESSAGE_TYPE.ACK}),_.try(function(){if(!n)throw new Error("No handler found for post message: "+r.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(o.matchDomain)(n.domain,t))throw new Error("Request origin "+t+" does not match domain "+n.domain.toString());var i=r.data;return n.handler({source:e,origin:t,data:i})}).then(function(e){return i({type:l.POST_MESSAGE_TYPE.RESPONSE,ack:l.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){var t=h(e).replace(/^Error: /,""),r=e.code;return i({type:l.POST_MESSAGE_TYPE.RESPONSE,ack:l.POST_MESSAGE_ACK.ERROR,error:t,code:r})})]).then(y).catch(function(e){if(n&&n.handleError)return n.handleError(e);throw e})},F[l.POST_MESSAGE_TYPE.RESPONSE]=function(e,t,r){if(!W(r.hash)){var n=x(r.hash);if(!n)throw new Error("No handler found for post message response for message: "+r.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(o.matchDomain)(n.domain,t))throw new Error("Response origin "+t+" does not match domain "+Object(o.stringifyDomainPattern)(n.domain));if(M(r.hash),r.ack===l.POST_MESSAGE_ACK.ERROR){var i=new Error(r.error);return r.code&&(i.code=r.code),n.respond(i,null)}if(r.ack===l.POST_MESSAGE_ACK.SUCCESS){var s=r.data||r.response;return n.respond(null,{source:e,origin:t,data:s})}}},F),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(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(e){return}var t=e.source,r=e.origin,n=function(e){var t,r=void 0;try{t=e,r=JSON.parse(t)}catch(e){return}if(r&&"object"===(void 0===r?"undefined":G(r))&&null!==r&&(r=r[l.WINDOW_PROPS.POSTROBOT])&&"object"===(void 0===r?"undefined":G(r))&&null!==r&&r.type&&"string"==typeof r.type&&$[r.type])return r}(e.data);if(n){if(!n.sourceDomain||"string"!=typeof n.sourceDomain)throw new Error("Expected message to have sourceDomain");0!==n.sourceDomain.indexOf(l.MOCK_PROTOCOL)&&0!==n.sourceDomain.indexOf(l.FILE_PROTOCOL)||(r=n.sourceDomain),-1===O.receivedMessages.indexOf(n.id)&&(O.receivedMessages.push(n.id),Object(o.isWindowClosed)(t)&&!n.fireAndForget||(n.data&&(n.data=function(e,t,r){return E({obj:n.data},function(r){if("object"===(void 0===r?"undefined":S(r))&&null!==r)return A(r,l.SERIALIZATION_TYPES.METHOD)?R(e,t,r):A(r,l.SERIALIZATION_TYPES.ERROR)?(n=r,o=new Error(n.__message__),n.__code__&&(o.code=n.__code__),o):A(r,l.SERIALIZATION_TYPES.PROMISE)?function(e,t,r){return window.Promise?new window.Promise(function(n,o){return R(e,t,r.__then__)(n,o)}):T(e,t,r)}(e,t,r):A(r,l.SERIALIZATION_TYPES.ZALGO_PROMISE)?T(e,t,r):A(r,l.SERIALIZATION_TYPES.REGEX)?function(e,t,r){return new RegExp(r.__source__)}(0,0,r):void 0;var n,o}).obj}(t,r)),$[n.type](t,r,n)))}}function H(e){try{e.source}catch(e){return}U({source:e.source||e.sourceElement,origin:e.origin||e.originalEvent&&e.originalEvent.origin,data:e.data})}function z(e){return _.try(function(){if(!e.name)throw new Error("Expected options.name");var t=e.name,r=void 0,n=void 0;if("string"==typeof e.window){var i=document.getElementById(e.window);if(!i)throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be a valid element id");if("iframe"!==i.tagName.toLowerCase())throw new Error("Expected options.window "+Object.prototype.toString.call(e.window)+" to be an iframe");if(!i.contentWindow)throw new Error("Iframe must have contentWindow. Make sure it has a src attribute and is in the DOM.");r=i.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 s=r;n=e.domain||l.WILDCARD;var a=e.name+"_"+g();if(Object(o.isWindowClosed)(s))throw new Error("Target window is closed");var c=!1,u=O.requestPromises.get(s);u||(u=[],O.requestPromises.set(s,u));var f=_.try(function(){if(Object(o.isAncestor)(window,s))return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Window",n=O.readyPromises.get(e);return n||(n=new _,O.readyPromises.set(e,n),-1!==t&&setTimeout(function(){return n.reject(new Error(r+" did not load after "+t+"ms"))},t),n)}(s,e.timeout||d.CHILD_WINDOW_TIMEOUT)}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(w(n)&&!e)return j(s)}).then(function(){var r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(w(n)){if(!Object(o.matchDomain)(n,r))throw new Error("Remote window domain "+r+" does not match regex: "+n.toString());n=r}if("string"!=typeof n&&!Array.isArray(n))throw new TypeError("Expected domain to be a string or array");var i=n;return new _(function(r,n){var p=void 0;if(e.fireAndForget||function(e,t){O.responseListeners[e]=t}(a,p={name:t,window:s,domain:i,respond:function(e,t){e||(c=!0,u.splice(u.indexOf(f,1))),e?n(e):r(t)}}),D(s,{type:l.POST_MESSAGE_TYPE.REQUEST,hash:a,name:t,data:e.data,fireAndForget:e.fireAndForget},i).catch(n),e.fireAndForget)return r();var h=d.ACK_TIMEOUT,m=e.timeout||d.RES_TIMEOUT,y=100;setTimeout(function r(){if(!c){if(Object(o.isWindowClosed)(s))return p.ack?n(new Error("Window closed for "+t+" before response")):n(new Error("Window closed for "+t+" before ack"));if(h=Math.max(h-y,0),-1!==m&&(m=Math.max(m-y,0)),p.ack){if(-1===m)return;y=Math.min(m,2e3)}else{if(0===h)return n(new Error("No ack for postMessage "+t+" in "+Object(o.getDomain)()+" in "+d.ACK_TIMEOUT+"ms"));if(0===m)return n(new Error("No response for postMessage "+t+" in "+Object(o.getDomain)()+" in "+(e.timeout||d.RES_TIMEOUT)+"ms"))}setTimeout(r,y)}},y)})});return f.catch(function(){!function(e){O.erroredResponseListeners[e]=!0}(a),M(a)}),u.push(f),f})}function K(e,t,r,n){return(n=n||{}).window=e,n.name=t,n.data=r,z(n)}function Y(e,t,r){var n=Object(o.getAncestor)();return n?K(n,e,t,r):new _(function(e,t){return t(new Error("Window does not have a parent"))})}function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.window)throw new Error("Expected options.window");var t=e.window;return{send:function(r,n){return K(t,r,n,e)}}}O.receivedMessages=O.receivedMessages||[],O.receiveMessage=U,O.requestPromises=O.requestPromises||new u,O.send=K;var Z="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 V(e){if(!e.name)throw new Error("Expected options.name");if(!e.handler)throw new Error("Expected options.handler");var t,r=e.name,n=e.window,i=e.domain,s={handler:e.handler,handleError:e.errorHandler||function(e){throw e},window:n,domain:i||l.WILDCARD,name:r},a=function e(t,r){var n=t.name,o=t.win,i=t.domain;if(!n||"string"!=typeof n)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var s=[],a=0,c=o,f=null==c?0:c.length;a<f;a++){var d=c[a];s.push(e({name:n,domain:i,win:d},r))}return{cancel:function(){for(var e=0,t=null==s?0:s.length;e<t;e++)s[e].cancel()}}}if(Array.isArray(i)){for(var p=[],h=0,m=i,y=null==m?0:m.length;h<y;h++){var g=m[h];p.push(e({name:n,win:o,domain:g},r))}return{cancel:function(){for(var e=0,t=null==p?0:p.length;e<t;e++)p[e].cancel()}}}var E=k({name:n,win:o,domain:i});if(o&&o!==l.WILDCARD||(o=O.WINDOW_WILDCARD),i=i||l.WILDCARD,E)throw o&&i?new Error("Request listener already exists for "+n+" on domain "+i.toString()+" for "+(o===O.WINDOW_WILDCARD?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+n+" for "+(o===O.WINDOW_WILDCARD?"wildcard":"specified")+" window"):i?new Error("Request listener already exists for "+n+" on domain "+i.toString()):new Error("Request listener already exists for "+n);var v=O.requestListeners,b=v[n];b||(b=new u,v[n]=b);var _=b.get(o);_||(_={},b.set(o,_));var S=i.toString(),C=_[L],A=void 0;return w(i)?(C||(C=[],_[L]=C),A={regex:i,listener:r},C.push(A)):_[S]=r,{cancel:function(){_&&(delete _[S],o&&0===Object.keys(_).length&&b.delete(o),A&&C.splice(C.indexOf(A,1)))}}}({name:r,win:n,domain:i},s);if(e.once){var c=s.handler;s.handler=m(function(){return a.cancel(),c.apply(this,arguments)})}if(s.window&&e.errorOnClose)var f=(t=void 0,t=setTimeout(function e(){t=setTimeout(e,50),function(){n&&"object"===(void 0===n?"undefined":Z(n))&&Object(o.isWindowClosed)(n)&&(f.cancel(),s.handleError(new Error("Post message target window is closed")))}.call()},50),{cancel:function(){clearTimeout(t)}});return{cancel:function(){a.cancel()}}}function J(e,t,r){return"function"==typeof t&&(r=t,t={}),(t=t||{}).name=e,t.handler=r||t.handler,V(t)}function Q(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];"function"==typeof t&&(r=t,t={}),t=t||{},r=r||t.handler;var n=t.errorHandler,o=new _(function(o,i){(t=t||{}).name=e,t.once=!0,t.handler=function(e){if(o(e),r)return r(e)},t.errorHandler=function(e){if(i(e),n)return n(e)}}),i=V(t);return o.cancel=i.cancel,o}function X(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{on:function(t,r){return J(t,e,r)}}}function ee(){delete window[l.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",H)}O.on=J;var te=Object(o.getAncestor)();function re(e){var t=O.requestPromises.get(e);if(t)for(var r=0,n=null==t?0:t.length;r<n;r++)t[r].reject(new Error("No response from window - cleaned up"));O.popupWindowsByWin&&O.popupWindowsByWin.delete(e),O.remoteWindows&&O.remoteWindows.delete(e),O.requestPromises.delete(e),O.methods.delete(e),O.readyPromises.delete(e)}var ne=null;function oe(){var e,t;O.initialized||(t=H,(e=window).addEventListener?e.addEventListener("message",t):e.attachEvent("onmessage",t),function(){e=function(e){var t=e.source,r=e.origin,n=O.readyPromises.get(t)||new _;n.resolve({origin:r}),O.readyPromises.set(t,n)},O.on(l.POST_MESSAGE_NAMES.HELLO,{domain:l.WILDCARD},function(t){var r=t.source,n=t.origin;return e({source:r,origin:n})});var e,t=Object(o.getAncestor)();t&&j(t).catch(y)}(),C({on:J,send:K})),O.initialized=!0}oe(),r.d(t,"cleanUpWindow",function(){return re}),r.d(t,"Promise",function(){return _}),r.d(t,"bridge",function(){return ne}),r.d(t,"init",function(){return oe}),r.d(t,"parent",function(){return te}),r.d(t,"send",function(){return K}),r.d(t,"request",function(){return z}),r.d(t,"sendToParent",function(){return Y}),r.d(t,"client",function(){return q}),r.d(t,"on",function(){return J}),r.d(t,"listen",function(){return V}),r.d(t,"once",function(){return Q}),r.d(t,"listener",function(){return X}),r.d(t,"CONFIG",function(){return d}),r.d(t,"CONSTANTS",function(){return l}),r.d(t,"disable",function(){return ee}),t.default=n}})});unwrapExports(postRobot);var Events,postRobot_1=postRobot.postRobot,postRobot$1=createCommonjsModule(function(e){e.exports=postRobot,e.exports.default=e.exports});class BearerConfig{constructor(e={}){this.integrationHost="BEARER_INTEGRATION_HOST",this.authorizationHost="BEARER_AUTHORIZATION_HOST",this.postRobotLogLevel="error",this.secured=!1,this.update(e)}get clientId(){return window.bearer&&window.bearer.clientId}update(e){Object.keys(e).forEach(t=>{this[t]=e[t]})}}!function(e){e.SESSION_INITIALIZED="BEARER_SESSION_INITIALIZED",e.COOKIE_SETUP="BEARER_COOKIE_SETUP",e.HAS_AUTHORIZED="BEARER_HAS_AUTHORIZED",e.AUTHORIZED="BEARER_AUTHORIZED",e.REVOKE="BEARER_REVOKE",e.REVOKED="BEARER_REVOKED",e.LOCALE_CHANGED="bearer-locale-changed"}(Events||(Events={}));var Events$1=Events;function cleanQuery(e){return Object.keys(e).reduce((t,r)=>(e[r]&&(t[r]=e[r]),t),{})}function formatQuery(e){return Object.keys(cleanQuery(e)).reduce((t,r)=>[...t,[r,e[r]].join("=")],[]).join("&")}var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e,t){return e(t={exports:{}},t.exports),t.exports}var n=1e3,r=60*n,o=60*r,s=24*o,i=7*s,c=365.25*s,u=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*c;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*s;case"hours":case"hour":case"hrs":case"hr":case"h":return a*o;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===u&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);return t>=s?a(e,t,s,"day"):t>=o?a(e,t,o,"hour"):t>=r?a(e,t,r,"minute"):t>=n?a(e,t,n,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=o?Math.round(e/o)+"h":t>=r?Math.round(e/r)+"m":t>=n?Math.round(e/n)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function a(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}var l=function(e){function t(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let i;function s(...e){if(!s.enabled)return;const t=s,n=Number(new Date),o=n-(i||n);t.diff=o,t.prev=i,t.curr=n,i=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,o)=>{if("%%"===n)return n;a++;const i=r.formatters[o];if("function"==typeof i){const r=e[a];n=i.call(t,r),e.splice(a,1),a--}return n}),r.formatArgs.call(t,e),(t.log||r.log).apply(t,e)}return s.namespace=e,s.enabled=r.enabled(e),s.useColors=r.useColors(),s.color=t(e),s.destroy=n,s.extend=o,"function"==typeof r.init&&r.init(s),r.instances.push(s),s}function n(){const e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){const e=[...r.names.map(i),...r.skips.map(i).map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){const e=r.instances[t];e.enabled=r.enabled(e.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=u,Object.keys(e).forEach(t=>{r[t]=e[t]}),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r},f=t(function(e,t){t.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))}),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=l(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});f.log,f.formatArgs,f.save,f.load,f.useColors,f.storage,f.colors;var p={isatty:function(){return!1},ReadStream:function(){throw new Error("tty.ReadStream is not implemented")},WriteStream:function(){throw new Error("tty.ReadStream is not implemented")}},d=function(e){return e instanceof Buffer},g=t(function(e){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}),C=t(function(e){try{var t=m;if("function"!=typeof t.inherits)throw"";e.exports=t.inherits}catch(t){e.exports=g}}),m=t(function(t,r){var n=/%[sdj%]/g;r.format=function(e){if(!g(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(s(arguments[r]));return t.join(" ")}r=1;for(var o=arguments,i=o.length,a=String(e).replace(n,function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(o[r++]);case"%d":return Number(o[r++]);case"%j":try{return JSON.stringify(o[r++])}catch(e){return"[Circular]"}default:return e}}),c=o[r];r<i;c=o[++r])m(c)||!v(c)?a+=" "+c:a+=" "+s(c);return a},r.deprecate=function(t,n){if(E(e.process))return function(){return r.deprecate(t,n).apply(this,arguments)};if(!0===process.noDeprecation)return t;var o=!1;return function(){if(!o){if(process.throwDeprecation)throw new Error(n);process.traceDeprecation?console.trace(n):console.error(n),o=!0}return t.apply(this,arguments)}};var o,i={};function s(e,t){var n={seen:[],stylize:c};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),h(t)?n.showHidden=t:t&&r._extend(n,t),E(n.showHidden)&&(n.showHidden=!1),E(n.depth)&&(n.depth=2),E(n.colors)&&(n.colors=!1),E(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=a),u(n,e,n.depth)}function a(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function c(e,t){return e}function u(e,t,n){if(e.customInspect&&t&&O(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var o=t.inspect(n,e);return g(o)||(o=u(e,o,n)),o}var i=function(e,t){if(E(t))return e.stylize("undefined","undefined");if(g(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return y(t)?e.stylize(""+t,"number"):h(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var s=Object.keys(t),a=function(e){var t={};return s.forEach(function(e,r){t[e]=!0}),t}();if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),_(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(t);if(0===s.length){if(O(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(w(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(b(t))return e.stylize(Date.prototype.toString.call(t),"date");if(_(t))return l(t)}var d,v="",S=!1,C=["{","}"];return p(t)&&(S=!0,C=["[","]"]),O(t)&&(v=" [Function"+(t.name?": "+t.name:"")+"]"),w(t)&&(v=" "+RegExp.prototype.toString.call(t)),b(t)&&(v=" "+Date.prototype.toUTCString.call(t)),_(t)&&(v=" "+l(t)),0!==s.length||S&&0!=t.length?n<0?w(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),d=S?function(e,t,r,n,o){for(var i=[],s=0,a=t.length;s<a;++s)R(t,String(s))?i.push(f(e,t,r,n,String(s),!0)):i.push("");return o.forEach(function(o){o.match(/^\d+$/)||i.push(f(e,t,r,n,o,!0))}),i}(e,t,n,a,s):s.map(function(r){return f(e,t,n,a,r,S)}),e.seen.pop(),function(e,t,r){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(d,v,C)):C[0]+v+C[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,o,i){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(n,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(r)?u(e,c.value,null):u(e,c.value,r-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),E(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e){return Array.isArray(e)}function h(e){return"boolean"==typeof e}function m(e){return null===e}function y(e){return"number"==typeof e}function g(e){return"string"==typeof e}function E(e){return void 0===e}function w(e){return v(e)&&"[object RegExp]"===S(e)}function v(e){return"object"==typeof e&&null!==e}function b(e){return v(e)&&"[object Date]"===S(e)}function _(e){return v(e)&&("[object Error]"===S(e)||e instanceof Error)}function O(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(E(o)&&(o=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!i[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var t=process.pid;i[e]=function(){var n=r.format.apply(r,arguments);console.error("%s %d: %s",e,t,n)}}else i[e]=function(){};return i[e]},r.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=p,r.isBoolean=h,r.isNull=m,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=g,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=E,r.isRegExp=w,r.isObject=v,r.isDate=b,r.isError=_,r.isFunction=O,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=d;var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(t=[A((e=new Date).getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),I[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=C,r._extend=function(e,t){if(!t||!v(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}),y=(m.format,m.deprecate,m.debuglog,m.inspect,m.isArray,m.isBoolean,m.isNull,m.isNullOrUndefined,m.isNumber,m.isString,m.isSymbol,m.isUndefined,m.isRegExp,m.isObject,m.isDate,m.isError,m.isFunction,m.isPrimitive,m.isBuffer,m.log,m.inherits,m._extend,y),h=(e,t)=>{t=t||process.argv;const r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return-1!==n&&(-1===o||n<o)};const b=process.env;let v;function F(e){return function(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}(function(e){if(!1===v)return 0;if(h("color=16m")||h("color=full")||h("color=truecolor"))return 3;if(h("color=256"))return 2;if(e&&!e.isTTY&&!0!==v)return 0;const t=v?1:0;if("win32"===process.platform){const e=y.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in b)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in b)||"codeship"===b.CI_NAME?1:t;if("TEAMCITY_VERSION"in b)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(b.TEAMCITY_VERSION)?1:0;if("truecolor"===b.COLORTERM)return 3;if("TERM_PROGRAM"in b){const e=parseInt((b.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(b.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(b.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(b.TERM)?1:"COLORTERM"in b?1:(b.TERM,t)}(e))}h("no-color")||h("no-colors")||h("color=false")?v=!1:(h("color")||h("colors")||h("color=true")||h("color=always"))&&(v=!0),"FORCE_COLOR"in b&&(v=0===b.FORCE_COLOR.length||0!==parseInt(b.FORCE_COLOR,10));var w={supportsColor:F,stdout:F(process.stdout),stderr:F(process.stderr)},O=t(function(e,t){t.init=function(e){e.inspectOpts={};const r=Object.keys(t.inspectOpts);for(let n=0;n<r.length;n++)e.inspectOpts[r[n]]=t.inspectOpts[r[n]]},t.log=function(...e){return process.stderr.write(m.format(...e)+"\n")},t.formatArgs=function(r){const{namespace:n,useColors:o}=this;if(o){const t=this.color,o="[3"+(t<8?t:"8;5;"+t),i=` ${o};1m${n} `;r[0]=i+r[0].split("\n").join("\n"+i),r.push(o+"m+"+e.exports.humanize(this.diff)+"")}else r[0]=(t.inspectOpts.hideDate?"":(new Date).toISOString()+" ")+n+" "+r[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):p.isatty(process.stderr.fd)},t.colors=[6,2,3,4,5,1];try{const r=w;r&&(r.stderr||r).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{const r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e},{}),e.exports=l(t);const{formatters:r}=e.exports;r.o=function(e){return this.inspectOpts.colors=this.useColors,m.inspect(e,this.inspectOpts).replace(/\s*\n\s*/g," ")},r.O=function(e){return this.inspectOpts.colors=this.useColors,m.inspect(e,this.inspectOpts)}}),x=(O.init,O.log,O.formatArgs,O.save,O.load,O.useColors,O.colors,O.inspectOpts,t(function(e){"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=f:e.exports=O})),debug=e=>x(`bearer:${e}`),debug$1=debug("core");const logger=debug$1.extend("Bearer"),warn=e=>{logger(`%c ${e}`,"background: #222; color: #bada55")},BEARER_WINDOW_INSTANCE_KEY="BEARER_INSTANCE",BEARER_EMITTER="BEARER_EMITTER",BEARER_WINDOW_KEY="BEARER",BEARER_CONFIG_KEY="BEARER_CONFIG",IFRAME_NAME="BEARER-IFRAME",LOG_LEVEL_KEY="LOG_LEVEL";class Bearer{constructor(e,t){this.window=t,this.isSessionInitialized=!1,this.authorized=(e=>{Bearer.emitter.emit(Events$1.AUTHORIZED,e)}),this.revoked=(e=>{Bearer.emitter.emit(Events$1.REVOKED,e)}),this.hasAuthorized=(e=>new Promise((t,r)=>{postRobot$1.send(this.iframe,Events$1.HAS_AUTHORIZED,{integrationId:e,clientId:Bearer.config.clientId}).then(({data:e,data:{authorized:n}})=>{logger("HAS_AUTHORIZED response %j",e),n?t(!0):r(!1)}).catch(iframeError)})),this.revokeAuthorization=((e,t)=>{postRobot$1.send(this.iframe,Events$1.REVOKE,{authId:t,integrationId:e,clientId:Bearer.config.clientId}).then(()=>{logger("Signing out")}).catch(iframeError)}),this.askAuthorizations=(({integrationId:e,setupId:t,authRefId:r=""})=>{if(this.isSessionInitialized){const n=formatQuery({setupId:t,authId:r,secured:Bearer.config.secured,clientId:this.bearerConfig.clientId}),o=`${Bearer.config.integrationHost}v2/auth/${e}?${n}`;return this.window.open(o,"","resizable,scrollbars,status,centerscreen=yes,width=500,height=600"),!0}return!1}),this.bearerConfig=new BearerConfig(e||{}),this.maybeInitialized=new Promise((e,t)=>{this.allowIntegrationRequests=e}),this.window[LOG_LEVEL_KEY]=this.bearerConfig.postRobotLogLevel,this.initSession()}static set _instance(e){window[BEARER_WINDOW_INSTANCE_KEY]&&warn("Replacing bearer instance"),window[BEARER_WINDOW_INSTANCE_KEY]=e}static get _instance(){return window[BEARER_WINDOW_INSTANCE_KEY]}static get emitter(){return window[BEARER_EMITTER]||(window[BEARER_EMITTER]=new fbemitter_2),window[BEARER_EMITTER]}static get instance(){return window[BEARER_WINDOW_INSTANCE_KEY]||this.init({})}static get config(){return this.instance.bearerConfig}static get version(){return"0.114.1"}get bearerConfig(){return window[BEARER_WINDOW_KEY]}set bearerConfig(e){window[BEARER_WINDOW_KEY]=e}get maybeInitialized(){return this.isSessionInitialized||warn("Waiting Bearer to be initialized"),this._maybeInitialized}set maybeInitialized(e){this._maybeInitialized=e}static init(e={}){return this._instance&&warn("One instance is already configured, reaplacing it"),this._instance=new Bearer(Object.assign({},e,window[BEARER_CONFIG_KEY]||{}),window),this._instance}initSession(){void 0===this.window||document.querySelector(`#${IFRAME_NAME}`)||(postRobot$1.on(Events$1.SESSION_INITIALIZED,e=>{this.sessionInitialized(e)}),postRobot$1.on(Events$1.AUTHORIZED,this.authorized),postRobot$1.on(Events$1.REVOKED,this.revoked),this.iframe=document.createElement("iframe"),this.iframe.src=`${this.bearerConfig.authorizationHost}v1/user/initialize`,this.iframe.id=IFRAME_NAME,this.iframe.width="0",this.iframe.height="0",this.iframe.frameBorder="0",this.iframe.style.display="none",document.body.appendChild(this.iframe))}sessionInitialized(e){logger("session initialized"),this.isSessionInitialized=!0,this.allowIntegrationRequests(!0)}}function iframeError(e){logger("Error contacting iframe")}Bearer.onAuthorized=((e,t)=>(logger("onAuthorized register %s",e),Bearer.emitter.addListener(Events$1.AUTHORIZED,r=>{r.data.integrationId===e?(logger("onAuthorized authorized %s",e),t(!0)):logger("onAuthorized different integrationId %s",e)}))),Bearer.onRevoked=((e,t)=>(logger("onRevoked register %s",e),Bearer.emitter.addListener(Events$1.REVOKED,r=>{r.data.integrationId===e?(logger("onRevoked revoked %s",e),t(!1)):logger("onRevoked different integrationId %s",e)})));var reInterpolate=/<%=([\s\S]+?)%>/g,lodash__reinterpolate=reInterpolate,INFINITY=1/0,symbolTag="[object Symbol]",reUnescapedHtml=/[&<>"'`]/g,reHasUnescapedHtml=RegExp(reUnescapedHtml.source),reEscape=/<%-([\s\S]+?)%>/g,reEvaluate=/<%([\s\S]+?)%>/g,htmlEscapes={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},freeGlobal="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")();function basePropertyOf(e){return function(t){return null==e?void 0:e[t]}}var escapeHtmlChar=basePropertyOf(htmlEscapes),objectProto=Object.prototype,objectToString=objectProto.toString,Symbol$1=root.Symbol,symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0,templateSettings={escape:reEscape,evaluate:reEvaluate,interpolate:lodash__reinterpolate,variable:"",imports:{_:{escape:escape}}};function baseToString(e){if("string"==typeof e)return e;if(isSymbol(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY?"-0":t}function isObjectLike(e){return!!e&&"object"==typeof e}function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&objectToString.call(e)==symbolTag}function toString(e){return null==e?"":baseToString(e)}function escape(e){return(e=toString(e))&&reHasUnescapedHtml.test(e)?e.replace(reUnescapedHtml,escapeHtmlChar):e}var lodash_templatesettings=templateSettings,INFINITY$1=1/0,MAX_SAFE_INTEGER=9007199254740991,argsTag="[object Arguments]",errorTag="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",symbolTag$1="[object Symbol]",reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g,reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,reIsUint=/^(?:0|[1-9]\d*)$/,reNoMatch=/($^)/,reUnescapedString=/['\n\r\u2028\u2029\\]/g,stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},freeGlobal$1="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,freeSelf$1="object"==typeof self&&self&&self.Object===Object&&self,root$1=freeGlobal$1||freeSelf$1||Function("return this")();function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function arrayMap(e,t){for(var r=-1,n=e?e.length:0,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function baseValues(e,t){return arrayMap(t,function(t){return e[t]})}function escapeStringChar(e){return"\\"+stringEscapes[e]}function overArg(e,t){return function(r){return e(t(r))}}var objectProto$1=Object.prototype,hasOwnProperty=objectProto$1.hasOwnProperty,objectToString$1=objectProto$1.toString,Symbol$2=root$1.Symbol,propertyIsEnumerable=objectProto$1.propertyIsEnumerable,nativeKeys=overArg(Object.keys,Object),nativeMax=Math.max,symbolProto$1=Symbol$2?Symbol$2.prototype:void 0,symbolToString$1=symbolProto$1?symbolProto$1.toString:void 0;function arrayLikeKeys(e,t){var r=isArray(e)||isArguments(e)?baseTimes(e.length,String):[],n=r.length,o=!!n;for(var i in e)!t&&!hasOwnProperty.call(e,i)||o&&("length"==i||isIndex(i,n))||r.push(i);return r}function assignInDefaults(e,t,r,n){return void 0===e||eq(e,objectProto$1[r])&&!hasOwnProperty.call(n,r)?t:e}function assignValue(e,t,r){var n=e[t];hasOwnProperty.call(e,t)&&eq(n,r)&&(void 0!==r||t in e)||(e[t]=r)}function baseKeys(e){if(!isPrototype(e))return nativeKeys(e);var t=[];for(var r in Object(e))hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}function baseKeysIn(e){if(!isObject(e))return nativeKeysIn(e);var t=isPrototype(e),r=[];for(var n in e)("constructor"!=n||!t&&hasOwnProperty.call(e,n))&&r.push(n);return r}function baseRest(e,t){return t=nativeMax(void 0===t?e.length-1:t,0),function(){for(var r=arguments,n=-1,o=nativeMax(r.length-t,0),i=Array(o);++n<o;)i[n]=r[t+n];n=-1;for(var s=Array(t+1);++n<t;)s[n]=r[n];return s[t]=i,apply(e,this,s)}}function baseToString$1(e){if("string"==typeof e)return e;if(isSymbol$1(e))return symbolToString$1?symbolToString$1.call(e):"";var t=e+"";return"0"==t&&1/e==-INFINITY$1?"-0":t}function copyObject(e,t,r,n){r||(r={});for(var o=-1,i=t.length;++o<i;){var s=t[o],a=n?n(r[s],e[s],s,r,e):void 0;assignValue(r,s,void 0===a?e[s]:a)}return r}function createAssigner(e){return baseRest(function(t,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(i=e.length>3&&"function"==typeof i?(o--,i):void 0,s&&isIterateeCall(r[0],r[1],s)&&(i=o<3?void 0:i,o=1),t=Object(t);++n<o;){var a=r[n];a&&e(t,a,n,i)}return t})}function isIndex(e,t){return!!(t=null==t?MAX_SAFE_INTEGER:t)&&("number"==typeof e||reIsUint.test(e))&&e>-1&&e%1==0&&e<t}function isIterateeCall(e,t,r){if(!isObject(r))return!1;var n=typeof t;return!!("number"==n?isArrayLike(r)&&isIndex(t,r.length):"string"==n&&t in r)&&eq(r[t],e)}function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$1)}function nativeKeysIn(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}function eq(e,t){return e===t||e!=e&&t!=t}function isArguments(e){return isArrayLikeObject(e)&&hasOwnProperty.call(e,"callee")&&(!propertyIsEnumerable.call(e,"callee")||objectToString$1.call(e)==argsTag)}var isArray=Array.isArray;function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike$1(e)&&isArrayLike(e)}function isError(e){return!!isObjectLike$1(e)&&(objectToString$1.call(e)==errorTag||"string"==typeof e.message&&"string"==typeof e.name)}function isFunction(e){var t=isObject(e)?objectToString$1.call(e):"";return t==funcTag||t==genTag}function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isObject(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function isObjectLike$1(e){return!!e&&"object"==typeof e}function isSymbol$1(e){return"symbol"==typeof e||isObjectLike$1(e)&&objectToString$1.call(e)==symbolTag$1}function toString$1(e){return null==e?"":baseToString$1(e)}var assignInWith=createAssigner(function(e,t,r,n){copyObject(t,keysIn(t),e,n)});function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}function template(e,t,r){var n=lodash_templatesettings.imports._.templateSettings||lodash_templatesettings;r&&isIterateeCall(e,t,r)&&(t=void 0),e=toString$1(e),t=assignInWith({},t,n,assignInDefaults);var o,i,s=assignInWith({},t.imports,n.imports,assignInDefaults),a=keys(s),c=baseValues(s,a),u=0,l=t.interpolate||reNoMatch,f="__p += '",d=RegExp((t.escape||reNoMatch).source+"|"+l.source+"|"+(l===lodash__reinterpolate?reEsTemplate:reNoMatch).source+"|"+(t.evaluate||reNoMatch).source+"|$","g"),p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";e.replace(d,function(t,r,n,s,a,c){return n||(n=s),f+=e.slice(u,c).replace(reUnescapedString,escapeStringChar),r&&(o=!0,f+="' +\n__e("+r+") +\n'"),a&&(i=!0,f+="';\n"+a+";\n__p += '"),n&&(f+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t}),f+="';\n";var h=t.variable;h||(f="with (obj) {\n"+f+"\n}\n"),f=(i?f.replace(reEmptyStringLeading,""):f).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;"),f="function("+(h||"obj")+") {\n"+(h?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(i?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var m=attempt(function(){return Function(a,p+"return "+f).apply(void 0,c)});if(m.source=f,isError(m))throw m;return m}var attempt=baseRest(function(e,t){try{return apply(e,void 0,t)}catch(e){return isError(e)?e:new Error(e)}}),lodash_template=template;const interpolate=/{{([\s\S]+?)}}/g,scopedTranslate=e=>t=>(r,n,o)=>lodash_template(t.get(e,r)||n,{interpolate:interpolate})(o||{}),scopedPluralize=e=>t=>(r,n,o,i)=>{const s=[r,n].join(".");if(t.get(e,s))return scopedTranslate(e)(t)(s,o,i);const a=[r,n>1?"many":n].join(".");return scopedTranslate(e)(t)(a,o,i)};(exports.FunctionType||(exports.FunctionType={})).FetchData="FetchData";const BearerContext="bearerContext",setupId="setupId",FunctionSaved="BearerStateSaved",BearerStateSavedEvent="bearer:StateSaved";function _BackendFunction(e,t=exports.FunctionType.FetchData){return function(t,r){defineFunctionProp(t,r,()=>(function(r={}){const n=t.INTEGRATION_ID;return n?bearer.instance.invoke(n,e,Object.assign({},r,{query:{setupId:retrieveSetupId(this),referenceId:retrieveReferenceId(this)}})).catch(e=>{throw e}):missingIntegrationId()}))}}function missingIntegrationId(){return console.info("[BEARER]","Missing integrationId, skipping api call"),Promise.reject(new BearerMissingIntegrationId)}function retrieveSetupId(e){return e.setupId||e[BearerContext]&&e[BearerContext][setupId]}function retrieveReferenceId(e){return e.referenceId}function defineFunctionProp(e,t,r){const n=()=>{};delete e[t]&&Object.defineProperty(e,t,{get:r,set:n})}class BearerMissingIntegrationId extends Error{constructor(){super(...arguments),this.message="Integration ID is missing. Please add @RootComponent decorator above your class definition"}}const BearerState=e=>(e,t)=>{},Events$2=Events$1,scopedT=e=>scopedTranslate(e)(window.bearer.i18n),scopedP=e=>scopedPluralize(e)(window.bearer.i18n);exports.Events=Events$2,exports.scopedT=scopedT,exports.scopedP=scopedP,exports.default=Bearer,exports.BearerState=BearerState,exports.BearerContext=BearerContext,exports.setupId=setupId,exports.FunctionSaved=FunctionSaved,exports.BearerStateSavedEvent="bearer:StateSaved",exports._BackendFunction=_BackendFunction;