UNPKG

66.4 kBJavaScriptView Raw
1var e=function(e){function t(n,r,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e.call(this,n),this.listener=r,this.context=o}return function(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)}(t,e),t}(function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subscriber=t}return e.prototype.remove=function(){this.subscriber&&(this.subscriber.removeSubscription(this),this.subscriber=null)},e}()),t=function(e){};"production"!==process.env.NODE_ENV&&(t=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")});var n=function(e,n,r,o,i,s,c,a){if(t(n),!e){var u;if(void 0===n)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,o,i,s,c,a],l=0;(u=new Error(n.replace(/%s/g,function(){return f[l++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}};var r=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._subscriptionsForType={},this._currentSubscription=null}return e.prototype.addSubscription=function(e,t){t.subscriber!==this&&("production"!==process.env.NODE_ENV?n(!1,"The subscriber of the subscription is incorrectly set."):n(!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,n=e.key,r=this._subscriptionsForType[t];r&&delete r[n]},e.prototype.getSubscriptionsForType=function(e){return this._subscriptionsForType[e]},e}();function o(e){return function(){return e}}var i=function(){};i.thatReturns=o,i.thatReturnsFalse=o(!1),i.thatReturnsTrue=o(!0),i.thatReturnsNull=o(null),i.thatReturnsThis=function(){return this},i.thatReturnsArgument=function(e){return e};var s=i;var c={EventEmitter:function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._subscriber=new r,this._currentSubscription=null}return t.prototype.addListener=function(t,n,r){return this._subscriber.addSubscription(t,new e(this._subscriber,n,r))},t.prototype.once=function(e,t,n){var r=this;return this.addListener(e,function(){r.removeCurrentListener(),t.apply(n,arguments)})},t.prototype.removeAllListeners=function(e){this._subscriber.removeAllSubscriptions(e)},t.prototype.removeCurrentListener=function(){this._currentSubscription||("production"!==process.env.NODE_ENV?n(!1,"Not in an emitting cycle; there is no current subscription"):n(!1)),this._subscriber.removeSubscription(this._currentSubscription)},t.prototype.listeners=function(e){var t=this._subscriber.getSubscriptionsForType(e);return t?t.filter(s.thatReturnsTrue).map(function(e){return e.listener}):[]},t.prototype.emit=function(e){var t=this._subscriber.getSubscriptionsForType(e);if(t){for(var n=Object.keys(t),r=0;r<n.length;r++){var o=t[n[r]];o&&(this._currentSubscription=o,this.__emitToSubscription.apply(this,[o].concat(Array.prototype.slice.call(arguments))))}this._currentSubscription=null}},t.prototype.__emitToSubscription=function(e,t){var n=Array.prototype.slice.call(arguments,2);e.listener.apply(e.context,n)},t}(),EmitterSubscription:e}.EventEmitter,a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(e,t){return e(t={exports:{}},t.exports),t.exports}var f=u(function(e,t){"undefined"!=typeof self&&self,e.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/index.js")}({"./node_modules/cross-domain-utils/src/constants.js":function(e,t,n){n.d(t,"a",function(){return r}),n.d(t,"b",function(){return o});var r={MOCK:"mock:",FILE:"file:",ABOUT:"about:"},o="*"},"./node_modules/cross-domain-utils/src/index.js":function(e,t,n){var r=n("./node_modules/cross-domain-utils/src/utils.js");n.d(t,"getActualDomain",function(){return r.a}),n.d(t,"getAncestor",function(){return r.b}),n.d(t,"getDomain",function(){return r.c}),n.d(t,"getUserAgent",function(){return r.d}),n.d(t,"isActuallySameDomain",function(){return r.e}),n.d(t,"isAncestor",function(){return r.f}),n.d(t,"isIframe",function(){return r.g}),n.d(t,"isPopup",function(){return r.h}),n.d(t,"isWindow",function(){return r.i}),n.d(t,"isWindowClosed",function(){return r.j}),n.d(t,"matchDomain",function(){return r.k}),n.d(t,"stringifyDomainPattern",function(){return r.l});var o=n("./node_modules/cross-domain-utils/src/types.js");n.n(o),n("./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,n){function r(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var o=n("./node_modules/cross-domain-utils/src/constants.js");t.a=f,t.c=l,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(l(window)===l(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 n=function(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}(w,e);if(-1!==n){var r=m[n];if(r&&function(e){if(!e.contentWindow)return!0;if(!e.parentNode)return!0;var t=e.ownerDocument;return!(!t||!t.documentElement||t.documentElement.contains(e))}(r))return!0}return!1},t.d=function(e){return(e=e||window).navigator.mockUserAgent||e.navigator.userAgent},t.b=y,t.f=function(e,t){var n=y(t);if(n)return n===e;if(t===e)return!1;if(function(e){if(e){try{if(e.top)return e.top}catch(e){}if(c(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,n=function e(t){for(var n=[],r=0,o=h(t),i=null==o?0:o.length;r<i;r++){var s=o[r];n.push(s);for(var c=0,a=e(s),u=null==a?0:a.length;c<u;c++){var f=a[c];n.push(f)}}return n}(e),r=null==n?0:n.length;t<r;t++){var o=n[t];try{if(o.top)return o.top}catch(e){}if(c(o)===o)return o}}}(t)===t)return!1;for(var r=0,o=h(e),i=null==o?0:o.length;r<i;r++)if(o[r]===t)return!0;return!1},t.h=function(){return Boolean(a(window))},t.g=function(){return Boolean(c(window))},t.k=function e(t,n){if("string"==typeof t){if("string"==typeof n)return t===o.b||n===t;if(r(n))return!1;if(Array.isArray(n))return!1}return r(t)?r(n)?t.toString()===n.toString():!Array.isArray(n)&&Boolean(n.match(t)):!!Array.isArray(t)&&(Array.isArray(n)?JSON.stringify(t)===JSON.stringify(n):!r(n)&&t.some(function(t){return e(t,n)}))},t.l=function(e){return Array.isArray(e)?"("+e.join(" | ")+")":r(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 c(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(e){}}function a(e){if(e&&!c(e))try{return e.opener}catch(e){}}function u(e){try{return e&&e.location&&e.location.href,!0}catch(e){}return!1}function f(e){var t=(e=e||window).location;if(!t)throw new Error("Can not read window location");var n=t.protocol;if(!n)throw new Error("Can not read window protocol");if(n===o.a.FILE)return o.a.FILE+"//";if(n===o.a.ABOUT){var r=c(e);return r&&u(r)?f(r):o.a.ABOUT+"//"}var i=t.host;if(!i)throw new Error("Can not read window host");return n+"//"+i}function l(e){var t=f(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(f(e)===f(window))return!0}catch(e){}return!1}function p(e,t){if(!e||!t)return!1;var n=c(t);return n?n===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=[],n=void 0;try{n=e.frames}catch(t){n=e}var r=void 0;try{r=n.length}catch(e){}if(0===r)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=n[o]}catch(e){continue}t.push(i)}return t}for(var s=0;s<100;s++){var c=void 0;try{c=n[s]}catch(e){return t}if(!c)return t;t.push(c)}return t}var w=[],m=[];function y(e){return a(e=e||window)||c(e)||void 0}},"./src/index.js":function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),n.d({},"WeakMap",function(){return u});var r={};n.d(r,"cleanUpWindow",function(){return ne}),n.d(r,"Promise",function(){return O}),n.d(r,"bridge",function(){return re}),n.d(r,"init",function(){return oe}),n.d(r,"parent",function(){return te}),n.d(r,"send",function(){return q}),n.d(r,"request",function(){return Z}),n.d(r,"sendToParent",function(){return Y}),n.d(r,"client",function(){return $}),n.d(r,"on",function(){return V}),n.d(r,"listen",function(){return K}),n.d(r,"once",function(){return Q}),n.d(r,"listener",function(){return X}),n.d(r,"CONFIG",function(){return d}),n.d(r,"CONSTANTS",function(){return f}),n.d(r,"disable",function(){return ee});var o=n("./node_modules/cross-domain-utils/src/index.js");function i(e,t){for(var n=0;n<e.length;n++)try{if(e[n]===t)return n}catch(e){}return-1}var s,c=Object.defineProperty,a=Date.now()%1e9,u=function(){function e(){if(function(t,n){if(!(t 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,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,n=0;n<t.length;n++){var r=t[n];if(Object(o.isWindow)(r)&&Object(o.isWindowClosed)(r)){if(e)try{e.delete(r)}catch(e){}t.splice(n,1),this.values.splice(n,1),n-=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 n=this.weakmap;if(n)try{n.set(e,t)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var r=this.name,o=e[r];o&&o[0]===e?o[1]=t:c(e,r,{value:[e,t],writable:!0})}else{this._cleanupClosedWindows();var s=this.keys,a=this.values,u=i(s,e);-1===u?(s.push(e),a.push(t)):a[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 n=i(this.keys,e);if(-1===n)return;return this.values[n]}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 t=this.weakmap;if(t)try{t.delete(e)}catch(e){delete this.weakmap}if(this.isSafeToReadWrite(e)){var n=e[this.name];n&&n[0]===e&&(n[0]=n[1]=void 0)}else{this._cleanupClosedWindows();var r=this.keys,o=i(r,e);-1!==o&&(r.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 n=e[this.name];return!(!n||n[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 n=t();return this.set(e,n),n},e}(),f={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:"*"},l={METHOD:"postrobot_method",HELLO:"postrobot_hello",OPEN_TUNNEL:"postrobot_open_tunnel"},d=(Object.keys(l).map(function(e){return l[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[f.SEND_STRATEGIES.POST_MESSAGE]=!0,s[f.SEND_STRATEGIES.BRIDGE]=!0,s[f.SEND_STRATEGIES.GLOBAL]=!0,s),ALLOW_SAME_ORIGIN:!1});0===window.location.href.indexOf(f.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 n=e&&e.stack,r=e&&e.message;if(n&&r)return-1!==n.indexOf(r)?n:r+"\n"+n;if(n)return n;if(r)return r}return"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)}catch(e){return"Error while stringifying error: "+h(e,t+1)}}var w=function(e){if(!e)return e;var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}};function m(){}function y(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})}function g(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(n>=100)throw new Error("Self-referential object passed, or object contained too many layers");var r=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)));r=[]}else r={};return function(e,t){Array.isArray(e)?function(e,t){for(var n=0;n<e.length;n++)t(e[n],n)}(e,t):"object"===(void 0===e?"undefined":p(e))&&null!==e&&function(e,t){for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)}(e,t)}(e,function(e,o){var i=t(e,o);void 0!==i?r[o]=i:"object"===(void 0===e?"undefined":p(e))&&null!==e?r[o]=g(e,t,n+1):r[o]=e}),r}function v(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function E(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 n=t.call(e);if("[object Window]"===n||"[object global]"===n||"[object DOMWindow]"===n)return!1}if("function"==typeof e.then)return!0}catch(e){return!1}return!1}function _(){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 O=function(){function e(t){var n=this;if(function(t,n){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 r=void 0,o=void 0,i=!1,s=!1,c=!1;try{t(function(e){c?n.resolve(e):(i=!0,r=e)},function(e){c?n.reject(e):(s=!0,o=e)})}catch(e){return void this.reject(e)}c=!0,i?this.resolve(r):s&&this.reject(o)}}return e.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(E(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(E(e))throw new Error("Can not reject promise with another promise");if(!e){var n=e&&"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e);e=new Error("Expected reject to be called with Error, got "+n)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){t.errorHandled||function(e,t){if(-1===_().dispatchedErrors.indexOf(e)){_().dispatchedErrors.push(e),setTimeout(function(){throw e},1);for(var n=0;n<_().possiblyUnhandledPromiseHandlers.length;n++)_().possiblyUnhandledPromiseHandlers[n](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,n=this.dispatching,r=this.resolved,o=this.rejected,i=this.handlers;if(!n&&(r||o)){this.dispatching=!0,_().activeCount+=1;for(var s=function(n){var s=i[n],c=s.onSuccess,a=s.onError,u=s.promise,f=void 0;if(r)try{f=c?c(t.value):t.value}catch(e){return u.reject(e),"continue"}else if(o){if(!a)return u.reject(t.error),"continue";try{f=a(t.error)}catch(e){return u.reject(e),"continue"}}f instanceof e&&(f.resolved||f.rejected)?(f.resolved?u.resolve(f.value):u.reject(f.error),f.errorHandled=!0):E(f)?f instanceof e&&(f.resolved||f.rejected)?f.resolved?u.resolve(f.value):u.reject(f.error):f.then(function(e){u.resolve(e)},function(e){u.reject(e)}):u.resolve(f)},c=0;c<i.length;c++)s(c);i.length=0,this.dispatching=!1,_().activeCount-=1,0===_().activeCount&&e.flushQueue()}},e.prototype.then=function(t,n){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.then expected a function for success handler");if(n&&"function"!=typeof n&&!n.call)throw new Error("Promise.then expected a function for error handler");var r=new e;return this.handlers.push({promise:r,onSuccess:t,onError:n}),this.errorHandled=!0,this.dispatch(),r},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(n){return e.try(t).then(function(){return n})},function(n){return e.try(t).then(function(){throw n})})},e.prototype.timeout=function(e,t){var n=this;if(this.resolved||this.rejected)return this;var r=setTimeout(function(){n.resolved||n.rejected||n.reject(t||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(t){return t instanceof e?t:E(t)?new e(function(e,n){return t.then(e,n)}):(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 n=new e,r=t.length,o=[];if(!r)return n.resolve(o),n;for(var i=function(i){var s=t[i];if(s instanceof e){if(s.resolved)return o[i]=s.value,r-=1,"continue"}else if(!E(s))return o[i]=s,r-=1,"continue";e.resolve(s).then(function(e){o[i]=e,0==(r-=1)&&n.resolve(o)},function(e){n.reject(e)})},s=0;s<t.length;s++)i(s);return 0===r&&n.resolve(o),n},e.hash=function(t){var n={};return e.all(Object.keys(t).map(function(r){return e.resolve(t[r]).then(function(e){n[r]=e})})).then(function(){return n})},e.map=function(t,n){return e.all(t.map(n))},e.onPossiblyUnhandledException=function(e){return function(e){return _().possiblyUnhandledPromiseHandlers.push(e),{cancel:function(){_().possiblyUnhandledPromiseHandlers.splice(_().possiblyUnhandledPromiseHandlers.indexOf(e),1)}}}(e)},e.try=function(t,n,r){if(t&&"function"!=typeof t&&!t.call)throw new Error("Promise.try expected a function");var o=void 0;try{o=t.apply(n,r||[])}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)||E(t)},e.flush=function(){var t=new e;return _().flushPromises.push(t),0===_().activeCount&&e.flushQueue(),t},e.flushQueue=function(){var e=_().flushPromises;_().flushPromises=[];for(var t=0,n=null==e?0:e.length;t<n;t++)e[t].resolve()},e}(),b=window[f.WINDOW_PROPS.POSTROBOT]=window[f.WINDOW_PROPS.POSTROBOT]||{};b.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};b.methods=b.methods||new u;var C=w(function(){b.on(f.POST_MESSAGE_NAMES.METHOD,{origin:f.WILDCARD},function(e){var t=e.source,n=e.origin,r=e.data,i=b.methods.get(t);if(!i)throw new Error("Could not find any methods this window has privileges to call");var s=i[r.id];if(!s)throw new Error("Could not find method with id: "+r.id);if(!Object(o.matchDomain)(s.domain,n))throw new Error("Method domain "+s.domain+" does not match origin "+n);return O.try(function(){return s.method.apply({source:t,origin:n,data:r},r.args)}).then(function(e){return{result:e,id:r.id,name:r.name}})})});function A(e,t){return"object"===(void 0===e?"undefined":S(e))&&null!==e&&e.__type__===t}function R(e,t,n,r){var o=y(),i=b.methods.get(e);return i||(i={},b.methods.set(e,i)),i[o]={domain:t,method:n},{__type__:f.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:r}}function T(e,t,n){function r(){var r=Array.prototype.slice.call(arguments);return b.send(e,f.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:r},{domain:t,timeout:-1}).then(function(e){return e.data.result},function(e){throw e})}return r.__name__=n.__name__,r.__xdomain__=!0,r.source=e,r.origin=t,r}function I(e,t,n){return new O(function(r,o){return T(e,t,n.__then__)(r,o)})}function j(e){return b.send(e,f.POST_MESSAGE_NAMES.HELLO,{},{domain:f.WILDCARD,timeout:-1}).then(function(e){return{origin:e.origin}})}b.readyPromises=b.readyPromises||new u;var P={};P[f.SEND_STRATEGIES.POST_MESSAGE]=function(e,t,n){(Array.isArray(n)?n:"string"==typeof n?[n]:[f.WILDCARD]).map(function(t){if(0===t.indexOf(f.MOCK_PROTOCOL)){if(window.location.protocol===f.FILE_PROTOCOL)return f.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(f.FILE_PROTOCOL)?f.WILDCARD:t}).forEach(function(n){return e.postMessage(t,n)})};var D=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};function L(e,t,n){return O.try(function(){var r;if(t=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=y(),i=Object(o.isPopup)()?f.WINDOW_TYPES.POPUP:Object(o.isIframe)()?f.WINDOW_TYPES.IFRAME:f.WINDOW_TYPES.FULLPAGE,s=Object(o.getDomain)(window);return D({},t,n,{sourceDomain:s,id:t.id||r,windowType:i})}(e,t,{data:function(e,n,r){return g({obj:t.data},function(t,r){return"function"==typeof t?R(e,n,t,r.toString()):t instanceof Error?(o=t,{__type__:f.SERIALIZATION_TYPES.ERROR,__message__:h(o),__code__:o.code}):window.Promise&&t instanceof window.Promise?function(e,t,n,r){return{__type__:f.SERIALIZATION_TYPES.PROMISE,__then__:R(e,t,function(e,t){return n.then(e,t)},r+".then")}}(e,n,t,r.toString()):O.isPromise(t)?function(e,t,n,r){return{__type__:f.SERIALIZATION_TYPES.ZALGO_PROMISE,__then__:R(e,t,function(e,t){return n.then(e,t)},r+".then")}}(e,n,t,r.toString()):v(t)?(i=t,{__type__:f.SERIALIZATION_TYPES.REGEX,__source__:i.source}):void 0;var o,i}).obj}(e,n),domain:n}),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,n){var r=void 0,o=void 0;try{if("{}"!==JSON.stringify({})&&(r=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{r&&(Object.prototype.toJSON=r),o&&(Array.prototype.toJSON=o)}catch(e){throw new Error("Can not repair JSON.stringify: "+e.message)}return i}(((r={})[f.WINDOW_PROPS.POSTROBOT]=t,r));return O.map(Object.keys(P),function(t){return O.try(function(){if(!d.ALLOWED_POST_MESSAGE_METHODS[t])throw new Error("Strategy disallowed: "+t);return P[t](e,s,n)}).then(function(){return i.push(t+": success"),!0},function(e){return i.push(t+": "+h(e)+"\n"),!1})}).then(function(e){var n=e.some(Boolean),r=t.type+" "+t.name+" "+(n?"success":"error")+":\n - "+i.join("\n - ")+"\n";if(!n)throw new Error(r)})})}b.responseListeners=b.responseListeners||{},b.requestListeners=b.requestListeners||{},b.WINDOW_WILDCARD=b.WINDOW_WILDCARD||new function(){},b.erroredResponseListeners=b.erroredResponseListeners||{};var N,x="__domain_regex__";function M(e){return b.responseListeners[e]}function F(e){delete b.responseListeners[e]}function W(e){return Boolean(b.erroredResponseListeners[e])}function k(e){var t=e.name,n=e.win,r=e.domain;if(n===f.WILDCARD&&(n=null),r===f.WILDCARD&&(r=null),!t)throw new Error("Name required to get request listener");var i=b.requestListeners[t];if(i)for(var s=0,c=[n,b.WINDOW_WILDCARD],a=null==c?0:c.length;s<a;s++){var u=c[s],l=u&&i.get(u);if(l){if(r&&"string"==typeof r){if(l[r])return l[r];if(l[x])for(var d=0,p=l[x],h=null==p?0:p.length;d<h;d++){var w=p[d],m=w.regex,y=w.listener;if(Object(o.matchDomain)(m,r))return y}}if(l[f.WILDCARD])return l[f.WILDCARD]}}}var U=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},G=((N={})[f.POST_MESSAGE_TYPE.ACK]=function(e,t,n){if(!W(n.hash)){var r=M(n.hash);if(!r)throw new Error("No handler found for post message ack for message: "+n.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(o.matchDomain)(r.domain,t))throw new Error("Ack origin "+t+" does not match domain "+r.domain.toString());r.ack=!0}},N[f.POST_MESSAGE_TYPE.REQUEST]=function(e,t,n){var r=k({name:n.name,win:e,domain:t});function i(r){return n.fireAndForget||Object(o.isWindowClosed)(e)?O.resolve():L(e,U({target:n.originalSource,hash:n.hash,name:n.name},r),t)}return O.all([i({type:f.POST_MESSAGE_TYPE.ACK}),O.try(function(){if(!r)throw new Error("No handler found for post message: "+n.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(o.matchDomain)(r.domain,t))throw new Error("Request origin "+t+" does not match domain "+r.domain.toString());var i=n.data;return r.handler({source:e,origin:t,data:i})}).then(function(e){return i({type:f.POST_MESSAGE_TYPE.RESPONSE,ack:f.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){var t=h(e).replace(/^Error: /,""),n=e.code;return i({type:f.POST_MESSAGE_TYPE.RESPONSE,ack:f.POST_MESSAGE_ACK.ERROR,error:t,code:n})})]).then(m).catch(function(e){if(r&&r.handleError)return r.handleError(e);throw e})},N[f.POST_MESSAGE_TYPE.RESPONSE]=function(e,t,n){if(!W(n.hash)){var r=M(n.hash);if(!r)throw new Error("No handler found for post message response for message: "+n.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!Object(o.matchDomain)(r.domain,t))throw new Error("Response origin "+t+" does not match domain "+Object(o.stringifyDomainPattern)(r.domain));if(F(n.hash),n.ack===f.POST_MESSAGE_ACK.ERROR){var i=new Error(n.error);return n.code&&(i.code=n.code),r.respond(i,null)}if(n.ack===f.POST_MESSAGE_ACK.SUCCESS){var s=n.data||n.response;return r.respond(null,{source:e,origin:t,data:s})}}},N),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 H(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,n=e.origin,r=function(e){var t,n=void 0;try{t=e,n=JSON.parse(t)}catch(e){return}if(n&&"object"===(void 0===n?"undefined":z(n))&&null!==n&&(n=n[f.WINDOW_PROPS.POSTROBOT])&&"object"===(void 0===n?"undefined":z(n))&&null!==n&&n.type&&"string"==typeof n.type&&G[n.type])return n}(e.data);if(r){if(!r.sourceDomain||"string"!=typeof r.sourceDomain)throw new Error("Expected message to have sourceDomain");0!==r.sourceDomain.indexOf(f.MOCK_PROTOCOL)&&0!==r.sourceDomain.indexOf(f.FILE_PROTOCOL)||(n=r.sourceDomain),-1===b.receivedMessages.indexOf(r.id)&&(b.receivedMessages.push(r.id),Object(o.isWindowClosed)(t)&&!r.fireAndForget||(r.data&&(r.data=function(e,t,n){return g({obj:r.data},function(n){if("object"===(void 0===n?"undefined":S(n))&&null!==n)return A(n,f.SERIALIZATION_TYPES.METHOD)?T(e,t,n):A(n,f.SERIALIZATION_TYPES.ERROR)?(r=n,o=new Error(r.__message__),r.__code__&&(o.code=r.__code__),o):A(n,f.SERIALIZATION_TYPES.PROMISE)?function(e,t,n){return window.Promise?new window.Promise(function(r,o){return T(e,t,n.__then__)(r,o)}):I(e,t,n)}(e,t,n):A(n,f.SERIALIZATION_TYPES.ZALGO_PROMISE)?I(e,t,n):A(n,f.SERIALIZATION_TYPES.REGEX)?function(e,t,n){return new RegExp(n.__source__)}(0,0,n):void 0;var r,o}).obj}(t,n)),G[r.type](t,n,r)))}}function B(e){try{e.source}catch(e){return}H({source:e.source||e.sourceElement,origin:e.origin||e.originalEvent&&e.originalEvent.origin,data:e.data})}function Z(e){return O.try(function(){if(!e.name)throw new Error("Expected options.name");var t=e.name,n=void 0,r=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.");n=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&&(n=e.window.contentWindow)}else n=e.window;if(!n)throw new Error("Expected options.window to be a window object, iframe, or iframe element id.");var s=n;r=e.domain||f.WILDCARD;var c=e.name+"_"+y();if(Object(o.isWindowClosed)(s))throw new Error("Target window is closed");var a=!1,u=b.requestPromises.get(s);u||(u=[],b.requestPromises.set(s,u));var l=O.try(function(){if(Object(o.isAncestor)(window,s))return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Window",r=b.readyPromises.get(e);return r||(r=new O,b.readyPromises.set(e,r),-1!==t&&setTimeout(function(){return r.reject(new Error(n+" did not load after "+t+"ms"))},t),r)}(s,e.timeout||d.CHILD_WINDOW_TIMEOUT)}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(v(r)&&!e)return j(s)}).then(function(){var n=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).origin;if(v(r)){if(!Object(o.matchDomain)(r,n))throw new Error("Remote window domain "+n+" does not match regex: "+r.toString());r=n}if("string"!=typeof r&&!Array.isArray(r))throw new TypeError("Expected domain to be a string or array");var i=r;return new O(function(n,r){var p=void 0;if(e.fireAndForget||function(e,t){b.responseListeners[e]=t}(c,p={name:t,window:s,domain:i,respond:function(e,t){e||(a=!0,u.splice(u.indexOf(l,1))),e?r(e):n(t)}}),L(s,{type:f.POST_MESSAGE_TYPE.REQUEST,hash:c,name:t,data:e.data,fireAndForget:e.fireAndForget},i).catch(r),e.fireAndForget)return n();var h=d.ACK_TIMEOUT,w=e.timeout||d.RES_TIMEOUT,m=100;setTimeout(function n(){if(!a){if(Object(o.isWindowClosed)(s))return p.ack?r(new Error("Window closed for "+t+" before response")):r(new Error("Window closed for "+t+" before ack"));if(h=Math.max(h-m,0),-1!==w&&(w=Math.max(w-m,0)),p.ack){if(-1===w)return;m=Math.min(w,2e3)}else{if(0===h)return r(new Error("No ack for postMessage "+t+" in "+Object(o.getDomain)()+" in "+d.ACK_TIMEOUT+"ms"));if(0===w)return r(new Error("No response for postMessage "+t+" in "+Object(o.getDomain)()+" in "+(e.timeout||d.RES_TIMEOUT)+"ms"))}setTimeout(n,m)}},m)})});return l.catch(function(){!function(e){b.erroredResponseListeners[e]=!0}(c),F(c)}),u.push(l),l})}function q(e,t,n,r){return(r=r||{}).window=e,r.name=t,r.data=n,Z(r)}function Y(e,t,n){var r=Object(o.getAncestor)();return r?q(r,e,t,n):new O(function(e,t){return t(new Error("Window does not have a parent"))})}function $(){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(n,r){return q(t,n,r,e)}}}b.receivedMessages=b.receivedMessages||[],b.receiveMessage=H,b.requestPromises=b.requestPromises||new u,b.send=q;var J="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 K(e){if(!e.name)throw new Error("Expected options.name");if(!e.handler)throw new Error("Expected options.handler");var t,n=e.name,r=e.window,i=e.domain,s={handler:e.handler,handleError:e.errorHandler||function(e){throw e},window:r,domain:i||f.WILDCARD,name:n},c=function e(t,n){var r=t.name,o=t.win,i=t.domain;if(!r||"string"!=typeof r)throw new Error("Name required to add request listener");if(Array.isArray(o)){for(var s=[],c=0,a=o,l=null==a?0:a.length;c<l;c++){var d=a[c];s.push(e({name:r,domain:i,win:d},n))}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,w=i,m=null==w?0:w.length;h<m;h++){var y=w[h];p.push(e({name:r,win:o,domain:y},n))}return{cancel:function(){for(var e=0,t=null==p?0:p.length;e<t;e++)p[e].cancel()}}}var g=k({name:r,win:o,domain:i});if(o&&o!==f.WILDCARD||(o=b.WINDOW_WILDCARD),i=i||f.WILDCARD,g)throw o&&i?new Error("Request listener already exists for "+r+" on domain "+i.toString()+" for "+(o===b.WINDOW_WILDCARD?"wildcard":"specified")+" window"):o?new Error("Request listener already exists for "+r+" for "+(o===b.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 E=b.requestListeners,_=E[r];_||(_=new u,E[r]=_);var O=_.get(o);O||(O={},_.set(o,O));var S=i.toString(),C=O[x],A=void 0;return v(i)?(C||(C=[],O[x]=C),A={regex:i,listener:n},C.push(A)):O[S]=n,{cancel:function(){O&&(delete O[S],o&&0===Object.keys(O).length&&_.delete(o),A&&C.splice(C.indexOf(A,1)))}}}({name:n,win:r,domain:i},s);if(e.once){var a=s.handler;s.handler=w(function(){return c.cancel(),a.apply(this,arguments)})}if(s.window&&e.errorOnClose)var l=(t=void 0,t=setTimeout(function e(){t=setTimeout(e,50),function(){r&&"object"===(void 0===r?"undefined":J(r))&&Object(o.isWindowClosed)(r)&&(l.cancel(),s.handleError(new Error("Post message target window is closed")))}.call()},50),{cancel:function(){clearTimeout(t)}});return{cancel:function(){c.cancel()}}}function V(e,t,n){return"function"==typeof t&&(n=t,t={}),(t=t||{}).name=e,t.handler=n||t.handler,K(t)}function Q(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];"function"==typeof t&&(n=t,t={}),t=t||{},n=n||t.handler;var r=t.errorHandler,o=new O(function(o,i){(t=t||{}).name=e,t.once=!0,t.handler=function(e){if(o(e),n)return n(e)},t.errorHandler=function(e){if(i(e),r)return r(e)}}),i=K(t);return o.cancel=i.cancel,o}function X(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{on:function(t,n){return V(t,e,n)}}}function ee(){delete window[f.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",B)}b.on=V;var te=Object(o.getAncestor)();function ne(e){var t=b.requestPromises.get(e);if(t)for(var n=0,r=null==t?0:t.length;n<r;n++)t[n].reject(new Error("No response from window - cleaned up"));b.popupWindowsByWin&&b.popupWindowsByWin.delete(e),b.remoteWindows&&b.remoteWindows.delete(e),b.requestPromises.delete(e),b.methods.delete(e),b.readyPromises.delete(e)}var re=null;function oe(){var e,t;b.initialized||(t=B,(e=window).addEventListener?e.addEventListener("message",t):e.attachEvent("onmessage",t),function(){e=function(e){var t=e.source,n=e.origin,r=b.readyPromises.get(t)||new O;r.resolve({origin:n}),b.readyPromises.set(t,r)},b.on(f.POST_MESSAGE_NAMES.HELLO,{domain:f.WILDCARD},function(t){var n=t.source,r=t.origin;return e({source:n,origin:r})});var e,t=Object(o.getAncestor)();t&&j(t).catch(m)}(),C({on:V,send:q})),b.initialized=!0}oe(),n.d(t,"cleanUpWindow",function(){return ne}),n.d(t,"Promise",function(){return O}),n.d(t,"bridge",function(){return re}),n.d(t,"init",function(){return oe}),n.d(t,"parent",function(){return te}),n.d(t,"send",function(){return q}),n.d(t,"request",function(){return Z}),n.d(t,"sendToParent",function(){return Y}),n.d(t,"client",function(){return $}),n.d(t,"on",function(){return V}),n.d(t,"listen",function(){return K}),n.d(t,"once",function(){return Q}),n.d(t,"listener",function(){return X}),n.d(t,"CONFIG",function(){return d}),n.d(t,"CONSTANTS",function(){return f}),n.d(t,"disable",function(){return ee}),t.default=r}})});!function(e){e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")&&e.default}(f);f.postRobot;var l,d=u(function(e){e.exports=f,e.exports.default=e.exports});class p{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"}(l||(l={}));var h=l;function w(e){return Object.keys(function(e){return Object.keys(e).reduce((t,n)=>(e[n]&&(t[n]=e[n]),t),{})}(e)).reduce((t,n)=>[...t,[n,e[n]].join("=")],[]).join("&")}var m="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function y(e,t){return e(t={exports:{}},t.exports),t.exports}var g=1e3,v=6e4,E=36e5,_=24*E,O=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*_;case"hours":case"hour":case"hrs":case"hr":case"h":return n*E;case"minutes":case"minute":case"mins":case"min":case"m":return n*v;case"seconds":case"second":case"secs":case"sec":case"s":return n*g;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);return t>=_?b(e,t,_,"day"):t>=E?b(e,t,E,"hour"):t>=v?b(e,t,v,"minute"):t>=g?b(e,t,g,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=_?Math.round(e/_)+"d":t>=E?Math.round(e/E)+"h":t>=v?Math.round(e/v)+"m":t>=g?Math.round(e/g)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function b(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var S=function(e){function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){let i;function s(...e){if(!s.enabled)return;const t=s,r=Number(new Date),o=r-(i||r);t.diff=o,t.prev=i,t.curr=r,i=r,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let c=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return r;c++;const i=n.formatters[o];if("function"==typeof i){const n=e[c];r=i.call(t,n),e.splice(c,1),c--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=r,s.extend=o,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function r(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function o(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(i),...n.skips.map(i).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){const e=n.instances[t];e.enabled=n.enabled(e.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=O,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n},C=y(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 n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))}),t.splice(o,0,n)},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=S(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});C.log,C.formatArgs,C.save,C.load,C.useColors,C.storage,C.colors;var A=function(){return!1},R=function(e){return e instanceof Buffer},T=y(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 n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}),I=y(function(e){try{var t=j;if("function"!=typeof t.inherits)throw"";e.exports=t.inherits}catch(t){e.exports=T}}),j=y(function(e,t){var n=/%[sdj%]/g;t.format=function(e){if(!w(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(i(arguments[r]));return t.join(" ")}r=1;for(var o=arguments,s=o.length,c=String(e).replace(n,function(e){if("%%"===e)return"%";if(r>=s)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}}),a=o[r];r<s;a=o[++r])p(a)||!v(a)?c+=" "+a:c+=" "+i(a);return c},t.deprecate=function(e,n){if(y(m.process))return function(){return t.deprecate(e,n).apply(this,arguments)};if(!0===process.noDeprecation)return e;var r=!1;return function(){if(!r){if(process.throwDeprecation)throw new Error(n);process.traceDeprecation?console.trace(n):console.error(n),r=!0}return e.apply(this,arguments)}};var r,o={};function i(e,n){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&t._extend(r,n),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),a(r,e,r.depth)}function s(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function c(e,t){return e}function a(e,n,r){if(e.customInspect&&n&&O(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,e);return w(o)||(o=a(e,o,r)),o}var i=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(w(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return h(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):p(t)?e.stylize("null","null"):void 0}(e,n);if(i)return i;var s=Object.keys(n),c=function(e){var t={};return s.forEach(function(e,n){t[e]=!0}),t}();if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),_(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return u(n);if(0===s.length){if(O(n)){var m=n.name?": "+n.name:"";return e.stylize("[Function"+m+"]","special")}if(g(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(E(n))return e.stylize(Date.prototype.toString.call(n),"date");if(_(n))return u(n)}var v,b="",S=!1,C=["{","}"];return l(n)&&(S=!0,C=["[","]"]),O(n)&&(b=" [Function"+(n.name?": "+n.name:"")+"]"),g(n)&&(b=" "+RegExp.prototype.toString.call(n)),E(n)&&(b=" "+Date.prototype.toUTCString.call(n)),_(n)&&(b=" "+u(n)),0!==s.length||S&&0!=n.length?r<0?g(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),v=S?function(e,t,n,r,o){for(var i=[],s=0,c=t.length;s<c;++s)A(t,String(s))?i.push(f(e,t,n,r,String(s),!0)):i.push("");return o.forEach(function(o){o.match(/^\d+$/)||i.push(f(e,t,n,r,o,!0))}),i}(e,n,r,c,s):s.map(function(t){return f(e,n,r,c,t,S)}),e.seen.pop(),function(e,t,n){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(v,b,C)):C[0]+b+C[1]}function u(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,o,i){var s,c,u;if((u=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?c=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(c=e.stylize("[Setter]","special")),A(r,o)||(s="["+o+"]"),c||(e.seen.indexOf(u.value)<0?(c=p(n)?a(e,u.value,null):a(e,u.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+c.split("\n").map(function(e){return" "+e}).join("\n")):c=e.stylize("[Circular]","special")),y(s)){if(i&&o.match(/^\d+$/))return c;(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+": "+c}function l(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function p(e){return null===e}function h(e){return"number"==typeof e}function w(e){return"string"==typeof e}function y(e){return void 0===e}function g(e){return v(e)&&"[object RegExp]"===b(e)}function v(e){return"object"==typeof e&&null!==e}function E(e){return v(e)&&"[object Date]"===b(e)}function _(e){return v(e)&&("[object Error]"===b(e)||e instanceof Error)}function O(e){return"function"==typeof e}function b(e){return Object.prototype.toString.call(e)}function S(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(y(r)&&(r=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!o[e])if(new RegExp("\\b"+e+"\\b","i").test(r)){var n=process.pid;o[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else o[e]=function(){};return o[e]},t.inspect=i,i.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]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=l,t.isBoolean=d,t.isNull=p,t.isNullOrUndefined=function(e){return null==e},t.isNumber=h,t.isString=w,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=y,t.isRegExp=g,t.isObject=v,t.isDate=E,t.isError=_,t.isFunction=O,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=R;var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(n=[S((e=new Date).getHours()),S(e.getMinutes()),S(e.getSeconds())].join(":"),[e.getDate(),C[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=I,t._extend=function(e,t){if(!t||!v(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}),P=(j.format,j.deprecate,j.debuglog,j.inspect,j.isArray,j.isBoolean,j.isNull,j.isNullOrUndefined,j.isNumber,j.isString,j.isSymbol,j.isUndefined,j.isRegExp,j.isObject,j.isDate,j.isError,j.isFunction,j.isPrimitive,j.isBuffer,j.log,j.inherits,j._extend,P),D=(e,t)=>{t=t||process.argv;const n=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(n+e),o=t.indexOf("--");return-1!==r&&(-1===o||r<o)};const L=process.env;let N;function x(e){return function(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}(function(e){if(!1===N)return 0;if(D("color=16m")||D("color=full")||D("color=truecolor"))return 3;if(D("color=256"))return 2;if(e&&!e.isTTY&&!0!==N)return 0;const t=N?1:0;if("win32"===process.platform){const e=P.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 L)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in L)||"codeship"===L.CI_NAME?1:t;if("TEAMCITY_VERSION"in L)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(L.TEAMCITY_VERSION)?1:0;if("truecolor"===L.COLORTERM)return 3;if("TERM_PROGRAM"in L){const e=parseInt((L.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(L.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(L.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(L.TERM)?1:"COLORTERM"in L?1:(L.TERM,t)}(e))}D("no-color")||D("no-colors")||D("color=false")?N=!1:(D("color")||D("colors")||D("color=true")||D("color=always"))&&(N=!0),"FORCE_COLOR"in L&&(N=0===L.FORCE_COLOR.length||0!==parseInt(L.FORCE_COLOR,10));var M={supportsColor:x,stdout:x(process.stdout),stderr:x(process.stderr)},F=y(function(e,t){t.init=function(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let r=0;r<n.length;r++)e.inspectOpts[n[r]]=t.inspectOpts[n[r]]},t.log=function(...e){return process.stderr.write(j.format(...e)+"\n")},t.formatArgs=function(n){const{namespace:r,useColors:o}=this;if(o){const t=this.color,o="[3"+(t<8?t:"8;5;"+t),i=` ${o};1m${r} `;n[0]=i+n[0].split("\n").join("\n"+i),n.push(o+"m+"+e.exports.humanize(this.diff)+"")}else n[0]=(t.inspectOpts.hideDate?"":(new Date).toISOString()+" ")+r+" "+n[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):A(process.stderr.fd)},t.colors=[6,2,3,4,5,1];try{const n=M;n&&(n.stderr||n).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 n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[n]=r,e},{}),e.exports=S(t);const{formatters:n}=e.exports;n.o=function(e){return this.inspectOpts.colors=this.useColors,j.inspect(e,this.inspectOpts).replace(/\s*\n\s*/g," ")},n.O=function(e){return this.inspectOpts.colors=this.useColors,j.inspect(e,this.inspectOpts)}}),W=(F.init,F.log,F.formatArgs,F.save,F.load,F.useColors,F.colors,F.inspectOpts,y(function(e){"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=C:e.exports=F}));const k=(e=>W(`bearer:${e}`))("core").extend("Bearer"),U=e=>{k(`%c ${e}`,"background: #222; color: #bada55")},G="BEARER_INSTANCE",z="BEARER_EMITTER",H="BEARER",B="BEARER_CONFIG",Z="BEARER-IFRAME",q="LOG_LEVEL";class Y{constructor(e,t){this.window=t,this.isSessionInitialized=!1,this.authorized=(e=>{Y.emitter.emit(h.AUTHORIZED,e)}),this.revoked=(e=>{Y.emitter.emit(h.REVOKED,e)}),this.hasAuthorized=(e=>new Promise((t,n)=>{d.send(this.iframe,h.HAS_AUTHORIZED,{integrationId:e,clientId:Y.config.clientId}).then(({data:e,data:{authorized:r}})=>{k("HAS_AUTHORIZED response %j",e),r?t(!0):n(!1)}).catch($)})),this.revokeAuthorization=((e,t)=>{d.send(this.iframe,h.REVOKE,{authId:t,integrationId:e,clientId:Y.config.clientId}).then(()=>{k("Signing out")}).catch($)}),this.askAuthorizations=(({integrationId:e,setupId:t,authRefId:n=""})=>{if(this.isSessionInitialized){const r=w({setupId:t,authId:n,secured:Y.config.secured,clientId:this.bearerConfig.clientId}),o=`${Y.config.integrationHost}v2/auth/${e}?${r}`;return this.window.open(o,"","resizable,scrollbars,status,centerscreen=yes,width=500,height=600"),!0}return!1}),this.bearerConfig=new p(e||{}),this.maybeInitialized=new Promise((e,t)=>{this.allowIntegrationRequests=e}),this.window[q]=this.bearerConfig.postRobotLogLevel,this.initSession()}static set _instance(e){window[G]&&U("Replacing bearer instance"),window[G]=e}static get _instance(){return window[G]}static get emitter(){return window[z]||(window[z]=new c),window[z]}static get instance(){return window[G]||this.init({})}static get config(){return this.instance.bearerConfig}static get version(){return"0.114.1"}get bearerConfig(){return window[H]}set bearerConfig(e){window[H]=e}get maybeInitialized(){return this.isSessionInitialized||U("Waiting Bearer to be initialized"),this._maybeInitialized}set maybeInitialized(e){this._maybeInitialized=e}static init(e={}){return this._instance&&U("One instance is already configured, reaplacing it"),this._instance=new Y(Object.assign({},e,window[B]||{}),window),this._instance}initSession(){void 0===this.window||document.querySelector(`#${Z}`)||(d.on(h.SESSION_INITIALIZED,e=>{this.sessionInitialized(e)}),d.on(h.AUTHORIZED,this.authorized),d.on(h.REVOKED,this.revoked),this.iframe=document.createElement("iframe"),this.iframe.src=`${this.bearerConfig.authorizationHost}v1/user/initialize`,this.iframe.id=Z,this.iframe.width="0",this.iframe.height="0",this.iframe.frameBorder="0",this.iframe.style.display="none",document.body.appendChild(this.iframe))}sessionInitialized(e){k("session initialized"),this.isSessionInitialized=!0,this.allowIntegrationRequests(!0)}}function $(e){k("Error contacting iframe")}Y.onAuthorized=((e,t)=>(k("onAuthorized register %s",e),Y.emitter.addListener(h.AUTHORIZED,n=>{n.data.integrationId===e?(k("onAuthorized authorized %s",e),t(!0)):k("onAuthorized different integrationId %s",e)}))),Y.onRevoked=((e,t)=>(k("onRevoked register %s",e),Y.emitter.addListener(h.REVOKED,n=>{n.data.integrationId===e?(k("onRevoked revoked %s",e),t(!1)):k("onRevoked different integrationId %s",e)})));var J=/<%=([\s\S]+?)%>/g,K=1/0,V="[object Symbol]",Q=/[&<>"'`]/g,X=RegExp(Q.source),ee="object"==typeof a&&a&&a.Object===Object&&a,te="object"==typeof self&&self&&self.Object===Object&&self,ne=ee||te||Function("return this")();var re,oe=(re={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},function(e){return null==re?void 0:re[e]}),ie=Object.prototype.toString,se=ne.Symbol,ce=se?se.prototype:void 0,ae=ce?ce.toString:void 0;var ue={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:J,variable:"",imports:{_:{escape:function(e){return t=e,(e=null==t?"":function(e){if("string"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&ie.call(e)==V}(e))return ae?ae.call(e):"";var t=e+"";return"0"==t&&1/e==-K?"-0":t}(t))&&X.test(e)?e.replace(Q,oe):e;var t}}}},fe=1/0,le=9007199254740991,de="[object Arguments]",pe="[object Error]",he="[object Function]",we="[object GeneratorFunction]",me="[object Symbol]",ye=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,ve=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ee=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,_e=/^(?:0|[1-9]\d*)$/,Oe=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ce="object"==typeof a&&a&&a.Object===Object&&a,Ae="object"==typeof self&&self&&self.Object===Object&&self,Re=Ce||Ae||Function("return this")();function Te(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Ie(e,t){return function(e,t){for(var n=-1,r=e?e.length:0,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}(t,function(t){return e[t]})}function je(e){return"\\"+Se[e]}var Pe,De,Le=Object.prototype,Ne=Le.hasOwnProperty,xe=Le.toString,Me=Re.Symbol,Fe=Le.propertyIsEnumerable,We=(Pe=Object.keys,De=Object,function(e){return Pe(De(e))}),ke=Math.max,Ue=Me?Me.prototype:void 0,Ge=Ue?Ue.toString:void 0;function ze(e,t){var n=Qe(e)||function(e){return function(e){return nt(e)&&Xe(e)}(e)&&Ne.call(e,"callee")&&(!Fe.call(e,"callee")||xe.call(e)==de)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var i in e)!t&&!Ne.call(e,i)||o&&("length"==i||$e(i,r))||n.push(i);return n}function He(e,t,n,r){return void 0===e||Ve(e,Le[n])&&!Ne.call(r,n)?t:e}function Be(e,t,n){var r=e[t];Ne.call(e,t)&&Ve(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ze(e){if(!tt(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=Ke(e),n=[];for(var r in e)("constructor"!=r||!t&&Ne.call(e,r))&&n.push(r);return n}function qe(e,t){return t=ke(void 0===t?e.length-1:t,0),function(){for(var n=arguments,r=-1,o=ke(n.length-t,0),i=Array(o);++r<o;)i[r]=n[t+r];r=-1;for(var s=Array(t+1);++r<t;)s[r]=n[r];return s[t]=i,Te(e,this,s)}}function Ye(e){if("string"==typeof e)return e;if(function(e){return"symbol"==typeof e||nt(e)&&xe.call(e)==me}(e))return Ge?Ge.call(e):"";var t=e+"";return"0"==t&&1/e==-fe?"-0":t}function $e(e,t){return!!(t=null==t?le:t)&&("number"==typeof e||_e.test(e))&&e>-1&&e%1==0&&e<t}function Je(e,t,n){if(!tt(n))return!1;var r=typeof t;return!!("number"==r?Xe(n)&&$e(t,n.length):"string"==r&&t in n)&&Ve(n[t],e)}function Ke(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Le)}function Ve(e,t){return e===t||e!=e&&t!=t}var Qe=Array.isArray;function Xe(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=le}(e.length)&&!function(e){var t=tt(e)?xe.call(e):"";return t==he||t==we}(e)}function et(e){return!!nt(e)&&(xe.call(e)==pe||"string"==typeof e.message&&"string"==typeof e.name)}function tt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function nt(e){return!!e&&"object"==typeof e}var rt,ot=(rt=function(e,t,n,r){!function(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var s=t[o],c=r?r(n[s],e[s],s,n,e):void 0;Be(n,s,void 0===c?e[s]:c)}}(t,function(e){return Xe(e)?ze(e,!0):Ze(e)}(t),e,r)},qe(function(e,t){var n=-1,r=t.length,o=r>1?t[r-1]:void 0,i=r>2?t[2]:void 0;for(o=rt.length>3&&"function"==typeof o?(r--,o):void 0,i&&Je(t[0],t[1],i)&&(o=r<3?void 0:o,r=1),e=Object(e);++n<r;){var s=t[n];s&&rt(e,s,n,o)}return e}));function it(e){return Xe(e)?ze(e):function(e){if(!Ke(e))return We(e);var t=[];for(var n in Object(e))Ne.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}var st=qe(function(e,t){try{return Te(e,void 0,t)}catch(e){return et(e)?e:new Error(e)}}),ct=function(e,t,n){var r,o=ue.imports._.templateSettings||ue;n&&Je(e,t,n)&&(t=void 0),e=null==(r=e)?"":Ye(r),t=ot({},t,o,He);var i,s,c=ot({},t.imports,o.imports,He),a=it(c),u=Ie(c,a),f=0,l=t.interpolate||Oe,d="__p += '",p=RegExp((t.escape||Oe).source+"|"+l.source+"|"+(l===J?Ee:Oe).source+"|"+(t.evaluate||Oe).source+"|$","g"),h="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";e.replace(p,function(t,n,r,o,c,a){return r||(r=o),d+=e.slice(f,a).replace(be,je),n&&(i=!0,d+="' +\n__e("+n+") +\n'"),c&&(s=!0,d+="';\n"+c+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=a+t.length,t}),d+="';\n";var w=t.variable;w||(d="with (obj) {\n"+d+"\n}\n"),d=(s?d.replace(ye,""):d).replace(ge,"$1").replace(ve,"$1;"),d="function("+(w||"obj")+") {\n"+(w?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var m=st(function(){return Function(a,h+"return "+d).apply(void 0,u)});if(m.source=d,et(m))throw m;return m};const at=/{{([\s\S]+?)}}/g,ut=e=>t=>(n,r,o)=>ct(t.get(e,n)||r,{interpolate:at})(o||{});var ft;!function(e){e.FetchData="FetchData"}(ft||(ft={}));const lt="bearerContext",dt="setupId",pt="BearerStateSaved",ht="bearer:StateSaved";function wt(e,t=ft.FetchData){return function(t,n){!function(e,t,n){const r=()=>{};delete e[t]&&Object.defineProperty(e,t,{get:n,set:r})}(t,n,()=>(function(n={}){const r=t.INTEGRATION_ID;return r?bearer.instance.invoke(r,e,Object.assign({},n,{query:{setupId:mt(this),referenceId:yt(this)}})).catch(e=>{throw e}):(console.info("[BEARER]","Missing integrationId, skipping api call"),Promise.reject(new gt))}))}}function mt(e){return e.setupId||e[lt]&&e[lt][dt]}function yt(e){return e.referenceId}class gt extends Error{constructor(){super(...arguments),this.message="Integration ID is missing. Please add @RootComponent decorator above your class definition"}}const vt=e=>(e,t)=>{},Et=h,_t=e=>ut(e)(window.bearer.i18n),Ot=e=>(e=>t=>(n,r,o,i)=>{const s=[n,r].join(".");if(t.get(e,s))return ut(e)(t)(s,o,i);const c=[n,r>1?"many":r].join(".");return ut(e)(t)(c,o,i)})(e)(window.bearer.i18n);export default Y;export{Et as Events,_t as scopedT,Ot as scopedP,vt as BearerState,ft as FunctionType,lt as BearerContext,dt as setupId,pt as FunctionSaved,ht as BearerStateSavedEvent,wt as _BackendFunction};