import{a as G,_ as N,b as K}from"./vendor-tslib-De9GV7Vy.js";import{r as a}from"./vendor-react-BUCujlKS.js";import{z as Q,f as U,R as q}from"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import{c as J,e as _}from"./vendor-use-sidecar-zDC0RhA3.js";import{u as $}from"./vendor-use-callback-ref-D3RC8gqK.js";import{s as p}from"./vendor-react-style-singleton-q6EMHnwf.js";var V=J(),Y=function(){},D=a.forwardRef(function(e,t){var o=a.useRef(null),l=a.useState({onScrollCapture:Y,onWheelCapture:Y,onTouchMoveCapture:Y}),d=l[0],f=l[1],h=e.forwardProps,c=e.children,m=e.className,S=e.removeScrollBar,b=e.enabled,R=e.shards,k=e.sideCar,y=e.noRelative,E=e.noIsolation,r=e.inert,n=e.allowPinchZoom,s=e.as,i=s===void 0?"div":s,v=e.gapMode,g=G(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),u=k,w=$([o,t]),C=N(N({},g),d);return a.createElement(a.Fragment,null,b&&a.createElement(u,{sideCar:V,removeScrollBar:S,shards:R,noRelative:y,noIsolation:E,inert:r,setCallbacks:f,allowPinchZoom:!!n,lockRef:o,gapMode:v}),h?a.cloneElement(a.Children.only(c),N(N({},C),{ref:w})):a.createElement(i,N({},C,{className:m,ref:w}),c))});D.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};D.classNames={fullWidth:U,zeroRight:Q};var W=!1;if(typeof window<"u")try{var T=Object.defineProperty({},"passive",{get:function(){return W=!0,!0}});window.addEventListener("test",T,T),window.removeEventListener("test",T,T)}catch{W=!1}var P=W?{passive:!1}:!1,ee=function(e){return e.tagName==="TEXTAREA"},Z=function(e,t){if(!(e instanceof Element))return!1;var o=window.getComputedStyle(e);return o[t]!=="hidden"&&!(o.overflowY===o.overflowX&&!ee(e)&&o[t]==="visible")},re=function(e){return Z(e,"overflowY")},te=function(e){return Z(e,"overflowX")},H=function(e,t){var o=t.ownerDocument,l=t;do{typeof ShadowRoot<"u"&&l instanceof ShadowRoot&&(l=l.host);var d=x(e,l);if(d){var f=z(e,l),h=f[1],c=f[2];if(h>c)return!0}l=l.parentNode}while(l&&l!==o.body);return!1},ae=function(e){var t=e.scrollTop,o=e.scrollHeight,l=e.clientHeight;return[t,o,l]},ne=function(e){var t=e.scrollLeft,o=e.scrollWidth,l=e.clientWidth;return[t,o,l]},x=function(e,t){return e==="v"?re(t):te(t)},z=function(e,t){return e==="v"?ae(t):ne(t)},le=function(e,t){return e==="h"&&t==="rtl"?-1:1},oe=function(e,t,o,l,d){var f=le(e,window.getComputedStyle(t).direction),h=f*l,c=o.target,m=t.contains(c),S=!1,b=h>0,R=0,k=0;do{if(!c)break;var y=z(e,c),E=y[0],r=y[1],n=y[2],s=r-n-f*E;(E||s)&&x(e,c)&&(R+=s,k+=E);var i=c.parentNode;c=i&&i.nodeType===Node.DOCUMENT_FRAGMENT_NODE?i.host:i}while(!m&&c!==document.body||m&&(t.contains(c)||t===c));return(b&&Math.abs(R)<1||!b&&Math.abs(k)<1)&&(S=!0),S},L=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},F=function(e){return[e.deltaX,e.deltaY]},O=function(e){return e&&"current"in e?e.current:e},ce=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ie=function(e){return`
  .block-interactivity-`.concat(e,` {pointer-events: none;}
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},ue=0,M=[];function se(e){var t=a.useRef([]),o=a.useRef([0,0]),l=a.useRef(),d=a.useState(ue++)[0],f=a.useState(p)[0],h=a.useRef(e);a.useEffect(function(){h.current=e},[e]),a.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(d));var r=K([e.lockRef.current],(e.shards||[]).map(O),!0).filter(Boolean);return r.forEach(function(n){return n.classList.add("allow-interactivity-".concat(d))}),function(){document.body.classList.remove("block-interactivity-".concat(d)),r.forEach(function(n){return n.classList.remove("allow-interactivity-".concat(d))})}}},[e.inert,e.lockRef.current,e.shards]);var c=a.useCallback(function(r,n){if("touches"in r&&r.touches.length===2||r.type==="wheel"&&r.ctrlKey)return!h.current.allowPinchZoom;var s=L(r),i=o.current,v="deltaX"in r?r.deltaX:i[0]-s[0],g="deltaY"in r?r.deltaY:i[1]-s[1],u,w=r.target,C=Math.abs(v)>Math.abs(g)?"h":"v";if("touches"in r&&C==="h"&&w.type==="range")return!1;var A=window.getSelection(),X=A&&A.anchorNode,j=X?X===w||X.contains(w):!1;if(j)return!1;var B=H(C,w);if(!B)return!0;if(B?u=C:(u=C==="v"?"h":"v",B=H(C,w)),!B)return!1;if(!l.current&&"changedTouches"in r&&(v||g)&&(l.current=u),!u)return!0;var I=l.current||u;return oe(I,n,r,I==="h"?v:g)},[]),m=a.useCallback(function(r){var n=r;if(!(!M.length||M[M.length-1]!==f)){var s="deltaY"in n?F(n):L(n),i=t.current.filter(function(u){return u.name===n.type&&(u.target===n.target||n.target===u.shadowParent)&&ce(u.delta,s)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var v=(h.current.shards||[]).map(O).filter(Boolean).filter(function(u){return u.contains(n.target)}),g=v.length>0?c(n,v[0]):!h.current.noIsolation;g&&n.cancelable&&n.preventDefault()}}},[]),S=a.useCallback(function(r,n,s,i){var v={name:r,delta:n,target:s,should:i,shadowParent:fe(s)};t.current.push(v),setTimeout(function(){t.current=t.current.filter(function(g){return g!==v})},1)},[]),b=a.useCallback(function(r){o.current=L(r),l.current=void 0},[]),R=a.useCallback(function(r){S(r.type,F(r),r.target,c(r,e.lockRef.current))},[]),k=a.useCallback(function(r){S(r.type,L(r),r.target,c(r,e.lockRef.current))},[]);a.useEffect(function(){return M.push(f),e.setCallbacks({onScrollCapture:R,onWheelCapture:R,onTouchMoveCapture:k}),document.addEventListener("wheel",m,P),document.addEventListener("touchmove",m,P),document.addEventListener("touchstart",b,P),function(){M=M.filter(function(r){return r!==f}),document.removeEventListener("wheel",m,P),document.removeEventListener("touchmove",m,P),document.removeEventListener("touchstart",b,P)}},[]);var y=e.removeScrollBar,E=e.inert;return a.createElement(a.Fragment,null,E?a.createElement(f,{styles:ie(d)}):null,y?a.createElement(q,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ve=_(V,se);var de=a.forwardRef(function(e,t){return a.createElement(D,N({},e,{ref:t,sideCar:ve}))});de.classNames=D.classNames;export{de as R};
