Files
OverlayScrollbars/packages/overlayscrollbars/dist/overlayscrollbars.esm.min.js
T

1 line
25 KiB
JavaScript

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