import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  DevEnvironmentProvider,
  ExtensionDataProvider,
  SiteProvider,
  SiteSelector,
  redirectWithCSMv2FTs,
  useARMClient,
  useArmTag,
  useBlocksCLIDevServerProvider,
  useDevEnvironment,
  useExtensionData,
  useMetasiteManagerClient,
  useOpenPage,
  usePlatform,
  useResolveBlocksEditorURL,
  useResolveDashboardExtensionDevUrl,
  useResolvePlatformDevUrl,
  useSite
} from "./chunk-YW5VWLDR.js";
import {
  useWixCliAppBi
} from "./chunk-M3OH247O.js";
import {
  useBackendComponents
} from "./chunk-KFXX6RSR.js";
import "./chunk-ZQ4OT2G3.js";
import "./chunk-P7IRRCF7.js";
import "./chunk-F7F76XNN.js";
import {
  createLogger
} from "./chunk-DKQSEAPV.js";
import {
  createCustomElementConfig
} from "./chunk-COJCSNKS.js";
import "./chunk-SHFXNLTG.js";
import {
  Alert,
  Box_default,
  CliError,
  CliErrorCode,
  ComponentType,
  ConfirmInput,
  DevCenterComponent,
  ErrorViewer,
  Key,
  Link,
  PlatformType,
  PointerIcon,
  PointerSmallIcon,
  SelectInput,
  Spinner,
  Text,
  TimeoutError,
  Trans,
  USER_CONFIG_FILENAME,
  getDataDirPath,
  getTestOverrides,
  pWaitFor,
  pathExists,
  readJson,
  require_lib,
  require_react,
  useAsync,
  useAsyncCallback,
  useBiLogger,
  useDevCenterClient,
  useErrorReporter,
  useExit,
  useExtensions,
  useHttpClient,
  useProjectModel,
  useTranslation,
  use_input_default,
  userConfigSchema,
  writeJson
} from "./chunk-MC5CS2RC.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-4EFJZ3GQ.js";

// src/components/DevCommand/index.ts
init_esm_shims();

// src/components/DevCommand/DevCommand.tsx
init_esm_shims();
var import_react20 = __toESM(require_react(), 1);

// ../cli-user-config/src/user-config.ts
init_esm_shims();
import { join } from "node:path";
function getUserConfigPath() {
  return join(getDataDirPath(), USER_CONFIG_FILENAME);
}
async function readUserConfig() {
  const configPath = getUserConfigPath();
  const isConfigExist = await pathExists(configPath);
  const json = isConfigExist ? await readJson(configPath) : {};
  return userConfigSchema.parse(json);
}
async function updateUserConfig(config) {
  const currentConfig = await readUserConfig();
  const newConfig = {
    ...currentConfig,
    ...config
  };
  const configPath = getUserConfigPath();
  await writeJson(configPath, newConfig);
}

// src/components/DevCommand/DevCommandScreens.tsx
init_esm_shims();
var import_react16 = __toESM(require_react(), 1);
var import_variant14 = __toESM(require_lib(), 1);

// src/components/DevCommand/HomeScreen.tsx
init_esm_shims();
var import_react11 = __toESM(require_react(), 1);
var import_variant10 = __toESM(require_lib(), 1);

// src/components/DevCommand/screen-state.ts
init_esm_shims();
var import_variant = __toESM(require_lib(), 1);
var ScreenState = (0, import_variant.variant)({
  Home: {},
  SiteSelector: {},
  DashboardScreen: (0, import_variant.fields)(),
  BackendScreen: (0, import_variant.fields)()
});

// src/components/Platform/PlatformSelector.tsx
init_esm_shims();
var import_react5 = __toESM(require_react(), 1);

// src/components/DevCommand/EditorInstallation.tsx
init_esm_shims();
var import_react4 = __toESM(require_react(), 1);
var import_variant5 = __toESM(require_lib(), 1);

// src/components/DevCommand/AppComponentsMigrations.tsx
init_esm_shims();
var import_react3 = __toESM(require_react(), 1);
var import_variant4 = __toESM(require_lib(), 1);

// src/components/DevCommand/useCustomElementsMigration.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var import_variant2 = __toESM(require_lib(), 1);
var DUMMY_CUSTOM_ELEMENT_TAG_NAME = "wix-cli-dummy-custom-element";
var DUMMY_CUSTOM_ELEMENT_URL = "https://www.unpkg.com/@wix/cli-dummy-custom-element";
var DUMMY_CUSTOM_ELEMENT_THUMBNAIL_URL = "https://www.unpkg.com/@wix/cli-dummy-custom-element/dist/preset/thumbnail.png";
function useCustomElementsMigration() {
  const { model } = useProjectModel();
  const getNewElements = (0, import_react.useCallback)(
    (newCustomElements) => {
      return newCustomElements.map((customElement) => {
        const config = createCustomElementConfig(
          customElement,
          DUMMY_CUSTOM_ELEMENT_URL
        );
        return {
          ...config,
          compData: {
            customElementWidget: {
              ...config.compData.customElementWidget,
              widgetData: {
                ...config.compData.customElementWidget.widgetData,
                tagName: DUMMY_CUSTOM_ELEMENT_TAG_NAME
              },
              presets: config.compData.customElementWidget.presets?.map(
                (preset) => ({
                  ...preset,
                  thumbnailUrl: DUMMY_CUSTOM_ELEMENT_THUMBNAIL_URL
                })
              )
            }
          }
        };
      });
    },
    []
  );
  return (0, import_react.useCallback)(
    (appComponents) => {
      const localCustomElements = model.components.filter(
        (component) => (0, import_variant2.isType)(component, DevCenterComponent.CustomElement)
      );
      if (!localCustomElements.length) {
        return;
      }
      const existingCustomElements = appComponents.filter(
        (component) => component.compType === ComponentType.CUSTOM_ELEMENT_WIDGET
      );
      const newCustomElements = localCustomElements.filter(
        (localCustomElement) => !existingCustomElements.some(
          (customElement) => customElement.compId === localCustomElement.id
        )
      );
      if (!newCustomElements.length) {
        return;
      }
      return getNewElements(newCustomElements);
    },
    [getNewElements, model.components]
  );
}

