"use strict";const AutoPlayPlugin=e=>{let n,o=e.options.autoplay??{},t=!1,r=!1,a=null,s=e?.container?.closest('[data-component-type="component"]')?.querySelector(".carousel-dots");function i(e){e.forEach(e=>{(r=e.isIntersecting)?v():c()})}function u(){!a&&e.container&&(a=new IntersectionObserver(i,{root:null,threshold:0})).observe(e.container)}function c(){clearTimeout(n)}function v(){c(),n=setTimeout(()=>{!t&&o.enable&&r&&e.next()},o.delay??2e3)}function l(){t=!0,c()}function d(){t=!1,v()}e.on("created",()=>{s?.addEventListener("mouseover",l),s?.addEventListener("mouseout",d),o.pauseOnHover&&e.container&&(e.container.addEventListener("mouseover",l),e.container.addEventListener("mouseout",d)),o.enable&&(u(),v())}),e.on("dragStarted",c),e.on("animationEnded",v),e.on("updated",e=>{(o=e.options?.autoplay??{}).enable&&(u(),v())}),e.on("optionsChanged",n=>{n.options.autoplay?.pauseOnHover!==o.pauseOnHover&&e.container&&(n.options.autoplay?.pauseOnHover?(e.container.addEventListener("mouseover",l),e.container.addEventListener("mouseout",d)):(e.container.removeEventListener("mouseover",l),e.container.removeEventListener("mouseout",d),t=!1)),(o=n.options.autoplay??{}).enable&&(u(),v())}),e.on("destroyed",()=>{e.container&&(e.container.removeEventListener("mouseover",l),e.container.removeEventListener("mouseout",d)),s?.removeEventListener("mouseover",l),s?.removeEventListener("mouseout",d),c(),a&&(a.disconnect(),a=null)})};exports.AutoPlayPlugin=AutoPlayPlugin;
