import{a as e,n as t}from"./jsx-runtime-CutOxEx1.js";var n=e(t(),1),r=`hireedge_global_context_v1`,i={resumeText:``,jdText:``,offerText:``};function a(){try{let e=localStorage.getItem(r);if(e){let t=JSON.parse(e);return{...i,...t}}}catch(e){console.error(`Failed to read global job context`,e)}return i}function o(e){try{localStorage.setItem(r,JSON.stringify(e)),window.dispatchEvent(new Event(`hireedge_global_context_changed`))}catch(e){console.error(`Failed to save global job context`,e)}}function s(){let[e,t]=(0,n.useState)(a);return(0,n.useEffect)(()=>{let e=e=>{e.key===r&&t(a())},n=()=>{t(a())};return window.addEventListener(`storage`,e),window.addEventListener(`hireedge_global_context_changed`,n),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(`hireedge_global_context_changed`,n)}},[]),{context:e,updateContext:(0,n.useCallback)(e=>{o({...a(),...e})},[])}}export{s as t};