(self.AMP=self.AMP||[]).push({n:"amp-iframe",v:"1533253141109",f:(function(AMP,_){ var l;function aa(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a;for(var d in b)if(Object.defineProperties){var e=Object.getOwnPropertyDescriptor(b,d);e&&Object.defineProperty(a,d,e)}else a[d]=b[d]}function q(a,b){b=void 0===b?"":b;try{return decodeURIComponent(a)}catch(c){return b}};var ba=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;self.log=self.log||{user:null,dev:null,userForEmbed:null};var t=self.log;function u(){if(!t.user)throw Error("failed to call initLogConstructor");return t.user}function v(){if(t.dev)return t.dev;throw Error("failed to call initLogConstructor");};function x(){var a,b=Object.create(null);a&&Object.assign(b,a);return b}function y(a){return a||{}};function z(a,b){var c=a.length-b.length;return 0<=c&&a.indexOf(b,c)==c};var A=self.AMP_CONFIG||{},ca={thirdParty:A.thirdPartyUrl||"https://3p.ampproject.net",thirdPartyFrameHost:A.thirdPartyFrameHost||"ampproject.net",thirdPartyFrameRegex:("string"==typeof A.thirdPartyFrameRegex?new RegExp(A.thirdPartyFrameRegex):A.thirdPartyFrameRegex)||/^d-\d+\.ampproject\.net$/,cdn:A.cdnUrl||"https://cdn.ampproject.org",cdnProxyRegex:("string"==typeof A.cdnProxyRegex?new RegExp(A.cdnProxyRegex):A.cdnProxyRegex)||/^https:\/\/([a-zA-Z0-9_-]+\.)?cdn\.ampproject\.org$/,localhostRegex:/^https?:\/\/localhost(:\d+)?$/, errorReporting:A.errorReportingUrl||"https://amp-error-reporting.appspot.com/r",localDev:A.localDev||!1};function B(a){this.Z=a;this.K=this.T=0;this.C=Object.create(null)}B.prototype.has=function(a){return!!this.C[a]};B.prototype.get=function(a){var b=this.C[a];if(b)return b.access=++this.K,b.payload};B.prototype.put=function(a,b){this.has(a)||this.T++;this.C[a]={payload:b,access:this.K};if(!(this.T<=this.Z)){v().warn("lru-cache","Trimming LRU cache");a=this.C;var c=this.K+1,d,e;for(e in a){var f=a[e].access;f=e&&(c[d]=Math.random() src. Must start with https://. Found %s",a);var n=e.parse(d);u().assert(!wa(c,"allow-same-origin")||f!=n.origin&&"data:"!=h,"Origin of must not be equal to container %sif allow-same-origin is set. See https://github.com/ampproject/amphtml/blob/master/spec/amp-iframe-origin-policy.md for details.", a);u().assert(!(z(g,"."+ca.thirdPartyFrameHost)||z(g,".ampproject.org")),"amp-iframe does not allow embedding of frames from ampproject.*: %s",b);return b} function xa(a){var b=a.element.getLayoutBox(),c=Math.min(600,.75*a.getViewport().getSize().height);u().assert(b.top>=c," elements must be positioned outside the first 75% of the viewport or 600px from the top (whichever is smaller): %s Current position %s. Min: %sPositioning rules don't apply for iframes that use `placeholder`.See https://github.com/ampproject/amphtml/blob/master/extensions/amp-iframe/amp-iframe.md#iframe-with-placeholder for details.",a.element,b.top,c)} function wa(a,b){var c=new RegExp("\\s"+b+"\\s","i");return c.test(" "+a+" ")}function ya(a,b){if(b){a=F(a.element,"url").parse(b);var c=a.hash;"data:"==a.protocol||c&&"#"!=c||(a=b.indexOf("#"),b=(-1==a?b:b.substring(0,a))+"#amp=1");return b}} l.firstAttachedCallback=function(){this.o=this.element.getAttribute("sandbox");var a;if(!(a=ya(this,this.element.getAttribute("src")))){a=this.element.getAttribute("srcdoc");var b=this.o;if(a){u().assert(!(" "+b+" ").match(/\s+allow-same-origin\s+/i),"allow-same-origin is not allowed with the srcdoc attribute %s.",this.element);if("undefined"!==typeof TextEncoder)b=(new TextEncoder("utf-8")).encode(a);else{a=unescape(encodeURIComponent(a));for(var b=new Uint8Array(a.length),c=0;cb||e>c)&&20>=b-f&&20>=c-e){b=!0;break a}}b=!1}this.O=b;b=this.element;c=b.getLayoutBox();this.B=10=d)}this.X=b;this.l&& this.l.fire()};function Aa(a){if(a.h){var b=a.getViewport().getLayoutRect(a.h),c=a.getLayoutBox();a.M=O(b,-c.left,-c.top)}}l.getIntersectionElementLayoutBox=function(){if(!this.h)return AMP.BaseElement.prototype.getIntersectionElementLayoutBox.call(this);var a=this.getLayoutBox();this.M||Aa(this);return O(this.M,a.left,a.top)}; l.layoutCallback=function(){var a=this;u().assert(!this.X,"amp-iframe is not used for displaying fixed ad. Please use amp-sticky-ad and amp-ad instead.");this.F||xa(this);this.G&&u().assert(this.getOverflowElement(),"Overflow element must be defined for resizable frames: %s",this.element);if(!this.iframeSrc)return Promise.resolve();if(this.B&&(X++,1 when its "sandbox" attribute contains "allow-top-navigation".');}; function Ca(a,b,c){if(a.G)if(100>b)a.user().error("amp-iframe","Ignoring embed-size request because the resize height is less than 100px. If you are using amp-iframe to display ads, consider using amp-ad instead.",a.element);else{var d,e;b=parseInt(b,10);isNaN(b)||(d=Math.max(b+(a.element.offsetHeight-a.h.offsetHeight),b));c=parseInt(c,10);isNaN(c)||(e=Math.max(c+(a.element.offsetWidth-a.h.offsetWidth),c));void 0!==d||void 0!==e?a.attemptChangeSize(d,e).then(function(){void 0!==d&&a.element.setAttribute("height", d);void 0!==e&&a.element.setAttribute("width",e)},function(){}):a.user().error("amp-iframe","Ignoring embed-size request because no width or height value is provided",a.element)}else a.user().error("amp-iframe","Ignoring embed-size request because this iframe is not resizable",a.element)} function za(a){if(da(a.win)){var b=a.element,c=b.getAttribute("src");c&&(a.m=F(b,"url").parse(c).origin);a.registerAction("postMessage",function(b){a.m?a.h.contentWindow.postMessage(b.args,a.m):u().error("amp-iframe",'"postMessage" action is only allowed with "src"attribute with an origin.')},100);if(a.m){var d=10,e=0,f=function(b){if(b.source===a.h.contentWindow)if(b.origin!==a.m)u().error("amp-iframe",'"message" received from unexpected origin: '+b.origin+". Only allowed from: "+a.m);else{var c; a.getAmpDoc().getRootNode().activeElement!==a.h?c=!1:(c=a.win.document.createElement("audio"),c.play(),c=c.paused?!1:!0);if(c){var g=b.data,k;try{k=JSON.parse(JSON.stringify(g))}catch(p){u().error("amp-iframe",'Data from "message" event must be JSON.');return}var m=a.win;b=y({data:k});c={detail:b};Object.assign(c,void 0);"function"==typeof m.CustomEvent?b=new m.CustomEvent("amp-iframe:message",c):(m=m.document.createEvent("CustomEvent"),m.initCustomEvent("amp-iframe:message",!!c.bubbles,!!c.cancelable, b),b=m);var r=F(a.getAmpDoc(),"action");r.trigger(a.element,"message",b,100)}else e++,u().error("amp-iframe",'"message" event may only be triggered from a user gesture.'),e>=d&&(u().error("amp-iframe",'Too many non-gesture-triggered "message" events; detaching event listener.'),a.win.removeEventListener("message",f))}};a.win.addEventListener("message",f)}}}l.ba=function(a){this.m=a};function Ba(a,b){var c=b||"";a.setAttribute("sandbox",c)}(function(a){a.registerElement("amp-iframe",Y)})(self.AMP); })}); //# sourceMappingURL=amp-iframe-0.1.js.map