Files
OverlayScrollbars/packages/overlayscrollbars/dist/overlayscrollbars.esm.min.js
T
2022-07-12 16:07:27 +02:00

1 line
24 KiB
JavaScript

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