import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  useCreatePreview
} from "./chunk-YVBOSUYT.js";
import {
  DeploymentStatus
} from "./chunk-F3UCUZVD.js";
import "./chunk-7IUEU3FM.js";
import "./chunk-MYWHJYA3.js";
import "./chunk-3WT6GXEF.js";
import "./chunk-DZ3U3XXP.js";
import "./chunk-I5KDLQBC.js";
import "./chunk-WFIBPVQL.js";
import "./chunk-ZY7YHRZR.js";
import "./chunk-DLEBD2WZ.js";
import "./chunk-RTNIG6ZW.js";
import "./chunk-O6HC4AYN.js";
import "./chunk-QRGKMYDD.js";
import "./chunk-WFQIXGJV.js";
import "./chunk-ECBO3UFC.js";
import "./chunk-YNEGRO3E.js";
import {
  ErrorViewer
} from "./chunk-HWT3LUJJ.js";
import "./chunk-TOBTRYZF.js";
import {
  Trans
} from "./chunk-7WVNO7VU.js";
import "./chunk-RPTAJN5Y.js";
import {
  Alert,
  Badge,
  Box_default,
  Link,
  Spinner,
  useAsync
} from "./chunk-YL4347CI.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-SVUXJRFD.js";
import "./chunk-YT5BPQDJ.js";
import "./chunk-LU3R3EBR.js";
import "./chunk-XZUGLEBK.js";
import "./chunk-VASURI4S.js";
import "./chunk-SDLCFZRL.js";
import {
  require_lib
} from "./chunk-MTT3QXBC.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site/src/components/PreviewCommand/PreviewCommand.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var import_variant = __toESM(require_lib(), 1);
var PreviewCommand = ({ force }) => {
  const createPreview = useCreatePreview();
  const { status } = useAsync(async () => {
    const { previewUrl, deploymentStatus } = await createPreview();
    if (!force && (0, import_variant.isType)(deploymentStatus, DeploymentStatus.Error)) {
      throw deploymentStatus.deploymentError;
    }
    return { previewUrl, deploymentStatus };
  }, []);
  return (0, import_variant.match)(status, {
    Error: () => null,
    Loading: () => /* @__PURE__ */ import_react.default.createElement(Spinner, { text: /* @__PURE__ */ import_react.default.createElement(Trans, { i18nKey: "preview_command.loading" }) }),
    Success: ({ result: { previewUrl, deploymentStatus } }) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, (0, import_variant.isType)(deploymentStatus, DeploymentStatus.Error) ? /* @__PURE__ */ import_react.default.createElement(Box_default, { marginBottom: 1, flexDirection: "column" }, /* @__PURE__ */ import_react.default.createElement(ErrorViewer, { error: deploymentStatus.deploymentError })) : null, /* @__PURE__ */ import_react.default.createElement(Alert, { type: "success" }, /* @__PURE__ */ import_react.default.createElement(Badge, { skin: "success" }, /* @__PURE__ */ import_react.default.createElement(Trans, { i18nKey: "general.success" })), " ", /* @__PURE__ */ import_react.default.createElement(
      Trans,
      {
        i18nKey: "preview_command.success",
        components: [/* @__PURE__ */ import_react.default.createElement(Link, { url: previewUrl })]
      }
    )))
  });
};
export {
  PreviewCommand
};
//# sourceMappingURL=PreviewCommand-X7FS7IVC.js.map