import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  VELO_DEPENDENCIES_CONFIG_FILENAME
} from "./chunk-4BLGYECY.js";
import {
  createLogger
} from "./chunk-3QMRQKKR.js";
import {
  terminalLink
} from "./chunk-YL4347CI.js";
import {
  source_default
} from "./chunk-AFPDHQYI.js";
import {
  WIX_CONFIG_FILENAME,
  WIX_LOCK_FILENAME
} from "./chunk-YT5BPQDJ.js";
import {
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site-old/src/logger.ts
init_esm_shims();
function createLogger2({ t }) {
  const logger = createLogger();
  const logAborting = () => logger.log(source_default.dim(t("general.aborting")));
  const logSyncingLocalCode = () => {
    const loader = logger.logWithLoader({
      text: t("dev_command.syncing_local_code_start")
    });
    return {
      success: () => {
        const message = t("dev_command.syncing_local_code_end");
        loader.succeed(message);
        return message;
      },
      fail: () => loader.stop()
    };
  };
  const logUpdatedLocalCodeToRevision = ({
    revision
  }) => {
    const message = t("dev_command.revision_created", {
      revision,
      configFileName: WIX_CONFIG_FILENAME
    });
    logger.log(message);
    return message;
  };
  const logRecoverableFailureToRemoveTypesDir = (error) => {
    const cause = getErrorMessage(error);
    logger.logWithLoader(t("dev_command.failed_to_delete_types_dir", { cause })).fail();
    logNewLine();
  };
  const logSyncingTypesToRevision = (revision) => {
    const loader = logger.logWithLoader({
      text: t("dev_command.syncing_types_to_revision_start", { revision })
    });
    return {
      success: () => {
        loader.succeed(
          t("dev_command.syncing_types_to_revision_end", { revision })
        );
      },
      fail: () => {
        loader.fail(t("dev_command.syncing_types_to_revision_fail_line1"));
        logger.log(
          `  ${t("dev_command.syncing_types_to_revision_fail_line2")}`
        );
        logNewLine();
        logger.log(
          `  ${t("dev_command.syncing_types_to_revision_fail_line3")}`
        );
        logNewLine();
      }
    };
  };
  const logSyncingPagesToRevision = (revision) => {
    const loader = logger.logWithLoader({
      text: t("dev_command.syncing_pages_to_revision_start", { revision })
    });
    return {
      success: () => {
        loader.succeed(
          t("dev_command.syncing_pages_to_revision_end", { revision })
        );
      },
      fail: () => loader.fail()
    };
  };
  const logNewLine = () => logger.log("");
  const logDependencyInstalling = (dependencyName) => {
    const loader = logger.logWithLoader({
      text: source_default.yellow(
        t("dependencies.installing_dependency", {
          dependency: source_default.bold.yellow(dependencyName)
        })
      )
    });
    return {
      success: () => {
        loader.succeed(
          source_default.green(
            t("dependencies.dependency_installed", {
              dependency: source_default.bold.green(dependencyName)
            })
          )
        );
      },
      fail: () => loader.stop()
    };
  };
  const logAllDependenciesInstalling = () => {
    const loader = logger.logWithLoader({
      text: source_default.yellow(t("dependencies.installing_all_dependencies"))
    });
    return {
      success: () => {
        loader.succeed(
          source_default.green(t("dependencies.all_dependencies_installed"))
        );
      },
      fail: () => loader.stop()
    };
  };
  const logDependencyUninstalling = (dependencyName) => {
    const loader = logger.logWithLoader({
      text: source_default.yellow(
        t("dependencies.uninstalling_dependency", {
          dependency: source_default.bold.yellow(dependencyName)
        })
      )
    });
    return {
      success: () => {
        loader.succeed(
          source_default.green(
            t("dependencies.dependency_uninstalled", {
              dependency: source_default.bold.green(dependencyName)
            })
          )
        );
      },
      fail: () => loader.stop()
    };
  };
  const logOpeningBrowser = (https) => {
    logger.log(t("dev_command.opening_browser"));
    if (https) {
      logger.log(t("dev_command.dev_server_url.approve_cert"));
    }
  };
  const logNoOpenedTab = (devEditorUrl) => {
    const message = t("dev_command.no_open_editor", {
      key: source_default.bold.italic("e"),
      link: devEditorUrl
    });
    logger.log(message);
    return message;
  };
  const logPublishRevision = ({
    branchName,
    isLocalDeployment,
    currentRevision,
    latestRevision,
    preview
  }) => logger.log(`
  ${!preview ? "" : `${t("publish_command.publish_details_preview")}
  ${source_default.underline(
    source_default.blue(preview.deploymentShortUrl ?? preview.deploymentUrl)
  )}`}

  ${source_default.bold(t("publish_command.publish_details_about_to_publish"))}

    ${isLocalDeployment ? t("publish_command.prompt_what_to_publish_choice_local") : branchName ? t("publish_command.prompt_what_to_publish_choice_remote", {
    branchName
  }) : t("publish_command.prompt_what_to_publish_choice_remote_fallback")}
    ${t("publish_command.publish_details_ui_version", {
    revision: currentRevision
  })}
    ${latestRevision && Number(latestRevision) > Number(currentRevision) ? `
  ${source_default.red(
    `${source_default.bold(
      t(
        "publish_command.publish_details_newer_editor_version_caution_title"
      )
    )}: ${t(
      "publish_command.publish_details_newer_editor_version_caution_details"
    )} ${source_default.underline(
      source_default.blue(
        terminalLink(
          t(
            "publish_command.publish_details_newer_editor_version_link_text"
          ),
          t(
            "publish_command.publish_details_newer_editor_version_link_url"
          )
        )
      )
    )}`
  )}
` : ""}
    ${isLocalDeployment ? source_default.red(
    `${source_default.bold(
      t("publish_command.publish_details_local_caution_title")
    )}: ${t("publish_command.publish_details_local_caution_details")}
`
  ) : ""}`);
  const logPipelineErrorInformation = ({
    pipelinesDescription
  }) => {
    const errorBadge = t("publish_command.publish_pipeline_error_badge");
    const taskDone = source_default.green(t("publish_command.generic_task_done"));
    const taskFailed = source_default.red(t("publish_command.generic_task_failed"));
    const divider = "-".repeat(30);
    const padding = "  ";
    const normalizeText = (text) => {
      return text.split("\n").map((line, index) => {
        if (line.trim() && index) {
          return `${padding}${line}`;
        }
        return line;
      }).join("\n");
    };
    let output = "";
    output += `
${source_default.red(errorBadge)} ${t(
      "publish_command.publish_pipeline_error_title"
    )}
`;
    output += `
${divider}
`;
    output += `Status: ${taskFailed}`;
    const tasksDescriptions = pipelinesDescription[0]?.tasksDescriptions;
    if (tasksDescriptions) {
      for (const task of tasksDescriptions) {
        output += `

* ${task.taskName}... ${task.status === "ERROR" ? `${taskFailed}:` : taskDone}
`;
        if (task.description) {
          const errorDescription = JSON.parse(task.description);
          for (const fileName in errorDescription) {
            output += `
${padding}${errorBadge} ${fileName} | `;
            output += normalizeText(errorDescription[fileName].toString());
          }
        }
      }
    }
    output += `
${divider}`;
    logger.log(output);
  };
  const logPublishing = () => {
    const loader = logger.logWithLoader({
      text: t("publish_command.publishing")
    });
    return {
      success: ({ siteUrl }) => {
        loader.succeed(
          t("publish_command.published", {
            url: source_default.underline(source_default.blue(siteUrl))
          })
        );
      },
      fail: () => loader.stop()
    };
  };
  const logDeploying = () => {
    const loader = logger.logWithLoader({
      text: t("publish_command.deploying")
    });
    return {
      success: () => {
        loader.succeed(
          `${t("publish_command.deploying")} ${source_default.green(
            t("publish_command.generic_task_done")
          )}`
        );
      },
      fail: () => loader.fail(
        `${t("publish_command.deploying")} ${source_default.red(
          t("publish_command.generic_task_failed")
        )}`
      )
    };
  };
  const logForceDeployWarning = () => logger.log(
    source_default.red(
      `${source_default.bold(
        t("publish_command.publish_with_errors_caution_title")
      )}: ${t("publish_command.publish_with_errors_caution_details")}
`
    )
  );
  const logPublishAborted = () => logger.log(`
${t("publish_command.publish_aborted")}`);
  const logCreatingPreview = () => logger.log(`
${t("preview_command.creating_preview")}
`);
  const logPreviewCreated = (url) => logger.log(t("preview_command.preview_created", { url: source_default.green(url) }));
  const logPreviewUnsupported = () => logger.log(t("preview_command.preview_unsupported"));
  const logFailedToGetLatestRevision = (error) => {
    const cause = error instanceof Error ? error.stack : error;
    logger.log(t("publish_command.failed_getting_latest_revision", { cause }));
  };
  const logMigratingToAnyNpm = () => {
    logger.log(
      `${t("install_command.migrating_to_any_npm", {
        wixLockFileName: WIX_LOCK_FILENAME,
        configFileName: VELO_DEPENDENCIES_CONFIG_FILENAME
      })}
`
    );
    logger.log(
      source_default.yellow(t("install_command.starting_migrating_to_any_npm"))
    );
  };
  const logMigrationToAnyNpmCompletedSuccessfully = () => logger.log(source_default.green(t("install_command.migration_to_any_npm_success")));
  const logMigrationToAnyNpmFailed = () => {
    logger.log(source_default.red(t("install_command.migration_to_any_npm_failed")));
  };
  const logPreviewing = () => {
    const loader = logger.logWithLoader({
      text: t("publish_command.creating_preview")
    });
    return {
      success: () => loader.succeed(t("publish_command.creating_preview_success")),
      fail: () => loader.fail(t("publish_command.creating_preview_failed")),
      stop: () => loader.stop()
    };
  };
  return {
    t,
    logAborting,
    logSyncingLocalCode,
    logRecoverableFailureToRemoveTypesDir,
    logUpdatedLocalCodeToRevision,
    logSyncingPagesToRevision,
    logSyncingTypesToRevision,
    logDependencyInstalling,
    logDependencyUninstalling,
    logAllDependenciesInstalling,
    logOpeningBrowser,
    logNoOpenedTab,
    logPublishRevision,
    logPublishing,
    logPublishAborted,
    logCreatingPreview,
    logPreviewCreated,
    logPreviewUnsupported,
    logNewLine,
    logFailedToGetLatestRevision,
    logMigratingToAnyNpm,
    logMigrationToAnyNpmCompletedSuccessfully,
    logMigrationToAnyNpmFailed,
    logDeploying,
    logForceDeployWarning,
    logPipelineErrorInformation,
    logPreviewing
  };
}
function getErrorMessage(cause) {
  return cause instanceof Error ? cause.message : JSON.stringify(cause);
}

export {
  createLogger2 as createLogger
};
//# sourceMappingURL=chunk-YKAYM32Q.js.map