import {
  reportAnalyticsEvent
} from "../chunk-3M3R5CPM.js";
import {
  getNextDeprecationDate
} from "../chunk-7NHT37SK.js";
import "../chunk-VSLR7ET4.js";
import "../chunk-5VTN2TLO.js";
import "../chunk-VKTUG2OW.js";
import "../chunk-BYPQXSAL.js";
import "../chunk-7R4IGMDH.js";
import "../chunk-NLUGD7PZ.js";
import {
  addSensitiveMetadata,
  getAllSensitiveMetadata,
  outputDebug,
  renderWarning
} from "../chunk-ZTT46LWS.js";
import "../chunk-XEDHKQZA.js";
import "../chunk-27ILOE3X.js";
import "../chunk-SNOECVP4.js";
import "../chunk-6XKWVDB6.js";
import "../chunk-UBB7JKND.js";
import "../chunk-T2GATXSP.js";
import "../chunk-XVNW332R.js";
import "../chunk-A3JXD7N7.js";
import "../chunk-7Q3MMWAC.js";
import "../chunk-MX4RJDBM.js";
import "../chunk-NB4NLOEJ.js";
import "../chunk-522OB3EU.js";
import "../chunk-PNN7RS7Y.js";
import {
  init_cjs_shims
} from "../chunk-POZ5MGPT.js";

// src/hooks/postrun.ts
init_cjs_shims();

// ../cli-kit/dist/public/node/hooks/postrun.js
init_cjs_shims();

// ../cli-kit/dist/public/node/hooks/deprecations.js
init_cjs_shims();
var postrun = (Command) => {
  let nextDeprecationDate = getNextDeprecationDate();
  if (nextDeprecationDate) {
    let forThemes = Command.id.includes("theme");
    renderUpgradeWarning(nextDeprecationDate, forThemes);
  }
};
function renderUpgradeWarning(upgradeByDate, forThemes) {
  let headline = `Upgrade to the latest CLI version by ${new Intl.DateTimeFormat("default", {
    year: "numeric",
    month: "long",
    day: "numeric"
  }).format(upgradeByDate)}.`;
  renderWarning({
    headline,
    body: "This command requires an upgrade to continue working as intended.",
    nextSteps: [["Run", { command: "upgrade" }, "to", {
      link: {
        label: "upgrade Shopify CLI",
        url: forThemes ? "https://shopify.dev/docs/themes/tools/cli#upgrade-shopify-cli" : "https://shopify.dev/docs/apps/tools/cli#upgrade-shopify-cli"
      }
    }]]
  });
}

// ../cli-kit/dist/public/node/hooks/postrun.js
var hook = async ({ config, Command }) => {
  await detectStopCommand(Command), await reportAnalyticsEvent({ config, exitMode: "ok" }), postrun(Command);
  let command = Command.id.replace(/:/g, " ");
  outputDebug(`Completed command ${command}`);
};
async function detectStopCommand(commandClass) {
  let currentTime = (/* @__PURE__ */ new Date()).getTime();
  if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, "analyticsStopCommand")) {
    let stopCommand = commandClass.analyticsStopCommand();
    if (stopCommand) {
      let { commandStartOptions } = getAllSensitiveMetadata();
      await addSensitiveMetadata(() => ({
        commandStartOptions: {
          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
          ...commandStartOptions,
          startTime: currentTime,
          startCommand: stopCommand
        }
      }));
    }
  }
}
export {
  hook as default
};
//# sourceMappingURL=postrun.js.map