// src/components/DevCommand/useBlocksComponentsMigrations.tsx
init_esm_shims();
var import_react2 = __toESM(require_react(), 1);
var import_variant3 = __toESM(require_lib(), 1);
function useBlocksComponentsMigration() {
  const { model } = useProjectModel();
  const virtualStudioComponent = model.components.find(
    (0, import_variant3.isType)(DevCenterComponent.BlocksMainComponent)
  );
  return (0, import_react2.useCallback)(
    (appComponents) => {
      const doesStudioComponentExists = appComponents.some(
        (component) => component.compType === ComponentType.STUDIO
      );
      if (!model.config.blocks || doesStudioComponentExists) {
        return;
      }
      const studioComponent = {
        compId: virtualStudioComponent?.id,
        compType: "STUDIO",
        compData: {},
        compName: "studio"
      };
      return [studioComponent];
    },
    [model, virtualStudioComponent]
  );
}

// src/components/DevCommand/AppComponentsMigrations.tsx
var AppMigrationsContext = (0, import_react3.createContext)(
  null
);
var AppComponentsMigrations = ({ children }) => {
  const { getAppByVersion } = useDevCenterClient();
  const { createComponents } = useARMClient();
  const getCustomElementMigrationComponents = useCustomElementsMigration();
  const getBlocksMigrationComponents = useBlocksComponentsMigration();
  const { t } = useTranslation();
  const { model } = useProjectModel();
  const appMigrationsContextData = useAsync(async () => {
    const {
      data: { components }
    } = await getAppByVersion({
      appId: model.config.appId
    });
    const newBlocksComponents = getBlocksMigrationComponents(components) ?? [];
    const newCustomElementsComponents = getCustomElementMigrationComponents(components) ?? [];
    const componentsToCreate = [
      ...newCustomElementsComponents,
      ...newBlocksComponents
    ];
    if (componentsToCreate.length) {
      await createComponents(
        model.config.appId,
        componentsToCreate,
        model.config.projectId
      );
    }
    return {
      addedSitePresence: !!newCustomElementsComponents.length
    };
  }, [model.components]);
  return (0, import_variant4.match)(appMigrationsContextData.status, {
    Error: () => null,
    Loading: () => /* @__PURE__ */ import_react3.default.createElement(Spinner, { text: t("general.loading") }),
    Success: ({ result: { addedSitePresence } }) => {
      return /* @__PURE__ */ import_react3.default.createElement(AppMigrationsContext.Provider, { value: { addedSitePresence } }, children);
    }
  });
};
function useAppComponentsMigrationsContext() {
  const context = (0, import_react3.useContext)(AppMigrationsContext);
  if (context == null) {
    throw new Error(
      "useAppMigrationsContext() cannot be used without a <AppMigrationsProvider>"
    );
  }
  return context;
}

// src/components/DevCommand/EditorInstallation.tsx
function isAbortError(error) {
  return error && typeof error === "object" && "name" in error && error.name === "AbortError";
}
var EditorInstallationContext = (0, import_react4.createContext)(
  null
);
function useEditorInstallation() {
  const context = (0, import_react4.useContext)(EditorInstallationContext);
  if (context == null) {
    throw new Error(
      "useEditorInstallation() cannot be used without an <EditorInstallationProvider>"
    );
  }
  return context;
}
var EditorInstallationStatus = (0, import_variant5.variant)({
  CheckInstallation: {},
  NotInstalled: (0, import_variant5.fields)(),
  WaitForInstallation: (0, import_variant5.fields)(),
  Installed: {}
});
var CheckEditorInstallation = ({ onReady }) => {
  const { model } = useProjectModel();
  const { reportError } = useErrorReporter();
  const { site } = useSite();
  const { isAppInstalledInEditor } = useDevCenterClient({ siteId: site.id });
  const checkAppInstalledState = useAsyncCallback(
    async ({ signal }, shouldWait = false) => {
      const { appId } = model.config;
      const { pollInterval } = getTestOverrides();
      try {
        if (shouldWait) {
          await pWaitFor(() => isAppInstalledInEditor(appId), {
            // Polling interval is set to 6.5 seconds to avoid rate limiting (429)
            interval: pollInterval ?? 6500,
            timeout: {
              milliseconds: 60 * 1e3 * 2,
              signal
            }
          });
          return true;
        }
        return await isAppInstalledInEditor(appId);
      } catch (error) {
        if (!isAbortError(error) && !(error instanceof TimeoutError)) {
          reportError(
            new CliError({
              cause: error,
              code: CliErrorCode.WaitForEditorInstallationStateFailure()
            })
          );
        }
        return false;
      }
    }
  );
  useAsync(async () => {
    onReady(checkAppInstalledState.execute);
  }, [site.id]);
  return null;
};
var EditorInstallation = ({ children }) => {
  const { t } = useTranslation();
  const { model } = useProjectModel();
  const httpClient = useHttpClient({ type: "backoffice" });
  const { isPlatformExists } = usePlatform();
  const { getExtensions } = useExtensions();
  const { site } = useSite();
  const { armTag } = useArmTag();
  const openPage = useOpenPage();
  const { addedSitePresence } = useAppComponentsMigrationsContext();
  const resolvePlatformUrl = useResolvePlatformDevUrl();
  const [editorInstallationStatus, setEditorInstallationStatus] = (0, import_react4.useState)(
    EditorInstallationStatus.CheckInstallation()
  );
  const openAddPanel = (0, import_react4.useMemo)(
    () => getExtensions("CustomElement").some(
      (element) => !element.installation?.autoAddToSite && (element.presets?.length ?? 0) > 0
    ),
    [getExtensions]
  );
  const openEditor = (0, import_react4.useCallback)(async () => {
    const platformType = PlatformType.Editor();
    const installationUrl = (0, import_variant5.match)(
      editorInstallationStatus,
      (0, import_variant5.partial)({
        NotInstalled: ({ installationUrl: installationUrl2 }) => installationUrl2,
        WaitForInstallation: ({ installationUrl: installationUrl2 }) => installationUrl2,
        default: () => resolvePlatformUrl(platformType, openAddPanel)
      })
    );
    await openPage({ title: platformType.type, url: installationUrl });
    if ((0, import_variant5.isType)(editorInstallationStatus, "NotInstalled")) {
      setEditorInstallationStatus(
        EditorInstallationStatus.WaitForInstallation({ installationUrl })
      );
      const isInstalled = await editorInstallationStatus.checkInstalledState(true);
      if (isInstalled) {
        setEditorInstallationStatus(EditorInstallationStatus.Installed());
      } else {
        setEditorInstallationStatus(editorInstallationStatus);
      }
    }
  }, [openPage, resolvePlatformUrl, editorInstallationStatus, openAddPanel]);
  const buildInstallationUrl = (0, import_react4.useCallback)(async () => {
    const { data: signedAppMarketParams } = await httpClient.post("/_serverless/app-market-json-web-token/json-web-token", {
      data: {
        data: JSON.stringify({
          appDefId: model.config.appId,
          version: "latest"
        })
      }
    }).catch((e) => {
      throw new CliError({
        code: CliErrorCode.FailedToGenerateAppMarketQueryParam(),
        cause: e
      });
    });
    const url = new URL(`https://wix.com/editor/${site.id}`);
    url.searchParams.append("openPanel", "appMarket");
    url.searchParams.append("preferAppManager", "true");
    url.searchParams.append("appMarketParams", signedAppMarketParams);
    url.searchParams.append("apps-override", armTag);
    if (openAddPanel) {
      url.searchParams.append("deeplink", `addpanel!${model.config.appId}`);
    }
    return redirectWithCSMv2FTs(url, PlatformType.Editor()).toString();
  }, [httpClient, model.config.appId, site.id, armTag, openAddPanel]);
  const { status, execute } = useAsyncCallback(
    async (_, checkInstalledState) => {
      if (isPlatformExists(PlatformType.Editor())) {
        const isInstalled = addedSitePresence ? false : await checkInstalledState();
        if (!isInstalled) {
          const installationUrl = await buildInstallationUrl();
          return setEditorInstallationStatus(
            EditorInstallationStatus.NotInstalled({
              installationUrl,
              checkInstalledState
            })
          );
        }
      }
      return setEditorInstallationStatus(EditorInstallationStatus.Installed());
    }
  );
  (0, import_react4.useEffect)(() => {
    setEditorInstallationStatus(EditorInstallationStatus.CheckInstallation());
  }, [site.id]);
  return /* @__PURE__ */ import_react4.default.createElement(EditorInstallationContext.Provider, { value: { openEditor } }, !(0, import_variant5.isType)(editorInstallationStatus, "Installed") && /* @__PURE__ */ import_react4.default.createElement(CheckEditorInstallation, { onReady: execute }), (0, import_variant5.match)(status, {
    NotRequested: () => null,
    Loading: () => /* @__PURE__ */ import_react4.default.createElement(Spinner, { text: t("general.loading") }),
    Error: () => null,
    Success: () => children
  }));
};

