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

1 line
24 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(O(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=window.HTMLElement;return!!t&&(e?t instanceof e:t.nodeType===o)},b=t=>{const e=window.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),O=t=>t?Object.keys(t):[],P=(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(O(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]=P(i,o)}else e[t]=o}))})),e},L=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)},T=(t,e,n)=>{if(s(n))return t?t.getAttribute(e):null;t&&t.setAttribute(e,n)},A=(t,e,n,o)=>{const r=T(t,e)||"",i=new Set(r.split(" "));i[o?"add":"delete"](n),T(t,e,m(i).join(" ").trim())},E=(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,j=(t,e)=>{const n=[],o=e?b(e)?e:null:document;return o?y(n,o.querySelectorAll(t)):n},z=(t,e)=>!!b(t)&&(M.matches||M.msMatchesSelector).call(t,e),B=t=>t?m(t.childNodes):[],H=t=>t?t.parentElement:null,I=(t,e)=>{if(b(t)){const n=M.closest;if(n)return n.call(t,e);do{if(z(t,e))return t;t=H(t)}while(t)}return null},k=(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)=>{k(t,null,e)},Y=(t,e)=>{k(t,t&&t.firstChild,e)},V=(t,e)=>{k(H(t),t&&t.nextSibling,e)},X=e=>{if(f(e))t(m(e),(t=>X(t)));else if(e){const t=H(e);t&&t.removeChild(e)}},N=t=>{const e=document.createElement("div");return t&&T(e,"class",t),e},W=e=>{const n=N();return n.innerHTML=e.trim(),t(B(n),(t=>X(t)))},F=t=>t.charAt(0).toUpperCase()+t.slice(1),K=["-webkit-","-moz-","-o-","-ms-"],J=["WebKit","Moz","O","MS","webkit","moz","o","ms"],q={},U={},G=e=>{let n=U[e];if($(U,e))return n;const o=F(e),r=N().style;return t(K,(t=>{const i=t.replace(/-/g,""),s=[e,t+e,i+o,F(i)+o];return!(n=s.find((t=>void 0!==r[t])))})),U[e]=n||""},Z=e=>{let n=q[e]||window[e];return $(q,e)||(t(J,(t=>(n=n||window[t+F(e)],!n))),q[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&&window.clearTimeout(t),t&&nt(t)},ft=()=>{},gt=(t,e)=>{let n,o,r,i;const{v:s,p:l,m:c}=e||{},d=window.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,Ot=t=>t?{w:t.clientWidth,h:t.clientHeight}:xt,Pt=t=>t?{w:t.scrollWidth,h:t.scrollHeight}:xt,Lt=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 Tt;const At=t=>t.split(" "),Et=(e,n,o,r)=>{t(At(n),(t=>{e.removeEventListener(t,o,r)}))},Ct=(e,n,o,r)=>{const i=(()=>{if(s(Tt)){Tt=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get(){Tt=!0}}))}catch(e){}}return Tt})(),l=i&&r&&r.C||!1,c=r&&r.$||!1,a=r&&r.O||!1,d=[],u=i?{passive:l,capture:c}:c;return t(At(n),(t=>{const n=a?r=>{e.removeEventListener(t,n,c),o&&o(r)}:o;y(d,Et.bind(null,e,t,n,c)),e.addEventListener(t,n,u)})),_.bind(0,d)},Rt=t=>(t=>t.stopPropagation())(t)||(t=>t.preventDefault())(t),Mt={x:0,y:0},jt=t=>{const e=t?St(t):0;return e?{x:e.left+window.pageYOffset,y:e.top+window.pageXOffset}:Mt},zt=(e,n)=>{t(h(n)?n:[n],e)},Bt=e=>{const n=new Map,o=(t,e)=>{if(t){const o=n.get(t);zt((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),zt((t=>{t&&r.add(t)}),e),o.bind(0,t,e)};return t(O(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()}))}]},Ht=(t,e)=>t?e.split(".").reduce(((t,e)=>t&&$(t,e)?t[e]:void 0),t):void 0,It=(t,e,n)=>o=>[Ht(t,o),n||void 0!==Ht(e,o)],kt=t=>{let e=t;return[()=>e,t=>{e=P({},e,t)}]},Dt="os-environment",Yt=`${Dt}-flexbox-glue`,Vt=`${Yt}-max`,Xt="data-overlayscrollbars",Nt=`${Xt}-overflow-x`,Wt=`${Xt}-overflow-y`,Ft="overflowVisible",Kt="viewportStyled",Jt="os-padding",qt="os-viewport",Ut=`${qt}-arrange`,Gt="os-content",Zt=`${qt}-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=t=>JSON.stringify(t,((t,e)=>{if(u(e))throw new Error;return e})),pe={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}},fe=(e,n)=>{const o={};return t(O(n).concat(O(e)),(t=>{const r=e[t],i=n[t];if(p(r)&&p(i))P(o[t]={},fe(r,i));else if($(n,t)&&i!==r){let e=!0;if(h(r)||h(i))try{he(r)===he(i)&&(e=!1)}catch(q){}e&&(o[t]=i)}})),o};let ge;const{abs:we,round:be}=Math,ve=(t,e,n)=>{D(t,e);const o=Ot(e),r=$t(e),i=Lt(n);return{x:r.h-o.h+i.h,y:r.w-o.w+i.w}},ye=(t,n)=>{const o="hidden";e(t,{overflowX:o,overflowY:o,direction:"rtl"}),C(t,0);const r=jt(t),i=jt(n);C(t,-999);const s=jt(n);return{i:r.x===i.x,n:i.x!==s.x}},me=(t,e)=>{const n=lt(t,Yt),o=St(t),r=St(e),i=ht(r,o,!0),s=lt(t,Vt),l=St(t),c=St(e),a=ht(c,l,!0);return n(),s(),i&&a},xe=()=>{const t=window.screen.deviceXDPI||0,e=window.screen.logicalXDPI||1;return window.devicePixelRatio||t/e},_e=()=>(ge||(ge=(()=>{const{body:t}=document,o=W(`<div class="${Dt}"><div></div></div>`)[0],r=o.firstChild,[i,,s]=Bt(),[l,c]=n({u:ve(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={A:!d,I:!1},p=P({},pe),f={T:a,P:u,L:d,M:"-1"===e(o,"zIndex"),H:ye(o,r),R:me(o,r),D:t=>i("_",t),j:P.bind(0,{},h),V(t){P(h,t)},B:P.bind(0,{},p),k(t){P(p,t)},F:P({},h),Y:P({},p)};if(E(o,"style"),X(o),!(d||u.x&&u.y)){let e=_t(),n=xe();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=we(c.w),d=we(c.h),u={w:we(be(i.w/(e.w/100))),h:we(be(i.h/(e.h/100)))},h=xe(),p=a>2&&d>2,f=!((t,e)=>{const n=we(t),o=we(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(ve(t,o,r));P(ge.T,e),X(o),n&&s("_")}e=i,n=h}))}return f})()),ge),$e={},Oe=()=>P({},$e);var Pe={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}(Pe);const Le=function(t){return t&&t.o&&Object.prototype.hasOwnProperty.call(t,"default")?t["default"]:t}(Pe.exports),Se={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__"},Te=(e,n,o,r)=>{const i={},l=Le({},n);return t(O(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]=Te(p,u,o,w+a);i[a]=e,l[a]=n,t([l,i],(t=>{L(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(Se,((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=Se[f]===o;return y(r,l?Se.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]},Ae=Se.boolean,Ee=[Se.array,Se.null],Ce="hidden scroll visible visible-hidden",Re={paddingAbsolute:Ae,updating:{elementEvents:Ee,attributes:Ee,debounce:[Se.number,Se.array,Se.null],ignoreMutation:[Se.function,Se.null]},overflow:{x:Ce,y:Ce},scrollbars:{visibility:"visible hidden auto",autoHide:"never scroll leavemove",autoHideDelay:Se.number,dragScroll:Ae,clickScroll:Ae,touch:Ae},nativeScrollbarsOverlaid:{show:Ae,initialize:Ae}},Me="__osOptionsValidationPlugin",je={[Me]:{q:(t,e)=>{const[n,o]=((t,e,n)=>Te(Re,e,n))(0,t,e);return Le({},o,n)}}},ze=3333333,Be="scroll",He="__osSizeObserverPlugin",Ie={[He]:{q:(t,n,o)=>{const r=W(`<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,ze),R(l,ze),C(s,ze),R(s,ze)},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,Be,g),Ct(s,Be,g)]);return e(c,{width:ze,height:ze}),p(),[o?g.bind(0,!1):p,w]}}};let ke=0;const De="__osScrollbarsHidingPlugin",Ye={[De]:{G:()=>{const{L:t,P:e,M:n}=_e(),o=!(n||t||!e.x&&!e.y)&&document.createElement("style");return o&&(T(o,"id",`${Ut}-${ke}`),ke++),o},N:(n,o,r,i,s,l)=>{const{R:c}=_e();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(`#${T(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,O(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,Xe=(t,e,n,o)=>Ve(o||Ve(n,t),t)||e.apply(0,t),Ne=(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},We=N.bind(0,""),Fe=t=>{D(H(t),B(t)),X(t)},Ke=t=>{const{j:e,L:n}=_e(),o=Oe()[De],r=o&&o.G,{J:i,K:s,A:l,I:c}=e(),a=w(t),d=t,u=a?t:d.target,h=z(u,"textarea"),p=!h&&z(u,"body"),f=u.ownerDocument,g=f.body,b=f.defaultView,m=!!et&&!h&&n,x=Xe.bind(0,[u]),$=Ne.bind(0,[u]),P=[x(We,s,d.viewport),x(We,s),x(We)].filter((t=>!!m||t!==u))[0],L=P===u,S={Z:u,J:h?x(We,i,d.host):u,K:P,A:!L&&$(We,l,d.padding),I:!L&&$(We,c,d.content),tt:!L&&!n&&r&&r(),nt:b,ot:f,st:H(g),et:g,ct:h,it:p,rt:a,lt:L,ft:(t,e)=>L?((t,e,n)=>{const o=T(t,Xt)||"";return new Set(o.split(" ")).has(n)})(P,0,e):((t,e)=>it(t,e,((t,e)=>t.contains(e))))(P,t),ut:(t,e,n)=>L?A(P,Xt,e,n):(n?lt:st)(P,t)},C=O(S).reduce(((t,e)=>{const n=S[e];return y(t,!(!n||H(n))&&n)}),[]),R=t=>t?v(C,t)>-1:null,{Z:M,J:j,A:I,K:Y,I:N,tt:W}=S,F=[],K=h&&R(j),J=h?M:B([N,Y,I,j,M].find((t=>!1===R(t)))),q=N||Y;return[S,()=>{const t=((t,e)=>(T(t,Xt,e),E.bind(0,t,Xt)))(j,L?"viewport":"host"),e=lt(I,Jt),o=lt(Y,!L&&qt),r=lt(N,Gt);K&&(V(M,j),y(F,(()=>{V(j,M),X(j)}))),D(q,J),D(j,I),D(I||j,!L&&Y),D(Y,N),y(F,(()=>{t(),E(Y,Nt),E(Y,Wt),R(N)&&Fe(N),R(Y)&&Fe(Y),R(I)&&Fe(I),e(),o(),r()})),n&&!L&&y(F,st.bind(0,Y,Zt)),W&&(((t,e)=>{k(H(t),t,e)})(Y,W),y(F,X.bind(0,W)))},_.bind(0,F)]},Je=(t,n)=>{const{I:o}=t,[r]=n;return t=>{const{R:n}=_e(),{dt: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,A: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}=_e(),{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({A:s,bt:!t,U:l?a:P({},r,a)})}return{yt:x}}},{max:Ue}=Math,Ge="visible",Ze="hidden",Qe=42,tn={_:at,u:{w:0,h:0}},en={_:dt,u:{x:Ze,y:Ze}},nn=(t,e,n)=>n?lt(t,e):st(t,e),on=t=>0===t.indexOf(Ge),rn=(t,o)=>{const[r,i]=o,{J:s,A:l,K:c,tt:a,lt:d,ut:u}=t,{T:h,R:p,L:f,P:g}=_e(),w=Oe()[De],b=!d&&!f&&(g.x||g.y),[v,y]=n(tn,Lt.bind(0,c)),[m,x]=n(tn,Pt.bind(0,c)),[_,$]=n(tn),[O]=n(en),P=(t,n)=>{if(e(c,{height:""}),n){const{bt:n,A:o}=r(),{St:i,W:l}=t,a=Lt(s),d=Ot(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})}},L=(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},W:{x:l,y:p},X:{x:a,y:w}}},S=(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))},[E,C]=w?w.N(b,c,a,r,L,S):[()=>b,()=>[ft]];return(t,n,o)=>{const{gt:a,Ct:h,ht:w,yt:b,_t:R,wt:M}=t,{dt:j,vt:z}=r(),[B,H]=n("nativeScrollbarsOverlaid.show"),[I,k]=n("overflow"),D=B&&g.x&&g.y,Y=!d&&!p&&(a||w||h||H||R),V=on(I.x),X=on(I.y),N=V||X;let W,F=y(o),K=x(o),J=$(o);if(H&&f&&u(Zt,Kt,!D),Y&&(W=L(D),P(W,j)),a||b||w||M||H){N&&u(Qt,Ft,!1);const[t,e]=C(D,z,W),[n,r]=F=v(o),[i,s]=K=m(o),l=Ot(c);let a=i,d=l;t(),(s||r||H)&&e&&!D&&E(e,i,n,z)&&(d=Ot(c),a=Pt(c)),J=_(((t,e,n)=>{const o=window.devicePixelRatio%1!=0?1:0,r={w:Ue(0,t.w-e.w-Ue(0,n.w)),h:Ue(0,t.h-e.h-Ue(0,n.h))};return{w:r.w>o?r.w:0,h:r.h>o?r.h:0}})({w:Ue(i.w,a.w),h:Ue(i.h,a.h)},{w:d.w+Ue(0,l.w-i.w),h:d.h+Ue(0,l.h-i.h)},n),o)}const[q,U]=J,[G,Z]=K,[Q,tt]=F,et={x:q.w>0,y:q.h>0},nt=V&&X&&(et.x||et.y)||V&&et.x&&!et.y||X&&et.y&&!et.x;if(b||M||tt||Z||U||k||H||Y){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(`${Ge}-`,"")||"";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,L(t,o)})(D,et,I,t),o=E(n,G,Q,z);d||S(n,z,o,t),Y&&P(n,j),d?(T(s,Nt,t.overflowX),T(s,Wt,t.overflowY)):e(c,t)}A(s,Xt,Ft,nt),nn(l,Qt,nt),!d&&nn(c,Qt,N);const[ot,rt]=O(L(D).xt);return i({xt:ot,$t:{x:q.w,y:q.h},Ot:et}),{zt:rt,At:U}}},sn=(e,n,o)=>{const r={},i=n||{};return t(O(e).concat(O(i)),(t=>{const n=e[t],s=i[t];r[t]=!!(o||n||s)})),r},ln="animationstart",cn="scroll",an=3333333,dn=t=>"rtl"===e(t,"direction"),un=t=>t&&(t.height||t.width),hn=(t,e,o)=>{const{It:r=!1,Tt:i=!1}=o||{},s=Oe()[He],{H:l}=_e(),c=W(`<div class="${te}"><div class="${ne}"></div></div>`)[0],a=c.firstChild,d=dn.bind(0,c),[u]=n({u:void 0,g:!0,_:(t,e)=>!(!t||!un(t)&&un(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=un(e),r=un(n);i=!n||!o,s=!r&&o,a=!i}else o?[,a]=t:s=!0===t;if(r&&a){const e=o?t[0]:dn(c);C(c,e?l.n?-an:l.i?0:an:an),R(c,an)}i||e({gt:!o,Pt:o?t:void 0,Tt:!!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,cn,(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,ln,b,{O:!!et}))),Y(t,c),()=>{_(g),X(c)}},pn=(t,e)=>{const o=N(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,hn(o,t)),t()}return Y(t,o),()=>{_(r),X(o)}},fn=(e,n,o,r)=>{let i=!1;const{Lt:s,Mt:l,Ht:c,Et:a,Rt:u,Dt: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):j(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,O=x&&d(o)?T(i,o):0,P=0!==O&&h!==O,L=v(g,o)>-1&&P;if(n&&!$){const n=!x,c=x&&L,d=c&&a&&z(i,a),u=(d?!s(i,o,h,O):n||c)&&!l(t,!!d,e,r);y(p,f),b=b||u,m=m||_}!n&&$&&P&&!s(i,o,h,O)&&(y(c,o),w=w||L)})),m&&!x(p)&&f((t=>p.reduce(((e,n)=>(y(e,j(t,n)),z(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())}]},gn=`[${Xt}]`,wn=`.${qt}`,bn=["tabindex"],vn=["wrap","cols","rows"],yn=["id","class","style","open"],mn=(e,o,r)=>{let i,s,l;const[,c]=o,{J:p,K:f,I:g,ct:w,lt:y,ft:m,ut:x}=e,{L:_,R:$}=_e(),[P]=n({_:at,u:{w:0,h:0}},(()=>{const t=m(Qt,Ft);t&&x(Qt,Ft);const e=Pt(g),n=Pt(f),o=Lt(f);return t&&x(Qt,Ft,!0),{w:n.w+e.w+o.w,h:n.h+e.h+o.h}})),L=w?vn:yn.concat(vn),S=gt(r,{v:()=>i,p:()=>s,m(t,e){const[n]=t,[o]=e;return[O(n).concat(O(o)).reduce(((t,e)=>(t[e]=n[e]||o[e],t)),{})]}}),A=e=>{t(e||bn,(t=>{if(v(bn,t)>-1){const e=T(p,t);d(e)?T(f,t,e):E(f,t)}}))},C=({gt:t,Pt:e,Tt: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]=P();e&&(t?r:S)({ht:!0})},M=(g||!$)&&pn(p,(t=>{const[e,n]=t;c({dt:e}),r({_t:n})})),j=!y&&hn(p,C,{Tt:!0,It:!_}),[z]=fn(p,!1,((t,e)=>{e?S({Ct:!0}):y||A(t)}),{Mt:yn,Lt:yn.concat(bn)}),B=y&&new et(C.bind(0,{gt:!0}));return B&&B.observe(p),A(),[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=fn(g||f,!0,R,{Mt:L.concat(n||[]),Lt:L.concat(n||[]),Ht:r,Et:gn,Dt:(t,e)=>{const{target:n,attributeName:o}=t;return!(e||!o)&&((t,e,n)=>{const o=t&&I(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&&I(I(t,n),e)===o)})(n,gn,wn)||!!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(),j&&j(),B&&B.disconnect(),z()}]},xn={A:{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:{x:0,y:0},xt:{x:"hidden",y:"hidden"},Ot:{x:!1,y:!1},dt:!1,vt:!1},_n=t=>{const e=N(`${le} ${t}`),n=N(de),o=N(ue);return D(e,n),D(n,o),{kt:e,Ft:n,Yt:o}},$n=new Set,On=new WeakMap,Pn=(e,n,o)=>{let r=!1;const{B:i,P:s,D:l}=_e(),c=Oe(),d=w(e)?e:e.target,h=(t=>On.get(t))(d);if(h)return h;const p=c[Me],f=t=>{const e=t||{},n=p&&p.q;return n?n(e,!0):e},g=P({},i(),f(n)),[b,v,y]=Bt(o),[m,x,_]=((e,n)=>{const o=It(n,{}),r=kt(xn),[i,s,l]=Bt(),[c]=r,[d,u,h]=Ke(e),p=((e,n)=>{const{K:o}=e,{L:r,P:i,R:s}=_e(),l=!r&&(i.x||i.y),c=[Je(e,n),qe(e,n),rn(e,n)];return(e,n,r)=>{const i=sn(P({gt:!1,yt:!1,wt:!1,_t:!1,At:!1,zt:!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=sn(p,t(p,e,!!r)||{},r)})),a(u)&&C(o,u),a(h)&&R(o,h),p}})(d,r),[f,g]=mn(d,r,(t=>{l("u",[p(o,t),{},!1])})),w=c.bind(0);return w.jt=t=>{i("u",t)},w.Vt=u,w.Bt=d,[(t,e)=>{const o=It(n,t,e);f(o),l("u",[p(o,{},e),t,!!e])},w,()=>{s(),g(),h()}]})(e,g),[$,S,T]=((t,e,n)=>{const o=kt({}),[r]=o,[i,s,l]=((t,e)=>{const{j:n}=_e(),{qt:o}=n(),{Z:r,J:i,K:s,rt:l}=e,c=!l&&t.scrollbarsSlot,a=Ne([r,i,s],(()=>i),o,c),d=_n(ce),u=_n(ae),{kt:h}=d,{kt:p}=u;return[{Gt:d,Nt:u},()=>{D(a,h),D(a,p)},X.bind(0,[h,p])]})(t,n),c=r.bind(0);return c.Bt=i,c.Vt=s,[(t,n)=>{const o=It(e,t,n);console.log(o)},c,()=>{l()}]})(e,g,x.Bt),A=(t,e)=>{m(t,e),$(t,e)},E=l(A.bind(0,{},!0)),M=t=>{(t=>{On.delete(t),$n.delete(t)})(d),E(),T(),_(),r=!0,y("destroyed",[j,!!t]),v()},j={options(t){if(t){const e=fe(g,f(t));L(e)||(P(g,e),A(e))}return P({},g)},on:b,off:(t,e)=>{t&&e&&v(t,e)},state(){const{$t:t,xt:e,Ot:n,A:o,bt:i}=x();return P({},{overflowAmount:t,overflowStyle:e,hasOverflow:n,padding:o,paddingAbsolute:i,destroyed:r})},elements(){const{Z:t,J:e,A:n,K:o,I:r}=x.Bt;return P({},{target:t,host:e,padding:n||o,viewport:o,content:r||o})},update:t=>(A({},t),j),destroy:M.bind(0)};return t(O(c),(t=>{const e=c[t];u(e)&&e(Pn,j)})),s.x&&s.y&&!g.nativeScrollbarsOverlaid.initialize?(M(!0),j):(x.Vt(),S.Vt(),((t,e)=>{On.set(t,e),$n.add(t)})(d,j),y("initialized",[j]),x.jt(((t,e,n)=>{const{gt:o,wt:r,_t:i,At:s,zt:l,ht:c,Ct:a}=t;y("updated",[j,{updateHints:{sizeChanged:o,directionChanged:r,heightIntrinsicChanged:i,overflowAmountChanged:s,overflowStyleChanged:l,contentMutation:c,hostMutation:a},changedOptions:e,force:n}])})),j.update(!0))};Pn.plugin=e=>t(h(e)?e:[e],(e=>{t(O(e),(t=>{$e[t]=e[t]}))})),Pn.env=()=>{const{T:t,P:e,L:n,H:o,R:r,M:i,F:s,Y:l,j:c,V:a,B:d,k:u}=_e();return P({},{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{Pn as OverlayScrollbars,je as optionsValidationPlugin,Ye as scrollbarsHidingPlugin,Ie as sizeObserverPlugin};