;
(self.AMP=self.AMP||[]).push({m:1,v:"2601162341000",n:"amp-viewer-integration",ev:"0.1",l:!0,p:"high",f:function(t,s){(()=>{var s;function e(){return s||(s=Promise.resolve(void 0))}var{isArray:n}=Array;function i(t,s){const e=t.length-s.length;return e>=0&&t.indexOf(s,e)==e}var{hasOwnProperty:r,toString:o}=Object.prototype;function h(t){const s=Object.create(null);return t&&Object.assign(s,t),s}function c(t,s,e,n,i,r,o,h,c,u,l){return t}var u=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function l(t,s=""){try{return decodeURIComponent(t)}catch(t){return s}}function a(t){const s=Object.getOwnPropertyDescriptor(t,"message");if(null!=s&&s.writable)return t;const{message:e,stack:n}=t,i=new Error(e);for(const s in t)i[s]=t[s];return i.stack=n,i}function f(t){let s=null,e="";for(const t of arguments)t instanceof Error&&!s?s=a(t):(e&&(e+=" "),e+=t);return s?e&&(s.message=e+": "+s.message):s=new Error(e),s}function d(t,...s){const e=f.apply(null,s);e.name=t||e.name,function(t){var s,e;null===(s=(e=self).__AMP_REPORT_ERROR)||void 0===s||s.call(e,t)}(e)}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var _=self.__AMP_LOG;function p(t,s){throw new Error("failed to call initLogConstructor")}function P(t){return _.user||(_.user=A()),function(t,s){return s&&s.ownerDocument.defaultView!=t}(_.user.win,t)?_.userForEmbed||(_.userForEmbed=A()):_.user}function A(t){return p()}function m(){return _.dev||(_.dev=p())}function E(t,s,e,n,i,r,o,h,c,u,l){return t}function g(t,s,e,n,i,r,o,h,c,u,l){return P().assert(t,s,e,n,i,r,o,h,c,u,l)}function T(t,s){return y(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),s)}function v(t,s){return y(M(w(t)),s)}function w(t){return t.nodeType?(e=t,s=(e.ownerDocument||e).defaultView,T(s,"ampdoc")).getAmpDoc(t):t;var s,e}function M(t){const s=w(t);return s.isSingleDoc()?s.win:s}function y(t,s){E(I(t,s));const e=function(t){let s=t.__AMP_SERVICES;return s||(s=t.__AMP_SERVICES={}),s}(t)[s];return e.obj||(E(e.ctor),E(e.context),e.obj=new e.ctor(e.context),E(e.obj),e.context=null,e.resolve&&e.resolve(e.obj)),e.obj}function I(t,s){const e=t.__AMP_SERVICES&&t.__AMP_SERVICES[s];return!(!e||!e.ctor)}var R,V=t=>T(t,"platform"),b=t=>v(t,"viewer"),x=t=>v(t,"viewport"),k=["Webkit","webkit","Moz","moz","ms","O","o"],S={"getPropertyPriority":()=>"","getPropertyValue":()=>""};function F(t){const s=t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()));return k.some((t=>s.startsWith(t+"-")))?`-${s}`:s}function N(t,s,e){if(Y(s))return s;R||(R=h());let n=R[s];if(!n||e){if(n=s,void 0===t[s]){const e=function(t){return t.charAt(0).toUpperCase()+t.slice(1)}(s),i=function(t,s){for(let e=0;e<k.length;e++){const n=k[e]+s;if(void 0!==t[n])return n}return""}(t,e);void 0!==t[i]&&(n=i)}e||(R[s]=n)}return n}function H(t,s){const{style:e}=t;for(const t in s)e.setProperty(F(N(e,t)),String(s[t]),"important")}function O(t,s,e,n,i){const r=N(t.style,s,i);if(!r)return;const o=n?e+n:e;t.style.setProperty(F(r),o)}function C(t,s,e){const n=N(t.style,s,e);if(n)return Y(n)?t.style.getPropertyValue(n):t.style[n]}function L(t,s){for(const e in s)O(t,e,s[e])}function U(t,s){const{style:e}=t;c(""!==s&&"none"!==s),c(!e.display),e.display=s}function D(t,s){return t.getComputedStyle(s)||S}function z(t,s){for(let e=0;e<s.length;e++)O(t,s[e],null)}function Y(t){return t.startsWith("--")}var q=class t{static solveYValueFromXValue(s,e,n,i,r,o,h,c,u){return t.Wr(t.Kr(s,e,i,o,c),n,r,h,u)}static Kr(s,e,n,i,r){const o=1e-6;let h=(s-e)/(r-e);if(h<=0)return 0;if(h>=1)return 1;let c=0,u=1,l=0;for(let a=0;a<8;a++){l=t.Yr(h,e,n,i,r);const a=(t.Yr(h+o,e,n,i,r)-l)/o;if(Math.abs(l-s)<o)return h;if(Math.abs(a)<o)break;l<s?c=h:u=h,h-=(l-s)/a}for(let a=0;Math.abs(l-s)>o&&a<8;a++)l<s?(c=h,h=(h+u)/2):(u=h,h=(h+c)/2),l=t.Yr(h,e,n,i,r);return h}static Yr(s,e,n,i,r){if(0==s)return e;if(1==s)return r;let o=t.Jr(e,n,s),h=t.Jr(n,i,s);const c=t.Jr(i,r,s);return o=t.Jr(o,h,s),h=t.Jr(h,c,s),t.Jr(o,h,s)}static Wr(s,e,n,i,r){if(0==s)return e;if(1==s)return r;let o=t.Jr(e,n,s),h=t.Jr(n,i,s);const c=t.Jr(i,r,s);return o=t.Jr(o,h,s),h=t.Jr(h,c,s),t.Jr(o,h,s)}static Jr(t,s,e){return t+e*(s-t)}},X={LINEAR:t=>t,EASE:t=>q.solveYValueFromXValue(t,0,0,.25,.1,.25,1,1,1),EASE_IN:t=>q.solveYValueFromXValue(t,0,0,.42,0,1,1,1,1),EASE_OUT:t=>q.solveYValueFromXValue(t,0,0,0,0,.58,1,1,1),EASE_IN_OUT:t=>q.solveYValueFromXValue(t,0,0,.42,0,.58,1,1,1)},K={"linear":X.LINEAR,"ease":X.EASE,"ease-in":X.EASE_IN,"ease-out":X.EASE_OUT,"ease-in-out":X.EASE_IN_OUT};function $(t){if(!t)return null;if("string"==typeof t){if(-1!=t.indexOf("cubic-bezier")){const r=t.match(/cubic-bezier\((.+)\)/);if(r){const t=r[1].split(",").map(parseFloat);if(4==t.length){for(let s=0;s<4;s++)if(isNaN(t[s]))return null;return s=t[0],e=t[1],n=t[2],i=t[3],t=>q.solveYValueFromXValue(t,0,0,s,e,n,i,1,1)}}return null}return K[t]}var s,e,n,i;return t}var j,W="Animation",J=function(){},B=class t{static animate(s,e,n,i){return new t(s).setCurve(i).add(0,e,1).start(n)}constructor(t,s){this.Qr=t,this.Xr=s||T(self,"vsync"),this.Zr=null,this.th=[]}setCurve(t){return t&&(this.Zr=$(t)),this}add(t,s,e,n){return this.th.push({delay:t,func:s,duration:e,curve:$(n)}),this}start(t){return new G(this.Xr,this.Qr,this.th,this.Zr,t)}},G=class{constructor(t,s,e,n,i){this.Xr=t,this.Qr=s,this.th=[];for(let t=0;t<e.length;t++){const s=e[t];this.th.push({delay:s.delay,func:s.func,duration:s.duration,curve:s.curve||n,started:!1,completed:!1})}this.ih=i,this.Or=Date.now(),this.pn=!0,this.yi={};const r=new class{constructor(){this.promise=new Promise(((t,s)=>{this.resolve=t,this.reject=s}))}};this.sh=r.promise,this.Ue=r.resolve,this.eh=r.reject,this.nh=this.Xr.createAnimTask(this.Qr,{mutate:this.rh.bind(this)}),this.Xr.canAnimate(this.Qr)?this.nh(this.yi):this.hh(!1,0)}then(t,s){return t||s?this.sh.then(t,s):this.sh}thenAlways(t){const s=t||J;return this.then(s,s)}halt(t){this.hh(!1,t||0)}hh(t,s){if(this.pn){if(this.pn=!1,0!=s){this.th.length>1&&this.th.sort(((t,s)=>t.delay+t.duration-(s.delay+s.duration)));try{if(s>0)for(let t=0;t<this.th.length;t++)this.th[t].func(1,!0);else for(let t=this.th.length-1;t>=0;t--)this.th[t].func(0,!1)}catch(s){m().error(W,"completion failed: "+s,s),t=!1}}t?this.Ue():this.eh()}}rh(t){if(!this.pn)return;const s=Date.now(),e=Math.min((s-this.Or)/this.ih,1);for(let t=0;t<this.th.length;t++){const s=this.th[t];!s.started&&e>=s.delay&&(s.started=!0)}for(let t=0;t<this.th.length;t++){const s=this.th[t];s.started&&!s.completed&&this.oh(s,e)}1==e?this.hh(!0,0):this.Xr.canAnimate(this.Qr)?this.nh(this.yi):this.hh(!1,0)}oh(t,s){let e,n;if(t.duration>0){if(e=Math.min((s-t.delay)/t.duration,1),n=e,t.curve&&1!=n)try{n=t.curve(e)}catch(t){return m().error(W,"step curve failed: "+t,t),void this.hh(!1,0)}}else e=1,n=1;1==e&&(t.completed=!0);try{t.func(n,t.completed)}catch(t){return m().error(W,"step mutate failed: "+t,t),void this.hh(!1,0)}}},Z="FixedLayer",Q="i-amphtml-lightbox",tt="i-amphtml-lightbox-element";function st(t){return-1!==t.tagName.indexOf("LIGHTBOX")}function et(t,s,e,n){let i=t,r=e,o=t=>{try{return r(t)}catch(t){var s,e;throw null===(s=(e=self).__AMP_REPORT_ERROR)||void 0===s||s.call(e,t),t}};const h=function(){if(void 0!==j)return j;j=!1;try{const t={get capture(){return j=!0,!1}};self.addEventListener("test-options",null,t),self.removeEventListener("test-options",null,t)}catch(t){}return j}(),c=!(null==n||!n.capture);return i.addEventListener(s,o,h?n:c),()=>{null==i||i.removeEventListener(s,o,h?n:c),r=null,i=null,o=null}}function nt(t,s,e,n){return et(t,s,e,n)}function it(t,s,e,n){let i=e;const r=et(t,s,(t=>{try{i(t)}finally{i=null,r()}}),n);return r}function rt(t){return"loading"!=t.readyState&&"uninitialized"!=t.readyState}function ot(t,s,e){return 0==s&&0==e||0==t.width&&0==t.height?t:{left:n=t.left+s,top:i=t.top+e,width:r=t.width,height:o=t.height,bottom:i+o,right:n+r,x:n,y:i};var n,i,r,o}function ht(t){return t.node.wholeText[t.offset]}var ct=/[,.\s\u2022()]/;function ut(t){return"’"==t||"‘"==t?"'":"“"==t||"”"==t?'"':t.toLowerCase()}function lt(t){const s=[];for(let e=0;e<t.length;e++){const n=t[e];ct.test(n)||s.push(ut(n))}return s.join("")}var at=class{constructor(t,s){this.rE=t,this.oE=s,this.matches=[],this.hE={},this.cE=t.length-1;for(let s=0;s<t.length;s++){const e=t[s];this.hE[e]=t.length-1-s}}update(){if(this.cE>0)return void this.cE--;const{oE:t,rE:s}=this,e=t.size();for(let n=0;n<s.length;n++){const i=ut(ht(t.get(e-1-n).pos));if(s[s.length-1-n]==i)continue;let r=this.hE[i];return null==r&&(r=s.length),r-=n,r<1&&(r=1),void(this.cE=r-1)}const n=t.get(e-1),i=n.pos;this.matches.push({start:t.get(e-s.length),end:{pos:{node:i.node,offset:i.offset+1},idx:n.idx+1}})}};function ft(t,s,e,n){for(let i=e;i<n.length;i++){const e=n[i];if(t.node!=e.start.node)return;if(e.start.node=s,e.start.offset-=t.offset,t.node!=e.end.node)return;e.end.node=s,e.end.offset-=t.offset}}function dt(t,s,e,n,i,r){for(;;){if(s.node==e.node){const o=_t(t,s.node,s.offset,e.offset,r);return void(o&&ft(e,o,i+1,n))}const o=pt(t,s.node);if(_t(t,s.node,s.offset,s.node.wholeText.length,r),!o)break;s={node:o,offset:0}}}function _t(t,s,e,n,i){if(e>=n)return null;const r=t.document,{parentNode:o,wholeText:h}=s;e>0&&o.insertBefore(r.createTextNode(h.substring(0,e)),s);const c=r.createElement("span");c.appendChild(r.createTextNode(h.substring(e,n))),o.insertBefore(c,s),i.push(c);let u=null;return n<h.length&&(u=r.createTextNode(h.substring(n)),o.insertBefore(u,s)),o.removeChild(s),u}function pt(t,s){let e=!0,n=s;for(;;){if(null==n)return null;if(e){const t=n.nextSibling;t?(n=t,e=!1):n=n.parentNode}else{if(n instanceof t.Text)return n;n.firstChild?n=n.firstChild:e=!0}}}var Pt=["key","code","location","ctrlKey","shiftKey","altKey","metaKey","repeat","isComposing","charCode","keyCode","which"],At="amp-viewer-messaging",mt="channelOpen",Et="__AMPHTML__";function gt(t){if("string"!=typeof t)return t;if("{"!=t.charAt(0))return null;try{return JSON.parse(t)}catch(t){return null}}var Tt,vt=class{constructor(t,s,e){this.i=t,this.h=s,this.o=e}addEventListener(t,s){this.i.addEventListener("message",(t=>{t.origin==this.h&&t.source==this.o&&s(t)}))}postMessage(t){const s="null"===this.h?"*":this.h;this.o.postMessage(t,s)}start(){}},wt=class t{static initiateHandshakeWithDocument(s,e){return new Promise((n=>{const i=setInterval((()=>{const r=new MessageChannel,o={app:Et,name:"handshake-poll"};s.postMessage(o,"*",[r.port2]);const h=r.port1,c=s=>{const r=gt(s.data);if(r&&r.app===Et&&r.name===mt){clearInterval(i),h.removeEventListener("message",c);const s=new t(null,h,!1,e,!0);s.t(r.requestid,mt,null),n(s)}};h.addEventListener("message",c),h.start()}),1e3)}))}static waitForHandshakeFromDocument(s,e,n,i,r){return new Promise((o=>{const h=c=>{const u=gt(c.data);if(u&&(c.origin==n||r&&r.test(c.origin))&&(!c.source||c.source==e)&&u.app===Et&&u.name===mt){s.removeEventListener("message",h);const n=new vt(s,c.origin,e),r=new t(null,n,!1,i,!0);r.t(u.requestid,mt,null),o(r)}};s.addEventListener("message",h)}))}constructor(t,s,e,n,i){this.i=t,this.l=s,this.u=!!e,this._=n||null,this.p=!!i,this.g=0,this.m={},this.P={},this.A=null,this.l.addEventListener("message",this.R.bind(this)),this.l.start()}registerHandler(t,s){this.P[t]=s}unregisterHandler(t){delete this.P[t]}setDefaultHandler(t){this.A=t}R(t){const s=gt(t.data);s&&s.app===Et&&(this._&&this.p&&s.messagingToken!==this._?this.M(At+": handleMessage_ error: ","invalid token"):"q"===s.type?this.q(s):"s"===s.type&&this.v(s))}sendRequest(t,s,e){const n=++this.g;let i;return e&&(i=new Promise(((t,s)=>{this.m[n]={resolve:t,reject:s}}))),this.I({app:Et,requestid:n,type:"q",name:t,data:s,rsvp:e}),i}t(t,s,e){this.I({app:Et,requestid:t,type:"s",name:s,data:e})}T(t,s,e){const n=this.V(e);this.M(At+": sendResponseError_, message name: "+s,n),this.I({app:Et,requestid:t,type:"s",name:s,data:null,error:n})}I(t){const s=Object.assign(t,{});this._&&!this.p&&(s.messagingToken=this._),this.l.postMessage(this.u?JSON.stringify(s):s)}q(t){let s=this.P[t.name];if(s||(s=this.A),!s){const s=new Error("Cannot handle request because no default handler is set!");throw s.args=t.name,s}const e=s(t.name,t.data,!!t.rsvp);if(t.rsvp){const s=t.requestid;if(!e)throw this.T(s,t.name,new Error("no response")),new Error("expected response but none given: "+t.name);e.then((e=>{this.t(s,t.name,e)}),(e=>{this.T(s,t.name,e)}))}}v(t){const s=t.requestid,e=this.m[s];e&&(delete this.m[s],t.error?(this.M(At+": handleResponse_ error: ",t.error),e.reject(new Error(`Request ${t.name} failed: ${t.error}`))):e.resolve(t.data))}M(t,s){if(!this.i)return;let e="amp-messaging-error-logger: "+t;e+=" data: "+this.V(s),this.i.viewerState=e}V(t){return t?t.message?t.message:String(t):"unknown error"}},Mt=["altKey","charCode","ctrlKey","detail","eventPhase","key","layerX","layerY","metaKey","pageX","pageY","returnValue","shiftKey","timeStamp","type","which"],yt=["clientX","clientY","force","identifier","pageX","pageY","radiusX","radiusY","screenX","screenY"],It=(()=>self.AMP.config.urls)(),Rt=new Set(["c","v","a","ad"]),Vt=t=>"string"==typeof t?function(t,s){return Tt||(Tt=self.document.createElement("a")),function(t,s,e){return t.href="",new URL(s,t.href)}(Tt,t)}(t):t;new class{constructor(t){this.win=t,this.uE=!1,this.lE=!1,this.aE=null}init(){const t=w(this.win.document),s=b(t);this.uE="1"==s.getParam("webview"),this.lE=s.hasCapability("handshakepoll");const n=s.getParam("messagingToken"),r=s.getParam("origin")||"";if(!this.uE&&!r)return e();if(x(t).createFixedLayer(class{constructor(t,s,e,n,i){this.ampdoc=t,this.Xr=s,this.fE=e,this.mh=n,this.dE=n,this._E=i&&t.isSingleDoc(),this.pE=null,this.PE=0,this.St=[],this.AE=new class{constructor(t,s,e){this.ln=y(t,"timer"),this.cn=s,this.an=e||0,this.dn=-1,this.fn=0,this.pn=!1,this.mn=()=>{this._n()}}isPending(){return-1!=this.dn}schedule(t){let s=t||this.an;this.pn&&s<10&&(s=10);const e=Date.now()+s;return(!this.isPending()||e-this.fn<-10)&&(this.cancel(),this.fn=e,this.dn=this.ln.delay(this.mn,s),!0)}_n(){this.dn=-1,this.fn=0,this.pn=!0,this.cn(),this.pn=!1}cancel(){this.isPending()&&(this.ln.cancel(this.dn),this.dn=-1)}}(t.win,(()=>this.update())),this.mE=null,this.EE=[],this.gE=[]}enterLightbox(t,s){const e=this.TE();e&&e.setLightboxMode(!0),t&&s&&s.then((()=>this.vE(t,!0)))}leaveLightbox(){const t=this.TE();t&&t.setLightboxMode(!1);const s=function(t,s){const e=[];let n=0;for(let s=0;s<t.length;s++){const i=t[s];i.lightboxed?e.push(i):(n<s&&(t[n]=i),n++)}return n<t.length&&(t.length=n),e}(this.St);this.wE(s),this.St.length||this.ME()}setup(){if(!b(this.ampdoc).isEmbedded())return!1;const t=this.ampdoc.getRootNode(),s=t.styleSheets;if(!s)return!0;this.EE.length=0,this.gE.length=0;for(let t=0;t<s.length;t++){const e=s[t];if(!e)return m().error(Z,"Aborting setup due to null stylesheet."),!0;const{disabled:n,ownerNode:i}=e;n||!i||"STYLE"!=i.tagName||i.hasAttribute("amp-boilerplate")||i.hasAttribute("amp-runtime")||i.hasAttribute("amp-extension")||this.yE(e.cssRules)}this.vE(t),this.St.length>0&&this.observeHiddenMutations();const e=V(this.ampdoc.win);return this.St.length>0&&!this._E&&e.isIos(),!0}vE(t,s){this.IE(t,s),this.RE(),this.update()}observeHiddenMutations(){this.VE()}ME(){this.AE.cancel();const t=this.mE;t&&(t(),this.mE=null)}VE(){if(this.mE)return;const t=this.ampdoc.getRootNode(),s=(t=>function(t,s){const e=M(w(t));return I(e,s)?y(e,s):null}(t,"hidden-observer"))(t.documentElement||t);this.mE=s.add((()=>{this.AE.isPending()||this.AE.schedule(16)}))}updatePaddingTop(t,s){this.mh=t,s||(this.dE=t),this.update()}transformMutate(t){t?this.St.forEach((s=>{s.fixedNow&&s.top&&(O(s.element,"transition","none"),s.transform&&"none"!=s.transform?O(s.element,"transform",s.transform+" "+t):O(s.element,"transform",t))})):this.St.forEach((t=>{t.fixedNow&&t.top&&L(t.element,{transform:"",transition:""})}))}addElement(t,s){return this.bE(t,"*","fixed",s)?(this.RE(),this.observeHiddenMutations(),this.update()):e()}removeElement(t){const s=this.xE(t);this.wE(s)}wE(t){t.length>0&&this.pE&&this.Xr.mutate((()=>{for(let s=0;s<t.length;s++){const e=t[s];"fixed"==e.position&&this.pE.returnFrom(e)}}))}isDeclaredFixed(t){return!!t.__AMP_DECLFIXED}isDeclaredSticky(t){return!!t.__AMP_DECLSTICKY}update(){if(this.St.filter((t=>!this.ampdoc.contains(t.element))).forEach((t=>this.xE(t.element))),0==this.St.length)return e();this.AE.cancel();let t=!1;return this.Xr.runPromise({measure:s=>{const e=this.St,n=[],{win:r}=this.ampdoc;for(let t=0;t<e.length;t++)H(e[t].element,{top:"",bottom:"-9999vh",transition:"none"});for(let t=0;t<e.length;t++)n.push(D(r,e[t].element).top);for(let t=0;t<e.length;t++)O(e[t].element,"bottom","");for(let o=0;o<e.length;o++){const h=e[o],{element:c,forceTransfer:u}=h,l=D(r,c),{offsetHeight:a,offsetTop:f,offsetWidth:d}=c,{bottom:_,display:p="",position:P="",zIndex:A}=l,m=parseFloat(l.opacity),E=l[N(l,"transform")];let{top:g}=l;const T="fixed"===P&&(u||d>0&&a>0),v=i(P,"sticky");if("none"===p||!T&&!v){s[h.id]={fixed:!1,sticky:!1,transferrable:!1,top:"",zIndex:""};continue}"auto"!==g&&n[o]===g||(g=T&&f===this.dE+this.fE?"0px":"");let w=!1;T&&(w=!0===u||!1!==u&&m>0&&a<300&&!(!g&&!_)),w&&(t=!0),s[h.id]={fixed:T,sticky:v,transferrable:w,top:g,zIndex:A,transform:E}}},mutate:s=>{t&&this._E&&this.TE().update();const e=this.St;for(let t=0;t<e.length;t++){const n=e[t],i=s[n.id];O(n.element,"transition","none"),O(n.element,"transition",""),i&&this.kE(n,t,i)}}},{}).catch((t=>{m().error(Z,"Failed to mutate fixed elements:",t)}))}IE(t,s){try{this.SE(t,s)}catch(t){m().error(Z,"Failed to setup fixed elements:",t)}}SE(t,s){for(let e=0;e<this.EE.length;e++){const n=this.EE[e],i=t.querySelectorAll(n);for(let t=0;t<i.length&&!(this.St.length>10);t++)this.bE(i[t],n,"fixed",void 0,s)}for(let e=0;e<this.gE.length;e++){const n=this.gE[e],i=t.querySelectorAll(n);for(let t=0;t<i.length;t++)this.bE(i[t],n,"sticky",void 0,s)}}FE(t){t.hasAttribute("style")&&(C(t,"top")||C(t,"bottom"))&&P().error(Z,"Inline styles with `top`, `bottom` and other CSS rules are not supported yet for fixed or sticky elements (#14186). Unexpected behavior may occur.",t)}bE(t,s,e,n,i){if(n||this.FE(t),st(t))return!1;const r=function(t,s,e){let n;for(n=t;n&&void 0!==n;n=n.parentElement)if(s(n))return n;return null}(t,st);if(!i&&r)return!1;const o=this.St,h=[];for(let s=0;s<o.length;s++){const e=o[s].element;if(e===t)break;if(e.contains(t))return!1;t.contains(e)&&h.push(e)}for(let t=0;t<h.length;t++)this.removeElement(h[t]);let c=null;for(let s=0;s<o.length;s++){const n=o[s];if(n.element==t&&n.position==e){c=n;break}}const u="fixed"==e;if(c)c.selectors.includes(s)||c.selectors.push(s);else{const n="F"+this.PE++;t.setAttribute("i-amphtml-fixedid",n),u?t.__AMP_DECLFIXED=!0:t.__AMP_DECLSTICKY=!0,c={id:n,element:t,position:e,selectors:[s],fixedNow:!1,stickyNow:!1,lightboxed:!!r},o.push(c)}return c.forceTransfer=!!u&&n,!0}xE(t){const s=[];for(let e=0;e<this.St.length;e++){const n=this.St[e];n.element===t&&(n.lightboxed||this.Xr.mutate((()=>{O(t,"top","")})),this.St.splice(e,1),s.push(n))}return this.St.length||this.ME(),s}RE(){this.St.sort(((t,s)=>{return(e=t.element)===(n=s.element)?0:e.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_PRECEDING|Node.DOCUMENT_POSITION_CONTAINS)?1:-1;var e,n}))}kE(t,s,e){const{element:n,fixedNow:i}=t;t.fixedNow=e.fixed,t.stickyNow=e.sticky,t.top=e.fixed||e.sticky?e.top:"",t.transform=e.transform,!i||e.fixed&&e.transferrable||!this.pE||this.pE.returnFrom(t),e.top&&(e.fixed||e.sticky)&&!t.lightboxed&&(e.fixed||!this._E?O(n,"top",`calc(${e.top} + ${this.mh}px)`):this.dE===this.mh?O(n,"top",e.top):O(n,"top",`calc(${e.top} - ${this.dE}px)`)),this._E&&e.fixed&&e.transferrable&&this.TE().transferTo(t,s,e)}TE(){if(!this._E||this.pE)return this.pE;const t=this.ampdoc.win.document;return this.pE=new class{constructor(t,s){var e;this._f=t,this.Xr=s,this.NE=t.body.cloneNode(!1),this.NE.removeAttribute("style"),L(this.NE,("display"in(e={position:"absolute",top:0,left:0,height:0,width:0,pointerEvents:"none",overflow:"hidden",animation:"none",background:"none",border:"none",borderImage:"none",boxSizing:"border-box",boxShadow:"none",float:"none",margin:0,opacity:1,outline:"none",padding:"none",transform:"none",transition:"none"})&&d("STYLE","`display` style detected. You must use toggle instead."),e)),U(this.NE,"block"),t.documentElement.appendChild(this.NE)}getRoot(){return this.NE}setLightboxMode(t){this.Xr.mutate((()=>{const s=this.getRoot();t?s.setAttribute(Q,""):s.removeAttribute(Q)}))}update(){const{body:t}=this._f,s=this.NE,e=t.attributes,n=s.attributes;for(let t=0;t<e.length;t++){const s=e[t];"style"!==s.name&&n.setNamedItem(s.cloneNode(!1))}for(let e=0;e<n.length;e++){const{name:i}=n[e];"style"===i||i===Q||t.hasAttribute(i)||(s.removeAttribute(i),e--)}}transferTo(t,s,e){const{element:n}=t;if(n.parentElement!=this.NE){if(!t.placeholder){O(n,"pointer-events","initial");const s=t.placeholder=this._f.createElement("i-amphtml-fpa");!function(t,s){void 0===s&&(s=t.hasAttribute("hidden")),s?t.removeAttribute("hidden"):t.setAttribute("hidden","")}(s,!1),s.setAttribute("i-amphtml-fixedid",t.id)}O(n,"zIndex",`calc(${1e4+s} + ${e.zIndex||0})`),t.lightboxed&&n.classList.add(tt),n.parentElement.replaceChild(t.placeholder,n),this.NE.appendChild(n),t.selectors.some((t=>this.HE(n,t)))||this.returnFrom(t)}}returnFrom(t){if(!t.placeholder||!this._f.contains(t.placeholder))return;const{element:s,placeholder:e}=t;t.lightboxed&&s.classList.remove(tt),this._f.contains(s)?(O(t.element,"zIndex",""),e.parentElement.replaceChild(s,e)):e.parentElement.removeChild(e)}HE(t,s){try{return function(t,s){return t.matches(s)}(t,s)}catch(t){return m().error(Z,"Failed to test query match:",t),!1}}}(t,this.Xr),this.pE}yE(t){for(let s=0;s<t.length;s++){const e=t[s];if(4!=e.type&&12!=e.type){if(1==e.type){const{selectorText:t}=e,{position:s}=e.style;if("*"===t||!s)continue;"fixed"===s?this.EE.push(t):i(s,"sticky")&&this.gE.push(t)}}else this.yE(e.cssRules)}}animateFixedElements(t,s,n,i,r){return this.updatePaddingTop(t,r),n<=0?e():B.animate(this.ampdoc.getRootNode(),(e=>{const n=(e=>s-t+(t-s)*e)(e);this.transformMutate(`translateY(${n}px)`)}),n,i).thenAlways((()=>{this.transformMutate(null)}))}}),this.uE||this.lE){const e=(o=this.win).parent&&o.parent!=o?this.win.parent:null;return this.OE(e,r).then((e=>this.CE(s,t,r,new wt(this.win,e,this.uE,n))))}var o;const c=function(t){const s=function(t){const s=h();if(!t)return s;let e;for(;e=u.exec(t);){const t=l(e[1],e[1]),n=e[2]?l(e[2].replace(/\+/g," "),e[2]):"";s[t]=n}return s}(t.win.location.hash).highlight;if(!s||s.length>102400)return null;const e=(n=s,JSON.parse(n));var n;const i=e.s;if(!(i instanceof Array)||i.length>15)return null;let r=0;for(let t=0;t<i.length;t++){const s=i[t];if("string"!=typeof s||!s)return null;if(r+=s.length,r>1500)return null}let o=!1;e.n&&(o=!0);let c=!1;return e.na&&(c=!0),{sentences:i,skipScrollAnimation:c,skipRendering:o}}(t);c&&(this.aE=new class{constructor(t,s){this.zi=t,this.yn=b(t),this.Il=x(this.zi),this.LE=null;const e=V(this.zi.win);var n;"fragmentDirective"in document&&e.isChrome()&&e.getMajorVersion()>=93?t.whenFirstVisible().then((()=>this.UE(s))):(n=t.win.document,new Promise((t=>{!function(t,s){!function(t,s,e){let n=s(t);if(n)e(t);else{const i=()=>{s(t)&&(n||(n=!0,e(t)),t.removeEventListener("readystatechange",i))};t.addEventListener("readystatechange",i)}}(t,rt,s)}(n,t)}))).then((()=>{this.DE(s)}))}UE(t){const{sentences:s}=t;if(null==s||!s.length)return;const e=s.map((t=>"text="+encodeURIComponent(t))).join("&");this.zE(e)}zE(t){const{hash:s}=this.zi.win.location;s?this.zi.win.location.replace(s+":~:"+t):this.zi.win.location.replace("#:~:"+t)}YE(t,s){const e={"state":t};for(const t in s)e[t]=s[t];this.yn.sendMessage("highlightState",e)}qE(t){const{win:s}=this.zi,e=function(t,s,e){if(e=function(t){const s=[];for(let e=0;e<t.length;e++){const n=lt(t[e]);n&&s.push(n)}return s}(e),e.length<=0)return null;const n=new class t{constructor(s,e){if(this.i=s,this.XE=e,this.KE=-1,this.$E=null,e instanceof s.Text)this.KE=0;else if(e instanceof s.Element){const{display:n}=D(s,e);if("none"==n)return;const i=e.firstChild;null!=i&&(this.$E=new t(s,i))}}next(){if(this.KE>=0)return this.jE();for(;null!=this.$E;){const s=this.$E.next();if(null!=s)return s;const e=this.$E.XE.nextSibling;this.$E=null!=e?new t(this.i,e):null}return null}jE(){const t=this.XE.wholeText;if(this.KE<t.length){const t=this.KE;return this.KE++,{node:this.XE,offset:t}}return null}}(t,s),i=new class{constructor(t){this.WE=t,this.JE=[],this.Pn=0}push(t){this.JE[this.Pn]=t,this.Pn=(this.Pn+1)%this.WE}get(t){return this.JE.length>=this.WE&&(t=(this.Pn+t)%this.WE),this.JE[t]}size(){return this.JE.length}}(e.map((t=>t.length)).reduce(((t,s)=>Math.max(t,s)))),r=[new at(e[0],i)];let o=-1;for(;;){o++;const t=n.next();if(null==t)return null;if(!ct.test(ht(t))){i.push({pos:t,idx:o});for(let t=0;t<r.length;t++)r[t].update();if(0!=r[r.length-1].matches.length){if(r.length==e.length)break;r.push(new at(e[r.length],i))}}}const h=[];t:for(let t=e.length-1;t>=0;t--){const s=r[t].matches;if(0==h.length){h.push(s[s.length-1]);continue}const e=h[h.length-1];for(let t=s.length-1;t>=0;t--){const n=s[t];if(e.start.idx>=n.end.idx){h.push(n);continue t}}E(!1)}const c=[];for(let t=h.length-1;t>=0;t--){const s=h[t];c.push({start:s.start.pos,end:s.end.pos})}return c}(s,this.zi.getBody(),t.sentences);if(!e)return;const n=function(t,s){s=function(t){const s=[];let e=null;for(let n=0;n<t.length;n++){const i=t[n];e&&e.end.node==i.start.node&&e.end.offset==i.start.offset?e.end=i.end:(e=i,s.push(i))}return s}(s);const e=[];for(let n=0;n<s.length;n++){const i=s[n];dt(t,i.start,i.end,s,n,e)}return e}(s,e);n&&0!=n.length&&(this.LE=n)}onVisibleOnce(t){t=function(t){let s=!1,e=null,n=t;return(...t)=>(s||(e=n.apply(self,t),s=!0,n=null),e)}(t),this.zi.onVisibilityChanged((()=>{"visible"==this.zi.getVisibilityState()&&t()}))}DE(t){if(this.zi.win.document.querySelector('script[id="amp-access"]'))return void this.YE("has_amp_access");if(this.qE(t),!this.LE)return void this.YE("not_found");const s=this.BE();if(this.YE("found",{"scroll":s}),t.skipRendering)return;for(let t=0;t<this.LE.length;t++)L(this.LE[t],{backgroundColor:"#fcff00",color:"#000"});const e=this.zi.getVisibilityState();t.skipScrollAnimation?"visible"==e?this.GE(s):(this.Il.setScrollTop(s),this.onVisibleOnce((()=>{this.GE(this.BE())}))):"visible"==e?this.ZE(s):(this.QE(s),this.onVisibleOnce((()=>{this.ZE(this.BE())}))),it(this.zi.getBody(),"click",this.tT.bind(this))}BE(){const t=this.LE;if(!t)return 0;const s=this.Il;let e=Number.MAX_VALUE,n=0;const i=s.getPaddingTop();for(let r=0;r<t.length;r++){const{bottom:o,top:h}=ot(s.getLayoutRect(t[r]),0,-i);e=Math.min(e,h),n=Math.max(n,o)}if(e>=n)return 0;let r=(n+e-(s.getHeight()-i))/2;return r>e-80&&(r=e-80),r>0?r:0}GE(t){this.YE("auto_scroll"),this.Il.setScrollTop(t),this.YE("shown")}QE(t){const s=Math.max(0,t-500);this.Il.setScrollTop(s)}sT(t){const s=this.BE(),e=this.Il.getScrollTop();if(e==s&&e==t)return null;const n={};return e!=s&&(this.Il.setScrollTop(s),n.nd=e-s),e!=t&&(n.od=e-t),n}ZE(t){this.QE(t);const s=this.zi.win.document.createElement("div");U(s,"block"),L(s,{"position":"absolute","top":Math.floor(t)+"px","height":"1px","left":"0","width":"1px","pointer-events":"none"});const e=this.zi.getBody();e.appendChild(s),this.YE("auto_scroll"),this.Il.animateScrollIntoView(s).then((()=>{e.removeChild(s),this.YE("shown",this.sT(t))}))}setupMessaging(t){t.registerHandler("highlightDismiss",this.tT.bind(this))}tT(){if(this.LE)for(let t=0;t<this.LE.length;t++)z(this.LE[t],["backgroundColor","color"])}}(t,c));const a=new vt(this.win,r,this.win.parent);return this.CE(s,t,r,new wt(this.win,a,this.uE,n))}OE(t,s){return new Promise((e=>{const n=nt(this.win,"message",(i=>{const r=gt(i.data);if(r&&i.origin===s&&i.source===t&&"__AMPHTML__"==r.app&&"handshake-poll"==r.name){if(this.uE&&(!i.ports||!i.ports.length))throw new Error("Did not receive communication port from the Viewer!");const t=i.ports&&i.ports.length>0?i.ports[0]:new vt(this.win,s,this.win.parent);e(t),n()}}))}))}CE(t,s,e,n){const i=s.getUrl(),r=function(t){if(!function(t){return It.cdnProxyRegex.test(Vt(t).origin)}(t=Vt(t)))return t.href;const s=t.pathname.split("/"),e=s[1];g(Rt.has(e),"Unknown path prefix in url %s",t.href);const n=s[2],i="s"==n?"https://"+decodeURIComponent(s[3]):"http://"+decodeURIComponent(n);return g(i.indexOf(".")>0,"Expected a . in origin %s",i),s.splice(1,"s"==n?3:2),i+s.join("/")+function(t,s){if(!t||"?"==t)return"";const e=new RegExp("[?&](amp_(js[^&=]*|gsa|r|kit)|usqp)\\b[^&]*","g"),n=t.replace(e,"").replace(/^[?&]/,"");return n?"?"+n:""}(t.search)+(t.hash||"")}(i);return n.sendRequest("channelOpen",{"url":i,"sourceUrl":r},!0).then((()=>{this.Ah(n,t,e)}))}Ah(t,s,e){t.setDefaultHandler(((t,e,n)=>s.receiveMessage(t,e,n))),s.setMessageDeliverer(t.sendRequest.bind(t),e),it(this.win,"unload",this.eT.bind(this,t)),(s.hasCapability("swipe")||s.hasCapability("touch"))&&this.nT(t),s.hasCapability("keyboard")&&this.iT(t),s.hasCapability("focus-rect")&&this.rT(t),null!=this.aE&&this.aE.setupMessaging(t)}eT(t){return t.sendRequest("unloaded",{},!0)}rT(t){new class{constructor(t,s){this.win=t,this.S=s,this.oT()}oT(){nt(this.win.document,"focusin",this.hT.bind(this),{capture:!1})}hT(t){t.defaultPrevented||this.S.sendRequest(t.type,{"focusTargetRect":t.target.getBoundingClientRect()},!1)}}(this.win,t)}nT(t){new class{constructor(t,s){this.win=t,this.S=s,this.cT=!1,this.uT=[],s.registerHandler("scrollLock",this.lT.bind(this)),this.aT()}aT(){const t=this.my.bind(this),s=this.win.document,e={capture:!1,passive:!this.cT};this.uT.push(nt(s,"touchstart",t,e),nt(s,"touchend",t,e),nt(s,"touchmove",t,e))}xv(){this.uT.forEach((t=>t())),this.uT.length=0}my(t){switch(t.type){case"touchstart":case"touchend":case"touchmove":this.fT(t);break;default:return}}fT(t){if(null!=t&&t.shouldViewerCancelPropagation)t.stopImmediatePropagation();else{if(t&&t.type){const s=this.dT(t);this.S.sendRequest(t.type,s,!1)}this.cT&&t.cancelable&&t.preventDefault()}}dT(t){const s=this._T(t,Mt);return t.touches&&(s.touches=this.pT(t.touches)),t.changedTouches&&(s.changedTouches=this.pT(t.changedTouches)),s}pT(t){const s=[];for(let e=0;e<t.length;e++)s.push(this._T(t[e],yt));return s}_T(t,s){const e={};for(let n=0;n<s.length;n++){const i=s[n];void 0!==t[i]&&(e[i]=t[i])}return e}lT(t,s,e){return this.cT=!!s,this.xv(),this.aT(),e?Promise.resolve({}):void 0}}(this.win,t)}iT(t){new class{constructor(t,s){this.win=t,this.S=s,this.PT()}PT(){const t=this.my.bind(this);nt(this.win,"keydown",t),nt(this.win,"keypress",t),nt(this.win,"keyup",t)}my(t){(function(t){if(t.defaultPrevented)return!0;if("Escape"==t.key)return!1;switch(t.target.nodeName){case"INPUT":return"checkbox"!=t.target.type||" "==t.key;case"TEXTAREA":case"BUTTON":case"SELECT":case"OPTION":return!0}return t.target.hasAttribute&&t.target.hasAttribute("contenteditable")})(t)||this.hT(t)}hT(t){this.S.sendRequest(t.type,function(t){const s={};return Pt.forEach((e=>{void 0!==t[e]&&(s[e]=t[e])})),s}(t),!1)}}(this.win,t)}}(t.win).init()})();
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}});
//# sourceMappingURL=amp-viewer-integration-0.1.mjs.map