// src/components/Platform/PlatformSelector.tsx
var PlatformOption = ({
  label,
  inputKey,
  suffix,
  disabled
}) => {
  const getTextSkin = () => disabled ? "secondary" : "standard";
  return /* @__PURE__ */ import_react5.default.createElement(Box_default, null, /* @__PURE__ */ import_react5.default.createElement(Box_default, { marginRight: 1 }, /* @__PURE__ */ import_react5.default.createElement(Box_default, { marginRight: 1 }, /* @__PURE__ */ import_react5.default.createElement(Text, { skin: getTextSkin() }, /* @__PURE__ */ import_react5.default.createElement(PointerSmallIcon, null), " ", /* @__PURE__ */ import_react5.default.createElement(Key, { value: inputKey }), " -")), /* @__PURE__ */ import_react5.default.createElement(Box_default, { gap: 1 }, /* @__PURE__ */ import_react5.default.createElement(Text, { skin: getTextSkin() }, label))), /* @__PURE__ */ import_react5.default.createElement(Text, { skin: getTextSkin() }, suffix));
};
var PlatformSelector = ({
  onMultipleDashboardExtensionSelection
}) => {
  const { t } = useTranslation();
  const bi = useWixCliAppBi();
  const { isPlatformExists } = usePlatform();
  const { openEditor } = useEditorInstallation();
  const { dashboardExtensions } = useExtensions();
  const resolvePlatformUrl = useResolvePlatformDevUrl();
  const resolveDashboardExtensionUrl = useResolveDashboardExtensionDevUrl();
  const resolveBlocksEditorUrl = useResolveBlocksEditorURL();
  const { enabled: isBlocksEnabled } = useBlocksCLIDevServerProvider();
  const { site } = useSite();
  const openPage = useOpenPage();
  const { getDashboardExtensionsRoute } = useExtensionData();
  const openPlatform = (0, import_react5.useCallback)(
    async (platformType) => {
      await openPage({
        title: platformType.type,
        url: resolvePlatformUrl(platformType)
      });
    },
    [openPage, resolvePlatformUrl]
  );
  use_input_default(async (input) => {
    if (input === "d" && isPlatformExists(PlatformType.Dashboard())) {
      bi.cliAction({
        question: t("general.view_changes"),
        questionKey: "general.view_changes",
        action: t("general.platform.dashboard"),
        key: input
      });
      if (dashboardExtensions.length === 1 && dashboardExtensions[0]) {
        await openPage({
          title: "Dashboard",
          url: resolveDashboardExtensionUrl(dashboardExtensions[0])
        });
      } else {
        onMultipleDashboardExtensionSelection();
      }
    }
    if (input === "e" && isPlatformExists(PlatformType.Editor())) {
      bi.cliAction({
        question: t("general.view_changes"),
        questionKey: "general.view_changes",
        action: t("general.platform.editor"),
        key: input
      });
      await openEditor();
    }
    if (input === "s" && site.viewUrl && isPlatformExists(PlatformType.Site())) {
      bi.cliAction({
        question: t("general.view_changes"),
        questionKey: "general.view_changes",
        action: t("general.platform.site"),
        key: input
      });
      await openPlatform(PlatformType.Site());
    }
    if (input === "b" && isBlocksEnabled) {
      bi.cliAction({
        question: t("general.view_changes"),
        questionKey: "general.view_changes",
        action: t("general.platform.blocks_editor"),
        key: input
      });
      await openPage({
        title: t("general.platform.blocks_editor"),
        url: resolveBlocksEditorUrl()
      });
    }
  });
  const dashboardOptionSuffix = (0, import_react5.useMemo)(() => {
    if (dashboardExtensions.length === 0) {
      return null;
    }
    if (dashboardExtensions.length === 1 && dashboardExtensions[0]) {
      const route = getDashboardExtensionsRoute(dashboardExtensions[0]);
      return /* @__PURE__ */ import_react5.default.createElement(Text, { skin: "secondary" }, " - ", route);
    }
    return /* @__PURE__ */ import_react5.default.createElement(Text, null, String.fromCodePoint(9660));
  }, [dashboardExtensions, getDashboardExtensionsRoute]);
  return /* @__PURE__ */ import_react5.default.createElement(Box_default, { paddingLeft: 2, flexDirection: "column" }, isPlatformExists(PlatformType.Site()) && /* @__PURE__ */ import_react5.default.createElement(
    PlatformOption,
    {
      inputKey: "S",
      label: site.viewUrl ? t("general.platform.site") : t("general.platform.unpublished_site"),
      disabled: !site.viewUrl
    }
  ), isPlatformExists(PlatformType.Editor()) && /* @__PURE__ */ import_react5.default.createElement(PlatformOption, { inputKey: "E", label: t("general.platform.editor") }), isPlatformExists(PlatformType.Dashboard()) && /* @__PURE__ */ import_react5.default.createElement(
    PlatformOption,
    {
      inputKey: "D",
      label: t("general.platform.dashboard"),
      suffix: dashboardOptionSuffix
    }
  ), isBlocksEnabled && /* @__PURE__ */ import_react5.default.createElement(
    PlatformOption,
    {
      inputKey: "B",
      label: t("general.platform.blocks_editor")
    }
  ));
};

