import React from"react";const domReferenceKey="__navigator";class Navigator extends React.Component{static find(t){let e=t.target;for(;e!==t.currentTarget&&e instanceof HTMLElement;){var r=e[domReferenceKey];if(r instanceof Navigator)return r;e=e.parentNode}}init(t){const e=this.target;void 0!==e&&(this.target=void 0,e[domReferenceKey]=void 0),null!==t&&((this.target=t)[domReferenceKey]=this)}focus(){this.target.focus()}scrollTo(t){var e=this.props.children;if(Array.isArray(e)){const a=this.target;var r=a.scrollHeight/e.length,s=r/2,e=t%r,e=(a.scrollHeight-a.clientHeight)/2+(e+(e<-s?r:s<=e?-r:0));return a.scrollTop=e,Math.round(t/r)}return 0}hasStates(){var t=this.state;if(null==t)return!1;t=t.states;return null!=t}render(){var t=this.props,e=this.state||{},r=e.states;const s=[t.className];if(null!=r)for(const a in r)!0===r[a]&&s.push(a);return React.createElement("div",{className:s.join(" "),tabIndex:e.tabIndex,ref:t=>this.init(t)},this.props.children)}}export{Navigator};