import{j as y}from"./jsx-runtime-CbGirg_M.js";import{r as l}from"./index-BoRhKTB8.js";import{g as m,u as w}from"./chunk-UIGDSWPH-C8mvmDRm.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};o.SENTRY_RELEASE={id:"28ce3948dcef68c9e8b5be7c5619a3bd17c18150"}}catch{}})();const E={vertical:"scrollTop",horizontal:"scrollLeft"};function N({elementQuery:o,direction:f="vertical",...g}){const n=`position:${o}`,d=m(),p=w(),a=E[f],i=l.useCallback(()=>{const t=document.querySelector(o);if(!t)return;let e={};try{const s=JSON.parse(sessionStorage.getItem(n)||"{}");typeof s=="object"&&s!==null&&(e=s)}catch(s){console.warn("Error parsing scroll positions from sessionStorage:",s)}const r={...e,[p.key]:t[a]};sessionStorage.setItem(n,JSON.stringify(r))},[n,o,p.key]);l.useEffect(()=>{if(d.state==="idle"){const t=document.querySelector(o);if(!t)return;try{const r=JSON.parse(sessionStorage.getItem(n)||"{}")[window.history.state.key];typeof r=="number"&&(t[a]=r)}catch(e){console.error(e),sessionStorage.removeItem(n)}}else i()},[n,o,d.state,i]),l.useEffect(()=>(window.addEventListener("pagehide",i),()=>{window.removeEventListener("pagehide",i)}),[i]);function S(t,e,r){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 u=JSON.parse(sessionStorage.getItem(t)||"{}")[window.history.state.key];typeof u=="number"&&(s[r]=u)}catch(c){console.error(c),sessionStorage.removeItem(t)}}return y.jsx("script",{...g,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${S})(${JSON.stringify(n)}, ${JSON.stringify(o)}, ${JSON.stringify(a)})`}})}export{N as E};
//# sourceMappingURL=index-CU92LMzx.js.map
