;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3e5887d8-8f41-43bf-a5a4-2f4fe49941fe", e._sentryDebugIdIdentifier = "sentry-dbid-3e5887d8-8f41-43bf-a5a4-2f4fe49941fe");
  } catch (e) {
  }
}
;
import { useContext, useCallback, useMemo } from "preact/hooks";
import { a as debounce } from "./debouncedInputEvent-Cv2S512Y.js";
import { b9 as StateContext } from "./StoreProvider-CqQrndhS.js";
function useStateContext() {
  const context = useContext(StateContext);
  return context;
}
const ON_CHANGE_DEBOUNCE_DURATION = 200;
function useGlobalData() {
  const { getData } = useStateContext();
  return getData();
}
function useGlobalDataSlice(sliceId) {
  const { dispatch, getData } = useStateContext();
  const sliceData = getData()[sliceId];
  const updateState = useCallback(
    (updatedSlice) => dispatch({
      type: "addToState",
      value: {
        ...updatedSlice,
        dataStoreId: sliceId
      }
      // TODO merge SFValue and StateSlice types
    }),
    [sliceId]
  );
  const clearState = useCallback(
    () => dispatch({
      type: "removeFromState",
      value: { dataStoreId: sliceId }
    }),
    [sliceId]
  );
  const updateStateSlice = useMemo(
    // can this debounce be useDebounce?
    () => debounce(updateState, ON_CHANGE_DEBOUNCE_DURATION),
    [updateState]
  );
  const clearStateSlice = useMemo(
    () => debounce(clearState, ON_CHANGE_DEBOUNCE_DURATION),
    [clearState]
  );
  return { sliceData, updateStateSlice, clearStateSlice };
}
function useResetGlobalData() {
  const { dispatch } = useStateContext();
  return useCallback(
    () => dispatch({
      type: "resetState"
    }),
    [dispatch]
  );
}
export {
  useGlobalData as a,
  useResetGlobalData as b,
  useStateContext as c,
  useGlobalDataSlice as u
};
