@ussebastian/kitdigital
Version:
Kit Digital de la Universidad San Sebastián
3 lines (2 loc) • 19.1 kB
JavaScript
/*! @ussebastian/kitdigital v0.12.16 | MIT (c) Asimov Consultores SpA - 2024 */
function n(n){return"number"==typeof n}function t(n){return"string"==typeof n}function e(n){return"boolean"==typeof n}function o(n){return"[object Object]"===Object.prototype.toString.call(n)}function r(n){return Math.abs(n)}function i(n){return Math.sign(n)}function c(n,t){return r(n-t)}function u(n){return f(n).map(Number)}function s(n){return n[a(n)]}function a(n){return Math.max(0,n.length-1)}function l(n,t){return t===a(n)}function d(n,t=0){return Array.from(Array(n),((n,e)=>t+e))}function f(n){return Object.keys(n)}function p(n,t){return[n,t].reduce(((n,t)=>(f(t).forEach((e=>{const r=n[e],i=t[e],c=o(r)&&o(i);n[e]=c?p(r,i):i})),n)),{})}function g(n,t){return void 0!==t.MouseEvent&&n instanceof t.MouseEvent}function m(){let n=[];const t={add:function(e,o,r,i={passive:!0}){let c;if("addEventListener"in e)e.addEventListener(o,r,i),c=()=>e.removeEventListener(o,r,i);else{const n=e;n.addListener(r),c=()=>n.removeListener(r)}return n.push(c),t},clear:function(){n=n.filter((n=>n()))}};return t}function h(n,t,e,o){const i=m(),c=1e3/60;let u=null,s=0,a=0;function l(n){if(!a)return;u||(u=n);const i=n-u;for(u=n,s+=i;s>=c;)e(),s-=c;const d=r(s/c);o(d),a&&t.requestAnimationFrame(l)}function d(){t.cancelAnimationFrame(a),u=null,s=0,a=0}return{init:function(){i.add(n,"visibilitychange",(()=>{n.hidden&&(u=null,s=0)}))},destroy:function(){d(),i.clear()},start:function(){a||(a=t.requestAnimationFrame(l))},stop:d,update:e,render:o}}function x(n=0,t=0){const e=r(n-t);function o(t){return t<n}function i(n){return n>t}function c(n){return o(n)||i(n)}return{length:e,max:t,min:n,constrain:function(e){return c(e)?o(e)?n:t:e},reachedAny:c,reachedMax:i,reachedMin:o,removeOffset:function(n){return e?n-e*Math.ceil((n-t)/e):n}}}function y(n,t,e){const{constrain:o}=x(0,n),i=n+1;let c=u(t);function u(n){return e?r((i+n)%i):o(n)}function s(){return c}function a(){return y(n,s(),e)}const l={get:s,set:function(n){return c=u(n),l},add:function(n){return a().set(s()+n)},clone:a};return l}function v(n,t,o,u,s,a,l,d,f,p,h,y,v,S,b,w,E,I,O){const{cross:L,direction:D}=n,M=["INPUT","SELECT","TEXTAREA"],A={passive:!1},F=m(),T=m(),P=x(50,225).constrain(S.measure(20)),N={mouse:300,touch:400},k={mouse:500,touch:600},z=b?43:25;let H=!1,V=0,B=0,R=!1,j=!1,C=!1,G=!1;function U(n){if(!g(n,u)&&n.touches.length>=2)return W(n);const t=a.readPoint(n),e=a.readPoint(n,L),o=c(t,V),r=c(e,B);if(!j&&!G){if(!n.cancelable)return W(n);if(j=o>r,!j)return W(n)}const i=a.pointerMove(n);o>w&&(C=!0),p.useFriction(.3).useDuration(.75),d.start(),s.add(D(i)),n.preventDefault()}function W(n){const t=h.byDistance(0,!1).index!==y.get(),e=a.pointerUp(n)*(b?k:N)[G?"mouse":"touch"],o=function(n,t){const e=y.add(-1*i(n)),o=h.byDistance(n,!b).distance;return b||r(n)<P?o:E&&t?.5*o:h.byIndex(e.get(),0).distance}(D(e),t),u=function(n,t){if(0===n||0===t)return 0;if(r(n)<=r(t))return 0;const e=c(r(n),r(t));return r(e/n)}(e,o),s=z-10*u,l=I+u/50;j=!1,R=!1,T.clear(),p.useDuration(s).useFriction(l),f.distance(o,!b),G=!1,v.emit("pointerUp")}function q(n){C&&(n.stopPropagation(),n.preventDefault(),C=!1)}return{init:function(n){if(!O)return;function r(r){(e(O)||O(n,r))&&function(n){const e=g(n,u);if(G=e,C=b&&e&&!n.buttons&&H,H=c(s.get(),l.get())>=2,e&&0!==n.button)return;if(function(n){const t=n.nodeName||"";return M.includes(t)}(n.target))return;R=!0,a.pointerDown(n),p.useFriction(0).useDuration(0),s.set(l),function(){const n=G?o:t;T.add(n,"touchmove",U,A).add(n,"touchend",W).add(n,"mousemove",U,A).add(n,"mouseup",W)}(),V=a.readPoint(n),B=a.readPoint(n,L),v.emit("pointerDown")}(r)}const i=t;F.add(i,"dragstart",(n=>n.preventDefault()),A).add(i,"touchmove",(()=>{}),A).add(i,"touchend",(()=>{})).add(i,"touchstart",r).add(i,"mousedown",r).add(i,"touchcancel",W).add(i,"contextmenu",W).add(i,"click",q,!0)},destroy:function(){F.clear(),T.clear()},pointerDown:function(){return R}}}function S(n,t){let e,o;function i(n){return n.timeStamp}function c(e,o){const r="client"+("x"===(o||n.scroll)?"X":"Y");return(g(e,t)?e:e.touches[0])[r]}return{pointerDown:function(n){return e=n,o=n,c(n)},pointerMove:function(n){const t=c(n)-c(o),r=i(n)-i(e)>170;return o=n,r&&(e=n),t},pointerUp:function(n){if(!e||!o)return 0;const t=c(o)-c(e),u=i(n)-i(e),s=i(n)-i(o)>170,a=t/u;return u&&!s&&r(a)>.1?a:0},readPoint:c}}function b(n,t,o,i,c,u,s){let a,l,d=[],f=!1;function p(n){return c.measureSize(s.measure(n))}return{init:function(c){if(!u)return;l=p(n),d=i.map(p),a=new ResizeObserver((s=>{f||(e(u)||u(c,s))&&function(e){for(const u of e){const e=u.target===n,s=i.indexOf(u.target),a=e?l:d[s];if(r(p(e?n:i[s])-a)>=.5){o.requestAnimationFrame((()=>{c.reInit(),t.emit("resize")}));break}}}(s)})),[n].concat(i).forEach((n=>a.observe(n)))},destroy:function(){a&&a.disconnect(),f=!0}}}function w(n,t,e,o,i){const c=i.measure(10),u=i.measure(50),s=x(.1,.99);let a=!1;return{constrain:function(i){if(a||!n.reachedAny(e.get())||!n.reachedAny(t.get()))return;const l=n.reachedMin(t.get())?"min":"max",d=r(n[l]-t.get()),f=e.get()-t.get(),p=s.constrain(d/u);e.subtract(f*p),!i&&r(f)<c&&(e.set(n.constrain(e.get())),o.useDuration(25).useBaseFriction())},toggleActive:function(n){a=!n}}}function E(n,t,e,o){const r=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:u}=x(r,i);return{loop:function(t){if(!function(n){return 1===n?u(e.get()):-1===n&&c(e.get())}(t))return;const r=n*(-1*t);o.forEach((n=>n.add(r)))}}}function I(n,t,e,o,c){const{reachedAny:u,removeOffset:a,constrain:l}=o;function d(n){return n.concat().sort(((n,t)=>r(n)-r(t)))[0]}function f(t,o){const r=[t,t+e,t-e];if(!n)return t;if(!o)return d(r);const c=r.filter((n=>i(n)===o));return c.length?d(c):s(r)-e}return{byDistance:function(e,o){const i=c.get()+e,{index:s,distance:d}=function(e){const o=n?a(e):l(e),i=t.map(((n,t)=>({diff:f(n-o,0),index:t}))).sort(((n,t)=>r(n.diff)-r(t.diff))),{index:c}=i[0];return{index:c,distance:o}}(i),p=!n&&u(i);return!o||p?{index:s,distance:e}:{index:s,distance:e+f(t[s]-d,0)}},byIndex:function(n,e){return{index:n,distance:f(t[n]-c.get(),e)}},shortcut:f}}function O(t){let e=t;function o(t){return n(t)?t:t.get()}return{get:function(){return e},set:function(n){e=o(n)},add:function(n){e+=o(n)},subtract:function(n){e-=o(n)}}}function L(n,t){const e="x"===n.scroll?function(n){return`translate3d(${n}px,0px,0px)`}:function(n){return`translate3d(0px,${n}px,0px)`},o=t.style;let r=!1;return{clear:function(){r||(o.transform="",t.getAttribute("style")||t.removeAttribute("style"))},to:function(t){r||(o.transform=e(n.direction(t)))},toggleActive:function(n){r=!n}}}function D(n,t,e,o,r,i,c,s,a){const l=.5,d=u(r),f=u(r).reverse(),p=function(){const n=c[0];return h(m(f,n),e,!1)}().concat(function(){const n=t-c[0]-1;return h(m(d,n),-e,!0)}());function g(n,t){return n.reduce(((n,t)=>n-r[t]),t)}function m(n,t){return n.reduce(((n,e)=>g(n,t)>0?n.concat([e]):n),[])}function h(r,c,u){const d=function(n){return i.map(((e,r)=>({start:e-o[r]+l+n,end:e+t-l+n})))}(c);return r.map((t=>{const o=u?0:-e,r=u?e:0,i=u?"end":"start",c=d[t][i];return{index:t,loopPoint:c,slideLocation:O(-1),translate:L(n,a[t]),target:()=>s.get()>c?o:r}}))}return{canLoop:function(){return p.every((({index:n})=>g(d.filter((t=>t!==n)),t)<=.1))},clear:function(){p.forEach((n=>n.translate.clear()))},loop:function(){p.forEach((n=>{const{target:t,translate:e,slideLocation:o}=n,r=t();r!==o.get()&&(e.to(r),o.set(r))}))},loopPoints:p}}function M(n,t,o){let r,i=!1;return{init:function(c){o&&(r=new MutationObserver((n=>{i||(e(o)||o(c,n))&&function(n){for(const e of n)if("childList"===e.type){c.reInit(),t.emit("slidesChanged");break}}(n)})),r.observe(n,{childList:!0}))},destroy:function(){r&&r.disconnect(),i=!0}}}function A(n,t,e,o){const r={};let i,c=null,u=null,s=!1;return{init:function(){i=new IntersectionObserver((n=>{s||(n.forEach((n=>{const e=t.indexOf(n.target);r[e]=n})),c=null,u=null,e.emit("slidesInView"))}),{root:n.parentElement,threshold:o}),t.forEach((n=>i.observe(n)))},destroy:function(){i&&i.disconnect(),s=!0},get:function(n=!0){if(n&&c)return c;if(!n&&u)return u;const t=function(n){return f(r).reduce(((t,e)=>{const o=parseInt(e),{isIntersecting:i}=r[o];return(n&&i||!n&&!i)&&t.push(o),t}),[])}(n);return n&&(c=t),n||(u=t),t}}}function F(t,e,o,i,c,l,d,f,p){const{startEdge:g,endEdge:m,direction:h}=t,x=n(o);return{groupSlides:function(n){return x?function(n,t){return u(n).filter((n=>n%t==0)).map((e=>n.slice(e,e+t)))}(n,o):function(n){return n.length?u(n).reduce(((t,o,u)=>{const x=s(t)||0,y=0===x,v=o===a(n),S=c[g]-l[x][g],b=c[g]-l[o][m],w=!i&&y?h(d):0,E=r(b-(!i&&v?h(f):0)-(S+w));return u&&E>e+p&&t.push(o),v&&t.push(n.length),t}),[]).map(((t,e,o)=>{const r=Math.max(o[e-1]||0);return n.slice(r,t)})):[]}(n)}}}function T(e,o,f,p,g,T,P){const{align:N,axis:k,direction:z,startIndex:H,loop:V,duration:B,dragFree:R,dragThreshold:j,inViewThreshold:C,slidesToScroll:G,skipSnaps:U,containScroll:W,watchResize:q,watchSlides:$,watchDrag:Q}=T,X={measure:function(n){const{offsetTop:t,offsetLeft:e,offsetWidth:o,offsetHeight:r}=n;return{top:t,right:e+o,bottom:t+r,left:e,width:o,height:r}}},Y=X.measure(o),J=f.map(X.measure),K=function(n,t){const e="rtl"===t,o="y"===n,r=!o&&e?-1:1;return{scroll:o?"y":"x",cross:o?"x":"y",startEdge:o?"top":e?"right":"left",endEdge:o?"bottom":e?"left":"right",measureSize:function(n){const{height:t,width:e}=n;return o?t:e},direction:function(n){return n*r}}}(k,z),Z=K.measureSize(Y),_=function(n){return{measure:function(t){return n*(t/100)}}}(Z),nn=function(n,e){const o={start:function(){return 0},center:function(n){return r(n)/2},end:r};function r(n){return e-n}return{measure:function(r,i){return t(n)?o[n](r):n(e,r,i)}}}(N,Z),tn=!V&&!!W,en=V||!!W,{slideSizes:on,slideSizesWithGaps:rn,startGap:cn,endGap:un}=function(n,t,e,o,i,c){const{measureSize:u,startEdge:a,endEdge:d}=n,f=e[0]&&i,p=function(){if(!f)return 0;const n=e[0];return r(t[a]-n[a])}(),g=function(){if(!f)return 0;const n=c.getComputedStyle(s(o));return parseFloat(n.getPropertyValue(`margin-${d}`))}(),m=e.map(u),h=e.map(((n,t,e)=>{const o=!t,r=l(e,t);return o?m[t]+p:r?m[t]+g:e[t+1][a]-n[a]})).map(r);return{slideSizes:m,slideSizesWithGaps:h,startGap:p,endGap:g}}(K,Y,J,f,en,g),sn=F(K,Z,G,V,Y,J,cn,un,2),{snaps:an,snapsAligned:ln}=function(n,t,e,o,i){const{startEdge:c,endEdge:u}=n,{groupSlides:a}=i,l=a(o).map((n=>s(n)[u]-n[0][c])).map(r).map(t.measure),d=o.map((n=>e[c]-n[c])).map((n=>-r(n))),f=a(d).map((n=>n[0])).map(((n,t)=>n+l[t]));return{snaps:d,snapsAligned:f}}(K,nn,Y,J,sn),dn=-s(an)+s(rn),{snapsContained:fn,scrollContainLimit:pn}=function(n,t,e,o,r){const i=x(-t+n,0),u=e.map(((n,t)=>{const{min:o,max:r}=i,c=i.constrain(n),u=!t,s=l(e,t);return u?r:s||d(o,c)?o:d(r,c)?r:c})).map((n=>parseFloat(n.toFixed(3)))),a=function(){const n=u[0],t=s(u);return x(u.lastIndexOf(n),u.indexOf(t)+1)}();function d(n,t){return c(n,t)<1}return{snapsContained:function(){if(t<=n+r)return[i.max];if("keepSnaps"===o)return u;const{min:e,max:c}=a;return u.slice(e,c)}(),scrollContainLimit:a}}(Z,dn,ln,W,2),gn=tn?fn:ln,{limit:mn}=function(n,t,e){const o=t[0];return{limit:x(e?o-n:s(t),o)}}(dn,gn,V),hn=y(a(gn),H,V),xn=hn.clone(),yn=u(f),vn=h(p,g,(()=>(({dragHandler:n,scrollBody:t,scrollBounds:e,options:{loop:o}})=>{o||e.constrain(n.pointerDown()),t.seek()})(Pn)),(n=>(({scrollBody:n,translate:t,location:e,offsetLocation:o,scrollLooper:r,slideLooper:i,dragHandler:c,animation:u,eventHandler:s,options:{loop:a}},l)=>{const d=n.velocity(),f=n.settled();f&&!c.pointerDown()&&(u.stop(),s.emit("settle")),f||s.emit("scroll"),o.set(e.get()-d+d*l),a&&(r.loop(n.direction()),i.loop()),t.to(o.get())})(Pn,n))),Sn=gn[hn.get()],bn=O(Sn),wn=O(Sn),En=O(Sn),In=function(n,t,e,o,c){let u=0,s=0,a=o,l=c,d=n.get(),f=0;function p(n){return a=n,m}function g(n){return l=n,m}const m={direction:function(){return s},duration:function(){return a},velocity:function(){return u},seek:function(){const t=e.get()-n.get();let o=0;return a?(u+=t/a,u*=l,d+=u,n.add(u),o=d-f):(u=0,n.set(e),o=t),s=i(o),f=d,m},settled:function(){return r(e.get()-t.get())<.001},useBaseFriction:function(){return g(c)},useBaseDuration:function(){return p(o)},useFriction:g,useDuration:p};return m}(bn,wn,En,B,.68),On=I(V,gn,dn,mn,En),Ln=function(n,t,e,o,r,i,c){function u(r){const u=r.distance,s=r.index!==t.get();i.add(u),u&&(o.duration()?n.start():(n.update(),n.render(1),n.update())),s&&(e.set(t.get()),t.set(r.index),c.emit("select"))}return{distance:function(n,t){u(r.byDistance(n,t))},index:function(n,e){const o=t.clone().set(n);u(r.byIndex(o.get(),e))}}}(vn,hn,xn,In,On,En,P),Dn=function(n){const{max:t,length:e}=n;return{get:function(n){return e?(n-t)/-e:0}}}(mn),Mn=m(),An=A(o,f,P,C),{slideRegistry:Fn}=function(n,t,e,o,r,i){const{groupSlides:c}=r,{min:u,max:f}=o;return{slideRegistry:function(){const o=c(i),r=!n||"keepSnaps"===t;return 1===e.length?[i]:r?o:o.slice(u,f).map(((n,t,e)=>{const o=!t,r=l(e,t);return o?d(s(e[0])+1):r?d(a(i)-s(e)[0]+1,s(e)[0]):n}))}()}}(tn,W,gn,pn,sn,yn),Tn=function(t,e,o,r,i,c,u){let s=0;function a(n){"Tab"===n.code&&(s=(new Date).getTime())}function l(a){c.add(a,"focus",(()=>{if((new Date).getTime()-s>10)return;t.scrollLeft=0;const c=e.indexOf(a),l=o.findIndex((n=>n.includes(c)));n(l)&&(i.useDuration(0),r.index(l,0),u.emit("slideFocus"))}),{passive:!0,capture:!0})}return{init:function(){c.add(document,"keydown",a,!1),e.forEach(l)}}}(e,f,Fn,Ln,In,Mn,P),Pn={ownerDocument:p,ownerWindow:g,eventHandler:P,containerRect:Y,slideRects:J,animation:vn,axis:K,dragHandler:v(K,e,p,g,En,S(K,g),bn,vn,Ln,In,On,hn,P,_,R,j,U,.68,Q),eventStore:Mn,percentOfView:_,index:hn,indexPrevious:xn,limit:mn,location:bn,offsetLocation:wn,options:T,resizeHandler:b(o,P,g,f,K,q,X),scrollBody:In,scrollBounds:w(mn,wn,En,In,_),scrollLooper:E(dn,mn,wn,[bn,wn,En]),scrollProgress:Dn,scrollSnapList:gn.map(Dn.get),scrollSnaps:gn,scrollTarget:On,scrollTo:Ln,slideLooper:D(K,Z,dn,on,rn,an,gn,wn,f),slideFocus:Tn,slidesHandler:M(o,P,$),slidesInView:An,slideIndexes:yn,slideRegistry:Fn,slidesToScroll:sn,target:En,translate:L(K,o)};return Pn}const P={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function N(n){function t(n,t){return p(n,t||{})}const e={mergeOptions:t,optionsAtMedia:function(e){const o=e.breakpoints||{},r=f(o).filter((t=>n.matchMedia(t).matches)).map((n=>o[n])).reduce(((n,e)=>t(n,e)),{});return t(e,r)},optionsMediaQueries:function(t){return t.map((n=>f(n.breakpoints||{}))).reduce(((n,t)=>n.concat(t)),[]).map(n.matchMedia)}};return e}function k(n,e,o){const r=n.ownerDocument,i=r.defaultView,c=N(i),u=function(n){let t=[];return{init:function(e,o){return t=o.filter((({options:t})=>!1!==n.optionsAtMedia(t).active)),t.forEach((t=>t.init(e,n))),o.reduce(((n,t)=>Object.assign(n,{[t.name]:t})),{})},destroy:function(){t=t.filter((n=>n.destroy()))}}}(c),s=m(),a=function(){let n,t={};function e(n){return t[n]||[]}const o={init:function(t){n=t},emit:function(t){return e(t).forEach((e=>e(n,t))),o},off:function(n,r){return t[n]=e(n).filter((n=>n!==r)),o},on:function(n,r){return t[n]=e(n).concat([r]),o},clear:function(){t={}}};return o}(),{mergeOptions:l,optionsAtMedia:d,optionsMediaQueries:f}=c,{on:p,off:g,emit:h}=a,x=M;let y,v,S,b,w=!1,E=l(P,k.globalOptions),I=l(E),O=[];function L(t){const e=T(n,S,b,r,i,t,a);if(t.loop&&!e.slideLooper.canLoop()){return L(Object.assign({},t,{loop:!1}))}return e}function D(e,o){w||(E=l(E,e),I=d(E),O=o||O,function(){const{container:e,slides:o}=I,r=t(e)?n.querySelector(e):e;S=r||n.children[0];const i=t(o)?S.querySelectorAll(o):o;b=[].slice.call(i||S.children)}(),y=L(I),f([E,...O.map((({options:n})=>n))]).forEach((n=>s.add(n,"change",M))),I.active&&(y.translate.to(y.location.get()),y.animation.init(),y.slidesInView.init(),y.slideFocus.init(),y.eventHandler.init(H),y.resizeHandler.init(H),y.slidesHandler.init(H),y.options.loop&&y.slideLooper.loop(),S.offsetParent&&b.length&&y.dragHandler.init(H),v=u.init(H,O)))}function M(n,t){const e=z();A(),D(l({startIndex:e},n),t),a.emit("reInit")}function A(){y.dragHandler.destroy(),y.eventStore.clear(),y.translate.clear(),y.slideLooper.clear(),y.resizeHandler.destroy(),y.slidesHandler.destroy(),y.slidesInView.destroy(),y.animation.destroy(),u.destroy(),s.clear()}function F(n,t,e){I.active&&!w&&(y.scrollBody.useBaseFriction().useDuration(!0===t?0:I.duration),y.scrollTo.index(n,e||0))}function z(){return y.index.get()}const H={canScrollNext:function(){return y.index.add(1).get()!==z()},canScrollPrev:function(){return y.index.add(-1).get()!==z()},containerNode:function(){return S},internalEngine:function(){return y},destroy:function(){w||(w=!0,s.clear(),A(),a.emit("destroy"),a.clear())},off:g,on:p,emit:h,plugins:function(){return v},previousScrollSnap:function(){return y.indexPrevious.get()},reInit:x,rootNode:function(){return n},scrollNext:function(n){F(y.index.add(1).get(),n,-1)},scrollPrev:function(n){F(y.index.add(-1).get(),n,1)},scrollProgress:function(){return y.scrollProgress.get(y.location.get())},scrollSnapList:function(){return y.scrollSnapList},scrollTo:F,selectedScrollSnap:z,slideNodes:function(){return b},slidesInView:function(){return y.slidesInView.get()},slidesNotInView:function(){return y.slidesInView.get(!1)}};return D(e,o),setTimeout((()=>a.emit("init")),0),H}k.globalOptions=void 0;const z={active:!0,breakpoints:{},delay:4e3,jump:!1,playOnInit:!0,stopOnFocusIn:!0,stopOnInteraction:!0,stopOnMouseEnter:!1,stopOnLastSnap:!1,rootNode:null};function H(n={}){let t,e,o,r=!1,i=!0,c=!1,u=0;function s(){if(o)return;if(!i)return;r||e.emit("autoplay:play");const{ownerWindow:n}=e.internalEngine();n.clearInterval(u),u=n.setInterval(p,t.delay),r=!0}function a(){if(o)return;r&&e.emit("autoplay:stop");const{ownerWindow:n}=e.internalEngine();n.clearInterval(u),u=0,r=!1}function l(){if(d())return i=r,a();i&&s()}function d(){const{ownerDocument:n}=e.internalEngine();return"hidden"===n.visibilityState}function f(n){void 0!==n&&(c=n),i=!0,s()}function p(){const{index:n}=e.internalEngine(),o=n.clone().add(1).get(),r=e.scrollSnapList().length-1;t.stopOnLastSnap&&o===r&&a(),e.canScrollNext()?e.scrollNext(c):e.scrollTo(0,c)}return{name:"autoplay",options:n,init:function(r,u){e=r;const{mergeOptions:f,optionsAtMedia:p}=u,g=f(z,H.globalOptions),m=f(g,n);if(t=p(m),e.scrollSnapList().length<=1)return;c=t.jump,o=!1;const{eventStore:h,ownerDocument:x}=e.internalEngine(),y=e.rootNode(),v=t.rootNode&&t.rootNode(y)||y,S=e.containerNode();e.on("pointerDown",a),t.stopOnInteraction||e.on("pointerUp",s),t.stopOnMouseEnter&&(h.add(v,"mouseenter",(()=>{i=!1,a()})),t.stopOnInteraction||h.add(v,"mouseleave",(()=>{i=!0,s()}))),t.stopOnFocusIn&&(h.add(S,"focusin",a),t.stopOnInteraction||h.add(S,"focusout",s)),h.add(x,"visibilitychange",l),t.playOnInit&&!d()&&s()},destroy:function(){e.off("pointerDown",a).off("pointerUp",s),a(),o=!0,r=!1},play:f,stop:function(){r&&a()},reset:function(){r&&f()},isPlaying:function(){return r}}}H.globalOptions=void 0;export{H as A,k as E};