import{a as i}from"./chunk-34X5J4DA.js";import{i as h,m as r,n as m,q as u,r as f}from"./chunk-QECZUVWI.js";import{f as d}from"./chunk-S5EYVFES.js";var g=":host{display:-ms-flexbox;display:flex;height:100%;overflow-x:scroll;-webkit-scroll-snap-type:x mandatory;-ms-scroll-snap-type:x mandatory;scroll-snap-type:x mandatory;scrollbar-width:none;-ms-overflow-style:none}:host::-webkit-scrollbar{display:none}:host(.segment-view-disabled){-ms-touch-action:none;touch-action:none;overflow-x:hidden}:host(.segment-view-scroll-disabled){pointer-events:none}:host(.segment-view-disabled){opacity:0.3}",w=":host{display:-ms-flexbox;display:flex;height:100%;overflow-x:scroll;-webkit-scroll-snap-type:x mandatory;-ms-scroll-snap-type:x mandatory;scroll-snap-type:x mandatory;scrollbar-width:none;-ms-overflow-style:none}:host::-webkit-scrollbar{display:none}:host(.segment-view-disabled){-ms-touch-action:none;touch-action:none;overflow-x:hidden}:host(.segment-view-scroll-disabled){pointer-events:none}:host(.segment-view-disabled){opacity:0.3}",b=(()=>{let c=class{constructor(e){h(this,e),this.ionSegmentViewScroll=f(this,"ionSegmentViewScroll",7),this.scrollEndTimeout=null,this.isTouching=!1,this.disabled=!1}handleScroll(e){var t;let{scrollLeft:a,scrollWidth:s,clientWidth:o}=e.target,l=s-o,n=(i(this.el)?-1:1)*(a/l);this.ionSegmentViewScroll.emit({scrollRatio:n,isManualScroll:(t=this.isManualScroll)!==null&&t!==void 0?t:!0}),this.resetScrollEndTimeout()}handleScrollStart(){this.scrollEndTimeout&&(clearTimeout(this.scrollEndTimeout),this.scrollEndTimeout=null),this.isTouching=!0}handleTouchEnd(){this.isTouching=!1}resetScrollEndTimeout(){this.scrollEndTimeout&&(clearTimeout(this.scrollEndTimeout),this.scrollEndTimeout=null),this.scrollEndTimeout=setTimeout(()=>{this.checkForScrollEnd()},100)}checkForScrollEnd(){this.isTouching||(this.isManualScroll=void 0)}setContent(e,t=!0){return d(this,null,function*(){let s=this.getSegmentContents().findIndex(n=>n.id===e);if(s===-1)return;this.isManualScroll=!1,this.resetScrollEndTimeout();let o=this.el.offsetWidth,l=s*o;this.el.scrollTo({top:0,left:(i(this.el)?-1:1)*l,behavior:t?"smooth":"instant"})})}getSegmentContents(){return Array.from(this.el.querySelectorAll("ion-segment-content"))}render(){let{disabled:e,isManualScroll:t}=this;return r(m,{key:"1c9bfce83967a93d63c225031a5cd688509d8fc8",class:{"segment-view-disabled":e,"segment-view-scroll-disabled":t===!1}},r("slot",{key:"19fee034e76fffbdb5f622cb514037c00f9d55d5"}))}get el(){return u(this)}};return c.style={ios:g,md:w},c})();export{b as ion_segment_view};
