Files
OverlayScrollbars/packages/overlayscrollbars/dist/overlayscrollbars.esm.min.js
T
2022-07-27 22:19:33 +02:00

1 line
26 KiB
JavaScript

function t(e,n){if(g(e))for(let t=0;t<e.length&&!1!==n(e[t],t,e);t++);else e&&t(Object.keys(e),(t=>n(e[t],t,e)));return e}function e(e,n){const o=d(n);if(p(n)||o){let t=o?"":{};if(e){const r=window.getComputedStyle(e,null);t=o?yt(e,r,n):n.reduce(((t,n)=>(t[n]=yt(e,r,n),t)),t)}return t}e&&t(L(n),(t=>mt(e,t,n[t])))}const n=(t,e)=>{const{o:n,u:o,_:r}=t;let i,s=n;const l=(t,e)=>{const n=s,l=t,c=e||(o?!o(n,l):n!==l);return(c||r)&&(s=l,i=n),[s,c,i]};return[e?t=>l(e(s,i),t):l,t=>[s,!!t,i]]},o=Node.ELEMENT_NODE,{toString:r,hasOwnProperty:i}=Object.prototype,s=t=>void 0===t,l=t=>null===t,c=t=>s(t)||l(t)?`${t}`:r.call(t).replace(/^\[object (.+)\]$/,"$1").toLowerCase(),a=t=>"number"==typeof t,d=t=>"string"==typeof t,u=t=>"boolean"==typeof t,h=t=>"function"==typeof t,p=t=>Array.isArray(t),f=t=>"object"==typeof t&&!p(t)&&!l(t),g=t=>{const e=!!t&&t.length,n=a(e)&&e>-1&&e%1==0;return!(!(p(t)||!h(t)&&n)||e>0&&f(t)&&!(e-1 in t))},w=t=>{if(!t||!f(t)||"object"!==c(t))return!1;let e;const n="constructor",o=t[n],r=o&&o.prototype,l=i.call(t,n),a=r&&i.call(r,"isPrototypeOf");if(o&&!l&&!a)return!1;for(e in t);return s(e)||i.call(t,e)},b=t=>{const e=HTMLElement;return!!t&&(e?t instanceof e:t.nodeType===o)},v=t=>{const e=Element;return!!t&&(e?t instanceof e:t.nodeType===o)},y=(t,e,n)=>t.indexOf(e,n),m=(t,e,n)=>(n||d(e)||!g(e)?t.push(e):Array.prototype.push.apply(t,e),t),x=e=>{const n=Array.from,o=[];return n&&e?n(e):(e instanceof Set?e.forEach((t=>{m(o,t)})):t(e,(t=>{m(o,t)})),o)},$=t=>!!t&&0===t.length,O=(e,n,o)=>{t(e,(t=>t&&t.apply(void 0,n||[]))),!o&&(e.length=0)},S=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),L=t=>t?Object.keys(t):[],C=(e,n,o,r,i,s,c)=>{const a=[n,o,r,i,s,c];return"object"==typeof e&&!l(e)||h(e)||(e={}),t(a,(n=>{t(L(n),(t=>{const o=n[t];if(e===o)return!0;const r=p(o);if(o&&(w(o)||r)){const n=e[t];let i=n;r&&!p(n)?i=[]:r||w(n)||(i={}),e[t]=C(i,o)}else e[t]=o}))})),e},P=t=>{for(const e in t)return!1;return!0},M=(t,e,n,o)=>{if(s(o))return n?n[t]:e;n&&!l(o)&&!1!==o&&(n[t]=o)},T=(t,e,n)=>{if(s(n))return t?t.getAttribute(e):null;t&&t.setAttribute(e,n)},E=(t,e,n,o)=>{if(n){const r=T(t,e)||"",i=new Set(r.split(" "));i[o?"add":"delete"](n),T(t,e,x(i).join(" ").trim())}},R=(t,e)=>{t&&t.removeAttribute(e)},D=(t,e)=>M("scrollLeft",0,t,e),z=(t,e)=>M("scrollTop",0,t,e),I=Element.prototype,A=(t,e)=>{const n=[],o=e?v(e)?e:null:document;return o?m(n,o.querySelectorAll(t)):n},B=(t,e)=>!!v(t)&&(I.matches||I.msMatchesSelector).call(t,e),k=t=>t?x(t.childNodes):[],H=t=>t?t.parentElement:null,Y=(t,e)=>{if(v(t)){const n=I.closest;if(n)return n.call(t,e);do{if(B(t,e))return t;t=H(t)}while(t)}return null},X=(e,n,o)=>{if(o){let r,i=n;e&&(g(o)?(r=document.createDocumentFragment(),t(o,(t=>{t===i&&(i=t.previousSibling),r.appendChild(t)}))):r=o,n&&(i?i!==n&&(i=i.nextSibling):i=e.firstChild),e.insertBefore(r,i||null))}},V=(t,e)=>{X(t,null,e)},j=(t,e)=>{X(H(t),t&&t.nextSibling,e)},F=e=>{if(g(e))t(x(e),(t=>F(t)));else if(e){const t=H(e);t&&t.removeChild(e)}},_=t=>{const e=document.createElement("div");return t&&T(e,"class",t),e},N=e=>{const n=_();return n.innerHTML=e.trim(),t(k(n),(t=>F(t)))},Z=t=>t.charAt(0).toUpperCase()+t.slice(1),W=["-webkit-","-moz-","-o-","-ms-"],G=["WebKit","Moz","O","MS","webkit","moz","o","ms"],K={},q={},J=e=>{let n=q[e];if(S(q,e))return n;const o=Z(e),r=_().style;return t(W,(t=>{const i=t.replace(/-/g,""),s=[e,t+e,i+o,Z(i)+o];return!(n=s.find((t=>void 0!==r[t])))})),q[e]=n||""},U=e=>{let n=K[e]||window[e];return S(K,e)||(t(G,(t=>(n=n||window[t+Z(e)],!n))),K[e]=n),n},Q=U("MutationObserver"),tt=U("IntersectionObserver"),et=U("ResizeObserver"),nt=U("cancelAnimationFrame"),ot=U("requestAnimationFrame"),rt=window.setTimeout,it=window.clearTimeout,st=/[^\x20\t\r\n\f]+/g,lt=(t,e,n)=>{const o=t&&t.classList;let r,i=0,s=!1;if(o&&e&&d(e)){const t=e.match(st)||[];for(s=t.length>0;r=t[i++];)s=!!n(o,r)&&s}return s},ct=(t,e)=>{lt(t,e,((t,e)=>t.remove(e)))},at=(t,e)=>(lt(t,e,((t,e)=>t.add(e))),ct.bind(0,t,e)),dt=(e,n,o,r)=>{if(e&&n){let i=!0;return t(o,(t=>{(r?r(e[t]):e[t])!==(r?r(n[t]):n[t])&&(i=!1)})),i}return!1},ut=(t,e)=>dt(t,e,["w","h"]),ht=(t,e)=>dt(t,e,["x","y"]),pt=(t,e)=>dt(t,e,["t","r","b","l"]),ft=(t,e,n)=>dt(t,e,["width","height"],n&&(t=>Math.round(t))),gt=()=>{},wt=(t,e)=>{let n,o,r,i=gt;const{g:s,v:l,p:c}=e||{},d=function(e){i(),it(n),n=o=void 0,i=gt,t.apply(this,e)},u=t=>c&&o?c(o,t):t,p=()=>{i!==gt&&d(u(r)||r)},f=function(){const t=x(arguments),e=h(s)?s():s,c=a(e)&&e>=0;if(c){const s=h(l)?l():l,c=a(s)&&s>=0,f=e>0?rt:ot,g=e>0?it:nt,w=u(t)||t,b=d.bind(0,w);i();const v=f(b,e);i=()=>g(v),c&&!n&&(n=rt(p,s)),o=r=w}else d(t)};return f.m=p,f},bt={opacity:1,zindex:1},vt=(t,e)=>{const n=e?parseFloat(t):parseInt(t,10);return n==n?n:0},yt=(t,e,n)=>null!=e?e[n]||e.getPropertyValue(n):t.style[n],mt=(t,e,n)=>{try{const{style:o}=t;s(o[e])?o.setProperty(e,n):o[e]=((t,e)=>!bt[t.toLowerCase()]&&a(e)?`${e}px`:e)(e,n)}catch(I){}},xt=(t,n,o)=>{const r=n?`${n}-`:"",i=o?`-${o}`:"",s=`${r}top${i}`,l=`${r}right${i}`,c=`${r}bottom${i}`,a=`${r}left${i}`,d=e(t,[s,l,c,a]);return{t:vt(d[s]),r:vt(d[l]),b:vt(d[c]),l:vt(d[a])}},$t={w:0,h:0},Ot=t=>t?{w:t.offsetWidth,h:t.offsetHeight}:$t,St=t=>t?{w:t.clientWidth,h:t.clientHeight}:$t,Lt=t=>t?{w:t.scrollWidth,h:t.scrollHeight}:$t,Ct=t=>{const n=parseFloat(e(t,"height"))||0,o=parseFloat(e(t,"height"))||0;return{w:o-Math.round(o),h:n-Math.round(n)}},Pt=t=>t.getBoundingClientRect();let Mt;const Tt=t=>t.split(" "),Et=(e,n,o,r)=>{t(Tt(n),(t=>{e.removeEventListener(t,o,r)}))},Rt=(e,n,o,r)=>{var i;const l=(()=>{if(s(Mt)){Mt=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get(){Mt=!0}}))}catch(e){}}return Mt})(),c=null!=(i=l&&r&&r.S)?i:l,a=r&&r.$||!1,d=r&&r.C||!1,u=[],h=l?{passive:c,capture:a}:a;return t(Tt(n),(t=>{const n=d?r=>{e.removeEventListener(t,n,a),o&&o(r)}:o;m(u,Et.bind(null,e,t,n,a)),e.addEventListener(t,n,h)})),O.bind(0,u)},Dt=t=>t.stopPropagation(),zt={x:0,y:0},It=t=>{const e=t?Pt(t):0;return e?{x:e.left+window.pageYOffset,y:e.top+window.pageXOffset}:zt},At=(e,n)=>{t(p(n)?n:[n],e)},Bt=e=>{const n=new Map,o=(t,e)=>{if(t){const o=n.get(t);At((t=>{o&&o[t?"delete":"clear"](t)}),e)}else n.forEach((t=>{t.clear()})),n.clear()},r=(t,e)=>{const r=n.get(t)||new Set;return n.set(t,r),At((t=>{t&&r.add(t)}),e),o.bind(0,t,e)};return t(L(e),(t=>{r(t,e[t])})),[r,o,(e,o)=>{const r=n.get(e);t(x(r),(t=>{o&&!$(o)?t.apply(0,o):t()}))}]},kt=(t,e)=>t?e.split(".").reduce(((t,e)=>t&&S(t,e)?t[e]:void 0),t):void 0,Ht=(t,e,n)=>o=>[kt(t,o),n||void 0!==kt(e,o)],Yt=t=>{let e=t;return[()=>e,t=>{e=C({},e,t)}]},Xt="os-environment",Vt=`${Xt}-flexbox-glue`,jt=`${Vt}-max`,Ft="data-overlayscrollbars",_t=`${Ft}-overflow-x`,Nt=`${Ft}-overflow-y`,Zt="overflowVisible",Wt="scrollbarHidden",Gt="updating",Kt="os-padding",qt="os-viewport",Jt=`${qt}-arrange`,Ut="os-content",Qt=`${qt}-scrollbar-hidden`,te=`os-overflow-visible`,ee="os-size-observer",ne=`${ee}-appear`,oe=`${ee}-listener`,re=`${oe}-scroll`,ie=`${oe}-item`,se=`${ie}-final`,le="os-trinsic-observer",ce="os-scrollbar",ae=`${ce}-horizontal`,de=`${ce}-vertical`,ue=`${ce}-track`,he=`${ce}-handle`,pe=`${ce}-visible`,fe=`${ce}-cornerless`,ge=`${ce}-transitionless`,we=`${ce}-interaction`,be=`${ce}-unusable`,ve=`${ce}-auto-hidden`,ye=`${ue}-interactive`,me=`${he}-interactive`,xe=t=>JSON.stringify(t,((t,e)=>{if(h(e))throw new Error;return e})),$e={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,updating:{elementEvents:[["img","load"]],debounce:[0,33],attributes:null,ignoreMutation:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:800,dragScroll:!0,clickScroll:!1,pointers:["mouse","touch","pen"]}},Oe=(e,n)=>{const o={};return t(L(n).concat(L(e)),(t=>{const r=e[t],i=n[t];if(f(r)&&f(i))C(o[t]={},Oe(r,i));else if(S(n,t)&&i!==r){let e=!0;if(p(r)||p(i))try{xe(r)===xe(i)&&(e=!1)}catch(K){}e&&(o[t]=i)}})),o},Se={},Le=()=>C({},Se),Ce="__osOptionsValidationPlugin",Pe=3333333,Me="scroll",Te="__osSizeObserverPlugin",Ee={[Te]:{O:(t,n,o)=>{const r=N(`<div class="${ie}" dir="ltr"><div class="${ie}"><div class="${se}"></div></div><div class="${ie}"><div class="${se}" style="width: 200%; height: 200%"></div></div></div>`);V(t,r),at(t,re);const i=r[0],s=i.lastChild,l=i.firstChild,c=null==l?void 0:l.firstChild;let a,d=Ot(i),u=d,h=!1;const p=()=>{D(l,Pe),z(l,Pe),D(s,Pe),z(s,Pe)},f=t=>{a=0,h&&(d=u,n(!0===t))},g=t=>{u=Ot(i),h=!t||!ut(u,d),t?(Dt(t),h&&!a&&(nt(a),a=ot(f))):f(!1===t),p()},w=m([],[Rt(l,Me,g),Rt(s,Me,g)]);return e(c,{width:Pe,height:Pe}),ot(p),[o?g.bind(0,!1):p,w]}}};let Re=0;const{round:De,abs:ze}=Math,Ie="__osScrollbarsHidingPlugin",Ae={[Ie]:{A:t=>{const{T:e,I:n,L:o}=t,r=!(o||e||!n.x&&!n.y)&&document.createElement("style");return r&&(T(r,"id",`${Jt}-${Re}`),Re++),r},H:(n,o,r,i,s,l,c)=>[(t,o,l,c)=>{if(n){const{P:n}=s(),{D:a,M:d}=t,{x:u,y:h}=d,{x:p,y:f}=a,g=n[c?"paddingRight":"paddingLeft"],w=n.paddingTop,b=o.w+l.w,v=o.h+l.h,y={w:f&&h?`${f+b-g}px`:"",h:p&&u?`${p+v-w}px`:""};if(i){const{sheet:t}=i;if(t){const{cssRules:e}=t;if(e){e.length||t.insertRule(`#${T(i,"id")} + .${Jt}::before {}`,0);const n=e[0].style;n.width=y.w,n.height=y.h}}}else e(r,{"--os-vaw":y.w,"--os-vah":y.h})}return n},(i,a,d)=>{if(n){const u=d||l(i),{P:h}=s(),{M:p}=u,{x:f,y:g}=p,w={},b=e=>t(e.split(" "),(t=>{w[t]=h[t]}));f&&b("marginBottom paddingTop paddingBottom"),g&&b("marginLeft marginRight paddingLeft paddingRight");const v=e(r,L(w));return ct(r,Jt),o||(w.height=""),e(r,w),[()=>{c(u,a,n,v),e(r,v),at(r,Jt)},u]}return[gt]}],R:()=>{let t={w:0,h:0},e=0;return(n,o,r)=>{const i={w:window.innerWidth,h:window.innerHeight},s={w:i.w-t.w,h:i.h-t.h};if(0===s.w&&0===s.h)return;const l=ze(s.w),c=ze(s.h),a={w:ze(De(i.w/(t.w/100))),h:ze(De(i.h/(t.h/100)))},d=(()=>{const t=window.screen.deviceXDPI||0,e=window.screen.logicalXDPI||1;return window.devicePixelRatio||t/e})(),u=l>2&&c>2,h=!((t,e)=>{const n=ze(t),o=ze(e);return!(n===o||n+1===o||n-1===o)})(a.w,a.h);if(u&&h&&d!==e&&d>0){const[t,e]=o();C(n.k,t),e&&r()}t=i,e=d}}}};let Be;const ke=(t,e,n,o)=>{V(t,e);const r=St(e),i=Ot(e),s=Ct(n);return o&&F(e),{x:i.h-r.h+s.h,y:i.w-r.w+s.w}},He=(t,n)=>{const o="hidden";e(t,{overflowX:o,overflowY:o,direction:"rtl"}),D(t,0);const r=It(t),i=It(n);D(t,-999);const s=It(n);return{i:r.x===i.x,n:i.x!==s.x}},Ye=(t,e)=>{const n=at(t,Vt),o=Pt(t),r=Pt(e),i=ft(r,o,!0),s=at(t,jt),l=Pt(t),c=Pt(e),a=ft(c,l,!0);return n(),s(),i&&a},Xe=()=>(Be||(Be=(()=>{const{body:t}=document,o=N(`<div class="${Xt}"><div></div></div>`)[0],r=o.firstChild,[i,,s]=Bt(),[l,c]=n({o:ke(t,o,r),u:ht},ke.bind(0,t,o,r,!0)),[a]=c(),d=(t=>{let n=!1;const o=at(t,Qt);try{n="none"===e(t,J("scrollbar-width"))||"none"===window.getComputedStyle(t,"::-webkit-scrollbar").getPropertyValue("display")}catch(r){}return o(),n})(o),u={x:0===a.x,y:0===a.y},h={host:null,padding:!d,viewport:t=>d&&t===t.ownerDocument.body&&t,content:!1,scrollbarsSlot:!0,cancel:{nativeScrollbarsOverlaid:!0,body:null}},p=C({},$e),f={k:a,I:u,T:d,L:"-1"===e(o,"zIndex"),B:He(o,r),V:Ye(o,r),j:t=>i("_",t),Y:C.bind(0,{},h),q(t){C(h,t)},F:C.bind(0,{},p),G(t){C(p,t)},N:C({},h),U:C({},p)};if(R(o,"style"),F(o),!(d||u.x&&u.y)){let t;window.addEventListener("resize",(()=>{const e=Le()[Ie];t=t||e&&e.R(),t&&t(f,l,s.bind(0,"_"))}))}return f})()),Be),Ve=(t,e)=>h(t)?t.apply(0,e):t,je=(t,e,n,o)=>{const r=s(o)?n:o;return Ve(r,t)||e()},Fe=(t,e,n,o)=>{const r=s(o)?n:o,i=Ve(r,t);return!!i&&(b(i)?i:e())},_e=_.bind(0,""),Ne=t=>{V(H(t),k(t)),F(t)},Ze=t=>{const e=Xe(),{Y:n,T:o}=e,r=Le()[Ie],i=r&&r.A,{host:s,viewport:l,padding:c,content:a}=n(),d=b(t),u=d?{}:t,{host:h,padding:p,viewport:f,content:g}=u,w=d?t:u.target,v=B(w,"textarea"),x=w.ownerDocument,$=w===x.body,S=x.defaultView,C=je.bind(0,[w]),P=Fe.bind(0,[w]),M=C(_e,l,f),D=M===w,z={J:w,K:v?C(_e,s,h):w,Z:M,tt:!D&&P(_e,c,p),nt:!D&&P(_e,a,g),ot:!D&&!o&&i&&i(e),st:$?x.documentElement:M,et:$?x:M,ct:S,rt:x,it:v,W:$,lt:d,X:D,ut:(t,e)=>D?((t,e,n)=>{const o=T(t,Ft)||"";return new Set(o.split(" ")).has(n)})(M,0,e):((t,e)=>lt(t,e,((t,e)=>t.contains(e))))(M,t),ft:(t,e,n)=>D?E(M,Ft,e,n):(n?at:ct)(M,t)},I=L(z).reduce(((t,e)=>{const n=z[e];return m(t,!(!n||H(n))&&n)}),[]),A=t=>t?y(I,t)>-1:null,{J:Y,K:_,tt:N,Z,nt:W,ot:G}=z,K=[],q=v&&A(_),J=v?Y:k([W,Z,N,_,Y].find((t=>!1===A(t)))),U=W||Z;return[z,()=>{const t=((t,e)=>(T(t,Ft,e),R.bind(0,t,Ft)))(_,D?"viewport":"host"),e=at(N,Kt),n=at(Z,!D&&qt),r=at(W,Ut),i=$?at(H(w),Qt):gt;q&&(j(Y,_),m(K,(()=>{j(_,Y),F(_)}))),V(U,J),V(_,N),V(N||_,!D&&Z),V(Z,W),m(K,(()=>{i(),t(),R(Z,_t),R(Z,Nt),A(W)&&Ne(W),A(Z)&&Ne(Z),A(N)&&Ne(N),e(),n(),r()})),o&&!D&&m(K,ct.bind(0,Z,Qt)),G&&(((t,e)=>{X(H(t),t,e)})(Z,G),m(K,F.bind(0,G)))},O.bind(0,K)]},We=(t,n)=>{const{nt:o}=t,[r]=n;return t=>{const{V:n}=Xe(),{dt:i}=r(),{_t:s}=t,l=(o||!n)&&s;return l&&e(o,{height:i?"":"100%"}),{ht:l,gt:l}}},Ge=(t,o)=>{const[r,i]=o,{K:s,tt:l,Z:c,X:a}=t,[d,u]=n({u:pt,o:xt()},xt.bind(0,s,"padding",""));return(t,n,o)=>{let[s,h]=u(o);const{T:p,V:f}=Xe(),{vt:g}=r(),{ht:w,gt:b,wt:v}=t,[y,m]=n("paddingAbsolute");(w||h||!f&&b)&&([s,h]=d(o));const x=!a&&(m||v||h);if(x){const t=!y||!l&&!p,n=s.r+s.l,o=s.t+s.b,r={marginRight:t&&!g?-n:0,marginBottom:t?-o:0,marginLeft:t&&g?-n:0,top:t?-s.t:0,right:t?g?-s.r:"auto":0,left:t?g?"auto":-s.l:0,width:t?`calc(100% + ${n}px)`:""},a={paddingTop:t?s.t:0,paddingRight:t?s.r:0,paddingBottom:t?s.b:0,paddingLeft:t?s.l:0};e(l||c,r),e(c,a),i({tt:s,bt:!t,P:l?a:C({},r,a)})}return{yt:x}}},{max:Ke}=Math,qe=Ke.bind(0,0),Je="visible",Ue="hidden",Qe=42,tn={u:ut,o:{w:0,h:0}},en={u:ht,o:{x:Ue,y:Ue}},nn=(t,e,n)=>n?at(t,e):ct(t,e),on=t=>0===t.indexOf(Je),rn=(t,o)=>{const[r,i]=o,{K:s,tt:l,Z:c,ot:a,X:d,ft:u}=t,{k:h,V:p,T:f,I:g}=Xe(),w=Le()[Ie],b=!d&&!f&&(g.x||g.y),[v,y]=n(tn,Ct.bind(0,c)),[m,x]=n(tn,Lt.bind(0,c)),[$,O]=n(tn),[S,L]=n(tn),[C]=n(en),P=(t,n)=>{if(e(c,{height:""}),n){const{bt:n,tt:o}=r(),{St:i,D:l}=t,a=Ct(s),d=St(s),u="content-box"===e(c,"boxSizing"),h=n||u?o.b+o.t:0,p=!(g.x&&u);e(c,{height:d.h+a.h+(i.x&&p?l.x:0)-h})}},M=(t,n)=>{const o=f||t?0:Qe,r=(t,r,i)=>{const s=e(c,t),l="scroll"===(n?n[t]:s);return[s,l,l&&!f?r?o:i:0,r&&!!o]},[i,s,l,a]=r("overflowX",g.x,h.x),[d,u,p,w]=r("overflowY",g.y,h.y);return{xt:{x:i,y:d},St:{x:s,y:u},D:{x:l,y:p},M:{x:a,y:w}}},R=(t,e,n,o)=>{const{D:i,M:s}=t,{x:l,y:c}=s,{x:a,y:d}=i,{P:u}=r(),h=e?"marginLeft":"marginRight",p=e?"paddingLeft":"paddingRight",f=u[h],g=u.marginBottom,w=u[p],b=u.paddingBottom;o.width=`calc(100% + ${d+-1*f}px)`,o[h]=-d+f,o.marginBottom=-a+g,n&&(o[p]=w+(c?d:0),o.paddingBottom=b+(l?a:0))},[D,z]=w?w.H(b,p,c,a,r,M,R):[()=>b,()=>[gt]];return(t,n,o)=>{const{ht:a,$t:h,gt:w,yt:b,_t:I,wt:A}=t,{dt:B,vt:k}=r(),[H,Y]=n("showNativeOverlaidScrollbars"),[X,V]=n("overflow"),j=H&&g.x&&g.y,F=!d&&!p&&(a||w||h||Y||I),_=on(X.x),N=on(X.y),Z=_||N;let W,G=y(o),K=x(o),q=O(o),J=L(o);if(Y&&f&&u(Qt,Wt,!j),F&&(W=M(j),P(W,B)),a||b||w||A||Y){Z&&u(te,Zt,!1);const[t,e]=z(j,k,W),[n,r]=G=v(o),[i,s]=K=m(o),l=St(c);let a=i,d=l;t(),(s||r||Y)&&e&&!j&&D(e,i,n,k)&&(d=St(c),a=Lt(c));const h={w:qe(Ke(i.w,a.w)+n.w),h:qe(Ke(i.h,a.h)+n.h)},p={w:qe(d.w+qe(l.w-i.w)+n.w),h:qe(d.h+qe(l.h-i.h)+n.h)};J=S(p),q=$(((t,e)=>{const n=window.devicePixelRatio%1!=0?1:0,o={w:qe(t.w-e.w),h:qe(t.h-e.h)};return{w:o.w>n?o.w:0,h:o.h>n?o.h:0}})(h,p),o)}const[U,Q]=J,[tt,et]=q,[nt,ot]=K,[rt,it]=G,st={x:tt.w>0,y:tt.h>0},lt=_&&N&&(st.x||st.y)||_&&st.x&&!st.y||N&&st.y&&!st.x;if(b||A||it||ot||Q||et||V||Y||F){const t={marginRight:0,marginBottom:0,marginLeft:0,width:"",overflowY:"",overflowX:""},n=((t,e,n,o)=>{const r=(t,e)=>{const n=on(t),o=e&&n&&t.replace(`${Je}-`,"")||"";return[e&&!n?t:"",on(o)?"hidden":o]},[i,s]=r(n.x,e.x),[l,c]=r(n.y,e.y);return o.overflowX=s&&l?s:i,o.overflowY=c&&i?c:l,M(t,o)})(j,st,X,t),o=D(n,nt,rt,k);d||R(n,k,o,t),F&&P(n,B),d?(T(s,_t,t.overflowX),T(s,Nt,t.overflowY)):e(c,t)}E(s,Ft,Zt,lt),nn(l,te,lt),!d&&nn(c,te,Z);const[ct,at]=C(M(j).xt);return i({xt:ct,Ct:{x:U.w,y:U.h},Ot:{x:tt.w,y:tt.h},At:st}),{zt:at,Tt:Q,It:et}}},sn=(e,n,o)=>{const r={},i=n||{};return t(L(e).concat(L(i)),(t=>{const n=e[t],s=i[t];r[t]=!!(o||n||s)})),r},ln=3333333,cn=t=>"rtl"===e(t,"direction"),an=t=>t&&(t.height||t.width),dn=(t,e,o)=>{const{Et:r=!1,Lt:i=!1}=o||{},s=Le()[Te],{B:l}=Xe(),c=N(`<div class="${ee}"><div class="${oe}"></div></div>`)[0],a=c.firstChild,d=cn.bind(0,c),[h]=n({o:void 0,_:!0,u:(t,e)=>!(!t||!an(t)&&an(e))}),g=t=>{const n=p(t)&&t.length>0&&f(t[0]),o=!n&&u(t[0]);let i=!1,s=!1,a=!0;if(n){const[e,,n]=h(t.pop().contentRect),o=an(e),r=an(n);i=!n||!o,s=!r&&o,a=!i}else o?[,a]=t:s=!0===t;if(r&&a){const e=o?t[0]:cn(c);D(c,e?l.n?-ln:l.i?0:ln:ln),z(c,ln)}i||e({ht:!o,Ht:o?t:void 0,Lt:!!s})},w=[];let b,v=!!i&&g;return[()=>{O(w),F(c)},()=>{if(et){const t=new et(g);t.observe(a),m(w,(()=>{t.disconnect()}))}else if(s){const[t,e]=s.O(a,g,i);v=t,m(w,e)}if(r){b=n({o:!d()},d);const[t]=b;m(w,Rt(c,"scroll",(e=>{const n=t(),[o,r]=n;r&&(ct(a,"ltr rtl"),at(a,o?"rtl":"ltr"),g(n)),Dt(e)})))}v&&(at(c,ne),m(w,Rt(c,"animationstart",v,{C:!!et}))),V(t,c)}]},un=(t,e)=>{let o;const r=_(le),i=[],[s]=n({o:!1}),l=(t,n)=>{if(t){const o=s((t=>0===t.h||t.isIntersecting||t.intersectionRatio>0)(t)),[,r]=o;if(r)return!n&&e(o),[o]}},c=(t,e)=>{if(t&&t.length>0)return l(t.pop(),e)};return[()=>{O(i),F(r)},()=>{if(tt)o=new tt((t=>c(t)),{root:t}),o.observe(r),m(i,(()=>{o.disconnect()}));else{const t=()=>{const t=Ot(r);l(t)},[e,n]=dn(r,t);m(i,e),n(),t()}V(t,r)},()=>{if(o)return c(o.takeRecords(),!0)}]},hn=(e,n,o,r)=>{let i=!1;const{Pt:s,Dt:l,Mt:c,Rt:a,kt:u,Bt:h}=r||{},p=wt((()=>{i&&o(!0)}),{g:33,v:99}),[f,g]=((e,n,o)=>{let r,i=!1;const s=s=>{if(o){const l=o.reduce(((t,n)=>{if(n){const o=n[0],r=n[1],i=r&&o&&(s?s(o):A(o,e));i&&i.length&&r&&d(r)&&m(t,[i,r.trim()],!0)}return t}),[]);t(l,(e=>t(e[0],(t=>{const o=e[1],s=r.get(t);if(s){const t=s[0],e=s[1];t===o&&e()}const l=Rt(t,o,(e=>{i?(l(),r.delete(t)):n(e)}));r.set(t,[o,l])}))))}};return o&&(r=new WeakMap,s()),[()=>{i=!0},s]})(e,p,c),w=l||[],b=(s||[]).concat(w),v=(i,s)=>{const l=u||gt,c=h||gt,p=[],f=[];let b=!1,v=!1,x=!1;return t(i,(t=>{const{attributeName:o,target:i,type:s,oldValue:u,addedNodes:h}=t,g="attributes"===s,$="childList"===s,O=e===i,S=g&&d(o)?T(i,o):0,L=0!==S&&u!==S,C=y(w,o)>-1&&L;if(n&&!O){const n=!g,s=g&&C,d=s&&a&&B(i,a),p=(d?!l(i,o,u,S):n||s)&&!c(t,!!d,e,r);m(f,h),v=v||p,x=x||$}!n&&O&&L&&!l(i,o,u,S)&&(m(p,o),b=b||C)})),x&&!$(f)&&g((t=>f.reduce(((e,n)=>(m(e,A(t,n)),B(n,t)?m(e,n):e)),[]))),n?(!s&&v&&o(!1),[!1]):!$(p)||b?(!s&&o(p,b),[p,b]):void 0},x=new Q((t=>v(t)));return x.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:b,subtree:n,childList:n,characterData:n}),i=!0,[()=>{i&&(f(),x.disconnect(),i=!1)},()=>{if(i){p.m();const t=x.takeRecords();return!$(t)&&v(t,!0)}}]},pn=`[${Ft}]`,fn=`.${qt}`,gn=["tabindex"],wn=["wrap","cols","rows"],bn=["id","class","style","open"],vn=(e,o,r)=>{let i,s,l;const[,c]=o,{K:u,Z:f,nt:g,it:w,X:b,ut:x,ft:$}=e,{V:O}=Xe(),[S]=n({u:ut,o:{w:0,h:0}},(()=>{const t=x(te,Zt),e=x(Jt,""),n=e&&D(f),o=e&&z(f);$(te,Zt),$(Jt,""),$("",Gt,!0);const r=Lt(g),i=Lt(f),s=Ct(f);return $(te,Zt,t),$(Jt,"",e),$("",Gt),D(f,n),z(f,o),{w:i.w+r.w+s.w,h:i.h+r.h+s.h}})),P=w?wn:bn.concat(wn),M=wt(r,{g:()=>i,v:()=>s,p(t,e){const[n]=t,[o]=e;return[L(n).concat(L(o)).reduce(((t,e)=>(t[e]=n[e]||o[e],t)),{})]}}),E=e=>{t(e||gn,(t=>{if(y(gn,t)>-1){const e=T(u,t);d(e)?T(f,t,e):R(f,t)}}))},I=(t,e)=>{const[n,o]=t,i={_t:o};return c({dt:n}),!e&&r(i),i},A=({ht:t,Ht:e,Lt:n})=>{const o=!t||n?r:M;let i=!1;if(e){const[t,n]=e;i=n,c({vt:t})}o({ht:t,wt:i})},B=(t,e)=>{const[,n]=S(),o={gt:n};return n&&!e&&(t?r:M)(o),o},k=(t,e,n)=>{const o={$t:e};return e?!n&&M(o):b||E(t),o},[H,X,V]=g||!O?un(u,I):[gt,gt,gt],[j,F]=b?[gt,gt]:dn(u,A,{Lt:!0,Et:!0}),[_,N]=hn(u,!1,k,{Dt:bn,Pt:bn.concat(gn)}),Z=b&&et&&new et(A.bind(0,{ht:!0}));return Z&&Z.observe(u),E(),[()=>{H(),j(),l&&l[0](),Z&&Z.disconnect(),_()},()=>{F(),X()},()=>{const t={},e=N(),n=V(),o=l&&l[1]();return e&&C(t,k.apply(0,m(e,!0))),n&&C(t,I.apply(0,m(n,!0))),o&&C(t,B.apply(0,m(o,!0))),t},t=>{const[e]=t("updating.ignoreMutation"),[n,o]=t("updating.attributes"),[r,c]=t("updating.elementEvents"),[d,u]=t("updating.debounce"),w=t=>h(e)&&e(t);if((c||o)&&(l&&(l[1](),l[0]()),l=hn(g||f,!0,B,{Dt:P.concat(n||[]),Pt:P.concat(n||[]),Mt:r,Rt:pn,Bt:(t,e)=>{const{target:n,attributeName:o}=t;return!(e||!o)&&((t,e,n)=>{const o=t&&Y(t,e),r=t&&((t,e)=>{const n=e?v(e)?e:null:document;return n?n.querySelector(t):null})(n,o);return!(!o||!r||o!==t&&r!==t&&Y(Y(t,n),e)===o)})(n,pn,fn)||!!Y(n,`.${ce}`)||!!w(t)}})),u)if(M.m(),p(d)){const t=d[0],e=d[1];i=!!a(t)&&t,s=!!a(e)&&e}else a(d)?(i=d,s=!1):(i=!1,s=!1)}]},yn={x:0,y:0},mn={tt:{t:0,r:0,b:0,l:0},bt:!1,P:{marginRight:0,marginBottom:0,marginLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0},Ct:yn,Ot:yn,xt:{x:"hidden",y:"hidden"},At:{x:!1,y:!1},dt:!1,vt:!1},{round:xn,abs:$n}=Math,On=t=>({x:t.pageX,y:t.pageY}),Sn=(t,e)=>Rt(t,"mousedown",Rt.bind(0,e,"click",Dt,{C:!0,$:!0}),{$:!0}),Ln=(t,n,o,r,i,s)=>{const{B:l}=Xe(),{qt:c,Ft:a,Gt:d}=o,u=`scroll${s?"Left":"Top"}`,h=`${s?"x":"y"}`,p=`${s?"w":"h"}`,f=(t,n,o)=>f=>{const{Ot:g}=i(),w=(On(f)[h]-n)*o/(Ot(a)[p]-Ot(c)[p])*g[h],b="rtl"===e(d,"direction")&&s?l.n||l.i?1:-1:1;r[u]=$n(t)+w*b};return Rt(c,"pointerdown",(e=>{if(((t,e,n)=>{const o=e.scrollbars,{button:r,isPrimary:i,pointerType:s}=t,{pointers:l}=o;return 0===r&&i&&o["dragScroll"]&&(l||[]).includes(s)})(e,t)){const t=Rt(n,"selectstart",(t=>(t=>t.preventDefault())(t)),{S:!1}),o=Rt(c,"pointermove",f(r[u]||0,On(e)[h],1/(t=>{const{width:e,height:n}=Pt(t),{w:o,h:r}=Ot(t);return{x:xn(e)/o||1,y:xn(n)/r||1}})(r)[h]));Rt(c,"pointerup",(e=>{t(),o(),c.releasePointerCapture(e.pointerId)}),{C:!0}),c.setPointerCapture(e.pointerId)}}))},{min:Cn,max:Pn,abs:Mn}=Math,Tn=(t,e,n,o)=>{if(o){const t=n?"x":"y",{Ot:e,Ct:r}=o,i=r[t],s=e[t];return Pn(0,Cn(1,i/(i+s)))}const r=n?"w":"h",i=Ot(t)[r],s=Ot(e)[r];return Pn(0,Cn(1,i/s))},En=(n,o,r)=>{const{Y:i}=Xe(),{scrollbarsSlot:s}=i(),{rt:l,J:c,K:a,Z:d,lt:h,st:p}=o,{scrollbarsSlot:f}=h?{}:n,g=Fe([c,a,d],(()=>a),s,f),w=(e,n,o)=>{const r=o?at:ct;t(e,(t=>{r(t.Gt,n)}))},b=(n,o)=>{t(n,(t=>{const[n,r]=o(t);e(n,r)}))},v=(t,e,n)=>{b(t,(t=>{const{qt:o,Ft:r}=t;return[o,{[n?"width":"height"]:`${(100*Tn(o,r,n,e)).toFixed(3)}%`}]}))},y=(t,n,o)=>{const r=o?"X":"Y";b(t,(t=>{const{qt:i,Ft:s,Gt:l}=t,c=((t,e,n,o,r,i)=>{const{B:s}=Xe(),l=i?"x":"y",c=i?"Left":"Top",{Ot:a}=o,d=Math.floor(a[l]),u=Mn(n[`scroll${c}`]),h=i&&r,p=s.i?u:d-u,f=Cn(1,(h?p:u)/d),g=Tn(t,e,i);return 1/g*(1-g)*f})(i,s,p,n,"rtl"===e(l,"direction"),o);return[i,{transform:c==c?`translate${r}(${(100*c).toFixed(3)}%)`:""}]}))},x=[],S=[],L=[],C=(t,e,n)=>{const o=u(n),r=!o||!n;(!o||n)&&w(S,t,e),r&&w(L,t,e)},P=t=>{const e=t?ae:de,n=t?S:L,o=$(n)?ge:"",i=_(`${ce} ${e} ${o}`),s=_(ue),c=_(he),a={Gt:i,Ft:s,qt:c};return V(i,s),V(s,c),m(n,a),m(x,[F.bind(0,i),r(a,C,l,p,t)]),a},M=P.bind(0,!0),T=P.bind(0,!1);return M(),T(),[{Nt:t=>{v(S,t,!0),v(L,t)},Ut:t=>{y(S,t,!0),y(L,t)},Wt:C,Xt:{Jt:S,Kt:M,Zt:b.bind(0,S)},Qt:{Jt:L,Kt:T,Zt:b.bind(0,L)}},()=>{V(g,S[0].Gt),V(g,L[0].Gt),rt((()=>{C(ge)}),300)},O.bind(0,x)]},Rn=t=>{let e;const n=t?rt:ot,o=t?it:nt;return[r=>{o(e),e=n(r,h(t)?t():t)},()=>o(e)]},Dn=new Set,zn=new WeakMap,In=(e,n,o)=>{let r=!1;const{F:i,j:c}=Xe(),a=Le(),d=b(e),u=d?e:e.target,p=(t=>zn.get(t))(u);if(p)return p;const f=a[Ce],g=t=>{const e=t||{},n=f&&f.O;return n?n(e,!0):e},w=C({},i(),g(n)),[v,y,m]=Bt(o),[x,$,S]=((e,n)=>{const o=Ht(n,{}),r=Yt(mn),[i,s,l]=Bt(),[c]=r,[a,d,u]=Ze(e),h=((e,n)=>{const{Z:o,ft:r}=e,{T:i,I:s,V:l}=Xe(),c=!i&&(s.x||s.y),a=[We(e,n),Ge(e,n),rn(e,n)];return(e,n,i)=>{const s=sn(C({ht:!1,yt:!1,wt:!1,_t:!1,Tt:!1,It:!1,zt:!1,$t:!1,gt:!1},n),{},i),d=c||!l,u=d&&D(o),h=d&&z(o);r("",Gt,!0);let p=s;return t(a,(t=>{p=sn(p,t(p,e,!!i)||{},i)})),D(o,u),z(o,h),r("",Gt),p}})(a,r),p=(t,e,n)=>{const o=L(t).some((e=>t[e]));(o||!P(e)||n)&&l("u",[t,e,n])},[f,g,w,b]=vn(a,r,(t=>{p(h(o,t),{},!1)})),v=c.bind(0);return v.Vt=t=>{i("u",t)},v.jt=()=>{g(),d()},v.Yt=a,[(t,e)=>{const o=Ht(n,t,e);b(o),p(h(o,w(),e),t,!!e)},v,()=>{s(),f(),u()}]})(e,w),[M,T,E]=((t,e,n)=>{let o,r,i,s,l,c=0;const a=Yt({}),[d]=a,[u,h]=Rn(),[p,f]=Rn(),[g,w]=Rn(100),[b,v]=Rn(100),[y,m]=Rn((()=>c)),[x,$,S]=En(t,n.Yt,((t,e)=>(n,o,r,i,s)=>{const{Gt:l}=n;return O.bind(0,[Rt(l,"pointerenter",(()=>{o(we,!0)})),Rt(l,"pointerleave pointercancel",(()=>{o(we)})),Sn(l,r),Ln(t,r,n,i,e,s)])})(e,n)),{K:L,Z:C,st:P,et:M,X:T,W:E}=n.Yt,{Xt:R,Qt:I,Wt:A,Nt:B,Ut:k}=x,{Zt:Y}=R,{Zt:X}=I,V=t=>{const{Gt:e}=t,n=T&&!E&&H(e)===C&&e;return[n,{transform:n?`translate(${D(P)}px, ${z(P)}px)`:""}]},j=(t,e)=>{if(m(),t)A(ve);else{const t=()=>A(ve,!0);c>0&&!e?y(t):t()}},F=()=>{s=r,s&&j(!0)},_=[w,m,v,f,h,S,Rt(L,"mouseover",F,{C:!0}),Rt(L,"mouseenter",F),Rt(L,"mouseleave",(()=>{s=!1,r&&j(!1)})),Rt(L,"mousemove",(()=>{o&&u((()=>{w(),j(!0),b((()=>{o&&j(!1)}))}))})),Rt(M,"scroll",(()=>{p((()=>{k(n()),i&&j(!0),g((()=>{i&&!s&&j(!1)}))})),T&&Y(V),T&&X(V)}))],N=d.bind(0);return N.Yt=x,N.jt=$,[(t,s,a)=>{const{Tt:d,It:u,zt:h,wt:p}=a,f=Ht(e,t,s),g=n(),{Ot:w,xt:b}=g,[v,y]=f("scrollbars.theme"),[m,x]=f("scrollbars.visibility"),[$,O]=f("scrollbars.autoHide"),[S]=f("scrollbars.autoHideDelay"),[L,C]=f("scrollbars.dragScroll"),[P,M]=f("scrollbars.clickScroll"),T=d||u||p,E=h||x,R=(t,e)=>{const n="visible"===m||"auto"===m&&"scroll"===t;return A(pe,n,e),n};if(c=S,y&&(A(l),A(v,!0),l=v),O&&(o="move"===$,r="leave"===$,i="never"!==$,j(!i,!0)),C&&A(me,L),M&&A(ye,P),E){const t=R(b.x,!0),e=R(b.y,!1);A(fe,!(t&&e))}T&&(B(g),k(g),A(be,!w.x,!0),A(be,!w.y,!1))},N,O.bind(0,_)]})(e,w,$),R=(t,e)=>{x(t,!!e)},I=c(R.bind(0,{},!0)),A=t=>{(t=>{zn.delete(t),Dn.delete(t)})(u),I(),E(),S(),r=!0,m("destroyed",[B,!!t]),y()},B={options(t){if(t){const e=Oe(w,g(t));P(e)||(C(w,e),R(e))}return C({},w)},on:v,off:(t,e)=>{t&&e&&y(t,e)},state(){const{Ct:t,Ot:e,xt:n,At:o,tt:i,bt:s}=$();return C({},{overflowEdge:t,overflowAmount:e,overflowStyle:n,hasOverflow:o,padding:i,paddingAbsolute:s,destroyed:r})},elements(){const{J:t,K:e,tt:n,Z:o,nt:r}=$.Yt;return C({},{target:t,host:e,padding:n||o,viewport:o,content:r||o})},update:t=>(R({},t),B),destroy:A.bind(0)};return $.Vt(((t,e,n)=>{M(e,n,t)})),t(L(a),(t=>{const e=a[t];h(e)&&e(In,B)})),((t,e)=>{const{nativeScrollbarsOverlaid:n,body:o}=t||{},{W:r,X:i}=e,{Y:c,I:a}=Xe(),{nativeScrollbarsOverlaid:d,body:u}=c().cancel,h=null!=n?n:d,p=s(o)?u:o,f=(a.x||a.y)&&h,g=r&&(l(p)?!i:p);return!!f||!!g})(!d&&e.cancel,$.Yt)?(A(!0),B):($.jt(),T.jt(),((t,e)=>{zn.set(t,e),Dn.add(t)})(u,B),m("initialized",[B]),$.Vt(((t,e,n)=>{const{ht:o,wt:r,_t:i,Tt:s,It:l,zt:c,gt:a,$t:d}=t;m("updated",[B,{updateHints:{sizeChanged:o,directionChanged:r,heightIntrinsicChanged:i,overflowEdgeChanged:s,overflowAmountChanged:l,overflowStyleChanged:c,contentMutation:a,hostMutation:d},changedOptions:e,force:n}])})),B.update(!0))};In.plugin=e=>{t(p(e)?e:[e],(e=>{t(L(e),(t=>{Se[t]=e[t]}))}))},In.env=()=>{const{k:t,I:e,T:n,B:o,V:r,L:i,N:s,U:l,Y:c,q:a,F:d,G:u}=Xe();return C({},{scrollbarsSize:t,scrollbarsOverlaid:e,scrollbarsHiding:n,rtlScrollBehavior:o,flexboxGlue:r,cssCustomProperties:i,staticDefaultInitialization:s,staticDefaultOptions:l,getDefaultInitialization:c,setDefaultInitialization:a,getDefaultOptions:d,setDefaultOptions:u})};export{In as OverlayScrollbars,Ae as scrollbarsHidingPlugin,Ee as sizeObserverPlugin};