// src/components/DevCommand/DashboardNumericViewer.tsx
init_esm_shims();
var import_react10 = __toESM(require_react(), 1);
var import_variant9 = __toESM(require_lib(), 1);

// src/components/CloseScreen/CloseScreen.tsx
init_esm_shims();
var import_react6 = __toESM(require_react(), 1);
var CloseScreen = ({ onClose }) => {
  const { t } = useTranslation();
  const bi = useWixCliAppBi();
  use_input_default((_, key) => {
    if (key.escape) {
      bi.cliAction({
        question: t("general.close_screen"),
        questionKey: "general.close_screen",
        action: "close",
        key: "esc"
      });
      onClose();
    }
  });
  return /* @__PURE__ */ import_react6.default.createElement(Text, { skin: "secondary" }, /* @__PURE__ */ import_react6.default.createElement(
    Trans,
    {
      i18nKey: "general.close_screen",
      components: [/* @__PURE__ */ import_react6.default.createElement(Key, { value: "esc", skin: "secondary" })]
    }
  ));
};

// src/components/DevCommand/DashboardScreen.tsx
init_esm_shims();
var import_react8 = __toESM(require_react(), 1);
var import_variant7 = __toESM(require_lib(), 1);

// src/components/DevCommand/DashboardArrowViewer.tsx
init_esm_shims();
var import_react7 = __toESM(require_react(), 1);
var import_variant6 = __toESM(require_lib(), 1);
var DashboardArrowViewer = ({
  dashboardExtension,
  onClose,
  onSelect
}) => {
  const { t } = useTranslation();
  const { getExtensions } = useExtensions();
  const bi = useWixCliAppBi();
  const resolveDashboardExtensionUrl = useResolveDashboardExtensionDevUrl();
  const { getDashboardExtensionsRoute } = useExtensionData();
  const openPage = useOpenPage();
  const getLabelKey = (0, import_react7.useCallback)(
    () => (0, import_variant6.match)(
      dashboardExtension,
      (0, import_variant6.lookup)({
        DashboardPlugin: "dev_command.dashboard_page_plugin_screen.select_label",
        DashboardMenuPlugin: "dev_command.dashboard_menu_plugin_screen.select_label",
        DashboardPage: "dev_command.dashboard_pages_screen.select_label",
        DashboardModal: "dev_command.dashboard_modal_screen.select_label"
      })
    ),
    [dashboardExtension]
  );
  const handleSubmit = (0, import_react7.useCallback)(
    async (dashboardExtension2) => {
      const url = resolveDashboardExtensionUrl(dashboardExtension2);
      bi.cliAction({
        question: t(getLabelKey()),
        questionKey: getLabelKey(),
        action: dashboardExtension2.title,
        key: "enter"
      });
      await openPage({ url, title: dashboardExtension2.title });
      onSelect?.(dashboardExtension2);
    },
    [resolveDashboardExtensionUrl, bi, t, getLabelKey, openPage, onSelect]
  );
  return /* @__PURE__ */ import_react7.default.createElement(Box_default, { flexDirection: "column", gap: 1 }, /* @__PURE__ */ import_react7.default.createElement(Box_default, { flexDirection: "column" }, /* @__PURE__ */ import_react7.default.createElement(
    SelectInput,
    {
      label: t(getLabelKey()),
      options: getExtensions(dashboardExtension).map(
        (dashboardExtensionInstance) => ({
          key: dashboardExtensionInstance.id,
          title: dashboardExtensionInstance.title,
          description: getDashboardExtensionsRoute(
            dashboardExtensionInstance
          ),
          value: dashboardExtensionInstance
        })
      ),
      onSubmit: ({ value: dashboardExtensionInstance }) => handleSubmit(dashboardExtensionInstance)
    }
  )), /* @__PURE__ */ import_react7.default.createElement(CloseScreen, { onClose }));
};

// src/components/DevCommand/DashboardScreen.tsx
var DashboardScreenSelector = (0, import_variant7.variant)({
  Arrow: (0, import_variant7.fields)(),
  Numeric: {}
});
var DashboardScreen = ({
  onClose,
  onSelect,
  initialSelectorType = DashboardScreenSelector.Numeric()
}) => {
  const [selectorType, setSelectorType] = (0, import_react8.useState)(initialSelectorType);
  return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, (0, import_variant7.match)(selectorType, {
    Arrow: ({ dashboardExtension }) => /* @__PURE__ */ import_react8.default.createElement(
      DashboardArrowViewer,
      {
        dashboardExtension,
        onSelect,
        onClose
      }
    ),
    Numeric: () => /* @__PURE__ */ import_react8.default.createElement(
      DashboardNumericViewer,
      {
        onViewMore: setSelectorType,
        onSelect,
        onClose
      }
    )
  }));
};

// src/components/NumericViewer/NumericViewer.tsx
init_esm_shims();
var import_react9 = __toESM(require_react(), 1);
var import_variant8 = __toESM(require_lib(), 1);
var ListItem = ({ itemNumber, children }) => {
  const keyValue = `${itemNumber}`;
  return /* @__PURE__ */ import_react9.default.createElement(Box_default, { flexDirection: "row", gap: 1 }, /* @__PURE__ */ import_react9.default.createElement(Text, null, /* @__PURE__ */ import_react9.default.createElement(PointerSmallIcon, null), " ", /* @__PURE__ */ import_react9.default.createElement(Key, { value: keyValue }), " -"), children);
};
var NumericOption = (0, import_variant8.variant)(
  (0, import_variant8.onTerms)(({ I: _I, V }) => ({
    Item: (0, import_variant8.fields)(),
    ViewMore: (0, import_variant8.payload)(V)
  }))
);
function NumericViewer({
  startIndex,
  titleKey,
  items
}) {
  return /* @__PURE__ */ import_react9.default.createElement(Box_default, { flexDirection: "column" }, /* @__PURE__ */ import_react9.default.createElement(Trans, { i18nKey: titleKey }), /* @__PURE__ */ import_react9.default.createElement(Box_default, { paddingLeft: 2, flexDirection: "column" }, items.map((item, index) => /* @__PURE__ */ import_react9.default.createElement(
    ListItem,
    {
      key: startIndex + index + 1,
      itemNumber: startIndex + index + 1
    },
    (0, import_variant8.match)(item, {
      Item: ({ title, description }) => /* @__PURE__ */ import_react9.default.createElement(Box_default, { flexDirection: "row", gap: 1 }, /* @__PURE__ */ import_react9.default.createElement(Text, null, title), description && /* @__PURE__ */ import_react9.default.createElement(Text, { skin: "secondary" }, "(", description, ")")),
      ViewMore: () => /* @__PURE__ */ import_react9.default.createElement(Trans, { i18nKey: "general.numeric_viewer.show_more" })
    })
  ))));
}

