import { useCallback as f, useState as i, useRef as p, useEffect as b } from "../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
function l(e, t) {
  const s = f(() => e.getValue(t), [e, t]), [r, n] = i(() => s()), a = p(r);
  return b(() => {
    const c = () => {
      const u = s();
      a.current !== u && (a.current = u, n(u));
    };
    return c(), e.subscribe(c);
  }, [e, s, t]), r;
}
export {
  l as useWatch
};
