import{c as y,q as F,O as ae,o as de,f as ue,g as fe,b as Se,h as me,P as he,Q as U,A as ve,H as N,i as L,n as ge,R as u,k as be,p as V,T as _e,z as Te,a as xe,U as Pe,V as we,W as g,d as Ee,t as $,X as ye,s as Le,Y as $e,m as ze,Z as Ae}from"./index-6Jqoo2rk.js";const Ce=$("<div>"),Ie=$("<div class=scrollable-thumb-container><div class=scrollable-thumb>"),Me=24;function Re(t){return u()?window.setTimeout(t,Me):requestAnimationFrame(t)}function Oe(t){u()?window.clearTimeout(t):cancelAnimationFrame(t)}const Be=Ee();function Ye(t){const n=t.axis??"y",f=n==="x"?"scrollLeft":"scrollTop",S=n==="x"?"scrollWidth":"scrollHeight",X=n==="x"?"clientWidth":"clientHeight",q=n==="x"?"offsetWidth":"offsetHeight",z=n==="x"?"clientX":"clientY",[Q,A]=y(!1),a=()=>r[f],Z=e=>r[f]=e,m=()=>r[S],b=()=>r[X],_=()=>r[q],C=()=>m()-Math.round(a()+_()),j=F(()=>t.onScrollOffset??300);let T=0,h=0,I,M,x=!1,v=!1;const[G,J]=y(!0),[K,p]=y(!0);let d=0;const ee=ae(()=>{x=!0,d&&(R(),v=!0)},()=>{x=!1,v&&(P(),v=!1)});de(ee);const P=()=>{if(x){R(),v=!0;return}!t.onScrolledTop&&!t.onScrolledBottom&&!B().length&&u()||d||(d=Re(()=>{d=0;const e=a();T=h===e?0:h<e?1:-1,h=e,oe(e),B().forEach(o=>o()),O()}))},R=()=>{d&&(Oe(d),d=0)},O=()=>{if(!t.onScrolledTop&&!t.onScrolledBottom)return;const e=m();if(!e)return;const o=a(),s=_(),c=j(),l=e-s;t.onScrolledTop&&o<=c&&T<=0&&t.onScrolledTop(),t.onScrolledBottom&&l-o<=c&&T>=0&&t.onScrolledBottom()},te=()=>{J(!a()),p(C()<=1)},oe=(e=a())=>{if(u()||!i)return;const o=m(),s=b(),c=o/s/.75,l=Math.max(20,s/c),w=e/(o-s)*s,D=e/(o-s),E=s-l;s<o?(i.style.height=l+"px",i.style.transform=`translateY(${Math.min(E,w-l*D)}px)`):i.style.height="0px"},se=e=>{h=e,ne(),Z(e)},ne=()=>{A(!0),r.addEventListener("scroll",e=>{g(e),A(!1)},{capture:!0,passive:!1,once:!0})},B=F(()=>[t.onScroll,t.withBorders&&te].filter(Boolean)),H=e=>{g(e);const o=m(),s=b(),c=i.offsetHeight,l=o-s,w=s-c,E=(e[z]-I)/w*l,ie=M+E;r[f]=ie},le=e=>{g(e),I=e[z],M=a(),e.target.classList.add("is-focused"),window.addEventListener("mousemove",H),window.addEventListener("mouseup",ce,{once:!0})},ce=e=>{window.removeEventListener("mousemove",H),i.classList.remove("is-focused")},re=e=>{e.stopPropagation();const o=r;!e.deltaX&&o.scrollWidth>o.clientWidth&&(o.scrollLeft+=e.deltaY/4,g(e))},W=()=>{!u()&&i&&P()},Y={get scrollPosition(){return a()},get scrollSize(){return m()},get clientSize(){return b()},get offsetSize(){return _()},getDistanceToEnd:C,get container(){return r},onSizeChange:W,setScrollPositionSilently:se,checkForTriggers:O};t.contextRef&&ue(()=>t.contextRef)(Y);const k=fe(()=>Se(Be.Provider,{value:Y,get children(){return t.children}}));me(he(k,W));let r,i;return(()=>{const e=Ce();return U(e,"wheel",n==="x"&&!ve&&re||void 0),U(e,"scroll",!Q()&&P),N(o=>{r=o,t.ref?.(o)},e),L(e,(()=>{const o=ge(()=>!u()&&n==="y");return()=>o()&&(()=>{const s=Ie(),c=s.firstChild;return c.$$mousedown=le,N(l=>{i=l,t.thumbRef?.(l)},c),s})()})(),null),L(e,k,null),be(o=>{const s=V("scrollable",`scrollable-${n}`,t.class,t.relative&&"relative",_e&&!Te&&"no-scrollbar",...t.withBorders?[G()&&"scrolled-start",K()&&"scrolled-end",n==="y"&&"scrollable-y-bordered",(t.withBorders==="top"||t.withBorders==="both")&&"scrollable-y-bordered-top",(t.withBorders==="bottom"||t.withBorders==="both")&&"scrollable-y-bordered-bottom"]:[]),c=t.classList,l=t.style;return s!==o._v$&&xe(e,o._v$=s),o._v$2=Pe(e,c,o._v$2),o._v$3=we(e,l,o._v$3),o},{_v$:void 0,_v$2:void 0,_v$3:void 0}),e})()}ye(["mousedown"]);const He=$("<span>"),ke=t=>{const[n,f]=Le(t,["icon","class"]);return(()=>{const S=He();return $e(S,ze({get class(){return V("tgico",n.class)}},f),!1,!0),L(S,()=>Ae(n.icon)),S})()};export{ke as I,Ye as S,Be as a};
//# sourceMappingURL=iconTsx-Cr8T7ZIv.js.map