// src/components/DevCommand/DashboardNumericViewer.tsx
var MAX_EXTENSIONS = 9;
var MAX_DASHBOARD_PAGES = 3;
var MAX_PAGE_PLUGINS = 3;
var MAX_MENU_PLUGINS = 3;
var DashboardNumericViewer = ({
  onViewMore,
  onSelect,
  onClose
}) => {
  const { t } = useTranslation();
  const { getExtensions } = useExtensions();
  const { getDashboardExtensionsRoute } = useExtensionData();
  const bi = useWixCliAppBi();
  const resolveDashboardExtensionUrl = useResolveDashboardExtensionDevUrl();
  const openPage = useOpenPage();
  const dashboardExtensions = (0, import_react10.useMemo)(
    () => ({
      dashboardPages: getExtensions("DashboardPage"),
      dashboardMenuPlugins: getExtensions("DashboardMenuPlugin"),
      dashboardPlugins: getExtensions("DashboardPlugin")
    }),
    [getExtensions]
  );
  const dashboardPagesData = dashboardExtensions.dashboardPages.slice(
    0,
    dashboardExtensions.dashboardPages.length > MAX_DASHBOARD_PAGES ? MAX_DASHBOARD_PAGES - 1 : dashboardExtensions.dashboardPages.length
  );
  const dashboardPagesShowMoreIndex = dashboardExtensions.dashboardPages.length > dashboardPagesData.length ? dashboardPagesData.length + 1 : void 0;
  const dashboardPagesCount = Math.max(
    dashboardPagesData.length,
    dashboardPagesShowMoreIndex ?? 0
  );
  const maxMenuPlugins = Math.min(
    MAX_MENU_PLUGINS,
    Math.floor((MAX_EXTENSIONS - dashboardPagesCount) / 2)
  );
  const dashboardMenuPluginsData = dashboardExtensions.dashboardMenuPlugins.slice(
    0,
    dashboardExtensions.dashboardMenuPlugins.length > maxMenuPlugins ? maxMenuPlugins - 1 : dashboardExtensions.dashboardMenuPlugins.length
  );
  const dashboardMenuPluginsShowMoreIndex = dashboardExtensions.dashboardMenuPlugins.length > dashboardMenuPluginsData.length ? dashboardMenuPluginsData.length + dashboardPagesCount + 1 : void 0;
  const dashboardMenuPluginsCount = Math.max(
    dashboardMenuPluginsData.length + dashboardPagesCount,
    dashboardMenuPluginsShowMoreIndex ?? 0
  );
  const maxPagePlugins = Math.min(
    MAX_PAGE_PLUGINS,
    MAX_EXTENSIONS - dashboardMenuPluginsCount
  );
  const dashboardPluginsData = dashboardExtensions.dashboardPlugins.slice(
    0,
    dashboardExtensions.dashboardPlugins.length > maxPagePlugins ? maxPagePlugins - 1 : dashboardExtensions.dashboardPlugins.length
  );
  const dashboardPluginsShowMoreIndex = dashboardExtensions.dashboardPlugins.length > dashboardPluginsData.length ? dashboardPluginsData.length + dashboardMenuPluginsCount + 1 : void 0;
  const visibleItems = [
    ...dashboardPagesData.map(
      (page) => NumericOption.Item({
        title: page.title,
        description: page.route,
        value: page
      })
    ),
    ...dashboardPagesShowMoreIndex ? [NumericOption.ViewMore("DashboardPage")] : [],
    ...dashboardMenuPluginsData.map(
      (menuPlugin) => NumericOption.Item({
        title: menuPlugin.title,
        description: getDashboardExtensionsRoute(menuPlugin),
        value: menuPlugin
      })
    ),
    ...dashboardMenuPluginsShowMoreIndex ? [NumericOption.ViewMore("DashboardMenuPlugin")] : [],
    ...dashboardPluginsData.map(
      (pagePlugin) => NumericOption.Item({
        title: pagePlugin.title,
        description: getDashboardExtensionsRoute(pagePlugin),
        value: pagePlugin
      })
    ),
    ...dashboardPluginsShowMoreIndex ? [NumericOption.ViewMore("DashboardPlugin")] : []
  ];
  const getLabelKey = (dashboardExtension) => {
    return (0, import_variant9.match)(
      dashboardExtension,
      (0, import_variant9.lookup)({
        DashboardPage: "general.dashboard_pages_viewer.title",
        DashboardMenuPlugin: "general.dashboard_menu_plugins_viewer.title",
        DashboardPlugin: "general.dashboard_plugins_viewer.title",
        DashboardModal: ""
        // NOTE: No key for this type
      })
    );
  };
  use_input_default(async (input) => {
    const inputNumber = Number(input);
    if (inputNumber > 0 && inputNumber <= visibleItems.length) {
      const itemIndex = inputNumber - 1;
      const item = visibleItems.at(itemIndex);
      if (item) {
        await (0, import_variant9.match)(item, {
          Item: async (item2) => {
            bi.cliAction({
              question: t(getLabelKey(item2.value)),
              questionKey: getLabelKey(item2.value),
              action: item2.title,
              key: input
            });
            await handleSelect(item2.value);
          },
          ViewMore: (viewMore) => {
            bi.cliAction({
              question: t("general.numeric_viewer.show_more"),
              questionKey: "general.numeric_viewer.show_more",
              action: "view_more",
              key: input
            });
            onViewMore(
              DashboardScreenSelector.Arrow({
                dashboardExtension: viewMore.payload
              })
            );
          }
        });
      }
    }
  });
  const handleSelect = (0, import_react10.useCallback)(
    async (dashboardExtension) => {
      const url = resolveDashboardExtensionUrl(dashboardExtension);
      await openPage({
        url,
        title: dashboardExtension.title
      });
      onSelect?.(dashboardExtension);
    },
    [onSelect, openPage, resolveDashboardExtensionUrl]
  );
  const dashboardPages = visibleItems.slice(0, dashboardPagesCount);
  const dashboardMenuPlugins = visibleItems.slice(
    dashboardPagesCount,
    dashboardMenuPluginsCount
  );
  const dashboardPlugins = visibleItems.slice(dashboardMenuPluginsCount);
  return /* @__PURE__ */ import_react10.default.createElement(Box_default, { flexDirection: "column", gap: 1 }, dashboardPages.length > 0 && /* @__PURE__ */ import_react10.default.createElement(
    NumericViewer,
    {
      startIndex: 0,
      titleKey: "general.dashboard_pages_viewer.title",
      items: dashboardPages
    }
  ), dashboardMenuPlugins.length > 0 && /* @__PURE__ */ import_react10.default.createElement(
    NumericViewer,
    {
      startIndex: dashboardPagesCount,
      titleKey: "general.dashboard_menu_plugins_viewer.title",
      items: dashboardMenuPlugins
    }
  ), dashboardPlugins.length > 0 && /* @__PURE__ */ import_react10.default.createElement(
    NumericViewer,
    {
      startIndex: dashboardMenuPluginsCount,
      titleKey: "general.dashboard_plugins_viewer.title",
      items: dashboardPlugins
    }
  ), onClose && /* @__PURE__ */ import_react10.default.createElement(CloseScreen, { onClose }));
};

