import{r as n}from"./index-CFdT0RIo.js";import{l as m}from"./chunk-EVOBXE3Y-Bmgys8-c.js";import{b as y}from"./root-loader-ByAKsmmv.js";import{o as p,l as S,i as E,s as v}from"./schemas-Bn3zadsT.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 s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="c7f8156f-b6f5-4a2f-b7b9-b1575d882fe1",t._sentryDebugIdIdentifier="sentry-dbid-c7f8156f-b6f5-4a2f-b7b9-b1575d882fe1")}catch{}})();const w=p({type:S("epicshop:file-change"),data:p({filePaths:E(v())})});function R({watchPaths:t}){const s=y(),r=m(),c=n.useRef(r);n.useEffect(()=>{c.current=r},[r]);const f=new URLSearchParams;for(const e of t)f.append("watch",e);const a=f.toString(),b=s.protocol==="https:"?"wss:":"ws:",h=s.hostname,g=s.port,i=`${b}//${h}:${g}/__ws?${a}`;n.useEffect(()=>{if(!a)return;let e=null;function l(){e&&e.close();try{e=new WebSocket(i)}catch(o){console.error("🐨 EpicShop WebSocket failed to connect:",o);return}e.onmessage=o=>{const d=w.safeParse(JSON.parse(o.data));if(!d.success)return;const{data:u}=d;u.type==="epicshop:file-change"&&(console.log("🐨 Revalidating due to file changes:",u.data.filePaths),c.current.revalidate())},e.onclose=o=>{o.code===1006&&setTimeout(()=>{l()},1e3)},e.onerror=o=>{console.error("🐨 EpicShop WebSocket error:",o)}}return l(),()=>{e?.close()}},[a,i])}const D=ENV.EPICSHOP_DEPLOYED?()=>null:R;export{D as u};
//# sourceMappingURL=revalidation-ws-DjL8N8TA.js.map
