import{j as S}from"./jsx-runtime-hUI6LOBV.js";import{r as d}from"./index-CFdT0RIo.js";import{k as m,u as w}from"./chunk-EVOBXE3Y-Bmgys8-c.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"66e9b849450b819e11683314a547a341cb57f7d0"};var a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="290e9837-5e69-4079-8766-b5172c3ca5e0",t._sentryDebugIdIdentifier="sentry-dbid-290e9837-5e69-4079-8766-b5172c3ca5e0")}catch{}})();const b={vertical:"scrollTop",horizontal:"scrollLeft"};function v({elementQuery:t,direction:a="vertical",...f}){const r=`position:${t}`,p=m(),u=w(),l=b[a],i=d.useCallback(()=>{const o=document.querySelector(t);if(!o)return;let e={};try{const s=JSON.parse(sessionStorage.getItem(r)||"{}");typeof s=="object"&&s!==null&&(e=s)}catch(s){console.warn("Error parsing scroll positions from sessionStorage:",s)}const n={...e,[u.key]:o[l]};sessionStorage.setItem(r,JSON.stringify(n))},[r,t,u.key]);d.useEffect(()=>{if(p.state==="idle"){const o=document.querySelector(t);if(!o)return;try{const n=JSON.parse(sessionStorage.getItem(r)||"{}")[window.history.state.key];typeof n=="number"&&(o[l]=n)}catch(e){console.error(e),sessionStorage.removeItem(r)}}else i()},[r,t,p.state,i]),d.useEffect(()=>(window.addEventListener("pagehide",i),()=>{window.removeEventListener("pagehide",i)}),[i]);function y(o,e,n){const s=document.querySelector(e);if(!s){console.warn(`Element not found: ${e}. Cannot restore scroll.`);return}if(!window.history.state||!window.history.state.key){const c=Math.random().toString(32).slice(2);window.history.replaceState({key:c},"")}try{const g=JSON.parse(sessionStorage.getItem(o)||"{}")[window.history.state.key];typeof g=="number"&&(s[n]=g)}catch(c){console.error(c),sessionStorage.removeItem(o)}}return S.jsx("script",{...f,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${y})(${JSON.stringify(r)}, ${JSON.stringify(t)}, ${JSON.stringify(l)})`}})}export{v as E};
//# sourceMappingURL=index-J1nVA_jb.js.map
