; (self.AMP=self.AMP||[]).push({m:1,v:"2409191841000",n:"amp-auto-ads",ev:"0.1",l:!0,f:function(t,n){(()=>{function n(t,n,i){return n in t?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t}function i(t,n){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),i.push.apply(i,e)}return i}function e(t){for(var e=1;e=0&&t.indexOf(n,i)==i}var{hasOwnProperty:a,toString:u}=Object.prototype;function c(t){const n=Object.create(null);return t&&Object.assign(n,t),n}function h(t,n,i,e,s,r,o,a,u,c,h){return t}function l(t){return JSON.parse(t)}var d=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function f(t,n=""){try{return decodeURIComponent(t)}catch(t){return n}}function g(t){const n=c();if(!t)return n;let i;for(;i=d.exec(t);){const t=f(i[1],i[1]),e=i[2]?f(i[2].replace(/\+/g," "),i[2]):"";n[t]=e}return n}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var p=self.__AMP_LOG;function m(t){return p.user||(p.user=A()),function(t,n){return n&&n.ownerDocument.defaultView!=t}(p.user.win,t)?p.userForEmbed||(p.userForEmbed=A()):p.user}function A(t){return function(t,n){throw new Error("failed to call initLogConstructor")}()}function b(t,n,i,e,s,r,o,a,u,c,h){return t}function v(t,n,i,e,s,r,o,a,u,c,h){return m().assert(t,n,i,e,s,r,o,a,u,c,h)}function w(t){return(t.ownerDocument||t).defaultView}function P(t,n){return C(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),n)}function _(t,n){return C(function(t){const n=y(t);return n.isSingleDoc()?n.win:n}(y(t)),n)}function y(t){return t.nodeType?(n=w(t),P(n,"ampdoc")).getAmpDoc(t):t;var n}function C(t,n){b(function(t,n){const i=t.__AMP_SERVICES&&t.__AMP_SERVICES[n];return!(!i||!i.ctor)}(t,n));const i=function(t){let n=t.__AMP_SERVICES;return n||(n=t.__AMP_SERVICES={}),n}(t)[n];return i.obj||(b(i.ctor),b(i.context),i.obj=new i.ctor(i.context),b(i.obj),i.context=null,i.resolve&&i.resolve(i.obj)),i.obj}var M="__AMP__EXPERIMENT_TOGGLES";function E(t,n,i){return function(t,n){for(const i in n)t.setAttribute(i,n[i]);return t}(t.createElement(n),i)}var S=t=>_(t,"documentInfo").get(),R=t=>P(t,"extensions"),I=t=>_(t,"viewport");function k(t,n,i,e){const s=[],r=e&&null!=e.value&&""!==e.value?encodeURIComponent(e.name)+"="+encodeURIComponent(String(e.value)):null;let o=i-t.length;r&&(o-=r.length+1);const a=Object.keys(n);for(let t=0;to){const t=c.substr(0,o-u.length-1).replace(/%\w?$/,"");t&&s.push(u+t),r&&s.push(r);break}s.push(u+c),o-=h}return s.length?t+"?"+s.join("&"):t}var x,O={"type":!0,"rtc-config":!0,"layout":!0,"height":!0,"width":!0,"sticky":!0,"json":!0},j="attributes";function T(t,n){return t[n]?(i=t[n],"[object Object]"!==u.call(i)||r(t[n])?{}:function(t){const n={};for(const i in t){if(!O[i]&&!i.startsWith("data-"))continue;const e=typeof t[i];"number"!=e&&"string"!=e&&"boolean"!=e||(n[i]=String(t[i]))}return n}(t[n])):{};var i}function V(t,n){return x||(x=self.document.createElement("a")),function(t,n,i){return t.href="",new URL(n,t.href)}(x,t)}function D(t){if(h(function(t){const n=t.tagName;return n.startsWith("AMP-")&&!("AMP-STICKY-AD-TOP-PADDING"==n||"AMP-BODY"==n)}(t)),t.createdCallback)return Promise.resolve(t);if(!t.__AMP_UPG_PRM){const n=new class{constructor(){this.promise=new Promise(((t,n)=>{this.resolve=t,this.reject=n}))}};t.__AMP_UPG_PRM=n.promise,t.__AMP_UPG_RES=n.resolve}const n=t.__AMP_UPG_PRM;return h(n),n}function N(t){return(n=w(t),P(n,"vsync")).measurePromise((()=>function(t){const n=t.ownerDocument.body;let i=0,e=0;for(let s=t;s&&s!=n;s=s.offsetParent)i+=s.offsetLeft,e+=s.offsetTop;const{offsetHeight:s,offsetWidth:r}=t;return function(t,n,i,e){return{left:t,top:n,width:i,height:e,bottom:n+e,right:t+i,x:t,y:n}}(i,e,r,s)}(t)));var n}var U=["AMP-SIDEBAR","AMP-APP-BANNER"],z={};function q(t,n){const i=n.placements;if(!i)return[];const s=[];return i.forEach((n=>{!function(t,n,i){const s=z[n.pos];if(!s)return;const r=n.anchor;if(!r)return;const o=L(t.getRootNode(),r);if(!o.length)return;let a;if(n.style){const t=parseInt(n.style.top_m,10),i=parseInt(n.style.bot_m,10);(t||i)&&(a={top:t||void 0,bottom:i||void 0})}o.forEach((r=>{if(!function(t,n){const i=1==n||4==n?t.parentElement:t;if(!i)return!1;const e=i;return!U.some((t=>{return n=t,!!e.closest(n);var n}))}(r,n.pos))return;const o=T(n,j);i.push(new class{constructor(t,n,i,e,s,r){this.ampdoc=t,this.Ua=_(n,"mutator"),this.rA=n,this.aA=i,this.uA=e,this.cA=s,this.hA=r,this.lA=null,this.Mi=0}getAdElement(){return this.lA}getEstimatedPosition(){return N(this.rA).then((t=>this.dA(t)))}dA(t){switch(this.aA){case 1:case 2:return t.top;case 3:case 4:return t.bottom;default:throw new Error("Unknown position")}}placeAd(t,n,i,e){return this.getEstimatedPosition().then((s=>this.ampdoc.win.scrollY>s?(this.Mi=0,this.Mi):i.isTooNearAnAd(s).then((i=>{if(i)return this.Mi=3,this.Mi;const s=e&&this.fA(this.rA);return this.lA=s?this.gA(t):this.pA(t,n.width),this.uA(this.rA,this.getAdElement()),s?D(this.getAdElement()).then((()=>this.getAdElement().build())).then((()=>{const t=!this.getAdElement().classList.contains("i-amphtml-layout-awaiting-size");return this.Mi=t?2:1,this.Mi})):this.mA(n).then((t=>D(this.getAdElement()).then((()=>this.getAdElement().build())).then((()=>this.Ua.requestChangeSize(this.getAdElement(),t.height,t.width,t.margins))).then((()=>(this.Mi=2,this.Mi)),(()=>(this.Mi=1,this.Mi)))))}))))}mA(t){return Promise.resolve({height:t.height||250,margins:this.hA})}pA(t,n){const i=e(e({"layout":n?"fixed":"fixed-height","height":"0","width":n||"auto","class":"i-amphtml-layout-awaiting-size"},t),this.cA);return E(this.ampdoc.win.document,"amp-ad",i)}gA(t){const n=e(e({"width":"100vw","height":"0","layout":"fixed","class":"i-amphtml-layout-awaiting-size","data-auto-format":"rspv","data-full-width":""},t),this.cA);return E(this.ampdoc.win.document,"amp-ad",n)}fA(t){return I(t).getSize().width<488}}(t,r,n.pos,s,o,a))}))}(t,n,s)})),s}function L(t,n){const i=n.selector;if(!i)return[];let e=[].slice.call(function(t,n){return t.querySelectorAll(function(t,n){return t.replace(/^|,/g,"$&:scope ")}(n))}(t.documentElement||t,i));const s=n.min_c||0;if(s>0&&(e=e.filter((t=>t.textContent.length>=s))),"number"==typeof n.index||!n.all){const t=e[n.index||0];e=t?[t]:[]}if(0==e.length)return[];if(n.sub){let t=[];return e.forEach((i=>{t=t.concat(L(i,n.sub))})),t}return e}function $(t,n){if(!t)return null;const i=parseFloat(t);return isNaN(i)||i<0?null:o(t,"px")?i:o(t,"vp")?i*n:null}z[1]=(t,n)=>{t.parentNode.insertBefore(n,t)},z[4]=(t,n)=>{t.parentNode.insertBefore(n,t.nextSibling)},z[2]=(t,n)=>{t.insertBefore(n,t.firstChild)},z[3]=(t,n)=>{t.appendChild(n)};var F="amp-auto-ads",G=class extends t.BaseElement{buildCallback(){const t=this.element.getAttribute("type");if(v(t,"Missing type attribute"),this.AA=function(t,n){return"adsense"==t?new class{constructor(t){this.bA=t}isEnabled(){return!0}isResponsiveEnabled(){return!0}getConfigUrl(){const t=S(this.bA),n=V(t.canonicalUrl).hostname,i=w(this.bA);return k("//pagead2.googlesyndication.com/getconfig/ama",{"client":this.bA.getAttribute("data-ad-client"),"plah":n,"ama_t":"amp","url":t.canonicalUrl,"debug_experiment_id":(/(?:#|,)deid=([\d,]+)/i.exec(i.location.hash)||[])[1]||null},4096)}filterConfig(t){return w(this.bA).adsbygoogle&&t.stickyAdAttributes&&(t.stickyAdAttributes["data-no-fill"]="true"),t}getAttributes(){const t={"type":"adsense","data-ad-client":this.bA.getAttribute("data-ad-client")},n=this.bA.getAttribute("data-ad-host"),i=this.bA.getAttribute("data-ad-host-channel");return n&&(t["data-ad-host"]=n,i&&(t["data-ad-host-channel"]=i)),t}getDefaultAdConstraints(){const t=I(this.bA).getSize().height;return{initialMinSpacing:t,subsequentMinSpacing:[{adCount:3,spacing:2*t},{adCount:6,spacing:3*t}],maxAdCount:8}}getSizing(){return{}}}(n):"alright"==t?new class{constructor(t){this.bA=t}isEnabled(){return!0}isResponsiveEnabled(){return!1}getConfigUrl(){const t=S(this.bA);return k("//analytics.alright.network/amp/",{"p":this.bA.getAttribute("data-publisher-id"),"t":this.bA.getAttribute("data-page-type"),"c":this.bA.getAttribute("data-content-category")||"","u":t.canonicalUrl,"w":window.screen.width,"h":window.screen.height},4096)}filterConfig(t){return t}getAttributes(){return{"width":300,"height":250,"layout":"responsive","data-multi-size-validation":"false","type":"doubleclick","data-ad":"alright"}}getDefaultAdConstraints(){const t=I(this.bA).getSize().height;return{initialMinSpacing:t,subsequentMinSpacing:[{adCount:3,spacing:2*t},{adCount:6,spacing:3*t}],maxAdCount:8}}getSizing(){return{width:300,height:250}}}(n):"denakop"==t?new class{constructor(t){this.bA=t}isEnabled(t){return!0}isResponsiveEnabled(){return!0}getConfigUrl(){const t=S(this.bA),n=this.bA.getAttribute("data-account-id");return n?k("https://v3.denakop.com/ad-request",{"a":n,"v":"amp","u":t.canonicalUrl},4096):k("//v2.denakop.com/ad-request/amp",{"p":this.bA.getAttribute("data-publisher-id"),"t":this.bA.getAttribute("data-tag-id"),"u":t.canonicalUrl},4096)}filterConfig(t){return t}getAttributes(){return{"data-multi-size-validation":"false","type":"doubleclick","data-ad":"denakop","style":"position:relative !important"}}getDefaultAdConstraints(){const t=I(this.bA).getSize().height;return{initialMinSpacing:t,subsequentMinSpacing:[{adCount:4,spacing:2*t},{adCount:8,spacing:3*t}],maxAdCount:20}}getSizing(){return{}}}(n):"doubleclick"==t?new class{constructor(t){this.bA=t}isEnabled(t){return!0}isResponsiveEnabled(){return!1}getConfigUrl(){const t=S(this.bA),n=V(t.canonicalUrl).hostname;return k("//pagead2.googlesyndication.com/getconfig/ama",{"client":this.bA.getAttribute("data-ad-legacy-client"),"plah":n,"ama_t":"amp","url":t.canonicalUrl},4096)}filterConfig(t){return t}getAttributes(){return{"type":"doubleclick","data-slot":this.bA.getAttribute("data-slot"),"json":this.bA.getAttribute("data-json")}}getDefaultAdConstraints(){const t=I(this.bA).getSize().height;return{initialMinSpacing:t,subsequentMinSpacing:[{adCount:3,spacing:2*t},{adCount:6,spacing:3*t}],maxAdCount:8}}getSizing(){const t=function(t,n){try{return l(t)}catch(t){return null}}(this.bA.getAttribute("data-experiment"));return t?{height:t.height?Number(t.height):250,width:t.width?Number(t.width):void 0}:{}}}(n):"firstimpression.io"==t?new class{constructor(t){this.bA=t,this.pvid64=0}isEnabled(t){return!0}isResponsiveEnabled(){return!1}getConfigUrl(){let t=0;S(this.bA).pageViewId64.then((t=>{this.pvid64=t}));const{hash:n,host:i,pathname:e,search:s}=window.location,r=Object.assign(g(n),g(s)),o=S(this.bA),a=e.match(/amp\/fi\/(\d+)\//);null!=a&&2==a.length&&(t=a[1]);const u=r.fi_reveal,c=r.fi_demand,h=r.fi_geo,l=r.disable_fi,d=r.fi_cdnhost||(t?i:"cdn.firstimpression.io"),f=r.fi_cdnpath||(t?"/amp-preview.php":"/delivery/amp.php"),p=this.bA.getAttribute("data-website-id"),m=this.bA.getAttribute("data-targeting"),A={"id":p,"url":o.canonicalUrl,"w":window.screen.width,"h":window.screen.height};return m&&(A.targeting=m),void 0!==u&&(A.fi_reveal=u),void 0!==c&&(A.fi_demand=c),h&&(A.fi_geo=h),l&&(A.disable_fi=l),t&&(A.preview_id=t),k("https://"+d+f,A,4096)}filterConfig(t){return t}getAttributes(){return{"type":"firstimpression","data-pvid64":this.pvid64}}getDefaultAdConstraints(){const t=I(this.bA).getSize().height;return{initialMinSpacing:t,subsequentMinSpacing:[{adCount:3,spacing:2*t},{adCount:6,spacing:3*t}],maxAdCount:8}}getSizing(){return{height:1}}}(n):"premiumads"==t?new class{constructor(t){this.bA=t}isEnabled(){return!0}isResponsiveEnabled(){return!1}getConfigUrl(){const t=this.bA.dataset;return k(`${t.host||"https://tags.premiumads.com.br"}/autoads/${t.publisher}`,t.json?{"json":t.json}:{},4096)}filterConfig(t){return t}getAttributes(){const t=this.bA.dataset;return{"type":"doubleclick","data-ad":"premiumads","json":t.json||"","layout":t.layout||"fixed","style":t.style||"margin: 0 auto; position: relative !important; display: block !important;"}}getDefaultAdConstraints(){const t=I(this.bA).getSize().height;return{initialMinSpacing:t,subsequentMinSpacing:[{adCount:3,spacing:2*t},{adCount:6,spacing:3*t}],maxAdCount:8}}getSizing(){return{}}}(n):"wunderkind"==t?new class{constructor(t){this.bA=t}isEnabled(t){const n=this.bA.getAttribute("data-website-id");return!(!n||!n.match(/^[0-9]+$/))}isResponsiveEnabled(){return!0}getConfigUrl(){const t=S(this.bA);return k("https://api.bounceexchange.com/bounce/amp",{"w_id":this.bA.getAttribute("data-website-id"),"calling_url":t.sourceUrl},4096)}filterConfig(t){return t}getAttributes(){return{"type":"wunderkind","data-ad":"wunderkind","layout":"responsive","height":"75vw","width":"100vw"}}getDefaultAdConstraints(){return{initialMinSpacing:I(this.bA).getSize().height,subsequentMinSpacing:[],maxAdCount:10}}getSizing(){return{}}}(n):null}(t,this.element),v(this.AA,"No AdNetworkConfig for type: "+t),!this.AA.isEnabled(this.win))return;const n=this.getAmpDoc();R(this.win).installExtensionForDoc(n,"amp-ad"),this.vA=this.getAmpDoc().whenFirstVisible().then((()=>this.AA.filterConfig(this.wA(this.AA.getConfigUrl())))),this.PA()||this._A()}isLayoutSupported(){return!0}layoutCallback(){return this.PA()?this._A():s||(s=Promise.resolve(void 0))}wA(t){return(n=this.win,P(n,"xhr")).fetchJson(t,{mode:"cors",method:"GET",credentials:"omit"}).then((t=>t.json())).catch((t=>(this.user().error(F,"amp-auto-ads config xhr failed: "+t),null)));var n}PA(){return function(t,n){const i=function(t){var n,i,s,o,a;if(t[M])return t[M];t[M]=c();const u=t[M];h(u);const d=e(e({},null!==(n=t.AMP_CONFIG)&&void 0!==n?n:{}),null!==(i=t.AMP_EXP)&&void 0!==i?i:l((null===(s=t.__AMP_EXP)||void 0===s?void 0:s.textContent)||"{}"));for(const t in d){const n=d[t];"number"==typeof n&&n>=0&&n<=1&&(u[t]=Math.random(){if(!n)return;const i=n.noConfigReason;i&&this.user().warn(F,i);const s=q(t,n),r=e(e({},this.AA.getAttributes()),T(n,j)),o=this.AA.getSizing(),a=function(t,n){const i=n.adConstraints;if(!i)return null;const e=I(t).getHeight(),s=$(i.initialMinSpacing,e);if(null==s)return null;const r=(i.subsequentMinSpacing||[]).map((t=>{const n=t.adCount;if(null==n)return null;const i=$(t.spacing,e);return null==i?null:{adCount:n,spacing:i}}));return-1!=r.indexOf(null)||null==i.maxAdCount?null:{initialMinSpacing:s,subsequentMinSpacing:r,maxAdCount:i.maxAdCount}}(t,n)||this.AA.getDefaultAdConstraints(),u=new class{constructor(t,n){this.yA=t,this.CA=n.initialMinSpacing,this.MA=n.subsequentMinSpacing.slice(0).sort(((t,n)=>t.adCount-n.adCount)),this.EA=n.maxAdCount,this.SA=this.RA()}addAd(t){this.yA.push(t),this.SA=this.RA()}getAdCount(){return this.yA.length}isMaxAdCountReached(){return this.getAdCount()>=this.EA}isTooNearAnAd(t){return this.IA(t,0)}IA(t,n){return n>=this.yA.length?Promise.resolve(!1):this.kA(t,this.yA[n]).then((i=>it>=n.top&&t<=n.bottom?0:Math.min(Math.abs(t-n.top),Math.abs(t-n.bottom))))}RA(){const t=this.getAdCount();let n=this.CA;for(let i=0;i!t.parentElement||"AMP-STICKY-AD"!=t.parentElement.tagName))}(t),a);new class{constructor(t,n,i,e,s=!1){this.xA=t.slice(0),this.OA=n,this.jA=i,this.TA=e,this.VA=0,this.DA=s}run(){return this.TA.isMaxAdCountReached()?(t=()=>this.NA(),new Promise((n=>{n(t())}))):this.UA().then((t=>t?this.run():this.NA()));var t}NA(){return{adsPlaced:this.VA,totalAdsOnPage:this.TA.getAdCount()}}UA(){const t=this.xA.shift();return t?t.placeAd(this.OA,this.jA,this.TA,this.DA).then((n=>2==n?(this.TA.addAd(t.getAdElement()),this.VA++,!0):this.UA())):Promise.resolve(!1)}}(s,r,o,u,this.AA.isResponsiveEnabled()).run();const c=e(e({},r),T(n,"stickyAdAttributes"));new class{constructor(t,n,i){this.ampdoc=t,this.OA=n,this.zA=i}run(){return this.qA()?Promise.resolve(!1):this.LA()?("top"===this.OA.sticky?(R(this.ampdoc.win).installExtensionForDoc(this.ampdoc,"amp-ad","0.1"),this.$A()):(R(this.ampdoc.win).installExtensionForDoc(this.ampdoc,"amp-sticky-ad","1.0"),this.FA()),Promise.resolve(!0)):Promise.resolve(!1)}qA(){return!!this.ampdoc.getRootNode().querySelector("amp-sticky-ad, amp-ad[sticky]")}LA(){return m().assertArray(this.zA.optInStatus||[]).includes(2)}$A(){const t=I(this.ampdoc).getWidth(),n=e(e({},this.OA),{},{"width":String(t),"height":this.OA.height||"100"}),i=E(this.ampdoc.win.document,"amp-ad",n),s=this.ampdoc.getBody();s.insertBefore(i,s.firstChild)}FA(){const t=this.OA,n=I(this.ampdoc).getWidth(),i=e(e({},t),{},{"width":String(n),"height":t.height||"100"});delete i.sticky;const s=this.ampdoc.win.document,r=E(s,"amp-ad",i),o=E(s,"amp-sticky-ad",{"layout":"nodisplay"});o.appendChild(r);const a=this.ampdoc.getBody();a.insertBefore(o,a.firstChild)}}(t,c,n).run()}))}};t.registerElement(F,G)})(); /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}}); //# sourceMappingURL=amp-auto-ads-0.1.mjs.map