'use strict';
'use client';
import { c } from 'react/compiler-runtime';
import { jsx } from 'react/jsx-runtime';
import { createContext, useState, useContext } from 'react';
import { createError } from '../../../../fd-toolbox/errors/errors.js';
import { metaErrorMessages } from '../../constants/meta-error-messages-constants.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
const GlobalContext = createContext(void 0);
function GlobalContextProvider(t0) {
  const $ = c(3);
  const {
    config,
    children
  } = t0;
  const [globalConfig, setGlobalConfig] = useState(config);
  let t1;
  if ($[0] !== children || $[1] !== globalConfig) {
    const contextValue = {
      globalConfig,
      setGlobalConfig
    };
    t1 = jsx(GlobalContext.Provider, {
      value: contextValue,
      children
    });
    $[0] = children;
    $[1] = globalConfig;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  return t1;
}
__name(GlobalContextProvider, "GlobalContextProvider");
function useGlobalConfig() {
  const context = useContext(GlobalContext);
  if (!context) {
    throw createError(metaErrorMessages.globalContextUsedOutside);
  }
  return context;
}
__name(useGlobalConfig, "useGlobalConfig");

export { GlobalContextProvider, useGlobalConfig };