// src/components/DevCommand/HomeScreen.tsx
var HomeScreen = ({ onScreenChange }) => {
  const { t } = useTranslation();
  const { site } = useSite();
  const bi = useWixCliAppBi();
  const { hasSinglePlatform } = usePlatform();
  const { hasExtensions, dashboardExtensions } = useExtensions();
  const { backendComponents } = useBackendComponents();
  use_input_default(async (input) => {
    if (input === "c") {
      bi.cliAction({
        question: t("dev_command.dev_site.change"),
        questionKey: "dev_command.dev_site.change",
        action: "change_site",
        key: input
      });
      onScreenChange(ScreenState.SiteSelector());
    }
  });
  return /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(Box_default, { gap: 1 }, /* @__PURE__ */ import_react11.default.createElement(
    Trans,
    {
      i18nKey: "dev_command.dev_site.current",
      values: { siteName: site.displayName },
      components: [/* @__PURE__ */ import_react11.default.createElement(Text, { bold: true, skin: "info" })]
    }
  ), /* @__PURE__ */ import_react11.default.createElement(Text, { skin: "secondary" }, /* @__PURE__ */ import_react11.default.createElement(
    Trans,
    {
      i18nKey: "dev_command.dev_site.change",
      components: [/* @__PURE__ */ import_react11.default.createElement(Key, { value: "C", skin: "secondary" })]
    }
  ))), /* @__PURE__ */ import_react11.default.createElement(Box_default, { paddingTop: 1, paddingBottom: 1, flexDirection: "column" }, !hasExtensions() ? /* @__PURE__ */ import_react11.default.createElement(
    Trans,
    {
      i18nKey: "general.platform.none",
      components: [/* @__PURE__ */ import_react11.default.createElement(Link, { url: "https://wix.to/b7o4Ml0" })]
    }
  ) : /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, hasSinglePlatform(PlatformType.Dashboard()) && backendComponents.length === 0 && dashboardExtensions.some(
    (dashboardExtension) => !(0, import_variant10.isType)(dashboardExtension, "DashboardModal")
  ) ? /* @__PURE__ */ import_react11.default.createElement(
    DashboardNumericViewer,
    {
      onViewMore: (selectorType) => onScreenChange(
        ScreenState.DashboardScreen({
          selectorType
        })
      )
    }
  ) : /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(
    Trans,
    {
      i18nKey: "general.view_changes",
      components: [/* @__PURE__ */ import_react11.default.createElement(Text, { skin: "secondary" })]
    }
  ), /* @__PURE__ */ import_react11.default.createElement(
    PlatformSelector,
    {
      onMultipleDashboardExtensionSelection: () => onScreenChange(ScreenState.DashboardScreen()),
      onMultipleBackendComponentSelection: () => onScreenChange(ScreenState.BackendScreen())
    }
  )))));
};

// src/components/DevCommand/SiteSelectorScreen.tsx
init_esm_shims();
var import_react12 = __toESM(require_react(), 1);

// src/components/CloseScreen/index.tsx
init_esm_shims();

// src/components/DevCommand/SiteSelectorScreen.tsx
var SiteSelectorScreen = ({ onScreenChange }) => {
  const { t } = useTranslation();
  const { model } = useProjectModel();
  const biLogger = useBiLogger();
  const { site, setSite } = useSite();
  const { reportError } = useErrorReporter();
  const [error, setError] = (0, import_react12.useState)(null);
  const handleError = (0, import_react12.useCallback)(
    (error2) => {
      reportError(error2);
      setError(error2);
    },
    [reportError, setError]
  );
  const handleSubmit = (0, import_react12.useCallback)(
    async (site2) => {
      try {
        await setSite(site2);
        onScreenChange(ScreenState.Home());
      } catch (e) {
        handleError(e);
      }
    },
    [setSite, onScreenChange, handleError]
  );
  return /* @__PURE__ */ import_react12.default.createElement(Box_default, { flexDirection: "column", gap: 1 }, /* @__PURE__ */ import_react12.default.createElement(Box_default, { gap: 1 }, /* @__PURE__ */ import_react12.default.createElement(PointerIcon, null), /* @__PURE__ */ import_react12.default.createElement(
    Trans,
    {
      i18nKey: "general.dev_site.current",
      values: { name: site.displayName }
    }
  )), /* @__PURE__ */ import_react12.default.createElement(Box_default, { flexDirection: "column" }, /* @__PURE__ */ import_react12.default.createElement(
    SiteSelector,
    {
      appId: model.config.appId,
      biLogger,
      onSubmit: handleSubmit,
      onError: handleError
    }
  ), error ? /* @__PURE__ */ import_react12.default.createElement(
    ErrorViewer,
    {
      error,
      systemErrorOverride: /* @__PURE__ */ import_react12.default.createElement(Alert, { type: "error" }, t("dev_command.site_selector.error"))
    }
  ) : null), /* @__PURE__ */ import_react12.default.createElement(CloseScreen, { onClose: () => onScreenChange(ScreenState.Home()) }));
};

// src/components/DevCommand/BackendScreen.tsx
init_esm_shims();
var import_react15 = __toESM(require_react(), 1);
var import_variant13 = __toESM(require_lib(), 1);

