var e=`pos_cfd_msg:`;function t(t){let n=null;try{typeof BroadcastChannel<`u`&&(n=new BroadcastChannel(t))}catch{n=null}return{publish(r){let i=JSON.stringify(r);if(n)try{n.postMessage(r);return}catch{}try{localStorage.setItem(e+t,i)}catch{}},close(){if(n)try{n.close()}catch{}}}}function n(t,n){let r=null;try{typeof BroadcastChannel<`u`&&(r=new BroadcastChannel(t),r.onmessage=e=>{e?.data&&n(e.data)})}catch{r=null}let i=e+t,a=e=>{if(!(e.key!==i||!e.newValue))try{n(JSON.parse(e.newValue))}catch{}};return window.addEventListener(`storage`,a),()=>{if(window.removeEventListener(`storage`,a),r)try{r.close()}catch{}}}export{n,t};