mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-21 02:20:36 +03:00
1 line
19 KiB
JavaScript
1 line
19 KiB
JavaScript
const t=(t,e)=>{const{o:n,s:o,u:r}=e||{};let i,s=o;return{_:(e,o)=>{const a=s,l=t?t(o,s,i):o,c=e||(n?!n(a,l):a!==l);return(c||r)&&(s=l,i=a),{g:s,v:i,p:c}},m:t=>({g:s,v:i,p:!!t})}},e=Node.ELEMENT_NODE,{toString:n,hasOwnProperty:o}=Object.prototype;function r(t){return void 0===t}function i(t){return null===t}const s=t=>r(t)||i(t)?""+t:n.call(t).replace(/^\[object (.+)\]$/,"$1").toLowerCase();function a(t){return"number"==typeof t}function l(t){return"string"==typeof t}function c(t){return"boolean"==typeof t}function u(t){return"function"==typeof t}function d(t){return Array.isArray(t)}function _(t){return"object"==typeof t&&!d(t)&&!i(t)}function g(t){const e=!!t&&t.length,n=a(e)&&e>-1&&e%1==0;return!!(d(t)||!u(t)&&n)&&(!(e>0&&_(t))||e-1 in t)}function v(t){if(!t||!_(t)||"object"!==s(t))return!1;let e;const n=t.constructor,i=n&&n.prototype,a=o.call(t,"constructor"),l=i&&o.call(i,"isPrototypeOf");if(n&&!a&&!l)return!1;for(e in t);return r(e)||o.call(t,e)}function f(t){const n=window.Element;return!!t&&(n?t instanceof n:t.nodeType===e)}function h(t,e){if(g(t))for(let n=0;n<t.length&&!1!==e(t[n],n,t);n++);else t&&h(Object.keys(t),n=>e(t[n],n,t));return t}const p=(t,e,n)=>(n||l(e)||!g(e)?t.push(e):Array.prototype.push.apply(t,e),t),w=t=>{if(Array.from)return Array.from(t);const e=[];return h(t,t=>{p(e,t)}),e},b=t=>t&&0===t.length,m=(t,e)=>{const n=t=>t&&t(e);t instanceof Set?t.forEach(n):h(t,n)},y=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),S=t=>t?Object.keys(t):[];function x(t,e,n,o,r,s,a){const l=[e,n,o,r,s,a];return"object"==typeof t&&!i(t)||u(t)||(t={}),h(l,e=>{h(S(e),n=>{const o=e[n];if(t===o)return!0;const r=d(o);if(o&&(v(o)||r)){const e=t[n];let i=e;r&&!d(e)?i=[]:r||v(e)||(i={}),t[n]=x(i,o)}else t[n]=o})}),t}function C(t){for(const e in t)return!1;return!0}function O(t,e,n,o){if(r(o))return n?n[t]:e;n&&(n[t]=o)}function z(t,e,n){if(r(n))return t?t.getAttribute(e):null;t&&t.setAttribute(e,n)}function L(t,e){return O("scrollLeft",0,t,e)}function M(t,e){return O("scrollTop",0,t,e)}const A=Element.prototype,I=(t,e)=>{const n=[],o=e?f(e)?e:null:document;return o?p(n,o.querySelectorAll(t)):n},T=(t,e)=>{if(f(t)){return(A.matches||A.msMatchesSelector).call(t,e)}return!1},$=t=>t?w(t.childNodes):[],R=t=>t?t.parentElement:null,V=(t,e)=>{if(f(t)){const n=A.closest;if(n)return n.call(t,e);do{if(T(t,e))return t;t=R(t)}while(t)}return null},j=(t,e,n)=>{const o=t&&V(t,e),r=t&&((t,e)=>{const n=e?f(e)?e:null:document;return n?n.querySelector(t):null})(n,o);return!(!o||!r)&&(o===t||r===t||V(V(t,n),e)!==o)},E=(t,e,n)=>{if(n){let o,r=e;t&&(g(n)?(o=document.createDocumentFragment(),h(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))}},H=(t,e)=>{E(t,null,e)},P=(t,e)=>{E(t,t&&t.firstChild,e)},B=(t,e)=>{E(R(t),t&&t.nextSibling,e)},D=t=>{if(g(t))h(w(t),t=>D(t));else if(t){const e=R(t);e&&e.removeChild(t)}},q=t=>{const e=document.createElement("div");return t&&z(e,"class",t),e},N=t=>{const e=q();return e.innerHTML=t.trim(),h($(e),t=>D(t))},F=["WebKit","Moz","O","MS","webkit","moz","o","ms"],Y={},G=t=>{let e=Y[t]||window[t];return y(Y,t)||(h(F,n=>{var o;return e=e||window[n+(o=t,o.charAt(0).toUpperCase()+o.slice(1))],!e}),Y[t]=e),e},W=G("MutationObserver"),X=G("IntersectionObserver"),k=G("ResizeObserver"),U=G("cancelAnimationFrame"),J=G("requestAnimationFrame"),K=/[^\x20\t\r\n\f]+/g,Q=(t,e,n)=>{let o,r=0,i=!1;if(t&&l(e)){const s=e.match(K)||[];for(i=s.length>0;o=s[r++];)i=!!n(t.classList,o)&&i}return i},Z=(t,e)=>{Q(t,e,(t,e)=>t.add(e))},tt=(t,e)=>{Q(t,e,(t,e)=>t.remove(e))},et={w:0,h:0},nt=()=>({w:window.innerWidth,h:window.innerHeight}),ot=t=>t?{w:t.offsetWidth,h:t.offsetHeight}:et,rt=t=>t?{w:t.clientWidth,h:t.clientHeight}:et,it=t=>t?{w:t.scrollWidth,h:t.scrollHeight}:et,st=t=>t.getBoundingClientRect();let at;const lt=t=>t.split(" "),ct=(t,e,n,o)=>{h(lt(e),e=>{t.removeEventListener(e,n,o)})},ut=(t,e,n,o)=>{const i=(()=>{if(r(at)){at=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){at=!0}}))}catch(t){}}return at})(),s=i&&o&&o.S||!1,a=o&&o.C||!1,l=o&&o.O||!1,c=[],u=i?{passive:s,capture:a}:a;return h(lt(e),e=>{const o=l?r=>{t.removeEventListener(e,o,a),n&&n(r)}:n;p(c,ct.bind(null,t,e,o,a)),t.addEventListener(e,o,u)}),m.bind(0,c)},dt=t=>(t=>t.stopPropagation())(t)||(t=>t.preventDefault())(t),_t=(t,e,n,o)=>{if(t&&e){let r=!0;return h(n,n=>{(o?o(t[n]):t[n])!==(o?o(e[n]):e[n])&&(r=!1)}),r}return!1},gt=(t,e)=>_t(t,e,["w","h"]),vt=(t,e)=>_t(t,e,["t","r","b","l"]),ft=(t,e,n)=>_t(t,e,["width","height"],n&&(t=>Math.round(t))),ht=()=>{},pt=(t,e,n)=>{let o,r;const i=a(e)&&e>0,s=a(n)&&n>0,l=i?window.clearTimeout:U,c=i?window.setTimeout:J,u=function(e){r=s?performance.now():0,o&&l(o),t.apply(this,e)};return function(){const t=u.bind(this,arguments),i=!!s&&performance.now()-r>=n;o&&l(o),o=i?t():c(t,e)}},wt={opacity:1,zindex:1},bt=(t,e)=>{const n=e?parseFloat(t):parseInt(t,10);return Number.isNaN(n)?0:n},mt=(t,e,n)=>null!=e?e[n]||e.getPropertyValue(n):t.style[n],yt=(t,e,n)=>{try{if(t){const{style:o}=t;r(o[e])?o.setProperty(e,n):o[e]=((t,e)=>!wt[t.toLowerCase()]&&a(e)?e+"px":e)(e,n)}}catch(o){}};function St(t,e){const n=l(e);if(d(e)||n){let o=n?"":{};if(t){const r=window.getComputedStyle(t,null);o=n?mt(t,r,e):e.reduce((e,n)=>(e[n]=mt(t,r,n),e),o)}return o}h(S(e),n=>yt(t,n,e[n]))}const xt={x:0,y:0},Ct=t=>{const e=t?st(t):0;return e?{x:e.left+window.pageYOffset,y:e.top+window.pageXOffset}:xt};var Ot=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){function e(){return t.exports=e=Object.assign||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},e.apply(this,arguments)}t.exports=e}));const{stringify:zt}=JSON,Lt=["__TPL_","_TYPE__"],Mt=["boolean","number","string","array","object","function","null"].reduce((t,e)=>(t[e]=Lt[0]+e+Lt[1],t),{}),At=(t,e,n,o,i)=>{const a={},c=Ot({},t);return h(S(e).filter(e=>y(t,e)),u=>{const _=r(n[u])?{}:n[u],g=t[u],f=e[u],w=v(f),b=i?i+".":"";if(w&&v(g)){const t=At(g,f,_,o,b+u);a[u]=t.L,c[u]=t.M,h([c,a],t=>{C(t[u])&&delete t[u]})}else if(!w){let t=!1;const e=[],n=[],i=s(g);if(h(d(f)?f:[f],o=>{let s;h(Mt,(t,e)=>{t===o&&(s=e)});const a=r(s);if(a&&l(g)){const n=o.split(" ");t=!!n.find(t=>t===g),p(e,n)}else t=Mt[i]===o;return p(n,a?Mt.string:s),!t}),t){(d(g)||v(g)?zt(g)!==zt(_):g!==_)&&(a[u]=g)}else o&&console.warn(`The option "${b}${u}" wasn't set, because it doesn't accept the type [ ${i.toUpperCase()} ] with the value of "${g}".\r\nAccepted types are: [ ${n.join(", ").toUpperCase()} ].\r\n${e.length>0?`\r\nValid strings are: [ ${e.join(", ")} ].`:""}`);delete c[u]}}),{M:c,L:a}},It=(t,e,n,o)=>At(t,e,n||{},o||!1),Tt=t=>{const e={A:{},I:{}};return h(S(t),n=>{const o=t[n];if(d(o))e.A[n]=o[1],e.I[n]=o[0];else{const t=Tt(o);e.A[n]=t.A,e.I[n]=t.I}}),e},$t=Mt.number,Rt=[Mt.string,Mt.array,Mt.null],Vt=[!0,Mt.boolean],jt=[!1,Mt.boolean],Et={resize:["none","none both horizontal vertical"],paddingAbsolute:jt,updating:{elementEvents:[[["img","load"]],[Mt.array,Mt.null]],contentMutationDebounce:[80,$t],hostMutationDebounce:[0,$t],resizeDebounce:[0,$t]},overflow:{x:["scroll","hidden scroll visible visible-hidden"],y:["scroll","hidden scroll visible visible-hidden"]},scrollbars:{visibility:["auto","visible hidden auto"],autoHide:["never","never scroll leavemove"],autoHideDelay:[800,$t],dragScroll:Vt,clickScroll:jt,touch:Vt},textarea:{dynWidth:jt,dynHeight:jt,inheritedAttrs:[["style","class"],Rt]},nativeScrollbarsOverlaid:{show:jt,initialize:jt}},{A:Ht,I:Pt}=Tt(Et);let Bt;const{abs:Dt,round:qt}=Math,Nt=(t,e)=>{H(t,e);const n=rt(e),o=ot(e);return{x:o.h-n.h,y:o.w-n.w}},Ft=(t,e)=>{St(t,{overflowX:"hidden",overflowY:"hidden",direction:"rtl"}),L(t,0);const n=Ct(t),o=Ct(e);L(t,-999);const r=Ct(e);return{i:n.x===o.x,n:o.x!==r.x}},Yt=(t,e)=>{Z(t,"os-environment-flexbox-glue");const n=st(t),o=st(e),r=ft(o,n,!0);Z(t,"os-environment-flexbox-glue-max");const i=st(t),s=st(e),a=ft(s,i,!0);return r&&a},Gt=()=>{const t=window.screen.deviceXDPI||0,e=window.screen.logicalXDPI||1;return window.devicePixelRatio||t/e},Wt=()=>{const{body:t}=document,e=N('<div class="os-environment"><div></div></div>')[0],n=e.firstChild,o=new Set,r=Nt(t,e),i={x:0===r.x,y:0===r.y},s=(t=>({T:!t,$:!1}))(!1);let a=s,l=Pt;const c={R:r,V:i,j:!1,H:"-1"===St(e,"zIndex"),P:Ft(e,n),B:Yt(e,n),D(t){o.add(t)},q(t){o.delete(t)},N:()=>Ot({},a),F(t){a=x({},a,t)},Y:()=>Ot({},l),G(t){l=x({},l,t)},W:s,X:l};var u,d;if(d="style",(u=e)&&u.removeAttribute(d),D(e),!i.x||!i.y){let n=nt(),i=Gt(),s=r;window.addEventListener("resize",()=>{if(o.size){const r=nt(),a={w:r.w-n.w,h:r.h-n.h};if(0===a.w&&0===a.h)return;const l={w:Dt(a.w),h:Dt(a.h)},c={w:Dt(qt(r.w/(n.w/100))),h:Dt(qt(r.h/(n.h/100)))},u=Gt(),d=l.w>2&&l.h>2,_=!((t,e)=>{const n=Dt(t),o=Dt(e);return!(n===o||n+1===o||n-1===o)})(c.w,c.h),g=u!==i&&i>0;if(d&&_&&g){const n=Bt.R=Nt(t,e);D(e),s.x===n.x&&s.y===n.y||m(o),s=n}n=r,i=u}})}return c},Xt=()=>(Bt||(Bt=Wt()),Bt),kt=t=>{H(R(t),$(t)),D(t)};let Ut=0;const Jt=(t,e)=>{const n=c(t);return n||r(t)?(n?t:e)&&void 0:t},Kt=t=>{const{N:n,j:o,V:i,H:s}=Xt(),{T:a,$:l}=n(),c=function(t){const n=window.HTMLElement;return!!t&&(n?t instanceof n:t.nodeType===e)}(t),u=c?{}:{k:t.host,U:t.target,J:t.viewport,T:Jt(t.padding,a),$:Jt(t.content,l)};if(c){const e=q("os-viewport"),n=a&&q("os-padding"),o=l&&q("os-content");u.U=t,u.T=n,u.J=e,u.$=o}let{U:d,T:_,J:g,$:v}=u;const f=[],h=T(d,"textarea"),w=!h&&T(d,"body"),b=h?u.k||q():d,y=t=>h?d:$(t);if(h&&b!==u.k&&(B(d,b),p(f,()=>{B(b,d),D(b)})),c){const t=v||g;H(t,y(d)),H(b,_),H(_||b,g),H(g,v),p(f,()=>{H(b,$(t)),D(_||g),tt(b,"os-host")})}else{const t=v||g||_||b,e=r(_),n=r(g),o=r(v),i=y(t);_=u.T=e?q():_,g=u.J=n?q():g,v=u.$=o?q():v,H(b,_),H(_||b,g),H(g,v);H(v||g,i),p(f,()=>{o&&kt(v),n&&kt(g),e&&kt(_),tt(b,"os-host"),tt(_,"os-padding"),tt(g,"os-viewport"),tt(v,"os-content")})}Z(b,"os-host"),Z(_,"os-padding"),Z(g,"os-viewport"),Z(v,"os-content");const S=d.ownerDocument,x=S.body,C={K:S.defaultView,Z:S,tt:R(x),et:x,nt:h,ot:w},O=Ot({},u,{k:b});if(o)p(f,tt.bind(0,g,"os-viewport-scrollbar-styled"));else if(!s&&(i.x||i.y)){const t=(()=>{const t=document.createElement("style");return z(t,"id","os-viewport-arrange-"+Ut),Ut++,t})();M=t,E(R(L=g),L,M),p(f,D.bind(0,t)),O.rt=t}var L,M;return{it:O,st:C,at:()=>{m(f)}}},Qt=e=>{const{lt:n,ct:o}=e,{k:r,T:i,J:s}=n.it,{_:a,m:l}=t(()=>((t,e,n)=>{const o=e?e+"-":"",r=n?"-"+n:"",i=`${o}top${r}`,s=`${o}right${r}`,a=`${o}bottom${r}`,l=`${o}left${r}`,c=St(t,[i,s,a,l]);return{t:bt(c[i]),r:bt(c[s]),b:bt(c[a]),l:bt(c[l])}})(r,"padding"),{o:vt});return(t,e,n)=>{let{g:r,p:c}=l(n);const{j:u}=Xt(),{ut:d,dt:_}=t,{g,p:v}=_,{g:f,p:h}=e("paddingAbsolute");(d||c)&&({g:r,p:c}=a(n));const p=h||v||c;if(p){const{g:t}=a(n),e=!f||!i&&!u,r=t.r+t.l,l=t.t+t.b,c={marginTop:0,marginRight:0,marginBottom:e?-l:0,marginLeft:0,top:e?-t.t:0,right:0,bottom:0,left:0,maxWidth:e?`calc(100% + ${r}px)`:""},d={paddingTop:e?t.t:0,paddingRight:e?t.r:0,paddingBottom:e?t.b:0,paddingLeft:e?t.l:0};if(e){const e=g?"right":"left",n=g?"marginLeft":"marginRight",o=g?t.r:t.l;c[e]=-o,c[n]=-r}St(i||s,c),St(s,d),o({_t:{gt:!e,T:t},vt:i?d:Ot({},c,d)})}return{ft:p}}},Zt=e=>{const{lt:n,ht:o,pt:r,ct:i}=e,{k:s,J:a,rt:l}=n.it,{_:c,m:u}=t(t=>g(t.wt,t.bt,t.yt),{o:gt}),{_:d,m:_}=t(t=>({w:Math.max(0,t.St.w-t.xt.w),h:Math.max(0,t.St.h-t.xt.h)}),{o:gt,s:{w:0,h:0}}),g=(t,e,n)=>({w:t.w-Math.round(Math.max(0,n.width-e.w)),h:t.h-Math.round(Math.max(0,n.height-e.h))}),v=(t,e)=>{if(St(a,{height:""}),e){const{gt:e,T:n}=r()._t,{Ct:o,Ot:i}=t,l=st(s),c=ot(s),u=rt(s),d=e||"content-box"===St(a,"boxSizing")?n.b+n.t:0,_=u.h+(l.height-c.h);St(a,{height:_+(o.x?i.x:0)-d})}},f=(t,e)=>{const{R:n,V:o,j:r}=Xt(),{x:i,y:s}=o,l=r||t?0:42,c=!e?St(a,["overflowX","overflowY"]):e,u={x:"scroll"===c.overflowX,y:"scroll"===c.overflowY};return{Ct:u,zt:{x:i&&!!l,y:s&&!!l},Ot:{x:u.x&&!r?i?l:n.x:0,y:u.y&&!r?s?l:n.y:0}}},p=(t,e,n)=>{if(o){const{Ot:o,zt:i}=t,{x:s,y:c}=i,{x:u,y:d}=o,{vt:_}=r(),g=_[n?"paddingRight":"paddingLeft"],v=_.paddingTop,f={w:d&&c?d+e.w-g+"px":"",h:u&&s?u+e.h-v+"px":""};if(l){const{sheet:t}=l;if(t){const{cssRules:e}=t;if(e){e.length||t.insertRule(`#${z(l,"id")} + .os-viewport-arrange::before {}`,0);const n=e[0].style;n.width=f.w,n.height=f.h}}}else St(a,{"--viewport-arrange-width":f.w,"--viewport-arrange-height":f.h})}return o},w=(t,e,n,o)=>{const{Ot:i,zt:s}=t,{x:a,y:l}=s,{x:c,y:u}=i,{vt:d}=r(),_=e?"marginLeft":"marginRight",g=e?"paddingLeft":"paddingRight",v=d[_],f=d.marginBottom,h=d[g],p=d.paddingBottom;o.maxWidth=`calc(100% + ${u+-1*v}px)`,o[_]=-u+v,o.marginBottom=-c+f,n&&(o[g]=h+(l?u:0),o.paddingBottom=p+(a?c:0))};return(t,e,n)=>{const{dt:s,Lt:l,ut:b,Mt:m,At:y,ft:x}=t,{B:C,j:O,V:z}=Xt(),{g:L,p:M}=l,{g:A,p:I}=s,{g:T,p:$}=e("nativeScrollbarsOverlaid.show"),R=T&&z.x&&z.y,V=!C&&(b||y||m||$||M);let j,E=_(n),H=u(n);if($&&O&&(R?tt(a,"os-viewport-scrollbar-styled"):Z(a,"os-viewport-scrollbar-styled")),V&&(j=f(R),v(j,!!L)),b||x||y||$||I){const{It:t,Tt:e}=((t,e,n)=>{if(o){const i=n||f(t),{vt:s}=r(),{B:l}=Xt(),{zt:c}=i,{x:u,y:d}=c,_={},g=t=>h(t.split(" "),t=>{_[t]=s[t]});l||(_.height=""),u&&g("marginTop marginBottom paddingTop paddingBottom"),d&&g("marginLeft marginRight paddingLeft paddingRight");const v=St(a,S(_));return tt(a,"os-viewport-arrange"),St(a,_),{It:()=>{w(i,e,o,v),St(a,v),Z(a,"os-viewport-arrange")},Tt:i}}return{It:ht}})(R,A,j),i=rt(a),s=st(a),l=ot(a);let u=it(a),_=i;const{g:v,p:b}=H=c(n,{yt:s,bt:l,wt:u});t(),(b||$)&&e&&!R&&p(e,v,A)&&(_=rt(a),u=g(it(a),ot(a),st(a))),E=d(n,{St:{w:Math.max(v.w,u.w),h:Math.max(v.h,u.h)},xt:{w:_.w+Math.max(0,i.w-v.w),h:_.h+Math.max(0,i.h-v.h)}})}const{g:P,p:B}=e("overflow"),{g:D,p:q}=H,{g:N,p:F}=E;if(x||q||F||B||$||I||V){const t={marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,maxWidth:"",overflowY:"",overflowX:""},e=((t,e,n,o)=>{const r=(t,e,n,o)=>{const r=t?"overflowX":"overflowY",i=0===n.indexOf("visible"),s="visible-hidden"===n,a="scroll"===n;return i&&(o[r]="visible"),a&&e>0&&(o[r]=n),{$t:i,Rt:s?"hidden":"scroll"}},{$t:i,Rt:s}=r(!0,e.w,n.x,o),{$t:a,Rt:l}=r(!1,e.h,n.y,o);return i&&!a&&(o.overflowX=s),a&&!i&&(o.overflowY=l),f(t,o)})(R,N,P,t),n=p(e,D,A);w(e,A,n,t),V&&v(e,!!L),St(a,t),i({Vt:e.Ct,jt:N})}}},te=t=>"rtl"===St(t,"direction"),ee=t=>t&&(t.height||t.width),ne=(e,n,o)=>{const{Et:r=!1,Ht:i=!1}=o||{},{P:s}=Xt(),a=N('<div class="os-size-observer"><div class="os-size-observer-listener"></div></div>')[0],l=a.firstChild,{_:u}=t(0,{u:!0,o:(t,e)=>!(!t||!ee(t)&&ee(e))}),_=t=>{const e=t&&c(t.g);let o=!1;if(d(t)&&t.length>0){const{v:e,g:n,p:r}=u(0,t.pop().contentRect);o=!e||!ee(n)}else e&&t.p;if(r){const n=e?t.g:te(a);L(a,n?s.n?-3333333:s.i?0:3333333:3333333),M(a,3333333)}o||n(e?t:void 0)},g=[];let v,f=!!i&&_;if(k){const t=new k(_);t.observe(l),p(g,()=>t.disconnect())}else{const t=N('<div class="os-size-observer-listener-item" dir="ltr"><div class="os-size-observer-listener-item"><div class="os-size-observer-listener-item-final"></div></div><div class="os-size-observer-listener-item"><div class="os-size-observer-listener-item-final" style="width: 200%; height: 200%"></div></div></div>');H(l,t),Z(l,"os-size-observer-listener-scroll");const e=t[0],n=e.lastChild,o=e.firstChild,r=null==o?void 0:o.firstChild;let s,a=ot(l),c=a,u=!1;const d=()=>{L(o,3333333),M(o,3333333),L(n,3333333),M(n,3333333)},v=()=>{s=0,u&&(a=c,_())},h=t=>{c=ot(l),u=!t||!gt(c,a),t?(dt(t),u&&!s&&(U(s),s=J(v))):v(),d()};p(g,[ut(o,"scroll",h),ut(n,"scroll",h)]),St(r,{width:3333333,height:3333333}),d(),f=i?h.bind(0,!1):d}if(r){v=t(()=>te(a));const{_:e}=v;p(g,ut(a,"scroll",t=>{const n=e(),{g:o,p:r}=n;r&&(tt(l,"ltr rtl"),Z(l,o?"rtl":"ltr"),_(n)),dt(t)}))}return f&&(Z(a,"os-size-observer-appear"),p(g,ut(a,"animationstart",f,{O:!!k}))),P(e,a),{at(){m(g),D(a)},Pt:t=>({dt:v?v.m(t):{g:!1,v:!1,p:!1}})}},oe=(t,e,n,o)=>{let i=!1;const{Bt:s,Dt:a,qt:c,Nt:d,Ft:_,Yt:g,Gt:v}=o||{},{at:f,Wt:w,Xt:m}=((t,e,n)=>{let o,i;const s=()=>{o&&(o.forEach((t,e)=>ct(e,t,n)),o.clear())},a=e=>{if(o&&i){h(i.reduce((n,o)=>{if(o){const r=o[0],i=o[1],s=i&&r&&(e?e(r):I(r,t)),a=u(i)?i(s):i;s&&s.length&&a&&l(a)&&p(n,[s,a.trim()],!0)}return n},[]),t=>h(t[0],e=>{const i=t[1],s=o.get(e),a=!r(s)&&i!==s,l=a?`${s} ${i}`:i;a&&ct(e,s,n),o.set(e,l),ut(e,l,n)}))}},c=t=>{o=o||new Map,i=t,s(),a()};return e&&c(e),{at:s,Wt:a,Xt:c}})(t,e&&c,pt(()=>{i&&n(!0)},84)),y=a||[],S=(s||[]).concat(y),x=r=>{const i=(e?g:_)||ht,s=v||ht,a=[],c=[];let u=!1,f=!1,m=!1;h(r,n=>{const{attributeName:r,target:_,type:g,oldValue:v,addedNodes:h}=n,w="attributes"===g,b="childList"===g,S=t===_,x=w&&l(r)?z(_,r):0,C=0!==x&&v!==x,O=(L=r,y.indexOf(L,M)>-1&&C);var L,M;if(e&&!S){const e=!w,a=w&&O,l=a&&d&&T(_,d),u=(l?!i(_,r,v,x):e||a)&&!s(n,!!l,t,o);p(c,h),f=f||u,m=m||b}!e&&S&&C&&!i(_,r,v,x)&&(p(a,r),u=u||O)}),m&&!b(c)&&w(t=>c.reduce((e,n)=>(p(e,I(t,n)),T(n,t)?p(e,n):e),[])),e?f&&n(f):b(a)&&!u||n(a,u)},C=new W(x);return C.observe(t,{attributes:!0,attributeOldValue:!0,attributeFilter:S,subtree:e,childList:e,characterData:e}),i=!0,{at:()=>{i&&(f(),C.disconnect(),i=!1)},Xt:t=>{m(i&&e&&t)},_:()=>{i&&x(C.takeRecords())}}},re=(t,e)=>t?e.split(".").reduce((t,e)=>t&&y(t,e)?t[e]:void 0,t):void 0,ie=["id","class","style","open"],se=(t,e,n,o)=>{if("class"===e&&n&&o){return!!((t,e)=>{const n=t&&t.split(" "),o=e&&e.split(" "),r={};return h(n,t=>{r[t]=1}),h(o,t=>{r[t]?delete r[t]:r[t]=1}),S(r)})(n,o).find(t=>0!==t.indexOf("os-"))}return!1},ae={g:!1,v:!1,p:!1},le={g:!1,v:!1,p:!1},ce={_t:{gt:!1,T:{t:0,r:0,b:0,l:0}},Vt:{x:!1,y:!1},jt:{w:0,h:0},vt:{marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0}},ue=(e,n)=>{let o=ce;const{k:r,J:i,$:s}=n.it,{j:l,V:c,B:u,D:d,q:_}=Xt(),g=!l&&(c.x||c.y),v=[],f={I:e,lt:n,ht:g,pt:()=>o,ct(t){var e,n;t&&t.vt&&(t.vt=(e=t.vt,n=ce.vt,S(e).reduce((t,n)=>{const o=e[n];return t[n]=""===o?0:o,t},Ot({},n)))),o=x({},o,t)}};p(v,(t=>{const{lt:e}=t,{$:n}=e.it;return t=>{const{Lt:e}=t,{g:o,p:r}=e;return r&&St(n,{height:o?"":"100%",display:o?"":"inline"}),{ut:r,At:r}}})(f)),p(v,Qt(f)),p(v,Zt(f));const w=(t,n,o)=>{let{dt:r,Lt:s,ut:l=o||!1,Mt:c=o||!1,At:d=o||!1,ft:_=o||!1}=t||{};const f=r||(y?y.Pt(o).dt:ae),p=s||(b?b.Pt(o).Lt:le),w=t=>({g:re(e,t),p:o||void 0!==re(n,t)}),m=g||!u,S=m&&L(i),x=m&&M(i);h(v,t=>{const{ut:e,Mt:n,At:r,ft:i}=t({dt:f,Lt:p,ut:l,Mt:c,At:d,ft:_},w,!!o)||{};l=e||l,c=n||c,d=r||d,_=i||_}),a(S)&&L(i,S),a(x)&&M(i,x)},b=(s||!u)&&((e,n)=>{const o=q("os-trinsic-observer"),r=[],{_:i,m:s}=t(t=>0===t.h||t.isIntersecting||t.intersectionRatio>0,{s:!1});if(X){const t=new X(t=>{if(t&&t.length>0){const e=t.pop();if(e){const t=i(0,e);t.p&&n(t)}}},{root:e});t.observe(o),p(r,()=>t.disconnect())}else{const t=()=>{const t=ot(o),e=i(0,t);e.p&&n(e)};p(r,ne(o,t).at),t()}return P(e,o),{at(){m(r),D(o)},Pt:t=>({Lt:s(t)})}})(r,t=>{w({Lt:t})}),y=ne(r,t=>{w({dt:t,ut:!t})},{Ht:!0,Et:!l}),C=(oe(r,!1,()=>{requestAnimationFrame(()=>{w({Mt:!0})})},{Dt:ie,Bt:ie,Ft:se}),oe(s||i,!0,()=>{requestAnimationFrame(()=>{w({At:!0})})},{Dt:ie,Bt:ie,qt:e.updating.elementEvents,Nt:".os-host",Gt:(t,e)=>{const{target:n,attributeName:o}=t;return!e&&(!!o&&(j(n,".os-host",".os-viewport")||j(n,".os-host",".os-content")))},Yt:se}),(t,e)=>{w(null,t,e)}),O=C.bind(null,null,!0);return d(O),console.log(Xt()),{_:C,kt:()=>({Ut:o.jt}),at(){_(O)}}};export default(t,e,n)=>{const{Y:o}=Xt(),r=x({},o(),It(e||{},Ht,null,!0).L),i=Kt(t),s=ue(r,i),a={options(t){if(t){const{L:e}=It(t,Ht,r,!0);C(e)||(x(r,e),s._(e))}return r},state:()=>s.kt(),update(t){s._(null,t)}};return a.update(!0),a}; |