import*as t from"react";import e,{PrimeReactContext as r,localeOption as n}from"primereact/api";import{ComponentBase as o,useHandleStyle as i}from"primereact/componentbase";import{CSSTransition as l}from"primereact/csstransition";import{useMergeProps as c,useEventListener as a,useUnmountEffect as s}from"primereact/hooks";import{ChevronUpIcon as p}from"primereact/icons/chevronup";import{Ripple as u}from"primereact/ripple";import{classNames as f,DomHandler as m,ZIndexUtils as y,IconUtils as b}from"primereact/utils";function d(){return d=Object.assign?Object.assign.bind():function(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=Array(e);rj.threshold)};t.useImperativeHandle(v,(function(){return{props:j,getElement:function(){return elementRef.current}}})),t.useEffect((function(){"window"===j.target?H():"parent"===j.target&&R()}),[]),s((function(){y.clear(N.current)}));var z=O({className:I("icon")},x("icon")),M=b.getJSXIcon(j.icon||t.createElement(p,z),T({},z),{props:j}),U=n("aria")?n("aria").scrollTop:void 0,Z=O({ref:N,type:"button",className:f(j.className,I("root")),style:j.style,onClick:function(){("window"===j.target?window:A.current.parentElement).scroll({top:0,behavior:j.behavior})},"aria-label":U},k.getOtherProps(j),x("root")),_=O({classNames:I("transition"),in:h,timeout:{enter:150,exit:150},options:j.transitionOptions,unmountOnExit:!0,onEnter:function(){y.set("overlay",N.current,S&&S.autoZIndex||e.autoZIndex,S&&S.zIndex.overlay||e.zIndex.overlay)},onEntered:function(){j.onShow&&j.onShow()},onExited:function(){y.clear(N.current),j.onHide&&j.onHide()}},x("transition"));return t.createElement(t.Fragment,null,t.createElement(l,d({nodeRef:N},_),t.createElement("button",Z,M,t.createElement(u,null))),D&&t.createElement("span",{ref:A,className:"p-scrolltop-helper"}))})));N.displayName="ScrollTop";export{N as ScrollTop};