import { c as _c } from "react-compiler-runtime";
import { useEffect } from 'react';
import type { ScopedMcpServerConfig } from '../services/mcp/types.js';
import { getGlobalConfig } from '../utils/config.js';
import { isEnvDefinedFalsy, isEnvTruthy } from '../utils/envUtils.js';
import type { DetectedIDEInfo } from '../utils/ide.js';
import { type IDEExtensionInstallationStatus, type IdeType, initializeIdeIntegration, isSupportedTerminal } from '../utils/ide.js';
type UseIDEIntegrationProps = {
  autoConnectIdeFlag?: boolean;
  ideToInstallExtension: IdeType | null;
  setDynamicMcpConfig: React.Dispatch<React.SetStateAction<Record<string, ScopedMcpServerConfig> | undefined>>;
  setShowIdeOnboarding: React.Dispatch<React.SetStateAction<boolean>>;
  setIDEInstallationState: React.Dispatch<React.SetStateAction<IDEExtensionInstallationStatus | null>>;
};
export function useIDEIntegration(t0) {
  const $ = _c(7);
  const {
    autoConnectIdeFlag,
    ideToInstallExtension,
    setDynamicMcpConfig,
    setShowIdeOnboarding,
    setIDEInstallationState
  } = t0;
  let t1;
  let t2;
  if ($[0] !== autoConnectIdeFlag || $[1] !== ideToInstallExtension || $[2] !== setDynamicMcpConfig || $[3] !== setIDEInstallationState || $[4] !== setShowIdeOnboarding) {
    t1 = () => {
      const addIde = function addIde(ide) {
        if (!ide) {
          return;
        }
        const globalConfig = getGlobalConfig();
        const autoConnectEnabled = (globalConfig.autoConnectIde || autoConnectIdeFlag || isSupportedTerminal() || process.env.CLAUDE_CODE_SSE_PORT || ideToInstallExtension || isEnvTruthy(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)) && !isEnvDefinedFalsy(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE);
        if (!autoConnectEnabled) {
          return;
        }
        setDynamicMcpConfig(prev => {
          if (prev?.ide) {
            return prev;
          }
          return {
            ...prev,
            ide: {
              type: ide.url.startsWith("ws:") ? "ws-ide" : "sse-ide",
              url: ide.url,
              ideName: ide.name,
              authToken: ide.authToken,
              ideRunningInWindows: ide.ideRunningInWindows,
              scope: "dynamic" as const
            }
          };
        });
      };
      initializeIdeIntegration(addIde, ideToInstallExtension, () => setShowIdeOnboarding(true), status => setIDEInstallationState(status));
    };
    t2 = [autoConnectIdeFlag, ideToInstallExtension, setDynamicMcpConfig, setShowIdeOnboarding, setIDEInstallationState];
    $[0] = autoConnectIdeFlag;
    $[1] = ideToInstallExtension;
    $[2] = setDynamicMcpConfig;
    $[3] = setIDEInstallationState;
    $[4] = setShowIdeOnboarding;
    $[5] = t1;
    $[6] = t2;
  } else {
    t1 = $[5];
    t2 = $[6];
  }
  useEffect(t1, t2);
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJ1c2VFZmZlY3QiLCJTY29wZWRNY3BTZXJ2ZXJDb25maWciLCJnZXRHbG9iYWxDb25maWciLCJpc0VudkRlZmluZWRGYWxzeSIsImlzRW52VHJ1dGh5IiwiRGV0ZWN0ZWRJREVJbmZvIiwiSURFRXh0ZW5zaW9uSW5zdGFsbGF0aW9uU3RhdHVzIiwiSWRlVHlwZSIsImluaXRpYWxpemVJZGVJbnRlZ3JhdGlvbiIsImlzU3VwcG9ydGVkVGVybWluYWwiLCJVc2VJREVJbnRlZ3JhdGlvblByb3BzIiwiYXV0b0Nvbm5lY3RJZGVGbGFnIiwiaWRlVG9JbnN0YWxsRXh0ZW5zaW9uIiwic2V0RHluYW1pY01jcENvbmZpZyIsIlJlYWN0IiwiRGlzcGF0Y2giLCJTZXRTdGF0ZUFjdGlvbiIsIlJlY29yZCIsInNldFNob3dJZGVPbmJvYXJkaW5nIiwic2V0SURFSW5zdGFsbGF0aW9uU3RhdGUiLCJ1c2VJREVJbnRlZ3JhdGlvbiIsInQwIiwiJCIsIl9jIiwidDEiLCJ0MiIsImFkZElkZSIsImlkZSIsImdsb2JhbENvbmZpZyIsImF1dG9Db25uZWN0RW5hYmxlZCIsImF1dG9Db25uZWN0SWRlIiwicHJvY2VzcyIsImVudiIsIkNMQVVERV9DT0RFX1NTRV9QT1JUI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QU0sIGJyZWFraW5nIHRlcm1pbmFsIGRldGVjdGlvbiwgYnV0IHRoZVxuICAgICAgICAgIC8vIElERSBleHRlbnNpb24ncyBwb3J0IGVudiB2YXIgaXMgaW5oZXJpdGVkLiBJZiBzZXQsIGF1dG8tY29ubmVjdCBhbnl3YXkuXG4gICAgICAgICAgcHJvY2Vzcy5lbnYuQ0xBVURFX0NPREVfU1NFX1BPUlQgfHxcbiAgICAgICAgICBpZGVUb0luc3RhbGxFeHRlbnNpb24gfHxcbiAgICAgICAgICBpc0VudlRydXRoeShwcm9jZXNzLmVudi5DTEFVREVfQ09ERV9BVVRPX0NPTk5FQ1RfSURFKSkgJiZcbiAgICAgICAgIWlzRW52RGVmaW5lZEZhbHN5KHByb2Nlc3MuZW52LkNMQVVERV9DT0RFX0FVVE9fQ09OTkVDVF9JREUpXG5cbiAgICAgIGlmICghYXV0b0Nvbm5lY3RFbmFibGVkKSB7XG4gICAgICAgIHJldHVyblxuICAgICAgfVxuXG4gICAgICBzZXREeW5hbWljTWNwQ29uZmlnKHByZXYgPT4ge1xuICAgICAgICAvLyBPbmx5IGFkZCB0aGUgSURFIGlmIHdlIGRvbid0IGFscmVhZHkgaGF2ZSBvbmVcbiAgICAgICAgaWYgKHByZXY/LmlkZSkge1xuICAgICAgICAgIHJldHVybiBwcmV2XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAuLi5wcmV2LFxuICAgICAgICAgIGlkZToge1xuICAgICAgICAgICAgdHlwZTogaWRlLnVybC5zdGFydHNXaXRoKCd3czonKSA/ICd3cy1pZGUnIDogJ3NzZS1pZGUnLFxuICAgICAgICAgICAgdXJsOiBpZGUudXJsLFxuICAgICAgICAgICAgaWRlTmFtZTogaWRlLm5hbWUsXG4gICAgICAgICAgICBhdXRoVG9rZW46IGlkZS5hdXRoVG9rZW4sXG4gICAgICAgICAgICBpZGVSdW5uaW5nSW5XaW5kb3dzOiBpZGUuaWRlUnVubmluZ0luV2luZG93c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