post-robot
Advanced tools
Comparing version 4.0.16 to 4.0.17
{ | ||
"name": "post-robot", | ||
"main": "index.js", | ||
"version": "4.0.16", | ||
"version": "4.0.17", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Daniel Brain <dbrain@paypal.com>" |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():e.postRobot=r()}(this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){"use strict";function t(){s.global.initialized||(i.util.listen(window,"message",a.messageListener),(0,u.openTunnelToOpener)(),(0,i.initOnReady)(),(0,i.listenForMethods)()),s.global.initialized=!0}Object.defineProperty(r,"__esModule",{value:!0}),r.Promise=void 0;var o=n(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(8);Object.defineProperty(r,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=n(6),s=n(15),u=n(23);t(),r["default"]=e.exports},function(e,r,n){"use strict";function t(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r["default"]=e,r}Object.defineProperty(r,"__esModule",{value:!0}),r.winutil=r.util=r.linkUrl=r.bridgeRequired=r.openBridge=r.reset=r.parent=void 0;var o=n(2);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(25);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(26);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var s=n(6);Object.defineProperty(r,"reset",{enumerable:!0,get:function(){return s.resetListeners}});var u=n(23);Object.defineProperty(r,"openBridge",{enumerable:!0,get:function(){return u.openBridge}}),Object.defineProperty(r,"bridgeRequired",{enumerable:!0,get:function(){return u.bridgeRequired}}),Object.defineProperty(r,"linkUrl",{enumerable:!0,get:function(){return u.linkUrl}});var c=n(12);Object.defineProperty(r,"util",{enumerable:!0,get:function(){return c.util}});var d=n(14),f=t(d);r.parent=(0,d.getAncestor)(),r.winutil=f},function(e,r,n){"use strict";function t(e){return c.promise.nodeify(new c.promise.Promise(function(r,n){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(s.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var t=document.getElementById(e.window);if(!t)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==t.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=t.contentWindow,!e.window)throw new Error("Expected options.window")}e.domain=e.domain||"*";var o=e.name+"_"+c.util.uniqueID();if(u.listeners.response[o]=e,(0,c.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,t){return e||(i=!0),e?n(e):r(t)},c.promise.run(function(){return(0,c.isAncestor)(window,e.window)?(0,c.onWindowReady)(e.window):void 0}).then(function(){if((0,u.sendMessage)(e.window,{hash:o,type:s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data,fireAndForget:e.fireAndForget},e.domain)["catch"](n),e.fireAndForget)return r();var t=c.util.intervalTimeout(s.CONFIG.ACK_TIMEOUT,100,function(r){return e.ack||(0,c.isWindowClosed)(e.window)?t.cancel():r?void 0:n(new Error("No ack for postMessage "+e.name+" in "+s.CONFIG.ACK_TIMEOUT+"ms"))});e.timeout&&!function(){var r=c.util.intervalTimeout(e.timeout,100,function(t){return i||(0,c.isWindowClosed)(e.window)?r.cancel():t?void 0:n(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}()})["catch"](n)}),e.callback)}function o(e,r,n,o,i){return i||(o||"function"!=typeof n?"function"==typeof o&&(i=o,o={}):(i=n,o={},n={})),o=o||{},o.window=e,o.name=r,o.data=n,o.callback=i,t(o)}function i(e,r,n,t){var i=(0,c.getAncestor)();return i?o(i,e,r,n,t):new c.promise.Promise(function(e,r){return r(new Error("Window does not have a parent"))})}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(!e.window)throw new Error("Expected options.window");return{send:function(r,n,t){return o(e.window,r,n,e,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.send=void 0,r.request=t,r.sendToParent=i,r.client=a;var s=n(3),u=n(6),c=n(8);r.send=o},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(4);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.CONFIG=void 0;var o,i=n(5),a=r.CONFIG={ALLOW_POSTMESSAGE_POPUP:!0,LOG_LEVEL:"info",BRIDGE_TIMEOUT:5e3,ACK_TIMEOUT:1e3,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL,!0),o)};0===window.location.href.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(a.ALLOW_POSTMESSAGE_POPUP=!0)},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=r.CONSTANTS={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",READY:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},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__"};r.POST_MESSAGE_NAMES_LIST=Object.keys(n.POST_MESSAGE_NAMES).map(function(e){return n.POST_MESSAGE_NAMES[e]})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(7);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(24);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,r,n){"use strict";function t(e){try{e=(0,s.jsonParse)(e)}catch(r){return}if(e&&(e=e[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],e&&e.type&&d.RECEIVE_MESSAGE_TYPES[e.type]))return e}function o(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(r){return}var n=e.source,o=e.origin,i=e.data,u=t(i);if(u&&(0!==u.sourceDomain.indexOf(a.CONSTANTS.MOCK_PROTOCOL)&&0!==u.sourceDomain.indexOf(a.CONSTANTS.FILE_PROTOCOL)||(o=u.sourceDomain),-1===c.global.receivedMessages.indexOf(u.id))){c.global.receivedMessages.push(u.id);var f=void 0;if(f=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(u.name)||u.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===u.ack?"error":"info",s.log.logLevel(f,["\n\n ","#receive",u.type.replace(/^postrobot_message_/,""),"::",u.name,"::",o,"\n\n",u]),(0,s.isWindowClosed)(n))return s.log.debug("Source window is closed - can not send "+u.type+" "+u.name);u.data&&(u.data=(0,s.deserializeMethods)(n,o,u.data)),d.RECEIVE_MESSAGE_TYPES[u.type](n,o,u)}}function i(e){try{e.source}catch(r){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,u.emulateIERestrictions)(e.source,window)}catch(r){return}o(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.receiveMessage=o,r.messageListener=i;var a=n(3),s=n(8),u=n(18),c=n(15),d=n(20);c.global.receivedMessages=c.global.receivedMessages||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(9);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var s=n(16);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return s[e]}})});var u=n(11);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return u[e]}})});var c=n(17);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.promise=r.Promise=void 0;var t=n(10),o=n(11),i=r.Promise=t.SyncPromise,a=r.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(r,n){(0,o.nextTick)(function(){return a.run(e).then(r,n)})})},method:function(e){return function(){var r=this,n=arguments;return i.resolve().then(function(){return e.apply(r,n)})}},nodeify:function(e,r){return r?void e.then(function(e){r(null,e)},function(e){r(e)}):e},deNodeify:function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;r>t;t++)n[t-1]=arguments[t];return new i(function(r,t){try{return n.length<e.length?e.apply(void 0,n.concat([function(e,n){return e?t(e):r(n)}])):a.run(function(){return e.apply(void 0,n)}).then(r,t)}catch(o){return t(o)}})},map:function(e,r){for(var n=[],t=function(t){n.push(a.run(function(){return r(e[t])}))},o=0;o<e.length;o++)t(o);return i.all(n)}}},function(e,r){"use strict";function n(e,r,n){function t(){if(a){if(u)return n(o);if(s)return r(i)}}var o,i,a=!1,s=!1,u=!1;try{e(function(e){i=e,s=!0,t()},function(e){o=e,u=!0,t()})}catch(c){return n(c)}a=!0,t()}function t(e){d.push(e),u=u||setTimeout(o,1)}function o(){u=null;var e=d;d=[];for(var r=0;r<e.length;r++){var n=e[r];n.hasHandlers||(n.handlers.push({onError:function(e){if(!n.hasHandlers){i(e);for(var r=0;r<c.length;r++)c[r](n.value)}}}),n.dispatch())}}function i(e){setTimeout(function(){throw e},1)}function a(e){try{if(!e)return!1;if(window.Window&&e instanceof window.Window)return!1;if(window.constructor&&e instanceof window.constructor)return!1;if(f){var r=f.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if(e&&e.then instanceof Function)return!0}catch(n){return!1}return!1}function s(){window.Promise=l}Object.defineProperty(r,"__esModule",{value:!0}),r.patchPromise=s;var u,c=[],d=[],f={}.toString,l=r.SyncPromise=function(e,r){if(this.parent=r,this.resolved=!1,this.rejected=!1,this.hasHandlers=!1,this.handlers=[],t(this),e){var o=this;n(e,function(e){return o.resolve(e)},function(e){return o.reject(e)})}};l.resolve=function(e){return a(e)?e:(new l).resolve(e)},l.reject=function(e){return(new l).reject(e)},l.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},l.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},l.prototype.dispatch=function(){var e=this;if(this.resolved||this.rejected)for(var r=function(){var r=e.handlers.shift();try{e.resolved?n=r.onSuccess?r.onSuccess(e.value):e.value:r.onError?n=r.onError(e.value):t=e.value}catch(o){t=o}if(n===e)throw new Error("Can not return a promise from the the then handler of the same promise");return r.promise?void(t?r.promise.reject(t):a(n)?n.then(function(e){r.promise.resolve(e)},function(e){r.promise.reject(e)}):r.promise.resolve(n)):"continue"};this.handlers.length;){var n,t;r()}},l.prototype.then=function(e,r){var n=new l(null,this);return this.handlers.push({promise:n,onSuccess:e,onError:r}),this.hasHandlers=!0,this.dispatch(),n},l.prototype["catch"]=function(e){return this.then(null,e)},l.prototype["finally"]=function(e){return this.then(function(r){return e(),r},function(r){throw e(),r})},l.all=function(e){for(var r=new l,n=e.length,t=[],o=0;o<e.length;o++){var i=a(e[o])?e[o]:l.resolve(e[o]);i.then(function(e){t[o]=e,n-=1,0===n&&r.resolve(t)},function(e){r.reject(e)})}return r},l.onPossiblyUnhandledException=function(e){c.push(e)}},function(e,r,n){"use strict";function t(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(r,"__esModule",{value:!0}),r.nextTick=t;var o=n(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var r=a.shift();r.call()}})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.util=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(3),i=r.util={once:function(e){if(!e)return e;var r=!1;return function(){return r?void 0:(r=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,r){try{return!!e[r]}catch(n){return!1}},safeGetProp:function(e,r){try{return e[r]}catch(n){return}},listen:function(e,r,n){return e.addEventListener?e.addEventListener(r,n):e.attachEvent("on"+r,n),{cancel:function(){e.removeEventListener?e.removeEventListener(r,n):e.detachEvent("on"+r,n)}}},apply:function(e,r,n){return"function"==typeof e.apply?e.apply(r,n):e(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9])},find:function(e,r,n){if(!e)return n;for(var t=0;t<e.length;t++)if(r(e[t]))return e[t];return n},map:function(e,r){for(var n=[],t=0;t<e.length;t++)n.push(r(e[t]));return n},some:function(e,r){r=r||Boolean;for(var n=0;n<e.length;n++)if(r(e[n]))return!0;return!1},keys:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(n);return r},values:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(e[n]);return r},getByValue:function(e,r){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r)return n},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var r={};return function(){var n=JSON.stringify(Array.prototype.slice.call(arguments));return r.hasOwnProperty(n)||(r[n]=e.apply(this,arguments)),r[n]}},extend:function(e,r){if(!r)return e;for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n]);return e},each:function(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(e[n],n);else if("object"===("undefined"==typeof e?"undefined":t(e))&&null!==e)for(var o in e)e.hasOwnProperty(o)&&r(e[o],o)},replaceObject:function(e,r){var n=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(n>=100)throw new Error("Self-referential object passed, or object contained too many layers");var o=Array.isArray(e)?[]:{};return i.each(e,function(e,a){var s=r(e,a);void 0!==s?o[a]=s:"object"===("undefined"==typeof e?"undefined":t(e))&&null!==e?o[a]=i.replaceObject(e,r,n+1):o[a]=e}),o},safeInterval:function(e,r){function n(){t=setTimeout(n,r),e.call()}var t=void 0;return t=setTimeout(n,r),{cancel:function(){clearTimeout(t)}}},intervalTimeout:function(e,r,n){var t=i.safeInterval(function(){e-=r,e=0>=e?0:e,0===e&&t.cancel(),n(e)},r);return t},getDomain:function(e){if(e=e||window,e.mockDomain&&0===e.mockDomain.indexOf(o.CONSTANTS.MOCK_PROTOCOL))return e.mockDomain;if(!e.location.protocol)throw new Error("Can not read window protocol");if(!e.location.host)throw new Error("Can not read window host");return e.location.protocol+"//"+e.location.host},getDomainFromUrl:function(e){var r=void 0;return e.match(/^(https?|mock|file):\/\//)?(r=e,r=r.split("/").slice(0,3).join("/")):this.getDomain()},safeGet:function(e,r){var n=void 0;try{n=e[r]}catch(t){}return n}}},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.log=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(12),i=n(14),a=n(3),s=["debug","info","warn","error"];Function.prototype.bind&&window.console&&"object"===t(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var u=r.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),a.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,r){setTimeout(function(){var n=document.getElementById("postRobotLogs");n||(n=document.createElement("div"),n.id="postRobotLogs",n.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(n));var t=document.createElement("div"),a=(new Date).toString().split(" ")[4],s=o.util.map(r,function(e){if("string"==typeof e)return e;if(!e)return Object.prototype.toString.call(e);var r=void 0;try{r=(0,i.jsonStringify)(e,0,2)}catch(n){r="[object]"}return"\n\n"+r+"\n\n"}).join(" "),u=a+" "+e+" "+s;t.innerHTML=u;var c={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];t.style.cssText="margin-top: 10px; color: "+c+";",n.childNodes.length?n.insertBefore(t,n.childNodes[0]):n.appendChild(t)})},logLevel:function(e,r){try{if(s.indexOf(e)<s.indexOf(a.CONFIG.LOG_LEVEL))return;if(r=Array.prototype.slice.call(r),r.unshift(""+window.location.host+window.location.pathname),r.unshift("::"),r.unshift(""+(0,i.getWindowType)().toLowerCase()),r.unshift("[post-robot]"),a.CONFIG.LOG_TO_PAGE&&u.writeToPage(e,r),!window.console)return;if(window.console[e]||(e="log"),!window.console[e])return;window.console[e].apply(window.console,r)}catch(n){}},debug:function(){u.logLevel("debug",arguments)},info:function(){u.logLevel("info",arguments)},warn:function(){u.logLevel("warn",arguments)},error:function(){u.logLevel("error",arguments)}}},function(e,r,n){"use strict";function t(e){for(var r=A.global.domainMatches,n=Array.isArray(r),t=0,r=n?r:r[Symbol.iterator]();;){var o;if(n){if(t>=r.length)break;o=r[t++]}else{if(t=r.next(),t.done)break;o=t.value}var i=o;if(i.win===e)return i.match}var a=void 0;try{a=P.util.getDomain(window)===P.util.getDomain(e)}catch(s){a=!1}return A.global.domainMatches.push({win:e,match:a}),M||(M=setTimeout(function(){A.global.domainMatches=[],M=null},1)),a}function o(e){try{return!e||e.closed?!0:!(!t(e)||!P.util.safeGet(e,"mockclosed"))}catch(r){}return!0}function i(e){if(e)try{return e.opener}catch(r){return}}function a(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(r){return}}function s(e){var r=[];try{for(;e.parent!==e;)r.push(e.parent),e=e.parent}catch(n){}return r}function u(e,r){if(!e||!r)return!1;var n=a(r);return n?n===e:-1!==s(r).indexOf(e)}function c(e){var r=[],n=void 0;try{n=e.frames}catch(t){n=e}var o=void 0;try{o=n.length}catch(t){}if(0===o)return r;if(o){for(var i=0;o>i;i++){var a=void 0;try{a=n[i]}catch(t){continue}r.push(a)}return r}for(var s=0;100>s;s++){var u=void 0;try{u=n[s]}catch(t){return r}if(!u)return r;r.push(u)}return r}function d(e){for(var r=[],n=c(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var s=d(a),u=Array.isArray(s),f=0,s=u?s:s[Symbol.iterator]();;){var l;if(u){if(f>=s.length)break;l=s[f++]}else{if(f=s.next(),f.done)break;l=f.value}var w=l;r.push(w)}}return r}function f(e){var r=d(e);r.push(e);for(var n=s(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var u=c(a),f=Array.isArray(u),l=0,u=f?u:u[Symbol.iterator]();;){var w;if(f){if(l>=u.length)break;w=u[l++]}else{if(l=u.next(),l.done)break;w=l.value}var p=w;-1===r.indexOf(p)&&r.push(p)}}return r}function l(e){if(e){try{if(e.top)return e.top}catch(r){}if(a(e)===e)return e;try{if(u(window,e))return window.top}catch(r){}try{if(u(e,window))return window.top}catch(r){}for(var n=d(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var s=i;try{if(s.top)return s.top}catch(r){}if(a(s)===s)return s}}}function w(e,r){for(var n=c(e),o=n,i=Array.isArray(o),a=0,o=i?o:o[Symbol.iterator]();;){var s;if(i){if(a>=o.length)break;s=o[a++]}else{if(a=o.next(),a.done)break;s=a.value}var u=s;try{if(t(u)&&u.name===r)return u}catch(d){}}try{if(0!==n.indexOf(e.frames[r]))return e.frames[r]}catch(d){}try{if(0!==n.indexOf(e[r]))return e[r]}catch(d){}}function p(e,r){var n=a(r);if(n)return n===e;for(var t=c(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var s;if(o){if(i>=t.length)break;s=t[i++]}else{if(i=t.next(),i.done)break;s=i.value}var u=s;if(u===r)return!0}return!1}function m(e,r){return e===i(r)}function v(e){e=e||window;var r=i(e);if(r)return r;var n=a(e);return n?n:void 0}function h(e,r){var n=v(r);if(n)return n===e;if(r===e)return!1;if(l(r)===r)return!1;for(var t=c(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s===r)return!0}return!1}function S(){return Boolean(i(window))}function O(){return Boolean(a(window))}function g(){return Boolean(!O()&&!S())}function b(){return S()?N.CONSTANTS.WINDOW_TYPES.POPUP:O()?N.CONSTANTS.WINDOW_TYPES.IFRAME:N.CONSTANTS.WINDOW_TYPES.FULLPAGE}function y(e,r){for(var n=e,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}for(var a=i,s=r,u=Array.isArray(s),c=0,s=u?s:s[Symbol.iterator]();;){var d;if(u){if(c>=s.length)break;d=s[c++]}else{if(c=s.next(),c.done)break;d=c.value}var f=d;if(a===f)return!0}}}function E(e,r){var n=l(e),t=l(r);try{if(n&&t)return n===t}catch(o){}var a=f(e),s=f(r);if(y(a,s))return!0;var u=i(n),c=i(t);return u&&y(f(u),s)?!1:c&&y(f(c),a)?!1:void 0}function _(){var e=void 0,r=void 0;try{if("{}"!==JSON.stringify({})&&(e=Object.prototype.toJSON,delete Object.prototype.toJSON),"{}"!==JSON.stringify({}))throw new Error("Can not correctly serialize JSON objects");if("[]"!==JSON.stringify([])&&(r=Array.prototype.toJSON,delete Array.prototype.toJSON),"[]"!==JSON.stringify([]))throw new Error("Can not correctly serialize JSON objects")}catch(n){throw new Error("Can not repair JSON.stringify: "+n.message)}var t=JSON.stringify.apply(this,arguments);try{e&&(Object.prototype.toJSON=e),r&&(Array.prototype.toJSON=r)}catch(n){throw new Error("Can not repair JSON.stringify: "+n.message)}return t}function T(){return JSON.parse.apply(this,arguments)}Object.defineProperty(r,"__esModule",{value:!0}),r.isSameDomain=t,r.isWindowClosed=o,r.getOpener=i,r.getParent=a,r.getParents=s,r.isAncestorParent=u,r.getFrames=c,r.getAllChildFrames=d,r.getAllFramesInWindow=f,r.getTop=l,r.getFrameByName=w,r.isParent=p,r.isOpener=m,r.getAncestor=v,r.isAncestor=h,r.isPopup=S,r.isIframe=O,r.isFullpage=g,r.getWindowType=b,r.isSameTopWindow=E,r.jsonStringify=_,r.jsonParse=T;var P=n(12),A=n(15),N=n(3);A.global.domainMatches=A.global.domainMatches||[];var M=void 0},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.global=void 0;var t=n(3);r.global=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]||{}},function(e,r,n){"use strict";function t(e){return"object"===("undefined"==typeof e?"undefined":u(e))&&null!==e&&e.__type__===c.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,r,n,t){var o=d.util.uniqueID();return p.global.methods[o]={destination:e,domain:r,method:n},{__type__:c.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:t}}function i(e,r,n){return d.util.replaceObject({obj:n},function(n,t){return"function"==typeof n?o(e,r,n,t):void 0}).obj}function a(e,r,n){function t(){var t=Array.prototype.slice.call(arguments);return l.log.debug("Call foreign method",n.__name__,t),(0,f.send)(e,c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:t},{domain:r}).then(function(e){var r=e.data;return l.log.debug("Got foreign method result",n.__name__,r.result),r.result})}return t.__name__=n.__name__,t}function s(e,r,n){return d.util.replaceObject({obj:n},function(n,o){return t(n)?a(e,r,n):void 0}).obj}Object.defineProperty(r,"__esModule",{value:!0}),r.listenForMethods=void 0;var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};r.serializeMethod=o,r.serializeMethods=i,r.deserializeMethod=a,r.deserializeMethods=s;var c=n(3),d=n(12),f=n(1),l=n(13),w=n(9),p=n(15);p.global.methods=p.global.methods||{};r.listenForMethods=d.util.once(function(){(0,f.on)(c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{window:"*",origin:"*"},function(e){var r=e.source,n=e.origin,t=e.data,o=p.global.methods[t.id];if(!o)throw new Error("Could not find method with id: "+t.id);if(o.destination!==r)throw new Error("Method window does not match");if(o.domain&&"*"!==o.domain&&n!==o.domain)throw new Error("Method domain "+o.domain+" does not match origin "+n);return l.log.debug("Call local method",t.name,t.args),w.promise.run(function(){return o.method.apply({source:r,origin:n,data:t},t.args)}).then(function(e){return{result:e,id:t.id,name:t.name}})})})},function(e,r,n){"use strict";function t(){(0,s.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,{window:"*",domain:"*"},function(e){for(var r=e.source,n=(e.data,d.global.readyPromises),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===r)return void a.promise.resolve(r)}d.global.readyPromises.push({win:r,promise:(new c.SyncPromise).resolve(r)})});var e=(0,a.getAncestor)();e&&(0,s.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{},{domain:"*"})["catch"](function(e){u.log.debug(e.stack||e.toString())})}function o(e){for(var r=arguments.length<=1||void 0===arguments[1]?5e3:arguments[1],n=arguments.length<=2||void 0===arguments[2]?"Window":arguments[2],t=d.global.readyPromises,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s.win===e)return s.promise}var u=new c.SyncPromise;return d.global.readyPromises.push({win:e,promise:u}),setTimeout(function(){return u.reject(new Error(n+" did not load after "+r+"ms"))},r),u}Object.defineProperty(r,"__esModule",{value:!0}),r.initOnReady=t,r.onWindowReady=o;var i=n(3),a=n(14),s=n(1),u=n(13),c=n(10),d=n(15);d.global.readyPromises=d.global.readyPromises||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(19);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})})},function(e,r,n){"use strict";function t(e,r){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP&&(0,i.isSameTopWindow)(e,r)===!1)throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}Object.defineProperty(r,"__esModule",{value:!0}),r.emulateIERestrictions=t;var o=n(3),i=n(8)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){return"string"==typeof e?"*"===e||r===e:"[object RegExp]"===Object.prototype.toString.call(e)?r.match(e):Array.isArray(e)?-1!==e.indexOf(r):!1}Object.defineProperty(r,"__esModule",{value:!0}),r.RECEIVE_MESSAGE_TYPES=void 0;var i,a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},s=n(3),u=n(8),c=n(21),d=n(24);r.RECEIVE_MESSAGE_TYPES=(i={},t(i,s.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Ack origin "+r+" does not match domain "+t.domain);t.ack=!0}),t(i,s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,r,n){function t(t){return n.fireAndForget||(0,u.isWindowClosed)(e)?u.promise.Promise.resolve():(0,c.sendMessage)(e,a({target:n.originalSource,hash:n.hash,name:n.name},t),r)}var i=(0,d.getRequestListener)(n.name,e,r);return u.promise.Promise.all([t({type:s.CONSTANTS.POST_MESSAGE_TYPE.ACK}),u.promise.run(function(){if(!i)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(!o(i.domain,r))throw new Error("Request origin "+r+" does not match domain "+i.domain);var t=n.data;return u.promise.deNodeify(i.handler,{source:e,origin:r,data:t})}).then(function(e){return t({type:s.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:s.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return t({type:s.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:s.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})])["catch"](function(e){return i&&i.handleError?i.handleError(e):void u.log.error(e.stack||e.toString())})}),t(i,s.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Response origin "+r+" does not match domain "+t.domain);if(delete d.listeners.response[n.hash],n.ack===s.CONSTANTS.POST_MESSAGE_ACK.ERROR)return t.respond(new Error(n.error));if(n.ack===s.CONSTANTS.POST_MESSAGE_ACK.SUCCESS){var i=n.data||n.response;return t.respond(null,{source:e,origin:r,data:i})}}),i)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],t=u.util.uniqueID(),o=(0,u.getWindowType)(),i=u.util.getDomain(window);return a({},r,n,{sourceDomain:i,id:r.id||t,windowType:o})}function i(e,r,n){return u.promise.run(function(){r=o(e,r,{data:(0,u.serializeMethods)(e,n,r.data),domain:n});var i=void 0;if(i=-1!==s.POST_MESSAGE_NAMES_LIST.indexOf(r.name)||r.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===r.ack?"error":"info",u.log.logLevel(i,["\n\n ","#send",r.type.replace(/^postrobot_message_/,""),"::",r.name,"::",n||"*","\n\n",r]),s.CONFIG.MOCK_MODE)return delete r.target,window[s.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:(0,u.jsonStringify)(r,0,2)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",r);var a=[],d=(0,u.jsonStringify)(t({},s.CONSTANTS.WINDOW_PROPS.POSTROBOT,r),0,2);return u.promise.map(Object.keys(c.SEND_MESSAGE_STRATEGIES),function(r){return u.promise.run(function(){if(!s.CONFIG.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return c.SEND_MESSAGE_STRATEGIES[r](e,d,n)}).then(function(){return a.push(r+": success"),!0},function(e){return a.push(r+": "+(e.stack||e.toString())+"\n"),!1})}).then(function(e){var n=u.util.some(e),t=r.type+" "+r.name+" "+(n?"success":"error")+":\n - "+a.join("\n - ")+"\n";if(u.log.debug(t),!n)throw new Error(t); | ||
})})}Object.defineProperty(r,"__esModule",{value:!0});var a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e};r.buildMessage=o,r.sendMessage=i;var s=n(3),u=n(8),c=n(22)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.SEND_MESSAGE_STRATEGIES=void 0;var o,i=n(3),a=n(8),s=n(18),u=n(23);r.SEND_MESSAGE_STRATEGIES=(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,r,n){return(0,s.emulateIERestrictions)(window,e),n&&0===n.indexOf(i.CONSTANTS.MOCK_PROTOCOL)&&(n=e.location.protocol+"//"+e.location.host),n&&0===n.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(n="*"),e.postMessage(r,n)}),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,function(e,r,n){if((0,a.isSameDomain)(e))throw new Error("Post message through bridge disabled between same domain windows");if((0,a.isSameTopWindow)(window,e)!==!1)throw new Error("Can only use bridge to communicate between two different windows, not between frames");return(0,u.sendBridgeMessage)(e,r,n)}),t(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL,function(e,r,n){if(!(0,a.isSameDomain)(e))throw new Error("Post message through global disabled between different domain windows");if((0,a.isSameTopWindow)(window,e)!==!1)throw new Error("Can only use global to communicate between two different windows, not between frames");var t=e[i.CONSTANTS.WINDOW_PROPS.POSTROBOT];if(!t)throw new Error("Can not find postRobot global on foreign window");return t.receiveMessage({source:window,origin:n,data:r})}),o)},function(e,r,n){"use strict";function t(e){e=e||h.util.getDomainFromUrl(e);var r=e.replace(/[^a-zA-Z0-9]+/g,"_"),n=v.CONSTANTS.BRIDGE_NAME_PREFIX+"_"+r;return n}function o(e){try{var r=(0,h.getFrames)(e);if(!r||!r.length)return;for(var n=0;n<r.length;n++)try{var t=r[n];if(t&&t!==window&&(0,h.isSameDomain)(t)&&t[v.CONSTANTS.WINDOW_PROPS.POSTROBOT])return t}catch(o){continue}}catch(o){}}function i(e){var r=(arguments.length<=1||void 0===arguments[1]?v.CONFIG.BRIDGE_TIMEOUT:arguments[1],new h.promise.Promise);S.global.remoteWindows.push({win:e,sendMessagePromise:r})}function a(e,r,n){for(var t=S.global.remoteWindows,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s.win===e){var u=function(t,o,i){if(t!==e)throw new Error("Remote window does not match window");if("*"!==i&&i!==r)throw new Error("Remote domain "+i+" does not match domain "+r);n(o)};return s.sendMessagePromise.resolve(u),void(s.sendMessagePromise=h.promise.Promise.resolve(u))}}throw new Error("Window not found to register sendMessage to")}function s(e,r){for(var n=S.global.remoteWindows,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===e)return a.sendMessagePromise.reject(r)}throw new Error("Window not found on which to reject sendMessage")}function u(e,r,n){var t=(0,h.isOpener)(window,e),o=(0,h.isOpener)(e,window);if(!t&&!o)throw new Error("Can only send messages to and from parent and popup windows");for(var i=S.global.remoteWindows,a=Array.isArray(i),s=0,i=a?i:i[Symbol.iterator]();;){var u;if(a){if(s>=i.length)break;u=i[s++]}else{if(s=i.next(),s.done)break;u=s.value}var c=u;if(c.win===e)return c.sendMessagePromise.then(function(t){return t(e,r,n)})}throw new Error("Window not found to send message to")}function c(e,r){for(var n=Object.keys(S.global.popupWindows),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var a;if(t){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var s=a,u=S.global.popupWindows[s];if(u.win===e){u.domain=h.util.getDomainFromUrl(r),i(e);break}}}function d(e,r){(0,O.on)(v.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{source:e,domain:r},function(e){var n=e.origin,t=e.data;if(n!==r)throw new Error("Domain "+r+" does not match origin "+n);if(!t.name)throw new Error("Register window expected to be passed window name");if(!t.sendMessage)throw new Error("Register window expected to be passed sendMessage method");var o=S.global.popupWindows[t.name];if(!o)throw new Error("Window with name "+t.name+" does not exist, or was not opened by this window");if(!o.domain)throw new Error("We do not have a registered domain for window "+t.name);if(o.domain!==n)throw new Error("Message origin "+n+" does not matched registered window origin "+o.domain);return a(o.win,r,t.sendMessage),{sendMessage:function(e){window&&!window.closed&&(0,g.receiveMessage)({data:e,origin:o.domain,source:o.win})}}})}function f(){var e=(0,h.getOpener)(window);if(e&&!(0,h.isSameDomain)(e)){i(e);var r=o(e);return r?window.name?r[v.CONSTANTS.WINDOW_PROPS.POSTROBOT].openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(e){window&&!window.closed&&(0,g.receiveMessage)({data:e,origin:this.origin,source:this.source})}}).then(function(r){var n=r.source,t=r.origin,o=r.data;if(n!==e)throw new Error("Source does not match opener");a(n,t,o.sendMessage)})["catch"](function(r){throw s(e,r),r}):s(e,new Error("Can not register with opener: window does not have a name")):s(e,new Error("Can not register with opener: no bridge found in opener"))}}function l(e,r){h.log.debug("Opening bridge:",e,r);var n=document.createElement("iframe");return n.setAttribute("name",e),n.setAttribute("id",e),n.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),n.setAttribute("frameborder","0"),n.setAttribute("border","0"),n.setAttribute("scrolling","no"),n.setAttribute("allowTransparency","true"),n.setAttribute("tabindex","-1"),n.setAttribute("hidden","true"),n.setAttribute("title",""),n.setAttribute("role","presentation"),n.src=r,n}function w(e,r){return r=r||h.util.getDomainFromUrl(e),h.util.getDomain()!==r}function p(e,r){return r=r||h.util.getDomainFromUrl(e),S.global.bridges[r]?S.global.bridges[r]:(S.global.bridges[r]=h.promise.run(function(){if(h.util.getDomain()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var n=t(r),o=(0,h.getFrameByName)(window,n);if(o)throw new Error("Frame with name "+n+" already exists on page");var i=l(n,e);return b.then(function(n){return new h.promise.Promise(function(e,r){setTimeout(e,1)}).then(function(){n.appendChild(i);var t=i.contentWindow;return d(t,r),new h.promise.Promise(function(e,r){i.onload=e,i.onerror=r}).then(function(){return(0,h.onWindowReady)(t,v.CONFIG.BRIDGE_TIMEOUT,"Bridge "+e)}).then(function(){return t})})})}),S.global.bridges[r])}Object.defineProperty(r,"__esModule",{value:!0});var m=function(){function e(e,r){var n=[],t=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(t=(a=s.next()).done)&&(n.push(a.value),!r||n.length!==r);t=!0);}catch(u){o=!0,i=u}finally{try{!t&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.sendBridgeMessage=u,r.linkUrl=c,r.openTunnelToOpener=f,r.bridgeRequired=w,r.openBridge=p;var v=n(3),h=n(8),S=n(15),O=n(1),g=n(6),b=new h.promise.Promise(function(e){if(window.document&&window.document.body)return e(window.document.body);var r=setInterval(function(){return window.document&&window.document.body?(clearInterval(r),e(window.document.body)):void 0},10)});S.global.remoteWindows=S.global.remoteWindows||[],S.global.popupWindows=S.global.popupWindows||{};var y=window.open;window.open=function(e,r,n,t){var o=e;if(e&&0===e.indexOf(v.CONSTANTS.MOCK_PROTOCOL)){var a=e.split("|"),s=m(a,2);o=s[0],e=s[1]}o&&(o=h.util.getDomainFromUrl(o));var u=y.call(this,e,r,n,t);return e&&i(u),r&&(S.global.popupWindows[r]={win:u,domain:o}),u},S.global.openTunnelToParent=function(e){var r=e.name,n=e.source,t=e.canary,o=e.sendMessage,i=(0,h.getParent)(window);if(!i)throw new Error("No parent window found to open tunnel to");return(0,O.send)(i,v.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{name:r,sendMessage:function(){if(!(0,h.isWindowClosed)(n)){try{t()}catch(e){return}o.apply(this,arguments)}}},{domain:"*"})},S.global.receiveMessage=function(e){return(0,g.receiveMessage)(e)},S.global.bridges=S.global.bridges||{}},function(e,r,n){"use strict";function t(){s.global.listeners.request=[],s.global.listeners.response=[]}function o(e,r,n){for(var t={},o=s.global.listeners.request,i=Array.isArray(o),a=0,o=i?o:o[Symbol.iterator]();;){var u;if(i){if(a>=o.length)break;u=o[a++]}else{if(a=o.next(),a.done)break;u=a.value}var c=u;if(c.name===e){var d=c.win&&"*"!==c.win,f=c.domain&&"*"!==c.domain,l=d&&c.win===r,w=f&&c.domain===n;d&&f?l&&w&&(t.all=c.options):f?w&&(t.domain=c.options):d?l&&(t.win=c.options):t.name=c.options}}return t.all||t.domain||t.win||t.name}function i(e){for(var r=s.global.listeners.request,n=Array.isArray(r),t=0,r=n?r:r[Symbol.iterator]();;){var o;if(n){if(t>=r.length)break;o=r[t++]}else{if(t=r.next(),t.done)break;o=t.value}var i=o;i.options===e&&s.global.listeners.request.splice(s.global.listeners.request.indexOf(i),1)}}function a(e,r,n,t,a){var s=o(e,r,n);if(s){if(!a){if(r)throw new Error("Request listener already exists for "+e+" on domain "+n+" for specified window: "+(s.win===r));throw new Error("Request listener already exists for "+e+" on domain "+n)}i(s)}u.request.push({name:e,win:r,domain:n,options:t})}Object.defineProperty(r,"__esModule",{value:!0}),r.listeners=void 0,r.resetListeners=t,r.getRequestListener=o,r.removeRequestListener=i,r.addRequestListener=a;var s=n(15);s.global.listeners=s.global.listeners||{request:[],response:[]};var u=r.listeners=s.global.listeners},function(e,r,n){"use strict";function t(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||u.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var r=e.handler;e.handler=u.util.once(function(){return(0,c.removeRequestListener)(e),r.apply(this,arguments)})}();var r=e.override||s.CONFIG.MOCK_MODE;return e.source&&(e.window=e.source),e.domain=e.domain||"*",(0,c.addRequestListener)(e.name,e.window,e.domain,e,r),e.handleError=function(r){e.errorHandler(r)},e.window&&e.errorOnClose&&!function(){var r=u.util.safeInterval(function(){(0,u.isWindowClosed)(e.window)&&(r.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,c.removeRequestListener)(e)}}}function o(e,r,n,o){return"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,t(r)}function i(e,r,n,o){"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,r.once=!0;var i=new u.promise.Promise(function(e,n){r.handler=r.handler||function(r){return e(r)},r.errorHandler=r.errorHandler||n}),a=t(r);return u.util.extend(i,a),i}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return{on:function(r,n,t){return o(r,e,n,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.on=void 0,r.listen=t,r.once=i,r.listener=a;var s=n(3),u=n(8),c=n(6);r.on=o},function(e,r,n){"use strict";function t(){a.CONFIG.MOCK_MODE=!0}function o(){a.CONFIG.MOCK_MODE=!1}function i(){delete window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",s.messageListener)}Object.defineProperty(r,"__esModule",{value:!0}),r.CONSTANTS=r.CONFIG=void 0,r.enableMockMode=t,r.disableMockMode=o;var a=n(3);Object.defineProperty(r,"CONFIG",{enumerable:!0,get:function(){return a.CONFIG}}),Object.defineProperty(r,"CONSTANTS",{enumerable:!0,get:function(){return a.CONSTANTS}}),r.disable=i;var s=n(6)}])}); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("postRobot",[],r):"object"==typeof exports?exports.postRobot=r():e.postRobot=r()}(this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){"use strict";function t(){s.global.initialized||(i.util.listen(window,"message",a.messageListener),(0,u.openTunnelToOpener)(),(0,i.initOnReady)(),(0,i.listenForMethods)()),s.global.initialized=!0}Object.defineProperty(r,"__esModule",{value:!0}),r.Promise=void 0;var o=n(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(8);Object.defineProperty(r,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=n(6),s=n(15),u=n(23);t(),r["default"]=e.exports},function(e,r,n){"use strict";function t(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r["default"]=e,r}Object.defineProperty(r,"__esModule",{value:!0}),r.winutil=r.util=r.linkUrl=r.bridgeRequired=r.openBridge=r.reset=r.parent=void 0;var o=n(2);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(25);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(26);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var s=n(6);Object.defineProperty(r,"reset",{enumerable:!0,get:function(){return s.resetListeners}});var u=n(23);Object.defineProperty(r,"openBridge",{enumerable:!0,get:function(){return u.openBridge}}),Object.defineProperty(r,"bridgeRequired",{enumerable:!0,get:function(){return u.bridgeRequired}}),Object.defineProperty(r,"linkUrl",{enumerable:!0,get:function(){return u.linkUrl}});var c=n(12);Object.defineProperty(r,"util",{enumerable:!0,get:function(){return c.util}});var d=n(14),f=t(d);r.parent=(0,d.getAncestor)(),r.winutil=f},function(e,r,n){"use strict";function t(e){return c.promise.nodeify(new c.promise.Promise(function(r,n){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(s.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var t=document.getElementById(e.window);if(!t)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==t.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=t.contentWindow,!e.window)throw new Error("Expected options.window")}e.domain=e.domain||"*";var o=e.name+"_"+c.util.uniqueID();if(u.listeners.response[o]=e,(0,c.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,t){return e||(i=!0),e?n(e):r(t)},c.promise.run(function(){return(0,c.isAncestor)(window,e.window)?(0,c.onWindowReady)(e.window):void 0}).then(function(){if((0,u.sendMessage)(e.window,{hash:o,type:s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data,fireAndForget:e.fireAndForget},e.domain)["catch"](n),e.fireAndForget)return r();var t=c.util.intervalTimeout(s.CONFIG.ACK_TIMEOUT,100,function(r){return e.ack||(0,c.isWindowClosed)(e.window)?t.cancel():r?void 0:n(new Error("No ack for postMessage "+e.name+" in "+s.CONFIG.ACK_TIMEOUT+"ms"))});e.timeout&&!function(){var r=c.util.intervalTimeout(e.timeout,100,function(t){return i||(0,c.isWindowClosed)(e.window)?r.cancel():t?void 0:n(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}()})["catch"](n)}),e.callback)}function o(e,r,n,o,i){return i||(o||"function"!=typeof n?"function"==typeof o&&(i=o,o={}):(i=n,o={},n={})),o=o||{},o.window=e,o.name=r,o.data=n,o.callback=i,t(o)}function i(e,r,n,t){var i=(0,c.getAncestor)();return i?o(i,e,r,n,t):new c.promise.Promise(function(e,r){return r(new Error("Window does not have a parent"))})}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(!e.window)throw new Error("Expected options.window");return{send:function(r,n,t){return o(e.window,r,n,e,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.send=void 0,r.request=t,r.sendToParent=i,r.client=a;var s=n(3),u=n(6),c=n(8);r.send=o},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(4);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.CONFIG=void 0;var o,i=n(5),a=r.CONFIG={ALLOW_POSTMESSAGE_POPUP:!0,LOG_LEVEL:"info",BRIDGE_TIMEOUT:5e3,ACK_TIMEOUT:1e3,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL,!0),o)};0===window.location.href.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(a.ALLOW_POSTMESSAGE_POPUP=!0)},function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=r.CONSTANTS={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",READY:"postrobot_ready",OPEN_TUNNEL:"postrobot_open_tunnel"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},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__"};r.POST_MESSAGE_NAMES_LIST=Object.keys(n.POST_MESSAGE_NAMES).map(function(e){return n.POST_MESSAGE_NAMES[e]})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(7);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(24);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,r,n){"use strict";function t(e){try{e=(0,s.jsonParse)(e)}catch(r){return}if(e&&(e=e[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],e&&e.type&&d.RECEIVE_MESSAGE_TYPES[e.type]))return e}function o(e){if(!window||window.closed)throw new Error("Message recieved in closed window");try{if(!e.source)return}catch(r){return}var n=e.source,o=e.origin,i=e.data,u=t(i);if(u&&(0!==u.sourceDomain.indexOf(a.CONSTANTS.MOCK_PROTOCOL)&&0!==u.sourceDomain.indexOf(a.CONSTANTS.FILE_PROTOCOL)||(o=u.sourceDomain),-1===c.global.receivedMessages.indexOf(u.id))){c.global.receivedMessages.push(u.id);var f=void 0;if(f=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(u.name)||u.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===u.ack?"error":"info",s.log.logLevel(f,["\n\n ","#receive",u.type.replace(/^postrobot_message_/,""),"::",u.name,"::",o,"\n\n",u]),(0,s.isWindowClosed)(n))return s.log.debug("Source window is closed - can not send "+u.type+" "+u.name);u.data&&(u.data=(0,s.deserializeMethods)(n,o,u.data)),d.RECEIVE_MESSAGE_TYPES[u.type](n,o,u)}}function i(e){try{e.source}catch(r){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,u.emulateIERestrictions)(e.source,window)}catch(r){return}o(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.receiveMessage=o,r.messageListener=i;var a=n(3),s=n(8),u=n(18),c=n(15),d=n(20);c.global.receivedMessages=c.global.receivedMessages||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(9);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})});var o=n(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return a[e]}})});var s=n(16);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return s[e]}})});var u=n(11);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return u[e]}})});var c=n(17);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.promise=r.Promise=void 0;var t=n(10),o=n(11),i=r.Promise=t.SyncPromise,a=r.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(r,n){(0,o.nextTick)(function(){return a.run(e).then(r,n)})})},method:function(e){return function(){var r=this,n=arguments;return i.resolve().then(function(){return e.apply(r,n)})}},nodeify:function(e,r){return r?void e.then(function(e){r(null,e)},function(e){r(e)}):e},deNodeify:function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;r>t;t++)n[t-1]=arguments[t];return new i(function(r,t){try{return n.length<e.length?e.apply(void 0,n.concat([function(e,n){return e?t(e):r(n)}])):a.run(function(){return e.apply(void 0,n)}).then(r,t)}catch(o){return t(o)}})},map:function(e,r){for(var n=[],t=function(t){n.push(a.run(function(){return r(e[t])}))},o=0;o<e.length;o++)t(o);return i.all(n)}}},function(e,r){"use strict";function n(e,r,n){function t(){if(a){if(u)return n(o);if(s)return r(i)}}var o,i,a=!1,s=!1,u=!1;try{e(function(e){i=e,s=!0,t()},function(e){o=e,u=!0,t()})}catch(c){return n(c)}a=!0,t()}function t(e){d.push(e),u=u||setTimeout(o,1)}function o(){u=null;var e=d;d=[];for(var r=0;r<e.length;r++){var n=e[r];n.hasHandlers||(n.handlers.push({onError:function(e){if(!n.hasHandlers){i(e);for(var r=0;r<c.length;r++)c[r](n.value)}}}),n.dispatch())}}function i(e){setTimeout(function(){throw e},1)}function a(e){try{if(!e)return!1;if(window.Window&&e instanceof window.Window)return!1;if(window.constructor&&e instanceof window.constructor)return!1;if(f){var r=f.call(e);if("[object Window]"===r||"[object global]"===r||"[object DOMWindow]"===r)return!1}if(e&&e.then instanceof Function)return!0}catch(n){return!1}return!1}function s(){window.Promise=l}Object.defineProperty(r,"__esModule",{value:!0}),r.patchPromise=s;var u,c=[],d=[],f={}.toString,l=r.SyncPromise=function(e,r){if(this.parent=r,this.resolved=!1,this.rejected=!1,this.hasHandlers=!1,this.handlers=[],t(this),e){var o=this;n(e,function(e){return o.resolve(e)},function(e){return o.reject(e)})}};l.resolve=function(e){return a(e)?e:(new l).resolve(e)},l.reject=function(e){return(new l).reject(e)},l.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},l.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},l.prototype.dispatch=function(){var e=this;if(this.resolved||this.rejected)for(var r=function(){var r=e.handlers.shift();try{e.resolved?n=r.onSuccess?r.onSuccess(e.value):e.value:r.onError?n=r.onError(e.value):t=e.value}catch(o){t=o}if(n===e)throw new Error("Can not return a promise from the the then handler of the same promise");return r.promise?void(t?r.promise.reject(t):a(n)?n.then(function(e){r.promise.resolve(e)},function(e){r.promise.reject(e)}):r.promise.resolve(n)):"continue"};this.handlers.length;){var n,t;r()}},l.prototype.then=function(e,r){var n=new l(null,this);return this.handlers.push({promise:n,onSuccess:e,onError:r}),this.hasHandlers=!0,this.dispatch(),n},l.prototype["catch"]=function(e){return this.then(null,e)},l.prototype["finally"]=function(e){return this.then(function(r){return e(),r},function(r){throw e(),r})},l.all=function(e){for(var r=new l,n=e.length,t=[],o=0;o<e.length;o++){var i=a(e[o])?e[o]:l.resolve(e[o]);i.then(function(e){t[o]=e,n-=1,0===n&&r.resolve(t)},function(e){r.reject(e)})}return r},l.onPossiblyUnhandledException=function(e){c.push(e)}},function(e,r,n){"use strict";function t(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(r,"__esModule",{value:!0}),r.nextTick=t;var o=n(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var r=a.shift();r.call()}})},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.util=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(3),i=r.util={once:function(e){if(!e)return e;var r=!1;return function(){return r?void 0:(r=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,r){try{return!!e[r]}catch(n){return!1}},safeGetProp:function(e,r){try{return e[r]}catch(n){return}},listen:function(e,r,n){return e.addEventListener?e.addEventListener(r,n):e.attachEvent("on"+r,n),{cancel:function(){e.removeEventListener?e.removeEventListener(r,n):e.detachEvent("on"+r,n)}}},apply:function(e,r,n){return"function"==typeof e.apply?e.apply(r,n):e(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9])},find:function(e,r,n){if(!e)return n;for(var t=0;t<e.length;t++)if(r(e[t]))return e[t];return n},map:function(e,r){for(var n=[],t=0;t<e.length;t++)n.push(r(e[t]));return n},some:function(e,r){r=r||Boolean;for(var n=0;n<e.length;n++)if(r(e[n]))return!0;return!1},keys:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(n);return r},values:function(e){var r=[];for(var n in e)e.hasOwnProperty(n)&&r.push(e[n]);return r},getByValue:function(e,r){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r)return n},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var r={};return function(){var n=JSON.stringify(Array.prototype.slice.call(arguments));return r.hasOwnProperty(n)||(r[n]=e.apply(this,arguments)),r[n]}},extend:function(e,r){if(!r)return e;for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n]);return e},each:function(e,r){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(e[n],n);else if("object"===("undefined"==typeof e?"undefined":t(e))&&null!==e)for(var o in e)e.hasOwnProperty(o)&&r(e[o],o)},replaceObject:function(e,r){var n=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(n>=100)throw new Error("Self-referential object passed, or object contained too many layers");var o=Array.isArray(e)?[]:{};return i.each(e,function(e,a){var s=r(e,a);void 0!==s?o[a]=s:"object"===("undefined"==typeof e?"undefined":t(e))&&null!==e?o[a]=i.replaceObject(e,r,n+1):o[a]=e}),o},safeInterval:function(e,r){function n(){t=setTimeout(n,r),e.call()}var t=void 0;return t=setTimeout(n,r),{cancel:function(){clearTimeout(t)}}},intervalTimeout:function(e,r,n){var t=i.safeInterval(function(){e-=r,e=0>=e?0:e,0===e&&t.cancel(),n(e)},r);return t},getDomain:function(e){if(e=e||window,e.mockDomain&&0===e.mockDomain.indexOf(o.CONSTANTS.MOCK_PROTOCOL))return e.mockDomain;if(!e.location.protocol)throw new Error("Can not read window protocol");if(!e.location.host)throw new Error("Can not read window host");return e.location.protocol+"//"+e.location.host},getDomainFromUrl:function(e){var r=void 0;return e.match(/^(https?|mock|file):\/\//)?(r=e,r=r.split("/").slice(0,3).join("/")):this.getDomain()},safeGet:function(e,r){var n=void 0;try{n=e[r]}catch(t){}return n}}},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.log=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(12),i=n(14),a=n(3),s=["debug","info","warn","error"];Function.prototype.bind&&window.console&&"object"===t(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var u=r.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),a.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,r){setTimeout(function(){var n=document.getElementById("postRobotLogs");n||(n=document.createElement("div"),n.id="postRobotLogs",n.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(n));var t=document.createElement("div"),a=(new Date).toString().split(" ")[4],s=o.util.map(r,function(e){if("string"==typeof e)return e;if(!e)return Object.prototype.toString.call(e);var r=void 0;try{r=(0,i.jsonStringify)(e,0,2)}catch(n){r="[object]"}return"\n\n"+r+"\n\n"}).join(" "),u=a+" "+e+" "+s;t.innerHTML=u;var c={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];t.style.cssText="margin-top: 10px; color: "+c+";",n.childNodes.length?n.insertBefore(t,n.childNodes[0]):n.appendChild(t)})},logLevel:function(e,r){try{if(s.indexOf(e)<s.indexOf(a.CONFIG.LOG_LEVEL))return;if(r=Array.prototype.slice.call(r),r.unshift(""+window.location.host+window.location.pathname),r.unshift("::"),r.unshift(""+(0,i.getWindowType)().toLowerCase()),r.unshift("[post-robot]"),a.CONFIG.LOG_TO_PAGE&&u.writeToPage(e,r),!window.console)return;if(window.console[e]||(e="log"),!window.console[e])return;window.console[e].apply(window.console,r)}catch(n){}},debug:function(){u.logLevel("debug",arguments)},info:function(){u.logLevel("info",arguments)},warn:function(){u.logLevel("warn",arguments)},error:function(){u.logLevel("error",arguments)}}},function(e,r,n){"use strict";function t(e){for(var r=M.global.domainMatches,n=Array.isArray(r),t=0,r=n?r:r[Symbol.iterator]();;){var o;if(n){if(t>=r.length)break;o=r[t++]}else{if(t=r.next(),t.done)break;o=t.value}var i=o;if(i.win===e)return i.match}var a=void 0;try{a=N.util.getDomain(window)===N.util.getDomain(e)}catch(s){a=!1}return M.global.domainMatches.push({win:e,match:a}),j||(j=setTimeout(function(){M.global.domainMatches=[],j=null},1)),a}function o(e){try{return!e||e.closed?!0:!(!t(e)||!N.util.safeGet(e,"mockclosed"))}catch(r){}return!0}function i(e){if(e)try{return e.opener}catch(r){return}}function a(e){if(e)try{if(e.parent&&e.parent!==e)return e.parent}catch(r){return}}function s(e){var r=[];try{for(;e.parent!==e;)r.push(e.parent),e=e.parent}catch(n){}return r}function u(e,r){if(!e||!r)return!1;var n=a(r);return n?n===e:-1!==s(r).indexOf(e)}function c(e){var r=[],n=void 0;try{n=e.frames}catch(t){n=e}var o=void 0;try{o=n.length}catch(t){}if(0===o)return r;if(o){for(var i=0;o>i;i++){var a=void 0;try{a=n[i]}catch(t){continue}r.push(a)}return r}for(var s=0;100>s;s++){var u=void 0;try{u=n[s]}catch(t){return r}if(!u)return r;r.push(u)}return r}function d(e){for(var r=[],n=c(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var s=d(a),u=Array.isArray(s),f=0,s=u?s:s[Symbol.iterator]();;){var l;if(u){if(f>=s.length)break;l=s[f++]}else{if(f=s.next(),f.done)break;l=f.value}var w=l;r.push(w)}}return r}function f(e){var r=d(e);r.push(e);for(var n=s(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;r.push(a);for(var u=c(a),f=Array.isArray(u),l=0,u=f?u:u[Symbol.iterator]();;){var w;if(f){if(l>=u.length)break;w=u[l++]}else{if(l=u.next(),l.done)break;w=l.value}var p=w;-1===r.indexOf(p)&&r.push(p)}}return r}function l(e){if(e){try{if(e.top)return e.top}catch(r){}if(a(e)===e)return e;try{if(u(window,e))return window.top}catch(r){}try{if(u(e,window))return window.top}catch(r){}for(var n=d(e),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var s=i;try{if(s.top)return s.top}catch(r){}if(a(s)===s)return s}}}function w(e,r){for(var n=c(e),o=n,i=Array.isArray(o),a=0,o=i?o:o[Symbol.iterator]();;){var s;if(i){if(a>=o.length)break;s=o[a++]}else{if(a=o.next(),a.done)break;s=a.value}var u=s;try{if(t(u)&&u.name===r)return u}catch(d){}}try{if(0!==n.indexOf(e.frames[r]))return e.frames[r]}catch(d){}try{if(0!==n.indexOf(e[r]))return e[r]}catch(d){}}function p(e,r){var n=void 0;if(n=w(e,r))return n;for(var t=S(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(n=w(s,r))return n}for(var u=c(e),d=Array.isArray(u),f=0,u=d?u:u[Symbol.iterator]();;){var l;if(d){if(f>=u.length)break;l=u[f++]}else{if(f=u.next(),f.done)break;l=f.value}var p=l;if(n=w(p,r))return n}}function m(e,r){var n=a(r);if(n)return n===e;for(var t=c(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var s;if(o){if(i>=t.length)break;s=t[i++]}else{if(i=t.next(),i.done)break;s=i.value}var u=s;if(u===r)return!0}return!1}function v(e,r){return e===i(r)}function h(e){e=e||window;var r=i(e);if(r)return r;var n=a(e);return n?n:void 0}function S(e){for(var r=[],n=e;n;)n=h(n),n&&r.push(n);return r}function O(e,r){var n=h(r);if(n)return n===e;if(r===e)return!1;if(l(r)===r)return!1;for(var t=c(e),o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s===r)return!0}return!1}function g(){return Boolean(i(window))}function b(){return Boolean(a(window))}function y(){return Boolean(!b()&&!g())}function E(){return g()?C.CONSTANTS.WINDOW_TYPES.POPUP:b()?C.CONSTANTS.WINDOW_TYPES.IFRAME:C.CONSTANTS.WINDOW_TYPES.FULLPAGE}function _(e,r){for(var n=e,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}for(var a=i,s=r,u=Array.isArray(s),c=0,s=u?s:s[Symbol.iterator]();;){var d;if(u){if(c>=s.length)break;d=s[c++]}else{if(c=s.next(),c.done)break;d=c.value}var f=d;if(a===f)return!0}}}function T(e,r){var n=l(e),t=l(r);try{if(n&&t)return n===t}catch(o){}var a=f(e),s=f(r);if(_(a,s))return!0;var u=i(n),c=i(t);return u&&_(f(u),s)?!1:c&&_(f(c),a)?!1:void 0}function A(){var e=void 0,r=void 0;try{if("{}"!==JSON.stringify({})&&(e=Object.prototype.toJSON,delete Object.prototype.toJSON),"{}"!==JSON.stringify({}))throw new Error("Can not correctly serialize JSON objects");if("[]"!==JSON.stringify([])&&(r=Array.prototype.toJSON,delete Array.prototype.toJSON),"[]"!==JSON.stringify([]))throw new Error("Can not correctly serialize JSON objects")}catch(n){throw new Error("Can not repair JSON.stringify: "+n.message)}var t=JSON.stringify.apply(this,arguments);try{e&&(Object.prototype.toJSON=e),r&&(Array.prototype.toJSON=r)}catch(n){throw new Error("Can not repair JSON.stringify: "+n.message)}return t}function P(){return JSON.parse.apply(this,arguments)}Object.defineProperty(r,"__esModule",{value:!0}),r.isSameDomain=t,r.isWindowClosed=o,r.getOpener=i,r.getParent=a,r.getParents=s,r.isAncestorParent=u,r.getFrames=c,r.getAllChildFrames=d,r.getAllFramesInWindow=f,r.getTop=l,r.getFrameByName=w,r.findFrameByName=p,r.isParent=m,r.isOpener=v,r.getAncestor=h,r.getAncestors=S,r.isAncestor=O,r.isPopup=g,r.isIframe=b,r.isFullpage=y,r.getWindowType=E,r.isSameTopWindow=T,r.jsonStringify=A,r.jsonParse=P;var N=n(12),M=n(15),C=n(3);M.global.domainMatches=M.global.domainMatches||[];var j=void 0},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.global=void 0;var t=n(3);r.global=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]=window[t.CONSTANTS.WINDOW_PROPS.POSTROBOT]||{}},function(e,r,n){"use strict";function t(e){return"object"===("undefined"==typeof e?"undefined":u(e))&&null!==e&&e.__type__===c.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,r,n,t){var o=d.util.uniqueID();return p.global.methods[o]={destination:e,domain:r,method:n},{__type__:c.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:o,__name__:t}}function i(e,r,n){return d.util.replaceObject({obj:n},function(n,t){return"function"==typeof n?o(e,r,n,t):void 0}).obj}function a(e,r,n){function t(){var t=Array.prototype.slice.call(arguments);return l.log.debug("Call foreign method",n.__name__,t),(0,f.send)(e,c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:t},{domain:r}).then(function(e){var r=e.data;return l.log.debug("Got foreign method result",n.__name__,r.result),r.result})}return t.__name__=n.__name__,t}function s(e,r,n){return d.util.replaceObject({obj:n},function(n,o){return t(n)?a(e,r,n):void 0}).obj}Object.defineProperty(r,"__esModule",{value:!0}),r.listenForMethods=void 0;var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};r.serializeMethod=o,r.serializeMethods=i,r.deserializeMethod=a,r.deserializeMethods=s;var c=n(3),d=n(12),f=n(1),l=n(13),w=n(9),p=n(15);p.global.methods=p.global.methods||{};r.listenForMethods=d.util.once(function(){(0,f.on)(c.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{window:"*",origin:"*"},function(e){var r=e.source,n=e.origin,t=e.data,o=p.global.methods[t.id];if(!o)throw new Error("Could not find method with id: "+t.id);if(o.destination!==r)throw new Error("Method window does not match");if(o.domain&&"*"!==o.domain&&n!==o.domain)throw new Error("Method domain "+o.domain+" does not match origin "+n);return l.log.debug("Call local method",t.name,t.args),w.promise.run(function(){return o.method.apply({source:r,origin:n,data:t},t.args)}).then(function(e){return{result:e,id:t.id,name:t.name}})})})},function(e,r,n){"use strict";function t(){(0,s.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,{window:"*",domain:"*"},function(e){for(var r=e.source,n=(e.data,d.global.readyPromises),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===r)return void a.promise.resolve(r)}d.global.readyPromises.push({win:r,promise:(new c.SyncPromise).resolve(r)})});var e=(0,a.getAncestor)();e&&(0,s.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{},{domain:"*"})["catch"](function(e){u.log.debug(e.stack||e.toString())})}function o(e){for(var r=arguments.length<=1||void 0===arguments[1]?5e3:arguments[1],n=arguments.length<=2||void 0===arguments[2]?"Window":arguments[2],t=d.global.readyPromises,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s.win===e)return s.promise}var u=new c.SyncPromise;return d.global.readyPromises.push({win:e,promise:u}),setTimeout(function(){return u.reject(new Error(n+" did not load after "+r+"ms"))},r),u}Object.defineProperty(r,"__esModule",{value:!0}),r.initOnReady=t,r.onWindowReady=o;var i=n(3),a=n(14),s=n(1),u=n(13),c=n(10),d=n(15);d.global.readyPromises=d.global.readyPromises||[]},function(e,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var t=n(19);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(r,e,{enumerable:!0,get:function(){return t[e]}})})},function(e,r,n){"use strict";function t(e,r){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP&&(0,i.isSameTopWindow)(e,r)===!1)throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}Object.defineProperty(r,"__esModule",{value:!0}),r.emulateIERestrictions=t;var o=n(3),i=n(8)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){return"string"==typeof e?"*"===e||r===e:"[object RegExp]"===Object.prototype.toString.call(e)?r.match(e):Array.isArray(e)?-1!==e.indexOf(r):!1}Object.defineProperty(r,"__esModule",{value:!0}),r.RECEIVE_MESSAGE_TYPES=void 0;var i,a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},s=n(3),u=n(8),c=n(21),d=n(24);r.RECEIVE_MESSAGE_TYPES=(i={},t(i,s.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Ack origin "+r+" does not match domain "+t.domain);t.ack=!0}),t(i,s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,r,n){function t(t){return n.fireAndForget||(0,u.isWindowClosed)(e)?u.promise.Promise.resolve():(0,c.sendMessage)(e,a({target:n.originalSource,hash:n.hash,name:n.name},t),r)}var i=(0,d.getRequestListener)(n.name,e,r);return u.promise.Promise.all([t({type:s.CONSTANTS.POST_MESSAGE_TYPE.ACK}),u.promise.run(function(){if(!i)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(!o(i.domain,r))throw new Error("Request origin "+r+" does not match domain "+i.domain);var t=n.data;return u.promise.deNodeify(i.handler,{source:e,origin:r,data:t})}).then(function(e){return t({type:s.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:s.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return t({type:s.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:s.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})])["catch"](function(e){return i&&i.handleError?i.handleError(e):void u.log.error(e.stack||e.toString())})}),t(i,s.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,r,n){var t=d.listeners.response[n.hash];if(!t)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);if(!o(t.domain,r))throw new Error("Response origin "+r+" does not match domain "+t.domain);if(delete d.listeners.response[n.hash],n.ack===s.CONSTANTS.POST_MESSAGE_ACK.ERROR)return t.respond(new Error(n.error));if(n.ack===s.CONSTANTS.POST_MESSAGE_ACK.SUCCESS){var i=n.data||n.response;return t.respond(null,{source:e,origin:r,data:i})}}),i)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function o(e,r){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],t=u.util.uniqueID(),o=(0,u.getWindowType)(),i=u.util.getDomain(window);return a({},r,n,{sourceDomain:i,id:r.id||t,windowType:o})}function i(e,r,n){return u.promise.run(function(){r=o(e,r,{data:(0,u.serializeMethods)(e,n,r.data),domain:n});var i=void 0;if(i=-1!==s.POST_MESSAGE_NAMES_LIST.indexOf(r.name)||r.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK?"debug":"error"===r.ack?"error":"info",u.log.logLevel(i,["\n\n ","#send",r.type.replace(/^postrobot_message_/,""),"::",r.name,"::",n||"*","\n\n",r]),s.CONFIG.MOCK_MODE)return delete r.target,window[s.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:(0,u.jsonStringify)(r,0,2)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",r);var a=[],d=(0,u.jsonStringify)(t({},s.CONSTANTS.WINDOW_PROPS.POSTROBOT,r),0,2); | ||
return u.promise.map(Object.keys(c.SEND_MESSAGE_STRATEGIES),function(r){return u.promise.run(function(){if(!s.CONFIG.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return c.SEND_MESSAGE_STRATEGIES[r](e,d,n)}).then(function(){return a.push(r+": success"),!0},function(e){return a.push(r+": "+(e.stack||e.toString())+"\n"),!1})}).then(function(e){var n=u.util.some(e),t=r.type+" "+r.name+" "+(n?"success":"error")+":\n - "+a.join("\n - ")+"\n";if(u.log.debug(t),!n)throw new Error(t)})})}Object.defineProperty(r,"__esModule",{value:!0});var a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e};r.buildMessage=o,r.sendMessage=i;var s=n(3),u=n(8),c=n(22)},function(e,r,n){"use strict";function t(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}Object.defineProperty(r,"__esModule",{value:!0}),r.SEND_MESSAGE_STRATEGIES=void 0;var o,i=n(3),a=n(8),s=n(18),u=n(23);r.SEND_MESSAGE_STRATEGIES=(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,r,n){return(0,s.emulateIERestrictions)(window,e),n&&0===n.indexOf(i.CONSTANTS.MOCK_PROTOCOL)&&(n=e.location.protocol+"//"+e.location.host),n&&0===n.indexOf(i.CONSTANTS.FILE_PROTOCOL)&&(n="*"),e.postMessage(r,n)}),t(o,i.CONSTANTS.SEND_STRATEGIES.BRIDGE,function(e,r,n){if((0,a.isSameDomain)(e))throw new Error("Post message through bridge disabled between same domain windows");if((0,a.isSameTopWindow)(window,e)!==!1)throw new Error("Can only use bridge to communicate between two different windows, not between frames");return(0,u.sendBridgeMessage)(e,r,n)}),t(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL,function(e,r,n){if(!(0,a.isSameDomain)(e))throw new Error("Post message through global disabled between different domain windows");if((0,a.isSameTopWindow)(window,e)!==!1)throw new Error("Can only use global to communicate between two different windows, not between frames");var t=e[i.CONSTANTS.WINDOW_PROPS.POSTROBOT];if(!t)throw new Error("Can not find postRobot global on foreign window");return t.receiveMessage({source:window,origin:n,data:r})}),o)},function(e,r,n){"use strict";function t(e){e=e||h.util.getDomainFromUrl(e);var r=e.replace(/[^a-zA-Z0-9]+/g,"_"),n=v.CONSTANTS.BRIDGE_NAME_PREFIX+"_"+r;return n}function o(e){try{var r=(0,h.getFrames)(e);if(!r||!r.length)return;for(var n=0;n<r.length;n++)try{var t=r[n];if(t&&t!==window&&(0,h.isSameDomain)(t)&&t[v.CONSTANTS.WINDOW_PROPS.POSTROBOT])return t}catch(o){continue}}catch(o){}}function i(e){var r=(arguments.length<=1||void 0===arguments[1]?v.CONFIG.BRIDGE_TIMEOUT:arguments[1],new h.promise.Promise);S.global.remoteWindows.push({win:e,sendMessagePromise:r})}function a(e,r,n){for(var t=S.global.remoteWindows,o=Array.isArray(t),i=0,t=o?t:t[Symbol.iterator]();;){var a;if(o){if(i>=t.length)break;a=t[i++]}else{if(i=t.next(),i.done)break;a=i.value}var s=a;if(s.win===e){var u=function(t,o,i){if(t!==e)throw new Error("Remote window does not match window");if("*"!==i&&i!==r)throw new Error("Remote domain "+i+" does not match domain "+r);n(o)};return s.sendMessagePromise.resolve(u),void(s.sendMessagePromise=h.promise.Promise.resolve(u))}}throw new Error("Window not found to register sendMessage to")}function s(e,r){for(var n=S.global.remoteWindows,t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var i;if(t){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i;if(a.win===e)return a.sendMessagePromise.reject(r)}throw new Error("Window not found on which to reject sendMessage")}function u(e,r,n){var t=(0,h.isOpener)(window,e),o=(0,h.isOpener)(e,window);if(!t&&!o)throw new Error("Can only send messages to and from parent and popup windows");for(var i=S.global.remoteWindows,a=Array.isArray(i),s=0,i=a?i:i[Symbol.iterator]();;){var u;if(a){if(s>=i.length)break;u=i[s++]}else{if(s=i.next(),s.done)break;u=s.value}var c=u;if(c.win===e)return c.sendMessagePromise.then(function(t){return t(e,r,n)})}throw new Error("Window not found to send message to")}function c(e,r){for(var n=Object.keys(S.global.popupWindows),t=Array.isArray(n),o=0,n=t?n:n[Symbol.iterator]();;){var a;if(t){if(o>=n.length)break;a=n[o++]}else{if(o=n.next(),o.done)break;a=o.value}var s=a,u=S.global.popupWindows[s];if(u.win===e){u.domain=h.util.getDomainFromUrl(r),i(e);break}}}function d(e,r){(0,O.on)(v.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{source:e,domain:r},function(e){var n=e.origin,t=e.data;if(n!==r)throw new Error("Domain "+r+" does not match origin "+n);if(!t.name)throw new Error("Register window expected to be passed window name");if(!t.sendMessage)throw new Error("Register window expected to be passed sendMessage method");var o=S.global.popupWindows[t.name];if(!o)throw new Error("Window with name "+t.name+" does not exist, or was not opened by this window");if(!o.domain)throw new Error("We do not have a registered domain for window "+t.name);if(o.domain!==n)throw new Error("Message origin "+n+" does not matched registered window origin "+o.domain);return a(o.win,r,t.sendMessage),{sendMessage:function(e){window&&!window.closed&&(0,g.receiveMessage)({data:e,origin:o.domain,source:o.win})}}})}function f(){var e=(0,h.getOpener)(window);if(e&&!(0,h.isSameDomain)(e)){i(e);var r=o(e);return r?window.name?r[v.CONSTANTS.WINDOW_PROPS.POSTROBOT].openTunnelToParent({name:window.name,source:window,canary:function(){},sendMessage:function(e){window&&!window.closed&&(0,g.receiveMessage)({data:e,origin:this.origin,source:this.source})}}).then(function(r){var n=r.source,t=r.origin,o=r.data;if(n!==e)throw new Error("Source does not match opener");a(n,t,o.sendMessage)})["catch"](function(r){throw s(e,r),r}):s(e,new Error("Can not register with opener: window does not have a name")):s(e,new Error("Can not register with opener: no bridge found in opener"))}}function l(e,r){h.log.debug("Opening bridge:",e,r);var n=document.createElement("iframe");return n.setAttribute("name",e),n.setAttribute("id",e),n.setAttribute("style","display: none; margin: 0; padding: 0; border: 0px none; overflow: hidden;"),n.setAttribute("frameborder","0"),n.setAttribute("border","0"),n.setAttribute("scrolling","no"),n.setAttribute("allowTransparency","true"),n.setAttribute("tabindex","-1"),n.setAttribute("hidden","true"),n.setAttribute("title",""),n.setAttribute("role","presentation"),n.src=r,n}function w(e,r){return r=r||h.util.getDomainFromUrl(e),h.util.getDomain()!==r}function p(e,r){return r=r||h.util.getDomainFromUrl(e),S.global.bridges[r]?S.global.bridges[r]:(S.global.bridges[r]=h.promise.run(function(){if(h.util.getDomain()===r)throw new Error("Can not open bridge on the same domain as current domain: "+r);var n=t(r),o=(0,h.getFrameByName)(window,n);if(o)throw new Error("Frame with name "+n+" already exists on page");var i=l(n,e);return b.then(function(n){return new h.promise.Promise(function(e,r){setTimeout(e,1)}).then(function(){n.appendChild(i);var t=i.contentWindow;return d(t,r),new h.promise.Promise(function(e,r){i.onload=e,i.onerror=r}).then(function(){return(0,h.onWindowReady)(t,v.CONFIG.BRIDGE_TIMEOUT,"Bridge "+e)}).then(function(){return t})})})}),S.global.bridges[r])}Object.defineProperty(r,"__esModule",{value:!0});var m=function(){function e(e,r){var n=[],t=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(t=(a=s.next()).done)&&(n.push(a.value),!r||n.length!==r);t=!0);}catch(u){o=!0,i=u}finally{try{!t&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.sendBridgeMessage=u,r.linkUrl=c,r.openTunnelToOpener=f,r.bridgeRequired=w,r.openBridge=p;var v=n(3),h=n(8),S=n(15),O=n(1),g=n(6),b=new h.promise.Promise(function(e){if(window.document&&window.document.body)return e(window.document.body);var r=setInterval(function(){return window.document&&window.document.body?(clearInterval(r),e(window.document.body)):void 0},10)});S.global.remoteWindows=S.global.remoteWindows||[],S.global.popupWindows=S.global.popupWindows||{};var y=window.open;window.open=function(e,r,n,t){var o=e;if(e&&0===e.indexOf(v.CONSTANTS.MOCK_PROTOCOL)){var a=e.split("|"),s=m(a,2);o=s[0],e=s[1]}o&&(o=h.util.getDomainFromUrl(o));var u=y.call(this,e,r,n,t);return e&&i(u),r&&(S.global.popupWindows[r]={win:u,domain:o}),u},S.global.openTunnelToParent=function(e){var r=e.name,n=e.source,t=e.canary,o=e.sendMessage,i=(0,h.getParent)(window);if(!i)throw new Error("No parent window found to open tunnel to");return(0,O.send)(i,v.CONSTANTS.POST_MESSAGE_NAMES.OPEN_TUNNEL,{name:r,sendMessage:function(){if(!(0,h.isWindowClosed)(n)){try{t()}catch(e){return}o.apply(this,arguments)}}},{domain:"*"})},S.global.receiveMessage=function(e){return(0,g.receiveMessage)(e)},S.global.bridges=S.global.bridges||{}},function(e,r,n){"use strict";function t(){u.global.listeners.request=[],u.global.listeners.response=[]}function o(e,r){return"string"==typeof e?"*"===e||r===e:"[object RegExp]"===Object.prototype.toString.call(e)?r.match(e):Array.isArray(e)?-1!==e.indexOf(r):!1}function i(e,r,n){for(var t={},i=u.global.listeners.request,a=Array.isArray(i),s=0,i=a?i:i[Symbol.iterator]();;){var c;if(a){if(s>=i.length)break;c=i[s++]}else{if(s=i.next(),s.done)break;c=s.value}var d=c;if(d.name===e){var f=d.win&&"*"!==d.win,l=d.domain&&"*"!==d.domain,w=f&&d.win===r,p=l&&o(d.domain,n);f&&l?w&&p&&(t.all=d.options):l?p&&(t.domain=d.options):f?w&&(t.win=d.options):t.name=d.options}}return t.all||t.domain||t.win||t.name}function a(e){for(var r=u.global.listeners.request,n=Array.isArray(r),t=0,r=n?r:r[Symbol.iterator]();;){var o;if(n){if(t>=r.length)break;o=r[t++]}else{if(t=r.next(),t.done)break;o=t.value}var i=o;i.options===e&&u.global.listeners.request.splice(u.global.listeners.request.indexOf(i),1)}}function s(e,r,n,t,o){var s=i(e,r,n);if(s){if(!o){if(r)throw new Error("Request listener already exists for "+e+" on domain "+n+" for specified window: "+(s.win===r));throw new Error("Request listener already exists for "+e+" on domain "+n)}a(s)}c.request.push({name:e,win:r,domain:n,options:t})}Object.defineProperty(r,"__esModule",{value:!0}),r.listeners=void 0,r.resetListeners=t,r.getRequestListener=i,r.removeRequestListener=a,r.addRequestListener=s;var u=n(15);u.global.listeners=u.global.listeners||{request:[],response:[]};var c=r.listeners=u.global.listeners},function(e,r,n){"use strict";function t(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||u.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var r=e.handler;e.handler=u.util.once(function(){return(0,c.removeRequestListener)(e),r.apply(this,arguments)})}();var r=e.override||s.CONFIG.MOCK_MODE;return e.source&&(e.window=e.source),e.domain=e.domain||"*",(0,c.addRequestListener)(e.name,e.window,e.domain,e,r),e.handleError=function(r){e.errorHandler(r)},e.window&&e.errorOnClose&&!function(){var r=u.util.safeInterval(function(){(0,u.isWindowClosed)(e.window)&&(r.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,c.removeRequestListener)(e)}}}function o(e,r,n,o){return"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,t(r)}function i(e,r,n,o){"function"==typeof r&&(o=n,n=r,r={}),r=r||{},r.name=e,r.handler=n||r.handler,r.errorHandler=o||r.errorHandler,r.once=!0;var i=new u.promise.Promise(function(e,n){r.handler=r.handler||function(r){return e(r)},r.errorHandler=r.errorHandler||n}),a=t(r);return u.util.extend(i,a),i}function a(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];return{on:function(r,n,t){return o(r,e,n,t)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.on=void 0,r.listen=t,r.once=i,r.listener=a;var s=n(3),u=n(8),c=n(6);r.on=o},function(e,r,n){"use strict";function t(){a.CONFIG.MOCK_MODE=!0}function o(){a.CONFIG.MOCK_MODE=!1}function i(){delete window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT],window.removeEventListener("message",s.messageListener)}Object.defineProperty(r,"__esModule",{value:!0}),r.CONSTANTS=r.CONFIG=void 0,r.enableMockMode=t,r.disableMockMode=o;var a=n(3);Object.defineProperty(r,"CONFIG",{enumerable:!0,get:function(){return a.CONFIG}}),Object.defineProperty(r,"CONSTANTS",{enumerable:!0,get:function(){return a.CONSTANTS}}),r.disable=i;var s=n(6)}])}); |
{ | ||
"name": "post-robot", | ||
"version": "4.0.16", | ||
"version": "4.0.17", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "dist/post-robot.min.js", |
@@ -16,2 +16,19 @@ | ||
function matchDomain(domain, origin) { | ||
if (typeof domain === 'string') { | ||
return domain === '*' || origin === domain; | ||
} | ||
if (Object.prototype.toString.call(domain) === '[object RegExp]') { | ||
return origin.match(domain); | ||
} | ||
if (Array.isArray(domain)) { | ||
return domain.indexOf(origin) !== -1; | ||
} | ||
return false; | ||
} | ||
export function getRequestListener(name, win, domain) { | ||
@@ -31,3 +48,3 @@ | ||
let matchedWin = (specifiedWin && requestListener.win === win); | ||
let matchedDomain = (specifiedDomain && requestListener.domain === domain); | ||
let matchedDomain = (specifiedDomain && matchDomain(requestListener.domain, domain)); | ||
@@ -34,0 +51,0 @@ if (specifiedWin && specifiedDomain) { |
@@ -309,2 +309,29 @@ | ||
export function findFrameByName(win, name) { | ||
let frame; | ||
frame = getFrameByName(win, name); | ||
if (frame) { | ||
return frame; | ||
} | ||
for (let ancestor of getAncestors(win)) { | ||
frame = getFrameByName(ancestor, name); | ||
if (frame) { | ||
return frame; | ||
} | ||
} | ||
for (let childFrame of getFrames(win)) { | ||
frame = getFrameByName(childFrame, name); | ||
if (frame) { | ||
return frame; | ||
} | ||
} | ||
} | ||
export function isParent(win, frame) { | ||
@@ -348,3 +375,19 @@ | ||
export function getAncestors(win) { | ||
let results = []; | ||
let ancestor = win; | ||
while (ancestor) { | ||
ancestor = getAncestor(ancestor); | ||
if (ancestor) { | ||
results.push(ancestor); | ||
} | ||
} | ||
return results; | ||
} | ||
export function isAncestor(parent, child) { | ||
@@ -351,0 +394,0 @@ |
Sorry, the diff of this file is too big to display
247986
5370