/*!
 * Built by Revolist OU ❤️
 */
import{proxyCustomElement as t,HTMLElement as i,createEvent as e,h as r,Host as s,transformTag as l}from"@stencil/core/internal/client";import{L as o,a as h,b as c}from"./local.scroll.timer.js";import{g as n}from"./index2.js";class a{constructor(t){this.element=t,this.autohideScrollTimeout=0}setScrollSize(t){t?this.element.removeAttribute("autohide"):this.element.setAttribute("autohide","true")}checkScroll({scrollSize:t,contentSize:i,virtualSize:e}){!t&&i>e&&(this.element.setAttribute("visible","true"),this.autohideScrollTimeout=this.show(this.element,this.autohideScrollTimeout))}show(t,i){return clearTimeout(i),Number(setTimeout((()=>{null==t||t.removeAttribute("visible")}),1e3))}clear(){clearTimeout(this.autohideScrollTimeout)}}const u=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.scrollVirtual=e(this,"scrollvirtual",7),this.dimension="rgRow",this.scrollSize=0}async setScroll(t){var i;this.dimension===t.dimension&&(this.localScrollTimer.latestScrollUpdate(t.dimension),null===(i=this.localScrollService)||void 0===i||i.setScroll(t),t.coordinate&&this.autohideScrollPlugin.checkScroll({scrollSize:this.scrollSize,contentSize:this.realSize,virtualSize:this.virtualSize}))}async changeScroll(t){return t.delta?this.localScrollService.setScrollByDelta(t,this.element["rgRow"===t.dimension?"scrollTop":"scrollLeft"]):t}connectedCallback(){this.autohideScrollPlugin=new a(this.element),this.localScrollTimer=new o("ontouchstart"in document.documentElement?0:10),this.localScrollService=new h({runScroll:t=>this.scrollVirtual.emit(t),applyScroll:t=>{this.localScrollTimer.setCoordinate(t),this.element["rgRow"===t.dimension?"scrollTop":"scrollLeft"]=t.coordinate}})}disconnectedCallback(){this.autohideScrollPlugin.clear()}componentWillLoad(){this.scrollSize=n(document)}componentDidRender(){let t=0;"rgRow"===this.dimension?(t=this.element.scrollHeight>this.element.clientHeight?this.scrollSize:0,this.element.style.minWidth=`${t}px`):(t=this.element.scrollWidth>this.element.clientWidth?this.scrollSize:0,this.element.style.minHeight=`${t}px`),this.autohideScrollPlugin.setScrollSize(t),this.localScrollService.setParams({contentSize:this.realSize,clientSize:"rgRow"===this.dimension?this.element.clientHeight:this.element.clientWidth,virtualSize:this.clientSize},this.dimension)}onScroll(t){if(!(t.target instanceof Element))return;const i=t.target;let e="scrollLeft";"rgRow"===this.dimension&&(e="scrollTop");const r=()=>{var t;null===(t=this.localScrollService)||void 0===t||t.scroll(i[e]||0,this.dimension)};this.localScrollTimer.isReady(this.dimension,i[e])?r():this.localScrollTimer.throttleLastScrollUpdate(this.dimension,i[e]||0,(()=>r()))}render(){const t=c(this.realSize,"rgRow"===this.dimension?this.element.clientHeight:this.element.clientWidth,this.clientSize);return r(s,{key:"7213817ef941eee4050b714266598ec0c2961ee9",onScroll:t=>this.onScroll(t)},r("div",{key:"501da49c63253ab943172494b9dbf5399be56cee",style:{["rgRow"===this.dimension?"height":"width"]:`${t}px`}}))}get element(){return this}static get style(){return"revogr-scroll-virtual[autohide]{position:absolute;z-index:100 !important}revogr-scroll-virtual[autohide].vertical{top:0;right:0}revogr-scroll-virtual[autohide].vertical[visible]{min-width:20px !important}revogr-scroll-virtual[autohide].horizontal{bottom:0;left:0}revogr-scroll-virtual[autohide].horizontal[visible]{min-height:20px !important}revogr-scroll-virtual.vertical{overflow-y:auto;overflow-x:hidden;height:100%}revogr-scroll-virtual.vertical>div{width:1px}revogr-scroll-virtual.horizontal{overflow-x:auto;overflow-y:hidden;width:100%}revogr-scroll-virtual.horizontal>div{height:1px}"}},[0,"revogr-scroll-virtual",{dimension:[1],realSize:[2,"real-size"],virtualSize:[2,"virtual-size"],clientSize:[2,"client-size"],setScroll:[64],changeScroll:[64]}]);function v(){"undefined"!=typeof customElements&&["revogr-scroll-virtual"].forEach((t=>{"revogr-scroll-virtual"===t&&(customElements.get(l(t))||customElements.define(l(t),u))}))}export{u as R,v as d}