;
(self.AMP=self.AMP||[]).push({m:1,v:"2601162341000",n:"amp-gwd-animation",ev:"0.1",l:!0,f:function(t,n){(()=>{var{isArray:n}=Array,{hasOwnProperty:i,toString:e}=Object.prototype;function s(t,n){return i.call(t,n)}function o(t){return(t.ownerDocument||t).defaultView}function r(t){return CSS.escape(t)}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var a=self.__AMP_LOG;function c(t){return a.user||(a.user=u()),function(t,n){return n&&n.ownerDocument.defaultView!=t}(a.user.win,t)?a.userForEmbed||(a.userForEmbed=u()):a.user}function u(t){return function(t,n){throw new Error("failed to call initLogConstructor")}()}function l(t,n,i,e,s,o,r,a,c,u,l){return t}function h(t,n,i,e,s,o,r,a,u,l,h){return c().assert(t,n,i,e,s,o,r,a,u,l,h)}function d(t,n){const i=function(t){const n=g(t);return n.isSingleDoc()?n.win:n}(g(t));return m(i,n)?_(i,n):null}function f(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}function g(t){return t.nodeType?(n=o(t),function(t,n){return _(t=f(t),"ampdoc")}(n)).getAmpDoc(t):t;var n}function _(t,n){l(m(t,n));const i=function(t){let n=t.__AMP_SERVICES;return n||(n=t.__AMP_SERVICES={}),n}(t)[n];return i.obj||(l(i.ctor),l(i.context),i.obj=new i.ctor(i.context),l(i.obj),i.context=null,i.resolve&&i.resolve(i.obj)),i.obj}function m(t,n){const i=t.__AMP_SERVICES&&t.__AMP_SERVICES[n];return!(!i||!i.ctor)}var P=t=>d(t,"action"),A="gwd-page-wrapper",v="gwd-pause-animation",E="gwd-play-animation",p="data-gwd-label-animation",w="gwd.timelineEvent",T=["animationend","webkitAnimationEnd"],b="__AMP_GWD_GOTO_COUNTERS__",R="GWD",I="amp-gwd-animation",M={"play":["args.id"],"pause":["args.id"],"togglePlay":["args.id"],"gotoAndPlay":["args.id","args.label"],"gotoAndPause":["args.id","args.label"],"gotoAndPlayNTimes":["args.id","args.label","args.N","event.detail.eventName"],"setCurrentPage":["args.index"]},y=class extends t.BaseElement{constructor(t){super(t),this.J$="",this.Q$=null,this.Z$=this.tW.bind(this)}buildCallback(){this.J$=this.element.getAttribute("timeline-event-prefix")||"";const t=function(t,n){const i=(t.ownerDocument||t).defaultView,e=n||f(i);if(i&&i!=e&&f(i)==e)try{return i.frameElement}catch(t){}return null}(this.element,this.getAmpDoc().win);t&&(this.Q$=t.__AMP_EMBED__),this.NV().addEventListener(w,this.Z$,!0);const n=this.nW();if(n){h(this.element.id,`The ${I} element must have an id.`);const t=`${this.element.id}.setCurrentPage(index=event.index)`;!function(t,n,i,e){let s;const o=n.getAttribute("on")||"",r="slideChange:",a=o.indexOf(r);if(-1!=a){const t=a+r.length;s=o.substr(0,t)+e+","+o.substr(t)}else s=o,s&&(s+=";"),s+=`slideChange:${e}`;P(t).setActions(n,s)}(this.element,n,0,t)}const i=this.iW.bind(this);for(const t in M)this.registerAction(t,i)}NV(){return this.Q$?this.Q$.win.document:this.getAmpDoc().getRootNode()}nW(){return this.NV().getElementById("pagedeck")}iW(t){this.eW(t)&&this.sW(t)}eW(t){if("setCurrentPage"==t.method){const n=this.nW();return n&&t.source==n}return!0}sW(t){const n=h(d(this.element,"gwd"),"Cannot execute action because the GWD service is not registered."),i=M[t.method].map((n=>function(t,n){const i=n.split(".");let e=t;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!e||void 0===e[n]){e=void 0;break}e=e[n]}return e}(t,n)));n[t.method].apply(n,i)}tW(t){const n=P(this.element),i=function(t){return t.detail}(t).eventName,e=`${this.J$}${i}`;n.trigger(this.element,e,t,3)}detachedCallback(){return this.NV().removeEventListener(w,this.Z$,!0),!0}};t.registerServiceForDoc("gwd",class{constructor(t){this.zi=t,this.i=t.win,this._f=this.i.document,this.oW=this.rW.bind(this),t.whenReady().then((()=>{const t=this._f.body;!function(t,n,i){if(n())i();else{const e=new(o(t).MutationObserver)((()=>{n()&&(e.disconnect(),i())}));e.observe(t,{childList:!0})}}(t,(()=>!!t.querySelector(`.${r(A)}`)),this.Ze.bind(this))}))}Ze(){this.aW(),this.setCurrentPage(0)}setEnabled(t){this._f.body.classList.toggle("i-amphtml-gwd-animation-disabled",!t)}setCurrentPage(t){const n=this._f.body.querySelectorAll(`.${r(A)}`);if(0==n.length)return;const i=(e=`.${r(A)}.${r(E)}`,this._f.body.querySelector(function(t,n){return t.replace(/^|,/g,"$&:scope ")}(e)));var e;i&&this.cW(i);const s=n[t];s?this.uW(s):c().error(R,"Could not find page with index "+t+".")}uW(t){t.classList.add(E)}cW(t){var n;t.classList.remove(E),[t].concat((n=t.querySelectorAll("*"),n?Array.prototype.slice.call(n):[])).forEach((t=>this.lW(t)))}lW(t){if(t.classList.remove(v),t.hasAttribute(p)){const n=t.getAttribute(p);t.classList.remove(n),t.removeAttribute(p)}delete t[b]}play(t){const n=this.getReceiver(t);n&&n.classList.remove(v)}pause(t){const n=this.getReceiver(t);n&&n.classList.add(v)}togglePlay(t){const n=this.getReceiver(t);n&&n.classList.toggle(v)}gotoAndPlay(t,n){const i=this.getReceiver(t);i&&this.hW(i,n)}gotoAndPause(t,n){const i=this.getReceiver(t);i&&(this.hW(i,n),this.i.setTimeout((()=>{this.pause(t)}),40))}gotoAndPlayNTimes(t,n,i,e){if(i<=0)return void c().error(R,`Invalid maxCount parameter: ${i}`);if(!e)return void c().error(R,"Event name required but not specified.");const o=this.getReceiver(t);if(!o)return;const r=`${e}_${n}`,a=function(t,n){return t[b]&&s(t[b],n)?t[b][n]:0}(o,r);a<i&&(this.hW(o,n),function(t,n,i){t[b]||(t[b]={}),s(t[b],n)||(t[b][n]=0),t[b][n]=i}(o,r,a+1))}getReceiver(t){if("document.body"==t)return this._f.body;const n=this._f.getElementById(t);return n&&n.classList?n:(c().error(R,`Could not get receiver with id ${t}.`),null)}hW(t,n){t.classList.remove(v);const i=t.getAttribute(p);i&&(t.classList.remove(i),t.removeAttribute(p)),i==n&&function(t){const n="__AMP_GWD_TEMP";self[n]=t.offsetWidth,delete self[n]}(t),t.classList.add(n),t.setAttribute(p,n)}rW(t){const n=t.target.getAttribute("data-event-name");if(!n)return;const i={"eventName":n,"sourceEvent":t},e=function(t,n,i,e){const s={detail:i};return Object.assign(s,void 0),new t.CustomEvent("gwd.timelineEvent",s)}(this.i,0,i);this._f.dispatchEvent(e)}aW(){for(let t=0;t<T.length;t++)this._f.body.addEventListener(T[t],this.oW,!0)}dW(){for(let t=0;t<T.length;t++)this._f.body.removeEventListener(T[t],this.oW,!0)}dispose(){this.dW()}}),t.registerElement(I,y,".i-amphtml-gwd-animation-disabled [class*=-animation],.i-amphtml-gwd-animation-disabled [class*=gwdanimation]{animation:none!important}\n/*# sourceURL=/extensions/amp-gwd-animation/0.1/amp-gwd-animation.css*/")})();
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}});
//# sourceMappingURL=amp-gwd-animation-0.1.mjs.map