;
(self.AMP=self.AMP||[]).push({m:1,v:"2605071401000",n:"amp-subscriptions",ev:"0.1",l:!0,f:function(t,s){(()=>{var s;function i(){return s||(s=Promise.resolve(void 0))}var e=class{constructor(){this.promise=new Promise(((t,s)=>{this.resolve=t,this.reject=s}))}},{hasOwnProperty:n,toString:r}=Object.prototype;function o(t){const s=Object.create(null);return t&&Object.assign(s,t),s}function h(t,s){return n.call(t,s)}function c(t,s){if("."==s)return t;const i=s.split(".");let e=t;for(const t of i){if(!(t&&e&&void 0!==e[t]&&"object"==typeof e&&h(e,t))){e=void 0;break}e=e[t]}return e}var{isArray:u}=Array;function l(t){return JSON.parse(t)}function a(t,s){try{return l(t)}catch(t){return null==s||s(t),null}}function f(t,s,i,e,n,r,o,h,c,u,l){return t}function d(t){return(t.ownerDocument||t).defaultView}function p(t,s,i){return function(t,s){for(const i in s)t.setAttribute(i,s[i]);return t}(t.createElement(s),i)}var m=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function g(t,s=""){try{return decodeURIComponent(t)}catch(t){return s}}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var b=self.__AMP_LOG;function _(t,s){throw new Error("failed to call initLogConstructor")}function P(t){return b.user||(b.user=A()),function(t,s){return s&&s.ownerDocument.defaultView!=t}(b.user.win,t)?b.userForEmbed||(b.userForEmbed=A()):b.user}function A(t){return _()}function y(){return b.dev||(b.dev=_())}function v(t,s,i,e,n,r,o,h,c,u,l){return t}function E(t,s,i,e,n,r,o,h,c,u,l){return P().assert(t,s,i,e,n,r,o,h,c,u,l)}function w(t,s){return M(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),s)}function R(t,s){return M(k(S(t)),s)}function I(t,s){return function(t,s){const i=V(t,s);if(i)return i;const n=x(t);return n[s]=function(){const t=new e,{promise:s,reject:i,resolve:n}=t;return s.catch((()=>{})),{obj:null,promise:s,resolve:n,reject:i,context:null,ctor:null}}(),n[s].promise}(k(t),s)}function T(t,s){return V(k(t),s)}function S(t){return t.nodeType?(s=d(t),w(s,"ampdoc")).getAmpDoc(t):t;var s}function k(t){const s=S(t);return s.isSingleDoc()?s.win:s}function M(t,s){v(O(t,s));const i=x(t)[s];return i.obj||(v(i.ctor),v(i.context),i.obj=new i.ctor(i.context),v(i.obj),i.context=null,i.resolve&&i.resolve(i.obj)),i.obj}function V(t,s){const i=x(t)[s];return i?i.promise?i.promise:(M(t,s),i.promise=Promise.resolve(i.obj)):null}function x(t){let s=t.__AMP_SERVICES;return s||(s=t.__AMP_SERVICES={}),s}function O(t,s){const i=t.__AMP_SERVICES&&t.__AMP_SERVICES[s];return!(!i||!i.ctor)}var C=t=>M(t,"timer"),L=t=>R(t,"viewer"),U=t=>R(t,"viewport");function D(t){const s=function(t){return t.readyState}(t);return"loading"!=s&&"uninitialized"!=s}var N=class{constructor(t,s){let i,e,n;const r=t.indexOf(":");-1!=r?(e=t,i=e.substring(0,r),n=e.substring(r+1)):(i=t,e=null,n=null),this.publicationId_=i,this.productId_=e,this.label_=n,this.locked_=s}getPublicationId(){return this.publicationId_}getProductId(){return this.productId_}getLabel(){return this.label_}isLocked(){return this.locked_}};function j(t){console.log.apply(console,arguments)}function F(t,s){let i=t;do{if(i.nextSibling)return!0}while((i=i.parentNode)&&i!=s);return!1}function $(t){const s=Object.getOwnPropertyDescriptor(t,"message");if(s&&s.writable)return t;const{message:i,stack:e}=t,n=new Error(i);for(const s in t)n[s]=t[s];return n.stack=e,n}function z(t){let s=null,i="";for(let t=0;t<arguments.length;t++){const e=arguments[t];e instanceof Error&&!s?s=$(e):(i&&(i+=" "),i+=e)}return s?i&&(s.message=i+": "+s.message):s=new Error(i),s}var K=class{constructor(t=""){this.suffix_=t}prepareError_(t){this.suffix_&&(t.message?-1===t.message.indexOf(this.suffix_)&&(t.message=this.suffix_):t.message=this.suffix_)}createError(t){const s=z.apply(null,Array.prototype.slice.call(arguments));return this.prepareError_(s),s}createExpectedError(t){const s=z.apply(null,Array.prototype.slice.call(arguments));return this.prepareError_(s),s.expected=!0,s}error(t){throw this.createError.apply(this,arguments)}expectedError(t){throw this.createExpectedError.apply(this,arguments)}},G=new K(self.__AMP_TOP?"​​​":"");new K;var B="__SWG-SEEN__",W=["CreativeWork","Article","NewsArticle","Blog","Comment","Course","HowTo","Message","Review","WebPage"],J=new RegExp(W.join("|")),Y=class{constructor(){}checkValue(t,s){return!!t&&this.checkArray(this.toArray_(t),s)}checkString(t,s){return!!t&&this.checkArray(t.split(/\s+/),s)}checkArray(t,s){for(const i of t){const t=i.replace(/^http:\/\/schema.org\//i,"");if(s.includes(t))return!0}return!1}toArray_(t){return Array.isArray(t)?t:[t]}};function H(t,s){const i=t.querySelector(`meta[name="${s}"]`);return i?i.getAttribute("content"):null}function Q(t,s,i){return s in t?Object.defineProperty(t,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[s]=i,t}function Z(t,s){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);s&&(e=e.filter((function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),i.push.apply(i,e)}return i}function X(t){for(var s=1;s<arguments.length;s++){var i=null!=arguments[s]?arguments[s]:{};s%2?Z(Object(i),!0).forEach((function(s){Q(t,s,i[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Z(Object(i)).forEach((function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(i,s))}))}return t}var q="subscriptions-action",tt="started",st={IS_READY_TO_PAY:"isReadyToPay",SUPPORTS_VIEWER:"supportsViewer"},it={};function et(t){if("undefined"!=typeof TextDecoder)return new TextDecoder("utf-8").decode(t);const s=function(t){const s=new Array(t.length);for(let i=0;i<t.length;i++)s[i]=String.fromCharCode(t[i]);return s.join("")}(new Uint8Array(t.buffer||t));return decodeURIComponent(escape(s))}function nt(t){const s=new Uint8Array(t.length);for(let i=0;i<t.length;i++){const e=t.charCodeAt(i);f(e<=255),s[i]=e}return s}function rt(t){return"function"==typeof t.then?t:new Promise(((s,i)=>{t.oncomplete=i=>{s(t.result)},t.onerror=i}))}function ot(t){const s=atob(t),i=s.length,e=new Uint8Array(i);for(let t=0;t<i;t++)e[t]=s.charCodeAt(t);return e}var ht,ct=["Webkit","webkit","Moz","moz","ms","O","o"];function ut(t){const s=t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()));return ct.some((t=>s.startsWith(t+"-")))?`-${s}`:s}function lt(t,s,i){if(s.startsWith("--"))return s;ht||(ht=o());let e=ht[s];if(!e||i){if(e=s,void 0===t[s]){const i=function(t){return t.charAt(0).toUpperCase()+t.slice(1)}(s),n=function(t,s){for(let i=0;i<ct.length;i++){const e=ct[i]+s;if(void 0!==t[e])return e}return""}(t,i);void 0!==t[n]&&(e=n)}i||(ht[s]=e)}return e}function at(t,s){const{style:i}=t;for(const t in s)i.setProperty(ut(lt(i,t)),String(s[t]),"important")}function ft(t,s){void 0===s&&(s=t.hasAttribute("hidden")),s?t.removeAttribute("hidden"):t.setAttribute("hidden","")}var dt,pt,mt="SUBSCRIBER",gt="METERING",bt="UNLOCKED",_t=class t{static empty(s){return new t({source:"",raw:"",service:s,granted:!1})}constructor(t){const{dataObject:s,decryptedDocumentKey:i,grantReason:e="",granted:n=!1,raw:r="",service:o,source:h}=t;this.raw=r,this.source=h,this.service=o,this.granted=n,this.grantReason=e,this.data=s,this.decryptedDocumentKey=i}json(){return{"source":this.source,"service":this.service,"granted":this.granted,"grantReason":this.grantReason,"data":this.data}}jsonForPingback(){return X({"raw":this.raw},this.json())}static parseFromJson(s,i=null){s||(s={});const e=i||JSON.stringify(s),n=s.source||"",r=s.granted||!1,o=s.grantReason,h=s.data||null,c=s.decryptedDocumentKey||null;return new t({source:n,raw:e,service:"",granted:r,grantReason:o,dataObject:h,decryptedDocumentKey:c})}isSubscriber(){return this.granted&&this.grantReason===mt}isFree(){return this.granted&&this.grantReason===bt}},Pt=(()=>self.AMP.config.urls)(),At=new Set(["c","v","a","ad"]),yt=t=>"string"==typeof t?Et(t):t;function vt(t){return t.origin||Et(t.location.href).origin}function Et(t,s){return dt||(dt=self.document.createElement("a")),function(t,s,i){return t.href="",new URL(s,t.href)}(dt,t)}function wt(t,s,i,e){return function(t,s,i){if(!s)return t;const e=t.split("#",2),n=e[0].split("?",2);let r=n[0]+(n[1]?i?`?${s}&${n[1]}`:`?${n[1]}&${s}`:`?${s}`);return r+=e[1]?`#${e[1]}`:"",r}(t,function(t,s){return`${encodeURIComponent(t)}=${encodeURIComponent(s)}`}(s,i),e)}function Rt(t,s,i="source"){var e;return E(null!=t,"%s %s must be available",s,i),E("https:"==(e=yt(e=t)).protocol||"localhost"==e.hostname||"127.0.0.1"==e.hostname||function(t,s){const i=t.length-s.length;return i>=0&&t.indexOf(s,i)==i}(e.hostname,".localhost")||/^\/\//.test(t),'%s %s must start with "https://" or "//" or be relative and served from either https or from localhost. Invalid value: %s',s,i,t),t}function It(t,s,i,e){let n=t,r=i,o=t=>{try{return r(t)}catch(t){var s,i;throw null===(s=(i=self).__AMP_REPORT_ERROR)||void 0===s||s.call(i,t),t}};const h=function(){if(void 0!==pt)return pt;pt=!1;try{const t={get capture(){return pt=!0,!1}};self.addEventListener("test-options",null,t),self.removeEventListener("test-options",null,t)}catch(t){}return pt}(),c=!(null==e||!e.capture);return n.addEventListener(s,o,h?e:c),()=>{null==n||n.removeEventListener(s,o,h?e:c),r=null,n=null,o=null}}function Tt(t){return t.data}function St(t,s,i,e){let n;try{n=t.open(s,i,e)}catch(t){y().error("DOM","Failed to open url on target: ",i,t)}var r,o;return!n&&"_top"!=i&&("number"!=typeof o&&(o=0),o+"noopener".length>(r=e||"").length||-1===r.indexOf("noopener",o))&&(n=t.open(s,"_top")),n}var kt=(()=>self.AMP.config.urls)(),Mt=new RegExp("RETURN_URL");function Vt(t,s){return function(t,s){const i=L(t);return parseInt(t.getParam("dialog"),10)?new xt(i,s):new Ot(t.win,i,s)}(t,s).open()}var xt=class{constructor(t,s){this.viewer=t,this.urlOrPromise=s}getLoginUrl(){let t;return t="string"==typeof this.urlOrPromise?Promise.resolve(this.urlOrPromise):this.urlOrPromise,t.then((t=>Ct(t,"RETURN_URL")))}open(){return this.getLoginUrl().then((t=>this.viewer.sendMessageAwaitResponse("openDialog",{"url":t})))}},Ot=class{constructor(t,s,i){this.win=t,this.viewer=s,this.urlOrPromise=i,this.oe=null,this.oh=null,this.p_t=null,this.__t=null,this.m_t=null,this.A_t=null}open(){return E(!this.oe,"Dialog already opened"),new Promise(((t,s)=>{this.oe=t,this.oh=s,this.P_t()})).then((t=>(this._r(),t)),(t=>{throw this._r(),t}))}_r(){if(this.oe=null,this.oh=null,this.p_t){try{this.p_t.close()}catch(t){}this.p_t=null}this.m_t&&(this.win.clearInterval(this.m_t),this.m_t=null),this.A_t&&(this.A_t(),this.A_t=null)}getLoginUrl(){let t;return t="string"==typeof this.urlOrPromise?Promise.resolve(this.urlOrPromise):this.urlOrPromise,t.then((t=>Ct(t,this.v_t())))}P_t(){const{screen:t}=this.win,s=Math.floor(Math.min(700,.9*t.width)),e=Math.floor(Math.min(450,.9*t.height)),n=`height=${e},width=${s},left=${Math.floor((t.width-s)/2)},top=${Math.floor((t.height-e)/2)},resizable=yes,scrollbars=yes`,r=this.v_t();if(this.__t=null,"string"==typeof this.urlOrPromise){const t=Ct(this.urlOrPromise,r);this.p_t=St(this.win,t,"_blank",n),this.p_t&&(this.__t=i())}else this.p_t=St(this.win,"","_blank",n),this.p_t&&(this.__t=this.urlOrPromise.then((t=>{const s=Ct(t,r);this.p_t.location.replace(s)}),(t=>{throw new Error("failed to resolve url: "+t)})));this.__t?this.__t.then((()=>{this.g_t(r)}),(t=>{this.b_t(null,t)})):this.b_t(null,new Error("failed to open dialog"))}g_t(t){const s=Et(t).origin;this.m_t=this.win.setInterval((()=>{this.p_t.closed&&(this.win.clearInterval(this.m_t),this.m_t=null,this.win.setTimeout((()=>{this.b_t("")}),3e3))}),500),this.A_t=It(this.win,"message",(t=>{t.origin==s&&Tt(t)&&"amp"==Tt(t).sentinel&&"result"==Tt(t).type&&(this.p_t&&this.p_t.postMessage({"sentinel":"amp","type":"result-ack"},s),this.b_t(Tt(t).result))}),void 0)}b_t(t,s){this.oe&&(s?this.oh(s):this.oe(t),this._r())}v_t(){const t=this.viewer.getResolvedViewerUrl();let s;return s=`${kt.cdn}/v0/amp-login-done-0.1.html`,s+"?url="+encodeURIComponent(t)}};function Ct(t,s){return Mt.test(t)?t.replace(Mt,encodeURIComponent(s)):t+(-1==t.indexOf("?")?"?":"&")+"return="+encodeURIComponent(s)}var Lt="local",Ut=function(){var t=function(t,s,i,e){for(i=i||{},e=t.length;e--;i[t[e]]=s);return i},s=[1,3],i=[1,4],e=[1,18],n=[1,19],r=[1,14],o=[1,15],h=[1,16],c=[1,17],u=[1,21],l=[1,22],a=[5,6,7,10],f=[5,6,7,10,15,16,17,18,19,20,21],d=[5,6,7,10,15,16,17,18,19,20,21,25,27],p={trace:function(){},yy:{},jN:{"error":2,"result":3,"search_condition":4,"EOF":5,"OR":6,"AND":7,"NOT":8,"(":9,")":10,"predicate":11,"comparison_predicate":12,"truthy_predicate":13,"scalar_exp":14,"EQ":15,"DEQ":16,"NEQ":17,"LT":18,"LTE":19,"GT":20,"GTE":21,"atom":22,"field_ref":23,"literal":24,"DOT":25,"field_name":26,"[":27,"string":28,"]":29,"NAME":30,"STRING":31,"NUMERIC":32,"TRUE":33,"FALSE":34,"NULL":35,"$accept":0,"$end":1},$N:{2:"error",5:"EOF",6:"OR",7:"AND",8:"NOT",9:"(",10:")",15:"EQ",16:"DEQ",17:"NEQ",18:"LT",19:"LTE",20:"GT",21:"GTE",25:"DOT",27:"[",29:"]",30:"NAME",31:"STRING",32:"NUMERIC",33:"TRUE",34:"FALSE",35:"NULL"},BN:[0,[3,2],[4,3],[4,3],[4,2],[4,3],[4,1],[11,1],[11,1],[12,3],[12,3],[12,3],[12,3],[12,3],[12,3],[12,3],[13,1],[14,1],[14,1],[22,1],[23,3],[23,4],[23,1],[26,1],[28,1],[24,1],[24,1],[24,1],[24,1],[24,1]],performAction:function(t,s,i,e,n,r,o){var h=r.length-1;switch(n){case 1:return r[h-1];case 2:this.$=r[h-2]||r[h];break;case 3:this.$=r[h-2]&&r[h];break;case 4:this.$=!r[h];break;case 5:this.$=r[h-1];break;case 6:case 7:case 8:case 17:case 18:case 19:this.$=r[h];break;case 9:this.$=r[h-2]===r[h];break;case 10:throw new Error('"==" is not allowed, use "="');case 11:this.$=r[h-2]!==r[h];break;case 12:this.$=typeof r[h-2]==typeof r[h]&&r[h-2]<r[h];break;case 13:this.$=typeof r[h-2]==typeof r[h]&&r[h-2]<=r[h];break;case 14:this.$=typeof r[h-2]==typeof r[h]&&r[h-2]>r[h];break;case 15:this.$=typeof r[h-2]==typeof r[h]&&r[h-2]>=r[h];break;case 16:this.$=void 0!==r[h]&&null!==r[h]&&""!==r[h]&&0!==r[h]&&!1!==r[h];break;case 20:this.$="[object Object]"==Object.prototype.toString.call(r[h-2])&&r[h-2].hasOwnProperty(r[h])?r[h-2][r[h]]:null;break;case 21:this.$="[object Object]"==Object.prototype.toString.call(r[h-3])&&r[h-3].hasOwnProperty(r[h-1])?r[h-3][r[h-1]]:null;break;case 22:this.$=void 0!==e[r[h]]?e[r[h]]:null;break;case 23:this.$=t;break;case 24:this.$=t.substring(1,t.length-1);break;case 26:this.$=Number(t);break;case 27:this.$=!0;break;case 28:this.$=!1;break;case 29:this.$=null}},table:[{3:1,4:2,8:s,9:i,11:5,12:6,13:7,14:8,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{1:[3]},{5:[1,20],6:u,7:l},{4:23,8:s,9:i,11:5,12:6,13:7,14:8,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{4:24,8:s,9:i,11:5,12:6,13:7,14:8,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},t(a,[2,6]),t(a,[2,7]),t(a,[2,8]),t(a,[2,16],{15:[1,25],16:[1,26],17:[1,27],18:[1,28],19:[1,29],20:[1,30],21:[1,31]}),t(f,[2,17]),t(f,[2,18],{25:[1,32],27:[1,33]}),t(f,[2,19]),t(d,[2,22]),t(f,[2,25]),t(f,[2,26]),t(f,[2,27]),t(f,[2,28]),t(f,[2,29]),t(d,[2,23]),t([5,6,7,10,15,16,17,18,19,20,21,29],[2,24]),{1:[2,1]},{4:34,8:s,9:i,11:5,12:6,13:7,14:8,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{4:35,8:s,9:i,11:5,12:6,13:7,14:8,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},t(a,[2,4]),{6:u,7:l,10:[1,36]},{14:37,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{14:38,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{14:39,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{14:40,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{14:41,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{14:42,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{14:43,22:9,23:10,24:11,26:12,28:13,30:e,31:n,32:r,33:o,34:h,35:c},{26:44,30:e},{28:45,31:n},t([5,6,10],[2,2],{7:l}),t(a,[2,3]),t(a,[2,5]),t(a,[2,9]),t(a,[2,10]),t(a,[2,11]),t(a,[2,12]),t(a,[2,13]),t(a,[2,14]),t(a,[2,15]),t(d,[2,20]),{29:[1,46]},t(d,[2,21])],defaultActions:{20:[2,1]},parseError:function(t,s){if(!s.recoverable){var i=new Error(t);throw i.hash=s,i}this.trace(t)},parse:function(t){var s=this,i=[0],e=[null],n=[],r=this.table,o="",h=0,c=0,u=0,l=2,a=1,f=n.slice.call(arguments,1),d=Object.create(this.lexer),p={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(p.yy[m]=this.yy[m]);d.setInput(t,p.yy),p.yy.lexer=d,p.yy.parser=this,void 0===d.yylloc&&(d.yylloc={});var g=d.yylloc;n.push(g);var b=d.options&&d.options.ranges;"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,P,A,y,v,E,w,R,I,T=function(){var t;return"number"!=typeof(t=d.lex()||a)&&(t=s.jN[t]||t),t},S={};;){if(A=i[i.length-1],this.defaultActions[A]?y=this.defaultActions[A]:(null==_&&(_=T()),y=r[A]&&r[A][_]),void 0===y||!y.length||!y[0]){var k="";for(E in I=[],r[A])this.$N[E]&&E>l&&I.push("'"+this.$N[E]+"'");k=d.showPosition?"Parse error on line "+(h+1)+":\n"+d.showPosition()+"\nExpecting "+I.join(", ")+", got '"+(this.$N[_]||_)+"'":"Parse error on line "+(h+1)+": Unexpected "+(_==a?"end of input":"'"+(this.$N[_]||_)+"'"),this.parseError(k,{text:d.match,token:this.$N[_]||_,line:d.yylineno,loc:g,expected:I})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+_);switch(y[0]){case 1:i.push(_),e.push(d.yytext),n.push(d.yylloc),i.push(y[1]),_=null,P?(_=P,P=null):(c=d.yyleng,o=d.yytext,h=d.yylineno,g=d.yylloc,u>0&&u--);break;case 2:if(w=this.BN[y[1]][1],S.$=e[e.length-w],S._$={first_line:n[n.length-(w||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(w||1)].first_column,last_column:n[n.length-1].last_column},b&&(S._$.range=[n[n.length-(w||1)].range[0],n[n.length-1].range[1]]),void 0!==(v=this.performAction.apply(S,[o,c,h,p.yy,y[1],e,n].concat(f))))return v;w&&(i=i.slice(0,-1*w*2),e=e.slice(0,-1*w),n=n.slice(0,-1*w)),i.push(this.BN[y[1]][0]),e.push(S.$),n.push(S._$),R=r[i[i.length-2]][i[i.length-1]],i.push(R);break;case 3:return!0}}return!0}},m=function(){return{EOF:1,parseError:function(t,s){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,s)},setInput:function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var s=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var e=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===e.length?this.yylloc.first_column:0)+e[e.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+s+"^"},test_match:function(t,s){var i,e,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(e=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=e.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:e?e[e.length-1].length-e[e.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,s,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,s,i,e;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;r<n.length;r++)if((i=this._input.match(this.rules[n[r]]))&&(!s||i[0].length>s[0].length)){if(s=i,e=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,n[r])))return t;if(this._backtrack){s=!1;continue}return!1}if(!this.options.flex)break}return s?!1!==(t=this.test_match(s,n[e]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,s,i,e){switch(i){case 0:break;case 1:return 7;case 2:return 6;case 3:return 8;case 4:return 35;case 5:case 6:return 33;case 7:case 8:return 34;case 9:return 9;case 10:return 10;case 11:return 27;case 12:return 29;case 13:return"|";case 14:return 19;case 15:return 18;case 16:return 21;case 17:return 20;case 18:return 17;case 19:return 16;case 20:return 15;case 21:return 32;case 22:return 30;case 23:case 24:return 31;case 25:return 25;case 26:return"INVALID";case 27:return 5}},rules:[/^(?:\s+)/,/^(?:AND\b)/,/^(?:OR\b)/,/^(?:NOT\b)/,/^(?:NULL\b)/,/^(?:TRUE\b)/,/^(?:true\b)/,/^(?:FALSE\b)/,/^(?:false\b)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\|)/,/^(?:<=)/,/^(?:<)/,/^(?:>=)/,/^(?:>)/,/^(?:!=)/,/^(?:==)/,/^(?:=)/,/^(?:-?[0-9]+(\.[0-9]+)?\b)/,/^(?:[a-zA-Z_][a-zA-Z0-9_]*)/,/^(?:'[^\']*')/,/^(?:"[^\"]*")/,/^(?:\.)/,/^(?:.)/,/^(?:$)/],conditions:{"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27],"inclusive":!0}}}}();function g(){this.yy={}}return p.lexer=m,g.prototype=p,p.Parser=g,new g}(),Dt=Ut;function Nt(t,s){return function(t,s){try{return Dt.yy=s,!!Dt.parse(t)}finally{Dt.yy=null}}(t,s)}var jt="_AMP_SUBSCRIPTIONS_CLICK_HANDLED",Ft=class{constructor(t,s,i){this.ji=t,this.da=t.getRootNode(),this.Hot=s,this.Kgt=!!this.Hot.pingbackAllEntitlements,this.Iot=i,this.Lot=new class{constructor(t,s){const i=t.getHeadNode();this.Vy=function(t,s){const i=k(S(t));return O(i,s)?M(i,s):null}(i,"url-replace"),this.Mot=s,this.Got=null}setAuthResponse(t){this.Got=t}buildUrl(t,s){return this.Uot(s).then((s=>this.Vy.expandUrlAsync(t,s)))}collectUrlVars(t,s){return this.Uot(s).then((s=>this.Vy.collectVars(t,s)))}Uot(t){return this.Mot.then((s=>{const i={"READER_ID":s,"ACCESS_READER_ID":s};return t&&(i.AUTHDATA=t=>{if(this.Got)return c(this.Got,t)}),i}))}}(this.ji,this.Iot.getReaderId("local")),this.Tot=i.getAnalytics(),E(this.Hot.actions,"Actions have not been defined in the service config"),this.V_=new class{constructor(t,s,i,e){for(const t in e)Rt(e[t],`action ${t}`);this.Qgt=e,this.Zgt={},this.Lot=s,this.qU=i,this.sbt=null,this.ibt=0,this.nbt=Vt.bind(null,t),this.build()}build(){if(0==Object.keys(this.Qgt).length)return null;const t=[];for(const s in this.Qgt)t.push(this.Lot.buildUrl(this.Qgt[s],!0).then((t=>{this.Zgt[s]=t})));return Promise.all(t).then((()=>this.Zgt))}execute(t){E(this.Qgt[t],"Action URL is not configured: %s",t);const s=E(this.Zgt[t],"Action URL is not ready: %s",t);return this.Ps(s,t)}Ps(t,s){const i=Date.now();if(this.sbt&&i-this.ibt<1e3)return this.sbt;this.qU.actionEvent(Lt,s,tt);const e=this.nbt(t).then((t=>{this.sbt=null;const i=function(t){const s=o();if(!t)return s;let i;for(;i=m.exec(t);){const t=g(i[1],i[1]),e=i[2]?g(i[2].replace(/\+/g," "),i[2]):"";s[t]=e}return s}(t).success,e="true"==i||"yes"==i||"1"==i;return e?this.qU.actionEvent(Lt,s,"success"):this.qU.actionEvent(Lt,s,"rejected"),e||!i})).catch((t=>{throw this.qU.actionEvent(Lt,s,"failed"),this.sbt==e&&(this.sbt=null),t}));return this.sbt=e,this.ibt=i,this.sbt}}(this.ji,this.Lot,this.Tot,this.validateActionMap(this.Hot.actions)),this.jm=new class{constructor(t,s,i){this.ji=t,this.da=t.getRootNode(),this.p_t=s,this.g_=R(t,"templates"),this.Iot=i}render(t){return Promise.all([this.rbt(t),this.obt(t)])}reset(){return this.p_t.close(),this.hbt({},this.da,(()=>!1))}rbt(t){this.hbt(t,this.da,Nt)}obt(t){return this.ji.whenReady().then((()=>{const s=this.ji.getRootNode().querySelectorAll("[subscriptions-dialog][subscriptions-display]");for(let i=0;i<s.length;i++){const e=s[i],n=e.getAttribute("subscriptions-display");if(n&&Nt(n,t))return e}})).then((s=>{if(!s)return;if("TEMPLATE"==s.tagName)return this.g_.renderTemplate(s,t).then((s=>{const i=t;return this.hbt(i,s,Nt)}));const i=s.cloneNode(!0);return i.removeAttribute("subscriptions-dialog"),i.removeAttribute("subscriptions-display"),i})).then((t=>{if(t)return this.p_t.open(t,!0)}))}hbt(t,s,i){return this.ji.whenReady().then((()=>{const e=s.querySelectorAll('[subscriptions-action], [subscriptions-section="actions"], [subscriptions-actions]');for(let s=0;s<e.length;s++){const n=e[s],r=n.getAttribute("subscriptions-display");r&&i(r,t)?(n.classList.add("i-amphtml-subs-display"),n.getAttribute("subscriptions-service")&&n.getAttribute("subscriptions-action")&&"false"!==n.getAttribute("subscriptions-decorate")&&!n.hasAttribute("i-amphtml-subs-decorated")&&(this.Iot.decorateServiceAction(n,n.getAttribute("subscriptions-service"),n.getAttribute("subscriptions-action"),null),n.setAttribute("i-amphtml-subs-decorated",!0))):n.classList.remove("i-amphtml-subs-display")}return s}))}}(this.ji,i.getDialog(),this.Iot)}getPlatformKey(){return"local"}validateActionMap(t){return E(t.login,'Action "login" is not present in action map'),E(t.subscribe,'Action "subscribe" is not present in action map'),t}eT(){const t=t=>{if(t[jt])return;t[jt]=!0;const s=function(t,s){return t.closest("[subscriptions-action]")}(t.target);this.ya(s)};this.da.addEventListener("click",t),this.da.body&&this.da.body.addEventListener("click",t)}ya(t){if(t){const s=t.getAttribute("subscriptions-action"),i=t.getAttribute("subscriptions-service");if("local"==i)this.executeAction(s,t.id);else if("auto"==(i||"auto"))if("login"==s){const i=this.Iot.selectPlatformForLogin();this.Iot.delegateActionToService(s,i.getPlatformKey(),t.id)}else this.executeAction(s,t.id);else i&&this.Iot.delegateActionToService(s,i,t.id)}}activate(t){this.cbt(t).then((t=>{this.jm.render(t)}))}cbt(t){const s=t.json();return this.Iot.getScoreFactorStates().then((t=>(s.factors=t,this.Lot.setAuthResponse(s)))).then((()=>this.V_.build())).then((()=>s))}reset(){this.jm.reset()}executeAction(t){return this.V_.execute(t).then((t=>(t&&this.Iot.resetPlatforms(),!!t)))}isPrerenderSafe(){return!1}getSupportedScoreFactor(t){return 0}getBaseScore(){return this.Hot.baseScore||0}getEntitlements(){}pingback(t){}pingbackReturnsAllEntitlements(){return this.Kgt}isPingbackEnabled(){return!1}decorateUI(t,s,i){}},$t="__AMP__",zt=class extends Ft{constructor(t,s,i){super(t,s,i),v("iframe"==this.Hot.type),this.wv=E(this.Hot.iframeSrc,'"iframeSrc" URL must be specified'),Rt(this.wv,"iframe Url"),this.Y_t=this.Hot.iframeVars||null,this.Y_t&&E(u(this.Y_t),'"iframeVars" must be an array'),this.bg=Et(this.wv).origin,this.tAt=null,this.iAt=null,this.Ov=t.win.document.createElement("iframe"),ft(this.Ov,!1),this.sAt=new class{constructor(t,s,i){this.i=t,this.eAt=s,this.bg=i,this.o=null,this.nAt=null,this.rAt=this.my.bind(this),this.oAt=0,this.hAt={}}connect(t){if(this.nAt)throw new Error("already connected");this.nAt=t,this.i.addEventListener("message",this.rAt)}disconnect(){this.nAt&&(this.nAt=null,this.i.removeEventListener("message",this.rAt))}isConnected(){return null!=this.bg}getTarget(){const t=this.cAt();if(!t)throw new Error("not connected");return t}cAt(){return this.nAt&&!this.o&&("function"==typeof this.eAt?this.o=this.eAt():this.o=this.eAt),this.o}getTargetOrigin(){if(null==this.bg)throw new Error("not connected");return this.bg}sendCommand(t,s){this.XP(void 0,t,s)}sendCommandRsvp(t,s){const i=String(++this.oAt);let e=null;const n=new Promise((t=>{e=t}));return this.hAt[i]={promise:n,resolver:e},this.XP(i,t,s),n}XP(t,s,i){const e=this.getTarget(),n="connect"==s?null!=this.bg?this.bg:"*":this.getTargetOrigin();e.postMessage({"sentinel":$t,"_rsvp":t,"cmd":s,"payload":i||null},n)}my(t){const s=t,{data:i}=s;if(!i||i.sentinel!=$t)return;const e=s.origin,n=i.cmd,r=i.payload||null;if(null==this.bg&&"start"==n&&(this.bg=e),null==this.bg&&s.source&&this.cAt()==s.source&&(this.bg=e),e!=this.bg)return;const o=i._rsvp,h=!!o&&"rsvp"!=n,c=this.uAt(o,n,r);h&&Promise.resolve(c).then((t=>{this.XP(o,"rsvp",{"result":t})}),(t=>{this.XP(o,"rsvp",{"error":String(t)})}))}uAt(t,s,i){if("rsvp"!=s)return this.nAt(s,i);{const s=t&&this.hAt[t];s&&("error"in i?s.resolver(Promise.reject(new Error(i.error))):s.resolver(i.result),delete this.hAt[t])}}}(this.ji.win,(()=>this.Ov.contentWindow),this.bg),this.Xg=null,this.eT()}getEntitlements(){return this.connect().then((()=>this.sAt.sendCommandRsvp("authorize",{}).then((t=>(t.source="local-iframe",t))).then((t=>_t.parseFromJson(t)))))}isPingbackEnabled(){return!0}pingback(t){return this.connect().then((()=>this.sAt.sendCommandRsvp("pingback",{entitlement:t})))}connect(){if(!this.iAt){const t=new e;this.iAt=t.promise,this.tAt=t.resolve,this.Xg=this.dAt(),this.sAt.connect(this.uAt.bind(this)),this.ji.getBody().appendChild(this.Ov),this.Ov.src=this.wv}return this.iAt}dAt(){return new Promise((t=>{const s=l(JSON.stringify(this.Hot)),i=this.Iot.getPageConfig();if(s.pageConfig={publicationId:i.getPublicationId(),productId:i.getProductId(),encryptedDocumentKey:this.Iot.getEncryptedDocumentKey("local")||null},this.Y_t){const i=this.Y_t.join("&");this.Lot.collectUrlVars(i,!1).then((i=>{s.iframeVars=i,t(s)}))}else t(s)}))}uAt(t,s){"connect"===t&&this.Xg.then((t=>{this.sAt.sendCommandRsvp("start",{"protocol":"amp-subscriptions","config":t}).then((()=>{this.tAt&&(this.tAt(),this.tAt=null)}))}))}},Kt=class extends Ft{constructor(t,s,i){super(t,s,i),this.Ddt=Rt(E(this.Hot.authorizationUrl,"Service config does not have authorization Url"),"Authorization Url"),this.Mw=w(this.ji.win,"xhr"),this.Odt=this.Hot.pingbackUrl||null,this.eT()}getEntitlements(){const t=this.Lot.buildUrl(this.Ddt,!1),s=this.Iot.loadMeteringState();return Promise.all([t,s]).then((t=>{let s=t[0];const i=t[1];i&&(s=wt(s,"meteringState",btoa(JSON.stringify(i))));const e=this.Iot.getEncryptedDocumentKey("local");return e&&(s=wt(s,"crypt",e)),this.Mw.fetchJson(s,{credentials:"include"}).then((t=>t.json())).then((t=>{const s=[];return t.metering&&t.metering.state&&s.push(this.Iot.saveMeteringState(t.metering.state)),Promise.all(s).then((()=>_t.parseFromJson(t)))}))}))}isPingbackEnabled(){return!!this.Odt}ubt(t){if(u(t)){const s=[];return t.forEach((t=>{s.push(t.jsonForPingback())})),JSON.stringify(s)}return JSON.stringify(t.jsonForPingback())}pingback(t){if(!this.isPingbackEnabled)return;const s=v(this.Odt);return this.Lot.buildUrl(s,!0).then((s=>this.Mw.sendSignal(s,{method:"POST",credentials:"include",headers:{"Content-Type":"text/plain"},body:this.ubt(t)})))}};function Gt(t,s,i){return"iframe"===s.type?new zt(t,s,i):new Kt(t,s,i)}var Bt=class{constructor(){this.mn=null}add(t){return this.mn||(this.mn=[]),this.mn.push(t),()=>{this.remove(t)}}remove(t){this.mn&&function(t,s){const i=t.indexOf(s);-1!=i&&t.splice(i,1)}(this.mn,t)}removeAll(){this.mn&&(this.mn.length=0)}fire(t){if(this.mn)for(const s of this.mn.slice())s(t)}getHandlerCount(){var t,s;return null!==(t=null===(s=this.mn)||void 0===s?void 0:s.length)&&void 0!==t?t:0}},Wt="i-amphtml-subs",Jt={"-":"+","_":"/",".":"="};function Yt(t){return nt(atob(t.replace(/[-_.]/g,(t=>Jt[t]))))}function Ht(t,s,i){if(s[i])return s[i];const e=t.querySelector(`style[${i}], link[${i}]`);return e?(s[i]=e,e):null}function Qt(t,s){const i=t.styleSheets;for(let t=0;t<i.length;t++)if(i[t].ownerNode==s)return!0;return!1}var Zt=self.__AMP_ERRORS||[];self.__AMP_ERRORS=Zt;var Xt="amp-subscriptions";t.registerServiceForDoc("subscriptions",(function(t){return new class{constructor(t){const s=t.getElementById(Xt);this.ji=t,function(t,s,i,e,n){const r=t.getHeadNode(),h=function(t,s,i,e){let n=t.__AMP_CSS_SM;n||(n=t.__AMP_CSS_SM=o());const r=`amp-extension=${e}`;if(r){const i=Ht(t,n,r);if(i)return"STYLE"==i.tagName&&i.textContent!==s&&(i.textContent=s),i}const h=(t.ownerDocument||t).createElement("style");h.textContent=s;let c=null;return h.setAttribute("amp-extension",e),c=Ht(t,n,"amp-runtime"),function(t,s,i=null){if(!i)return void function(t,s){t.insertBefore(s,t.firstChild)}(t,s);const e=i.nextSibling;t.insertBefore(s,e)}(t,h,c),r&&(n[r]=h),h}(r,function(t,s){const i=t.__AMP_CSS_TR;return i?i(s):s}(r,'[subscriptions-action]:not(.i-amphtml-subs-display),[subscriptions-actions]:not(.i-amphtml-subs-display),[subscriptions-section=actions]:not(.i-amphtml-subs-display),body.i-amphtml-subs-delegated [subscriptions-section=actions],body.i-amphtml-subs-grant-unk [subscriptions-action],body.i-amphtml-subs-grant-unk [subscriptions-section=actions],body:not(.i-amphtml-subs-grant-no) [subscriptions-section=content-not-granted],body:not(.i-amphtml-subs-grant-yes) [subscriptions-section=content],body:not(.i-amphtml-subs-loading) [subscriptions-section=loading]{display:none!important}amp-subscriptions-dialog{display:block!important;position:fixed!important;bottom:0!important;left:0!important;margin-left:0!important;width:100%!important;z-index:2147483641!important;max-height:90vh;box-sizing:border-box;opacity:1;background-image:none;background-color:#fff;box-shadow:0 0 5px 0 rgba(0,0,0,.2);margin-bottom:0;transition:transform 0.3s ease-in}.i-amphtml-subs-dialog-close-button{position:absolute;width:28px;height:28px;top:-28px;right:0;background-image:url(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="341 8 13 13"><path fill="%234F4F4F" fill-rule="evenodd" d="M354 9.31 352.69 8l-5.19 5.19L342.31 8 341 9.31l5.19 5.19-5.19 5.19 1.31 1.31 5.19-5.19 5.19 5.19 1.31-1.31-5.19-5.19z"/></svg>\');background-size:13px 13px;background-position:9px;background-color:#fff;background-repeat:no-repeat;box-shadow:0 -1px 1px 0 rgba(0,0,0,.2);border:none;border-radius:12px 0 0 0;cursor:pointer}body:not(.i-amphtml-subs-grant-yes) .i-amphtml-subs-dialog-close-button{display:none}.i-amphtml-subs-progress{height:2px;background-color:#ccc;position:relative;margin:8px;overflow:hidden}.i-amphtml-subs-progress:after{content:"";background-color:#2196f3;height:2px;position:absolute;left:0;top:0;width:20%;animation:i-amphtml-subs-loading-progress 1500ms ease-in-out infinite}@keyframes i-amphtml-subs-loading-progress{0%{transform:translateX(-100%)}to{transform:translateX(500%)}}@media (min-width:480px){amp-subscriptions-dialog{width:480px!important;left:-240px!important;margin-left:50vw!important}}\n/*# sourceURL=/extensions/amp-subscriptions/0.1/amp-subscriptions.css*/'),0,"amp-subscriptions");if(i){const s=t.getRootNode();if(Qt(s,h))return h;const i=setInterval((()=>{Qt(s,h)&&clearInterval(i)}),4)}}(t,0,(()=>{})),this.Rc=null,this.jm=new class{constructor(t){this.ji=t,this.Yc=R(t,"mutator"),this.setGrantState(null),this.lbt().classList.add(`${Wt}-ready`),this.addLoadingBar()}lbt(){return this.ji.getBody()}MO(t,s){this.Yc.mutateElement(this.ji.getBody(),(()=>{this.lbt().classList.toggle(`${Wt}-${t}-unk`,null===s),this.lbt().classList.toggle(`${Wt}-${t}-yes`,!0===s),this.lbt().classList.toggle(`${Wt}-${t}-no`,!1===s)}))}addLoadingBar(){return this.ji.whenReady().then((()=>{const t=this.ji.getBody();if(!t.querySelector("[subscriptions-section=loading]")){const i=p(this.ji.win.document,"div",{"class":"i-amphtml-subs-progress","subscriptions-section":"loading"});t.insertBefore(i,(s=t,f(/^[\w-]+$/.test("footer")),"> footer",s.querySelector(function(t,s){return t.replace(/^|,/g,"$&:scope ")}("> footer"))))}var s}))}abt(t,s){this.Yc.mutateElement(this.ji.getBody(),(()=>{this.lbt().classList.toggle(`${Wt}-${t}`,s)}))}setGrantState(t){this.MO("grant",t)}toggleLoading(t){this.abt("loading",t)}}(t),this.fbt=null,this.dbt=null,this.pbt=null,this.mbt=P().assertElement(s),this.Tot=new class{constructor(t){this.el=t,this.Et=[]}registerEventListener(t){this.Et.push(t)}serviceEvent(t,s,i,e){this.event(t,X({"serviceId":s},i),e)}event(t,s,i){i=i||{};const e=t!==q?t:t+`-${i.action}-${i.status}`;s=s||{},function(t,s,i={},e=!0){var n;(n=t,function(t,s,i,e){const n=T(t,s);if(n)return n;const r=S(t);return r.whenExtensionsKnown().then((()=>{const t=r.getExtensionVersion(i);return t?w(r.win,"extensions").waitForExtension(i,t):null})).then((i=>i?I(t,s):null))}(n,"amp-analytics-instrumentation","amp-analytics")).then((n=>{n&&n.triggerEventForTarget(t,s,i,e)}))}(this.el,e,s,!1);for(let e=0;e<this.Et.length;e++)this.Et[e](t,s,i)}actionEvent(t,s,i,e){this.serviceEvent(q,t,e,{"action":s,"status":i})}}(this.mbt),this.Iot=new class{constructor(t){this.tnt=t}getAnalytics(){return this.tnt.getAnalytics()}getDialog(){return this.tnt.getDialog()}getEncryptedDocumentKey(t){return this.tnt.getEncryptedDocumentKey(t)}getPageConfig(){return this.tnt.getPageConfig()}getReaderId(t){return this.tnt.getReaderId(t)}getScoreFactorStates(){return this.tnt.getScoreFactorStates()}delegateActionToLocal(t,s){return this.delegateActionToService(t,"local",s)}delegateActionToService(t,s,i){return this.tnt.delegateActionToService(t,s,i)}decorateServiceAction(t,s,i,e){this.tnt.decorateServiceAction(t,s,i,e)}resetPlatforms(){this.tnt.resetPlatforms()}selectPlatformForLogin(){return this.tnt.selectPlatformForLogin()}loadMeteringState(){return this.tnt.gbt?this.tnt.gbt.loadMeteringState():Promise.resolve(null)}saveMeteringState(t){return this.tnt.gbt?this.tnt.gbt.saveMeteringState(t):i()}rememberMeteringEntitlementsWereFetched(){this.tnt.gbt&&(this.tnt.gbt.entitlementsWereFetchedWithCurrentMeteringState=!0)}}(this),this.p_t=new class{constructor(t){this.ji=t,this.sh=w(t.win,"vsync"),this.Se=C(t.win),this.wl=U(t),this.zh=!1,this.G0=null,this.bbt=i();const s=this.ji.win.document;this.fh=p(s,"amp-subscriptions-dialog",{"role":"dialog"}),ft(this.fh,!1),this.dZ=p(s,"button",{"class":"i-amphtml-subs-dialog-close-button"}),this.showCloseAction(!1),this.fh.appendChild(this.dZ),this.dZ.addEventListener("click",(()=>{this.close()})),this.ji.getBody().appendChild(this.fh),at(this.fh,{transform:"translateY(100%)"})}getRoot(){return this.fh}isVisible(){return this.zh}open(t,s=!0){return this.Hc((()=>this.AX(t,s)))}close(){return this.Hc((()=>this.kO()))}Hc(t){return this.bbt=this.bbt.then(t)}AX(t,s=!0){return this.G0?this.fh.replaceChild(t,this.G0):this.fh.appendChild(t),this.G0=t,this.zh?i():(this.zh=!0,this.sh.mutatePromise((()=>{ft(this.fh,!0),this.showCloseAction(s)})).then((()=>this.sh.mutatePromise((()=>{at(this.fh,{transform:"translateY(0)"})})).then((()=>this.Se.promise(300))))).then((()=>{let t;return this.sh.runPromise({measure:()=>{t=this.fh.offsetHeight},mutate:()=>{this.wl.updatePaddingBottom(t),this.wl.addToFixedLayer(this.fh,!0)}})})))}kO(){return this.zh?this.sh.mutatePromise((()=>{at(this.fh,{transform:"translateY(100%)"})})).then((()=>this.Se.promise(300))).then((()=>this.sh.mutatePromise((()=>{ft(this.fh,!1),this.wl.updatePaddingBottom(0),this.zh=!1})))):i()}showCloseAction(t){ft(this.dZ,t)}}(t),this._bt=new class{constructor(t){this.ji=t,this.k_t=null,this.Se=C(t.win),this.wl=U(t)}scheduleView(t){return this.k_t=null,this.ji.whenReady().then((()=>new Promise((t=>{this.ji.isVisible()&&t(),this.ji.onVisibilityChanged((()=>{this.ji.isVisible()&&t()}))})).then((()=>this.CAt(t)))))}CAt(t){return this.k_t||(this.k_t=this.xAt(t).catch((t=>{throw this.k_t=null,t}))),this.k_t}xAt(t){if(0==t)return i();const s=[];return new Promise(((i,e)=>{s.push(this.ji.onVisibilityChanged((()=>{this.ji.isVisible()||e(new Error("CANCELLED"))})));const n=this.Se.delay(i,t);s.push((()=>this.Se.cancel(n))),s.push(this.wl.onScroll(i)),s.push(function(t,s,i,e){let n=i;const r=It(t,"click",(t=>{try{n(t)}finally{n=null,r()}}),void 0);return r}(this.ji.getRootNode(),0,i))})).then((()=>{s.forEach((t=>t()))}),(t=>{throw s.forEach((t=>t())),t}))}}(t),this.We=L(t),this.Pbt=null,this.Se=C(t.win),this.Abt=this.We.hasCapability("auth"),this.ybt=this.Abt&&this.We.hasCapability("paywall"),this.R_t=I(t,"cid"),this.vbt={},this.Ebt=new class{constructor(t){this.ji=t,this.wbt=null;const s=this.ji.getRootNode().querySelector("script[cryptokeys]");this.Rbt=null,s&&s.hasAttribute("sha-256-hash")&&(this.Rbt=s.getAttribute("sha-256-hash")),this.Ibt=s&&a(s.textContent)||null}isDocumentEncrypted(){return!!this.Ibt&&Object.keys(this.Ibt).length>0}getEncryptedKeys(){return this.Ibt}getEncryptedDocumentKey(t){const s=this.getEncryptedKeys();return s&&s[t]||null}tryToDecryptDocument(t){if(!this.Rbt)return this.Tbt(t);const s=(i=t,"undefined"!=typeof TextEncoder?(new TextEncoder).encode(i):nt(unescape(encodeURIComponent(i))));var i;return crypto.subtle.digest("SHA-256",s).then((s=>{var i;return((i=new Uint8Array(s))?Array.prototype.slice.call(i):[]).map((t=>function(t,s,i){if(t.length>=s)return t;s-=t.length;let e="0";for(;s>e.length;)e+="0";return e.slice(0,s)+t}(t.toString(16),2))).join("")!=this.Rbt?Promise.reject(new Error("Invalid Document Key")):this.Tbt(t)}))}Tbt(t){return this.wbt||(this.wbt=this.ji.whenReady().then((()=>{return(s=ot(t).buffer,rt((self.msCrypto?self.msCrypto.subtle:self.crypto.subtle).importKey("raw",s,"AES-GCM",!0,["decrypt"]))).then((t=>{const s=this.ji.getRootNode().querySelectorAll("script[ciphertext]"),i=[];return s.forEach((s=>{const e=ot(s.textContent.replace(/\s+/g,"")).buffer,n=e.slice(0,12),r=e.slice(12);i.push(function(t,s,i){const e=!!self.msCrypto;return rt((e?self.msCrypto.subtle:self.crypto.subtle).decrypt({name:"AES-GCM",iv:s,tag:e?i.slice(i.byteLength-16):void 0,tagLength:128},t,e?i.slice(0,i.byteLength-16):i)).then((t=>function(t){if("undefined"!=typeof TextDecoder)return new TextDecoder("utf-8").decode(t);const s=new Uint8Array(t.buffer||t),i=new Array(s.length);for(let t=0;t<s.length;t++)i[t]=String.fromCharCode(s[t]);const e=i.join("");return decodeURIComponent(escape(e))}(new Uint8Array(t))))}(t,n,r).then((t=>{s.outerHTML=t})))})),Promise.all(i)}));var s}))),this.wbt}}(t),this.gbt=null}start(){return this.Ee().then((()=>{if(this.Tot.event("subscriptions-started"),this.jm.toggleLoading(!0),E(this.fbt,"Page config is null"),this.Abt)return this.Sbt(),void this.kbt(!1);E(this.dbt.services,"Services not configured in service config");const t=this.dbt.services.map((t=>t.serviceId||"local"));this.Mbt(t),this.dbt.services.forEach((t=>{this.Vbt(t)})),this.pbt.getAvailablePlatforms().forEach((t=>{this.xbt(t)})),function(t){return t.waitForBodyOpen().then((()=>{const s=t.getBody(),i=(e=s,n=()=>!!s.firstElementChild,new Promise((t=>{!function(t,s,i){if(s(t))i();else{const e=new(d(t).MutationObserver)((()=>{s(t)&&(e.disconnect(),i())}));e.observe(t,{childList:!0})}}(e,n,t)})));var e,n;return C(t.win).timeoutPromise(2e3,i).then((()=>"AMP-STORY"===s.firstElementChild.tagName),(()=>!1))}))}(this.ji).then((t=>{t&&this.p_t.getRoot().classList.add("i-amphtml-story-subscriptions-dialog-wrapper"),this.kbt(!t)}))})),this}getAccessReaderId(){return this.Ee().then((()=>this.getReaderId("local")))}getAnalytics(){return this.Tot}getAuthdataField(t){return this.Ee().then((()=>this.pbt.getEntitlementPromiseFor("local"))).then((s=>c(s.json(),t)))}getDialog(){return this.p_t}maybeRenderDialogForSelectedPlatform(){return this.Ee().then((()=>{if(!this.Abt&&!this.dbt.alwaysGrant)return this.Obt()}))}getGrantStatus(){return this.pbt.getGrantStatus()}addOnEntitlementResolvedCallback(t){this.pbt.addOnEntitlementResolvedCallback(t)}getEncryptedDocumentKey(t){return this.Ebt.getEncryptedDocumentKey(t)}getPageConfig(){return v(this.fbt)}getReaderId(t){let s=this.vbt[t];if(!s){const e=i(),n="amp-access"+("local"==t?"":"-"+t);s=this.R_t.then((t=>t.get({scope:n,createCookieIfNotPresent:!0},e))),this.vbt[t]=s}return s}getScoreFactorStates(){return this.pbt.getScoreFactorStates()}registerPlatform(t,s){return this.Ee().then((()=>{if(this.Abt)return;const i=E(this.dbt.services.filter((s=>(s.serviceId||"local")===t))[0],"No matching services for the ID found"),e=s(i,this.Iot);this.pbt.resolvePlatform(e.getPlatformKey(),e),this.Tot.serviceEvent("subscriptions-service-registered",e.getPlatformKey()),this.Tot.serviceEvent("subscriptions-platform-registered",e.getPlatformKey()),this.xbt(e)}))}selectPlatformForLogin(){return this.pbt.selectPlatformForLogin()}Ee(){if(!this.Rc){const t=new class{constructor(t){this.ji=t,this.wl=U(this.ji)}getWin(){return this.ji.win}getRootNode(){return this.ji.getRootNode()}getRootElement(){const t=this.ji.getRootNode();return t.documentElement||t.body||t}getHead(){return this.ji.getHeadNode()}getBody(){return this.ji.isBodyAvailable()?this.ji.getBody():null}isReady(){return this.ji.isReady()}whenReady(){return this.ji.whenReady()}addToFixedLayer(t){return this.wl.addToFixedLayer(t,!0)}}(this.ji),s=new class{constructor(t){var s;this.doc_=9===(s=t).nodeType||s.document?new class{constructor(t){const s=!!t.document;this.win_=s?t:t.defaultView,this.doc_=s?t.document:t}getWin(){return this.win_}getRootNode(){return this.doc_}getRootElement(){return this.doc_.documentElement}getHead(){return this.doc_.head}getBody(){return this.doc_.body}isReady(){return D(this.doc_)}whenReady(){return t=this.doc_,new Promise((s=>{!function(t,s){!function(t,s,i){if(s(t))return void i(t);let e=!1;const n=()=>{s(t)&&!e&&(i(t),e=!0,t.removeEventListener("readystatechange",n))};t.addEventListener("readystatechange",n)}(t,D,s)}(t,s)}));var t}addToFixedLayer(t){return i()}}(s):s,this.configResolver_=null,this.configPromise_=new Promise((t=>{this.configResolver_=t})),this.metaParser_=new class{constructor(t){this.doc_=t}check(){if(!this.doc_.getBody())return null;const t=H(this.doc_.getRootNode(),"subscriptions-product-id");if(!t)return null;const s=H(this.doc_.getRootNode(),"subscriptions-accessible-for-free"),i=!(!s||"false"!==s.toLowerCase());return new N(t,i)}}(this.doc_),this.ldParser_=new class{constructor(t){this.doc_=t,this.checkType_=new Y}check(){if(!this.doc_.getBody())return null;const t=this.doc_.isReady(),s=this.doc_.getRootNode().querySelectorAll('script[type="application/ld+json"]');for(let i=0;i<s.length;i++){const e=s[i];if(e[B]||!e.textContent||!t&&!F(e))continue;if(e[B]=!0,!J.test(e.textContent))continue;const n=this.tryExtractConfig_(e);if(n)return n}return null}tryExtractConfig_(t){let s=function(t,s){try{return function(t){return JSON.parse(t)}(t)}catch(t){return}}(t.textContent);if(!s)return null;Array.isArray(s)||(s=[s]);let i=s;for(let t=0;t<i.length;t++){const s=i[t];if(s["@graph"]&&Array.isArray(s["@graph"])&&(i=i.concat(s["@graph"])),!this.checkType_.checkValue(s["@type"],W))continue;let e=null;const n=this.valueArray_(s,"isPartOf");if(n)for(let t=0;t<n.length&&(e=this.discoverProductId_(n[t]),!e);t++);if(!e)continue;const r=this.bool_(this.singleValue_(s,"isAccessibleForFree"),!0);return new N(e,!r)}return null}bool_(t,s){if("boolean"==typeof t)return t;if("string"==typeof t){const s=t.toLowerCase();if("false"===s)return!1;if("true"===s)return!0}return s}discoverProductId_(t){return this.checkType_.checkValue(t["@type"],["Product"])?this.singleValue_(t,"productID"):null}valueArray_(t,s){const i=t[s];return null==i||""===i?null:Array.isArray(i)?i:[i]}singleValue_(t,s){const i=this.valueArray_(t,s),e=i&&i[0];return null==e||""===e?null:e}}(this.doc_),this.microdataParser_=new class{constructor(t){this.doc_=t,this.access_=null,this.productId_=null,this.checkType_=new Y}discoverAccess_(t){const s=t.querySelectorAll("[itemprop='isAccessibleForFree']");for(let i=0;s[i];i++){const e=s[i],n=e.getAttribute("content")||e.textContent;if(n&&this.isValidElement_(e,t,"alreadySeenForAccessInfo")){let t=null;return"true"==n.toLowerCase()?t=!0:"false"==n.toLowerCase()&&(t=!1),t}}return null}isValidElement_(t,s,i){for(let s=t;s&&!s[i];s=s.parentNode)if(s[i]=!0,s.hasAttribute&&s.hasAttribute("itemscope")){const t=s.getAttribute("itemtype");return this.checkType_.checkString(t,W)}return!1}discoverProductId_(t){const s=t.querySelectorAll('[itemprop="productID"]');for(let i=0;s[i];i++){const e=s[i],n=e.getAttribute("content")||e.textContent,r=e.closest("[itemtype][itemscope]");if(!(r.getAttribute("itemtype").indexOf("http://schema.org/Product")<=-1)&&this.isValidElement_(r.parentElement,t,"alreadySeenForProductInfo"))return n}return null}getPageConfig_(){let t=null;return null!=this.access_?t=!this.access_:this.doc_.isReady()&&(t=!1),null!=this.productId_&&null!=t?new N(this.productId_,t):null}tryExtractConfig_(){let t=this.getPageConfig_();if(t)return t;const s=Array.prototype.slice.call(this.doc_.getRootNode().querySelectorAll("[itemscope][itemtype]")).filter((t=>this.checkType_.checkString(t.getAttribute("itemtype"),W)));for(let i=0;s[i]&&null==t;i++){const e=s[i];null==this.access_&&(this.access_=this.discoverAccess_(e)),this.productId_||(this.productId_=this.discoverProductId_(e)),t=this.getPageConfig_()}return t}check(){return this.doc_.getBody()?this.tryExtractConfig_():null}}(this.doc_)}resolveConfig(){return i().then(this.check.bind(this)),this.doc_.whenReady().then(this.check.bind(this)),this.configPromise_}check(){if(!this.configResolver_)return null;const t=this.metaParser_.check()||this.ldParser_.check()||this.microdataParser_.check();return t?(this.configResolver_(t),this.configResolver_=null):this.doc_.isReady()&&(this.configResolver_(Promise.reject(G.createError("No config could be discovered in the page"))),this.configResolver_=null),function(t){if(/swg.debug=1/.test(self.location.hash)){const t=Array.prototype.slice.call(arguments,0);t.unshift("[Subscriptions]"),j.apply(j,t)}}(t),t}}(t);this.Rc=Promise.all([this.Cbt(),s.resolveConfig()]).then((t=>{this.dbt=t[0],this.fbt=t[1]})).then((()=>{this.Lbt()}))}return this.Rc}Vbt(t){"local"==(t.serviceId||"local")&&this.pbt.resolvePlatform("local",Gt(this.ji,t,this.Iot))}Cbt(){return new Promise((t=>{t(a(this.mbt.textContent,(t=>{throw P().createError('Failed to parse "amp-subscriptions" JSON: ',t)})))}))}Ubt(t){this.jm.toggleLoading(!1),this.Pbt=this._bt.scheduleView(2e3),this.ybt&&!t||this.jm.setGrantState(t)}Dbt(t,s){this.pbt.resolveEntitlement(t,s),s.decryptedDocumentKey&&this.Ebt.tryToDecryptDocument(s.decryptedDocumentKey),this.Tot.serviceEvent("subscriptions-entitlement-resolved",t)}Nbt(t){return t.getEntitlements().then((s=>s&&s.granted&&this.Ebt.isDocumentEncrypted()&&!s.decryptedDocumentKey?(("local"==t.getPlatformKey()?P():y()).error(Xt,`${t.getPlatformKey()}: Subscription granted and encryption enabled, but no decrypted document key returned.`),null):s))}xbt(t){return this.jbt()?i():(t.isPrerenderSafe()?i():this.ji.whenFirstVisible()).then((()=>this.Se.timeoutPromise(3e3,this.Nbt(t)).then((s=>(s=s||_t.empty(t.getPlatformKey()),this.Dbt(t.getPlatformKey(),s),s))).catch((s=>{const i=t.getPlatformKey();throw this.pbt.reportPlatformFailureAndFallback(i),P().createError(`fetch entitlements failed for ${i}`,s)}))))}Mbt(t){const s=this.dbt.fallbackEntitlement?_t.parseFromJson(this.dbt.fallbackEntitlement):_t.empty("local");this.pbt=new class t{constructor(t,s,i,n,r){this.Fbt=n||{},this.$bt=t,this.zbt={},this.Kbt={},t.forEach((t=>{this.Kbt[t]=new e})),this.Gbt=new Bt,this.Bbt=new Bt,this.Wbt=null,this.Jbt=null,this.Ybt=null,this.Hbt=null,this.Qbt=[],this.Zbt=i,this.Xbt=Object.assign(it,s),this.qbt=r||new Bt}resolvePlatform(t,s){this.Fbt[t]=s,this.Bbt.fire({platformKey:t})}resetPlatformStore(){for(const t in this.Fbt)this.Fbt[t].reset();return new t(this.$bt,this.Xbt,this.Zbt,this.Fbt,this.qbt)}resetPlatform(t){delete this.zbt[t],this.Kbt[t]=new e,this.Fbt[t].reset(),this.Wbt=null,this.Jbt=null,this.Ybt=null,this.Hbt=null}onPlatformResolves(t,s){const i=this.Fbt[t];i?s(i):this.Bbt.add((i=>{i.platformKey===t&&s(this.getPlatform(t))}))}getPlatform(t){const s=this.Fbt[t];return v(s),s}tPt(){return this.getPlatform("local")}getAvailablePlatforms(){const t=[];for(const s in this.Fbt){const i=this.Fbt[s];t.push(i)}return t}onChange(t){this.Gbt.add(t)}addOnEntitlementResolvedCallback(t){this.qbt.add(t)}resolveEntitlement(t,s){s&&(s.service=t),this.zbt[t]=s;const i=this.Kbt[t];i&&i.resolve(s),-1!==this.Qbt.indexOf(t)&&this.Qbt.splice(this.Qbt.indexOf(t),1),s.granted&&this.sPt(s),this.Gbt.fire({platformKey:t,entitlement:s}),this.qbt.fire({platformKey:t,entitlement:s})}getResolvedEntitlementFor(t){return v(this.zbt[t]),this.zbt[t]}getEntitlementPromiseFor(t){return v(this.Kbt[t]),this.Kbt[t].promise}getScoreFactorStates(){const t={};return Promise.all(this.$bt.map((s=>(t[s]={},Promise.all(Object.values(st).map((i=>this.iPt(s,i).then((e=>{t[s][i]=e}))))))))).then((()=>t))}iPt(t,s){return this.getEntitlementPromiseFor(t).then((()=>this.Fbt[t].getSupportedScoreFactor(s)))}getGrantStatus(){if(null!==this.Wbt)return this.Wbt.promise;this.Wbt=new e;for(const t in this.zbt){const s=this.zbt[t];s.granted&&(this.sPt(s),this.Wbt.resolve(!0))}return this.ePt()?this.Wbt.resolve(!1):this.onChange((t=>{const{entitlement:s}=t;s.granted?this.Wbt.resolve(!0):this.ePt()&&this.Wbt.resolve(!1)})),this.Wbt.promise}sPt(t){(!this.Jbt&&t.granted||this.Jbt&&!this.Jbt.isSubscriber()&&t.isSubscriber())&&(this.Jbt=t)}getGrantEntitlement(){const t=()=>this.Jbt&&(this.Jbt.isSubscriber()||this.Jbt.isFree()),s=()=>t()||this.ePt();return this.Ybt||(this.Ybt=new e,s()?this.Ybt.resolve(this.Jbt):this.Gbt.add((()=>{s()&&this.Ybt.resolve(this.Jbt)}))),this.Ybt.promise}reset(){this.Wbt=null}getAllPlatformsEntitlements(){return this.Hbt||(this.Hbt=new e,this.ePt()?this.Hbt.resolve(this.nPt()):this.onChange((()=>{this.ePt()&&this.Hbt.resolve(this.nPt())}))),this.Hbt.promise}nPt(){const t=[];for(const s in this.zbt)h(this.zbt,s)&&t.push(this.zbt[s]);return t}selectPlatform(){return this.getAllPlatformsEntitlements().then((()=>this.rPt()))}ePt(){return Object.keys(this.zbt).length===this.$bt.length}oPt(t,s){const i=s.getSupportedScoreFactor(t);return"number"!=typeof i?0:this.Xbt[t]*Math.min(1,Math.max(-1,i))}rPt(){v(this.ePt());const t=this.getAvailablePlatforms();for(;t.length;){const s=t.pop(),i=this.getResolvedEntitlementFor(s.getPlatformKey());if(i.isSubscriber()||i.isFree())return s}return this.hPt(this.cPt())}cPt(){return this.getAvailablePlatforms().map((t=>({platform:t,weight:this.uPt(t)})))}uPt(t){const s=[0],i=t.getBaseScore();for(const i in this.Xbt)h(this.Xbt,i)&&s.push(this.oPt(i,t));return i+s.reduce(((t,s)=>t+s))}hPt(t){const s=this.tPt();return t.sort(((t,i)=>i.weight===t.weight&&t.platform===s?-1:i.weight-t.weight)),t[0].platform}lPt(t){const s=this.getAvailablePlatforms().map((s=>{const i=s.getSupportedScoreFactor(t);return{platform:s,weight:"number"==typeof i?i:0}}));return this.hPt(s)}reportPlatformFailureAndFallback(t){if(t===this.tPt().getPlatformKey()&&this.Zbt)this.resolveEntitlement(this.tPt().getPlatformKey(),this.Zbt);else if(-1===this.Qbt.indexOf(t)){const s=_t.empty(t);this.resolveEntitlement(t,s),this.Qbt.push(t)}}selectPlatformForLogin(){return this.lPt(st.SUPPORTS_VIEWER)}}(t,this.dbt.score,s),this.aPt(this.pbt)}Sbt(){const t=vt(this.ji.win);this.Mbt(["local"]),this.dbt.services.forEach((s=>{if("local"==(s.serviceId||"local")){const i=new class{constructor(t,s,i,e){this.ji=t,this.Iot=i,this.fbt=i.getPageConfig(),this.Rh=Gt(t,s,i),this.We=L(this.ji),this.We.onMessage("subscriptionchange",this.fPt.bind(this)),this.e_t=new class{constructor(t){this.win=t,this.n_t=t.crypto&&(t.crypto.subtle||t.crypto.webkitSubtle)||null}decode(t){return this.r_t(t).payload}isVerificationSupported(){return!!this.n_t}decodeAndVerify(t,s){if(!this.n_t)throw new Error("Crypto is not supported on this platform");return new Promise((s=>s(this.r_t(t)))).then((t=>{const i=t.header.alg;if(!i||"RS256"!=i)throw new Error("Only alg=RS256 is supported");return this.o_t(s).then((s=>{const i=Yt(t.sig);return this.n_t.verify({name:"RSASSA-PKCS1-v1_5"},s,i,nt(t.verifiable))})).then((s=>{if(s)return t.payload;throw new Error("Signature verification failed")}))}))}r_t(t){function s(){throw new Error(`Invalid token: "${t}"`)}const i=t.split(".");3!=i.length&&s();const e=Yt(i[0]),n=Yt(i[1]);return{header:a(et(e),s),payload:a(et(n),s),verifiable:`${i[0]}.${i[1]}`,sig:i[2]}}o_t(t){return t.then((t=>this.n_t.importKey("spki",function(t){const s=t.trim().replace(/^-+BEGIN[^-]*-+/,"").replace(/-+END[^-]*-+$/,"").replace(/[\r\n]/g,"").trim();return nt(atob(s))}(t),{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"])))}}(t.win),this.dPt=this.fbt.getPublicationId(),this.pPt=this.fbt.getProductId(),this.h=e,this.Se=C(t.win)}isPrerenderSafe(){return!0}getEntitlements(){v(this.pPt);const t={"publicationId":this.dPt,"productId":this.pPt,"origin":this.h};let s;const i=this.We.getParam("cryptokeys")||"google.com";if(i){const t=i.split(",");for(let i=0;i!=t.length&&(s=this.Iot.getEncryptedDocumentKey(t[i]),!s);i++);}return s&&(t.encryptedDocumentKey=s),this.Se.timeoutPromise(3e3,this.We.sendMessageAwaitResponse("auth",t)).then((t=>{const s=(t=t||{}).error,i=t.authorization,e=t.decryptedDocumentKey;if(s)throw new Error(s.message);return i?this.mPt(i,e).catch((t=>{throw this.gPt(t.message),t})):_t.empty("local")}))}mPt(t,s){return new Promise((i=>{const e=vt(this.ji.win),n=Et(function(t){if(!function(t){return Pt.cdnProxyRegex.test(yt(t).origin)}(t=yt(t)))return t.href;const s=t.pathname.split("/"),i=s[1];E(At.has(i),"Unknown path prefix in url %s",t.href);const e=s[2],n="s"==e?"https://"+decodeURIComponent(s[3]):"http://"+decodeURIComponent(e);return E(n.indexOf(".")>0,"Expected a . in origin %s",n),s.splice(1,"s"==e?3:2),n+s.join("/")+function(t,s){if(!t||"?"==t)return"";const i=new RegExp("[?&](amp_(js[^&=]*|gsa|r|kit)|usqp)\\b[^&]*","g"),e=t.replace(i,"").replace(/^[?&]/,"");return e?"?"+e:""}(t.search)+(t.hash||"")}(this.ji.win.location)).origin,r=this.e_t.decode(t),o=E(this.fbt.getProductId(),"Product id is null");if(r.aud!=e&&r.aud!=n)throw P().createError(`The mismatching "aud" field: ${r.aud}`);if(r.exp<Math.floor(Date.now()/1e3))throw P().createError("Payload is expired");const h=r.entitlements;let c,u=_t.empty("local");if(h){if(Array.isArray(h)){for(let t=0;t<h.length;t++)if(-1!==h[t].products.indexOf(o)){c=h[t];break}}else-1!==h.products.indexOf(o)&&(c=h);c&&(u=new _t({source:"viewer",raw:t,granted:!0,grantReason:c.subscriptionToken?mt:"",dataObject:c,decryptedDocumentKey:s}))}r.metering&&!u.granted&&(u=new _t({source:r.iss||"",raw:t,granted:!0,grantReason:gt,dataObject:r.metering,decryptedDocumentKey:s})),u.service="local",i(u)}))}gPt(t){this.We.sendMessage("auth-rejected",{"reason":t})}getPlatformKey(){return this.Rh.getPlatformKey()}activate(){}reset(){}isPingbackEnabled(){return this.Rh.isPingbackEnabled()}pingbackReturnsAllEntitlements(){return this.Rh.pingbackReturnsAllEntitlements()}pingback(t){this.Rh.pingback(t)}getSupportedScoreFactor(t){return this.Rh.getSupportedScoreFactor(t)}getBaseScore(){return 0}executeAction(t,s){return this.Rh.executeAction(t,s)}decorateUI(t,s,i){return this.Rh.decorateUI(t,s,i)}fPt(){this.Iot.resetPlatforms()}}(this.ji,s,this.Iot,t);this.pbt.resolvePlatform("local",i),this.Nbt(i).then((t=>{v(t),this.Dbt("local",t)})).catch((t=>{this.pbt.reportPlatformFailureAndFallback("local"),y().error(Xt,"Viewer auth failed:",t)}))}}))}kbt(t=!0){const s=this.pbt.getGrantStatus(),i=this.pbt.getGrantEntitlement();return Promise.all([s,i]).then((s=>{const i=s[0],e=s[1],n=()=>this.bPt({granted:i,shouldActivatePlatform:t});if(!this.gbt)return void n();const r=this.pbt.getPlatform(this.gbt.platformKey);if(i){if(!e||e.grantReason!==gt||e.service!==this.gbt.platformKey)return void n();const t=()=>{this.bPt({granted:!0,shouldActivatePlatform:!1})};r.activate(e,e,t)}else this.gbt.entitlementsWereFetchedWithCurrentMeteringState?n():this.gbt.loadMeteringState().then((t=>{if(t)this.resetPlatform(this.gbt.platformKey);else{const t=_t.empty("local"),s=()=>this.kbt();r.activate(t,t,s)}}))}))}bPt({granted:t,shouldActivatePlatform:s}){this.Ubt(t),this._Pt(),s&&this.Obt()}Obt(){return Promise.all([this.pbt.getGrantStatus(),this.pbt.selectPlatform(),this.pbt.getGrantEntitlement()]).then((t=>{const s=t[1],i=t[2],e=this.pbt.getResolvedEntitlementFor(s.getPlatformKey()),n=i||e;s.activate(e,i),this.Tot.serviceEvent("subscriptions-service-activated",s.getPlatformKey()),this.Tot.serviceEvent("subscriptions-platform-activated",s.getPlatformKey()),n.granted?this.Tot.serviceEvent("subscriptions-access-granted",n.service):(this.Tot.serviceEvent("subscriptions-paywall-activated",s.getPlatformKey()),this.Tot.serviceEvent("subscriptions-access-denied",s.getPlatformKey()))}))}_Pt(){return this.Pbt?this.Pbt.then((()=>{this.pbt.getAvailablePlatforms().forEach((t=>{t.isPingbackEnabled()&&(t.pingbackReturnsAllEntitlements()?this.pbt.getAllPlatformsEntitlements().then((s=>t.pingback(s))):this.pbt.getGrantEntitlement().then((s=>t.pingback(s||_t.empty("local")))))}))})):null}resetPlatforms(){this.pbt=this.pbt.resetPlatformStore(),this.jm.toggleLoading(!0),this.gbt&&(this.gbt.entitlementsWereFetchedWithCurrentMeteringState=!1),this.pbt.getAvailablePlatforms().forEach((t=>{this.xbt(t)})),this.Tot.serviceEvent("subscriptions-service-re-authorized",""),this.Tot.serviceEvent("subscriptions-platform-re-authorized",""),this.kbt()}resetPlatform(t){this.jm.toggleLoading(!0),this.pbt.resetPlatform(t);const s=this.pbt.getPlatform(t);this.xbt(s),this.kbt()}delegateActionToLocal(t,s){return this.delegateActionToService(t,"local",s)}delegateActionToService(t,s,i=null){return new Promise((e=>{this.pbt.onPlatformResolves(s,(n=>{v(n),this.Tot.event("subscriptions-action-delegated",{"action":t,"serviceId":s},{"action":t,"status":tt}),e(n.executeAction(t,i))}))}))}decorateServiceAction(t,s,i,e){this.pbt.onPlatformResolves(s,(s=>{v(s),s.decorateUI(t,i,e)}))}aPt(t){this.jbt()&&t.resolveEntitlement("local",new _t({source:"",raw:"",granted:!0,grantReason:bt,dataObject:{}}))}jbt(){return!this.fbt.isLocked()||this.dbt.alwaysGrant}Lbt(){const{services:t}=this.dbt,s=t.find((t=>t.enableMetering));s&&(this.gbt=new class{constructor({platformKey:t}){this.entitlementsWereFetchedWithCurrentMeteringState=!1,this.platformKey=t,this.PPt=""}saveMeteringState(t){const s=JSON.stringify(t);return Promise.resolve(this.PPt).then((t=>s!==t)).then((t=>{t&&(this.PPt=s,this.entitlementsWereFetchedWithCurrentMeteringState=!1)}))}loadMeteringState(){return this.PPt?Promise.resolve(JSON.parse(this.PPt)):Promise.resolve(null)}}({platformKey:s.serviceId}))}}(t).start()}))})();
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}});
//# sourceMappingURL=amp-subscriptions-0.1.mjs.map