// src/components/DevCommand/BackendNumericViewer.tsx
init_esm_shims();
var import_react13 = __toESM(require_react(), 1);
var import_variant11 = __toESM(require_lib(), 1);
var MAX_BACKEND_COMPONENT = 9;
var MAX_SERVICE_PLUGINS = 4;
var MAX_EVENTS = 5;
var BackendNumericViewer = ({
  onViewMore,
  onSelect,
  onClose
}) => {
  const { t } = useTranslation();
  const bi = useWixCliAppBi();
  const { backendComponentsByType } = useBackendComponents();
  const servicePluginsData = backendComponentsByType.ServicePlugin.slice(
    0,
    backendComponentsByType.ServicePlugin.length > MAX_SERVICE_PLUGINS ? MAX_SERVICE_PLUGINS - 1 : backendComponentsByType.ServicePlugin.length
  );
  const servicePluginsShowMoreIndex = backendComponentsByType.ServicePlugin.length > servicePluginsData.length ? servicePluginsData.length + 1 : void 0;
  const servicePluginsCount = Math.max(
    servicePluginsData.length,
    servicePluginsShowMoreIndex ?? 0
  );
  const maxBackendEvents = Math.min(
    MAX_EVENTS,
    MAX_BACKEND_COMPONENT - servicePluginsCount
  );
  const backendEventsData = backendComponentsByType.Event.slice(
    0,
    backendComponentsByType.Event.length > maxBackendEvents ? maxBackendEvents - 1 : backendComponentsByType.Event.length
  );
  const backendEventsShowMoreIndex = backendComponentsByType.Event.length > backendEventsData.length ? backendEventsData.length + servicePluginsCount + 1 : void 0;
  const visibleItems = [
    ...servicePluginsData.map(
      (servicePlugin) => NumericOption.Item({
        title: servicePlugin.servicePlugin.name,
        value: servicePlugin
      })
    ),
    ...servicePluginsShowMoreIndex ? [NumericOption.ViewMore("ServicePlugin")] : [],
    ...backendEventsData.map(
      (event) => NumericOption.Item({
        title: event.title,
        value: event
      })
    ),
    ...backendEventsShowMoreIndex ? [NumericOption.ViewMore("Event")] : []
  ];
  const getLabelKey = (backendComponent) => {
    return (0, import_variant11.match)(
      backendComponent,
      (0, import_variant11.lookup)({
        Api: "general.backend_api_viewer.title",
        Event: "general.backend_events_viewer.title",
        ServicePlugin: "general.backend_plugin_viewer.title"
      })
    );
  };
  use_input_default((input) => {
    const inputNumber = Number(input);
    if (inputNumber > 0 && inputNumber <= visibleItems.length) {
      const item = visibleItems.at(inputNumber - 1);
      if (item) {
        (0, import_variant11.match)(item, {
          Item: (item2) => {
            bi.cliAction({
              question: t(getLabelKey(item2.value)),
              questionKey: getLabelKey(item2.value),
              action: item2.title,
              key: input
            });
            handleSelect(item2.value);
          },
          ViewMore: (viewMore) => {
            bi.cliAction({
              question: t("general.numeric_viewer.show_more"),
              questionKey: "general.numeric_viewer.show_more",
              action: "view_more",
              key: input
            });
            onViewMore(
              BackendScreenSelector.Arrow({
                backendComponentName: viewMore.payload
              })
            );
          }
        });
      }
    }
  });
  const handleSelect = (0, import_react13.useCallback)(
    (backendComponent) => {
      onSelect?.(backendComponent);
    },
    [onSelect]
  );
  const backendPlugins = visibleItems.slice(0, servicePluginsCount);
  const backendEvents = visibleItems.slice(servicePluginsCount);
  return /* @__PURE__ */ import_react13.default.createElement(Box_default, { flexDirection: "column", gap: 1 }, backendPlugins.length > 0 && /* @__PURE__ */ import_react13.default.createElement(
    NumericViewer,
    {
      startIndex: 0,
      titleKey: "general.backend_plugin_viewer.title",
      items: backendPlugins
    }
  ), backendEvents.length > 0 && /* @__PURE__ */ import_react13.default.createElement(
    NumericViewer,
    {
      startIndex: servicePluginsCount,
      titleKey: "general.backend_events_viewer.title",
      items: backendEvents
    }
  ), onClose && /* @__PURE__ */ import_react13.default.createElement(CloseScreen, { onClose }));
};

// src/components/DevCommand/BackendArrowViewer.tsx
init_esm_shims();
var import_react14 = __toESM(require_react(), 1);
var import_variant12 = __toESM(require_lib(), 1);
var BackendArrowViewer = ({
  backendComponentName,
  onClose,
  onSelect
}) => {
  const { t } = useTranslation();
  const bi = useWixCliAppBi();
  const { backendComponentsByType } = useBackendComponents();
  const getLabelKey = (0, import_react14.useCallback)(
    () => (0, import_variant12.match)(
      backendComponentName,
      (0, import_variant12.lookup)({
        Api: "dev_command.backend_apis_screen.select_label",
        Event: "dev_command.backend_events_screen.select_label",
        ServicePlugin: "dev_command.backend_plugins_screen.select_label"
      })
    ),
    [backendComponentName]
  );
  const getBackendComponentName = (backendComponent) => (0, import_variant12.isType)(backendComponent, "ServicePlugin") ? backendComponent.servicePlugin.name : backendComponent.title;
  const handleSubmit = (0, import_react14.useCallback)(
    (backendComponent) => {
      bi.cliAction({
        question: t(getLabelKey()),
        questionKey: getLabelKey(),
        action: getBackendComponentName(backendComponent),
        key: "enter"
      });
      onSelect?.(backendComponent);
    },
    [bi, getLabelKey, onSelect, t]
  );
  const options = (0, import_react14.useMemo)(() => {
    return backendComponentsByType[backendComponentName].map(
      (backendComponent, index) => ({
        key: index.toString(),
        title: getBackendComponentName(backendComponent),
        value: backendComponent
      })
    );
  }, [backendComponentsByType, backendComponentName]);
  return /* @__PURE__ */ import_react14.default.createElement(Box_default, { flexDirection: "column", gap: 1 }, /* @__PURE__ */ import_react14.default.createElement(Box_default, { flexDirection: "column" }, /* @__PURE__ */ import_react14.default.createElement(
    SelectInput,
    {
      label: t(getLabelKey()),
      options,
      onSubmit: ({ value: backendComponent }) => handleSubmit(backendComponent)
    }
  )), /* @__PURE__ */ import_react14.default.createElement(CloseScreen, { onClose }));
};

