/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */
import{r as e,c as s,h as t,d as o,g as l}from"./p-gD7P82jx.js";import{i as n}from"./p-C53feagD.js";const i=class{constructor(t){e(this,t),this.ionSegmentViewScroll=s(this,"ionSegmentViewScroll",7),this.scrollEndTimeout=null,this.isTouching=!1,this.disabled=!1}handleScroll(e){var s;const{scrollLeft:t,scrollWidth:o,clientWidth:l}=e.target,i=o-l,a=(n(this.el)?-1:1)*(t/i);this.ionSegmentViewScroll.emit({scrollRatio:a,isManualScroll:null===(s=this.isManualScroll)||void 0===s||s}),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)}async setContent(e,s=!0){const t=this.getSegmentContents().findIndex((s=>s.id===e));if(-1===t)return;this.isManualScroll=!1,this.resetScrollEndTimeout();const o=t*this.el.offsetWidth;this.el.scrollTo({top:0,left:(n(this.el)?-1:1)*o,behavior:s?"smooth":"instant"})}getSegmentContents(){return Array.from(this.el.querySelectorAll("ion-segment-content"))}render(){const{disabled:e,isManualScroll:s}=this;return t(o,{key:"caf57037127fff688f45edd7c27018fc1d8cc689",class:{"segment-view-disabled":e,"segment-view-scroll-disabled":!1===s}},t("slot",{key:"f93d19747ed3f04ee5a966412f62f2900ee45480"}))}get el(){return l(this)}};i.style={ionic:":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}",ios:":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}",md:":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}"};export{i as ion_segment_view}