var e=`sg-scroll:`;function t(t){return e+t}function n(e){if(!e||typeof sessionStorage>`u`)return null;try{let n=sessionStorage.getItem(t(e));if(!n)return null;let r=JSON.parse(n),i=Number(r?.x),a=Number(r?.y);return!Number.isFinite(i)||!Number.isFinite(a)?null:{x:i,y:a}}catch{return null}}function r(e,n){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(t(e),JSON.stringify({x:n.scrollLeft,y:n.scrollTop}))}catch{}}function i(e,t){let i=t,a=0;function o(){cancelAnimationFrame(a),a=requestAnimationFrame(()=>r(i,e))}function s(){let t=n(i);t&&(e.scrollLeft=t.x,e.scrollTop=t.y)}return e.addEventListener(`scroll`,o,{passive:!0}),requestAnimationFrame(s),{update(e){i=e},destroy(){cancelAnimationFrame(a),e.removeEventListener(`scroll`,o)}}}export{i as n,r,n as t};