// src/components/DevCommand/BackendScreen.tsx
var BackendScreenSelector = (0, import_variant13.variant)({
  Arrow: (0, import_variant13.fields)(),
  Numeric: {}
});
var BackendScreen = ({
  onClose,
  onSelect,
  initialSelectorType = BackendScreenSelector.Numeric()
}) => {
  const [selectorType, setSelectorType] = (0, import_react15.useState)(initialSelectorType);
  return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, (0, import_variant13.match)(selectorType, {
    Arrow: ({ backendComponentName }) => /* @__PURE__ */ import_react15.default.createElement(
      BackendArrowViewer,
      {
        backendComponentName,
        onSelect,
        onClose
      }
    ),
    Numeric: () => /* @__PURE__ */ import_react15.default.createElement(
      BackendNumericViewer,
      {
        onViewMore: setSelectorType,
        onClose
      }
    )
  }));
};

// src/components/DevCommand/DevCommandScreens.tsx
var DevCommandScreens = () => {
  const [screen, setScreen] = (0, import_react16.useState)(ScreenState.Home());
  return (0, import_variant14.match)(screen, {
    Home: () => /* @__PURE__ */ import_react16.default.createElement(HomeScreen, { onScreenChange: setScreen }),
    SiteSelector: () => /* @__PURE__ */ import_react16.default.createElement(SiteSelectorScreen, { onScreenChange: setScreen }),
    DashboardScreen: ({ selectorType }) => /* @__PURE__ */ import_react16.default.createElement(
      DashboardScreen,
      {
        initialSelectorType: selectorType,
        onSelect: () => setScreen(ScreenState.Home()),
        onClose: () => setScreen(ScreenState.Home())
      }
    ),
    BackendScreen: ({ selectorType }) => /* @__PURE__ */ import_react16.default.createElement(
      BackendScreen,
      {
        initialSelectorType: selectorType,
        onSelect: () => setScreen(ScreenState.Home()),
        onClose: () => setScreen(ScreenState.Home())
      }
    )
  });
};

// src/components/DevCommand/TunnelingConsent.tsx
init_esm_shims();
var import_react17 = __toESM(require_react(), 1);
var import_variant15 = __toESM(require_lib(), 1);
var TunnelingConsent = ({ children }) => {
  const exit = useExit();
  const { t } = useTranslation();
  const { backendComponents } = useBackendComponents();
  const [approved, setApproved] = (0, import_react17.useState)();
  const { status } = useAsync(async () => {
    const config = await readUserConfig();
    if (config.tunneling) {
      setApproved(true);
    }
    return config;
  }, []);
  if (backendComponents.length === 0 || approved) {
    return children;
  }
  return /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, (0, import_variant15.match)(status, {
    Success: () => /* @__PURE__ */ import_react17.default.createElement(
      ConfirmInput,
      {
        label: t("dev_command.tunneling.confirm"),
        initialValue: true,
        onSubmit: async (approved2) => {
          setApproved(approved2);
          await updateUserConfig({ tunneling: approved2 });
          if (!approved2) {
            exit();
          }
        }
      }
    ),
    Error: () => null,
    Loading: () => null
  }), approved === false && /* @__PURE__ */ import_react17.default.createElement(Text, { skin: "error" }, /* @__PURE__ */ import_react17.default.createElement(Trans, { i18nKey: "dev_command.tunneling.abort_dev" })));
};

// src/components/DevCommand/RequiredAppsWarning.tsx
init_esm_shims();
var import_react18 = __toESM(require_react(), 1);
var import_variant16 = __toESM(require_lib(), 1);
var RequiredAppsWarning = ({ children }) => {
  const { logger } = useDevEnvironment();
  const { site } = useSite();
  const { model } = useProjectModel();
  const { getRequiredApps } = useDevCenterClient();
  const { getSiteInstalledApps } = useMetasiteManagerClient();
  const { t } = useTranslation();
  const { status: requiredAppsStatus } = useAsync(async () => {
    const requiredApps = await getRequiredApps(model.config.appId);
    if (requiredApps.length === 0) {
      return;
    }
    const siteInstalledApps = await getSiteInstalledApps(site.id);
    const missingRequiredApps = requiredApps.filter(
      (requiredApp) => !siteInstalledApps.includes(requiredApp.id)
    );
    if (missingRequiredApps.length === 0) {
      return;
    }
    logger.warn(
      /* @__PURE__ */ import_react18.default.createElement(Alert, { type: "warning" }, t("dev_command.required_apps.warning", {
        requiredAppNames: missingRequiredApps.map((app) => app.name).join(", ")
      }))
    );
  }, []);
  return (0, import_variant16.match)(requiredAppsStatus, {
    Loading: () => /* @__PURE__ */ import_react18.default.createElement(Spinner, { text: t("dev_command.required_apps.loading") }),
    Error: () => null,
    Success: () => children
  });
};

// src/components/DevCommand/DevScreenBorder.tsx
init_esm_shims();
var import_react19 = __toESM(require_react(), 1);
var DevScreenBorder = ({ children }) => {
  return /* @__PURE__ */ import_react19.default.createElement(
    Box_default,
    {
      flexDirection: "column",
      borderTop: true,
      borderLeft: false,
      borderBottom: false,
      borderRight: false,
      borderStyle: "round",
      borderColor: "blueBright"
    },
    children
  );
};

// src/components/DevCommand/DevCommand.tsx
var DevCommand = ({ https, origin, port }) => {
  const logger = (0, import_react20.useMemo)(() => createLogger({ timestamp: true }), []);
  return /* @__PURE__ */ import_react20.default.createElement(SiteProvider, null, /* @__PURE__ */ import_react20.default.createElement(TunnelingConsent, null, /* @__PURE__ */ import_react20.default.createElement(
    DevEnvironmentProvider,
    {
      logger,
      https,
      origin,
      port
    },
    /* @__PURE__ */ import_react20.default.createElement(AppComponentsMigrations, null, /* @__PURE__ */ import_react20.default.createElement(EditorInstallation, null, /* @__PURE__ */ import_react20.default.createElement(RequiredAppsWarning, null, /* @__PURE__ */ import_react20.default.createElement(ExtensionDataProvider, null, /* @__PURE__ */ import_react20.default.createElement(DevScreenBorder, null, /* @__PURE__ */ import_react20.default.createElement(DevCommandScreens, null))))))
  )));
};
export {
  DevCommand
};
//# sourceMappingURL=DevCommand-P4HQDQ42.js.map