import React, { createContext, useMemo, useContext, useEffect } from 'react';
import { inject } from 'mobx-react';
import { injectIntl } from 'react-intl';
import { observer } from 'mobx-react-lite';
import HandleMapStore from "../../../store/handleMapStore";
import { useCodeManagerStore } from "../../../../stores";
import useStore from "./useStore";
var CodeQualityStore = /*#__PURE__*/createContext();
export function useCodeQualityStore() {
  return useContext(CodeQualityStore);
}
export var CodeQualityStoreProvider = injectIntl(inject('AppState')(observer(function (props) {
  var children = props.children,
      formatMessage = props.intl.formatMessage,
      projectId = props.AppState.currentMenuType.projectId;

  var _useCodeManagerStore = useCodeManagerStore(),
      appServiceDs = _useCodeManagerStore.appServiceDs,
      selectAppDs = _useCodeManagerStore.selectAppDs;

  var appServiceId = selectAppDs.current.get('appServiceId');
  var codeQualityStore = useStore();
  useEffect(function () {
    if (!appServiceId) return;
    codeQualityStore.loadCodeQualityData(projectId, appServiceId);
  }, [appServiceId]);
  var value = {
    formatMessage: formatMessage,
    handleMapStore: HandleMapStore,
    codeQuality: codeQualityStore,
    projectId: projectId
  };
  return /*#__PURE__*/React.createElement(CodeQualityStore.Provider, {
    value: value
  }, children);
})));