import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  useBackendAsAServiceClient
} from "./chunk-T6BKE35X.js";
import {
  useProjectModel
} from "./chunk-XJE267QM.js";
import "./chunk-JJWBWHWO.js";
import "./chunk-YTGCPERW.js";
import {
  SiteAuthProvider
} from "./chunk-VZ3FZHJK.js";
import "./chunk-OWRWPLVG.js";
import "./chunk-CIOBCAOI.js";
import "./chunk-RPTAJN5Y.js";
import {
  Alert,
  Spinner,
  useAsync
} from "./chunk-2DKXIL7C.js";
import {
  require_react
} from "./chunk-7ZOEVDW3.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-LFX6WS3B.js";
import "./chunk-XTVDTH5G.js";
import "./chunk-TMZBOD2B.js";
import "./chunk-DR2IE2NL.js";
import "./chunk-JWVFFICN.js";
import "./chunk-YRSNPU5L.js";
import {
  require_lib
} from "./chunk-PIOT47FJ.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-astro-commands/src/components/EnvSetCommand/index.ts
init_esm_shims();

// ../cli-astro-commands/src/components/EnvSetCommand/EnvSetCommand.tsx
init_esm_shims();
var import_react2 = __toESM(require_react(), 1);

// ../cli-astro-commands/src/components/EnvSetCommand/EnvSet.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var import_variant = __toESM(require_lib(), 1);
var ENV_NAME = "prod";
var EnvSet = ({
  variable
}) => {
  const { model } = useProjectModel();
  const backendAsAServiceClient = useBackendAsAServiceClient();
  const { status } = useAsync(async () => {
    await backendAsAServiceClient.upsertAppEnvironment(
      model.config.appId,
      ENV_NAME,
      {
        [variable.key]: variable.value
      }
    );
  }, []);
  return (0, import_variant.match)(status, {
    Loading: () => /* @__PURE__ */ import_react.default.createElement(Spinner, { text: "Setting environment variable..." }),
    Success: () => /* @__PURE__ */ import_react.default.createElement(Alert, { type: "success" }, '"', variable.key, '" was successfully set'),
    Error: () => null,
    NotRequested: () => null
  });
};

// ../cli-astro-commands/src/components/EnvSetCommand/EnvSetCommand.tsx
var EnvSetCommand = ({ variable }) => {
  const {
    model: { config }
  } = useProjectModel();
  let commandTree = /* @__PURE__ */ import_react2.default.createElement(EnvSet, { variable });
  if (config.projectType === "Site") {
    commandTree = /* @__PURE__ */ import_react2.default.createElement(SiteAuthProvider, { siteId: config.siteId }, commandTree);
  }
  return commandTree;
};
export {
  EnvSetCommand
};
//# sourceMappingURL=EnvSetCommand-WXUUESWT.js.map